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