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