summaryrefslogtreecommitdiffhomepage
path: root/dhcpv6/dhcpv6.go
diff options
context:
space:
mode:
Diffstat (limited to 'dhcpv6/dhcpv6.go')
-rw-r--r--dhcpv6/dhcpv6.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/dhcpv6/dhcpv6.go b/dhcpv6/dhcpv6.go
index 9b6ef5c..146687a 100644
--- a/dhcpv6/dhcpv6.go
+++ b/dhcpv6/dhcpv6.go
@@ -11,6 +11,9 @@ type DHCPv6 interface {
String() string
Summary() string
Length() int
+ IsRelay() bool
+ GetOption(code OptionCode) []Option
+ GetOneOption(code OptionCode) Option
}
func FromBytes(data []byte) (DHCPv6, error) {
@@ -78,3 +81,24 @@ func NewMessage() (*DHCPv6Message, error) {
}
return &d, nil
}
+
+func getOptions(options []Option, code OptionCode, onlyFirst bool) []Option {
+ var ret []Option
+ for _, opt := range options {
+ if opt.Code() == code {
+ ret = append(ret, opt)
+ if onlyFirst {
+ break
+ }
+ }
+ }
+ return ret
+}
+
+func getOption(options []Option, code OptionCode) Option {
+ opts := getOptions(options, code, true)
+ if opts == nil {
+ return nil
+ }
+ return opts[0]
+}