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