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