diff options
author | Chris Koch <chrisko@google.com> | 2019-12-28 00:33:22 -0800 |
---|---|---|
committer | insomniac <insomniacslk@users.noreply.github.com> | 2020-03-05 15:51:55 +0000 |
commit | 8d3e32a40580e3e227f64d9068f84b321e7921b2 (patch) | |
tree | 5419ea36fd39b6775f06f683ba0ad1b906d3341d /dhcpv6/option_relaymsg_test.go | |
parent | 9e4750895995d4d3f4dd36d4fff26d7b3927a34b (diff) |
dhcpv6: intro Getters for Options
Allow the Options type to have getters for each specific options, in
order to avoid users having to cast options to their specific type.
This commit introduces a getter for exactly one option: the
ClientArchType.
i.e. users can replace
archTypes := msg.GetOneOption(OptionClientArchType).(*OptClientArchType)
with
archTypes := msg.Options.ArchTypes()
Because a few message types and options embed options (normal message,
relay message, IANA/IATA option) and each have a restricted set of
options that can be used inside them, we'll introduce at least 3 or more
Options subtypes:
- MessageOptions
- RelayOptions
- IdentityOptions
Perhaps others will join at a later time, such as VendorOptions or
AddressOptions for the IAAddress options field.
Signed-off-by: Chris Koch <chrisko@google.com>
Diffstat (limited to 'dhcpv6/option_relaymsg_test.go')
-rw-r--r-- | dhcpv6/option_relaymsg_test.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/dhcpv6/option_relaymsg_test.go b/dhcpv6/option_relaymsg_test.go index dd82d28..887bf95 100644 --- a/dhcpv6/option_relaymsg_test.go +++ b/dhcpv6/option_relaymsg_test.go @@ -106,10 +106,10 @@ func TestRelayMsgParseOptRelayMsgSingleEncapsulation(t *testing.T) { if tID := innerDHCP.TransactionID; tID != xid { t.Fatalf("Invalid inner DHCP transaction ID. Expected 0xaabbcc, got %v", tID) } - if len(innerDHCP.Options) != 1 { - t.Fatalf("Invalid inner DHCP options length. Expected 1, got %v", len(innerDHCP.Options)) + if len(innerDHCP.Options.Options) != 1 { + t.Fatalf("Invalid inner DHCP options length. Expected 1, got %v", len(innerDHCP.Options.Options)) } - innerOpt := innerDHCP.Options[0] + innerOpt := innerDHCP.Options.Options[0] eto, ok := innerOpt.(*OptElapsedTime) if !ok { t.Fatalf("Invalid inner option type. Expected OptElapsedTime, got %v", |