xref: /titanic_41/usr/src/uts/common/inet/arp.h (revision 8475e04352e630e4bd0f59a283286ee2475a14ce)
1 /*
2  * CDDL HEADER START
3  *
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 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 /* Copyright (c) 1990 Mentat Inc. */
26 
27 #ifndef	_INET_ARP_H
28 #define	_INET_ARP_H
29 
30 #include <sys/types.h>
31 #include <net/if.h>
32 
33 #ifdef	__cplusplus
34 extern "C" {
35 #endif
36 
37 /*
38  * Warning: the interfaces described in this file are private to the
39  * implementation.  They may change at any time without notice and are not
40  * documented.  Do not depend on them.
41  */
42 
43 #define	ARP_REQUEST	1
44 #define	ARP_RESPONSE	2
45 #define	RARP_REQUEST	3
46 #define	RARP_RESPONSE	4
47 
48 #define	AR_IOCTL		(((unsigned)'A' & 0xFF)<<8)
49 #define	CMD_IN_PROGRESS		0x10000
50 
51 #define	AR_ENTRY_ADD		(AR_IOCTL + 1)
52 #define	AR_ENTRY_DELETE		(AR_IOCTL + 2)
53 #define	AR_ENTRY_QUERY		(AR_IOCTL + 3)
54 #define	AR_ENTRY_SQUERY		(AR_IOCTL + 6)
55 #define	AR_MAPPING_ADD		(AR_IOCTL + 7)
56 #define	AR_CLIENT_NOTIFY	(AR_IOCTL + 8)
57 #define	AR_INTERFACE_UP		(AR_IOCTL + 9)
58 #define	AR_INTERFACE_DOWN	(AR_IOCTL + 10)
59 #define	AR_INTERFACE_ON		(AR_IOCTL + 12)
60 #define	AR_INTERFACE_OFF	(AR_IOCTL + 13)
61 #define	AR_DLPIOP_DONE		(AR_IOCTL + 14)
62 /*
63  * This is not an ARP command per se, it is used to interface between
64  * ARP and IP during close.
65  */
66 #define	AR_ARP_CLOSING		(AR_IOCTL + 16)
67 #define	AR_ARP_EXTEND		(AR_IOCTL + 17)
68 #define	AR_IPMP_ACTIVATE	(AR_IOCTL + 18)
69 #define	AR_IPMP_DEACTIVATE	(AR_IOCTL + 19)
70 
71 /* Both ace_flags and area_flags; must also modify arp.c in mdb */
72 #define	ACE_F_PERMANENT		0x0001
73 #define	ACE_F_PUBLISH		0x0002
74 #define	ACE_F_DYING		0x0004
75 #define	ACE_F_RESOLVED		0x0008
76 /* Using bit mask extraction from target address */
77 #define	ACE_F_MAPPING		0x0010
78 #define	ACE_F_MYADDR		0x0020	/* IP claims to own this address */
79 #define	ACE_F_UNVERIFIED	0x0040	/* DAD not yet complete */
80 #define	ACE_F_AUTHORITY		0x0080	/* check for duplicate MACs */
81 #define	ACE_F_DEFEND		0x0100	/* single transmit (area_flags only) */
82 #define	ACE_F_OLD		0x0200	/* should revalidate when IP asks */
83 #define	ACE_F_FAST		0x0400	/* fast probe enabled */
84 #define	ACE_F_DELAYED		0x0800	/* rescheduled on arp_defend_rate */
85 #define	ACE_F_DAD_ABORTED	0x1000	/* DAD was aborted on link down */
86 
87 /* ared_flags */
88 #define	ARED_F_PRESERVE_PERM	0x0001	/* preserve permanent ace */
89 
90 /* ARP Command Structures */
91 
92 /* arc_t - Common command overlay */
93 typedef struct ar_cmd_s {
94 	uint32_t	arc_cmd;
95 	uint32_t	arc_name_offset;
96 	uint32_t	arc_name_length;
97 } arc_t;
98 
99 /*
100  * NOTE: when using area_t for an AR_ENTRY_SQUERY, the area_hw_addr_offset
101  * field isn't what you might think. See comments in ip_multi.c where
102  * the routine ill_create_squery() is called, and also in the routine
103  * itself, to see how this field is used *only* when the area_t holds
104  * an AR_ENTRY_SQUERY.
105  */
106 typedef	struct ar_entry_add_s {
107 	uint32_t	area_cmd;
108 	uint32_t	area_name_offset;
109 	uint32_t	area_name_length;
110 	uint32_t	area_proto;
111 	uint32_t	area_proto_addr_offset;
112 	uint32_t	area_proto_addr_length;
113 	uint32_t	area_proto_mask_offset;
114 	uint32_t	area_flags;		/* Same values as ace_flags */
115 	uint32_t	area_hw_addr_offset;
116 	uint32_t	area_hw_addr_length;
117 } area_t;
118 
119 typedef	struct ar_entry_delete_s {
120 	uint32_t	ared_cmd;
121 	uint32_t	ared_name_offset;
122 	uint32_t	ared_name_length;
123 	uint32_t	ared_proto;
124 	uint32_t	ared_proto_addr_offset;
125 	uint32_t	ared_proto_addr_length;
126 	uint32_t	ared_flags;
127 } ared_t;
128 
129 typedef	struct ar_entry_query_s {
130 	uint32_t	areq_cmd;
131 	uint32_t	areq_name_offset;
132 	uint32_t	areq_name_length;
133 	uint32_t	areq_proto;
134 	uint32_t	areq_target_addr_offset;
135 	uint32_t	areq_target_addr_length;
136 	uint32_t	areq_flags;
137 	uint32_t	areq_sender_addr_offset;
138 	uint32_t	areq_sender_addr_length;
139 	uint32_t	areq_xmit_count;	/* 0 ==> cache lookup only */
140 	uint32_t	areq_xmit_interval; /* # of milliseconds; 0: default */
141 		/* # ofquests to buffer; 0: default */
142 	uint32_t	areq_max_buffered;
143 	uchar_t	areq_sap[8];		/* to insert in returned template */
144 } areq_t;
145 
146 #define	AR_EQ_DEFAULT_XMIT_COUNT	6
147 #define	AR_EQ_DEFAULT_XMIT_INTERVAL	1000
148 #define	AR_EQ_DEFAULT_MAX_BUFFERED	4
149 
150 /*
151  * Structure used with AR_ENTRY_LLAQUERY to map from the link_addr
152  * (in Neighbor Discovery option format excluding the option type and
153  * length) to a hardware address.
154  * The response has the same format as for an AR_ENTRY_SQUERY - an M_CTL with
155  * arel_hw_addr updated.
156  * An IPv6 address will be passed in AR_ENTRY_LLAQUERY so that atmip
157  * can send it in AR_CLIENT_NOTIFY messages.
158  */
159 typedef	struct ar_entry_llaquery_s {
160 	uint32_t	arel_cmd;
161 	uint32_t	arel_name_offset;
162 	uint32_t	arel_name_length;
163 	uint32_t	arel_link_addr_offset;
164 	uint32_t	arel_link_addr_length;
165 	uint32_t	arel_hw_addr_offset;
166 	uint32_t	arel_hw_addr_length;
167 	uint32_t	arel_ip_addr_offset;
168 	uint32_t	arel_ip_addr_length;
169 } arel_t;
170 
171 typedef	struct ar_mapping_add_s {
172 	uint32_t	arma_cmd;
173 	uint32_t	arma_name_offset;
174 	uint32_t	arma_name_length;
175 	uint32_t	arma_proto;
176 	uint32_t	arma_proto_addr_offset;
177 	uint32_t	arma_proto_addr_length;
178 	uint32_t	arma_proto_mask_offset;
179 	uint32_t	arma_proto_extract_mask_offset;
180 	uint32_t	arma_flags;
181 	uint32_t	arma_hw_addr_offset;
182 	uint32_t	arma_hw_addr_length;
183 		/* Offset were we start placing */
184 	uint32_t	arma_hw_mapping_start;
185 					/* the mask&proto_addr */
186 } arma_t;
187 
188 /* Structure used to notify ARP of changes to IPMP group topology */
189 typedef	struct ar_ipmp_event_s {
190 	uint32_t	arie_cmd;
191 	uint32_t	arie_name_offset;
192 	uint32_t	arie_name_length;
193 	char		arie_grifname[LIFNAMSIZ];
194 } arie_t;
195 
196 /* Structure used to notify clients of interesting conditions. */
197 typedef struct ar_client_notify_s {
198 	uint32_t	arcn_cmd;
199 	uint32_t	arcn_name_offset;
200 	uint32_t	arcn_name_length;
201 	uint32_t	arcn_code;			/* Notification code. */
202 } arcn_t;
203 
204 /* Client Notification Codes */
205 #define	AR_CN_BOGON	1
206 #define	AR_CN_ANNOUNCE	2
207 #define	AR_CN_READY	3		/* DAD complete; address usable */
208 #define	AR_CN_FAILED	4		/* DAD failed; address unusable */
209 
210 /* ARP Header */
211 typedef struct arh_s {
212 	uchar_t	arh_hardware[2];
213 	uchar_t	arh_proto[2];
214 	uchar_t	arh_hlen;
215 	uchar_t	arh_plen;
216 	uchar_t	arh_operation[2];
217 	/* The sender and target hw/proto pairs follow */
218 } arh_t;
219 
220 #ifdef	__cplusplus
221 }
222 #endif
223 
224 #endif	/* _INET_ARP_H */
225