diff options
author | MikoĊaj Walczak <mikiwalczak+github@gmail.com> | 2018-08-21 17:22:44 +0100 |
---|---|---|
committer | insomniac <insomniacslk@users.noreply.github.com> | 2018-08-21 17:22:43 +0100 |
commit | 8a82f8dbe600ba1d30c2c57bd2460cac48efbbef (patch) | |
tree | bb78fe633ea6950e84ccd648faa201f6883e4edb /dhcpv6 | |
parent | 44ed3cf425236abe316ad6227c486ad6371c0703 (diff) |
Remove depracated function calls from the library (#145)
Diffstat (limited to 'dhcpv6')
-rw-r--r-- | dhcpv6/dhcpv6message.go | 6 | ||||
-rw-r--r-- | dhcpv6/dhcpv6relay.go | 6 | ||||
-rw-r--r-- | dhcpv6/dhcpv6relay_test.go | 4 |
3 files changed, 9 insertions, 7 deletions
diff --git a/dhcpv6/dhcpv6message.go b/dhcpv6/dhcpv6message.go index 7ee00ad..48b82e9 100644 --- a/dhcpv6/dhcpv6message.go +++ b/dhcpv6/dhcpv6message.go @@ -239,7 +239,7 @@ func (d *DHCPv6Message) Type() MessageType { } func (d *DHCPv6Message) SetMessage(messageType MessageType) { - msgString := MessageTypeToString(messageType) + msgString := messageType.String() if msgString == "" { log.Printf("Warning: unknown DHCPv6 message type: %v", messageType) } @@ -315,7 +315,7 @@ func (d *DHCPv6Message) IsOptionRequested(requested OptionCode) bool { func (d *DHCPv6Message) String() string { return fmt.Sprintf("DHCPv6Message(messageType=%v transactionID=0x%06x, %d options)", - d.MessageTypeToString(), d.TransactionID(), len(d.options), + d.Type().String(), d.TransactionID(), len(d.options), ) } @@ -324,7 +324,7 @@ func (d *DHCPv6Message) Summary() string { "DHCPv6Message\n"+ " messageType=%v\n"+ " transactionid=0x%06x\n", - d.MessageTypeToString(), + d.Type().String(), d.TransactionID(), ) ret += " options=[" diff --git a/dhcpv6/dhcpv6relay.go b/dhcpv6/dhcpv6relay.go index 5c30bad..4eabefe 100644 --- a/dhcpv6/dhcpv6relay.go +++ b/dhcpv6/dhcpv6relay.go @@ -3,6 +3,7 @@ package dhcpv6 import ( "errors" "fmt" + "log" "net" ) @@ -27,7 +28,7 @@ func (r *DHCPv6Relay) MessageTypeToString() string { func (r *DHCPv6Relay) String() string { ret := fmt.Sprintf( "DHCPv6Relay(messageType=%v hopcount=%v, linkaddr=%v, peeraddr=%v, %d options)", - r.MessageTypeToString(), r.hopCount, r.linkAddr, r.peerAddr, len(r.options), + r.Type().String(), r.hopCount, r.linkAddr, r.peerAddr, len(r.options), ) return ret } @@ -40,7 +41,7 @@ func (r *DHCPv6Relay) Summary() string { " linkaddr=%v\n"+ " peeraddr=%v\n"+ " options=%v\n", - r.MessageTypeToString(), + r.Type().String(), r.hopCount, r.linkAddr, r.peerAddr, @@ -63,6 +64,7 @@ func (r *DHCPv6Relay) ToBytes() []byte { } func (r *DHCPv6Relay) MessageType() MessageType { + log.Printf("Warning: DHCPv6Relay.MessageType() is deprecated and will be removed, use DHCPv6Relay.Type() instead") return r.messageType } diff --git a/dhcpv6/dhcpv6relay_test.go b/dhcpv6/dhcpv6relay_test.go index fe1b840..0710c5d 100644 --- a/dhcpv6/dhcpv6relay_test.go +++ b/dhcpv6/dhcpv6relay_test.go @@ -19,7 +19,7 @@ func TestDHCPv6Relay(t *testing.T) { // options is left empty here for testing purposes, even if it's // mandatory to have at least a relay message option } - if mt := r.MessageType(); mt != MessageTypeRelayForward { + if mt := r.Type(); mt != MessageTypeRelayForward { t.Fatalf("Invalid message type. Expected %v, got %v", MessageTypeRelayForward, mt) } if hc := r.HopCount(); hc != 10 { @@ -40,7 +40,7 @@ func TestDHCPv6RelaySettersAndGetters(t *testing.T) { r := DHCPv6Relay{} // set and get message type r.SetMessageType(MessageTypeRelayReply) - if mt := r.MessageType(); mt != MessageTypeRelayReply { + if mt := r.Type(); mt != MessageTypeRelayReply { t.Fatalf("Invalid message type. Expected %v, got %v", MessageTypeRelayReply, mt) } // set and get hop count |