summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChris Koch <chrisko@google.com>2019-12-28 03:06:13 -0800
committerinsomniac <insomniacslk@users.noreply.github.com>2020-03-05 15:51:55 +0000
commit69252213a65449f6984b24e912979876723ce066 (patch)
tree8f61a66d91ccfe08f3b64e162689788f18091c5c
parent3b6f190b53285624aaba864ca57892d3b2a2bec4 (diff)
v6: simplify GetTransactionID
Signed-off-by: Chris Koch <chrisko@google.com>
-rw-r--r--dhcpv6/dhcpv6.go15
1 files changed, 4 insertions, 11 deletions
diff --git a/dhcpv6/dhcpv6.go b/dhcpv6/dhcpv6.go
index 41b4726..a8f7bdc 100644
--- a/dhcpv6/dhcpv6.go
+++ b/dhcpv6/dhcpv6.go
@@ -1,7 +1,6 @@
package dhcpv6
import (
- "errors"
"fmt"
"net"
"strings"
@@ -223,15 +222,9 @@ func IsUsingUEFI(msg *Message) bool {
// GetTransactionID returns a transactionID of a message or its inner message
// in case of relay
func GetTransactionID(packet DHCPv6) (TransactionID, error) {
- if message, ok := packet.(*Message); ok {
- return message.TransactionID, nil
- }
- if relay, ok := packet.(*RelayMessage); ok {
- message, err := relay.GetInnerMessage()
- if err != nil {
- return TransactionID{0, 0, 0}, err
- }
- return GetTransactionID(message)
+ m, err := packet.GetInnerMessage()
+ if err != nil {
+ return TransactionID{0, 0, 0}, err
}
- return TransactionID{0, 0, 0}, errors.New("Invalid DHCPv6 packet")
+ return m.TransactionID, nil
}