1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 1996-2003 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate /* 28*7c478bd9Sstevel@tonic-gate * dhcp.h - Generic DHCP definitions, as per RFC's 2131 and 2132. 29*7c478bd9Sstevel@tonic-gate */ 30*7c478bd9Sstevel@tonic-gate 31*7c478bd9Sstevel@tonic-gate #ifndef _DHCP_H 32*7c478bd9Sstevel@tonic-gate #define _DHCP_H 33*7c478bd9Sstevel@tonic-gate 34*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 35*7c478bd9Sstevel@tonic-gate 36*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 37*7c478bd9Sstevel@tonic-gate extern "C" { 38*7c478bd9Sstevel@tonic-gate #endif 39*7c478bd9Sstevel@tonic-gate 40*7c478bd9Sstevel@tonic-gate #ifdef _REENTRANT 41*7c478bd9Sstevel@tonic-gate #include <thread.h> 42*7c478bd9Sstevel@tonic-gate #endif /* _REENTRANT */ 43*7c478bd9Sstevel@tonic-gate 44*7c478bd9Sstevel@tonic-gate /* 45*7c478bd9Sstevel@tonic-gate * DHCP option codes. 46*7c478bd9Sstevel@tonic-gate */ 47*7c478bd9Sstevel@tonic-gate 48*7c478bd9Sstevel@tonic-gate #define CD_PAD 0 49*7c478bd9Sstevel@tonic-gate #define CD_END 255 50*7c478bd9Sstevel@tonic-gate #define CD_SUBNETMASK 1 51*7c478bd9Sstevel@tonic-gate #define CD_TIMEOFFSET 2 52*7c478bd9Sstevel@tonic-gate #define CD_ROUTER 3 53*7c478bd9Sstevel@tonic-gate #define CD_TIMESERV 4 54*7c478bd9Sstevel@tonic-gate #define CD_IEN116_NAME_SERV 5 55*7c478bd9Sstevel@tonic-gate #define CD_DNSSERV 6 56*7c478bd9Sstevel@tonic-gate #define CD_LOG_SERV 7 57*7c478bd9Sstevel@tonic-gate #define CD_COOKIE_SERV 8 58*7c478bd9Sstevel@tonic-gate #define CD_LPR_SERV 9 59*7c478bd9Sstevel@tonic-gate #define CD_IMPRESS_SERV 10 60*7c478bd9Sstevel@tonic-gate #define CD_RESOURCE_SERV 11 61*7c478bd9Sstevel@tonic-gate #define CD_HOSTNAME 12 62*7c478bd9Sstevel@tonic-gate #define CD_BOOT_SIZE 13 63*7c478bd9Sstevel@tonic-gate #define CD_DUMP_FILE 14 64*7c478bd9Sstevel@tonic-gate #define CD_DNSDOMAIN 15 65*7c478bd9Sstevel@tonic-gate #define CD_SWAP_SERV 16 66*7c478bd9Sstevel@tonic-gate #define CD_ROOT_PATH 17 67*7c478bd9Sstevel@tonic-gate #define CD_EXTEND_PATH 18 68*7c478bd9Sstevel@tonic-gate 69*7c478bd9Sstevel@tonic-gate /* IP layer parameters */ 70*7c478bd9Sstevel@tonic-gate #define CD_IP_FORWARDING_ON 19 71*7c478bd9Sstevel@tonic-gate #define CD_NON_LCL_ROUTE_ON 20 72*7c478bd9Sstevel@tonic-gate #define CD_POLICY_FILTER 21 73*7c478bd9Sstevel@tonic-gate #define CD_MAXIPSIZE 22 74*7c478bd9Sstevel@tonic-gate #define CD_IPTTL 23 75*7c478bd9Sstevel@tonic-gate #define CD_PATH_MTU_TIMEOUT 24 76*7c478bd9Sstevel@tonic-gate #define CD_PATH_MTU_TABLE_SZ 25 77*7c478bd9Sstevel@tonic-gate 78*7c478bd9Sstevel@tonic-gate /* IP layer parameters per interface */ 79*7c478bd9Sstevel@tonic-gate #define CD_MTU 26 80*7c478bd9Sstevel@tonic-gate #define CD_ALL_SUBNETS_LCL_ON 27 81*7c478bd9Sstevel@tonic-gate #define CD_BROADCASTADDR 28 82*7c478bd9Sstevel@tonic-gate #define CD_MASK_DISCVRY_ON 29 83*7c478bd9Sstevel@tonic-gate #define CD_MASK_SUPPLIER_ON 30 84*7c478bd9Sstevel@tonic-gate #define CD_ROUTER_DISCVRY_ON 31 85*7c478bd9Sstevel@tonic-gate #define CD_ROUTER_SOLICIT_SERV 32 86*7c478bd9Sstevel@tonic-gate #define CD_STATIC_ROUTE 33 87*7c478bd9Sstevel@tonic-gate 88*7c478bd9Sstevel@tonic-gate /* Link Layer Parameters per Interface */ 89*7c478bd9Sstevel@tonic-gate #define CD_TRAILER_ENCAPS_ON 34 90*7c478bd9Sstevel@tonic-gate #define CD_ARP_TIMEOUT 35 91*7c478bd9Sstevel@tonic-gate #define CD_ETHERNET_ENCAPS_ON 36 92*7c478bd9Sstevel@tonic-gate 93*7c478bd9Sstevel@tonic-gate /* TCP Parameters */ 94*7c478bd9Sstevel@tonic-gate #define CD_TCP_TTL 37 95*7c478bd9Sstevel@tonic-gate #define CD_TCP_KALIVE_INTVL 38 96*7c478bd9Sstevel@tonic-gate #define CD_TCP_KALIVE_GRBG_ON 39 97*7c478bd9Sstevel@tonic-gate 98*7c478bd9Sstevel@tonic-gate /* Application layer parameters */ 99*7c478bd9Sstevel@tonic-gate #define CD_NIS_DOMAIN 40 100*7c478bd9Sstevel@tonic-gate #define CD_NIS_SERV 41 101*7c478bd9Sstevel@tonic-gate #define CD_NTP_SERV 42 102*7c478bd9Sstevel@tonic-gate #define CD_VENDOR_SPEC 43 103*7c478bd9Sstevel@tonic-gate 104*7c478bd9Sstevel@tonic-gate /* NetBIOS parameters */ 105*7c478bd9Sstevel@tonic-gate #define CD_NETBIOS_NAME_SERV 44 106*7c478bd9Sstevel@tonic-gate #define CD_NETBIOS_DIST_SERV 45 107*7c478bd9Sstevel@tonic-gate #define CD_NETBIOS_NODE_TYPE 46 108*7c478bd9Sstevel@tonic-gate #define CD_NETBIOS_SCOPE 47 109*7c478bd9Sstevel@tonic-gate 110*7c478bd9Sstevel@tonic-gate /* X Window parameters */ 111*7c478bd9Sstevel@tonic-gate #define CD_XWIN_FONT_SERV 48 112*7c478bd9Sstevel@tonic-gate #define CD_XWIN_DISP_SERV 49 113*7c478bd9Sstevel@tonic-gate 114*7c478bd9Sstevel@tonic-gate /* DHCP protocol extension options */ 115*7c478bd9Sstevel@tonic-gate #define CD_REQUESTED_IP_ADDR 50 116*7c478bd9Sstevel@tonic-gate #define CD_LEASE_TIME 51 117*7c478bd9Sstevel@tonic-gate #define CD_OPTION_OVERLOAD 52 118*7c478bd9Sstevel@tonic-gate #define CD_DHCP_TYPE 53 119*7c478bd9Sstevel@tonic-gate #define CD_SERVER_ID 54 120*7c478bd9Sstevel@tonic-gate #define CD_REQUEST_LIST 55 121*7c478bd9Sstevel@tonic-gate #define CD_MESSAGE 56 122*7c478bd9Sstevel@tonic-gate #define CD_MAX_DHCP_SIZE 57 123*7c478bd9Sstevel@tonic-gate #define CD_T1_TIME 58 124*7c478bd9Sstevel@tonic-gate #define CD_T2_TIME 59 125*7c478bd9Sstevel@tonic-gate #define CD_CLASS_ID 60 126*7c478bd9Sstevel@tonic-gate #define CD_CLIENT_ID 61 127*7c478bd9Sstevel@tonic-gate 128*7c478bd9Sstevel@tonic-gate /* Netware options */ 129*7c478bd9Sstevel@tonic-gate #define CD_NW_IP_DOMAIN 62 130*7c478bd9Sstevel@tonic-gate #define CD_NW_IP_OPTIONS 63 131*7c478bd9Sstevel@tonic-gate 132*7c478bd9Sstevel@tonic-gate /* Nisplus options */ 133*7c478bd9Sstevel@tonic-gate #define CD_NISPLUS_DMAIN 64 134*7c478bd9Sstevel@tonic-gate #define CD_NISPLUS_SERVS 65 135*7c478bd9Sstevel@tonic-gate 136*7c478bd9Sstevel@tonic-gate /* Optional sname/bootfile options */ 137*7c478bd9Sstevel@tonic-gate #define CD_TFTP_SERV_NAME 66 138*7c478bd9Sstevel@tonic-gate #define CD_OPT_BOOTFILE_NAME 67 139*7c478bd9Sstevel@tonic-gate 140*7c478bd9Sstevel@tonic-gate /* Additional server options */ 141*7c478bd9Sstevel@tonic-gate #define CD_MOBILE_IP_AGENT 68 142*7c478bd9Sstevel@tonic-gate #define CD_SMTP_SERVS 69 143*7c478bd9Sstevel@tonic-gate #define CD_POP3_SERVS 70 144*7c478bd9Sstevel@tonic-gate #define CD_NNTP_SERVS 71 145*7c478bd9Sstevel@tonic-gate #define CD_WWW_SERVS 72 146*7c478bd9Sstevel@tonic-gate #define CD_FINGER_SERVS 73 147*7c478bd9Sstevel@tonic-gate #define CD_IRC_SERVS 74 148*7c478bd9Sstevel@tonic-gate 149*7c478bd9Sstevel@tonic-gate /* Streettalk options */ 150*7c478bd9Sstevel@tonic-gate #define CD_STREETTALK_SERVS 75 151*7c478bd9Sstevel@tonic-gate #define CD_STREETTALK_DA_SERVS 76 152*7c478bd9Sstevel@tonic-gate 153*7c478bd9Sstevel@tonic-gate /* User class identifier */ 154*7c478bd9Sstevel@tonic-gate #define CD_USER_CLASS_ID 77 155*7c478bd9Sstevel@tonic-gate 156*7c478bd9Sstevel@tonic-gate /* Newer options */ 157*7c478bd9Sstevel@tonic-gate 158*7c478bd9Sstevel@tonic-gate #define CD_SLPDA 78 159*7c478bd9Sstevel@tonic-gate #define CD_SLPSS 79 160*7c478bd9Sstevel@tonic-gate #define CD_AGENTOPT 82 161*7c478bd9Sstevel@tonic-gate #define CD_FQDN 89 162*7c478bd9Sstevel@tonic-gate #define CD_PXEARCHi 93 163*7c478bd9Sstevel@tonic-gate #define CD_PXENIIi 94 164*7c478bd9Sstevel@tonic-gate #define CD_PXECID 95 165*7c478bd9Sstevel@tonic-gate #define CD_MULTICST 107 166*7c478bd9Sstevel@tonic-gate 167*7c478bd9Sstevel@tonic-gate #define DHCP_FIRST_OPT CD_SUBNETMASK 168*7c478bd9Sstevel@tonic-gate #define DHCP_LAST_STD CD_MULTICST 169*7c478bd9Sstevel@tonic-gate #define DHCP_SITE_OPT 128 /* inclusive */ 170*7c478bd9Sstevel@tonic-gate #define DHCP_END_SITE 254 171*7c478bd9Sstevel@tonic-gate #define DHCP_LAST_OPT DHCP_END_SITE /* last op code */ 172*7c478bd9Sstevel@tonic-gate 173*7c478bd9Sstevel@tonic-gate #define DHCP_MAX_OPT_SIZE 255 /* maximum option size in octets */ 174*7c478bd9Sstevel@tonic-gate 175*7c478bd9Sstevel@tonic-gate /* 176*7c478bd9Sstevel@tonic-gate * DHCP Packet. What will fit in a ethernet frame. We may use a smaller 177*7c478bd9Sstevel@tonic-gate * size, based on what our transport can handle. 178*7c478bd9Sstevel@tonic-gate */ 179*7c478bd9Sstevel@tonic-gate #define DHCP_DEF_MAX_SIZE 576 /* as spec'ed in RFC 2131 */ 180*7c478bd9Sstevel@tonic-gate #define PKT_BUFFER 1486 /* max possible size of pkt buffer */ 181*7c478bd9Sstevel@tonic-gate #define BASE_PKT_SIZE 240 /* everything but the options */ 182*7c478bd9Sstevel@tonic-gate typedef struct dhcp { 183*7c478bd9Sstevel@tonic-gate uint8_t op; /* message opcode */ 184*7c478bd9Sstevel@tonic-gate uint8_t htype; /* Hardware address type */ 185*7c478bd9Sstevel@tonic-gate uint8_t hlen; /* Hardware address length */ 186*7c478bd9Sstevel@tonic-gate uint8_t hops; /* Used by relay agents */ 187*7c478bd9Sstevel@tonic-gate uint32_t xid; /* transaction id */ 188*7c478bd9Sstevel@tonic-gate uint16_t secs; /* Secs elapsed since client boot */ 189*7c478bd9Sstevel@tonic-gate uint16_t flags; /* DHCP Flags field */ 190*7c478bd9Sstevel@tonic-gate struct in_addr ciaddr; /* client IP addr */ 191*7c478bd9Sstevel@tonic-gate struct in_addr yiaddr; /* 'Your' IP addr. (from server) */ 192*7c478bd9Sstevel@tonic-gate struct in_addr siaddr; /* Boot server IP addr */ 193*7c478bd9Sstevel@tonic-gate struct in_addr giaddr; /* Relay agent IP addr */ 194*7c478bd9Sstevel@tonic-gate uint8_t chaddr[16]; /* Client hardware addr */ 195*7c478bd9Sstevel@tonic-gate uint8_t sname[64]; /* Optl. boot server hostname */ 196*7c478bd9Sstevel@tonic-gate uint8_t file[128]; /* boot file name (ascii path) */ 197*7c478bd9Sstevel@tonic-gate uint8_t cookie[4]; /* Magic cookie */ 198*7c478bd9Sstevel@tonic-gate uint8_t options[60]; /* Options */ 199*7c478bd9Sstevel@tonic-gate } PKT; 200*7c478bd9Sstevel@tonic-gate 201*7c478bd9Sstevel@tonic-gate typedef uint32_t lease_t; /* DHCP lease time (32 bit quantity) */ 202*7c478bd9Sstevel@tonic-gate 203*7c478bd9Sstevel@tonic-gate /* 204*7c478bd9Sstevel@tonic-gate * DHCP packet types. As per protocol. 205*7c478bd9Sstevel@tonic-gate */ 206*7c478bd9Sstevel@tonic-gate #define DISCOVER ((uint8_t)1) 207*7c478bd9Sstevel@tonic-gate #define OFFER ((uint8_t)2) 208*7c478bd9Sstevel@tonic-gate #define REQUEST ((uint8_t)3) 209*7c478bd9Sstevel@tonic-gate #define DECLINE ((uint8_t)4) 210*7c478bd9Sstevel@tonic-gate #define ACK ((uint8_t)5) 211*7c478bd9Sstevel@tonic-gate #define NAK ((uint8_t)6) 212*7c478bd9Sstevel@tonic-gate #define RELEASE ((uint8_t)7) 213*7c478bd9Sstevel@tonic-gate #define INFORM ((uint8_t)8) 214*7c478bd9Sstevel@tonic-gate 215*7c478bd9Sstevel@tonic-gate /* 216*7c478bd9Sstevel@tonic-gate * Generic DHCP protocol defines 217*7c478bd9Sstevel@tonic-gate */ 218*7c478bd9Sstevel@tonic-gate #define DHCP_PERM ((lease_t)0xffffffff) /* "permanent" lease time */ 219*7c478bd9Sstevel@tonic-gate #define BOOTREQUEST (1) /* BOOTP REQUEST opcode */ 220*7c478bd9Sstevel@tonic-gate #define BOOTREPLY (2) /* BOOTP REPLY opcode */ 221*7c478bd9Sstevel@tonic-gate #define BOOTMAGIC { 99, 130, 83, 99 } /* rfc1048 magic cookie */ 222*7c478bd9Sstevel@tonic-gate #define BCAST_MASK 0x8000 /* BROADCAST flag */ 223*7c478bd9Sstevel@tonic-gate 224*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 225*7c478bd9Sstevel@tonic-gate } 226*7c478bd9Sstevel@tonic-gate #endif 227*7c478bd9Sstevel@tonic-gate 228*7c478bd9Sstevel@tonic-gate #endif /* _DHCP_H */ 229