dhcp.h revision 147689
1139749Simp/* $OpenBSD: dhcp.h,v 1.5 2004/05/04 15:49:49 deraadt Exp $ */ 2116735Sharti/* $FreeBSD: head/sbin/dhclient/dhcp.h 147689 2005-06-30 05:50:52Z brooks $ */ 3116735Sharti 4116735Sharti/* Protocol structures... */ 5116735Sharti 6116735Sharti/* 7116735Sharti * Copyright (c) 1995, 1996 The Internet Software Consortium. 8116735Sharti * All rights reserved. 9116735Sharti * 10116735Sharti * Redistribution and use in source and binary forms, with or without 11116735Sharti * modification, are permitted provided that the following conditions 12116735Sharti * are met: 13116735Sharti * 14116735Sharti * 1. Redistributions of source code must retain the above copyright 15116735Sharti * notice, this list of conditions and the following disclaimer. 16116735Sharti * 2. Redistributions in binary form must reproduce the above copyright 17116735Sharti * notice, this list of conditions and the following disclaimer in the 18116735Sharti * documentation and/or other materials provided with the distribution. 19116735Sharti * 3. Neither the name of The Internet Software Consortium nor the names 20116735Sharti * of its contributors may be used to endorse or promote products derived 21116735Sharti * from this software without specific prior written permission. 22116735Sharti * 23116735Sharti * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND 24116735Sharti * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 25116735Sharti * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 26116735Sharti * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27116735Sharti * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR 28116735Sharti * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 29116735Sharti * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 30116735Sharti * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 31116735Sharti * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 32116735Sharti * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 33116735Sharti * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 34116735Sharti * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35116735Sharti * SUCH DAMAGE. 36116735Sharti * 37116735Sharti * This software has been written for the Internet Software Consortium 38116735Sharti * by Ted Lemon <mellon@fugue.com> in cooperation with Vixie 39116735Sharti * Enterprises. To learn more about the Internet Software Consortium, 40116735Sharti * see ``http://www.vix.com/isc''. To learn more about Vixie 41116735Sharti * Enterprises, see ``http://www.vix.com''. 42116735Sharti */ 43116735Sharti 44116735Sharti#define DHCP_UDP_OVERHEAD (14 + /* Ethernet header */ \ 45116735Sharti 20 + /* IP header */ \ 46116735Sharti 8) /* UDP header */ 47116735Sharti#define DHCP_SNAME_LEN 64 48116735Sharti#define DHCP_FILE_LEN 128 49116735Sharti#define DHCP_FIXED_NON_UDP 236 50116735Sharti#define DHCP_FIXED_LEN (DHCP_FIXED_NON_UDP + DHCP_UDP_OVERHEAD) 51116735Sharti /* Everything but options. */ 52116735Sharti#define DHCP_MTU_MAX 1500 53116735Sharti#define DHCP_OPTION_LEN (DHCP_MTU_MAX - DHCP_FIXED_LEN) 54116735Sharti 55116735Sharti#define BOOTP_MIN_LEN 300 56116735Sharti#define DHCP_MIN_LEN 548 57116735Sharti 58116735Shartistruct dhcp_packet { 59116735Sharti u_int8_t op; /* Message opcode/type */ 60116735Sharti u_int8_t htype; /* Hardware addr type (see net/if_types.h) */ 61116735Sharti u_int8_t hlen; /* Hardware addr length */ 62116735Sharti u_int8_t hops; /* Number of relay agent hops from client */ 63116735Sharti u_int32_t xid; /* Transaction ID */ 64116735Sharti u_int16_t secs; /* Seconds since client started looking */ 65116735Sharti u_int16_t flags; /* Flag bits */ 66116735Sharti struct in_addr ciaddr; /* Client IP address (if already in use) */ 67116735Sharti struct in_addr yiaddr; /* Client IP address */ 68116735Sharti struct in_addr siaddr; /* IP address of next server to talk to */ 69116735Sharti struct in_addr giaddr; /* DHCP relay agent IP address */ 70116735Sharti unsigned char chaddr[16]; /* Client hardware address */ 71116735Sharti char sname[DHCP_SNAME_LEN]; /* Server name */ 72116735Sharti char file[DHCP_FILE_LEN]; /* Boot filename */ 73116735Sharti unsigned char options[DHCP_OPTION_LEN]; 74116735Sharti /* Optional parameters 75116735Sharti (actual length dependent on MTU). */ 76116735Sharti}; 77116735Sharti 78116735Sharti/* BOOTP (rfc951) message types */ 79116735Sharti#define BOOTREQUEST 1 80116735Sharti#define BOOTREPLY 2 81116735Sharti 82116735Sharti/* Possible values for flags field... */ 83116735Sharti#define BOOTP_BROADCAST 32768L 84116735Sharti 85116735Sharti/* Possible values for hardware type (htype) field... */ 86116735Sharti#define HTYPE_ETHER 1 /* Ethernet */ 87116735Sharti#define HTYPE_IEEE802 6 /* IEEE 802.2 Token Ring... */ 88116735Sharti#define HTYPE_FDDI 8 /* FDDI... */ 89116735Sharti 90116735Sharti/* Magic cookie validating dhcp options field (and bootp vendor 91116735Sharti extensions field). */ 92116735Sharti#define DHCP_OPTIONS_COOKIE "\143\202\123\143" 93116735Sharti 94116735Sharti/* DHCP Option codes: */ 95116735Sharti 96116735Sharti#define DHO_PAD 0 97116735Sharti#define DHO_SUBNET_MASK 1 98116735Sharti#define DHO_TIME_OFFSET 2 99116735Sharti#define DHO_ROUTERS 3 100116735Sharti#define DHO_TIME_SERVERS 4 101116735Sharti#define DHO_NAME_SERVERS 5 102116735Sharti#define DHO_DOMAIN_NAME_SERVERS 6 103116735Sharti#define DHO_LOG_SERVERS 7 104116735Sharti#define DHO_COOKIE_SERVERS 8 105116735Sharti#define DHO_LPR_SERVERS 9 106116735Sharti#define DHO_IMPRESS_SERVERS 10 107116735Sharti#define DHO_RESOURCE_LOCATION_SERVERS 11 108116735Sharti#define DHO_HOST_NAME 12 109116735Sharti#define DHO_BOOT_SIZE 13 110116735Sharti#define DHO_MERIT_DUMP 14 111116735Sharti#define DHO_DOMAIN_NAME 15 112116735Sharti#define DHO_SWAP_SERVER 16 113116735Sharti#define DHO_ROOT_PATH 17 114116735Sharti#define DHO_EXTENSIONS_PATH 18 115116735Sharti#define DHO_IP_FORWARDING 19 116116735Sharti#define DHO_NON_LOCAL_SOURCE_ROUTING 20 117116735Sharti#define DHO_POLICY_FILTER 21 118116735Sharti#define DHO_MAX_DGRAM_REASSEMBLY 22 119116735Sharti#define DHO_DEFAULT_IP_TTL 23 120116735Sharti#define DHO_PATH_MTU_AGING_TIMEOUT 24 121116735Sharti#define DHO_PATH_MTU_PLATEAU_TABLE 25 122116735Sharti#define DHO_INTERFACE_MTU 26 123116735Sharti#define DHO_ALL_SUBNETS_LOCAL 27 124116735Sharti#define DHO_BROADCAST_ADDRESS 28 125116735Sharti#define DHO_PERFORM_MASK_DISCOVERY 29 126116735Sharti#define DHO_MASK_SUPPLIER 30 127116735Sharti#define DHO_ROUTER_DISCOVERY 31 128116735Sharti#define DHO_ROUTER_SOLICITATION_ADDRESS 32 129116735Sharti#define DHO_STATIC_ROUTES 33 130116735Sharti#define DHO_TRAILER_ENCAPSULATION 34 131116735Sharti#define DHO_ARP_CACHE_TIMEOUT 35 132116735Sharti#define DHO_IEEE802_3_ENCAPSULATION 36 133116735Sharti#define DHO_DEFAULT_TCP_TTL 37 134116735Sharti#define DHO_TCP_KEEPALIVE_INTERVAL 38 135116735Sharti#define DHO_TCP_KEEPALIVE_GARBAGE 39 136116735Sharti#define DHO_NIS_DOMAIN 40 137116735Sharti#define DHO_NIS_SERVERS 41 138116735Sharti#define DHO_NTP_SERVERS 42 139116735Sharti#define DHO_VENDOR_ENCAPSULATED_OPTIONS 43 140116735Sharti#define DHO_NETBIOS_NAME_SERVERS 44 141116735Sharti#define DHO_NETBIOS_DD_SERVER 45 142116735Sharti#define DHO_NETBIOS_NODE_TYPE 46 143116735Sharti#define DHO_NETBIOS_SCOPE 47 144116735Sharti#define DHO_FONT_SERVERS 48 145116735Sharti#define DHO_X_DISPLAY_MANAGER 49 146116735Sharti#define DHO_DHCP_REQUESTED_ADDRESS 50 147116735Sharti#define DHO_DHCP_LEASE_TIME 51 148116735Sharti#define DHO_DHCP_OPTION_OVERLOAD 52 149116735Sharti#define DHO_DHCP_MESSAGE_TYPE 53 150116735Sharti#define DHO_DHCP_SERVER_IDENTIFIER 54 151116735Sharti#define DHO_DHCP_PARAMETER_REQUEST_LIST 55 152116735Sharti#define DHO_DHCP_MESSAGE 56 153116735Sharti#define DHO_DHCP_MAX_MESSAGE_SIZE 57 154116735Sharti#define DHO_DHCP_RENEWAL_TIME 58 155116735Sharti#define DHO_DHCP_REBINDING_TIME 59 156116735Sharti#define DHO_DHCP_CLASS_IDENTIFIER 60 157116735Sharti#define DHO_DHCP_CLIENT_IDENTIFIER 61 158116735Sharti#define DHO_SMTP_SERVER 69 159116735Sharti#define DHO_POP_SERVER 70 160116735Sharti#define DHO_NNTP_SERVER 71 161116735Sharti#define DHO_WWW_SERVER 72 162116735Sharti#define DHO_FINGER_SERVER 73 163116735Sharti#define DHO_IRC_SERVER 74 164116735Sharti#define DHO_DHCP_USER_CLASS_ID 77 165116735Sharti#define DHO_END 255 166116735Sharti 167116735Sharti/* DHCP message types. */ 168116735Sharti#define DHCPDISCOVER 1 169118208Sharti#define DHCPOFFER 2 170116735Sharti#define DHCPREQUEST 3 171118607Sjhb#define DHCPDECLINE 4 172118208Sharti#define DHCPACK 5 173118208Sharti#define DHCPNAK 6 174118208Sharti#define DHCPRELEASE 7 175118208Sharti#define DHCPINFORM 8 176116735Sharti