dhcp.h 3.3 KB

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