ISC DHCP  4.3.6
A reference DHCPv4 and DHCPv6 implementation
dhcp.h
Go to the documentation of this file.
1 /* dhcp.h
2 
3  Protocol structures... */
4 
5 /*
6  * Copyright (c) 2011-2012,2014 by Internet Systems Consortium, Inc. ("ISC")
7  * Copyright (c) 2004-2009 by Internet Systems Consortium, Inc. ("ISC")
8  * Copyright (c) 1995-2003 by Internet Software Consortium
9  *
10  * Permission to use, copy, modify, and distribute this software for any
11  * purpose with or without fee is hereby granted, provided that the above
12  * copyright notice and this permission notice appear in all copies.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
15  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
17  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
20  * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21  *
22  * Internet Systems Consortium, Inc.
23  * 950 Charter Street
24  * Redwood City, CA 94063
25  * <info@isc.org>
26  * https://www.isc.org/
27  *
28  */
29 
30 #ifndef DHCP_H
31 #define DHCP_H
32 
33 #define DHCP_UDP_OVERHEAD (20 + /* IP header */ \
34  8) /* UDP header */
35 #define DHCP_SNAME_LEN 64
36 #define DHCP_FILE_LEN 128
37 #define DHCP_FIXED_NON_UDP 236
38 #define DHCP_FIXED_LEN (DHCP_FIXED_NON_UDP + DHCP_UDP_OVERHEAD)
39  /* Everything but options. */
40 #define BOOTP_MIN_LEN 300
41 
42 #define DHCP_MTU_MAX 1500
43 #define DHCP_MTU_MIN 576
44 
45 #define DHCP_MAX_OPTION_LEN (DHCP_MTU_MAX - DHCP_FIXED_LEN)
46 #define DHCP_MIN_OPTION_LEN (DHCP_MTU_MIN - DHCP_FIXED_LEN)
47 
48 struct dhcp_packet {
49  u_int8_t op; /* 0: Message opcode/type */
50  u_int8_t htype; /* 1: Hardware addr type (net/if_types.h) */
51  u_int8_t hlen; /* 2: Hardware addr length */
52  u_int8_t hops; /* 3: Number of relay agent hops from client */
53  u_int32_t xid; /* 4: Transaction ID */
54  u_int16_t secs; /* 8: Seconds since client started looking */
55  u_int16_t flags; /* 10: Flag bits */
56  struct in_addr ciaddr; /* 12: Client IP address (if already in use) */
57  struct in_addr yiaddr; /* 16: Client IP address */
58  struct in_addr siaddr; /* 18: IP address of next server to talk to */
59  struct in_addr giaddr; /* 20: DHCP relay agent IP address */
60  unsigned char chaddr [16]; /* 24: Client hardware address */
61  char sname [DHCP_SNAME_LEN]; /* 40: Server name */
62  char file [DHCP_FILE_LEN]; /* 104: Boot filename */
63  unsigned char options [DHCP_MAX_OPTION_LEN];
64  /* 212: Optional parameters
65  (actual length dependent on MTU). */
66 };
67 
68 /* BOOTP (rfc951) message types */
69 #define BOOTREQUEST 1
70 #define BOOTREPLY 2
71 
72 /* Possible values for flags field... */
73 #define BOOTP_BROADCAST 32768L
74 
75 /* Possible values for hardware type (htype) field... */
76 #define HTYPE_ETHER 1 /* Ethernet 10Mbps */
77 #define HTYPE_IEEE802 6 /* IEEE 802.2 Token Ring... */
78 #define HTYPE_FDDI 8 /* FDDI... */
79 #define HTYPE_INFINIBAND 32 /* IP over Infiniband */
80 #define HTYPE_IPMP 255 /* IPMP - random hw address - there
81  * is no standard for this so we
82  * just steal a type */
83 
84 #define HTYPE_RESERVED 0 /* RFC 5494 */
85 
86 /* Magic cookie validating dhcp options field (and bootp vendor
87  extensions field). */
88 #define DHCP_OPTIONS_COOKIE "\143\202\123\143"
89 
90 /* DHCP Option codes: */
91 
92 #define DHO_PAD 0
93 #define DHO_SUBNET_MASK 1
94 #define DHO_TIME_OFFSET 2
95 #define DHO_ROUTERS 3
96 #define DHO_TIME_SERVERS 4
97 #define DHO_NAME_SERVERS 5
98 #define DHO_DOMAIN_NAME_SERVERS 6
99 #define DHO_LOG_SERVERS 7
100 #define DHO_COOKIE_SERVERS 8
101 #define DHO_LPR_SERVERS 9
102 #define DHO_IMPRESS_SERVERS 10
103 #define DHO_RESOURCE_LOCATION_SERVERS 11
104 #define DHO_HOST_NAME 12
105 #define DHO_BOOT_SIZE 13
106 #define DHO_MERIT_DUMP 14
107 #define DHO_DOMAIN_NAME 15
108 #define DHO_SWAP_SERVER 16
109 #define DHO_ROOT_PATH 17
110 #define DHO_EXTENSIONS_PATH 18
111 #define DHO_IP_FORWARDING 19
112 #define DHO_NON_LOCAL_SOURCE_ROUTING 20
113 #define DHO_POLICY_FILTER 21
114 #define DHO_MAX_DGRAM_REASSEMBLY 22
115 #define DHO_DEFAULT_IP_TTL 23
116 #define DHO_PATH_MTU_AGING_TIMEOUT 24
117 #define DHO_PATH_MTU_PLATEAU_TABLE 25
118 #define DHO_INTERFACE_MTU 26
119 #define DHO_ALL_SUBNETS_LOCAL 27
120 #define DHO_BROADCAST_ADDRESS 28
121 #define DHO_PERFORM_MASK_DISCOVERY 29
122 #define DHO_MASK_SUPPLIER 30
123 #define DHO_ROUTER_DISCOVERY 31
124 #define DHO_ROUTER_SOLICITATION_ADDRESS 32
125 #define DHO_STATIC_ROUTES 33
126 #define DHO_TRAILER_ENCAPSULATION 34
127 #define DHO_ARP_CACHE_TIMEOUT 35
128 #define DHO_IEEE802_3_ENCAPSULATION 36
129 #define DHO_DEFAULT_TCP_TTL 37
130 #define DHO_TCP_KEEPALIVE_INTERVAL 38
131 #define DHO_TCP_KEEPALIVE_GARBAGE 39
132 #define DHO_NIS_DOMAIN 40
133 #define DHO_NIS_SERVERS 41
134 #define DHO_NTP_SERVERS 42
135 #define DHO_VENDOR_ENCAPSULATED_OPTIONS 43
136 #define DHO_NETBIOS_NAME_SERVERS 44
137 #define DHO_NETBIOS_DD_SERVER 45
138 #define DHO_NETBIOS_NODE_TYPE 46
139 #define DHO_NETBIOS_SCOPE 47
140 #define DHO_FONT_SERVERS 48
141 #define DHO_X_DISPLAY_MANAGER 49
142 #define DHO_DHCP_REQUESTED_ADDRESS 50
143 #define DHO_DHCP_LEASE_TIME 51
144 #define DHO_DHCP_OPTION_OVERLOAD 52
145 #define DHO_DHCP_MESSAGE_TYPE 53
146 #define DHO_DHCP_SERVER_IDENTIFIER 54
147 #define DHO_DHCP_PARAMETER_REQUEST_LIST 55
148 #define DHO_DHCP_MESSAGE 56
149 #define DHO_DHCP_MAX_MESSAGE_SIZE 57
150 #define DHO_DHCP_RENEWAL_TIME 58
151 #define DHO_DHCP_REBINDING_TIME 59
152 #define DHO_VENDOR_CLASS_IDENTIFIER 60
153 #define DHO_DHCP_CLIENT_IDENTIFIER 61
154 #define DHO_NWIP_DOMAIN_NAME 62
155 #define DHO_NWIP_SUBOPTIONS 63
156 #define DHO_USER_CLASS 77
157 #define DHO_FQDN 81
158 #define DHO_DHCP_AGENT_OPTIONS 82
159 #define DHO_AUTHENTICATE 90 /* RFC3118, was 210 */
160 #define DHO_CLIENT_LAST_TRANSACTION_TIME 91
161 #define DHO_ASSOCIATED_IP 92
162 #define DHO_PXE_CLIENT_ID 97 /* RFC4578 */
163 #define DHO_SUBNET_SELECTION 118 /* RFC3011! */
164 #define DHO_DOMAIN_SEARCH 119 /* RFC3397 */
165 #define DHO_CLASSLESS_STATIC_ROUTES 121 /* RFC3442 */
166 #define DHO_VIVCO_SUBOPTIONS 124
167 #define DHO_VIVSO_SUBOPTIONS 125
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 #define DHCPLEASEQUERY 10
181 #define DHCPLEASEUNASSIGNED 11
182 #define DHCPLEASEUNKNOWN 12
183 #define DHCPLEASEACTIVE 13
184 
185 
186 /* Relay Agent Information option subtypes: */
187 #define RAI_CIRCUIT_ID 1
188 #define RAI_REMOTE_ID 2
189 #define RAI_AGENT_ID 3
190 #define RAI_LINK_SELECT 5
191 
192 /* FQDN suboptions: */
193 #define FQDN_NO_CLIENT_UPDATE 1
194 #define FQDN_SERVER_UPDATE 2
195 #define FQDN_ENCODED 3
196 #define FQDN_RCODE1 4
197 #define FQDN_RCODE2 5
198 #define FQDN_HOSTNAME 6
199 #define FQDN_DOMAINNAME 7
200 #define FQDN_FQDN 8
201 #define FQDN_SUBOPTION_COUNT 8
202 
203 /* Enterprise Suboptions: */
204 #define VENDOR_ISC_SUBOPTIONS 2495
205 
206 #endif /* DHCP_H */
207 
char file[DHCP_FILE_LEN]
Definition: dhcp.h:62
char sname[DHCP_SNAME_LEN]
Definition: dhcp.h:61
u_int16_t secs
Definition: dhcp.h:54
u_int8_t hlen
Definition: dhcp.h:51
#define DHCP_SNAME_LEN
Definition: dhcp.h:35
struct in_addr siaddr
Definition: dhcp.h:58
u_int16_t flags
Definition: dhcp.h:55
u_int8_t htype
Definition: dhcp.h:50
unsigned char chaddr[16]
Definition: dhcp.h:60
#define DHCP_MAX_OPTION_LEN
Definition: dhcp.h:45
u_int32_t xid
Definition: dhcp.h:53
struct in_addr yiaddr
Definition: dhcp.h:57
struct in_addr giaddr
Definition: dhcp.h:59
#define DHCP_FILE_LEN
Definition: dhcp.h:36
u_int8_t hops
Definition: dhcp.h:52
struct in_addr ciaddr
Definition: dhcp.h:56
u_int8_t op
Definition: dhcp.h:49
unsigned char options[DHCP_MAX_OPTION_LEN]
Definition: dhcp.h:63