/[pxelator]/lib/Net/DHCP/Constants.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /lib/Net/DHCP/Constants.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 568 - (show annotations)
Tue Jun 26 20:53:25 2012 UTC (10 years, 5 months ago) by dpavlin
File size: 14222 byte(s)
added 121
1 # Net::DHCP::Constants.pm
2 # Author: Stephan Hadinger
3
4 package Net::DHCP::Constants;
5
6 # standard module declaration
7 use 5.8.0;
8 use strict;
9 our (@ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS, $VERSION);
10 use Exporter;
11 $VERSION = 0.67;
12 @ISA = qw(Exporter);
13
14 @EXPORT = qw(MAGIC_COOKIE);
15
16 # Constants
17 our (%DHO_CODES, %REV_DHO_CODES);
18 our (%DHCP_MESSAGE, %REV_DHCP_MESSAGE);
19 our (%BOOTP_CODES, %REV_BOOTP_CODES);
20 our (%HTYPE_CODES, %REV_HTYPE_CODES);
21
22 %EXPORT_TAGS = (
23 dho_codes => [keys %DHO_CODES],
24 dhcp_message => [keys %DHCP_MESSAGE],
25 bootp_codes => [keys %BOOTP_CODES],
26 htype_codes => [keys %HTYPE_CODES],
27 dhcp_hashes => [ qw(
28 %DHO_CODES %REV_DHO_CODES %DHCP_MESSAGE %REV_DHCP_MESSAGE
29 %BOOTP_CODES %REV_BOOTP_CODES
30 %HTYPE_CODES %REV_HTYPE_CODES
31 )],
32 dhcp_other => [ qw(MAGIC_COOKIE DHCP_UDP_OVERHEAD DHCP_MAX_MTU BOOTP_MIN_LEN BOOTP_ABSOLUTE_MIN_LEN DHCP_MIN_LEN)]
33 );
34
35 @EXPORT_OK = qw(
36 %DHO_CODES %REV_DHO_CODES %DHCP_MESSAGE %REV_DHCP_MESSAGE
37 %BOOTP_CODES %REV_BOOTP_CODES
38 %HTYPE_CODES %REV_HTYPE_CODES
39 %DHO_FORMATS
40 );
41 Exporter::export_tags('dho_codes');
42 Exporter::export_tags('dhcp_message');
43 Exporter::export_tags('bootp_codes');
44 Exporter::export_tags('htype_codes');
45 Exporter::export_ok_tags('dhcp_other');
46
47 # MAGIC_COOKIE for DHCP (oterhwise it is BOOTP)
48 use constant MAGIC_COOKIE => "\x63\x82\x53\x63";
49
50 use constant DHCP_UDP_OVERHEAD => (14 + 20 + 8); # Ethernet + IP + UDP
51 use constant DHCP_MAX_MTU => 1500;
52 use constant BOOTP_ABSOLUTE_MIN_LEN => 236;
53 use constant BOOTP_MIN_LEN => 271; # dpavlin - Linux bootp is smaller than 300
54 use constant DHCP_MIN_LEN => 548;
55
56 BEGIN {
57 %BOOTP_CODES = (
58 'BOOTREQUEST' => 1,
59 'BOOTREPLY' => 2
60 );
61
62 %HTYPE_CODES = (
63 'HTYPE_ETHER' => 1,
64 'HTYPE_IEEE802' => 6,
65 'HTYPE_FDDI' => 8
66 );
67
68 %DHO_CODES = ( # rfc 2132
69 'DHO_PAD' => 0,
70 'DHO_SUBNET_MASK' => 1,
71 'DHO_TIME_OFFSET' => 2,
72 'DHO_ROUTERS' => 3,
73 'DHO_TIME_SERVERS' => 4,
74 'DHO_NAME_SERVERS' => 5,
75 'DHO_DOMAIN_NAME_SERVERS' => 6,
76 'DHO_LOG_SERVERS' => 7,
77 'DHO_COOKIE_SERVERS' => 8,
78 'DHO_LPR_SERVERS' => 9,
79 'DHO_IMPRESS_SERVERS' => 10,
80 'DHO_RESOURCE_LOCATION_SERVERS' => 11,
81 'DHO_HOST_NAME' => 12,
82 'DHO_BOOT_SIZE' => 13,
83 'DHO_MERIT_DUMP' => 14,
84 'DHO_DOMAIN_NAME' => 15,
85 'DHO_SWAP_SERVER' => 16,
86 'DHO_ROOT_PATH' => 17,
87 'DHO_EXTENSIONS_PATH' => 18,
88 'DHO_IP_FORWARDING' => 19,
89 'DHO_NON_LOCAL_SOURCE_ROUTING' => 20,
90 'DHO_POLICY_FILTER' => 21,
91 'DHO_MAX_DGRAM_REASSEMBLY' => 22,
92 'DHO_DEFAULT_IP_TTL' => 23,
93 'DHO_PATH_MTU_AGING_TIMEOUT' => 24,
94 'DHO_PATH_MTU_PLATEAU_TABLE' => 25,
95 'DHO_INTERFACE_MTU' => 26,
96 'DHO_ALL_SUBNETS_LOCAL' => 27,
97 'DHO_BROADCAST_ADDRESS' => 28,
98 'DHO_PERFORM_MASK_DISCOVERY' => 29,
99 'DHO_MASK_SUPPLIER' => 30,
100 'DHO_ROUTER_DISCOVERY' => 31,
101 'DHO_ROUTER_SOLICITATION_ADDRESS' => 32,
102 'DHO_STATIC_ROUTES' => 33,
103 'DHO_TRAILER_ENCAPSULATION' => 34,
104 'DHO_ARP_CACHE_TIMEOUT' => 35,
105 'DHO_IEEE802_3_ENCAPSULATION' => 36,
106 'DHO_DEFAULT_TCP_TTL' => 37,
107 'DHO_TCP_KEEPALIVE_INTERVAL' => 38,
108 'DHO_TCP_KEEPALIVE_GARBAGE' => 39,
109 'DHO_NIS_DOMAIN' => 40,
110 'DHO_NIS_SERVERS' => 41,
111 'DHO_NTP_SERVERS' => 42,
112 'DHO_VENDOR_ENCAPSULATED_OPTIONS' => 43,
113 'DHO_NETBIOS_NAME_SERVERS' => 44,
114 'DHO_NETBIOS_DD_SERVER' => 45,
115 'DHO_NETBIOS_NODE_TYPE' => 46,
116 'DHO_NETBIOS_SCOPE' => 47,
117 'DHO_FONT_SERVERS' => 48,
118 'DHO_X_DISPLAY_MANAGER' => 49,
119 'DHO_DHCP_REQUESTED_ADDRESS' => 50,
120 'DHO_DHCP_LEASE_TIME' => 51,
121 'DHO_DHCP_OPTION_OVERLOAD' => 52,
122 'DHO_DHCP_MESSAGE_TYPE' => 53,
123 'DHO_DHCP_SERVER_IDENTIFIER' => 54,
124 'DHO_DHCP_PARAMETER_REQUEST_LIST' => 55,
125 'DHO_DHCP_MESSAGE' => 56,
126 'DHO_DHCP_MAX_MESSAGE_SIZE' => 57,
127 'DHO_DHCP_RENEWAL_TIME' => 58,
128 'DHO_DHCP_REBINDING_TIME' => 59,
129 'DHO_VENDOR_CLASS_IDENTIFIER' => 60,
130 'DHO_DHCP_CLIENT_IDENTIFIER' => 61,
131 'DHO_NWIP_DOMAIN_NAME' => 62,
132 'DHO_NWIP_SUBOPTIONS' => 63,
133 'DHO_NIS_DOMAIN' => 64,
134 'DHO_NIS_SERVER' => 65,
135 'DHO_TFTP_SERVER' => 66,
136 'DHO_BOOTFILE' => 67,
137 'DHO_MOBILE_IP_HOME_AGENT' => 68,
138 'DHO_SMTP_SERVER' => 69,
139 'DHO_POP3_SERVER' => 70,
140 'DHO_NNTP_SERVER' => 71,
141 'DHO_WWW_SERVER' => 72,
142 'DHO_FINGER_SERVER' => 73,
143 'DHO_IRC_SERVER' => 74,
144 'DHO_STREETTALK_SERVER' => 75,
145 'DHO_STDA_SERVER' => 76,
146 'DHO_USER_CLASS' => 77,
147 'DHO_FQDN' => 81,
148 'DHO_DHCP_AGENT_OPTIONS' => 82,
149 'DHO_NDS_SERVERS' => 85,
150 'DHO_NDS_TREE_NAME' => 86,
151 'DHO_USER_AUTHENTICATION_PROTOCOL' => 98,
152 'DHO_AUTO_CONFIGURE' => 116,
153 'DHO_NAME_SERVICE_SEARCH' => 117,
154 'DHO_SUBNET_SELECTION' => 118,
155
156 'HDO_121' => 121,
157
158 # http://tools.ietf.org/html/draft-ietf-dhc-pxelinux-03
159 'DHO_PXELINUX_MAGIC' => 208, # 0xF100747E
160 'DHO_PXELINUX_CONFIG_FILE' => 209,
161 'DHO_PXELINUX_PATH_PREFIX' => 210,
162 'DHO_PXELINUX_REBOOT_TIME' => 211, # default: 300 s
163
164 'DHO_END' => 255
165 );
166
167 %DHCP_MESSAGE = (
168 'DHCPDISCOVER' => 1,
169 'DHCPOFFER' => 2,
170 'DHCPREQUEST' => 3,
171 'DHCPDECLINE' => 4,
172 'DHCPACK' => 5,
173 'DHCPNAK' => 6,
174 'DHCPRELEASE' => 7,
175 'DHCPINFORM' => 8,
176 'DHCPFORCERENEW' => 9,
177
178 'DHCPLEASEQUERY' => 13, # Cisco extension, draft-ietf-dhc-leasequery-08.txt
179 );
180 }
181
182 use constant \%DHO_CODES;
183 %REV_DHO_CODES = reverse %DHO_CODES;
184
185 use constant \%DHCP_MESSAGE;
186 %REV_DHCP_MESSAGE = reverse %DHCP_MESSAGE;
187
188 use constant \%BOOTP_CODES;
189 %REV_BOOTP_CODES = reverse %BOOTP_CODES; # for reverse lookup
190
191 use constant \%HTYPE_CODES;
192 %REV_HTYPE_CODES = reverse %HTYPE_CODES; # for reverse lookup
193
194 #
195 # Format of DHCP options : for pretty-printing
196 # void : no parameter
197 # inet : 4 bytes IP address
198 # inets : list of 4 bytess IP addresses
199 # inets2 : liste of 4 bytes IP addresses pairs (multiple of 8 bytes)
200 # int : 4 bytes integer
201 # short : 2 bytes intteger
202 # shorts : list of 2 bytes integers
203 # byte : 1 byte int
204 # bytes : list of 1 byte code
205 # string : char* (just kidding)
206 # relays : DHCP sub-options (rfc 3046)
207 # id : client identifier : byte (htype) + string (chaddr)
208 #
209 our %DHO_FORMATS = (
210 DHO_PAD() => 'void',
211 DHO_SUBNET_MASK() => 'inet',
212 DHO_TIME_OFFSET() => 'int',
213 DHO_ROUTERS() => 'inets',
214 DHO_TIME_SERVERS() => 'inets',
215 DHO_NAME_SERVERS() => 'inets',
216 DHO_DOMAIN_NAME_SERVERS() => 'inets',
217 DHO_LOG_SERVERS() => 'inets',
218 DHO_COOKIE_SERVERS() => 'inets',
219 DHO_LPR_SERVERS() => 'inets',
220 DHO_IMPRESS_SERVERS() => 'inets',
221 DHO_RESOURCE_LOCATION_SERVERS() => 'inets',
222 DHO_HOST_NAME() => 'string',
223 DHO_BOOT_SIZE() => 'short',
224 DHO_MERIT_DUMP() => 'string',
225 DHO_DOMAIN_NAME() => 'string',
226 DHO_SWAP_SERVER() => 'inet',
227 DHO_ROOT_PATH() => 'string',
228 DHO_EXTENSIONS_PATH() => 'string',
229 DHO_IP_FORWARDING() => 'byte',
230 DHO_NON_LOCAL_SOURCE_ROUTING() => 'byte',
231 DHO_POLICY_FILTER() => 'inets2',
232 DHO_MAX_DGRAM_REASSEMBLY() => 'short',
233 DHO_DEFAULT_IP_TTL() => 'byte',
234 DHO_PATH_MTU_AGING_TIMEOUT() => 'int',
235 DHO_PATH_MTU_PLATEAU_TABLE() => 'shorts',
236 DHO_INTERFACE_MTU() => 'short',
237 DHO_ALL_SUBNETS_LOCAL() => 'byte',
238 DHO_BROADCAST_ADDRESS() => 'inet',
239 DHO_PERFORM_MASK_DISCOVERY() => 'byte',
240 DHO_MASK_SUPPLIER() => 'byte',
241 DHO_ROUTER_DISCOVERY() => 'byte',
242 DHO_ROUTER_SOLICITATION_ADDRESS() => 'inet',
243 DHO_STATIC_ROUTES() => 'inets2',
244 DHO_TRAILER_ENCAPSULATION() => 'byte',
245 DHO_ARP_CACHE_TIMEOUT() => 'int',
246 DHO_IEEE802_3_ENCAPSULATION() => 'byte',
247 DHO_DEFAULT_TCP_TTL() => 'byte',
248 DHO_TCP_KEEPALIVE_INTERVAL() => 'int',
249 DHO_TCP_KEEPALIVE_GARBAGE() => 'byte',
250 DHO_NIS_DOMAIN() => 'string',
251 DHO_NIS_SERVERS() => 'inets',
252 DHO_NTP_SERVERS() => 'inets',
253 # DHO_VENDOR_ENCAPSULATED_OPTIONS() => '',
254 DHO_NETBIOS_NAME_SERVERS() => 'inets',
255 DHO_NETBIOS_DD_SERVER() => 'inets',
256 DHO_NETBIOS_NODE_TYPE() => 'byte',
257 DHO_NETBIOS_SCOPE() => 'string',
258 DHO_FONT_SERVERS() => 'inets',
259 DHO_X_DISPLAY_MANAGER() => 'inets',
260 DHO_DHCP_REQUESTED_ADDRESS() => 'inet',
261 DHO_DHCP_LEASE_TIME() => 'int',
262 DHO_DHCP_OPTION_OVERLOAD() => 'byte',
263 DHO_DHCP_MESSAGE_TYPE() => 'byte',
264 DHO_DHCP_SERVER_IDENTIFIER() => 'inet',
265 DHO_DHCP_PARAMETER_REQUEST_LIST() => 'bytes',
266 DHO_DHCP_MESSAGE() => 'string',
267 DHO_DHCP_MAX_MESSAGE_SIZE() => 'short',
268 DHO_DHCP_RENEWAL_TIME() => 'int',
269 DHO_DHCP_REBINDING_TIME() => 'int',
270 DHO_VENDOR_CLASS_IDENTIFIER() => 'string',
271 DHO_DHCP_CLIENT_IDENTIFIER() => 'ids',
272 DHO_NWIP_DOMAIN_NAME() => 'string', # rfc 2242
273 # DHO_NWIP_SUBOPTIONS() => '', # rfc 2242
274 DHO_NIS_DOMAIN() => 'string',
275 DHO_NIS_SERVER() => 'string',
276 DHO_TFTP_SERVER() => 'string',
277 DHO_BOOTFILE() => 'string',
278 DHO_MOBILE_IP_HOME_AGENT() => 'inets',
279 DHO_SMTP_SERVER() => 'inets',
280 DHO_POP3_SERVER() => 'inets',
281 DHO_NNTP_SERVER() => 'inets',
282 DHO_WWW_SERVER() => 'inets',
283 DHO_FINGER_SERVER() => 'inets',
284 DHO_IRC_SERVER() => 'inets',
285 DHO_STREETTALK_SERVER() => 'inets',
286 DHO_STDA_SERVER() => 'inets',
287 # DHO_USER_CLASS() => '', # rfc 3004
288 # DHO_FQDN() => '', # draft-ietf-dhc-fqdn-option-10.txt
289 # DHO_DHCP_AGENT_OPTIONS() => 'relays', # rfc 3046
290 DHO_NDS_SERVERS() => 'inets', # rfc 2241
291 DHO_NDS_TREE_NAME() => 'string', # rfc 2241
292 DHO_USER_AUTHENTICATION_PROTOCOL() => 'string', # rfc 2485
293 DHO_AUTO_CONFIGURE() => 'byte', # rfc 2563
294 DHO_NAME_SERVICE_SEARCH() => 'shorts', # rfc 2937
295 DHO_SUBNET_SELECTION() => 'inet', # rfc 3011
296
297 DHO_PXELINUX_MAGIC() => 'int', # draft-ietf-dhc-pxelinux-03
298 DHO_PXELINUX_CONFIG_FILE() => 'string',
299 DHO_PXELINUX_PATH_PREFIX() => 'string',
300 DHO_PXELINUX_REBOOT_TIME() => 'int', # 300 s
301
302 );
303
304 1;
305
306 =pod
307
308 =head1 NAME
309
310 Net::DHCP::Constants - Constants for DHCP codes and options
311
312 =head1 SYNOPSIS
313
314 use Net::DHCP::Constants;
315 print "DHCP option SUBNET_MASK is ", DHO_SUBNET_MASK();
316
317 =head1 DESCRIPTION
318
319 Represents constants used in DHCP protocol, defined in RFC 1533, RFC 2132,
320 RFC 2241, RFC 2485, RFC 2563, RFC 2937, RFC 3004, RFC 3011, RFC 3046.
321
322 =head1 TAGS
323
324 As mentioned above, constants can either be imported individually
325 or in sets grouped by tag names. The tag names are:
326
327 =over 4
328
329 =item * bootp_codes
330
331 Imports all of the basic I<BOOTP> constants.
332
333 (01) BOOTREQUEST
334 (02) BOOTREPLY
335
336 =item * htype_codes
337
338 Imports all I<HTYPE> (hardware address type) codes.
339
340 (01) HTYPE_ETHER
341 (06) HTYPE_IEEE802
342 (08) HTYPE_FDDI
343
344 Most common value is HTYPE_ETHER for C<Ethernet>.
345
346 =item * dhcp_message
347
348 Import all DHCP Message codes.
349
350 (01) DHCPDISCOVER
351 (02) DHCPOFFER
352 (03) DHCPREQUEST
353 (04) DHCPDECLINE
354 (05) DHCPACK
355 (06) DHCPNAK
356 (07) DHCPRELEASE
357 (08) DHCPINFORM
358 (09) DHCPFORCERENEW
359 (13) DHCPLEASEQUERY # draft-ietf-dhc-leasequery-08.txt
360
361 =item * dho_codes
362
363 Import all DHCP option codes.
364
365 (000) DHO_PAD
366 (001) DHO_SUBNET_MASK
367 (002) DHO_TIME_OFFSET
368 (003) DHO_ROUTERS
369 (004) DHO_TIME_SERVERS
370 (005) DHO_NAME_SERVERS
371 (006) DHO_DOMAIN_NAME_SERVERS
372 (007) DHO_LOG_SERVERS
373 (008) DHO_COOKIE_SERVERS
374 (009) DHO_LPR_SERVERS
375 (010) DHO_IMPRESS_SERVERS
376 (011) DHO_RESOURCE_LOCATION_SERVERS
377 (012) DHO_HOST_NAME
378 (013) DHO_BOOT_SIZE
379 (014) DHO_MERIT_DUMP
380 (015) DHO_DOMAIN_NAME
381 (016) DHO_SWAP_SERVER
382 (017) DHO_ROOT_PATH
383 (018) DHO_EXTENSIONS_PATH
384 (019) DHO_IP_FORWARDING
385 (020) DHO_NON_LOCAL_SOURCE_ROUTING
386 (021) DHO_POLICY_FILTER
387 (022) DHO_MAX_DGRAM_REASSEMBLY
388 (023) DHO_DEFAULT_IP_TTL
389 (024) DHO_PATH_MTU_AGING_TIMEOUT
390 (025) DHO_PATH_MTU_PLATEAU_TABLE
391 (026) DHO_INTERFACE_MTU
392 (027) DHO_ALL_SUBNETS_LOCAL
393 (028) DHO_BROADCAST_ADDRESS
394 (029) DHO_PERFORM_MASK_DISCOVERY
395 (030) DHO_MASK_SUPPLIER
396 (031) DHO_ROUTER_DISCOVERY
397 (032) DHO_ROUTER_SOLICITATION_ADDRESS
398 (033) DHO_STATIC_ROUTES
399 (034) DHO_TRAILER_ENCAPSULATION
400 (035) DHO_ARP_CACHE_TIMEOUT
401 (036) DHO_IEEE802_3_ENCAPSULATION
402 (037) DHO_DEFAULT_TCP_TTL
403 (038) DHO_TCP_KEEPALIVE_INTERVAL
404 (039) DHO_TCP_KEEPALIVE_GARBAGE
405 (041) DHO_NIS_SERVERS
406 (042) DHO_NTP_SERVERS
407 (043) DHO_VENDOR_ENCAPSULATED_OPTIONS
408 (044) DHO_NETBIOS_NAME_SERVERS
409 (045) DHO_NETBIOS_DD_SERVER
410 (046) DHO_NETBIOS_NODE_TYPE
411 (047) DHO_NETBIOS_SCOPE
412 (048) DHO_FONT_SERVERS
413 (049) DHO_X_DISPLAY_MANAGER
414 (050) DHO_DHCP_REQUESTED_ADDRESS
415 (051) DHO_DHCP_LEASE_TIME
416 (052) DHO_DHCP_OPTION_OVERLOAD
417 (053) DHO_DHCP_MESSAGE_TYPE
418 (054) DHO_DHCP_SERVER_IDENTIFIER
419 (055) DHO_DHCP_PARAMETER_REQUEST_LIST
420 (056) DHO_DHCP_MESSAGE
421 (057) DHO_DHCP_MAX_MESSAGE_SIZE
422 (058) DHO_DHCP_RENEWAL_TIME
423 (059) DHO_DHCP_REBINDING_TIME
424 (060) DHO_VENDOR_CLASS_IDENTIFIER
425 (061) DHO_DHCP_CLIENT_IDENTIFIER
426 (062) DHO_NWIP_DOMAIN_NAME
427 (063) DHO_NWIP_SUBOPTIONS
428 (064) DHO_NIS_DOMAIN
429 (065) DHO_NIS_SERVER
430 (066) DHO_TFTP_SERVER
431 (067) DHO_BOOTFILE
432 (068) DHO_MOBILE_IP_HOME_AGENT
433 (069) DHO_SMTP_SERVER
434 (070) DHO_POP3_SERVER
435 (071) DHO_NNTP_SERVER
436 (072) DHO_WWW_SERVER
437 (073) DHO_FINGER_SERVER
438 (074) DHO_IRC_SERVER
439 (075) DHO_STREETTALK_SERVER
440 (076) DHO_STDA_SERVER
441 (077) DHO_USER_CLASS
442 (081) DHO_FQDN
443 (082) DHO_DHCP_AGENT_OPTIONS
444 (085) DHO_NDS_SERVERS
445 (086) DHO_NDS_TREE_NAME
446 (098) DHO_USER_AUTHENTICATION_PROTOCOL
447 (116) DHO_AUTO_CONFIGURE
448 (117) DHO_NAME_SERVICE_SEARCH
449 (118) DHO_SUBNET_SELECTION
450 (255) DHO_END
451
452 =back
453
454 =head1 TO DO, LIMITATIONS
455
456 Automatic parsing of DHO_VENDOR_ENCAPSULATED_OPTIONS (code 43) is unsupported.
457
458 Automatic parsing of DHO_NWIP_SUBOPTIONS (code 63 - rfc 2242) is unsupported.
459
460 Automatic parsing of DHO_USER_CLASS (code 77 - rfc 3004) is unsupported.
461
462 =head1 SEE ALSO
463
464 L<Net::DHCP::Packet>, L<Net::DHCP::Options>
465
466 =head1 AUTHOR
467
468 Stephan Hadinger E<lt>shadinger@cpan.orgE<gt>.
469
470 =head1 COPYRIGHT
471
472 This program is free software; you can redistribute it and/or
473 modify it under the same terms as Perl itself.
474
475 =cut

  ViewVC Help
Powered by ViewVC 1.1.26