1
/* parsing packets: formats and tools
2
* Copyright (C) 1997 Angelos D. Keromytis.
3
* Copyright (C) 1998-2001 D. Hugh Redelmeier.
5
* This program is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License as published by the
7
* Free Software Foundation; either version 2 of the License, or (at your
8
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10
* This program is distributed in the hope that it will be useful, but
11
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15
* RCSID $Id: packet.h,v 1.27 2004/01/09 04:40:20 mcr Exp $
21
/* a struct_desc describes a structure for the struct I/O routines.
22
* This requires arrays of field_desc values to describe struct fields.
25
typedef const struct struct_desc {
27
const struct field_desc *fields;
31
/* Note: if an ft_af_enum field has the ISAKMP_ATTR_AF_TV bit set,
32
* the subsequent ft_lv field will be interpreted as an immediate value.
33
* This matches how attributes are encoded.
34
* See RFC 2408 "ISAKMP" 3.3
38
ft_mbz, /* must be zero */
39
ft_nat, /* natural number (may be 0) */
40
ft_len, /* length of this struct and any following crud */
41
ft_lv, /* length/value field of attribute */
42
ft_enum, /* value from an enumeration */
43
ft_loose_enum, /* value from an enumeration with only some names known */
44
ft_af_enum, /* Attribute Format + value from an enumeration */
45
ft_af_loose_enum, /* Attribute Format + enumeration, some names known */
46
ft_set, /* bits representing set */
47
ft_raw, /* bytes to be left in network-order */
48
ft_end, /* end of field list */
51
typedef const struct field_desc {
52
enum field_type field_type;
53
int size; /* size, in bytes, of field */
55
const void *desc; /* enum_names for enum or char *[] for bits */
58
/* The formatting of input and output of packets is done
59
* through packet_byte_stream objects.
60
* These describe a stream of bytes in memory.
61
* Several routines are provided to manipulate these objects
62
* Actual packet transfer is done elsewhere.
64
typedef struct packet_byte_stream {
65
struct packet_byte_stream *container; /* PBS of which we are part */
67
const char *name; /* what does this PBS represent? */
70
*cur, /* current position in stream */
71
*roof; /* byte after last in PBS (actually just a limit on output) */
72
/* For an output PBS, the length field will be filled in later so
73
* we need to record its particulars. Note: it may not be aligned.
76
field_desc *lenfld_desc;
79
/* For an input PBS, pbs_offset is amount of stream processed.
80
* For an output PBS, pbs_offset is current size of stream.
81
* For an input PBS, pbs_room is size of stream.
82
* For an output PBS, pbs_room is maximum size allowed.
84
#define pbs_offset(pbs) ((size_t)((pbs)->cur - (pbs)->start))
85
#define pbs_room(pbs) ((size_t)((pbs)->roof - (pbs)->start))
86
#define pbs_left(pbs) ((size_t)((pbs)->roof - (pbs)->cur))
88
extern void init_pbs(pb_stream *pbs, u_int8_t *start, size_t len, const char *name);
90
extern bool in_struct(void *struct_ptr, struct_desc *sd,
91
pb_stream *ins, pb_stream *obj_pbs);
92
extern bool in_raw(void *bytes, size_t len, pb_stream *ins, const char *name);
94
extern bool out_struct(const void *struct_ptr, struct_desc *sd,
95
pb_stream *outs, pb_stream *obj_pbs);
96
extern bool out_generic(u_int8_t np, struct_desc *sd,
97
pb_stream *outs, pb_stream *obj_pbs);
98
extern bool out_generic_raw(u_int8_t np, struct_desc *sd,
99
pb_stream *outs, const void *bytes, size_t len, const char *name);
101
extern bool out_modify_previous_np(u_int8_t np, pb_stream *outs);
103
#define out_generic_chunk(np, sd, outs, ch, name) \
104
out_generic_raw(np, sd, outs, (ch).ptr, (ch).len, name)
105
extern bool out_zero(size_t len, pb_stream *outs, const char *name);
106
extern bool out_raw(const void *bytes, size_t len, pb_stream *outs, const char *name);
107
#define out_chunk(ch, outs, name) out_raw((ch).ptr, (ch).len, (outs), (name))
108
extern void close_output_pbs(pb_stream *pbs);
111
extern void DBG_print_struct(const char *label, const void *struct_ptr,
112
struct_desc *sd, bool len_meaningful);
115
/* ISAKMP Header: for all messages
116
* layout from RFC 2408 "ISAKMP" section 3.1
118
* 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
119
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
122
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
125
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
126
* ! Next Payload ! MjVer ! MnVer ! Exchange Type ! Flags !
127
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
129
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
131
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
132
* Although the drafts are a little unclear, there are a few
133
* places that specify that messages should be padded with 0x00
134
* octets (bytes) to make the length a multiple of something.
136
* RFC 2408 "ISAKMP" 3.6 specifies that all messages will be
137
* padded to be a multiple of 4 octets in length.
138
* ??? This looks vestigial, and we ignore this requirement.
140
* RFC 2409 "IKE" Appedix B specifies:
141
* Each message should be padded up to the nearest block size
142
* using bytes containing 0x00.
143
* ??? This does not appear to be limited to encrypted messages,
144
* but it surely must be: the block size is meant to be the encryption
145
* block size, and that is meaningless for a non-encrypted message.
147
* RFC 2409 "IKE" 5.3 specifies:
148
* Encrypted payloads are padded up to the nearest block size.
149
* All padding bytes, except for the last one, contain 0x00. The
150
* last byte of the padding contains the number of the padding
151
* bytes used, excluding the last one. Note that this means there
152
* will always be padding.
153
* ??? This is nuts since payloads are not padded, messages are.
154
* It also contradicts Appendix B. So we ignore it.
156
* Summary: we pad encrypted output messages with 0x00 to bring them
157
* up to a multiple of the encryption block size. On input, we require
158
* that any encrypted portion of a message be a multiple of the encryption
159
* block size. After any decryption, we ignore padding (any bytes after
160
* the first payload that specifies a next payload of none; we don't
161
* require them to be zero).
166
u_int8_t isa_icookie[COOKIE_SIZE];
167
u_int8_t isa_rcookie[COOKIE_SIZE];
168
u_int8_t isa_np; /* Next payload */
169
u_int8_t isa_version; /* high-order 4 bits: Major; low order 4: Minor */
170
#define ISA_MAJ_SHIFT 4
171
#define ISA_MIN_MASK (~((~0u) << ISA_MAJ_SHIFT))
172
u_int8_t isa_xchg; /* Exchange type */
174
u_int32_t isa_msgid; /* Message ID (RAW) */
175
u_int32_t isa_length; /* Length of message */
178
extern struct_desc isakmp_hdr_desc;
180
/* Generic portion of all ISAKMP payloads.
181
* layout from RFC 2408 "ISAKMP" section 3.2
182
* This describes the first 32-bit chunk of all payloads.
183
* The previous next payload depends on the actual payload type.
185
* 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
186
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
187
* ! Next Payload ! RESERVED ! Payload Length !
188
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
190
struct isakmp_generic
193
u_int8_t isag_reserved;
194
u_int16_t isag_length;
197
extern struct_desc isakmp_generic_desc;
199
/* ISAKMP Data Attribute (generic representation within payloads)
200
* layout from RFC 2408 "ISAKMP" section 3.3
201
* This is not a payload type.
202
* In TLV format, this is followed by a value field.
204
* 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
205
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
206
* !A! Attribute Type ! AF=0 Attribute Length !
207
* !F! ! AF=1 Attribute Value !
208
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
209
* . AF=0 Attribute Value .
210
* . AF=1 Not Transmitted .
211
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
213
struct isakmp_attribute
215
/* The high order bit of isaat_af_type is the Attribute Format
216
* If it is off, the format is TLV: lv is the length of the following
218
* If it is on, the format is TV: lv is the value of the attribute.
219
* ISAKMP_ATTR_AF_MASK is the mask in host form.
221
* The low order 15 bits of isaat_af_type is the Attribute Type.
222
* ISAKMP_ATTR_RTYPE_MASK is the mask in host form.
224
u_int16_t isaat_af_type; /* high order bit: AF; lower 15: rtype */
225
u_int16_t isaat_lv; /* Length or value */
228
#define ISAKMP_ATTR_AF_MASK 0x8000
229
#define ISAKMP_ATTR_AF_TV ISAKMP_ATTR_AF_MASK /* value in lv */
230
#define ISAKMP_ATTR_AF_TLV 0 /* length in lv; value follows */
232
#define ISAKMP_ATTR_RTYPE_MASK 0x7FFF
235
isakmp_oakley_attribute_desc,
236
isakmp_ipsec_attribute_desc;
238
/* ISAKMP Security Association Payload
239
* layout from RFC 2408 "ISAKMP" section 3.4
240
* A variable length Situation follows.
241
* Previous next payload: ISAKMP_NEXT_SA
243
* 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
244
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
245
* ! Next Payload ! RESERVED ! Payload Length !
246
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
247
* ! Domain of Interpretation (DOI) !
248
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
252
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
256
u_int8_t isasa_np; /* Next payload */
257
u_int8_t isasa_reserved;
258
u_int16_t isasa_length; /* Payload length */
259
u_int32_t isasa_doi; /* DOI */
262
extern struct_desc isakmp_sa_desc;
264
extern struct_desc ipsec_sit_desc;
266
/* ISAKMP Proposal Payload
267
* layout from RFC 2408 "ISAKMP" section 3.5
268
* A variable length SPI follows.
269
* Previous next payload: ISAKMP_NEXT_P
271
* 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
272
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
273
* ! Next Payload ! RESERVED ! Payload Length !
274
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
275
* ! Proposal # ! Protocol-Id ! SPI Size !# of Transforms!
276
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
278
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
280
struct isakmp_proposal
283
u_int8_t isap_reserved;
284
u_int16_t isap_length;
285
u_int8_t isap_proposal;
286
u_int8_t isap_protoid;
287
u_int8_t isap_spisize;
288
u_int8_t isap_notrans; /* Number of transforms */
291
extern struct_desc isakmp_proposal_desc;
293
/* ISAKMP Transform Payload
294
* layout from RFC 2408 "ISAKMP" section 3.6
295
* Variable length SA Attributes follow.
296
* Previous next payload: ISAKMP_NEXT_T
298
* 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
299
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
300
* ! Next Payload ! RESERVED ! Payload Length !
301
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
302
* ! Transform # ! Transform-Id ! RESERVED2 !
303
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
307
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
309
struct isakmp_transform
312
u_int8_t isat_reserved;
313
u_int16_t isat_length;
314
u_int8_t isat_transnum; /* Number of the transform */
315
u_int8_t isat_transid;
316
u_int16_t isat_reserved2;
320
isakmp_isakmp_transform_desc,
321
isakmp_ah_transform_desc,
322
isakmp_esp_transform_desc,
323
isakmp_ipcomp_transform_desc;
325
/* ISAKMP Key Exchange Payload: no fixed fields beyond the generic ones.
326
* layout from RFC 2408 "ISAKMP" section 3.7
327
* Variable Key Exchange Data follow the generic fields.
328
* Previous next payload: ISAKMP_NEXT_KE
330
* 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
331
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
332
* ! Next Payload ! RESERVED ! Payload Length !
333
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
335
* ~ Key Exchange Data ~
337
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
339
extern struct_desc isakmp_keyex_desc;
341
/* ISAKMP Identification Payload
342
* layout from RFC 2408 "ISAKMP" section 3.8
343
* See "struct identity" declared later.
344
* Variable length Identification Data follow.
345
* Previous next payload: ISAKMP_NEXT_ID
347
* 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
348
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
349
* ! Next Payload ! RESERVED ! Payload Length !
350
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
351
* ! ID Type ! DOI Specific ID Data !
352
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
354
* ~ Identification Data ~
356
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
361
u_int8_t isaid_reserved;
362
u_int16_t isaid_length;
363
u_int8_t isaid_idtype;
364
u_int8_t isaid_doi_specific_a;
365
u_int16_t isaid_doi_specific_b;
368
extern struct_desc isakmp_identification_desc;
370
/* IPSEC Identification Payload Content
371
* layout from RFC 2407 "IPsec DOI" section 4.6.2
372
* See struct isakmp_id declared earlier.
373
* Note: Hashing skips the ISAKMP generic payload header
374
* Variable length Identification Data follow.
376
* 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
377
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
378
* ! Next Payload ! RESERVED ! Payload Length !
379
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
380
* ! ID Type ! Protocol ID ! Port !
381
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
382
* ~ Identification Data ~
383
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
385
struct isakmp_ipsec_id
388
u_int8_t isaiid_reserved;
389
u_int16_t isaiid_length;
390
u_int8_t isaiid_idtype;
391
u_int8_t isaiid_protoid;
392
u_int16_t isaiid_port;
395
extern struct_desc isakmp_ipsec_identification_desc;
397
/* ISAKMP Certificate Payload: no fixed fields beyond the generic ones.
398
* layout from RFC 2408 "ISAKMP" section 3.9
399
* Variable length Certificate Data follow the generic fields.
400
* Previous next payload: ISAKMP_NEXT_CERT.
402
* 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
403
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
404
* ! Next Payload ! RESERVED ! Payload Length !
405
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
406
* ! Cert Encoding ! !
407
* +-+-+-+-+-+-+-+-+ !
408
* ~ Certificate Data ~
410
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
415
u_int8_t isacert_reserved;
416
u_int16_t isacert_length;
417
u_int8_t isacert_type;
420
/* NOTE: this packet type has a fixed portion that is not a
421
* multiple of 4 octets. This means that sizeof(struct isakmp_cert)
422
* yields the wrong value for the length.
424
#define ISAKMP_CERT_SIZE 5
426
extern struct_desc isakmp_ipsec_certificate_desc;
428
/* ISAKMP Certificate Request Payload: no fixed fields beyond the generic ones.
429
* layout from RFC 2408 "ISAKMP" section 3.10
430
* Variable length Certificate Types and Certificate Authorities follow.
431
* Previous next payload: ISAKMP_NEXT_CR.
433
* 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
434
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
435
* ! Next Payload ! RESERVED ! Payload Length !
436
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
438
* +-+-+-+-+-+-+-+-+ !
439
* ~ Certificate Authority ~
441
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
446
u_int8_t isacr_reserved;
447
u_int16_t isacr_length;
451
/* NOTE: this packet type has a fixed portion that is not a
452
* multiple of 4 octets. This means that sizeof(struct isakmp_cr)
453
* yields the wrong value for the length.
455
#define ISAKMP_CR_SIZE 5
457
extern struct_desc isakmp_ipsec_cert_req_desc;
459
/* ISAKMP Hash Payload: no fixed fields beyond the generic ones.
460
* layout from RFC 2408 "ISAKMP" section 3.11
461
* Variable length Hash Data follow.
462
* Previous next payload: ISAKMP_NEXT_HASH.
464
* 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
465
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
466
* ! Next Payload ! RESERVED ! Payload Length !
467
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
471
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
473
extern struct_desc isakmp_hash_desc;
475
/* ISAKMP Signature Payload: no fixed fields beyond the generic ones.
476
* layout from RFC 2408 "ISAKMP" section 3.12
477
* Variable length Signature Data follow.
478
* Previous next payload: ISAKMP_NEXT_SIG.
480
* 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
481
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
482
* ! Next Payload ! RESERVED ! Payload Length !
483
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
487
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
489
extern struct_desc isakmp_signature_desc;
491
/* ISAKMP Nonce Payload: no fixed fields beyond the generic ones.
492
* layout from RFC 2408 "ISAKMP" section 3.13
493
* Variable length Nonce Data follow.
494
* Previous next payload: ISAKMP_NEXT_NONCE.
496
* 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
497
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
498
* ! Next Payload ! RESERVED ! Payload Length !
499
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
503
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
505
extern struct_desc isakmp_nonce_desc;
507
/* ISAKMP Notification Payload
508
* layout from RFC 2408 "ISAKMP" section 3.14
509
* This is followed by a variable length SPI
510
* and then possibly by variable length Notification Data.
511
* Previous next payload: ISAKMP_NEXT_N
513
* 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
514
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
515
* ! Next Payload ! RESERVED ! Payload Length !
516
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
517
* ! Domain of Interpretation (DOI) !
518
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
519
* ! Protocol-ID ! SPI Size ! Notify Message Type !
520
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
522
* ~ Security Parameter Index (SPI) ~
524
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
526
* ~ Notification Data ~
528
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
531
extern struct_desc isakmp_attr_desc;
533
/* From draft-dukes-ike-mode-cfg
534
3.2. Attribute Payload
536
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
537
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
538
! Next Payload ! RESERVED ! Payload Length !
539
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
540
! Type ! RESERVED ! Identifier !
541
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
546
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
548
struct isakmp_mode_attr
551
u_int8_t isama_reserved;
552
u_int16_t isama_length;
554
u_int8_t isama_reserved2;
555
u_int16_t isama_identifier;
558
extern struct_desc isakmp_attr_desc;
559
extern struct_desc isakmp_xauth_attribute_desc;
562
/* ISAKMP Notification Payload
563
* layout from RFC 2408 "ISAKMP" section 3.14
564
* This is followed by a variable length SPI
565
* and then possibly by variable length Notification Data.
566
* Previous next payload: ISAKMP_NEXT_N
568
* 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
569
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
570
* ! Next Payload ! RESERVED ! Payload Length !
571
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
572
* ! Domain of Interpretation (DOI) !
573
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
574
* ! Protocol-ID ! SPI Size ! Notify Message Type !
575
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
577
* ~ Security Parameter Index (SPI) ~
579
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
581
* ~ Notification Data ~
583
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
585
struct isakmp_notification
588
u_int8_t isan_reserved;
589
u_int16_t isan_length;
591
u_int8_t isan_protoid;
592
u_int8_t isan_spisize;
596
extern struct_desc isakmp_notification_desc;
598
/* ISAKMP Delete Payload
599
* layout from RFC 2408 "ISAKMP" section 3.15
600
* This is followed by a variable length SPI.
601
* Previous next payload: ISAKMP_NEXT_D
603
* 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
604
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
605
* ! Next Payload ! RESERVED ! Payload Length !
606
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
607
* ! Domain of Interpretation (DOI) !
608
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
609
* ! Protocol-Id ! SPI Size ! # of SPIs !
610
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
612
* ~ Security Parameter Index(es) (SPI) ~
614
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
619
u_int8_t isad_reserved;
620
u_int16_t isad_length;
622
u_int8_t isad_protoid;
623
u_int8_t isad_spisize;
624
u_int16_t isad_nospi;
627
extern struct_desc isakmp_delete_desc;
629
/* ISAKMP Vendor ID Payload
630
* layout from RFC 2408 "ISAKMP" section 3.15
631
* This is followed by a variable length VID.
632
* Previous next payload: ISAKMP_NEXT_VID
634
* 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
635
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
636
* ! Next Payload ! RESERVED ! Payload Length !
637
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
639
* ~ Vendor ID (VID) ~
641
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
643
extern struct_desc isakmp_vendor_id_desc;
648
u_int8_t isanoa_reserved_1;
649
u_int16_t isanoa_length;
650
u_int8_t isanoa_idtype;
651
u_int8_t isanoa_reserved_2;
652
u_int16_t isanoa_reserved_3;
655
extern struct_desc isakmp_nat_d;
656
extern struct_desc isakmp_nat_oa;
658
/* union of all payloads */
661
struct isakmp_generic generic;
663
struct isakmp_proposal proposal;
664
struct isakmp_transform transform;
665
struct isakmp_id id; /* Main Mode */
666
struct isakmp_cert cert;
668
struct isakmp_ipsec_id ipsec_id; /* Quick Mode */
669
struct isakmp_notification notification;
670
struct isakmp_delete delete;
671
struct isakmp_nat_oa nat_oa;
672
struct isakmp_mode_attr attribute;
675
/* descriptor for each payload type
677
* There is a slight problem in that some payloads differ, depending
678
* on the mode. Since this is table only used for top-level payloads,
679
* Proposal and Transform payloads need not be handled.
680
* That leaves only Identification payloads as a problem.
681
* We make all these entries NULL
683
extern struct_desc *const payload_descs[ISAKMP_NEXT_ROOF];
685
#endif /* _PACKET_H */