17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 77c478bd9Sstevel@tonic-gate * with the License. 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate * and limitations under the License. 137c478bd9Sstevel@tonic-gate * 147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * CDDL HEADER END 217c478bd9Sstevel@tonic-gate */ 227c478bd9Sstevel@tonic-gate /* 237c478bd9Sstevel@tonic-gate * Copyright 1996-2003 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*b31320a7SChris Fraire * Copyright (c) 2016, Chris Fraire <cfraire@me.com>. 267c478bd9Sstevel@tonic-gate */ 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate /* 297c478bd9Sstevel@tonic-gate * dhcp.h - Generic DHCP definitions, as per RFC's 2131 and 2132. 307c478bd9Sstevel@tonic-gate */ 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate #ifndef _DHCP_H 337c478bd9Sstevel@tonic-gate #define _DHCP_H 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate #ifdef __cplusplus 367c478bd9Sstevel@tonic-gate extern "C" { 377c478bd9Sstevel@tonic-gate #endif 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate #ifdef _REENTRANT 407c478bd9Sstevel@tonic-gate #include <thread.h> 417c478bd9Sstevel@tonic-gate #endif /* _REENTRANT */ 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate /* 447c478bd9Sstevel@tonic-gate * DHCP option codes. 457c478bd9Sstevel@tonic-gate */ 467c478bd9Sstevel@tonic-gate 477c478bd9Sstevel@tonic-gate #define CD_PAD 0 487c478bd9Sstevel@tonic-gate #define CD_END 255 497c478bd9Sstevel@tonic-gate #define CD_SUBNETMASK 1 507c478bd9Sstevel@tonic-gate #define CD_TIMEOFFSET 2 517c478bd9Sstevel@tonic-gate #define CD_ROUTER 3 527c478bd9Sstevel@tonic-gate #define CD_TIMESERV 4 537c478bd9Sstevel@tonic-gate #define CD_IEN116_NAME_SERV 5 547c478bd9Sstevel@tonic-gate #define CD_DNSSERV 6 557c478bd9Sstevel@tonic-gate #define CD_LOG_SERV 7 567c478bd9Sstevel@tonic-gate #define CD_COOKIE_SERV 8 577c478bd9Sstevel@tonic-gate #define CD_LPR_SERV 9 587c478bd9Sstevel@tonic-gate #define CD_IMPRESS_SERV 10 597c478bd9Sstevel@tonic-gate #define CD_RESOURCE_SERV 11 607c478bd9Sstevel@tonic-gate #define CD_HOSTNAME 12 617c478bd9Sstevel@tonic-gate #define CD_BOOT_SIZE 13 627c478bd9Sstevel@tonic-gate #define CD_DUMP_FILE 14 637c478bd9Sstevel@tonic-gate #define CD_DNSDOMAIN 15 647c478bd9Sstevel@tonic-gate #define CD_SWAP_SERV 16 657c478bd9Sstevel@tonic-gate #define CD_ROOT_PATH 17 667c478bd9Sstevel@tonic-gate #define CD_EXTEND_PATH 18 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate /* IP layer parameters */ 697c478bd9Sstevel@tonic-gate #define CD_IP_FORWARDING_ON 19 707c478bd9Sstevel@tonic-gate #define CD_NON_LCL_ROUTE_ON 20 717c478bd9Sstevel@tonic-gate #define CD_POLICY_FILTER 21 727c478bd9Sstevel@tonic-gate #define CD_MAXIPSIZE 22 737c478bd9Sstevel@tonic-gate #define CD_IPTTL 23 747c478bd9Sstevel@tonic-gate #define CD_PATH_MTU_TIMEOUT 24 757c478bd9Sstevel@tonic-gate #define CD_PATH_MTU_TABLE_SZ 25 767c478bd9Sstevel@tonic-gate 777c478bd9Sstevel@tonic-gate /* IP layer parameters per interface */ 787c478bd9Sstevel@tonic-gate #define CD_MTU 26 797c478bd9Sstevel@tonic-gate #define CD_ALL_SUBNETS_LCL_ON 27 807c478bd9Sstevel@tonic-gate #define CD_BROADCASTADDR 28 817c478bd9Sstevel@tonic-gate #define CD_MASK_DISCVRY_ON 29 827c478bd9Sstevel@tonic-gate #define CD_MASK_SUPPLIER_ON 30 837c478bd9Sstevel@tonic-gate #define CD_ROUTER_DISCVRY_ON 31 847c478bd9Sstevel@tonic-gate #define CD_ROUTER_SOLICIT_SERV 32 857c478bd9Sstevel@tonic-gate #define CD_STATIC_ROUTE 33 867c478bd9Sstevel@tonic-gate 877c478bd9Sstevel@tonic-gate /* Link Layer Parameters per Interface */ 887c478bd9Sstevel@tonic-gate #define CD_TRAILER_ENCAPS_ON 34 897c478bd9Sstevel@tonic-gate #define CD_ARP_TIMEOUT 35 907c478bd9Sstevel@tonic-gate #define CD_ETHERNET_ENCAPS_ON 36 917c478bd9Sstevel@tonic-gate 927c478bd9Sstevel@tonic-gate /* TCP Parameters */ 937c478bd9Sstevel@tonic-gate #define CD_TCP_TTL 37 947c478bd9Sstevel@tonic-gate #define CD_TCP_KALIVE_INTVL 38 957c478bd9Sstevel@tonic-gate #define CD_TCP_KALIVE_GRBG_ON 39 967c478bd9Sstevel@tonic-gate 977c478bd9Sstevel@tonic-gate /* Application layer parameters */ 987c478bd9Sstevel@tonic-gate #define CD_NIS_DOMAIN 40 997c478bd9Sstevel@tonic-gate #define CD_NIS_SERV 41 1007c478bd9Sstevel@tonic-gate #define CD_NTP_SERV 42 1017c478bd9Sstevel@tonic-gate #define CD_VENDOR_SPEC 43 1027c478bd9Sstevel@tonic-gate 1037c478bd9Sstevel@tonic-gate /* NetBIOS parameters */ 1047c478bd9Sstevel@tonic-gate #define CD_NETBIOS_NAME_SERV 44 1057c478bd9Sstevel@tonic-gate #define CD_NETBIOS_DIST_SERV 45 1067c478bd9Sstevel@tonic-gate #define CD_NETBIOS_NODE_TYPE 46 1077c478bd9Sstevel@tonic-gate #define CD_NETBIOS_SCOPE 47 1087c478bd9Sstevel@tonic-gate 1097c478bd9Sstevel@tonic-gate /* X Window parameters */ 1107c478bd9Sstevel@tonic-gate #define CD_XWIN_FONT_SERV 48 1117c478bd9Sstevel@tonic-gate #define CD_XWIN_DISP_SERV 49 1127c478bd9Sstevel@tonic-gate 1137c478bd9Sstevel@tonic-gate /* DHCP protocol extension options */ 1147c478bd9Sstevel@tonic-gate #define CD_REQUESTED_IP_ADDR 50 1157c478bd9Sstevel@tonic-gate #define CD_LEASE_TIME 51 1167c478bd9Sstevel@tonic-gate #define CD_OPTION_OVERLOAD 52 1177c478bd9Sstevel@tonic-gate #define CD_DHCP_TYPE 53 1187c478bd9Sstevel@tonic-gate #define CD_SERVER_ID 54 1197c478bd9Sstevel@tonic-gate #define CD_REQUEST_LIST 55 1207c478bd9Sstevel@tonic-gate #define CD_MESSAGE 56 1217c478bd9Sstevel@tonic-gate #define CD_MAX_DHCP_SIZE 57 1227c478bd9Sstevel@tonic-gate #define CD_T1_TIME 58 1237c478bd9Sstevel@tonic-gate #define CD_T2_TIME 59 1247c478bd9Sstevel@tonic-gate #define CD_CLASS_ID 60 1257c478bd9Sstevel@tonic-gate #define CD_CLIENT_ID 61 1267c478bd9Sstevel@tonic-gate 1277c478bd9Sstevel@tonic-gate /* Netware options */ 1287c478bd9Sstevel@tonic-gate #define CD_NW_IP_DOMAIN 62 1297c478bd9Sstevel@tonic-gate #define CD_NW_IP_OPTIONS 63 1307c478bd9Sstevel@tonic-gate 1317c478bd9Sstevel@tonic-gate /* Nisplus options */ 1327c478bd9Sstevel@tonic-gate #define CD_NISPLUS_DMAIN 64 1337c478bd9Sstevel@tonic-gate #define CD_NISPLUS_SERVS 65 1347c478bd9Sstevel@tonic-gate 1357c478bd9Sstevel@tonic-gate /* Optional sname/bootfile options */ 1367c478bd9Sstevel@tonic-gate #define CD_TFTP_SERV_NAME 66 1377c478bd9Sstevel@tonic-gate #define CD_OPT_BOOTFILE_NAME 67 1387c478bd9Sstevel@tonic-gate 1397c478bd9Sstevel@tonic-gate /* Additional server options */ 1407c478bd9Sstevel@tonic-gate #define CD_MOBILE_IP_AGENT 68 1417c478bd9Sstevel@tonic-gate #define CD_SMTP_SERVS 69 1427c478bd9Sstevel@tonic-gate #define CD_POP3_SERVS 70 1437c478bd9Sstevel@tonic-gate #define CD_NNTP_SERVS 71 1447c478bd9Sstevel@tonic-gate #define CD_WWW_SERVS 72 1457c478bd9Sstevel@tonic-gate #define CD_FINGER_SERVS 73 1467c478bd9Sstevel@tonic-gate #define CD_IRC_SERVS 74 1477c478bd9Sstevel@tonic-gate 1487c478bd9Sstevel@tonic-gate /* Streettalk options */ 1497c478bd9Sstevel@tonic-gate #define CD_STREETTALK_SERVS 75 1507c478bd9Sstevel@tonic-gate #define CD_STREETTALK_DA_SERVS 76 1517c478bd9Sstevel@tonic-gate 1527c478bd9Sstevel@tonic-gate /* User class identifier */ 1537c478bd9Sstevel@tonic-gate #define CD_USER_CLASS_ID 77 1547c478bd9Sstevel@tonic-gate 1557c478bd9Sstevel@tonic-gate /* Newer options */ 1567c478bd9Sstevel@tonic-gate 1577c478bd9Sstevel@tonic-gate #define CD_SLPDA 78 1587c478bd9Sstevel@tonic-gate #define CD_SLPSS 79 159*b31320a7SChris Fraire #define CD_CLIENTFQDN 81 1607c478bd9Sstevel@tonic-gate #define CD_AGENTOPT 82 161*b31320a7SChris Fraire 162*b31320a7SChris Fraire /* 163*b31320a7SChris Fraire * Per RFC 3679, option 89 was "Never published as standard and [is] not in 164*b31320a7SChris Fraire * general use". See active CD_CLIENTFQDN and RFC 4702. 165*b31320a7SChris Fraire */ 1667c478bd9Sstevel@tonic-gate #define CD_FQDN 89 167*b31320a7SChris Fraire 1687c478bd9Sstevel@tonic-gate #define CD_PXEARCHi 93 1697c478bd9Sstevel@tonic-gate #define CD_PXENIIi 94 1707c478bd9Sstevel@tonic-gate #define CD_PXECID 95 1717c478bd9Sstevel@tonic-gate #define CD_MULTICST 107 1727c478bd9Sstevel@tonic-gate 1737c478bd9Sstevel@tonic-gate #define DHCP_FIRST_OPT CD_SUBNETMASK 1747c478bd9Sstevel@tonic-gate #define DHCP_LAST_STD CD_MULTICST 1757c478bd9Sstevel@tonic-gate #define DHCP_SITE_OPT 128 /* inclusive */ 1767c478bd9Sstevel@tonic-gate #define DHCP_END_SITE 254 1777c478bd9Sstevel@tonic-gate #define DHCP_LAST_OPT DHCP_END_SITE /* last op code */ 1787c478bd9Sstevel@tonic-gate 1797c478bd9Sstevel@tonic-gate #define DHCP_MAX_OPT_SIZE 255 /* maximum option size in octets */ 1807c478bd9Sstevel@tonic-gate 1817c478bd9Sstevel@tonic-gate /* 1827c478bd9Sstevel@tonic-gate * DHCP Packet. What will fit in a ethernet frame. We may use a smaller 1837c478bd9Sstevel@tonic-gate * size, based on what our transport can handle. 1847c478bd9Sstevel@tonic-gate */ 1857c478bd9Sstevel@tonic-gate #define DHCP_DEF_MAX_SIZE 576 /* as spec'ed in RFC 2131 */ 1867c478bd9Sstevel@tonic-gate #define PKT_BUFFER 1486 /* max possible size of pkt buffer */ 1877c478bd9Sstevel@tonic-gate #define BASE_PKT_SIZE 240 /* everything but the options */ 1887c478bd9Sstevel@tonic-gate typedef struct dhcp { 1897c478bd9Sstevel@tonic-gate uint8_t op; /* message opcode */ 1907c478bd9Sstevel@tonic-gate uint8_t htype; /* Hardware address type */ 1917c478bd9Sstevel@tonic-gate uint8_t hlen; /* Hardware address length */ 1927c478bd9Sstevel@tonic-gate uint8_t hops; /* Used by relay agents */ 1937c478bd9Sstevel@tonic-gate uint32_t xid; /* transaction id */ 1947c478bd9Sstevel@tonic-gate uint16_t secs; /* Secs elapsed since client boot */ 1957c478bd9Sstevel@tonic-gate uint16_t flags; /* DHCP Flags field */ 1967c478bd9Sstevel@tonic-gate struct in_addr ciaddr; /* client IP addr */ 1977c478bd9Sstevel@tonic-gate struct in_addr yiaddr; /* 'Your' IP addr. (from server) */ 1987c478bd9Sstevel@tonic-gate struct in_addr siaddr; /* Boot server IP addr */ 1997c478bd9Sstevel@tonic-gate struct in_addr giaddr; /* Relay agent IP addr */ 2007c478bd9Sstevel@tonic-gate uint8_t chaddr[16]; /* Client hardware addr */ 2017c478bd9Sstevel@tonic-gate uint8_t sname[64]; /* Optl. boot server hostname */ 2027c478bd9Sstevel@tonic-gate uint8_t file[128]; /* boot file name (ascii path) */ 2037c478bd9Sstevel@tonic-gate uint8_t cookie[4]; /* Magic cookie */ 2047c478bd9Sstevel@tonic-gate uint8_t options[60]; /* Options */ 2057c478bd9Sstevel@tonic-gate } PKT; 2067c478bd9Sstevel@tonic-gate 2077c478bd9Sstevel@tonic-gate typedef uint32_t lease_t; /* DHCP lease time (32 bit quantity) */ 2087c478bd9Sstevel@tonic-gate 2097c478bd9Sstevel@tonic-gate /* 2107c478bd9Sstevel@tonic-gate * DHCP packet types. As per protocol. 2117c478bd9Sstevel@tonic-gate */ 2127c478bd9Sstevel@tonic-gate #define DISCOVER ((uint8_t)1) 2137c478bd9Sstevel@tonic-gate #define OFFER ((uint8_t)2) 2147c478bd9Sstevel@tonic-gate #define REQUEST ((uint8_t)3) 2157c478bd9Sstevel@tonic-gate #define DECLINE ((uint8_t)4) 2167c478bd9Sstevel@tonic-gate #define ACK ((uint8_t)5) 2177c478bd9Sstevel@tonic-gate #define NAK ((uint8_t)6) 2187c478bd9Sstevel@tonic-gate #define RELEASE ((uint8_t)7) 2197c478bd9Sstevel@tonic-gate #define INFORM ((uint8_t)8) 2207c478bd9Sstevel@tonic-gate 2217c478bd9Sstevel@tonic-gate /* 2227c478bd9Sstevel@tonic-gate * Generic DHCP protocol defines 2237c478bd9Sstevel@tonic-gate */ 2247c478bd9Sstevel@tonic-gate #define DHCP_PERM ((lease_t)0xffffffff) /* "permanent" lease time */ 2257c478bd9Sstevel@tonic-gate #define BOOTREQUEST (1) /* BOOTP REQUEST opcode */ 2267c478bd9Sstevel@tonic-gate #define BOOTREPLY (2) /* BOOTP REPLY opcode */ 2277c478bd9Sstevel@tonic-gate #define BOOTMAGIC { 99, 130, 83, 99 } /* rfc1048 magic cookie */ 2287c478bd9Sstevel@tonic-gate #define BCAST_MASK 0x8000 /* BROADCAST flag */ 2297c478bd9Sstevel@tonic-gate 2307c478bd9Sstevel@tonic-gate #ifdef __cplusplus 2317c478bd9Sstevel@tonic-gate } 2327c478bd9Sstevel@tonic-gate #endif 2337c478bd9Sstevel@tonic-gate 2347c478bd9Sstevel@tonic-gate #endif /* _DHCP_H */ 235