dhcp.h 4.3 KB

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