/[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 27 - (show annotations)
Wed Jul 29 00:46:29 2009 UTC (12 years, 2 months ago) by dpavlin
File size: 13780 byte(s)
really implement DHCP protocol, so this server now has correct name :-)

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 'DHO_END' => 255
157 );
158
159 %DHCP_MESSAGE = (
160 'DHCPDISCOVER' => 1,
161 'DHCPOFFER' => 2,
162 'DHCPREQUEST' => 3,
163 'DHCPDECLINE' => 4,
164 'DHCPACK' => 5,
165 'DHCPNAK' => 6,
166 'DHCPRELEASE' => 7,
167 'DHCPINFORM' => 8,
168 'DHCPFORCERENEW' => 9,
169
170 'DHCPLEASEQUERY' => 13, # Cisco extension, draft-ietf-dhc-leasequery-08.txt
171 );
172 }
173
174 use constant \%DHO_CODES;
175 %REV_DHO_CODES = reverse %DHO_CODES;
176
177 use constant \%DHCP_MESSAGE;
178 %REV_DHCP_MESSAGE = reverse %DHCP_MESSAGE;
179
180 use constant \%BOOTP_CODES;
181 %REV_BOOTP_CODES = reverse %BOOTP_CODES; # for reverse lookup
182
183 use constant \%HTYPE_CODES;
184 %REV_HTYPE_CODES = reverse %HTYPE_CODES; # for reverse lookup
185
186 #
187 # Format of DHCP options : for pretty-printing
188 # void : no parameter
189 # inet : 4 bytes IP address
190 # inets : list of 4 bytess IP addresses
191 # inets2 : liste of 4 bytes IP addresses pairs (multiple of 8 bytes)
192 # int : 4 bytes integer
193 # short : 2 bytes intteger
194 # shorts : list of 2 bytes integers
195 # byte : 1 byte int
196 # bytes : list of 1 byte code
197 # string : char* (just kidding)
198 # relays : DHCP sub-options (rfc 3046)
199 # id : client identifier : byte (htype) + string (chaddr)
200 #
201 our %DHO_FORMATS = (
202 DHO_PAD() => 'void',
203 DHO_SUBNET_MASK() => 'inet',
204 DHO_TIME_OFFSET() => 'int',
205 DHO_ROUTERS() => 'inets',
206 DHO_TIME_SERVERS() => 'inets',
207 DHO_NAME_SERVERS() => 'inets',
208 DHO_DOMAIN_NAME_SERVERS() => 'inets',
209 DHO_LOG_SERVERS() => 'inets',
210 DHO_COOKIE_SERVERS() => 'inets',
211 DHO_LPR_SERVERS() => 'inets',
212 DHO_IMPRESS_SERVERS() => 'inets',
213 DHO_RESOURCE_LOCATION_SERVERS() => 'inets',
214 DHO_HOST_NAME() => 'string',
215 DHO_BOOT_SIZE() => 'short',
216 DHO_MERIT_DUMP() => 'string',
217 DHO_DOMAIN_NAME() => 'string',
218 DHO_SWAP_SERVER() => 'inet',
219 DHO_ROOT_PATH() => 'string',
220 DHO_EXTENSIONS_PATH() => 'string',
221 DHO_IP_FORWARDING() => 'byte',
222 DHO_NON_LOCAL_SOURCE_ROUTING() => 'byte',
223 DHO_POLICY_FILTER() => 'inets2',
224 DHO_MAX_DGRAM_REASSEMBLY() => 'short',
225 DHO_DEFAULT_IP_TTL() => 'byte',
226 DHO_PATH_MTU_AGING_TIMEOUT() => 'int',
227 DHO_PATH_MTU_PLATEAU_TABLE() => 'shorts',
228 DHO_INTERFACE_MTU() => 'short',
229 DHO_ALL_SUBNETS_LOCAL() => 'byte',
230 DHO_BROADCAST_ADDRESS() => 'inet',
231 DHO_PERFORM_MASK_DISCOVERY() => 'byte',
232 DHO_MASK_SUPPLIER() => 'byte',
233 DHO_ROUTER_DISCOVERY() => 'byte',
234 DHO_ROUTER_SOLICITATION_ADDRESS() => 'inet',
235 DHO_STATIC_ROUTES() => 'inets2',
236 DHO_TRAILER_ENCAPSULATION() => 'byte',
237 DHO_ARP_CACHE_TIMEOUT() => 'int',
238 DHO_IEEE802_3_ENCAPSULATION() => 'byte',
239 DHO_DEFAULT_TCP_TTL() => 'byte',
240 DHO_TCP_KEEPALIVE_INTERVAL() => 'int',
241 DHO_TCP_KEEPALIVE_GARBAGE() => 'byte',
242 DHO_NIS_DOMAIN() => 'string',
243 DHO_NIS_SERVERS() => 'inets',
244 DHO_NTP_SERVERS() => 'inets',
245 # DHO_VENDOR_ENCAPSULATED_OPTIONS() => '',
246 DHO_NETBIOS_NAME_SERVERS() => 'inets',
247 DHO_NETBIOS_DD_SERVER() => 'inets',
248 DHO_NETBIOS_NODE_TYPE() => 'byte',
249 DHO_NETBIOS_SCOPE() => 'string',
250 DHO_FONT_SERVERS() => 'inets',
251 DHO_X_DISPLAY_MANAGER() => 'inets',
252 DHO_DHCP_REQUESTED_ADDRESS() => 'inet',
253 DHO_DHCP_LEASE_TIME() => 'int',
254 DHO_DHCP_OPTION_OVERLOAD() => 'byte',
255 DHO_DHCP_MESSAGE_TYPE() => 'byte',
256 DHO_DHCP_SERVER_IDENTIFIER() => 'inet',
257 DHO_DHCP_PARAMETER_REQUEST_LIST() => 'bytes',
258 DHO_DHCP_MESSAGE() => 'string',
259 DHO_DHCP_MAX_MESSAGE_SIZE() => 'short',
260 DHO_DHCP_RENEWAL_TIME() => 'int',
261 DHO_DHCP_REBINDING_TIME() => 'int',
262 DHO_VENDOR_CLASS_IDENTIFIER() => 'string',
263 # DHO_DHCP_CLIENT_IDENTIFIER() => 'ids',
264 DHO_NWIP_DOMAIN_NAME() => 'string', # rfc 2242
265 # DHO_NWIP_SUBOPTIONS() => '', # rfc 2242
266 DHO_NIS_DOMAIN() => 'string',
267 DHO_NIS_SERVER() => 'string',
268 DHO_TFTP_SERVER() => 'string',
269 DHO_BOOTFILE() => 'string',
270 DHO_MOBILE_IP_HOME_AGENT() => 'inets',
271 DHO_SMTP_SERVER() => 'inets',
272 DHO_POP3_SERVER() => 'inets',
273 DHO_NNTP_SERVER() => 'inets',
274 DHO_WWW_SERVER() => 'inets',
275 DHO_FINGER_SERVER() => 'inets',
276 DHO_IRC_SERVER() => 'inets',
277 DHO_STREETTALK_SERVER() => 'inets',
278 DHO_STDA_SERVER() => 'inets',
279 # DHO_USER_CLASS() => '', # rfc 3004
280 # DHO_FQDN() => '', # draft-ietf-dhc-fqdn-option-10.txt
281 # DHO_DHCP_AGENT_OPTIONS() => 'relays', # rfc 3046
282 DHO_NDS_SERVERS() => 'inets', # rfc 2241
283 DHO_NDS_TREE_NAME() => 'string', # rfc 2241
284 DHO_USER_AUTHENTICATION_PROTOCOL() => 'string', # rfc 2485
285 DHO_AUTO_CONFIGURE() => 'byte', # rfc 2563
286 DHO_NAME_SERVICE_SEARCH() => 'shorts', # rfc 2937
287 DHO_SUBNET_SELECTION() => 'inet', # rfc 3011
288
289 );
290
291 1;
292
293 =pod
294
295 =head1 NAME
296
297 Net::DHCP::Constants - Constants for DHCP codes and options
298
299 =head1 SYNOPSIS
300
301 use Net::DHCP::Constants;
302 print "DHCP option SUBNET_MASK is ", DHO_SUBNET_MASK();
303
304 =head1 DESCRIPTION
305
306 Represents constants used in DHCP protocol, defined in RFC 1533, RFC 2132,
307 RFC 2241, RFC 2485, RFC 2563, RFC 2937, RFC 3004, RFC 3011, RFC 3046.
308
309 =head1 TAGS
310
311 As mentioned above, constants can either be imported individually
312 or in sets grouped by tag names. The tag names are:
313
314 =over 4
315
316 =item * bootp_codes
317
318 Imports all of the basic I<BOOTP> constants.
319
320 (01) BOOTREQUEST
321 (02) BOOTREPLY
322
323 =item * htype_codes
324
325 Imports all I<HTYPE> (hardware address type) codes.
326
327 (01) HTYPE_ETHER
328 (06) HTYPE_IEEE802
329 (08) HTYPE_FDDI
330
331 Most common value is HTYPE_ETHER for C<Ethernet>.
332
333 =item * dhcp_message
334
335 Import all DHCP Message codes.
336
337 (01) DHCPDISCOVER
338 (02) DHCPOFFER
339 (03) DHCPREQUEST
340 (04) DHCPDECLINE
341 (05) DHCPACK
342 (06) DHCPNAK
343 (07) DHCPRELEASE
344 (08) DHCPINFORM
345 (09) DHCPFORCERENEW
346 (13) DHCPLEASEQUERY # draft-ietf-dhc-leasequery-08.txt
347
348 =item * dho_codes
349
350 Import all DHCP option codes.
351
352 (000) DHO_PAD
353 (001) DHO_SUBNET_MASK
354 (002) DHO_TIME_OFFSET
355 (003) DHO_ROUTERS
356 (004) DHO_TIME_SERVERS
357 (005) DHO_NAME_SERVERS
358 (006) DHO_DOMAIN_NAME_SERVERS
359 (007) DHO_LOG_SERVERS
360 (008) DHO_COOKIE_SERVERS
361 (009) DHO_LPR_SERVERS
362 (010) DHO_IMPRESS_SERVERS
363 (011) DHO_RESOURCE_LOCATION_SERVERS
364 (012) DHO_HOST_NAME
365 (013) DHO_BOOT_SIZE
366 (014) DHO_MERIT_DUMP
367 (015) DHO_DOMAIN_NAME
368 (016) DHO_SWAP_SERVER
369 (017) DHO_ROOT_PATH
370 (018) DHO_EXTENSIONS_PATH
371 (019) DHO_IP_FORWARDING
372 (020) DHO_NON_LOCAL_SOURCE_ROUTING
373 (021) DHO_POLICY_FILTER
374 (022) DHO_MAX_DGRAM_REASSEMBLY
375 (023) DHO_DEFAULT_IP_TTL
376 (024) DHO_PATH_MTU_AGING_TIMEOUT
377 (025) DHO_PATH_MTU_PLATEAU_TABLE
378 (026) DHO_INTERFACE_MTU
379 (027) DHO_ALL_SUBNETS_LOCAL
380 (028) DHO_BROADCAST_ADDRESS
381 (029) DHO_PERFORM_MASK_DISCOVERY
382 (030) DHO_MASK_SUPPLIER
383 (031) DHO_ROUTER_DISCOVERY
384 (032) DHO_ROUTER_SOLICITATION_ADDRESS
385 (033) DHO_STATIC_ROUTES
386 (034) DHO_TRAILER_ENCAPSULATION
387 (035) DHO_ARP_CACHE_TIMEOUT
388 (036) DHO_IEEE802_3_ENCAPSULATION
389 (037) DHO_DEFAULT_TCP_TTL
390 (038) DHO_TCP_KEEPALIVE_INTERVAL
391 (039) DHO_TCP_KEEPALIVE_GARBAGE
392 (041) DHO_NIS_SERVERS
393 (042) DHO_NTP_SERVERS
394 (043) DHO_VENDOR_ENCAPSULATED_OPTIONS
395 (044) DHO_NETBIOS_NAME_SERVERS
396 (045) DHO_NETBIOS_DD_SERVER
397 (046) DHO_NETBIOS_NODE_TYPE
398 (047) DHO_NETBIOS_SCOPE
399 (048) DHO_FONT_SERVERS
400 (049) DHO_X_DISPLAY_MANAGER
401 (050) DHO_DHCP_REQUESTED_ADDRESS
402 (051) DHO_DHCP_LEASE_TIME
403 (052) DHO_DHCP_OPTION_OVERLOAD
404 (053) DHO_DHCP_MESSAGE_TYPE
405 (054) DHO_DHCP_SERVER_IDENTIFIER
406 (055) DHO_DHCP_PARAMETER_REQUEST_LIST
407 (056) DHO_DHCP_MESSAGE
408 (057) DHO_DHCP_MAX_MESSAGE_SIZE
409 (058) DHO_DHCP_RENEWAL_TIME
410 (059) DHO_DHCP_REBINDING_TIME
411 (060) DHO_VENDOR_CLASS_IDENTIFIER
412 (061) DHO_DHCP_CLIENT_IDENTIFIER
413 (062) DHO_NWIP_DOMAIN_NAME
414 (063) DHO_NWIP_SUBOPTIONS
415 (064) DHO_NIS_DOMAIN
416 (065) DHO_NIS_SERVER
417 (066) DHO_TFTP_SERVER
418 (067) DHO_BOOTFILE
419 (068) DHO_MOBILE_IP_HOME_AGENT
420 (069) DHO_SMTP_SERVER
421 (070) DHO_POP3_SERVER
422 (071) DHO_NNTP_SERVER
423 (072) DHO_WWW_SERVER
424 (073) DHO_FINGER_SERVER
425 (074) DHO_IRC_SERVER
426 (075) DHO_STREETTALK_SERVER
427 (076) DHO_STDA_SERVER
428 (077) DHO_USER_CLASS
429 (081) DHO_FQDN
430 (082) DHO_DHCP_AGENT_OPTIONS
431 (085) DHO_NDS_SERVERS
432 (086) DHO_NDS_TREE_NAME
433 (098) DHO_USER_AUTHENTICATION_PROTOCOL
434 (116) DHO_AUTO_CONFIGURE
435 (117) DHO_NAME_SERVICE_SEARCH
436 (118) DHO_SUBNET_SELECTION
437 (255) DHO_END
438
439 =back
440
441 =head1 TO DO, LIMITATIONS
442
443 Automatic parsing of DHO_VENDOR_ENCAPSULATED_OPTIONS (code 43) is unsupported.
444
445 Automatic parsing of DHO_NWIP_SUBOPTIONS (code 63 - rfc 2242) is unsupported.
446
447 Automatic parsing of DHO_USER_CLASS (code 77 - rfc 3004) is unsupported.
448
449 =head1 SEE ALSO
450
451 L<Net::DHCP::Packet>, L<Net::DHCP::Options>
452
453 =head1 AUTHOR
454
455 Stephan Hadinger E<lt>shadinger@cpan.orgE<gt>.
456
457 =head1 COPYRIGHT
458
459 This program is free software; you can redistribute it and/or
460 modify it under the same terms as Perl itself.
461
462 =cut

  ViewVC Help
Powered by ViewVC 1.1.26