Drop ".i0", it is an undefined macro.
[netbsd-mini2440.git] / dist / tcpdump / isakmp.h
blob319c87ec8c6f8783e35c9ee01722f90a0ee845bc
1 /* $NetBSD$ */
3 /*
4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
5 * All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the project nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
31 /* YIPS @(#)Id: isakmp.h,v 1.10 2002/12/11 07:13:54 guy Exp */
33 /* refer to RFC 2408 */
35 /* must include <netinet/in.h> */
37 #if !defined(_ISAKMP_H_)
38 #define _ISAKMP_H_
40 typedef u_char cookie_t[8];
41 typedef u_char msgid_t[4];
43 typedef struct { /* i_cookie + r_cookie */
44 cookie_t i_ck;
45 cookie_t r_ck;
46 } isakmp_index;
48 #define INITIATOR 1
49 #define RESPONDER 2
51 #define PORT_ISAKMP 500
53 #define GENERATE 1
54 #define VALIDATE 0
56 /* Phase of oakley definition */
58 0000 0000 0000 0000
59 | |||| ||||
60 | |||| ++++--> negosiation number in phase
61 | ++++-------> phase number
62 +---------------> expire ?
64 #define ISAKMP_PH1 0x0010
65 #define ISAKMP_PH2 0x0020
66 #define ISAKMP_EXPIRED 0x0100
68 #define ISAKMP_NGP_0 0x0000
69 #define ISAKMP_NGP_1 0x0001
70 #define ISAKMP_NGP_2 0x0002
71 #define ISAKMP_NGP_3 0x0003
72 #define ISAKMP_NGP_4 0x0004
74 #define ISAKMP_PH1_N (ISAKMP_PH1 | ISAKMP_NGP_0) /* i.e. spawn */
75 #define ISAKMP_PH1_1 (ISAKMP_PH1 | ISAKMP_NGP_1)
76 #define ISAKMP_PH1_2 (ISAKMP_PH1 | ISAKMP_NGP_2)
77 #define ISAKMP_PH1_3 (ISAKMP_PH1 | ISAKMP_NGP_3)
78 #define ISAKMP_PH2_N (ISAKMP_PH2 | ISAKMP_NGP_0)
79 #define ISAKMP_PH2_1 (ISAKMP_PH2 | ISAKMP_NGP_1)
80 #define ISAKMP_PH2_2 (ISAKMP_PH2 | ISAKMP_NGP_2)
81 #define ISAKMP_PH2_3 (ISAKMP_PH2 | ISAKMP_NGP_3)
83 #define ISAKMP_TIMER_DEFAULT 10 /* seconds */
84 #define ISAKMP_TRY_DEFAULT 3 /* times */
86 /* 3.1 ISAKMP Header Format
87 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
88 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
89 ! Initiator !
90 ! Cookie !
91 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
92 ! Responder !
93 ! Cookie !
94 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
95 ! Next Payload ! MjVer ! MnVer ! Exchange Type ! Flags !
96 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
97 ! Message ID !
98 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
99 ! Length !
100 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
102 struct isakmp {
103 cookie_t i_ck; /* Initiator Cookie */
104 cookie_t r_ck; /* Responder Cookie */
105 u_int8_t np; /* Next Payload Type */
106 u_int8_t vers;
107 #define ISAKMP_VERS_MAJOR 0xf0
108 #define ISAKMP_VERS_MAJOR_SHIFT 4
109 #define ISAKMP_VERS_MINOR 0x0f
110 #define ISAKMP_VERS_MINOR_SHIFT 0
111 u_int8_t etype; /* Exchange Type */
112 u_int8_t flags; /* Flags */
113 msgid_t msgid;
114 u_int32_t len; /* Length */
117 /* Next Payload Type */
118 #define ISAKMP_NPTYPE_NONE 0 /* NONE*/
119 #define ISAKMP_NPTYPE_SA 1 /* Security Association */
120 #define ISAKMP_NPTYPE_P 2 /* Proposal */
121 #define ISAKMP_NPTYPE_T 3 /* Transform */
122 #define ISAKMP_NPTYPE_KE 4 /* Key Exchange */
123 #define ISAKMP_NPTYPE_ID 5 /* Identification */
124 #define ISAKMP_NPTYPE_CERT 6 /* Certificate */
125 #define ISAKMP_NPTYPE_CR 7 /* Certificate Request */
126 #define ISAKMP_NPTYPE_HASH 8 /* Hash */
127 #define ISAKMP_NPTYPE_SIG 9 /* Signature */
128 #define ISAKMP_NPTYPE_NONCE 10 /* Nonce */
129 #define ISAKMP_NPTYPE_N 11 /* Notification */
130 #define ISAKMP_NPTYPE_D 12 /* Delete */
131 #define ISAKMP_NPTYPE_VID 13 /* Vendor ID */
133 #define ISAKMP_MAJOR_VERSION 1
134 #define ISAKMP_MINOR_VERSION 0
136 /* Exchange Type */
137 #define ISAKMP_ETYPE_NONE 0 /* NONE */
138 #define ISAKMP_ETYPE_BASE 1 /* Base */
139 #define ISAKMP_ETYPE_IDENT 2 /* Identity Proteciton */
140 #define ISAKMP_ETYPE_AUTH 3 /* Authentication Only */
141 #define ISAKMP_ETYPE_AGG 4 /* Aggressive */
142 #define ISAKMP_ETYPE_INF 5 /* Informational */
144 /* Flags */
145 #define ISAKMP_FLAG_E 0x01 /* Encryption Bit */
146 #define ISAKMP_FLAG_C 0x02 /* Commit Bit */
148 /* 3.2 Payload Generic Header
149 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
150 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
151 ! Next Payload ! RESERVED ! Payload Length !
152 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
154 struct isakmp_gen {
155 u_int8_t np; /* Next Payload */
156 u_int8_t reserved; /* RESERVED, unused, must set to 0 */
157 u_int16_t len; /* Payload Length */
160 /* 3.3 Data Attributes
161 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
162 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
163 !A! Attribute Type ! AF=0 Attribute Length !
164 !F! ! AF=1 Attribute Value !
165 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
166 . AF=0 Attribute Value .
167 . AF=1 Not Transmitted .
168 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
170 struct isakmp_data {
171 u_int16_t type; /* defined by DOI-spec, and Attribute Format */
172 u_int16_t lorv; /* if f equal 1, Attribute Length */
173 /* if f equal 0, Attribute Value */
174 /* if f equal 1, Attribute Value */
176 #define ISAKMP_GEN_TLV 0x0000
177 #define ISAKMP_GEN_TV 0x8000
178 /* mask for type of attribute format */
179 #define ISAKMP_GEN_MASK 0x8000
181 /* 3.4 Security Association Payload */
182 /* MAY NOT be used, because of being defined in ipsec-doi. */
184 If the current payload is the last in the message,
185 then the value of the next payload field will be 0.
186 This field MUST NOT contain the
187 values for the Proposal or Transform payloads as they are considered
188 part of the security association negotiation. For example, this
189 field would contain the value "10" (Nonce payload) in the first
190 message of a Base Exchange (see Section 4.4) and the value "0" in the
191 first message of an Identity Protect Exchange (see Section 4.5).
193 struct isakmp_pl_sa {
194 struct isakmp_gen h;
195 u_int32_t doi; /* Domain of Interpretation */
196 u_int32_t sit; /* Situation */
199 /* 3.5 Proposal Payload */
201 The value of the next payload field MUST only contain the value "2"
202 or "0". If there are additional Proposal payloads in the message,
203 then this field will be 2. If the current Proposal payload is the
204 last within the security association proposal, then this field will
205 be 0.
207 struct isakmp_pl_p {
208 struct isakmp_gen h;
209 u_int8_t p_no; /* Proposal # */
210 u_int8_t prot_id; /* Protocol */
211 u_int8_t spi_size; /* SPI Size */
212 u_int8_t num_t; /* Number of Transforms */
213 /* SPI */
216 /* 3.6 Transform Payload */
218 The value of the next payload field MUST only contain the value "3"
219 or "0". If there are additional Transform payloads in the proposal,
220 then this field will be 3. If the current Transform payload is the
221 last within the proposal, then this field will be 0.
223 struct isakmp_pl_t {
224 struct isakmp_gen h;
225 u_int8_t t_no; /* Transform # */
226 u_int8_t t_id; /* Transform-Id */
227 u_int16_t reserved; /* RESERVED2 */
228 /* SA Attributes */
231 /* 3.7 Key Exchange Payload */
232 struct isakmp_pl_ke {
233 struct isakmp_gen h;
234 /* Key Exchange Data */
237 /* 3.8 Identification Payload */
238 /* MUST NOT to be used, because of being defined in ipsec-doi. */
239 struct isakmp_pl_id {
240 struct isakmp_gen h;
241 union {
242 u_int8_t id_type; /* ID Type */
243 u_int32_t doi_data; /* DOI Specific ID Data */
244 } d;
245 /* Identification Data */
248 /* 3.9 Certificate Payload */
249 struct isakmp_pl_cert {
250 struct isakmp_gen h;
251 u_int8_t encode; /* Cert Encoding */
252 char cert; /* Certificate Data */
254 This field indicates the type of
255 certificate or certificate-related information contained in the
256 Certificate Data field.
260 /* Certificate Type */
261 #define ISAKMP_CERT_NONE 0
262 #define ISAKMP_CERT_PKCS 1
263 #define ISAKMP_CERT_PGP 2
264 #define ISAKMP_CERT_DNS 3
265 #define ISAKMP_CERT_SIGN 4
266 #define ISAKMP_CERT_KE 5
267 #define ISAKMP_CERT_KT 6
268 #define ISAKMP_CERT_CRL 7
269 #define ISAKMP_CERT_ARL 8
270 #define ISAKMP_CERT_SPKI 9
272 /* 3.10 Certificate Request Payload */
273 struct isakmp_pl_cr {
274 struct isakmp_gen h;
275 u_int8_t num_cert; /* # Cert. Types */
277 Certificate Types (variable length)
278 -- Contains a list of the types of certificates requested,
279 sorted in order of preference. Each individual certificate
280 type is 1 octet. This field is NOT requiredo
282 /* # Certificate Authorities (1 octet) */
283 /* Certificate Authorities (variable length) */
286 /* 3.11 Hash Payload */
287 /* may not be used, because of having only data. */
288 struct isakmp_pl_hash {
289 struct isakmp_gen h;
290 /* Hash Data */
293 /* 3.12 Signature Payload */
294 /* may not be used, because of having only data. */
295 struct isakmp_pl_sig {
296 struct isakmp_gen h;
297 /* Signature Data */
300 /* 3.13 Nonce Payload */
301 /* may not be used, because of having only data. */
302 struct isakmp_pl_nonce {
303 struct isakmp_gen h;
304 /* Nonce Data */
307 /* 3.14 Notification Payload */
308 struct isakmp_pl_n {
309 struct isakmp_gen h;
310 u_int32_t doi; /* Domain of Interpretation */
311 u_int8_t prot_id; /* Protocol-ID */
312 u_int8_t spi_size; /* SPI Size */
313 u_int16_t type; /* Notify Message Type */
314 /* SPI */
315 /* Notification Data */
318 /* 3.14.1 Notify Message Types */
319 /* NOTIFY MESSAGES - ERROR TYPES */
320 #define ISAKMP_NTYPE_INVALID_PAYLOAD_TYPE 1
321 #define ISAKMP_NTYPE_DOI_NOT_SUPPORTED 2
322 #define ISAKMP_NTYPE_SITUATION_NOT_SUPPORTED 3
323 #define ISAKMP_NTYPE_INVALID_COOKIE 4
324 #define ISAKMP_NTYPE_INVALID_MAJOR_VERSION 5
325 #define ISAKMP_NTYPE_INVALID_MINOR_VERSION 6
326 #define ISAKMP_NTYPE_INVALID_EXCHANGE_TYPE 7
327 #define ISAKMP_NTYPE_INVALID_FLAGS 8
328 #define ISAKMP_NTYPE_INVALID_MESSAGE_ID 9
329 #define ISAKMP_NTYPE_INVALID_PROTOCOL_ID 10
330 #define ISAKMP_NTYPE_INVALID_SPI 11
331 #define ISAKMP_NTYPE_INVALID_TRANSFORM_ID 12
332 #define ISAKMP_NTYPE_ATTRIBUTES_NOT_SUPPORTED 13
333 #define ISAKMP_NTYPE_NO_PROPOSAL_CHOSEN 14
334 #define ISAKMP_NTYPE_BAD_PROPOSAL_SYNTAX 15
335 #define ISAKMP_NTYPE_PAYLOAD_MALFORMED 16
336 #define ISAKMP_NTYPE_INVALID_KEY_INFORMATION 17
337 #define ISAKMP_NTYPE_INVALID_ID_INFORMATION 18
338 #define ISAKMP_NTYPE_INVALID_CERT_ENCODING 19
339 #define ISAKMP_NTYPE_INVALID_CERTIFICATE 20
340 #define ISAKMP_NTYPE_BAD_CERT_REQUEST_SYNTAX 21
341 #define ISAKMP_NTYPE_INVALID_CERT_AUTHORITY 22
342 #define ISAKMP_NTYPE_INVALID_HASH_INFORMATION 23
343 #define ISAKMP_NTYPE_AUTHENTICATION_FAILED 24
344 #define ISAKMP_NTYPE_INVALID_SIGNATURE 25
345 #define ISAKMP_NTYPE_ADDRESS_NOTIFICATION 26
346 /* NOTIFY MESSAGES - STATUS TYPES */
347 #define ISAKMP_NTYPE_CONNECTED 16384
348 /* using only to log */
349 #define ISAKMP_LOG_RETRY_LIMIT_REACHED 65530
351 /* 3.15 Delete Payload */
352 struct isakmp_pl_d {
353 struct isakmp_gen h;
354 u_int32_t doi; /* Domain of Interpretation */
355 u_int8_t prot_id; /* Protocol-Id */
356 u_int8_t spi_size; /* SPI Size */
357 u_int16_t num_spi; /* # of SPIs */
358 /* SPI(es) */
362 struct isakmp_ph1tab {
363 struct isakmp_ph1 *head;
364 struct isakmp_ph1 *tail;
365 int len;
368 struct isakmp_ph2tab {
369 struct isakmp_ph2 *head;
370 struct isakmp_ph2 *tail;
371 int len;
374 #define EXCHANGE_PROXY 1
375 #define EXCHANGE_MYSELF 0
377 #define PFS_NEED 1
378 #define PFS_NONEED 0
380 #endif /* !defined(_ISAKMP_H_) */