~ubuntu-branches/ubuntu/hardy/openswan/hardy-updates

« back to all changes in this revision

Viewing changes to programs/pluto/packet.h

  • Committer: Bazaar Package Importer
  • Author(s): Rene Mayrhofer
  • Date: 2005-01-27 16:10:11 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050127161011-idgybmyz3vwhpfiq
Tags: 2.3.0-2
Urgency HIGH due to security issue and problems with build-deps in sarge.
* Fix the security issue. Please see
  http://www.idefense.com/application/poi/display?id=190&
      type=vulnerabilities&flashstatus=false
  for more details. Thanks to Martin Schulze for informing me about
  this issue.
  Closes: #292458: Openswan XAUTH/PAM Buffer Overflow Vulnerability
* Added a Build-Dependency to lynx.
  Closes: #291143: openswan: FTBFS: Missing build dependency.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* parsing packets: formats and tools
2
 
 * Copyright (C) 1997 Angelos D. Keromytis.
3
 
 * Copyright (C) 1998-2001  D. Hugh Redelmeier.
4
 
 *
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>.
9
 
 *
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
13
 
 * for more details.
14
 
 *
15
 
 * RCSID $Id: packet.h,v 1.27 2004/01/09 04:40:20 mcr Exp $
16
 
 */
17
 
 
18
 
#ifndef _PACKET_H
19
 
#define _PACKET_H
20
 
 
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.
23
 
 */
24
 
 
25
 
typedef const struct struct_desc {
26
 
    const char *name;
27
 
    const struct field_desc *fields;
28
 
    size_t size;
29
 
} struct_desc;
30
 
 
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
35
 
 */
36
 
 
37
 
enum field_type {
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 */
49
 
};
50
 
 
51
 
typedef const struct field_desc {
52
 
    enum field_type field_type;
53
 
    int size;   /* size, in bytes, of field */
54
 
    const char *name;
55
 
    const void *desc;   /* enum_names for enum or char *[] for bits */
56
 
} field_desc;
57
 
 
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.
63
 
 */
64
 
typedef struct packet_byte_stream {
65
 
    struct packet_byte_stream *container;   /* PBS of which we are part */
66
 
    struct_desc *desc;
67
 
    const char *name;   /* what does this PBS represent? */
68
 
    u_int8_t
69
 
        *start,
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.
74
 
     */
75
 
    u_int8_t *lenfld;
76
 
    field_desc *lenfld_desc;
77
 
} pb_stream;
78
 
 
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.
83
 
 */
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))
87
 
 
88
 
extern void init_pbs(pb_stream *pbs, u_int8_t *start, size_t len, const char *name);
89
 
 
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);
93
 
 
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);
100
 
#if 1
101
 
extern bool out_modify_previous_np(u_int8_t np, pb_stream *outs);
102
 
#endif
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);
109
 
 
110
 
#ifdef DEBUG
111
 
extern void DBG_print_struct(const char *label, const void *struct_ptr,
112
 
    struct_desc *sd, bool len_meaningful);
113
 
#endif
114
 
 
115
 
/* ISAKMP Header: for all messages
116
 
 * layout from RFC 2408 "ISAKMP" section 3.1
117
 
 *                      1                   2                   3
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
 
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
120
 
 * !                          Initiator                            !
121
 
 * !                            Cookie                             !
122
 
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
123
 
 * !                          Responder                            !
124
 
 * !                            Cookie                             !
125
 
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
126
 
 * !  Next Payload ! MjVer ! MnVer ! Exchange Type !     Flags     !
127
 
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
128
 
 * !                          Message ID                           !
129
 
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
130
 
 * !                            Length                             !
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.
135
 
 *
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.
139
 
 *
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.
146
 
 *
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.
155
 
 *
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).
162
 
 */
163
 
 
164
 
struct isakmp_hdr
165
 
{
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 */
173
 
    u_int8_t    isa_flags;
174
 
    u_int32_t   isa_msgid;              /* Message ID (RAW) */
175
 
    u_int32_t   isa_length;             /* Length of message */
176
 
};
177
 
 
178
 
extern struct_desc isakmp_hdr_desc;
179
 
 
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.
184
 
 *                      1                   2                   3
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
 
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
189
 
 */
190
 
struct isakmp_generic
191
 
{
192
 
    u_int8_t    isag_np;
193
 
    u_int8_t    isag_reserved;
194
 
    u_int16_t   isag_length;
195
 
};
196
 
 
197
 
extern struct_desc isakmp_generic_desc;
198
 
 
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.
203
 
 *                      1                   2                   3
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
 
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
212
 
 */
213
 
struct isakmp_attribute
214
 
{
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
217
 
     * attribute value.
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.
220
 
     *
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.
223
 
     */
224
 
    u_int16_t isaat_af_type;   /* high order bit: AF; lower 15: rtype */
225
 
    u_int16_t isaat_lv;                 /* Length or value */
226
 
};
227
 
 
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 */
231
 
 
232
 
#define ISAKMP_ATTR_RTYPE_MASK 0x7FFF
233
 
 
234
 
extern struct_desc
235
 
    isakmp_oakley_attribute_desc,
236
 
    isakmp_ipsec_attribute_desc;
237
 
 
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
242
 
 *                      1                   2                   3
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
 
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
249
 
 * !                                                               !
250
 
 * ~                           Situation                           ~
251
 
 * !                                                               !
252
 
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
253
 
 */
254
 
struct isakmp_sa
255
 
{
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 */
260
 
};
261
 
 
262
 
extern struct_desc isakmp_sa_desc;
263
 
 
264
 
extern struct_desc ipsec_sit_desc;
265
 
 
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
270
 
 *                      1                   2                   3
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
 
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
277
 
 * !                        SPI (variable)                         !
278
 
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
279
 
 */
280
 
struct isakmp_proposal
281
 
{
282
 
    u_int8_t    isap_np;
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 */
289
 
};
290
 
 
291
 
extern struct_desc isakmp_proposal_desc;
292
 
 
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
297
 
 *                      1                   2                   3
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
 
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
304
 
 * !                                                               !
305
 
 * ~                        SA Attributes                          ~
306
 
 * !                                                               !
307
 
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
308
 
 */
309
 
struct isakmp_transform
310
 
{
311
 
    u_int8_t    isat_np;
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;
317
 
};
318
 
 
319
 
extern struct_desc
320
 
    isakmp_isakmp_transform_desc,
321
 
    isakmp_ah_transform_desc,
322
 
    isakmp_esp_transform_desc,
323
 
    isakmp_ipcomp_transform_desc;
324
 
 
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
329
 
 *                      1                   2                   3
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
 
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
334
 
 * !                                                               !
335
 
 * ~                       Key Exchange Data                       ~
336
 
 * !                                                               !
337
 
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
338
 
 */
339
 
extern struct_desc isakmp_keyex_desc;
340
 
 
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
346
 
 *                      1                   2                   3
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
 
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
353
 
 * !                                                               !
354
 
 * ~                   Identification Data                         ~
355
 
 * !                                                               !
356
 
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
357
 
 */
358
 
struct isakmp_id
359
 
{
360
 
    u_int8_t    isaid_np;
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;
366
 
};
367
 
 
368
 
extern struct_desc isakmp_identification_desc;
369
 
 
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.
375
 
 *                      1                   2                   3
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
 
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
384
 
 */
385
 
struct isakmp_ipsec_id
386
 
{
387
 
    u_int8_t    isaiid_np;
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;
393
 
};
394
 
 
395
 
extern struct_desc isakmp_ipsec_identification_desc;
396
 
 
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.
401
 
 *                      1                   2                   3
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                        ~
409
 
 * !                                                               !
410
 
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
411
 
 */
412
 
struct isakmp_cert
413
 
{
414
 
    u_int8_t    isacert_np;
415
 
    u_int8_t    isacert_reserved;
416
 
    u_int16_t   isacert_length;
417
 
    u_int8_t    isacert_type;
418
 
};
419
 
 
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.
423
 
 */
424
 
#define ISAKMP_CERT_SIZE                5
425
 
 
426
 
extern struct_desc isakmp_ipsec_certificate_desc;
427
 
 
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.
432
 
 *                      1                   2                   3
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
 
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
437
 
 * !  Cert. Type   !                                               !
438
 
 * +-+-+-+-+-+-+-+-+                                               !
439
 
 * ~                    Certificate Authority                      ~
440
 
 * !                                                               !
441
 
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
442
 
 */
443
 
struct isakmp_cr
444
 
{
445
 
    u_int8_t    isacr_np;
446
 
    u_int8_t    isacr_reserved;
447
 
    u_int16_t   isacr_length;
448
 
    u_int8_t    isacr_type;
449
 
};
450
 
 
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.
454
 
 */
455
 
#define ISAKMP_CR_SIZE          5
456
 
 
457
 
extern struct_desc isakmp_ipsec_cert_req_desc;
458
 
 
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.
463
 
 *                      1                   2                   3
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
 
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
468
 
 * !                                                               !
469
 
 * ~                           Hash Data                           ~
470
 
 * !                                                               !
471
 
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
472
 
 */
473
 
extern struct_desc isakmp_hash_desc;
474
 
 
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.
479
 
 *                      1                   2                   3
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
 
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
484
 
 * !                                                               !
485
 
 * ~                         Signature Data                        ~
486
 
 * !                                                               !
487
 
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
488
 
 */
489
 
extern struct_desc isakmp_signature_desc;
490
 
 
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.
495
 
 *                      1                   2                   3
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
 
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
500
 
 * !                                                               !
501
 
 * ~                            Nonce Data                         ~
502
 
 * !                                                               !
503
 
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
504
 
 */
505
 
extern struct_desc isakmp_nonce_desc;
506
 
 
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
512
 
 *                      1                   2                   3
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
 
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
521
 
 * !                                                               !
522
 
 * ~                Security Parameter Index (SPI)                 ~
523
 
 * !                                                               !
524
 
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
525
 
 * !                                                               !
526
 
 * ~                       Notification Data                       ~
527
 
 * !                                                               !
528
 
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
529
 
 */
530
 
 
531
 
extern struct_desc isakmp_attr_desc;
532
 
 
533
 
/* From draft-dukes-ike-mode-cfg
534
 
3.2. Attribute Payload
535
 
                           1                   2                   3  
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
 
     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
542
 
     !                                                               !
543
 
     !                                                               !
544
 
     ~                           Attributes                          ~
545
 
     !                                                               !
546
 
     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
547
 
*/
548
 
struct isakmp_mode_attr
549
 
{
550
 
    u_int8_t    isama_np;
551
 
    u_int8_t    isama_reserved;
552
 
    u_int16_t   isama_length;
553
 
    u_int8_t    isama_type;
554
 
    u_int8_t    isama_reserved2;
555
 
    u_int16_t   isama_identifier;
556
 
};
557
 
 
558
 
extern struct_desc isakmp_attr_desc;
559
 
extern struct_desc isakmp_xauth_attribute_desc;
560
 
 
561
 
 
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
567
 
 *                      1                   2                   3
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
 
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
576
 
 * !                                                               !
577
 
 * ~                Security Parameter Index (SPI)                 ~
578
 
 * !                                                               !
579
 
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
580
 
 * !                                                               !
581
 
 * ~                       Notification Data                       ~
582
 
 * !                                                               !
583
 
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
584
 
 */
585
 
struct isakmp_notification
586
 
{
587
 
    u_int8_t    isan_np;
588
 
    u_int8_t    isan_reserved;
589
 
    u_int16_t   isan_length;
590
 
    u_int32_t   isan_doi;
591
 
    u_int8_t    isan_protoid;
592
 
    u_int8_t    isan_spisize;
593
 
    u_int16_t   isan_type;
594
 
};
595
 
 
596
 
extern struct_desc isakmp_notification_desc;
597
 
 
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
602
 
 *                      1                   2                   3
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
 
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
611
 
 * !                                                               !
612
 
 * ~               Security Parameter Index(es) (SPI)              ~
613
 
 * !                                                               !
614
 
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
615
 
 */
616
 
struct isakmp_delete
617
 
{
618
 
    u_int8_t    isad_np;
619
 
    u_int8_t    isad_reserved;
620
 
    u_int16_t   isad_length;
621
 
    u_int32_t   isad_doi;
622
 
    u_int8_t    isad_protoid;
623
 
    u_int8_t    isad_spisize;
624
 
    u_int16_t   isad_nospi;
625
 
};
626
 
 
627
 
extern struct_desc isakmp_delete_desc;
628
 
 
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
633
 
 *                      1                   2                   3
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
 
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
638
 
 * !                                                               !
639
 
 * ~                        Vendor ID (VID)                        ~
640
 
 * !                                                               !
641
 
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
642
 
 */
643
 
extern struct_desc isakmp_vendor_id_desc;
644
 
 
645
 
struct isakmp_nat_oa
646
 
{
647
 
    u_int8_t    isanoa_np;
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;
653
 
};
654
 
 
655
 
extern struct_desc isakmp_nat_d;
656
 
extern struct_desc isakmp_nat_oa;
657
 
 
658
 
/* union of all payloads */
659
 
 
660
 
union payload {
661
 
    struct isakmp_generic generic;
662
 
    struct isakmp_sa sa;
663
 
    struct isakmp_proposal proposal;
664
 
    struct isakmp_transform transform;
665
 
    struct isakmp_id id;    /* Main Mode */
666
 
    struct isakmp_cert cert;
667
 
    struct isakmp_cr cr;
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;
673
 
};
674
 
 
675
 
/* descriptor for each payload type
676
 
 *
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
682
 
 */
683
 
extern struct_desc *const payload_descs[ISAKMP_NEXT_ROOF];
684
 
 
685
 
#endif /* _PACKET_H */
686