summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Tizzoni <marco.tizzoni@gmail.com>2016-03-10 12:14:27 +0100
committerMarco Tizzoni <marco.tizzoni@gmail.com>2016-03-10 12:14:27 +0100
commit5878185909a5a166891ea1c74f926880167113a2 (patch)
treef6fe1856f53257cb18786543b238bc4cf4f3dd5b
parent4e9ed23207f638c7a731351915bfabe02f0fca39 (diff)
downloadnet-dhcp-ruby-5878185909a5a166891ea1c74f926880167113a2.tar.gz
Add supporto for DHCP Subnet Selection Option 0x76)
-rw-r--r--lib/net-dhcp/version.rb2
-rw-r--r--lib/net/dhcp/constants.rb18
-rw-r--r--lib/net/dhcp/options.rb29
3 files changed, 38 insertions, 11 deletions
diff --git a/lib/net-dhcp/version.rb b/lib/net-dhcp/version.rb
index 16f44c9..d945471 100644
--- a/lib/net-dhcp/version.rb
+++ b/lib/net-dhcp/version.rb
@@ -1,5 +1,5 @@
module Net
module Dhcp
- VERSION = "1.3.2"
+ VERSION = "1.3.3"
end
end
diff --git a/lib/net/dhcp/constants.rb b/lib/net/dhcp/constants.rb
index 353b183..256c18f 100644
--- a/lib/net/dhcp/constants.rb
+++ b/lib/net/dhcp/constants.rb
@@ -148,8 +148,8 @@ $DHCP_END= 0xff
$DHCP_CLIENTFQDN= 0x51 #rfc4702
-$DHCP_CLIENTARCH= 0x5d #rfc4578
-$DHCP_CLIENTARCH_I386= 0x0000
+$DHCP_CLIENTARCH= 0x5d #rfc4578
+$DHCP_CLIENTARCH_I386= 0x0000
$DHCP_CLIENTARCH_PC98= 0x0001
$DHCP_CLIENTARCH_ITANIUM= 0x0002
$DHCP_CLIENTARCH_ALPHA= 0x0003
@@ -172,11 +172,11 @@ $DHCP_CLIENTARCH_NAMES = [
'EFI x86-64',
]
-$DHCP_CLIENTNDI= 0x5e #rfc4578
-#$DHCP_LDAP= 0x5f
-$DHCP_UUIDGUID= 0x61 #rfc4578
-
-$DHCP_AUTOCONF= 0x74 #rfc2563
-$DHCP_AUTOCONF_NO= 0x00 #rfc2563
-$DHCP_AUTOCONF_YES= 0x01 #rfc2563
+$DHCP_CLIENTNDI= 0x5e #rfc4578
+#$DHCP_LDAP= 0x5f
+$DHCP_UUIDGUID= 0x61 #rfc4578
+$DHCP_AUTOCONF= 0x74 #rfc2563
+$DHCP_SUBNET_SELECTION= 0x76 #rfc3011
+$DHCP_AUTOCONF_NO= 0x00 #rfc2563
+$DHCP_AUTOCONF_YES= 0x01 #rfc2563
diff --git a/lib/net/dhcp/options.rb b/lib/net/dhcp/options.rb
index b9c080d..9475bec 100644
--- a/lib/net/dhcp/options.rb
+++ b/lib/net/dhcp/options.rb
@@ -555,6 +555,33 @@ module DHCP
end
end
+ # The subnet selection option is a DHCP option. The option contains a
+ # single IPv4 address that is the address of a subnet. The value for
+ # the subnet address is determined by taking any IPv4 address on the
+ # subnet and ANDing that address with the subnet mask (i.e.: the
+ # network and subnet bits are left alone and the remaining (address)
+ # bits are set to zero). When the DHCP server is configured to respond
+ # to this option, is allocating an address, and this option is present
+ # then the DHCP server MUST allocate the address on either:
+ # - the subnet specified in the subnet selection option, or;
+ #
+ # - a subnet on the same network segment as the subnet specified in the
+ # subnet selection option.
+ #
+ # The code for this option is 118, and its length is 4.
+ #
+ class SubnetSelectionOption < Option
+ def initialize(params={})
+ params[:type] = $DHCP_SUBNET_SELECTION
+ params[:payload] = params.fetch(:payload)
+ super(params)
+ end
+
+ def to_s()
+ "Subnet Selection = #{self.payload.join('.')}"
+ end
+ end
+
$DHCP_MSG_OPTIONS = {
$DHCP_SUBNETMASK => SubnetMaskOption,
$DHCP_TIMEOFFSET => Option,
@@ -638,7 +665,7 @@ module DHCP
$DHCP_LDAP => Option,
$DHCP_UUIDGUID => UUIDGUIDOption,
$DHCP_AUTOCONF => AutoConfigurationOption,
-
+ $DHCP_SUBNET_SELECTION => SubnetSelectionOption,
}
end