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