xref: /illumos-gate/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_mip.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 1999 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #ifndef	_SNOOP_MIP_H
28 #define	_SNOOP_MIP_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 #define	ALIGN(ptr)		(ptr)
37 
38 /*
39  *	E X T E N S I O N S
40  */
41 
42 typedef struct {
43 	uchar_t		type;
44 	uchar_t		length;
45 } exthdr_t;
46 
47 /* This header is used for Generalized MIP Authentication Extensions */
48 typedef struct {
49 	uint8_t		type;
50 	uint8_t		subtype;
51 	uint16_t	length;
52 } gen_exthdr_t;
53 
54 #define	MN_HA_AUTH	32
55 #define	MN_FA_AUTH	33
56 #define	FA_HA_AUTH	34
57 #define	GEN_AUTH	36
58 #define	MN_HA_KEY	126
59 #define	MN_HA_TRAVERSE	129
60 #define	ENCAP_DELIV	130
61 #define	MN_NAI		131
62 #define	FA_CHALLENGE	132
63 #define	MN_FA_KEY	133
64 
65 /* Subtypes for Generalized MIP Authentication Extension (GEN_AUTH) */
66 #define	GEN_AUTH_MN_AAA		1
67 
68 #define	KEY_ALG_NONE		0
69 #define	SA_MD5_MODE_PREF_SUF	2	/* ...in prefix+suffix */
70 #define	SA_HMAC_MD5		3
71 
72 /*
73  * 	R E G I S T R A T I O N    P R O T O C O L
74  */
75 
76 #define	REG_TYPE_REQ	1
77 #define	REG_TYPE_REP	3
78 
79 typedef struct ident_str {
80 	uint32_t high_bits;	/* generated by the HA */
81 	uint32_t low_bits;	/* generated by the MN */
82 } ident_t;
83 
84 #ifdef __sparc
85 #ifdef _BIT_FIELDS_HTOL
86 typedef struct registration_request_str {
87 	uchar_t		type;		/* must be REG_TYPE_REQ */
88 	uchar_t
89 		Simultaneous_registration : 	1,
90 		Broadcasts_desired : 		1,
91 		Decapsulation_done_locally : 	1, /* ...by the popup MN */
92 		Minimal_encap_desired : 	1,
93 		GRE_encap_desired : 		1,
94 		VJ_compression_desired : 	1,
95 		BiDirectional_Tunnel_desired : 	1,
96 		reserved : 			1;
97 	ushort_t	lifetime;	/* 0 = dereg; 0xffff = infinity */
98 	in_addr_t	home_addr;	/* address of the MN */
99 	in_addr_t	home_agent_addr; /* address of a HA */
100 	in_addr_t	care_of_addr;	/* address of decap endpoint */
101 	ident_t		identification;	/* for replay protection */
102 } regreq_t;
103 #endif /* _BIT_FIELDS_HTOL */
104 #endif /* __sparc */
105 
106 #ifdef __i386
107 #ifdef _BIT_FIELDS_LTOH
108 typedef struct registration_request_str {
109 	uchar_t		type;		/* must be REG_TYPE_REQ */
110 	uchar_t
111 		reserved : 			1,
112 		BiDirectional_Tunnel_desired : 	1,
113 		VJ_compression_desired : 	1,
114 		GRE_encap_desired : 		1,
115 		Minimal_encap_desired : 	1,
116 		Decapsulation_done_locally : 	1, /* ...by the popup MN */
117 		Broadcasts_desired : 		1,
118 		Simultaneous_registration : 	1;
119 	ushort_t	lifetime;	/* 0 = dereg; 0xffff = infinity */
120 	in_addr_t	home_addr;	/* address of the MN */
121 	in_addr_t	home_agent_addr; /* address of a HA */
122 	in_addr_t	care_of_addr;	/* address of decap endpoint */
123 	ident_t		identification;	/* for replay protection */
124 } regreq_t;
125 #endif /* _BIT_FIELDS_LTOH */
126 #endif /* __i386 */
127 
128 /*
129  * Registration Reply sent by a home agent to a mobile node in
130  * response to a registration request.
131  */
132 typedef struct registration_reply_str {
133 	uchar_t		type;		/* must be REG_TYPE_REP */
134 	uchar_t		code;		/* refer to draft document */
135 	ushort_t	lifetime;	/* 0 = dereg; 0xffff = infinity */
136 	in_addr_t	home_addr;	/* address of the mobile node */
137 	in_addr_t	home_agent_addr; /* address of the home agent */
138 	ident_t		identification;	/* derived from request's field */
139 } regrep_t;
140 
141 /* service ok */
142 #define	REPLY_CODE_ACK					0
143 #define	REPLY_CODE_ACK_NO_SIMULTANEOUS			1
144 
145 /* denied by FA */
146 #define	REPLY_CODE_FA_NACK_UNSPECIFIED			64
147 #define	REPLY_CODE_FA_NACK_PROHIBITED			65
148 #define	REPLY_CODE_FA_NACK_RESOURCES			66
149 #define	REPLY_CODE_FA_NACK_MN_AUTH			67
150 #define	REPLY_CODE_FA_NACK_HA_AUTH			68
151 #define	REPLY_CODE_FA_NACK_LIFETIME			69
152 #define	REPLY_CODE_FA_NACK_BAD_REQUEST			70
153 #define	REPLY_CODE_FA_NACK_BAD_REPLY			71
154 #define	REPLY_CODE_FA_NACK_ENCAP_UNAVAILABLE		72
155 #define	REPLY_CODE_FA_NACK_VJ_UNAVAILABLE		73
156 #define	REPLY_CODE_FA_NACK_BIDIR_TUNNEL_UNAVAILABLE	74
157 #define	REPLY_CODE_FA_NACK_BIDIR_TUNNEL_NO_TBIT		75
158 #define	REPLY_CODE_FA_NACK_BIDIR_TUNNEL_TOO_DISTANT	76
159 #define	REPLY_CODE_FA_NACK_ICMP_HA_NET_UNREACHABLE	80
160 #define	REPLY_CODE_FA_NACK_ICMP_HA_HOST_UNREACHABLE	81
161 #define	REPLY_CODE_FA_NACK_ICMP_HA_PORT_UNREACHABLE	82
162 #define	REPLY_CODE_FA_NACK_ICMP_HA_UNREACHABLE		88
163 #define	REPLY_CODE_FA_NACK_UNIQUE_HOMEADDR_REQD		96
164 #define	REPLY_CODE_FA_NACK_MISSING_NAI			97
165 #define	REPLY_CODE_FA_NACK_MISSING_HOME_AGENT		98
166 #define	REPLY_CODE_FA_NACK_MISSING_HOMEADDR		99
167 #define	REPLY_CODE_FA_NACK_UNKNOWN_CHALLENGE		104
168 #define	REPLY_CODE_FA_NACK_MISSING_CHALLENGE		105
169 #define	REPLY_CODE_FA_NACK_MISSING_MN_FA		106
170 
171 /* denied by HA */
172 #define	REPLY_CODE_HA_NACK_UNSPECIFIED			128
173 #define	REPLY_CODE_HA_NACK_PROHIBITED			129
174 #define	REPLY_CODE_HA_NACK_RESOURCES			130
175 #define	REPLY_CODE_HA_NACK_MN_AUTH			131
176 #define	REPLY_CODE_HA_NACK_FA_AUTH			132
177 #define	REPLY_CODE_HA_NACK_ID_MISMATCH			133
178 #define	REPLY_CODE_HA_NACK_BAD_REQUEST			134
179 #define	REPLY_CODE_HA_NACK_TOO_MANY_BINDINGS		135
180 #define	REPLY_CODE_HA_NACK_BAD_HA_ADDRESS		136
181 #define	REPLY_CODE_HA_NACK_BIDIR_TUNNEL_UNAVAILABLE	137
182 #define	REPLY_CODE_HA_NACK_BIDIR_TUNNEL_NO_TBIT		138
183 #define	REPLY_CODE_HA_NACK_BIDIR_ENCAP_UNAVAILABLE	139
184 
185 /*
186  * OTHER EXTENSIONS
187  */
188 
189 /*
190  * The second set consists of those extensions which may appear only
191  * in ICMP Router Discovery messages [4].  Currently, Mobile IP
192  * defines the following Types for Extensions appearing in ICMP
193  * Router Discovery messages:
194  *
195  * 0  One-byte PaddingOne-byte Padding (encoded with no Length nor
196  * Data field)
197  * 16  Mobility Agent Advertisement
198  * 19  Prefix-Lengths
199  */
200 #define	ICMP_ADV_MSG_PADDING_EXT	0
201 #define	ICMP_ADV_MSG_MOBILITY_AGT_EXT	16
202 #define	ICMP_ADV_MSG_PREFIX_LENGTH_EXT	19
203 #define	ICMP_ADV_MSG_FA_CHALLENGE	24
204 #define	ICMP_ADV_MSG_FA_NAI		25
205 
206 
207 /*
208  * Mobility Agent Advertisement Extension
209  * The Mobility Agent Adv Extension follows the ICMP Router
210  * Advertisement fields.It is used to indicate that an ICMP Router
211  * Advertisement message is also an Agent Advertisement being sent
212  * by a mobility agent.
213  *
214  * Type		16
215  * Length	(6 + 4*N), where N is the number of care-of addresses
216  *		advertised.
217  *
218  * Sequence Number
219  * The count of Agent Advertisement messages sent since the
220  * agent was initialized (Section 2.3.2).
221  *
222  * Registration Lifetime
223  * The longest lifetime (measured in seconds) that this
224  * agent is willing to accept in any Registration Request.
225  * A value of 0xffff indicates infinity.  This field has no
226  * relation to the "Lifetime" field within the ICMP Router
227  * Advertisement portion of the Agent Advertisement.
228  *
229  * R	Registration required.  Registration with this foreign
230  * agent (or another foreign agent on this link) is required
231  * rather than using a co-located care-of address.
232  *
233  * B	Busy.  The foreign agent will not accept registrations
234  * from additional mobile nodes.
235  *
236  * H	Home agent.  This agent offers service as a home agent
237  * on the link on which this Agent Advertisement message is
238  * sent.
239  *
240  * F	Foreign agent.  This agent offers service as a foreign
241  * agent on the link on which this Agent Advertisement
242  * message is sent.
243  *
244  * M	Minimal encapsulation.  This agent implements receiving
245  * tunneled datagrams that use minimal encapsulation [15].
246  *
247  * G	GRE encapsulation.  This agent implements receiving
248  * tunneled datagrams that use GRE encapsulation [8].
249  *
250  * V 	Van Jacobson header compression.  This agent supports use
251  * of Van Jacobson header compression [10] over the link
252  * with any registered mobile node.
253  *
254  * reserved 	sent as zero; ignored on reception.
255  *
256  * Care-of Address(es)
257  * The advertised foreign agent care-of address(es) provided
258  * by this foreign agent.  An Agent Advertisement MUST
259  * include at least one care-of address if the 'F' bit
260  * is set.  The number of care-of addresses present is
261  * determined by the Length field in the Extension.
262  *
263  * A HA must always be prepared to serve the mobile nodes for
264  * which it is the home agent. A FA may at times be too busy
265  * to serve additional MNs; even so, it must continue to send
266  * Agent Advertisements, so that any mobile nodes already registered
267  * with it will know that they have not moved out of range of the
268  * foreign agent and that the  has not failed.  A foreign
269  * agent may indicate that it is "too busy" to allow new MNs to
270  * register with it, by setting the 'B' bit in its Agent Adv.
271  * An Agent Adv message MUST NOT have the 'B' bit set if the
272  * 'F' bit is not also set, and at least one of the 'F' bit and the
273  * 'H'  bit MUST be set in any Agent Advertisement message sent.
274  *
275  * When a FA wishes to require registration even from those
276  * mobile nodes which have acquired a co-located care-of address, it
277  * sets the 'R' bit to one. Because this bit applies only to foreign
278  * agents, an agent MUST NOT set the 'R' bit to one unless the 'F'
279  * bit is also set to one.
280  */
281 #ifdef __sparc
282 #ifdef _BIT_FIELDS_HTOL
283 typedef struct mobility_agt_adv_extension {
284 	uchar_t		type;
285 	uchar_t		length;
286 	ushort_t	sequence_num;
287 	ushort_t	reg_lifetime;
288 	ushort_t	reg_bit:1,
289 			busy_bit:1,
290 			ha_bit:1,
291 			fa_bit:1,
292 			minencap_bit:1,
293 			greencap_bit:1,
294 			vanjacob_hdr_comp_bit:1,
295 			reverse_tunnel_bit:1,
296 			reserved:8;
297 } mobagtadvext_t;
298 
299 #endif /* _BIT_FIELDS_HTOL */
300 #endif /* __sparc */
301 
302 #ifdef __i386
303 #ifdef _BIT_FIELDS_LTOH
304 typedef struct mobility_agt_adv_extension {
305 	uchar_t		type;
306 	uchar_t		length;
307 	ushort_t	sequence_num;
308 	ushort_t	reg_lifetime;
309 	uchar_t
310 			reverse_tunnel_bit:1,
311 			vanjacob_hdr_comp_bit:1,
312 			greencap_bit:1,
313 			minencap_bit:1,
314 			fa_bit:1,
315 			ha_bit:1,
316 			busy_bit:1,
317 			reg_bit:1;
318 	uchar_t		reserved;
319 } mobagtadvext_t;
320 #endif /* _BIT_FIELDS_LTOH */
321 #endif /* __i386 */
322 
323 #ifdef __cplusplus
324 }
325 #endif
326 
327 #endif /* _SNOOP_MIP_H */
328