4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 #ifndef _PACKET_H
27 #define _PACKET_H
28
29 #pragma ident "%Z%%M% %I% %E% SMI"
30
31 #include <sys/types.h>
32 #include <netinet/in.h>
33 #include <netinet/dhcp.h>
34 #include <netinet/dhcp6.h>
35 #include <dhcp_impl.h>
36
37 #include "common.h"
38
39 /*
40 * packet.[ch] contain routines for manipulating, setting, and
41 * transmitting DHCP/BOOTP packets. see packet.c for descriptions on
42 * how to use the exported functions.
43 */
105 typedef boolean_t stop_func_t(dhcp_smach_t *, unsigned int);
106
107 /*
108 * Default I/O and interface control sockets.
109 */
110 extern int v6_sock_fd;
111 extern int v4_sock_fd;
112
113 extern const in6_addr_t ipv6_all_dhcp_relay_and_servers;
114 extern const in6_addr_t my_in6addr_any;
115
116 PKT_LIST *alloc_pkt_entry(size_t, boolean_t);
117 void free_pkt_entry(PKT_LIST *);
118 void free_pkt_list(PKT_LIST **);
119 uchar_t pkt_recv_type(const PKT_LIST *);
120 uint_t pkt_get_xid(const PKT *, boolean_t);
121 dhcp_pkt_t *init_pkt(dhcp_smach_t *, uchar_t);
122 boolean_t remove_pkt_opt(dhcp_pkt_t *, uint_t);
123 boolean_t update_v6opt_len(dhcpv6_option_t *, int);
124 void *add_pkt_opt(dhcp_pkt_t *, uint_t, const void *, uint_t);
125 void *add_pkt_subopt(dhcp_pkt_t *, dhcpv6_option_t *, uint_t,
126 const void *, uint_t);
127 void *add_pkt_opt16(dhcp_pkt_t *, uint_t, uint16_t);
128 void *add_pkt_opt32(dhcp_pkt_t *, uint_t, uint32_t);
129 void *add_pkt_prl(dhcp_pkt_t *, dhcp_smach_t *);
130 boolean_t add_pkt_lif(dhcp_pkt_t *, dhcp_lif_t *, int, const char *);
131 void stop_pkt_retransmission(dhcp_smach_t *);
132 void retransmit_now(dhcp_smach_t *);
133 PKT_LIST *recv_pkt(int, int, boolean_t);
134 boolean_t pkt_v4_match(uchar_t, dhcp_message_type_t);
135 void pkt_smach_enqueue(dhcp_smach_t *, PKT_LIST *);
136 boolean_t send_pkt(dhcp_smach_t *, dhcp_pkt_t *, in_addr_t,
137 stop_func_t *);
138 boolean_t send_pkt_v6(dhcp_smach_t *, dhcp_pkt_t *, in6_addr_t,
139 stop_func_t *, uint_t, uint_t);
140 boolean_t dhcp_ip_default(void);
141
142 #ifdef __cplusplus
143 }
144 #endif
|
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 * Copyright (c) 2016, Chris Fraire <cfraire@me.com>.
25 */
26
27 #ifndef _PACKET_H
28 #define _PACKET_H
29
30 #pragma ident "%Z%%M% %I% %E% SMI"
31
32 #include <sys/types.h>
33 #include <netinet/in.h>
34 #include <netinet/dhcp.h>
35 #include <netinet/dhcp6.h>
36 #include <dhcp_impl.h>
37
38 #include "common.h"
39
40 /*
41 * packet.[ch] contain routines for manipulating, setting, and
42 * transmitting DHCP/BOOTP packets. see packet.c for descriptions on
43 * how to use the exported functions.
44 */
106 typedef boolean_t stop_func_t(dhcp_smach_t *, unsigned int);
107
108 /*
109 * Default I/O and interface control sockets.
110 */
111 extern int v6_sock_fd;
112 extern int v4_sock_fd;
113
114 extern const in6_addr_t ipv6_all_dhcp_relay_and_servers;
115 extern const in6_addr_t my_in6addr_any;
116
117 PKT_LIST *alloc_pkt_entry(size_t, boolean_t);
118 void free_pkt_entry(PKT_LIST *);
119 void free_pkt_list(PKT_LIST **);
120 uchar_t pkt_recv_type(const PKT_LIST *);
121 uint_t pkt_get_xid(const PKT *, boolean_t);
122 dhcp_pkt_t *init_pkt(dhcp_smach_t *, uchar_t);
123 boolean_t remove_pkt_opt(dhcp_pkt_t *, uint_t);
124 boolean_t update_v6opt_len(dhcpv6_option_t *, int);
125 void *add_pkt_opt(dhcp_pkt_t *, uint_t, const void *, uint_t);
126 size_t encode_dhcp_opt(void *, boolean_t, uint_t, const void *,
127 uint_t);
128 void *add_pkt_subopt(dhcp_pkt_t *, dhcpv6_option_t *, uint_t,
129 const void *, uint_t);
130 void *add_pkt_opt16(dhcp_pkt_t *, uint_t, uint16_t);
131 void *add_pkt_opt32(dhcp_pkt_t *, uint_t, uint32_t);
132 void *add_pkt_prl(dhcp_pkt_t *, dhcp_smach_t *);
133 boolean_t add_pkt_lif(dhcp_pkt_t *, dhcp_lif_t *, int, const char *);
134 void stop_pkt_retransmission(dhcp_smach_t *);
135 void retransmit_now(dhcp_smach_t *);
136 PKT_LIST *recv_pkt(int, int, boolean_t);
137 boolean_t pkt_v4_match(uchar_t, dhcp_message_type_t);
138 void pkt_smach_enqueue(dhcp_smach_t *, PKT_LIST *);
139 boolean_t send_pkt(dhcp_smach_t *, dhcp_pkt_t *, in_addr_t,
140 stop_func_t *);
141 boolean_t send_pkt_v6(dhcp_smach_t *, dhcp_pkt_t *, in6_addr_t,
142 stop_func_t *, uint_t, uint_t);
143 boolean_t dhcp_ip_default(void);
144
145 #ifdef __cplusplus
146 }
147 #endif
|