選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

dhcp_constants.py 19KB

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