1 | # Anemon Dhcp |
---|
2 | # Copyright (C) 2005 Mathieu Ignacio -- mignacio@april.org |
---|
3 | # |
---|
4 | # This program is free software; you can redistribute it and/or modify |
---|
5 | # it under the terms of the GNU General Public License as published by |
---|
6 | # the Free Software Foundation; either version 2 of the License, or |
---|
7 | # (at your option) any later version. |
---|
8 | # |
---|
9 | # This program is distributed in the hope that it will be useful, |
---|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
12 | # GNU General Public License for more details. |
---|
13 | # |
---|
14 | # You should have received a copy of the GNU General Public License |
---|
15 | # along with this program; if not, write to the Free Software |
---|
16 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA |
---|
17 | |
---|
18 | |
---|
19 | MagicCookie = [99,130,83,99] |
---|
20 | |
---|
21 | |
---|
22 | # DhcpBaseOptions = '{fieldname':[location,length]} |
---|
23 | DhcpFields = {'op':[0,1], |
---|
24 | 'htype':[1,1], |
---|
25 | 'hlen':[2,1], |
---|
26 | 'hops':[3,1], |
---|
27 | 'xid':[4,4], |
---|
28 | 'secs':[8,2], |
---|
29 | 'flags':[10,2], |
---|
30 | 'ciaddr':[12,4], |
---|
31 | 'yiaddr':[16,4], |
---|
32 | 'siaddr':[20,4], |
---|
33 | 'giaddr':[24,4], |
---|
34 | 'chaddr':[28,16], |
---|
35 | 'sname':[44,64], |
---|
36 | 'file':[108,128] |
---|
37 | } |
---|
38 | DhcpFieldsTypes = {'op':"int", |
---|
39 | 'htype':"int", |
---|
40 | 'hlen':"int", |
---|
41 | 'hops':"int", |
---|
42 | 'xid':"int4", |
---|
43 | 'secs':"int2", |
---|
44 | 'flags':"int2", |
---|
45 | 'ciaddr':"ipv4", |
---|
46 | 'yiaddr':"ipv4", |
---|
47 | 'siaddr':"ipv4", |
---|
48 | 'giaddr':"ipv4", |
---|
49 | 'chaddr':"hwmac", |
---|
50 | 'sname':"str", |
---|
51 | 'file':"str" |
---|
52 | } |
---|
53 | |
---|
54 | # DhcpOptions = 'option_name':option_code |
---|
55 | DhcpOptions = {'pad':0, |
---|
56 | |
---|
57 | # Vendor Extension |
---|
58 | 'subnet_mask':1,'time_offset':2, |
---|
59 | 'router':3,'time_server':4,'name_server':5, |
---|
60 | 'domain_name_server':6,'log_server':7, |
---|
61 | 'cookie_server':8,'lpr_server':9, |
---|
62 | 'impress_server':10,'resource_location_server':11, |
---|
63 | 'host_name':12,'boot_file':13,'merit_dump_file':14, |
---|
64 | 'domain_name':15,'swap_server':16,'root_path':17,'extensions_path':18, |
---|
65 | |
---|
66 | # IP layer parameters per host |
---|
67 | 'ip_forwarding':19,'nonlocal_source_rooting':20, |
---|
68 | 'policy_filter':21,'maximum_datagram_reassembly_size':22, |
---|
69 | 'default_ip_time-to-live':23,'path_mtu_aging_timeout':24, |
---|
70 | 'path_mtu_table':25, |
---|
71 | |
---|
72 | # IP layer parameters per interface |
---|
73 | 'interface_mtu':26,'all_subnets_are_local':27, |
---|
74 | 'broadcast_address':28,'perform_mask_discovery':29, |
---|
75 | 'mask_supplier':30,'perform_router_discovery':31, |
---|
76 | 'routeur_solicitation_address':32,'static_route':33, |
---|
77 | |
---|
78 | # link layer parameters per interface |
---|
79 | 'trailer_encapsulation':34,'arp_cache_timeout':35, |
---|
80 | 'ethernet_encapsulation':36, |
---|
81 | |
---|
82 | # TCP parameters |
---|
83 | 'tcp_default_ttl':37,'tcp_keepalive_interval':38, |
---|
84 | 'tcp_keepalive_garbage':39, |
---|
85 | |
---|
86 | # Applications and service parameters |
---|
87 | 'nis_domain':40, |
---|
88 | 'nis_servers':41, |
---|
89 | 'ntp_servers':42, |
---|
90 | 'vendor_specific_information':43, |
---|
91 | 'nbns':44, |
---|
92 | 'nbdd':45,'node_type':46, |
---|
93 | 'netbios_scope':47,'x_window_system_font_server':48, |
---|
94 | 'x_window_system_display_manager':49, |
---|
95 | |
---|
96 | # DHCP extensions |
---|
97 | 'request_ip_address':50, |
---|
98 | 'ip_address_lease_time':51, |
---|
99 | 'overload':52, |
---|
100 | 'dhcp_message_type':53, |
---|
101 | 'server_identifier':54, |
---|
102 | 'parameter_request_list':55, |
---|
103 | 'message':56, |
---|
104 | 'maximum_dhcp_message_size':57, |
---|
105 | 'renewal_time_value':58, |
---|
106 | 'rebinding_time_value':59, |
---|
107 | 'class_identifier':60, |
---|
108 | 'client_identifier':61, |
---|
109 | |
---|
110 | # Add from RFC 2132 |
---|
111 | 'netware_ip_domain_name':62, |
---|
112 | 'netware_ip_sub_options':63, |
---|
113 | |
---|
114 | 'nis+_domain':64, |
---|
115 | 'nis+_servers':65, |
---|
116 | 'tftp_server_name':66, |
---|
117 | 'bootfile_name':67, |
---|
118 | 'mobile_ip_home_agent':68, |
---|
119 | 'smtp_servers':69, |
---|
120 | 'pop_servers':70, |
---|
121 | 'nntp_servers':71, |
---|
122 | 'default_world_wide_web_server':72, |
---|
123 | 'default_finger_server':73, |
---|
124 | 'default_internet_relay_chat_server':74, |
---|
125 | 'streettalk_server':75, |
---|
126 | 'streettalk_directory_assistance_server':76, |
---|
127 | |
---|
128 | 'user_class':77, |
---|
129 | 'directory_agent':78, |
---|
130 | 'service_scope':79, |
---|
131 | 'rapid_commit':80, |
---|
132 | |
---|
133 | 'client_fqdn':81, |
---|
134 | 'relay_agent':82, |
---|
135 | 'internet_storage_name_service':83, |
---|
136 | '84':84, |
---|
137 | 'nds_server':85, |
---|
138 | 'nds_tree_name':86, |
---|
139 | 'nds_context':87, |
---|
140 | '88':88, |
---|
141 | '89':89, |
---|
142 | 'authentication':90, |
---|
143 | 'client_last_transaction_time':91, |
---|
144 | 'associated_ip':92, |
---|
145 | 'client_system':93, |
---|
146 | 'client_ndi':94, |
---|
147 | 'ldap':95, |
---|
148 | 'unassigned':96, |
---|
149 | 'uuid_guid':97, |
---|
150 | 'open_group_user_auth':98, |
---|
151 | 'unassigned':99, |
---|
152 | 'unassigned':100, |
---|
153 | 'unassigned':101, |
---|
154 | 'unassigned':102, |
---|
155 | 'unassigned':103, |
---|
156 | 'unassigned':104, |
---|
157 | 'unassigned':105, |
---|
158 | 'unassigned':106, |
---|
159 | 'unassigned':107, |
---|
160 | 'unassigned':108, |
---|
161 | 'unassigned':109, |
---|
162 | 'unassigned':110, |
---|
163 | 'unassigned':111, |
---|
164 | 'netinfo_address':112, |
---|
165 | 'netinfo_tag':113, |
---|
166 | 'url':114, |
---|
167 | 'unassigned':115, |
---|
168 | 'auto_config':116, |
---|
169 | 'name_service_search':117, |
---|
170 | 'subnet_selection':118, |
---|
171 | 'domain_search':119, |
---|
172 | 'sip_servers':120, |
---|
173 | 'classless_static_route':121, |
---|
174 | 'cablelabs_client_configuration':122, |
---|
175 | 'geoconf':123, |
---|
176 | 'vendor_class':124, |
---|
177 | 'vendor_specific':125, |
---|
178 | '126':126,'127':127,'128':128,'129':129, |
---|
179 | '130':130,'131':131,'132':132,'133':133, |
---|
180 | '134':134,'135':135,'136':136,'137':137, |
---|
181 | '138':138,'139':139,'140':140,'141':141, |
---|
182 | '142':142,'143':143,'144':144,'145':145, |
---|
183 | '146':146,'147':147,'148':148,'149':149, |
---|
184 | '150':150,'151':151,'152':152,'153':153, |
---|
185 | '154':154,'155':155,'156':156,'157':157, |
---|
186 | '158':158,'159':159,'160':160,'161':161, |
---|
187 | '162':162,'163':163,'164':164,'165':165, |
---|
188 | '166':166,'167':167,'168':168,'169':169, |
---|
189 | '170':170,'171':171,'172':172,'173':173, |
---|
190 | '174':174,'175':175,'176':176,'177':177, |
---|
191 | '178':178,'179':179,'180':180,'181':181, |
---|
192 | '182':182,'183':183,'184':184,'185':185, |
---|
193 | '186':186,'187':187,'188':188,'189':189, |
---|
194 | '190':190,'191':191,'192':192,'193':193, |
---|
195 | '194':194,'195':195,'196':196,'197':197, |
---|
196 | '198':198,'199':199,'200':200,'201':201, |
---|
197 | '202':202,'203':203,'204':204,'205':205, |
---|
198 | '206':206,'207':207,'208':208,'209':209, |
---|
199 | '210':210,'211':211,'212':212,'213':213, |
---|
200 | '214':214,'215':215,'216':216,'217':217, |
---|
201 | '218':218,'219':219,'220':220,'221':221, |
---|
202 | '222':222,'223':223,'224':224,'225':225, |
---|
203 | '226':226,'227':227,'228':228,'229':229, |
---|
204 | '230':230,'231':231,'232':232,'233':233, |
---|
205 | '234':234,'235':235,'236':236,'237':237, |
---|
206 | '238':238,'239':239,'240':240,'241':241, |
---|
207 | '242':242,'243':243,'244':244,'245':245, |
---|
208 | '246':246,'247':247,'248':248,'249':249, |
---|
209 | '250':250,'251':251,'252':252,'253':253, |
---|
210 | '254':254,'end':255 |
---|
211 | |
---|
212 | } |
---|
213 | |
---|
214 | # DhcpOptionsList : reverse of DhcpOptions |
---|
215 | DhcpOptionsList = ['pad', |
---|
216 | |
---|
217 | # Vendor Extension |
---|
218 | 'subnet_mask','time_offset', |
---|
219 | 'router','time_server','name_server', |
---|
220 | 'domain_name_server','log_server', |
---|
221 | 'cookie_server','lpr_server', |
---|
222 | 'impress_server','resource_location_server', |
---|
223 | 'host_name','boot_file','merit_dump_file', |
---|
224 | 'domain_name','swap_server','root_path','extensions_path', |
---|
225 | |
---|
226 | # IP layer parameters per host |
---|
227 | 'ip_forwarding','nonlocal_source_rooting', |
---|
228 | 'policy_filter','maximum_datagram_reassembly_size', |
---|
229 | 'default_ip_time-to-live','path_mtu_aging_timeout', |
---|
230 | 'path_mtu_table', |
---|
231 | |
---|
232 | # IP layer parameters per interface |
---|
233 | 'interface_mtu','all_subnets_are_local', |
---|
234 | 'broadcast_address','perform_mask_discovery', |
---|
235 | 'mask_supplier','perform_router_discovery', |
---|
236 | 'routeur_solicitation_address','static_route', |
---|
237 | |
---|
238 | # link layer parameters per interface |
---|
239 | 'trailer_encapsulation','arp_cache_timeout', |
---|
240 | 'ethernet_encapsulation', |
---|
241 | |
---|
242 | # TCP parameters |
---|
243 | 'tcp_default_ttl','tcp_keepalive_interval', |
---|
244 | 'tcp_keepalive_garbage', |
---|
245 | |
---|
246 | # Applications and service parameters |
---|
247 | 'nis_domain', |
---|
248 | 'nis_servers', |
---|
249 | 'ntp_servers', |
---|
250 | 'vendor_specific_information','nbns', |
---|
251 | 'nbdd','node_type', |
---|
252 | 'netbios_scope','x_window_system_font_server', |
---|
253 | 'x_window_system_display_manager', |
---|
254 | |
---|
255 | # DHCP extensions |
---|
256 | 'request_ip_address', |
---|
257 | 'ip_address_lease_time', |
---|
258 | 'overload', |
---|
259 | 'dhcp_message_type', |
---|
260 | 'server_identifier', |
---|
261 | 'parameter_request_list', |
---|
262 | 'message', |
---|
263 | 'maximum_dhcp_message_size', |
---|
264 | 'renewal_time_value', |
---|
265 | 'rebinding_time_value', |
---|
266 | 'class_identifier', |
---|
267 | 'client_identifier', |
---|
268 | |
---|
269 | |
---|
270 | # adds from RFC 2132,2242 |
---|
271 | 'netware_ip_domain_name', |
---|
272 | 'netware_ip_sub_options', |
---|
273 | 'nis+_domain', |
---|
274 | 'nis+_servers', |
---|
275 | 'tftp_server_name', |
---|
276 | 'bootfile_name', |
---|
277 | 'mobile_ip_home_agent', |
---|
278 | 'smtp_servers', |
---|
279 | 'pop_servers', |
---|
280 | 'nntp_servers', |
---|
281 | 'default_world_wide_web_server', |
---|
282 | 'default_finger_server', |
---|
283 | 'default_internet_relay_chat_server', |
---|
284 | 'streettalk_server', |
---|
285 | 'streettalk_directory_assistance_server', |
---|
286 | 'user_class','directory_agent','service_scope', |
---|
287 | |
---|
288 | # 80 |
---|
289 | 'rapid_commit','client_fqdn','relay_agent', |
---|
290 | 'internet_storage_name_service', |
---|
291 | '84', |
---|
292 | 'nds_server','nds_tree_name','nds_context', |
---|
293 | '88','89', |
---|
294 | |
---|
295 | #90 |
---|
296 | 'authentication', |
---|
297 | 'client_last_transaction_time','associated_ip', #RFC 4388 |
---|
298 | 'client_system', 'client_ndi', #RFC 3679 |
---|
299 | 'ldap','unassigned','uuid_guid', #RFC 3679 |
---|
300 | 'open_group_user_auth', #RFC 2485 |
---|
301 | |
---|
302 | # 99->115 RFC3679 |
---|
303 | 'unassigned','unassigned','unassigned', |
---|
304 | 'unassigned','unassigned','unassigned', |
---|
305 | 'unassigned','unassigned','unassigned', |
---|
306 | 'unassigned','unassigned','unassigned', |
---|
307 | 'unassigned','netinfo_address','netinfo_tag', |
---|
308 | 'url','unassigned', |
---|
309 | |
---|
310 | #116 |
---|
311 | 'auto_config','name_service_search','subnet_selection', |
---|
312 | 'domain_search','sip_servers','classless_static_route', |
---|
313 | 'cablelabs_client_configuration','geoconf', |
---|
314 | |
---|
315 | #124 |
---|
316 | 'vendor_class', 'vendor_specific', |
---|
317 | |
---|
318 | '126','127','128','129', |
---|
319 | '130','131','132','133','134','135','136','137','138','139', |
---|
320 | '140','141','142','143','144','145','146','147','148','149', |
---|
321 | '150','151','152','153','154','155','156','157','158','159', |
---|
322 | '160','161','162','163','164','165','166','167','168','169', |
---|
323 | '170','171','172','173','174','175','176','177','178','179', |
---|
324 | '180','181','182','183','184','185','186','187','188','189', |
---|
325 | '190','191','192','193','194','195','196','197','198','199', |
---|
326 | '200','201','202','203','204','205','206','207','208','209', |
---|
327 | '210','211','212','213','214','215','216','217','218','219', |
---|
328 | '220','221','222','223','224','225','226','227','228','229', |
---|
329 | '230','231','232','233','234','235','236','237','238','239', |
---|
330 | '240','241','242','243','244','245','246','247','248','249', |
---|
331 | '250','251','252','253','254', |
---|
332 | |
---|
333 | 'end' |
---|
334 | ] |
---|
335 | |
---|
336 | |
---|
337 | # See http://www.iana.org/assignments/bootp-dhcp-parameters |
---|
338 | # FIXME : verify all ipv4+ options, somes are 32 bits... |
---|
339 | |
---|
340 | DhcpOptionsTypes = {0:"none", 1:"ipv4", 2:"ipv4", 3:"ipv4+", |
---|
341 | 4:"ipv4+", 5:"ipv4+", 6:"ipv4+", 7:"ipv4+", |
---|
342 | 8:"ipv4+", 9:"ipv4+", 10:"ipv4+", 11:"ipv4+", |
---|
343 | 12:"string", 13:"16-bits", 14:"string", 15:"string", |
---|
344 | 16:"ipv4", 17:"string", 18:"string", 19:"bool", |
---|
345 | 20:"bool", 21:"ipv4+", 22:"16-bits", 23:"char", |
---|
346 | 24:"ipv4", 25:"16-bits", 26:"16-bits", 27:"bool", |
---|
347 | 28:"ipv4", 29:"bool", 30:"bool", 31:"bool", |
---|
348 | 32:"ipv4", 33:"ipv4+", 34:"bool", 35:"32-bits", |
---|
349 | 36:"bool", 37:"char", 38:"32-bits", 39:"bool", |
---|
350 | 40:"string", 41:"ipv4+", 42:"ipv4+", 43:"string", |
---|
351 | 44:"ipv4+", 45:"ipv4+", 46:"char", 47:"string", |
---|
352 | 48:"ipv4+", 49:"ipv4+", 50:"ipv4", 51:"32-bits", |
---|
353 | 52:"char", 53:"char", 54:"ipv4", 55:"none", |
---|
354 | 56:"string", 57:"16-bits", 58:"32-bits", 59:"32-bits", |
---|
355 | 60:"string", 61:"identifier", 62:"string", 63:"RFC2242", |
---|
356 | 64:"string", 65:"ipv4+", 66:"string", 67:"string", |
---|
357 | 68:"ipv4", 69:"ipv4+", 70:"ipv4+", 71:"ipv4+", |
---|
358 | 72:"ipv4+", 73:"ipv4+", 74:"ipv4+", 75:"ipv4+", |
---|
359 | 76:"ipv4+", 77:"RFC3004", 78:"RFC2610", 79:"RFC2610", |
---|
360 | 80:"null", 81:"string", 82:"RFC3046", 83:"RFC4174", |
---|
361 | 84:"Unassigned", 85:"ipv4+", 86:"RFC2241", 87:"RFC2241", |
---|
362 | 88:"Unassigned", 89:"Unassigned", 90:"RFC3118", 91:"RFC4388", |
---|
363 | 92:"ipv4+", 93:"Unassigned", 94:"Unassigned", 95:"Unassigned", |
---|
364 | 96:"Unassigned", 97:"Unassigned", 98:"string", 99:"Unassigned", |
---|
365 | 100:"Unassigned", 101:"Unassigned", 102:"Unassigned", 103:"Unassigned", |
---|
366 | 104:"Unassigned", 105:"Unassigned", 106:"Unassigned", 107:"Unassigned", |
---|
367 | 108:"Unassigned", 109:"Unassigned", 110:"Unassigned", 111:"Unassigned", |
---|
368 | 112:"Unassigned", 113:"Unassigned", 114:"Unassigned", 115:"Unassigned", |
---|
369 | 116:"char", 117:"RFC2937", 118:"ipv4", 119:"RFC3397", |
---|
370 | 120:"RFC3361", |
---|
371 | |
---|
372 | #TODO |
---|
373 | 121:"Unassigned", 122:"Unassigned", 123:"Unassigned", |
---|
374 | 124:"Unassigned", 125:"Unassigned", 126:"Unassigned", 127:"Unassigned", |
---|
375 | 128:"Unassigned", 129:"Unassigned", 130:"Unassigned", 131:"Unassigned", |
---|
376 | 132:"Unassigned", 133:"Unassigned", 134:"Unassigned", 135:"Unassigned", |
---|
377 | 136:"Unassigned", 137:"Unassigned", 138:"Unassigned", 139:"Unassigned", |
---|
378 | 140:"Unassigned", 141:"Unassigned", 142:"Unassigned", 143:"Unassigned", |
---|
379 | 144:"Unassigned", 145:"Unassigned", 146:"Unassigned", 147:"Unassigned", |
---|
380 | 148:"Unassigned", 149:"Unassigned", 150:"Unassigned", 151:"Unassigned", |
---|
381 | 152:"Unassigned", 153:"Unassigned", 154:"Unassigned", 155:"Unassigned", |
---|
382 | 156:"Unassigned", 157:"Unassigned", 158:"Unassigned", 159:"Unassigned", |
---|
383 | 160:"Unassigned", 161:"Unassigned", 162:"Unassigned", 163:"Unassigned", |
---|
384 | 164:"Unassigned", 165:"Unassigned", 166:"Unassigned", 167:"Unassigned", |
---|
385 | 168:"Unassigned", 169:"Unassigned", 170:"Unassigned", 171:"Unassigned", |
---|
386 | 172:"Unassigned", 173:"Unassigned", 174:"Unassigned", 175:"Unassigned", |
---|
387 | 176:"Unassigned", 177:"Unassigned", 178:"Unassigned", 179:"Unassigned", |
---|
388 | 180:"Unassigned", 181:"Unassigned", 182:"Unassigned", 183:"Unassigned", |
---|
389 | 184:"Unassigned", 185:"Unassigned", 186:"Unassigned", 187:"Unassigned", |
---|
390 | 188:"Unassigned", 189:"Unassigned", 190:"Unassigned", 191:"Unassigned", |
---|
391 | 192:"Unassigned", 193:"Unassigned", 194:"Unassigned", 195:"Unassigned", |
---|
392 | 196:"Unassigned", 197:"Unassigned", 198:"Unassigned", 199:"Unassigned", |
---|
393 | 200:"Unassigned", 201:"Unassigned", 202:"Unassigned", 203:"Unassigned", |
---|
394 | 204:"Unassigned", 205:"Unassigned", 206:"Unassigned", 207:"Unassigned", |
---|
395 | 208:"Unassigned", 209:"Unassigned", 210:"Unassigned", 211:"Unassigned", |
---|
396 | 212:"Unassigned", 213:"Unassigned", 214:"Unassigned", 215:"Unassigned", |
---|
397 | 216:"Unassigned", 217:"Unassigned", 218:"Unassigned", 219:"Unassigned", |
---|
398 | 220:"Unassigned", 221:"Unassigned", 222:"Unassigned", 223:"Unassigned", |
---|
399 | 224:"Unassigned", 225:"Unassigned", 226:"Unassigned", 227:"Unassigned", |
---|
400 | 228:"Unassigned", 229:"Unassigned", 230:"Unassigned", 231:"Unassigned", |
---|
401 | 232:"Unassigned", 233:"Unassigned", 234:"Unassigned", 235:"Unassigned", |
---|
402 | 236:"Unassigned", 237:"Unassigned", 238:"Unassigned", 239:"Unassigned", |
---|
403 | 240:"Unassigned", 241:"Unassigned", 242:"Unassigned", 243:"Unassigned", |
---|
404 | 244:"Unassigned", 245:"Un"} |
---|