summaryrefslogtreecommitdiffhomepage
path: root/dhcpv4/utils.go
diff options
context:
space:
mode:
authorPablo Mazzini <pmazzini@gmail.com>2018-08-03 12:22:05 +0200
committerPablo Mazzini <pmazzini@gmail.com>2018-08-10 15:25:49 +0200
commit27e10b9e7f76b99dbdc0d8fd779b18ef322ed92c (patch)
tree5bfd9b0d94b0e387893519620cec34e5f3a62783 /dhcpv4/utils.go
parent5207d76712250f33111c546d9ace98336d616bfc (diff)
add IsRequested
Diffstat (limited to 'dhcpv4/utils.go')
-rw-r--r--dhcpv4/utils.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/dhcpv4/utils.go b/dhcpv4/utils.go
new file mode 100644
index 0000000..d95f586
--- /dev/null
+++ b/dhcpv4/utils.go
@@ -0,0 +1,14 @@
+package dhcpv4
+
+// IsRequested function takes a DHCPv4 message and an OptionCode, and returns
+// true if that option is within the requested options of the DHCPv6 message.
+func IsRequested(pkt *DHCPv4, requested OptionCode) bool {
+ for _, optprl := range pkt.GetOption(OptionParameterRequestList) {
+ for _, o := range optprl.(*OptParameterRequestList).RequestedOpts {
+ if o == requested {
+ return true
+ }
+ }
+ }
+ return false
+}