dhcp.h revision 147072
1248590Smm/* $OpenBSD: dhcp.h,v 1.5 2004/05/04 15:49:49 deraadt Exp $ */ 2248590Smm 3248590Smm/* Protocol structures... */ 4248590Smm 5248590Smm/* 6248590Smm * Copyright (c) 1995, 1996 The Internet Software Consortium. 7248590Smm * All rights reserved. 8248590Smm * 9248590Smm * Redistribution and use in source and binary forms, with or without 10248590Smm * modification, are permitted provided that the following conditions 11248590Smm * are met: 12248590Smm * 13248590Smm * 1. Redistributions of source code must retain the above copyright 14248590Smm * notice, this list of conditions and the following disclaimer. 15248590Smm * 2. Redistributions in binary form must reproduce the above copyright 16248590Smm * notice, this list of conditions and the following disclaimer in the 17248590Smm * documentation and/or other materials provided with the distribution. 18248590Smm * 3. Neither the name of The Internet Software Consortium nor the names 19248590Smm * of its contributors may be used to endorse or promote products derived 20248590Smm * from this software without specific prior written permission. 21248590Smm * 22248590Smm * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND 23248590Smm * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 24248590Smm * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 25248590Smm * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26248590Smm * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR 27248590Smm * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28248590Smm * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 29248590Smm * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 30248590Smm * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 31248590Smm * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 32248590Smm * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 33248590Smm * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34248590Smm * SUCH DAMAGE. 35248590Smm * 36248590Smm * This software has been written for the Internet Software Consortium 37248590Smm * by Ted Lemon <mellon@fugue.com> in cooperation with Vixie 38248590Smm * Enterprises. To learn more about the Internet Software Consortium, 39248590Smm * see ``http://www.vix.com/isc''. To learn more about Vixie 40248590Smm * Enterprises, see ``http://www.vix.com''. 41248590Smm */ 42248590Smm 43248590Smm#define DHCP_UDP_OVERHEAD (14 + /* Ethernet header */ \ 44248590Smm 20 + /* IP header */ \ 45248590Smm 8) /* UDP header */ 46248590Smm#define DHCP_SNAME_LEN 64 47248590Smm#define DHCP_FILE_LEN 128 48248590Smm#define DHCP_FIXED_NON_UDP 236 49248590Smm#define DHCP_FIXED_LEN (DHCP_FIXED_NON_UDP + DHCP_UDP_OVERHEAD) 50248590Smm /* Everything but options. */ 51248590Smm#define DHCP_MTU_MAX 1500 52248590Smm#define DHCP_OPTION_LEN (DHCP_MTU_MAX - DHCP_FIXED_LEN) 53248590Smm 54248590Smm#define BOOTP_MIN_LEN 300 55248590Smm#define DHCP_MIN_LEN 548 56248590Smm 57248590Smmstruct dhcp_packet { 58248590Smm u_int8_t op; /* Message opcode/type */ 59248590Smm u_int8_t htype; /* Hardware addr type (see net/if_types.h) */ 60248590Smm u_int8_t hlen; /* Hardware addr length */ 61248590Smm u_int8_t hops; /* Number of relay agent hops from client */ 62248590Smm u_int32_t xid; /* Transaction ID */ 63248590Smm u_int16_t secs; /* Seconds since client started looking */ 64248590Smm u_int16_t flags; /* Flag bits */ 65248590Smm struct in_addr ciaddr; /* Client IP address (if already in use) */ 66248590Smm struct in_addr yiaddr; /* Client IP address */ 67248590Smm struct in_addr siaddr; /* IP address of next server to talk to */ 68248590Smm struct in_addr giaddr; /* DHCP relay agent IP address */ 69248590Smm unsigned char chaddr[16]; /* Client hardware address */ 70248590Smm char sname[DHCP_SNAME_LEN]; /* Server name */ 71248590Smm char file[DHCP_FILE_LEN]; /* Boot filename */ 72248590Smm unsigned char options[DHCP_OPTION_LEN]; 73248590Smm /* Optional parameters 74248590Smm (actual length dependent on MTU). */ 75248590Smm}; 76248590Smm 77248590Smm/* BOOTP (rfc951) message types */ 78248590Smm#define BOOTREQUEST 1 79248590Smm#define BOOTREPLY 2 80248590Smm 81248590Smm/* Possible values for flags field... */ 82248590Smm#define BOOTP_BROADCAST 32768L 83248590Smm 84248590Smm/* Possible values for hardware type (htype) field... */ 85248590Smm#define HTYPE_ETHER 1 /* Ethernet */ 86248590Smm#define HTYPE_IEEE802 6 /* IEEE 802.2 Token Ring... */ 87248590Smm#define HTYPE_FDDI 8 /* FDDI... */ 88248590Smm 89248590Smm/* Magic cookie validating dhcp options field (and bootp vendor 90248590Smm extensions field). */ 91248590Smm#define DHCP_OPTIONS_COOKIE "\143\202\123\143" 92248590Smm 93248590Smm/* DHCP Option codes: */ 94248590Smm 95248590Smm#define DHO_PAD 0 96248590Smm#define DHO_SUBNET_MASK 1 97248590Smm#define DHO_TIME_OFFSET 2 98248590Smm#define DHO_ROUTERS 3 99248590Smm#define DHO_TIME_SERVERS 4 100248590Smm#define DHO_NAME_SERVERS 5 101248590Smm#define DHO_DOMAIN_NAME_SERVERS 6 102248590Smm#define DHO_LOG_SERVERS 7 103248590Smm#define DHO_COOKIE_SERVERS 8 104248590Smm#define DHO_LPR_SERVERS 9 105248590Smm#define DHO_IMPRESS_SERVERS 10 106248590Smm#define DHO_RESOURCE_LOCATION_SERVERS 11 107248590Smm#define DHO_HOST_NAME 12 108248590Smm#define DHO_BOOT_SIZE 13 109248590Smm#define DHO_MERIT_DUMP 14 110248590Smm#define DHO_DOMAIN_NAME 15 111248590Smm#define DHO_SWAP_SERVER 16 112248590Smm#define DHO_ROOT_PATH 17 113248590Smm#define DHO_EXTENSIONS_PATH 18 114248590Smm#define DHO_IP_FORWARDING 19 115248590Smm#define DHO_NON_LOCAL_SOURCE_ROUTING 20 116248590Smm#define DHO_POLICY_FILTER 21 117248590Smm#define DHO_MAX_DGRAM_REASSEMBLY 22 118248590Smm#define DHO_DEFAULT_IP_TTL 23 119248590Smm#define DHO_PATH_MTU_AGING_TIMEOUT 24 120248590Smm#define DHO_PATH_MTU_PLATEAU_TABLE 25 121248590Smm#define DHO_INTERFACE_MTU 26 122248590Smm#define DHO_ALL_SUBNETS_LOCAL 27 123248590Smm#define DHO_BROADCAST_ADDRESS 28 124248590Smm#define DHO_PERFORM_MASK_DISCOVERY 29 125248590Smm#define DHO_MASK_SUPPLIER 30 126248590Smm#define DHO_ROUTER_DISCOVERY 31 127248590Smm#define DHO_ROUTER_SOLICITATION_ADDRESS 32 128248590Smm#define DHO_STATIC_ROUTES 33 129248590Smm#define DHO_TRAILER_ENCAPSULATION 34 130248590Smm#define DHO_ARP_CACHE_TIMEOUT 35 131248590Smm#define DHO_IEEE802_3_ENCAPSULATION 36 132248590Smm#define DHO_DEFAULT_TCP_TTL 37 133248590Smm#define DHO_TCP_KEEPALIVE_INTERVAL 38 134248590Smm#define DHO_TCP_KEEPALIVE_GARBAGE 39 135248590Smm#define DHO_NIS_DOMAIN 40 136248590Smm#define DHO_NIS_SERVERS 41 137248590Smm#define DHO_NTP_SERVERS 42 138248590Smm#define DHO_VENDOR_ENCAPSULATED_OPTIONS 43 139248590Smm#define DHO_NETBIOS_NAME_SERVERS 44 140248590Smm#define DHO_NETBIOS_DD_SERVER 45 141248590Smm#define DHO_NETBIOS_NODE_TYPE 46 142248590Smm#define DHO_NETBIOS_SCOPE 47 143248590Smm#define DHO_FONT_SERVERS 48 144248590Smm#define DHO_X_DISPLAY_MANAGER 49 145248590Smm#define DHO_DHCP_REQUESTED_ADDRESS 50 146248590Smm#define DHO_DHCP_LEASE_TIME 51 147248590Smm#define DHO_DHCP_OPTION_OVERLOAD 52 148248590Smm#define DHO_DHCP_MESSAGE_TYPE 53 149248590Smm#define DHO_DHCP_SERVER_IDENTIFIER 54 150248590Smm#define DHO_DHCP_PARAMETER_REQUEST_LIST 55 151248590Smm#define DHO_DHCP_MESSAGE 56 152248590Smm#define DHO_DHCP_MAX_MESSAGE_SIZE 57 153248590Smm#define DHO_DHCP_RENEWAL_TIME 58 154248590Smm#define DHO_DHCP_REBINDING_TIME 59 155248590Smm#define DHO_DHCP_CLASS_IDENTIFIER 60 156248590Smm#define DHO_DHCP_CLIENT_IDENTIFIER 61 157248590Smm#define DHO_DHCP_USER_CLASS_ID 77 158248590Smm#define DHO_END 255 159248590Smm 160248590Smm/* DHCP message types. */ 161248590Smm#define DHCPDISCOVER 1 162248590Smm#define DHCPOFFER 2 163248590Smm#define DHCPREQUEST 3 164248590Smm#define DHCPDECLINE 4 165248590Smm#define DHCPACK 5 166248590Smm#define DHCPNAK 6 167248590Smm#define DHCPRELEASE 7 168248590Smm#define DHCPINFORM 8 169248590Smm