dhcp.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /* Dynamic Host Configuration Protocol / BOOTP */
  2. enum
  3. {
  4. OfferTimeout= 60, /* when an offer times out */
  5. MaxLease= 60*60, /* longest lease for dynamic binding */
  6. MinLease= 15*60, /* shortest lease for dynamic binding */
  7. StaticLease= 30*60, /* lease for static binding */
  8. IPUDPHDRSIZE= 28, /* size of an IP plus UDP header */
  9. MINSUPPORTED= 576, /* biggest IP message the client must support */
  10. /* lengths of some bootp fields */
  11. Maxhwlen= 16,
  12. Maxfilelen= 128,
  13. Maxoptlen= 312-4,
  14. /* bootp types */
  15. Bootrequest= 1,
  16. Bootreply= 2,
  17. /* bootp flags */
  18. Fbroadcast= 1<<15,
  19. /* dhcp v4 types */
  20. Discover= 1,
  21. Offer= 2,
  22. Request= 3,
  23. Decline= 4,
  24. Ack= 5,
  25. Nak= 6,
  26. Release= 7,
  27. Inform= 8,
  28. /* bootp option types */
  29. OBend= 255,
  30. OBpad= 0,
  31. OBmask= 1,
  32. OBtimeoff= 2,
  33. OBrouter= 3,
  34. OBtimeserver= 4,
  35. OBnameserver= 5,
  36. OBdnserver= 6,
  37. OBlogserver= 7,
  38. OBcookieserver= 8,
  39. OBlprserver= 9,
  40. OBimpressserver= 10,
  41. OBrlserver= 11,
  42. OBhostname= 12, /* 0x0c */
  43. OBbflen= 13,
  44. OBdumpfile= 14,
  45. OBdomainname= 15,
  46. OBswapserver= 16, /* 0x10 */
  47. OBrootpath= 17,
  48. OBextpath= 18,
  49. OBipforward= 19,
  50. OBnonlocal= 20,
  51. OBpolicyfilter= 21,
  52. OBmaxdatagram= 22,
  53. OBttl= 23,
  54. OBpathtimeout= 24,
  55. OBpathplateau= 25,
  56. OBmtu= 26,
  57. OBsubnetslocal= 27,
  58. OBbaddr= 28,
  59. OBdiscovermask= 29,
  60. OBsupplymask= 30,
  61. OBdiscoverrouter= 31,
  62. OBrsserver= 32, /* 0x20 */
  63. OBstaticroutes= 33,
  64. OBtrailerencap= 34,
  65. OBarptimeout= 35,
  66. OBetherencap= 36,
  67. OBtcpttl= 37,
  68. OBtcpka= 38,
  69. OBtcpkag= 39,
  70. OBnisdomain= 40,
  71. OBniserver= 41,
  72. OBntpserver= 42,
  73. OBvendorinfo= 43, /* 0x2b */
  74. OBnetbiosns= 44,
  75. OBnetbiosdds= 45,
  76. OBnetbiostype= 46,
  77. OBnetbiosscope= 47,
  78. OBxfontserver= 48, /* 0x30 */
  79. OBxdispmanager= 49,
  80. OBnisplusdomain= 64, /* 0x40 */
  81. OBnisplusserver= 65,
  82. OBhomeagent= 68,
  83. OBsmtpserver= 69,
  84. OBpop3server= 70,
  85. OBnntpserver= 71,
  86. OBwwwserver= 72,
  87. OBfingerserver= 73,
  88. OBircserver= 74,
  89. OBstserver= 75,
  90. OBstdaserver= 76,
  91. /* dhcp v4 options */
  92. ODipaddr= 50, /* 0x32 */
  93. ODlease= 51,
  94. ODoverload= 52,
  95. ODtype= 53, /* 0x35 */
  96. ODserverid= 54, /* 0x36 */
  97. ODparams= 55, /* 0x37 */
  98. ODmessage= 56,
  99. ODmaxmsg= 57,
  100. ODrenewaltime= 58,
  101. ODrebindingtime= 59,
  102. ODvendorclass= 60,
  103. ODclientid= 61, /* 0x3d */
  104. ODtftpserver= 66,
  105. ODbootfile= 67,
  106. /* plan9 vendor info options, v4 addresses only (deprecated) */
  107. OP9fsv4= 128, /* plan9 file servers */
  108. OP9authv4= 129, /* plan9 auth servers */
  109. /* plan9 vendor info options, textual addresses, thus v4 or v6 */
  110. OP9fs= 130, /* plan9 file servers */
  111. OP9auth= 131, /* plan9 auth servers */
  112. OP9ipaddr= 132, /* client's address */
  113. OP9ipmask= 133, /* client's subnet mask */
  114. OP9ipgw= 134, /* client's gateway */
  115. /* OP9dns= 135, /* dns servers */
  116. };
  117. /* a lease that never expires */
  118. #define Lforever ~0UL
  119. /* dhcp states */
  120. enum {
  121. Sinit,
  122. Sselecting,
  123. Srequesting,
  124. Sbound,
  125. Srenewing,
  126. Srebinding,
  127. };
  128. typedef struct Bootp Bootp;
  129. struct Bootp
  130. {
  131. /* Udphdr (included because of structure alignment on the alpha) */
  132. uchar udphdr[Udphdrsize];
  133. uchar op; /* opcode */
  134. uchar htype; /* hardware type */
  135. uchar hlen; /* hardware address len */
  136. uchar hops; /* hops */
  137. uchar xid[4]; /* a random number */
  138. uchar secs[2]; /* elapsed since client started booting */
  139. uchar flags[2];
  140. uchar ciaddr[IPv4addrlen]; /* client IP address (client tells server) */
  141. uchar yiaddr[IPv4addrlen]; /* client IP address (server tells client) */
  142. uchar siaddr[IPv4addrlen]; /* server IP address */
  143. uchar giaddr[IPv4addrlen]; /* gateway IP address */
  144. uchar chaddr[Maxhwlen]; /* client hardware address */
  145. char sname[64]; /* server host name (optional) */
  146. char file[Maxfilelen]; /* boot file name */
  147. uchar optmagic[4];
  148. uchar optdata[Maxoptlen];
  149. };