summaryrefslogtreecommitdiffhomepage
path: root/iana
diff options
context:
space:
mode:
authorinsomniac <insomniacslk@users.noreply.github.com>2018-05-08 18:13:53 +0200
committerGitHub <noreply@github.com>2018-05-08 18:13:53 +0200
commitf371c3544b9bdfd70ceab7d96895e6069cd46462 (patch)
tree7b693f66169c775ece2c8850d04a8186abcf5b05 /iana
parent94cb7f39d4813bfd059ccd990f239124525ef564 (diff)
OptStatusCode: public fields, proper codes, and tests (#61)
Diffstat (limited to 'iana')
-rw-r--r--iana/statuscodes.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/iana/statuscodes.go b/iana/statuscodes.go
new file mode 100644
index 0000000..47e8110
--- /dev/null
+++ b/iana/statuscodes.go
@@ -0,0 +1,32 @@
+package iana
+
+// StatusCode represents a IANA status code for DHCPv6
+type StatusCode uint16
+
+// IANA status codes as defined by rfc 3315 par. 24..4
+const (
+ StatusSuccess StatusCode = 0
+ StatusUnspecFail StatusCode = 1
+ StatusNoAddrsAvail StatusCode = 2
+ StatusNoBinding StatusCode = 3
+ StatusNotOnLink StatusCode = 4
+ StatusUseMulticast StatusCode = 5
+)
+
+// StatusCodeToString returns a mnemonic name for a given status code
+func StatusCodeToString(s StatusCode) string {
+ if sc := StatusCodeToStringMap[s]; sc != "" {
+ return sc
+ }
+ return "Unknown"
+}
+
+// StatusCodeToStringMap maps status codes to their names
+var StatusCodeToStringMap = map[StatusCode]string{
+ StatusSuccess: "Success",
+ StatusUnspecFail: "UnspecFail",
+ StatusNoAddrsAvail: "NoAddrsAvail",
+ StatusNoBinding: "NoBinding",
+ StatusNotOnLink: "NotOnLink",
+ StatusUseMulticast: "UseMulticast",
+}