Initial import from FreeBSD RELENG_4:
[games.git] / contrib / isc-dhcp / includes / dhcp.h
1 /* dhcp.h
2
3    Protocol structures... */
4
5 /*
6  * Copyright (c) 1995-2001 The Internet Software Consortium.
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  * 3. Neither the name of The Internet Software Consortium nor the names
19  *    of its contributors may be used to endorse or promote products derived
20  *    from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
23  * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
24  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26  * DISCLAIMED.  IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
27  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
30  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
33  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34  * SUCH DAMAGE.
35  *
36  * This software has been written for the Internet Software Consortium
37  * by Ted Lemon in cooperation with Vixie Enterprises.  To learn more
38  * about the Internet Software Consortium, see ``http://www.isc.org''.
39  * To learn more about Vixie Enterprises, see ``http://www.vix.com''.
40  */
41
42 #define DHCP_UDP_OVERHEAD       (14 + /* Ethernet header */             \
43                                  20 + /* IP header */                   \
44                                  8)   /* UDP header */
45 #define DHCP_SNAME_LEN          64
46 #define DHCP_FILE_LEN           128
47 #define DHCP_FIXED_NON_UDP      236
48 #define DHCP_FIXED_LEN          (DHCP_FIXED_NON_UDP + DHCP_UDP_OVERHEAD)
49                                                 /* Everything but options. */
50 #define DHCP_MTU_MAX            1500
51 #define DHCP_OPTION_LEN         (DHCP_MTU_MAX - DHCP_FIXED_LEN)
52
53 #define BOOTP_MIN_LEN           300
54 #define DHCP_MIN_LEN            548
55
56 struct dhcp_packet {
57         u_int8_t  op;           /* 0: Message opcode/type */
58         u_int8_t  htype;        /* 1: Hardware addr type (net/if_types.h) */
59         u_int8_t  hlen;         /* 2: Hardware addr length */
60         u_int8_t  hops;         /* 3: Number of relay agent hops from client */
61         u_int32_t xid;          /* 4: Transaction ID */
62         u_int16_t secs;         /* 8: Seconds since client started looking */
63         u_int16_t flags;        /* 10: Flag bits */
64         struct in_addr ciaddr;  /* 12: Client IP address (if already in use) */
65         struct in_addr yiaddr;  /* 16: Client IP address */
66         struct in_addr siaddr;  /* 18: IP address of next server to talk to */
67         struct in_addr giaddr;  /* 20: DHCP relay agent IP address */
68         unsigned char chaddr [16];      /* 24: Client hardware address */
69         char sname [DHCP_SNAME_LEN];    /* 40: Server name */
70         char file [DHCP_FILE_LEN];      /* 104: Boot filename */
71         unsigned char options [DHCP_OPTION_LEN];
72                                 /* 212: Optional parameters
73                                    (actual length dependent on MTU). */
74 };
75
76 /* BOOTP (rfc951) message types */
77 #define BOOTREQUEST     1
78 #define BOOTREPLY       2
79
80 /* Possible values for flags field... */
81 #define BOOTP_BROADCAST 32768L
82
83 /* Possible values for hardware type (htype) field... */
84 #define HTYPE_ETHER     1               /* Ethernet 10Mbps              */
85 #define HTYPE_IEEE802   6               /* IEEE 802.2 Token Ring...     */
86 #define HTYPE_FDDI      8               /* FDDI...                      */
87
88 /* Magic cookie validating dhcp options field (and bootp vendor
89    extensions field). */
90 #define DHCP_OPTIONS_COOKIE     "\143\202\123\143"
91
92 /* DHCP Option codes: */
93
94 #define DHO_PAD                         0
95 #define DHO_SUBNET_MASK                 1
96 #define DHO_TIME_OFFSET                 2
97 #define DHO_ROUTERS                     3
98 #define DHO_TIME_SERVERS                4
99 #define DHO_NAME_SERVERS                5
100 #define DHO_DOMAIN_NAME_SERVERS         6
101 #define DHO_LOG_SERVERS                 7
102 #define DHO_COOKIE_SERVERS              8
103 #define DHO_LPR_SERVERS                 9
104 #define DHO_IMPRESS_SERVERS             10
105 #define DHO_RESOURCE_LOCATION_SERVERS   11
106 #define DHO_HOST_NAME                   12
107 #define DHO_BOOT_SIZE                   13
108 #define DHO_MERIT_DUMP                  14
109 #define DHO_DOMAIN_NAME                 15
110 #define DHO_SWAP_SERVER                 16
111 #define DHO_ROOT_PATH                   17
112 #define DHO_EXTENSIONS_PATH             18
113 #define DHO_IP_FORWARDING               19
114 #define DHO_NON_LOCAL_SOURCE_ROUTING    20
115 #define DHO_POLICY_FILTER               21
116 #define DHO_MAX_DGRAM_REASSEMBLY        22
117 #define DHO_DEFAULT_IP_TTL              23
118 #define DHO_PATH_MTU_AGING_TIMEOUT      24
119 #define DHO_PATH_MTU_PLATEAU_TABLE      25
120 #define DHO_INTERFACE_MTU               26
121 #define DHO_ALL_SUBNETS_LOCAL           27
122 #define DHO_BROADCAST_ADDRESS           28
123 #define DHO_PERFORM_MASK_DISCOVERY      29
124 #define DHO_MASK_SUPPLIER               30
125 #define DHO_ROUTER_DISCOVERY            31
126 #define DHO_ROUTER_SOLICITATION_ADDRESS 32
127 #define DHO_STATIC_ROUTES               33
128 #define DHO_TRAILER_ENCAPSULATION       34
129 #define DHO_ARP_CACHE_TIMEOUT           35
130 #define DHO_IEEE802_3_ENCAPSULATION     36
131 #define DHO_DEFAULT_TCP_TTL             37
132 #define DHO_TCP_KEEPALIVE_INTERVAL      38
133 #define DHO_TCP_KEEPALIVE_GARBAGE       39
134 #define DHO_NIS_DOMAIN                  40
135 #define DHO_NIS_SERVERS                 41
136 #define DHO_NTP_SERVERS                 42
137 #define DHO_VENDOR_ENCAPSULATED_OPTIONS 43
138 #define DHO_NETBIOS_NAME_SERVERS        44
139 #define DHO_NETBIOS_DD_SERVER           45
140 #define DHO_NETBIOS_NODE_TYPE           46
141 #define DHO_NETBIOS_SCOPE               47
142 #define DHO_FONT_SERVERS                48
143 #define DHO_X_DISPLAY_MANAGER           49
144 #define DHO_DHCP_REQUESTED_ADDRESS      50
145 #define DHO_DHCP_LEASE_TIME             51
146 #define DHO_DHCP_OPTION_OVERLOAD        52
147 #define DHO_DHCP_MESSAGE_TYPE           53
148 #define DHO_DHCP_SERVER_IDENTIFIER      54
149 #define DHO_DHCP_PARAMETER_REQUEST_LIST 55
150 #define DHO_DHCP_MESSAGE                56
151 #define DHO_DHCP_MAX_MESSAGE_SIZE       57
152 #define DHO_DHCP_RENEWAL_TIME           58
153 #define DHO_DHCP_REBINDING_TIME         59
154 #define DHO_VENDOR_CLASS_IDENTIFIER     60
155 #define DHO_DHCP_CLIENT_IDENTIFIER      61
156 #define DHO_NWIP_DOMAIN_NAME            62
157 #define DHO_NWIP_SUBOPTIONS             63
158 #define DHO_USER_CLASS                  77
159 #define DHO_FQDN                        81
160 #define DHO_DHCP_AGENT_OPTIONS          82
161 #define DHO_SUBNET_SELECTION            118 /* RFC3011! */
162 /* The DHO_AUTHENTICATE option is not a standard yet, so I've
163    allocated an option out of the "local" option space for it on a
164    temporary basis.  Once an option code number is assigned, I will
165    immediately and shamelessly break this, so don't count on it
166    continuing to work. */
167 #define DHO_AUTHENTICATE                210
168
169 #define DHO_END                         255
170
171 /* DHCP message types. */
172 #define DHCPDISCOVER    1
173 #define DHCPOFFER       2
174 #define DHCPREQUEST     3
175 #define DHCPDECLINE     4
176 #define DHCPACK         5
177 #define DHCPNAK         6
178 #define DHCPRELEASE     7
179 #define DHCPINFORM      8
180
181 /* Relay Agent Information option subtypes: */
182 #define RAI_CIRCUIT_ID  1
183 #define RAI_REMOTE_ID   2
184 #define RAI_AGENT_ID    3
185
186 /* FQDN suboptions: */
187 #define FQDN_NO_CLIENT_UPDATE           1
188 #define FQDN_SERVER_UPDATE              2
189 #define FQDN_ENCODED                    3
190 #define FQDN_RCODE1                     4
191 #define FQDN_RCODE2                     5
192 #define FQDN_HOSTNAME                   6
193 #define FQDN_DOMAINNAME                 7
194 #define FQDN_FQDN                       8
195 #define FQDN_SUBOPTION_COUNT            8