]> git.lizzy.rs Git - plan9front.git/blob - sys/src/cmd/ip/dhcp.h
ip/dhcpd: change swap to rootserver (thanks k0ga)
[plan9front.git] / sys / src / cmd / ip / dhcp.h
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         OBrootserver=           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         ODdnsdomain=            119,
115
116         /* plan9 vendor info options, v4 addresses only (deprecated) */
117         OP9fsv4=                128,    /* plan9 file servers */
118         OP9authv4=              129,    /* plan9 auth servers */
119
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
129 /* a lease that never expires */
130 #define Lforever        ~0UL
131
132 /* dhcp states */
133 enum {
134         Sinit,
135         Sselecting,
136         Srequesting,
137         Sbound,
138         Srenewing,
139         Srebinding,
140 };
141
142 typedef struct Bootp    Bootp;
143 struct Bootp
144 {
145         /* Udphdr (included because of structure alignment on the alpha) */
146         uchar   udphdr[Udphdrsize];
147
148         uchar   op;                     /* opcode */
149         uchar   htype;                  /* hardware type */
150         uchar   hlen;                   /* hardware address len */
151         uchar   hops;                   /* hops */
152         uchar   xid[4];                 /* a random number */
153         uchar   secs[2];                /* elapsed since client started booting */
154         uchar   flags[2];
155         uchar   ciaddr[IPv4addrlen];    /* client IP address (client tells server) */
156         uchar   yiaddr[IPv4addrlen];    /* client IP address (server tells client) */
157         uchar   siaddr[IPv4addrlen];    /* server IP address */
158         uchar   giaddr[IPv4addrlen];    /* gateway IP address */
159         uchar   chaddr[Maxhwlen];       /* client hardware address */
160         char    sname[64];              /* server host name (optional) */
161         char    file[Maxfilelen];       /* boot file name */
162         uchar   optmagic[4];
163         uchar   optdata[Maxoptlen];
164 };