net-dhcp 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +11 -0
- data/.gitignore +40 -0
- data/Gemfile +4 -0
- data/LICENSE +12 -0
- data/README +14 -0
- data/README.etd.original +9 -0
- data/Rakefile +42 -0
- data/bin/net-dhcp +37 -0
- data/lib/net-dhcp.rb +2 -0
- data/lib/net-dhcp/version.rb +5 -0
- data/lib/net/dhcp.rb +48 -0
- data/lib/net/dhcp/constants.rb +182 -0
- data/lib/net/dhcp/core.rb +322 -0
- data/lib/net/dhcp/options.rb +621 -0
- data/lib/net/dhcp/oui.txt +68928 -0
- data/net-dhcp.gemspec +35 -0
- data/spec/net-dhcp_spec.rb +7 -0
- data/spec/spec_helper.rb +19 -0
- data/test/dhcp_test.rb +71 -0
- metadata +142 -0
@@ -0,0 +1,621 @@
|
|
1
|
+
=begin
|
2
|
+
**
|
3
|
+
** options.rb
|
4
|
+
** 29/OCT/2007
|
5
|
+
** ETD-Software
|
6
|
+
** - Daniel Martin Gomez <etd[-at-]nomejortu.com>
|
7
|
+
**
|
8
|
+
** Desc:
|
9
|
+
** This file provides a set of classes to work with the DHCP protocol.
|
10
|
+
** Here are defined the classes to work with the different options of the
|
11
|
+
** protocol as defined in rfc2131, rfc2132 and rfc2563.
|
12
|
+
**
|
13
|
+
** See the provided rdoc comments for further information.
|
14
|
+
**
|
15
|
+
** Version:
|
16
|
+
** v1.0 [29/October/2007]: first released
|
17
|
+
**
|
18
|
+
** License:
|
19
|
+
** Please see dhcp.rb or LICENSE.txt for copyright and licensing information.
|
20
|
+
**
|
21
|
+
=end
|
22
|
+
|
23
|
+
module DHCP
|
24
|
+
|
25
|
+
# General object to capture DHCP options. Every option of the protocol has
|
26
|
+
# three fields: an option *type*, a defined *length* and a *payload*
|
27
|
+
class Option
|
28
|
+
attr_accessor :type, :len, :payload
|
29
|
+
|
30
|
+
# Create a DHCP option object with the given *type* and *payload*. +params+
|
31
|
+
# must be an array containing at least these two keys: :*type* and :*payload*
|
32
|
+
# The length is calculated with the size of the payload
|
33
|
+
def initialize(params = {})
|
34
|
+
# We need a type, and a payload
|
35
|
+
if (([:type, :payload] & params.keys).size != 2)
|
36
|
+
raise ArgumentError('you need to specify values for :type and :payload')
|
37
|
+
end
|
38
|
+
|
39
|
+
self.type = params[:type]
|
40
|
+
self.payload = params[:payload]
|
41
|
+
self.len = params.fetch(:len, self.payload.size)
|
42
|
+
end
|
43
|
+
|
44
|
+
# Return the option packed as an array of bytes. The first two elements
|
45
|
+
# are the type and length of this option. The payload follows afterwards.
|
46
|
+
def to_a
|
47
|
+
return [self.type, self.len] + self.payload
|
48
|
+
end
|
49
|
+
|
50
|
+
# Return the option packed as a binary string.
|
51
|
+
def pack
|
52
|
+
(self.to_a).pack('C*')
|
53
|
+
end
|
54
|
+
|
55
|
+
# Check wether a given option is equivalent (protocol level) to this one.
|
56
|
+
def eql?(obj)
|
57
|
+
return false unless (self.class == obj.class)
|
58
|
+
|
59
|
+
vars = self.instance_variables
|
60
|
+
# check all the other instance vairables
|
61
|
+
vars.each do |var|
|
62
|
+
return false unless (self.instance_variable_get(var) == obj.instance_variable_get(var))
|
63
|
+
end
|
64
|
+
return true
|
65
|
+
end
|
66
|
+
alias == eql?
|
67
|
+
|
68
|
+
def to_s
|
69
|
+
"to_s NOT implemented for option type: #{self.type}"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
# The subnet mask option specifies the client's subnet mask as per RFC
|
75
|
+
# 950 [5].
|
76
|
+
#
|
77
|
+
# If both the subnet mask and the router option are specified in a DHCP
|
78
|
+
# reply, the subnet mask option MUST be first.
|
79
|
+
#
|
80
|
+
# The code for the subnet mask option is 1, and its length is 4 octets.
|
81
|
+
#
|
82
|
+
# The default value for this option is 255.255.255.255
|
83
|
+
class SubnetMaskOption < Option
|
84
|
+
def initialize(params={})
|
85
|
+
params[:type] = $DHCP_SUBNETMASK
|
86
|
+
params[:payload] = params.fetch(:payload, [255, 255, 255, 255])
|
87
|
+
super(params)
|
88
|
+
end
|
89
|
+
|
90
|
+
def to_s()
|
91
|
+
"Subnet Mask = #{self.payload.join('.')}"
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
|
96
|
+
# The router option specifies a list of IP addresses for routers on the
|
97
|
+
# client's subnet. Routers SHOULD be listed in order of preference.
|
98
|
+
#
|
99
|
+
# The code for the router option is 3. The minimum length for the
|
100
|
+
# router option is 4 octets, and the length MUST always be a multiple
|
101
|
+
# of 4.
|
102
|
+
#
|
103
|
+
# The default value for this option is 0.0.0.0
|
104
|
+
class RouterOption < Option
|
105
|
+
def initialize(params={})
|
106
|
+
params[:type] = $DHCP_ROUTER
|
107
|
+
params[:payload] = params.fetch(:payload, [0, 0, 0, 0])
|
108
|
+
super(params)
|
109
|
+
end
|
110
|
+
|
111
|
+
def to_s()
|
112
|
+
"Router = #{self.payload.join('.')}"
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
# The domain name server option specifies a list of Domain Name System
|
117
|
+
# (STD 13, RFC 1035 [8]) name servers available to the client. Servers
|
118
|
+
# SHOULD be listed in order of preference.
|
119
|
+
#
|
120
|
+
# The code for the domain name server option is 6. The minimum length
|
121
|
+
# for this option is 4 octets, and the length MUST always be a multiple
|
122
|
+
# of 4.
|
123
|
+
#
|
124
|
+
# The default value for this option is 0.0.0.0
|
125
|
+
class DomainNameServerOption < Option
|
126
|
+
def initialize(params={})
|
127
|
+
params[:type] = $DHCP_DNS
|
128
|
+
params[:payload] = params.fetch(:payload, [0, 0, 0, 0])
|
129
|
+
super(params)
|
130
|
+
end
|
131
|
+
|
132
|
+
def to_s()
|
133
|
+
"Domain Name Server = #{self.payload.join('.')}"
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
# This option specifies the name of the client. The name may or may
|
138
|
+
# not be qualified with the local domain name (see section 3.17 for the
|
139
|
+
# preferred way to retrieve the domain name). See RFC 1035 for
|
140
|
+
# character set restrictions.
|
141
|
+
#
|
142
|
+
# The code for this option is 12, and its minimum length is 1.
|
143
|
+
#
|
144
|
+
# The default value for this option is 'caprica'
|
145
|
+
class HostNameOption < Option
|
146
|
+
def initialize(params={})
|
147
|
+
params[:type] = $DHCP_DNS
|
148
|
+
params[:payload] = params.fetch(:payload, 'caprica'.unpack('C*'))
|
149
|
+
super(params)
|
150
|
+
end
|
151
|
+
|
152
|
+
def to_s()
|
153
|
+
"Host Name = #{self.payload.pack('C*')}"
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
# This option specifies the domain name that client should use when
|
158
|
+
# resolving hostnames via the Domain Name System.
|
159
|
+
#
|
160
|
+
# The code for this option is 15. Its minimum length is 1.
|
161
|
+
#
|
162
|
+
# The default value for this option is "nomejortu.com"
|
163
|
+
class DomainNameOption < Option
|
164
|
+
def initialize(params={})
|
165
|
+
params[:type] = $DHCP_DOMAINNAME
|
166
|
+
params[:payload] = params.fetch(:payload, 'nomejortu.com'.unpack('C*'))
|
167
|
+
super(params)
|
168
|
+
end
|
169
|
+
|
170
|
+
def to_s()
|
171
|
+
"Domain Name = #{self.payload.pack('C*')}"
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
# This option is used in a client request (DHCPDISCOVER) to allow the
|
176
|
+
# client to request that a particular IP address be assigned.
|
177
|
+
#
|
178
|
+
# The code for this option is 50, and its length is 4.
|
179
|
+
#
|
180
|
+
# The default value for this option is 0.0.0.0
|
181
|
+
class RequestedIPAddressOption < Option
|
182
|
+
def initialize(params={})
|
183
|
+
params[:type] = $DHCP_DISCOVERADDR
|
184
|
+
params[:payload] = params.fetch(:payload, [0, 0, 0, 0])
|
185
|
+
super(params)
|
186
|
+
end
|
187
|
+
|
188
|
+
def to_s
|
189
|
+
"Requested IP address = #{self.payload.join('.')}"
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
# This option is used in a client request (DHCPDISCOVER or DHCPREQUEST)
|
194
|
+
# to allow the client to request a lease time for the IP address. In a
|
195
|
+
# server reply (DHCPOFFER), a DHCP server uses this option to specify
|
196
|
+
# the lease time it is willing to offer.
|
197
|
+
#
|
198
|
+
# The time is in units of seconds, and is specified as a 32-bit
|
199
|
+
# unsigned integer.
|
200
|
+
#
|
201
|
+
# The code for this option is 51, and its length is 4.
|
202
|
+
#
|
203
|
+
# The default value is 7200 (2h)
|
204
|
+
class IPAddressLeaseTimeOption < Option
|
205
|
+
def initialize(params={})
|
206
|
+
params[:type] = $DHCP_LEASETIME
|
207
|
+
params[:payload] = params.fetch(:payload, [7200].pack('N').unpack('C*'))
|
208
|
+
super(params)
|
209
|
+
end
|
210
|
+
|
211
|
+
def to_s()
|
212
|
+
"IP Address Lease Time = #{self.payload.pack('C*').unpack('N').first} seg"
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
# This option is used to convey the type of the DHCP message. The code
|
217
|
+
# for this option is 53, and its length is 1. Legal values for this
|
218
|
+
# option are:
|
219
|
+
#
|
220
|
+
# Value Message Type
|
221
|
+
# ----- ------------
|
222
|
+
# 1 DHCPDISCOVER
|
223
|
+
# 2 DHCPOFFER
|
224
|
+
# 3 DHCPREQUEST
|
225
|
+
# 4 DHCPDECLINE
|
226
|
+
# 5 DHCPACK
|
227
|
+
# 6 DHCPNAK
|
228
|
+
# 7 DHCPRELEASE
|
229
|
+
# 8 DHCPINFORM
|
230
|
+
#
|
231
|
+
# The default value is 1 (DHCPDISCOVER)
|
232
|
+
class MessageTypeOption < Option
|
233
|
+
def initialize(params={})
|
234
|
+
params[:type] = $DHCP_MESSAGETYPE
|
235
|
+
params[:payload] = params.fetch(:payload, [$DHCP_MSG_DISCOVER])
|
236
|
+
super(params)
|
237
|
+
end
|
238
|
+
|
239
|
+
def to_s
|
240
|
+
"DHCP Message Type = #{$DHCP_MSG_NAMES[self.payload[0]-1]} (#{self.payload[0]})"
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
|
245
|
+
# This option is used in DHCPOFFER and DHCPREQUEST messages, and may
|
246
|
+
# optionally be included in the DHCPACK and DHCPNAK messages. DHCP
|
247
|
+
# servers include this option in the DHCPOFFER in order to allow the
|
248
|
+
# client to distinguish between lease offers. DHCP clients use the
|
249
|
+
# contents of the 'server identifier' field as the destination address
|
250
|
+
# for any DHCP messages unicast to the DHCP server. DHCP clients also
|
251
|
+
# indicate which of several lease offers is being accepted by including
|
252
|
+
# this option in a DHCPREQUEST message.
|
253
|
+
#
|
254
|
+
# The identifier is the IP address of the selected server.
|
255
|
+
#
|
256
|
+
# The code for this option is 54, and its length is 4.
|
257
|
+
#
|
258
|
+
# The default value is 0.0.0.0
|
259
|
+
class ServerIdentifierOption < Option
|
260
|
+
def initialize(params={})
|
261
|
+
params[:type] = $DHCP_SERVIDENT
|
262
|
+
params[:payload] = params.fetch(:payload, [0, 0, 0, 0])
|
263
|
+
super(params)
|
264
|
+
end
|
265
|
+
|
266
|
+
def to_s
|
267
|
+
"Server Identifier = #{self.payload.join('.')}"
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
# This option is used by a DHCP client to request values for specified
|
272
|
+
# configuration parameters. The list of requested parameters is
|
273
|
+
# specified as n octets, where each octet is a valid DHCP option code
|
274
|
+
# as defined in this document.
|
275
|
+
#
|
276
|
+
# The client MAY list the options in order of preference. The DHCP
|
277
|
+
# server is not required to return the options in the requested order,
|
278
|
+
# but MUST try to insert the requested options in the order requested
|
279
|
+
# by the client.
|
280
|
+
#
|
281
|
+
# The code for this option is 55. Its minimum length is 1.
|
282
|
+
#
|
283
|
+
# The default value is: $DHCP_SUBNETMASK | $DHCP_ROUTER | $DHCP_DNS | $DHCP_DOMAINNAME
|
284
|
+
class ParameterRequestListOption < Option
|
285
|
+
def initialize(params={})
|
286
|
+
params[:type] = $DHCP_PARAMREQUEST
|
287
|
+
params[:payload] = params.fetch(:payload, [$DHCP_SUBNETMASK, $DHCP_ROUTER, $DHCP_DNS, $DHCP_DOMAINNAME])
|
288
|
+
super(params)
|
289
|
+
end
|
290
|
+
|
291
|
+
def to_s
|
292
|
+
"Parameter Request List = #{self.payload}"
|
293
|
+
end
|
294
|
+
end
|
295
|
+
|
296
|
+
# This option is used by DHCP clients to optionally identify the vendor
|
297
|
+
# type and configuration of a DHCP client. The information is a string
|
298
|
+
# of n octets, interpreted by servers. Vendors may choose to define
|
299
|
+
# specific vendor class identifiers to convey particular configuration
|
300
|
+
# or other identification information about a client. For example, the
|
301
|
+
# identifier may encode the client's hardware configuration. Servers
|
302
|
+
# not equipped to interpret the class-specific information sent by a
|
303
|
+
# client MUST ignore it (although it may be reported). Servers that
|
304
|
+
#
|
305
|
+
# respond SHOULD only use option 43 to return the vendor-specific
|
306
|
+
# information to the client.
|
307
|
+
#
|
308
|
+
# The code for this option is 60, and its minimum length is 1.
|
309
|
+
#
|
310
|
+
# The default value is: 'etdsoft'
|
311
|
+
class VendorClassIDOption < Option
|
312
|
+
def initialize(params={})
|
313
|
+
params[:type] = $DHCP_CLASSSID
|
314
|
+
params[:payload] = params.fetch(:payload, 'etdsoft'.unpack('C*'))
|
315
|
+
super(params)
|
316
|
+
end
|
317
|
+
|
318
|
+
def to_s()
|
319
|
+
"Vendor class identifier = #{self.payload.pack('C*')}"
|
320
|
+
end
|
321
|
+
end
|
322
|
+
|
323
|
+
|
324
|
+
# This option is used by DHCP clients to specify their unique
|
325
|
+
# identifier. DHCP servers use this value to index their database of
|
326
|
+
# address bindings. This value is expected to be unique for all
|
327
|
+
# clients in an administrative domain.
|
328
|
+
#
|
329
|
+
# Identifiers SHOULD be treated as opaque objects by DHCP servers.
|
330
|
+
#
|
331
|
+
# The client identifier MAY consist of type-value pairs similar to the
|
332
|
+
# 'htype'/'chaddr' fields defined in [3]. For instance, it MAY consist
|
333
|
+
# of a hardware type and hardware address. In this case the type field
|
334
|
+
# SHOULD be one of the ARP hardware types defined in STD2 [22]. A
|
335
|
+
# hardware type of 0 (zero) should be used when the value field
|
336
|
+
# contains an identifier other than a hardware address (e.g. a fully
|
337
|
+
# qualified domain name).
|
338
|
+
#
|
339
|
+
# For correct identification of clients, each client's client-
|
340
|
+
# identifier MUST be unique among the client-identifiers used on the
|
341
|
+
# subnet to which the client is attached. Vendors and system
|
342
|
+
# administrators are responsible for choosing client-identifiers that
|
343
|
+
# meet this requirement for uniqueness.
|
344
|
+
#
|
345
|
+
# The code for this option is 61, and its minimum length is 2.
|
346
|
+
#
|
347
|
+
# The default value is: 0x6969
|
348
|
+
class ClientIdentifierOption < Option
|
349
|
+
def initialize(params={})
|
350
|
+
params[:type] = $DHCP_CLIENTID
|
351
|
+
params[:payload] = params.fetch(:payload, [0x69, 0x69])
|
352
|
+
super(params)
|
353
|
+
end
|
354
|
+
|
355
|
+
def to_s
|
356
|
+
"Client Identifier = #{self.payload}"
|
357
|
+
end
|
358
|
+
end
|
359
|
+
|
360
|
+
# Option that can be used to exchange information about a
|
361
|
+
# DHCPv4 client's fully qualified domain name and about responsibility
|
362
|
+
# for updating the DNS RR related to the client's address assignment.
|
363
|
+
#
|
364
|
+
# See rfc4702 for full details
|
365
|
+
#
|
366
|
+
# The code for this option is 81, and its minimun length is 3.
|
367
|
+
#
|
368
|
+
# The default payload for this option is 'etd'
|
369
|
+
class ClientFQDNOption < Option
|
370
|
+
def initialize(params={})
|
371
|
+
params[:type] = $DHCP_CLIENTFQDN
|
372
|
+
params[:payload] = params.fetch(:payload, 'etd'.unpack('C*'))
|
373
|
+
super(params)
|
374
|
+
end
|
375
|
+
|
376
|
+
def to_s
|
377
|
+
"Client Fully Qualified Domain Name = #{self.payload.pack('C*')}"
|
378
|
+
end
|
379
|
+
end
|
380
|
+
|
381
|
+
# Octet "n" gives the number of octets containing "architecture types"
|
382
|
+
# (not including the code and len fields). It MUST be an even number
|
383
|
+
# greater than zero. Clients that support more than one architecture
|
384
|
+
# type MAY include a list of these types in their initial DHCP and PXE
|
385
|
+
# boot server packets. The list of supported architecture types MAY be
|
386
|
+
# reduced in any packet exchange between the client and server(s).
|
387
|
+
# Octets "n1" and "n2" encode a 16-bit architecture type identifier
|
388
|
+
# that describes the pre-boot runtime environment(s) of the client
|
389
|
+
# machine.
|
390
|
+
#
|
391
|
+
# See rfc4578 for full details
|
392
|
+
#
|
393
|
+
# The code for this option is 93, and its length must be an even number
|
394
|
+
# greater than zero.
|
395
|
+
#
|
396
|
+
# The default payload for this option is $DHCP_CLIENTARCH_I386
|
397
|
+
class ClientSystemArchitectureOption < Option
|
398
|
+
def initialize(params={})
|
399
|
+
params[:type] = $DHCP_CLIENTARCH
|
400
|
+
params[:payload] = params.fetch(:payload, [$DHCP_CLIENTARCH_I386].pack('n').unpack('C*'))
|
401
|
+
super(params)
|
402
|
+
end
|
403
|
+
def to_s
|
404
|
+
arch_id = self.payload.pack('C*').unpack('n').first
|
405
|
+
if (arch_id > ($DHCP_CLIENTARCH_NAMES.size-1))
|
406
|
+
arch = 'unknown'
|
407
|
+
else
|
408
|
+
arch = $DHCP_CLIENTARCH_NAMES[arch_id]
|
409
|
+
end
|
410
|
+
|
411
|
+
"Client System Architecture = #{arch}"
|
412
|
+
end
|
413
|
+
end
|
414
|
+
|
415
|
+
# Octet "t" encodes a network interface type. For now the only
|
416
|
+
# supported value is 1 for Universal Network Device Interface (UNDI).
|
417
|
+
# Octets "M" and "m" describe the interface revision. To encode the
|
418
|
+
# UNDI revision of 2.11, "M" would be set to 2, and "m" would be set to
|
419
|
+
# 11 (0x0B).
|
420
|
+
#
|
421
|
+
# See rfc4578 for full details
|
422
|
+
#
|
423
|
+
# The code for this option is 94, and its length is 3.
|
424
|
+
#
|
425
|
+
# The default payload for this option is 0,0x69,0x69
|
426
|
+
class ClientNetworkDeviceInterfaceOption < Option
|
427
|
+
def initialize(params={})
|
428
|
+
params[:type] = $DHCP_CLIENTNDI
|
429
|
+
params[:payload] = params.fetch(:payload, [0]+[0x69]*2)
|
430
|
+
super(params)
|
431
|
+
end
|
432
|
+
def to_s
|
433
|
+
uuid = self.payload.pack('n').unpack('C*')
|
434
|
+
"Client Network Device Interface = #{uuid}"
|
435
|
+
end
|
436
|
+
end
|
437
|
+
|
438
|
+
# Octet "t" describes the type of the machine identifier in the
|
439
|
+
# remaining octets in this option. 0 (zero) is the only value defined
|
440
|
+
# for this octet at the present time, and it describes the remaining
|
441
|
+
# octets as a 16-octet Globally Unique Identifier (GUID). Octet "n" is
|
442
|
+
# 17 for type 0. (One definition of GUID can be found in Appendix A of
|
443
|
+
# the EFI specification [4].)
|
444
|
+
#
|
445
|
+
# See rfc4578 for full details
|
446
|
+
#
|
447
|
+
# The code for this option is 97, and its length is 17: 1 for the type of
|
448
|
+
# identifier and 16 for a Globally Unique Identifier.
|
449
|
+
#
|
450
|
+
# The default payload for this option is 0, [0x69]*16
|
451
|
+
class UUIDGUIDOption < Option
|
452
|
+
def initialize(params={})
|
453
|
+
params[:type] = $DHCP_UUIDGUID
|
454
|
+
params[:payload] = params.fetch(:payload, [0]+[0x69]*16)
|
455
|
+
super(params)
|
456
|
+
end
|
457
|
+
def to_s
|
458
|
+
"UUID/GUID Client Identifier = #{self.payload}"
|
459
|
+
end
|
460
|
+
end
|
461
|
+
|
462
|
+
|
463
|
+
# from rfc2132:
|
464
|
+
# This option specifies the maximum length DHCP message that it is
|
465
|
+
# willing to accept. The length is specified as an unsigned 16-bit
|
466
|
+
# integer. A client may use the maximum DHCP message size option in
|
467
|
+
# DHCPDISCOVER or DHCPREQUEST messages, but should not use the option
|
468
|
+
# in DHCPDECLINE messages.
|
469
|
+
class MaximumMsgSizeOption < Option
|
470
|
+
def initialize(params={})
|
471
|
+
params[:type] = $DHCP_MAXMSGSIZE
|
472
|
+
params[:payload] = params.fetch(:payload, [1024].pack('n').unpack('C*'))
|
473
|
+
super(params)
|
474
|
+
end
|
475
|
+
|
476
|
+
def to_s
|
477
|
+
"Maximum Message Size = #{self.payload}"
|
478
|
+
end
|
479
|
+
end
|
480
|
+
|
481
|
+
# see: rfc3004
|
482
|
+
class UserClassInformationOption < Option
|
483
|
+
def initialize(params={})
|
484
|
+
params[:type] = $DHCP_USERCLASS
|
485
|
+
params[:payload] = params.fetch(:payload, [0x67, 0x50, 0x58, 0x45] )
|
486
|
+
super(params)
|
487
|
+
end
|
488
|
+
|
489
|
+
def to_s
|
490
|
+
"UserClassInformation = #{self.payload}"
|
491
|
+
end
|
492
|
+
end
|
493
|
+
|
494
|
+
class PrivateOption < Option
|
495
|
+
def initialize(params={})
|
496
|
+
params[:type] = params.fetch(:private_type_num, $DHCP_PRIVATE)
|
497
|
+
params[:payload] = params.fetch(:payload, [0x00] )
|
498
|
+
super(params)
|
499
|
+
end
|
500
|
+
|
501
|
+
def to_s
|
502
|
+
"Private = #{self.payload}"
|
503
|
+
end
|
504
|
+
end
|
505
|
+
|
506
|
+
# Operating Systems are now attempting to support ad-hoc networks of
|
507
|
+
# two or more systems, while keeping user configuration at a minimum.
|
508
|
+
# To accommodate this, in the absence of a central configuration
|
509
|
+
# mechanism (DHCP), some OS's are automatically choosing a link-local
|
510
|
+
# IP address which will allow them to communicate only with other hosts
|
511
|
+
# on the same link. This address will not allow the OS to communicate
|
512
|
+
# with anything beyond a router. However, some sites depend on the
|
513
|
+
# fact that a host with no DHCP response will have no IP address. This
|
514
|
+
# document describes a mechanism by which DHCP servers are able to tell
|
515
|
+
# clients that they do not have an IP address to offer, and that the
|
516
|
+
# client should not generate an IP address it's own.
|
517
|
+
#
|
518
|
+
# See rfc2563 for full details
|
519
|
+
#
|
520
|
+
# The code for this option is 116, and its length is 1.
|
521
|
+
#
|
522
|
+
# The default payload for this option is $DHCP_AUTOCONF_YES
|
523
|
+
class AutoConfigurationOption < Option
|
524
|
+
def initialize(params={})
|
525
|
+
params[:type] = $DHCP_AUTOCONF
|
526
|
+
params[:payload] = params.fetch(:payload, [$DHCP_AUTOCONF_YES])
|
527
|
+
super(params)
|
528
|
+
end
|
529
|
+
|
530
|
+
def to_s
|
531
|
+
"DHCP Auto-Configuration = #{self.payload == $DHCP_AUTOCONF_YES ? 'Yes' : 'No' }"
|
532
|
+
end
|
533
|
+
end
|
534
|
+
|
535
|
+
$DHCP_MSG_OPTIONS = {
|
536
|
+
$DHCP_SUBNETMASK => SubnetMaskOption,
|
537
|
+
$DHCP_TIMEOFFSET => Option,
|
538
|
+
$DHCP_ROUTER => RouterOption,
|
539
|
+
$DHCP_TIMESERVER => Option,
|
540
|
+
$DHCP_NAMESERVER => Option,
|
541
|
+
$DHCP_DNS => DomainNameServerOption,
|
542
|
+
$DHCP_LOGSERV => Option,
|
543
|
+
$DHCP_COOKIESERV => Option,
|
544
|
+
$DHCP_QUOTESSERV => Option,
|
545
|
+
$DHCP_LPRSERV => Option,
|
546
|
+
$DHCP_IMPSERV => Option,
|
547
|
+
$DHCP_RESSERV => Option,
|
548
|
+
$DHCP_HOSTNAME => HostNameOption,
|
549
|
+
$DHCP_BOOTFILESIZE => Option,
|
550
|
+
$DHCP_DUMPFILE => Option,
|
551
|
+
$DHCP_DOMAINNAME => DomainNameOption,
|
552
|
+
$DHCP_SWAPSERV => Option,
|
553
|
+
$DHCP_ROOTPATH => Option,
|
554
|
+
$DHCP_EXTENPATH => Option,
|
555
|
+
$DHCP_IPFORWARD => Option,
|
556
|
+
$DHCP_SRCROUTE => Option,
|
557
|
+
$DHCP_POLICYFILTER => Option,
|
558
|
+
$DHCP_MAXASMSIZE => Option,
|
559
|
+
$DHCP_IPTTL => Option,
|
560
|
+
$DHCP_MTUTIMEOUT => Option,
|
561
|
+
$DHCP_MTUTABLE => Option,
|
562
|
+
$DHCP_MTUSIZE => Option,
|
563
|
+
$DHCP_LOCALSUBNETS => Option,
|
564
|
+
$DHCP_BROADCASTADDR => Option,
|
565
|
+
$DHCP_DOMASKDISCOV => Option,
|
566
|
+
$DHCP_MASKSUPPLY => Option,
|
567
|
+
$DHCP_DOROUTEDISC => Option,
|
568
|
+
$DHCP_ROUTERSOLICIT => Option,
|
569
|
+
$DHCP_STATICROUTE => Option,
|
570
|
+
$DHCP_TRAILERENCAP => Option,
|
571
|
+
$DHCP_ARPTIMEOUT => Option,
|
572
|
+
$DHCP_ETHERENCAP => Option,
|
573
|
+
$DHCP_TCPTTL => Option,
|
574
|
+
$DHCP_TCPKEEPALIVE => Option,
|
575
|
+
$DHCP_TCPALIVEGARBAGE => Option,
|
576
|
+
$DHCP_NISDOMAIN => Option,
|
577
|
+
$DHCP_NISSERVERS => Option,
|
578
|
+
$DHCP_NISTIMESERV => Option,
|
579
|
+
$DHCP_VENDSPECIFIC => Option,
|
580
|
+
$DHCP_NBNS => Option,
|
581
|
+
$DHCP_NBDD => Option,
|
582
|
+
$DHCP_NBTCPIP => Option,
|
583
|
+
$DHCP_NBTCPSCOPE => Option,
|
584
|
+
$DHCP_XFONT => Option,
|
585
|
+
$DHCP_XDISPLAYMGR => Option,
|
586
|
+
$DHCP_DISCOVERADDR => RequestedIPAddressOption,
|
587
|
+
$DHCP_LEASETIME => IPAddressLeaseTimeOption,
|
588
|
+
$DHCP_OPTIONOVERLOAD => Option,
|
589
|
+
$DHCP_MESSAGETYPE => MessageTypeOption,
|
590
|
+
$DHCP_SERVIDENT => ServerIdentifierOption,
|
591
|
+
$DHCP_PARAMREQUEST => ParameterRequestListOption,
|
592
|
+
$DHCP_MESSAGE => Option,
|
593
|
+
$DHCP_MAXMSGSIZE => MaximumMsgSizeOption,
|
594
|
+
$DHCP_RENEWTIME => Option,
|
595
|
+
$DHCP_REBINDTIME => Option,
|
596
|
+
$DHCP_CLASSSID => VendorClassIDOption,
|
597
|
+
$DHCP_CLIENTID => ClientIdentifierOption,
|
598
|
+
$DHCP_NISPLUSDOMAIN => Option,
|
599
|
+
$DHCP_NISPLUSSERVERS => Option,
|
600
|
+
$DHCP_MOBILEIPAGENT => Option,
|
601
|
+
$DHCP_SMTPSERVER => Option,
|
602
|
+
$DHCP_POP3SERVER => Option,
|
603
|
+
$DHCP_NNTPSERVER => Option,
|
604
|
+
$DHCP_WWWSERVER => Option,
|
605
|
+
$DHCP_FINGERSERVER => Option,
|
606
|
+
$DHCP_IRCSERVER => Option,
|
607
|
+
$DHCP_STSERVER => Option,
|
608
|
+
$DHCP_STDASERVER => Option,
|
609
|
+
$DHCP_USERCLASS => UserClassInformationOption,
|
610
|
+
$DHCP_PRIVATE => PrivateOption,
|
611
|
+
|
612
|
+
$DHCP_CLIENTFQDN => ClientFQDNOption,
|
613
|
+
$DHCP_CLIENTARCH => ClientSystemArchitectureOption,
|
614
|
+
$DHCP_CLIENTNDI => ClientNetworkDeviceInterfaceOption,
|
615
|
+
$DHCP_LDAP => Option,
|
616
|
+
$DHCP_UUIDGUID => UUIDGUIDOption,
|
617
|
+
$DHCP_AUTOCONF => AutoConfigurationOption,
|
618
|
+
|
619
|
+
}
|
620
|
+
|
621
|
+
end
|