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