summaryrefslogtreecommitdiffhomepage
path: root/iana
diff options
context:
space:
mode:
authorChris Koch <chrisko@google.com>2019-12-28 00:33:22 -0800
committerinsomniac <insomniacslk@users.noreply.github.com>2020-03-05 15:51:55 +0000
commit8d3e32a40580e3e227f64d9068f84b321e7921b2 (patch)
tree5419ea36fd39b6775f06f683ba0ad1b906d3341d /iana
parent9e4750895995d4d3f4dd36d4fff26d7b3927a34b (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 'iana')
-rw-r--r--iana/archtype.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/iana/archtype.go b/iana/archtype.go
index 255687c..865659b 100644
--- a/iana/archtype.go
+++ b/iana/archtype.go
@@ -49,6 +49,16 @@ func (a Arch) String() string {
// Archs represents multiple Arch values.
type Archs []Arch
+// Contains returns whether b is one of the Archs in a.
+func (a Archs) Contains(b Arch) bool {
+ for _, t := range a {
+ if t == b {
+ return true
+ }
+ }
+ return false
+}
+
// ToBytes returns the serialized option defined by RFC 4578 (DHCPv4) and RFC
// 5970 (DHCPv6) as the Client System Architecture Option.
func (a Archs) ToBytes() []byte {