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