]> git.saurik.com Git - apple/xnu.git/blame - bsd/netinet/dhcp_options.h
xnu-792.6.56.tar.gz
[apple/xnu.git] / bsd / netinet / dhcp_options.h
CommitLineData
9bccf70c
A
1
2#ifndef _NETINET_DHCP_OPTIONS_H
3#define _NETINET_DHCP_OPTIONS_H
4#include <sys/appleapiopts.h>
5/*
6 * Copyright (c) 1999-2002 Apple Computer, Inc. All rights reserved.
7 *
8 * @APPLE_LICENSE_HEADER_START@
9 *
ff6e181a
A
10 * This file contains Original Code and/or Modifications of Original Code
11 * as defined in and that are subject to the Apple Public Source License
12 * Version 2.0 (the 'License'). You may not use this file except in
13 * compliance with the License. Please obtain a copy of the License at
14 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * file.
9bccf70c 16 *
ff6e181a
A
17 * The Original Code and all software distributed under the License are
18 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
9bccf70c
A
19 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
20 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
ff6e181a
A
21 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
22 * Please see the License for the specific language governing rights and
23 * limitations under the License.
9bccf70c
A
24 *
25 * @APPLE_LICENSE_HEADER_END@
26 */
27
28/*
29 * dhcp_options.h
30 * - routines to parse and access dhcp options
31 */
32
33/*
34 * Modification History
35 *
36 * March 15, 2002 Dieter Siegmund (dieter@apple)
37 * - imported from bootp project
38 */
39#include <mach/boolean.h>
40#include <netinet/dhcp.h>
41
42
43/* overloaded option values */
44#define DHCP_OVERLOAD_FILE 1
45#define DHCP_OVERLOAD_SNAME 2
46#define DHCP_OVERLOAD_BOTH 3
47
48/*
49 * DHCP_OPTION_SIZE_MAX
50 * - the largest size that an option can be (limited to an 8-bit quantity)
51 */
52#define DHCP_OPTION_SIZE_MAX 255
53
54#define DHCP_TAG_OFFSET 0
55#define DHCP_LEN_OFFSET 1
56#define DHCP_OPTION_OFFSET 2
57
58
59
60#define RFC_OPTIONS_MAGIC { 99, 130, 83, 99 }
61#define RFC_MAGIC_SIZE 4 /* bytes */
62
63typedef enum {
64 /* rfc 1497 vendor extensions: 0..18, 255 */
65 dhcptag_pad_e = 0,
66 dhcptag_end_e = 255,
67 dhcptag_subnet_mask_e = 1,
68 dhcptag_time_offset_e = 2,
69 dhcptag_router_e = 3,
70 dhcptag_time_server_e = 4,
71 dhcptag_name_server_e = 5,
72 dhcptag_domain_name_server_e = 6,
73 dhcptag_log_server_e = 7,
74 dhcptag_cookie_server_e = 8,
75 dhcptag_lpr_server_e = 9,
76 dhcptag_impress_server_e = 10,
77 dhcptag_resource_location_server_e = 11,
78 dhcptag_host_name_e = 12,
79 dhcptag_boot_file_size_e = 13,
80 dhcptag_merit_dump_file_e = 14,
81 dhcptag_domain_name_e = 15,
82 dhcptag_swap_server_e = 16,
83 dhcptag_root_path_e = 17,
84 dhcptag_extensions_path_e = 18,
85
86 /* ip layer parameters per host: 19..25 */
87 dhcptag_ip_forwarding_e = 19,
88 dhcptag_non_local_source_routing_e = 20,
89 dhcptag_policy_filter_e = 21,
90 dhcptag_max_dgram_reassembly_size_e = 22,
91 dhcptag_default_ip_time_to_live_e = 23,
92 dhcptag_path_mtu_aging_timeout_e = 24,
93 dhcptag_path_mtu_plateau_table_e = 25,
94
95 /* ip layer parameters per interface: 26..33 */
96 dhcptag_interface_mtu_e = 26,
97 dhcptag_all_subnets_local_e = 27,
98 dhcptag_broadcast_address_e = 28,
99 dhcptag_perform_mask_discovery_e = 29,
100 dhcptag_mask_supplier_e = 30,
101 dhcptag_perform_router_discovery_e = 31,
102 dhcptag_router_solicitation_address_e = 32,
103 dhcptag_static_route_e = 33,
104 dhcptag_trailer_encapsulation_e = 34,
105 dhcptag_arp_cache_timeout_e = 35,
106 dhcptag_ethernet_encapsulation_e = 36,
107
108 /* tcp parameters: 37..39 */
109 dhcptag_default_ttl_e = 37,
110 dhcptag_keepalive_interval_e = 38,
111 dhcptag_keepalive_garbage_e = 39,
112
113 /* application & service parameters: 40..49, 64, 65, 68..76, 78, 79, 95 */
114 dhcptag_nis_domain_e = 40,
115 dhcptag_nis_servers_e = 41,
116 dhcptag_network_time_protocol_servers_e = 42,
117 dhcptag_vendor_specific_e = 43,
118 dhcptag_nb_over_tcpip_name_server_e = 44,
119 dhcptag_nb_over_tcpip_dgram_dist_server_e = 45,
120 dhcptag_nb_over_tcpip_node_type_e = 46,
121 dhcptag_nb_over_tcpip_scope_e = 47,
122 dhcptag_x_windows_font_server_e = 48,
123 dhcptag_x_windows_display_manager_e = 49,
124 dhcptag_nis_plus_domain_e = 64,
125 dhcptag_nis_plus_servers_e = 65,
126 dhcptag_mobile_ip_home_agent_e = 68,
127 dhcptag_smtp_server_e = 69,
128 dhcptag_pop3_server_e = 70,
129 dhcptag_nntp_server_e = 71,
130 dhcptag_default_www_server_e = 72,
131 dhcptag_default_finger_server_e = 73,
132 dhcptag_default_irc_server_e = 74,
133 dhcptag_streettalk_server_e = 75,
134 dhcptag_stda_server_e = 76,
135 dhcptag_slp_directory_agent_e = 78,
136 dhcptag_slp_service_scope_e = 79,
137 dhcptag_ldap_url_e = 95,
138
139 /* dhcp-specific extensions: 50..61, 66, 67 */
140 dhcptag_requested_ip_address_e = 50,
141 dhcptag_lease_time_e = 51,
142 dhcptag_option_overload_e = 52,
143 dhcptag_dhcp_message_type_e = 53,
144 dhcptag_server_identifier_e = 54,
145 dhcptag_parameter_request_list_e = 55,
146 dhcptag_message_e = 56,
147 dhcptag_max_dhcp_message_size_e = 57,
148 dhcptag_renewal_t1_time_value_e = 58,
149 dhcptag_rebinding_t2_time_value_e = 59,
150 dhcptag_vendor_class_identifier_e = 60,
151 dhcptag_client_identifier_e = 61,
152 dhcptag_tftp_server_name_e = 66,
153 dhcptag_bootfile_name_e = 67,
154
155 /* netinfo parent tags: 112, 113 */
156 dhcptag_netinfo_server_address_e = 112,
157 dhcptag_netinfo_server_tag_e = 113,
158
159 /* ad-hoc network disable option */
160 dhcptag_auto_configure_e = 116,
161} dhcptag_t;
162
163/*
164 * Module: dhcpol (dhcp options list)
165 *
166 * Purpose:
167 * Routines to parse and retrieve dhcp options.
168 */
169
170typedef struct {
171 void * * array; /* malloc'd array of pointers */
172 int size; /* number of elements in array */
173 int count; /* number of occupied elements */
174} ptrlist_t;
175
176typedef ptrlist_t dhcpol_t;
177
91447636 178#ifdef KERNEL_PRIVATE
9bccf70c
A
179
180void dhcpol_init(dhcpol_t * list);
181void dhcpol_free(dhcpol_t * list);
182int dhcpol_count(dhcpol_t * list);
183boolean_t dhcpol_add(dhcpol_t * list, void * element);
184void * dhcpol_element(dhcpol_t * list, int i);
185boolean_t dhcpol_concat(dhcpol_t * list, dhcpol_t * extra);
186boolean_t dhcpol_parse_buffer(dhcpol_t * list, void * buffer,
187 int length, unsigned char * err);
188void * dhcpol_find(dhcpol_t * list, int tag, int * len_p,
189 int * start);
190void * dhcpol_get(dhcpol_t * list, int tag, int * len_p);
191boolean_t dhcpol_parse_packet(dhcpol_t * options,
192 struct dhcp * pkt, int len,
193 unsigned char * err);
194boolean_t dhcpol_parse_vendor(dhcpol_t * vendor,
195 dhcpol_t * options,
196 unsigned char * err);
197void dhcpol_print(dhcpol_t * list);
91447636 198#endif KERNEL_PRIVATE
d7e50217 199#endif /* _NETINET_DHCP_OPTIONS_H */