summaryrefslogtreecommitdiffhomepage
path: root/dhcpv6/dhcpv6.go
diff options
context:
space:
mode:
authorChristopher Koch <c@chrisko.ch>2019-01-20 04:23:39 +0000
committerinsomniac <insomniacslk@users.noreply.github.com>2019-01-26 23:34:26 +0000
commitc09728dd0f8ccf56e74efe7df7328191a347e821 (patch)
tree0342d2dc8ee89a82ddcf86007806bd558a90acbd /dhcpv6/dhcpv6.go
parent5604533269d24e72911e36f94d335337849decae (diff)
dhcpv6: introduce TransactionID type
Diffstat (limited to 'dhcpv6/dhcpv6.go')
-rw-r--r--dhcpv6/dhcpv6.go16
1 files changed, 6 insertions, 10 deletions
diff --git a/dhcpv6/dhcpv6.go b/dhcpv6/dhcpv6.go
index c9f8c05..70c2bff 100644
--- a/dhcpv6/dhcpv6.go
+++ b/dhcpv6/dhcpv6.go
@@ -63,14 +63,10 @@ func FromBytes(data []byte) (DHCPv6, error) {
}
return &d, nil
} else {
- tid, err := BytesToTransactionID(data[1:4])
- if err != nil {
- return nil, err
- }
d := DHCPv6Message{
- messageType: messageType,
- transactionID: *tid,
+ messageType: messageType,
}
+ copy(d.transactionID[:], data[1:4])
if err := d.options.FromBytes(data[4:]); err != nil {
return nil, err
}
@@ -86,7 +82,7 @@ func NewMessage(modifiers ...Modifier) (DHCPv6, error) {
}
msg := DHCPv6Message{
messageType: MessageTypeSolicit,
- transactionID: *tid,
+ transactionID: tid,
}
// apply modifiers
d := DHCPv6(&msg)
@@ -209,16 +205,16 @@ func IsUsingUEFI(msg DHCPv6) bool {
// GetTransactionID returns a transactionID of a message or its inner message
// in case of relay
-func GetTransactionID(packet DHCPv6) (uint32, error) {
+func GetTransactionID(packet DHCPv6) (TransactionID, 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 TransactionID{0, 0, 0}, err
}
return GetTransactionID(message)
}
- return 0, errors.New("Invalid DHCPv6 packet")
+ return TransactionID{0, 0, 0}, errors.New("Invalid DHCPv6 packet")
}