summaryrefslogtreecommitdiffhomepage
path: root/dhcpv6/dhcpv6message.go
diff options
context:
space:
mode:
authorSean Karlage <skarlage@fb.com>2018-08-15 10:34:04 -0700
committerSean Karlage <skarlage@fb.com>2018-08-15 10:34:04 -0700
commit40169a2169f788c41cb806c9d344148e72a3a0bd (patch)
tree6cfee5029c946710e4ed7789151ac02e62fa852b /dhcpv6/dhcpv6message.go
parent8ea2525c898436a2a935580de67727bbe7035c85 (diff)
parent926a42d133247d7a4fa388548e4323b77421f798 (diff)
Merge branch 'master' into dhcpv4-moar-tests
Diffstat (limited to 'dhcpv6/dhcpv6message.go')
-rw-r--r--dhcpv6/dhcpv6message.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/dhcpv6/dhcpv6message.go b/dhcpv6/dhcpv6message.go
index e601932..7ee00ad 100644
--- a/dhcpv6/dhcpv6message.go
+++ b/dhcpv6/dhcpv6message.go
@@ -286,6 +286,33 @@ func (d *DHCPv6Message) UpdateOption(option Option) {
d.AddOption(option)
}
+// IsNetboot returns true if the machine is trying to netboot. It checks if
+// "boot file" is one of the requested options, which is useful for
+// SOLICIT/REQUEST packet types, it also checks if the "boot file" option is
+// included in the packet, which is useful for ADVERTISE/REPLY packet.
+func (d *DHCPv6Message) IsNetboot() bool {
+ if d.IsOptionRequested(OptionBootfileURL) {
+ return true
+ }
+ if optbf := d.GetOneOption(OptionBootfileURL); optbf != nil {
+ return true
+ }
+ return false
+}
+
+// IsOptionRequested takes an OptionCode and returns true if that option is
+// within the requested options of the DHCPv6 message.
+func (d *DHCPv6Message) IsOptionRequested(requested OptionCode) bool {
+ for _, optoro := range d.GetOption(OptionORO) {
+ for _, o := range optoro.(*OptRequestedOption).RequestedOptions() {
+ if o == requested {
+ return true
+ }
+ }
+ }
+ return false
+}
+
func (d *DHCPv6Message) String() string {
return fmt.Sprintf("DHCPv6Message(messageType=%v transactionID=0x%06x, %d options)",
d.MessageTypeToString(), d.TransactionID(), len(d.options),