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