diff options
author | insomniac <insomniacslk@users.noreply.github.com> | 2018-08-19 19:58:01 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-19 19:58:01 +0100 |
commit | c0dc38b656ec84a401a99f2f97f6af79c4e66398 (patch) | |
tree | 11892b32733d2cee916f8236c5afe10f40bcbab2 /dhcpv6 | |
parent | ececa3f5129cbc0bca341ea87a14bfaa8576156d (diff) |
Added String methods for types (#140)
* Added String methods for types
* Reverted change on bsdp.OptionCode
Diffstat (limited to 'dhcpv6')
-rw-r--r-- | dhcpv6/types.go | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/dhcpv6/types.go b/dhcpv6/types.go index 1ef5938..9c9f84f 100644 --- a/dhcpv6/types.go +++ b/dhcpv6/types.go @@ -1,5 +1,9 @@ package dhcpv6 +import ( + "log" +) + // from http://www.networksorcery.com/enp/protocol/dhcpv6.htm // MessageType represents the kind of DHCPv6 message. @@ -28,13 +32,18 @@ const ( MessageTypeLeaseQueryData MessageType = 17 ) +func (m MessageType) String() string { + if s, ok := MessageTypeToStringMap[m]; ok { + return s + } + return "Unknown" +} + // MessageTypeToString converts a MessageType to a human-readable string // representation. func MessageTypeToString(t MessageType) string { - if m, ok := MessageTypeToStringMap[t]; ok { - return m - } - return "Unknown" + 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 |