1*a1e26a70SApple OSS Distributions #ifndef _NETINET_DHCP_H 2*a1e26a70SApple OSS Distributions #define _NETINET_DHCP_H 3*a1e26a70SApple OSS Distributions #include <sys/appleapiopts.h> 4*a1e26a70SApple OSS Distributions 5*a1e26a70SApple OSS Distributions /* 6*a1e26a70SApple OSS Distributions * Copyright (c) 1999-2007 Apple Inc. All rights reserved. 7*a1e26a70SApple OSS Distributions * 8*a1e26a70SApple OSS Distributions * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 9*a1e26a70SApple OSS Distributions * 10*a1e26a70SApple OSS Distributions * This file contains Original Code and/or Modifications of Original Code 11*a1e26a70SApple OSS Distributions * as defined in and that are subject to the Apple Public Source License 12*a1e26a70SApple OSS Distributions * Version 2.0 (the 'License'). You may not use this file except in 13*a1e26a70SApple OSS Distributions * compliance with the License. The rights granted to you under the License 14*a1e26a70SApple OSS Distributions * may not be used to create, or enable the creation or redistribution of, 15*a1e26a70SApple OSS Distributions * unlawful or unlicensed copies of an Apple operating system, or to 16*a1e26a70SApple OSS Distributions * circumvent, violate, or enable the circumvention or violation of, any 17*a1e26a70SApple OSS Distributions * terms of an Apple operating system software license agreement. 18*a1e26a70SApple OSS Distributions * 19*a1e26a70SApple OSS Distributions * Please obtain a copy of the License at 20*a1e26a70SApple OSS Distributions * http://www.opensource.apple.com/apsl/ and read it before using this file. 21*a1e26a70SApple OSS Distributions * 22*a1e26a70SApple OSS Distributions * The Original Code and all software distributed under the License are 23*a1e26a70SApple OSS Distributions * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 24*a1e26a70SApple OSS Distributions * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 25*a1e26a70SApple OSS Distributions * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 26*a1e26a70SApple OSS Distributions * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 27*a1e26a70SApple OSS Distributions * Please see the License for the specific language governing rights and 28*a1e26a70SApple OSS Distributions * limitations under the License. 29*a1e26a70SApple OSS Distributions * 30*a1e26a70SApple OSS Distributions * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 31*a1e26a70SApple OSS Distributions */ 32*a1e26a70SApple OSS Distributions /* 33*a1e26a70SApple OSS Distributions * dhcp.h 34*a1e26a70SApple OSS Distributions * - definitions for DHCP (as specified in RFC2132) 35*a1e26a70SApple OSS Distributions */ 36*a1e26a70SApple OSS Distributions #include <sys/types.h> 37*a1e26a70SApple OSS Distributions #include <netinet/in.h> 38*a1e26a70SApple OSS Distributions #include <netinet/in_systm.h> 39*a1e26a70SApple OSS Distributions #include <netinet/ip.h> 40*a1e26a70SApple OSS Distributions #include <netinet/udp.h> 41*a1e26a70SApple OSS Distributions 42*a1e26a70SApple OSS Distributions struct dhcp { 43*a1e26a70SApple OSS Distributions u_char dp_op; /* packet opcode type */ 44*a1e26a70SApple OSS Distributions u_char dp_htype; /* hardware addr type */ 45*a1e26a70SApple OSS Distributions u_char dp_hlen; /* hardware addr length */ 46*a1e26a70SApple OSS Distributions u_char dp_hops; /* gateway hops */ 47*a1e26a70SApple OSS Distributions u_int32_t dp_xid; /* transaction ID */ 48*a1e26a70SApple OSS Distributions u_int16_t dp_secs; /* seconds since boot began */ 49*a1e26a70SApple OSS Distributions u_int16_t dp_flags; /* flags */ 50*a1e26a70SApple OSS Distributions struct in_addr dp_ciaddr; /* client IP address */ 51*a1e26a70SApple OSS Distributions struct in_addr dp_yiaddr; /* 'your' IP address */ 52*a1e26a70SApple OSS Distributions struct in_addr dp_siaddr; /* server IP address */ 53*a1e26a70SApple OSS Distributions struct in_addr dp_giaddr; /* gateway IP address */ 54*a1e26a70SApple OSS Distributions u_char dp_chaddr[16];/* client hardware address */ 55*a1e26a70SApple OSS Distributions u_char dp_sname[64];/* server host name */ 56*a1e26a70SApple OSS Distributions u_char dp_file[128];/* boot file name */ 57*a1e26a70SApple OSS Distributions u_char dp_options[0];/* variable-length options field */ 58*a1e26a70SApple OSS Distributions }; 59*a1e26a70SApple OSS Distributions 60*a1e26a70SApple OSS Distributions struct dhcp_packet { 61*a1e26a70SApple OSS Distributions struct ip ip; 62*a1e26a70SApple OSS Distributions struct udphdr udp; 63*a1e26a70SApple OSS Distributions struct dhcp dhcp; 64*a1e26a70SApple OSS Distributions }; 65*a1e26a70SApple OSS Distributions 66*a1e26a70SApple OSS Distributions #define DHCP_OPTIONS_MIN 312 67*a1e26a70SApple OSS Distributions #define DHCP_PACKET_MIN (sizeof(struct dhcp_packet) + DHCP_OPTIONS_MIN) 68*a1e26a70SApple OSS Distributions #define DHCP_PAYLOAD_MIN (sizeof(struct dhcp) + DHCP_OPTIONS_MIN) 69*a1e26a70SApple OSS Distributions 70*a1e26a70SApple OSS Distributions /* dhcp message types */ 71*a1e26a70SApple OSS Distributions #define DHCPDISCOVER 1 72*a1e26a70SApple OSS Distributions #define DHCPOFFER 2 73*a1e26a70SApple OSS Distributions #define DHCPREQUEST 3 74*a1e26a70SApple OSS Distributions #define DHCPDECLINE 4 75*a1e26a70SApple OSS Distributions #define DHCPACK 5 76*a1e26a70SApple OSS Distributions #define DHCPNAK 6 77*a1e26a70SApple OSS Distributions #define DHCPRELEASE 7 78*a1e26a70SApple OSS Distributions #define DHCPINFORM 8 79*a1e26a70SApple OSS Distributions 80*a1e26a70SApple OSS Distributions enum { 81*a1e26a70SApple OSS Distributions dhcp_msgtype_none_e = 0, 82*a1e26a70SApple OSS Distributions dhcp_msgtype_discover_e = DHCPDISCOVER, 83*a1e26a70SApple OSS Distributions dhcp_msgtype_offer_e = DHCPOFFER, 84*a1e26a70SApple OSS Distributions dhcp_msgtype_request_e = DHCPREQUEST, 85*a1e26a70SApple OSS Distributions dhcp_msgtype_decline_e = DHCPDECLINE, 86*a1e26a70SApple OSS Distributions dhcp_msgtype_ack_e = DHCPACK, 87*a1e26a70SApple OSS Distributions dhcp_msgtype_nak_e = DHCPNAK, 88*a1e26a70SApple OSS Distributions dhcp_msgtype_release_e = DHCPRELEASE, 89*a1e26a70SApple OSS Distributions dhcp_msgtype_inform_e = DHCPINFORM, 90*a1e26a70SApple OSS Distributions }; 91*a1e26a70SApple OSS Distributions 92*a1e26a70SApple OSS Distributions typedef uint8_t dhcp_msgtype_t; 93*a1e26a70SApple OSS Distributions 94*a1e26a70SApple OSS Distributions typedef int32_t dhcp_time_secs_t; /* absolute time */ 95*a1e26a70SApple OSS Distributions typedef int32_t dhcp_lease_t; /* relative time */ 96*a1e26a70SApple OSS Distributions #define dhcp_time_hton htonl 97*a1e26a70SApple OSS Distributions #define dhcp_time_ntoh ntohl 98*a1e26a70SApple OSS Distributions #define dhcp_lease_hton htonl 99*a1e26a70SApple OSS Distributions #define dhcp_lease_ntoh ntohl 100*a1e26a70SApple OSS Distributions 101*a1e26a70SApple OSS Distributions #define DHCP_INFINITE_LEASE ((dhcp_lease_t)-1) 102*a1e26a70SApple OSS Distributions #define DHCP_INFINITE_TIME ((dhcp_time_secs_t)-1) 103*a1e26a70SApple OSS Distributions 104*a1e26a70SApple OSS Distributions #define DHCP_FLAGS_BROADCAST ((u_int16_t)0x8000) 105*a1e26a70SApple OSS Distributions 106*a1e26a70SApple OSS Distributions #endif /* _NETINET_DHCP_H */ 107