summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChristopher Koch <c@chrisko.ch>2019-01-20 04:08:48 +0000
committerinsomniac <insomniacslk@users.noreply.github.com>2019-01-26 23:34:26 +0000
commit5604533269d24e72911e36f94d335337849decae (patch)
treea0a6e2437ec8c966493607c4d6e5584f7a4488d4
parent8936b6e4e714e0b682e37fa81fde29606e58e7c2 (diff)
dhcpv6: clean up MessageType
- print unknown message type numbers. - unexport unneeded map of strings.
-rw-r--r--dhcpv6/types.go19
1 files changed, 11 insertions, 8 deletions
diff --git a/dhcpv6/types.go b/dhcpv6/types.go
index 4629cf6..f842ff1 100644
--- a/dhcpv6/types.go
+++ b/dhcpv6/types.go
@@ -1,13 +1,15 @@
package dhcpv6
-// from http://www.networksorcery.com/enp/protocol/dhcpv6.htm
+import (
+ "fmt"
+)
// MessageType represents the kind of DHCPv6 message.
type MessageType uint8
-// The different kinds of DHCPv6 message types.
+// The DHCPv6 message types defined per RFC 3315, Section 5.3.
const (
- // MessageTypeNone is used internally and is not part of the RFC
+ // MessageTypeNone is used internally and is not part of the RFC.
MessageTypeNone MessageType = 0
MessageTypeSolicit MessageType = 1
MessageTypeAdvertise MessageType = 2
@@ -28,16 +30,17 @@ const (
MessageTypeLeaseQueryData MessageType = 17
)
+// String prints the message type name.
func (m MessageType) String() string {
- if s, ok := MessageTypeToStringMap[m]; ok {
+ if s, ok := messageTypeToStringMap[m]; ok {
return s
}
- return "Unknown"
+ return fmt.Sprintf("unknown (%d)", m)
}
-// MessageTypeToStringMap contains the mapping of MessageTypes to human-readable
-// strings.
-var MessageTypeToStringMap = map[MessageType]string{
+// messageTypeToStringMap contains the mapping of MessageTypes to
+// human-readable strings.
+var messageTypeToStringMap = map[MessageType]string{
MessageTypeSolicit: "SOLICIT",
MessageTypeAdvertise: "ADVERTISE",
MessageTypeRequest: "REQUEST",