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