diff options
author | Christopher Koch <chrisko@google.com> | 2019-03-04 12:47:50 -0800 |
---|---|---|
committer | insomniac <insomniacslk@users.noreply.github.com> | 2019-04-04 12:49:08 +0100 |
commit | 175868d67987770d2d729186f7676e0b98f925df (patch) | |
tree | 2d56b1cb28fddd14ad935fa3c41dcc368b31e30c /dhcpv6/dhcpv6.go | |
parent | b40bd52ae58aee37cec9ef81008e24488350c98f (diff) |
client6: new async DHCPv6 client like #250.
- Race-condition-averse.
- Supports multiple concurrent requests.
- Tested.
- Requires a fully compatible net.PacketConn.
Signed-off-by: Christopher Koch <chrisko@google.com>
Diffstat (limited to 'dhcpv6/dhcpv6.go')
-rw-r--r-- | dhcpv6/dhcpv6.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/dhcpv6/dhcpv6.go b/dhcpv6/dhcpv6.go index c8c4292..7505dfc 100644 --- a/dhcpv6/dhcpv6.go +++ b/dhcpv6/dhcpv6.go @@ -16,6 +16,11 @@ type DHCPv6 interface { String() string Summary() string IsRelay() bool + + // GetInnerMessage returns the innermost encapsulated DHCPv6 message. + // + // If it is already a message, it will be returned. If it is a relay + // message, the encapsulated message will be recursively extracted. GetInnerMessage() (*Message, error) GetOption(code OptionCode) []Option @@ -108,11 +113,11 @@ func DecapsulateRelay(l DHCPv6) (DHCPv6, error) { } opt := l.GetOneOption(OptionRelayMsg) if opt == nil { - return nil, fmt.Errorf("No OptRelayMsg found") + return nil, fmt.Errorf("malformed Relay message: no OptRelayMsg found") } relayOpt := opt.(*OptRelayMsg) if relayOpt.RelayMessage() == nil { - return nil, fmt.Errorf("Relay message cannot be nil") + return nil, fmt.Errorf("malformed Relay message: encapsulated message is empty") } return relayOpt.RelayMessage(), nil } |