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