Skip to content

Commit

Permalink
Add supporto for DHCP Subnet Selection Option 0x76)
Browse files Browse the repository at this point in the history
  • Loading branch information
elibus committed Mar 10, 2016
1 parent 4e9ed23 commit 5878185
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/net-dhcp/version.rb
@@ -1,5 +1,5 @@
module Net
module Dhcp
VERSION = "1.3.2"
VERSION = "1.3.3"
end
end
18 changes: 9 additions & 9 deletions lib/net/dhcp/constants.rb
Expand Up @@ -148,8 +148,8 @@
$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
Expand All @@ -172,11 +172,11 @@
'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
29 changes: 28 additions & 1 deletion lib/net/dhcp/options.rb
Expand Up @@ -555,6 +555,33 @@ def to_s
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,
Expand Down Expand Up @@ -638,7 +665,7 @@ def to_s
$DHCP_LDAP => Option,
$DHCP_UUIDGUID => UUIDGUIDOption,
$DHCP_AUTOCONF => AutoConfigurationOption,

$DHCP_SUBNET_SELECTION => SubnetSelectionOption,
}

end

0 comments on commit 5878185

Please sign in to comment.