diff options
author | MikoĊaj Walczak <mikiwalczak+github@gmail.com> | 2018-07-12 10:51:38 +0100 |
---|---|---|
committer | insomniac <insomniacslk@users.noreply.github.com> | 2018-07-12 10:51:38 +0100 |
commit | 8e3bcdab237624421034ccc4eb16f260d4338aec (patch) | |
tree | 0cb93b736c59506f68df67ac1150e80047dc202c /dhcpv6/utils.go | |
parent | 34154e71da6f5b4527809dc0babdefcbd262281c (diff) |
Asynchronous client for DHCPv6 (#80)
Diffstat (limited to 'dhcpv6/utils.go')
-rw-r--r-- | dhcpv6/utils.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/dhcpv6/utils.go b/dhcpv6/utils.go index 81ebaae..b1c0b93 100644 --- a/dhcpv6/utils.go +++ b/dhcpv6/utils.go @@ -1,6 +1,7 @@ package dhcpv6 import ( + "errors" "strings" ) @@ -58,3 +59,19 @@ func IsUsingUEFI(msg DHCPv6) bool { } return false } + +// GetTransactionID returns a transactionID of a message or its inner message +// in case of relay +func GetTransactionID(packet DHCPv6) (uint32, error) { + if message, ok := packet.(*DHCPv6Message); ok { + return message.TransactionID(), nil + } + if relay, ok := packet.(*DHCPv6Relay); ok { + message, err := relay.GetInnerMessage() + if err != nil { + return 0, err + } + return GetTransactionID(message) + } + return 0, errors.New("Invalid DHCPv6 packet") +} |