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