dhcp.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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, /* 0xc0 */
  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 */
  107. OP9fs= 128, /* plan9 file servers */
  108. OP9auth= 129, /* plan9 auth servers */
  109. };
  110. /* a lease that never expires */
  111. #define Lforever ~0UL
  112. /* dhcp states */
  113. enum {
  114. Sinit,
  115. Sselecting,
  116. Srequesting,
  117. Sbound,
  118. Srenewing,
  119. Srebinding,
  120. };
  121. typedef struct Bootp Bootp;
  122. struct Bootp
  123. {
  124. /* Udphdr (included because of structure alignment on the alpha) */
  125. uchar udphdr[Udphdrsize];
  126. uchar op; /* opcode */
  127. uchar htype; /* hardware type */
  128. uchar hlen; /* hardware address len */
  129. uchar hops; /* hops */
  130. uchar xid[4]; /* a random number */
  131. uchar secs[2]; /* elapsed since client started booting */
  132. uchar flags[2];
  133. uchar ciaddr[IPv4addrlen]; /* client IP address (client tells server) */
  134. uchar yiaddr[IPv4addrlen]; /* client IP address (server tells client) */
  135. uchar siaddr[IPv4addrlen]; /* server IP address */
  136. uchar giaddr[IPv4addrlen]; /* gateway IP address */
  137. uchar chaddr[Maxhwlen]; /* client hardware address */
  138. char sname[64]; /* server host name (optional) */
  139. char file[Maxfilelen]; /* boot file name */
  140. uchar optmagic[4];
  141. uchar optdata[Maxoptlen];
  142. };