diff options
Diffstat (limited to 'dhcpv6')
-rw-r--r-- | dhcpv6/dhcpv6message.go | 2 | ||||
-rw-r--r-- | dhcpv6/dhcpv6relay.go | 8 | ||||
-rw-r--r-- | dhcpv6/duid.go | 17 | ||||
-rw-r--r-- | dhcpv6/option_archtype.go | 3 | ||||
-rw-r--r-- | dhcpv6/option_statuscode.go | 2 | ||||
-rw-r--r-- | dhcpv6/types.go | 11 |
6 files changed, 12 insertions, 31 deletions
diff --git a/dhcpv6/dhcpv6message.go b/dhcpv6/dhcpv6message.go index cb17624..26be5f1 100644 --- a/dhcpv6/dhcpv6message.go +++ b/dhcpv6/dhcpv6message.go @@ -252,7 +252,7 @@ func (d *DHCPv6Message) SetMessage(messageType MessageType) { } func (d *DHCPv6Message) MessageTypeToString() string { - return MessageTypeToString(d.messageType) + return d.messageType.String() } func (d *DHCPv6Message) TransactionID() uint32 { diff --git a/dhcpv6/dhcpv6relay.go b/dhcpv6/dhcpv6relay.go index 4eabefe..220fd3d 100644 --- a/dhcpv6/dhcpv6relay.go +++ b/dhcpv6/dhcpv6relay.go @@ -3,7 +3,6 @@ package dhcpv6 import ( "errors" "fmt" - "log" "net" ) @@ -22,7 +21,7 @@ func (r *DHCPv6Relay) Type() MessageType { } func (r *DHCPv6Relay) MessageTypeToString() string { - return MessageTypeToString(r.messageType) + return r.messageType.String() } func (r *DHCPv6Relay) String() string { @@ -63,11 +62,6 @@ func (r *DHCPv6Relay) ToBytes() []byte { return ret } -func (r *DHCPv6Relay) MessageType() MessageType { - log.Printf("Warning: DHCPv6Relay.MessageType() is deprecated and will be removed, use DHCPv6Relay.Type() instead") - return r.messageType -} - func (r *DHCPv6Relay) SetMessageType(messageType MessageType) { // not enforcing if message type is not a RELAY_FORW or a RELAY_REPL message r.messageType = messageType diff --git a/dhcpv6/duid.go b/dhcpv6/duid.go index 36da9cd..8530827 100644 --- a/dhcpv6/duid.go +++ b/dhcpv6/duid.go @@ -25,6 +25,13 @@ var DuidTypeToString = map[DuidType]string{ DUID_UUID: "DUID-UUID", } +func (d DuidType) String() string { + if dtype, ok := DuidTypeToString[d]; ok { + return dtype + } + return "Unknown" +} + type Duid struct { Type DuidType HwType iana.HwTypeType // for DUID-LLT and DUID-LL. Ignored otherwise. RFC 826 @@ -79,14 +86,6 @@ func (d *Duid) ToBytes() []byte { } func (d *Duid) String() string { - dtype := DuidTypeToString[d.Type] - if dtype == "" { - dtype = "Unknown" - } - hwtype := iana.HwTypeToString[d.HwType] - if hwtype == "" { - hwtype = "Unknown" - } var hwaddr string if d.HwType == iana.HwTypeEthernet { for _, b := range d.LinkLayerAddr { @@ -96,7 +95,7 @@ func (d *Duid) String() string { hwaddr = hwaddr[:len(hwaddr)-1] } } - return fmt.Sprintf("DUID{type=%v hwtype=%v hwaddr=%v}", dtype, hwtype, hwaddr) + return fmt.Sprintf("DUID{type=%v hwtype=%v hwaddr=%v}", d.Type.String(), d.HwType.String(), hwaddr) } func DuidFromBytes(data []byte) (*Duid, error) { diff --git a/dhcpv6/option_archtype.go b/dhcpv6/option_archtype.go index 231eddd..636d10f 100644 --- a/dhcpv6/option_archtype.go +++ b/dhcpv6/option_archtype.go @@ -39,8 +39,7 @@ func (op *OptClientArchType) Length() int { func (op *OptClientArchType) String() string { atStrings := make([]string, 0) for _, at := range op.ArchTypes { - name := iana.ArchTypeToString(at) - atStrings = append(atStrings, name) + atStrings = append(atStrings, at.String()) } return fmt.Sprintf("OptClientArchType{archtype=%v}", strings.Join(atStrings, ", ")) } diff --git a/dhcpv6/option_statuscode.go b/dhcpv6/option_statuscode.go index 11f1cbf..74d200c 100644 --- a/dhcpv6/option_statuscode.go +++ b/dhcpv6/option_statuscode.go @@ -38,7 +38,7 @@ func (op *OptStatusCode) Length() int { func (op *OptStatusCode) String() string { return fmt.Sprintf("OptStatusCode{code=%s (%d), message=%v}", - iana.StatusCodeToString(op.StatusCode), op.StatusCode, + op.StatusCode.String(), op.StatusCode, string(op.StatusMessage)) } diff --git a/dhcpv6/types.go b/dhcpv6/types.go index 9c9f84f..4629cf6 100644 --- a/dhcpv6/types.go +++ b/dhcpv6/types.go @@ -1,9 +1,5 @@ package dhcpv6 -import ( - "log" -) - // from http://www.networksorcery.com/enp/protocol/dhcpv6.htm // MessageType represents the kind of DHCPv6 message. @@ -39,13 +35,6 @@ func (m MessageType) String() string { return "Unknown" } -// MessageTypeToString converts a MessageType to a human-readable string -// representation. -func MessageTypeToString(t MessageType) string { - log.Printf("Warning: MessageTypeToString is deprecated and will be removed, use MessageType.String() instead") - return t.String() -} - // MessageTypeToStringMap contains the mapping of MessageTypes to human-readable // strings. var MessageTypeToStringMap = map[MessageType]string{ |