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