"uint" is defined on all platforms; use "guint" instead.
[obnox/wireshark/wip.git] / packet-isakmp.c
1 /* packet-isakmp.c
2  * Routines for the Internet Security Association and Key Management Protocol
3  * (ISAKMP) (RFC 2408) and the Internet IP Security Domain of Interpretation
4  * for ISAKMP (RFC 2407)
5  * Brad Robel-Forrest <brad.robel-forrest@watchguard.com>
6  *
7  * $Id: packet-isakmp.c,v 1.55 2002/05/20 01:29:07 guy Exp $
8  *
9  * Ethereal - Network traffic analyzer
10  * By Gerald Combs <gerald@ethereal.com>
11  * Copyright 1998 Gerald Combs
12  * 
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  * 
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU General Public License for more details.
22  * 
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software
25  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
26  */
27
28 #ifdef HAVE_CONFIG_H
29 # include "config.h"
30 #endif
31
32 #ifdef HAVE_SYS_TYPES_H
33 # include <sys/types.h>
34 #endif
35
36 #include <stdio.h>
37 #include <string.h>
38
39 #ifdef HAVE_NETINET_IN_H
40 #include <netinet/in.h>
41 #endif
42
43 #include <glib.h>
44
45 #ifdef NEED_SNPRINTF_H
46 # include "snprintf.h"
47 #endif
48
49 #include <epan/packet.h>
50 #include "ipproto.h"
51
52 static int proto_isakmp = -1;
53
54 static gint ett_isakmp = -1;
55 static gint ett_isakmp_flags = -1;
56 static gint ett_isakmp_payload = -1;
57
58 #define UDP_PORT_ISAKMP 500
59 #define TCP_PORT_ISAKMP 500
60
61 #define NUM_PROTO_TYPES 5
62 #define proto2str(t)    \
63   ((t < NUM_PROTO_TYPES) ? prototypestr[t] : "UNKNOWN-PROTO-TYPE")
64
65 static const char *prototypestr[NUM_PROTO_TYPES] = {
66   "RESERVED",
67   "ISAKMP",
68   "IPSEC_AH",
69   "IPSEC_ESP",
70   "IPCOMP"
71 };
72
73 #define NUM_P1_ATT_TYPES        17
74 #define p1_atttype2str(t)       \
75   ((t < NUM_P1_ATT_TYPES) ? p1_atttypestr[t] : "UNKNOWN-ATTRIBUTE-TYPE")
76
77 static const char *p1_atttypestr[NUM_P1_ATT_TYPES] = {
78   "UNKNOWN-ATTRIBUTE-TYPE",
79   "Encryption-Algorithm",
80   "Hash-Algorithm",
81   "Authentication-Method",
82   "Group-Description",
83   "Group-Type",
84   "Group-Prime",
85   "Group-Generator-One",
86   "Group-Generator-Two",
87   "Group-Curve-A",
88   "Group-Curve-B",
89   "Life-Type",
90   "Life-Duration",
91   "PRF",
92   "Key-Length",
93   "Field-Size",
94   "Group-Order"
95 };
96
97 #define NUM_ATT_TYPES   11
98 #define atttype2str(t)  \
99   ((t < NUM_ATT_TYPES) ? atttypestr[t] : "UNKNOWN-ATTRIBUTE-TYPE")
100
101 static const char *atttypestr[NUM_ATT_TYPES] = {
102   "UNKNOWN-ATTRIBUTE-TYPE",
103   "SA-Life-Type",
104   "SA-Life-Duration",
105   "Group-Description",
106   "Encapsulation-Mode",
107   "Authentication-Algorithm",
108   "Key-Length",
109   "Key-Rounds",
110   "Compress-Dictinary-Size",
111   "Compress-Private-Algorithm",
112   "ECN Tunnel"
113 };
114
115 #define NUM_TRANS_TYPES 2
116 #define trans2str(t)    \
117   ((t < NUM_TRANS_TYPES) ? transtypestr[t] : "UNKNOWN-TRANS-TYPE")
118
119 static const char *transtypestr[NUM_TRANS_TYPES] = {
120   "RESERVED",
121   "KEY_IKE"
122 };
123
124 #define NUM_AH_TRANS_TYPES      8
125 #define ah_trans2str(t)         \
126   ((t < NUM_AH_TRANS_TYPES) ? ah_transtypestr[t] : "UNKNOWN-AH-TRANS-TYPE")
127
128 static const char *ah_transtypestr[NUM_AH_TRANS_TYPES] = {
129   "RESERVED",
130   "RESERVED",
131   "MD5",
132   "SHA",
133   "DES",
134   "SHA2-256",
135   "SHA2-384",
136   "SHA2-512"
137 };
138
139 #define NUM_ESP_TRANS_TYPES     13
140 #define esp_trans2str(t)        \
141   ((t < NUM_ESP_TRANS_TYPES) ? esp_transtypestr[t] : "UNKNOWN-ESP-TRANS-TYPE")
142
143 static const char *esp_transtypestr[NUM_ESP_TRANS_TYPES] = {
144   "RESERVED",
145   "DES-IV64",
146   "DES",
147   "3DES",
148   "RC5",
149   "IDEA",
150   "CAST",
151   "BLOWFISH",
152   "3IDEA",
153   "DES-IV32",
154   "RC4",
155   "NULL",
156   "AES"
157 };
158
159 #define NUM_IPCOMP_TRANS_TYPES    5
160 #define ipcomp_trans2str(t)  \
161   ((t < NUM_IPCOMP_TRANS_TYPES) ? ipcomp_transtypestr[t] : "UNKNOWN-IPCOMP-TRANS-TYPE")
162
163 static const char *ipcomp_transtypestr[NUM_IPCOMP_TRANS_TYPES] = {
164   "RESERVED",
165   "OUI",
166   "DEFLATE",
167   "LZS",
168   "LZJH"
169 };
170
171 #define NUM_ID_TYPES    12
172 #define id2str(t)       \
173   ((t < NUM_ID_TYPES) ? idtypestr[t] : "UNKNOWN-ID-TYPE")
174
175 static const char *idtypestr[NUM_ID_TYPES] = {
176   "RESERVED",
177   "IPV4_ADDR",
178   "FQDN",
179   "USER_FQDN",
180   "IPV4_ADDR_SUBNET",
181   "IPV6_ADDR",
182   "IPV6_ADDR_SUBNET",
183   "IPV4_ADDR_RANGE",
184   "IPV6_ADDR_RANGE",
185   "DER_ASN1_DN",
186   "DER_ASN1_GN",
187   "KEY_ID"
188 };
189
190 struct isakmp_hdr {
191   guint8        icookie[8];
192   guint8        rcookie[8];
193   guint8        next_payload;
194   guint8        version;
195   guint8        exch_type;
196   guint8        flags;
197 #define E_FLAG          0x01
198 #define C_FLAG          0x02
199 #define A_FLAG          0x04
200   guint8        message_id[4];
201   guint8        length[4];
202 };
203
204 struct udp_encap_hdr {
205   guint8        non_esp_marker[4];
206   guint32       esp_SPI;
207 };
208
209 static proto_tree *dissect_payload_header(tvbuff_t *, int, int, guint8,
210     guint8 *, guint16 *, proto_tree *);
211
212 static void dissect_sa(tvbuff_t *, int, int, proto_tree *, int);
213 static void dissect_proposal(tvbuff_t *, int, int, proto_tree *, int);
214 static void dissect_transform(tvbuff_t *, int, int, proto_tree *, int);
215 static void dissect_key_exch(tvbuff_t *, int, int, proto_tree *, int);
216 static void dissect_id(tvbuff_t *, int, int, proto_tree *, int);
217 static void dissect_cert(tvbuff_t *, int, int, proto_tree *, int);
218 static void dissect_certreq(tvbuff_t *, int, int, proto_tree *, int);
219 static void dissect_hash(tvbuff_t *, int, int, proto_tree *, int);
220 static void dissect_sig(tvbuff_t *, int, int, proto_tree *, int);
221 static void dissect_nonce(tvbuff_t *, int, int, proto_tree *, int);
222 static void dissect_notif(tvbuff_t *, int, int, proto_tree *, int);
223 static void dissect_delete(tvbuff_t *, int, int, proto_tree *, int);
224 static void dissect_vid(tvbuff_t *, int, int, proto_tree *, int);
225 static void dissect_config(tvbuff_t *, int, int, proto_tree *, int);
226
227 static const char *payloadtype2str(guint8);
228 static const char *exchtype2str(guint8);
229 static const char *doitype2str(guint32);
230 static const char *msgtype2str(guint16);
231 static const char *situation2str(guint32);
232 static const char *value2str(int, guint16, guint16);
233 static const char *attrtype2str(guint8);
234 static const char *cfgattrident2str(guint16);
235 static const char *certtype2str(guint8);
236
237 static gboolean get_num(tvbuff_t *, int, guint16, guint32 *);
238
239 #define LOAD_TYPE_NONE          0       /* payload type for None */
240 #define LOAD_TYPE_PROPOSAL      2       /* payload type for Proposal */
241 #define LOAD_TYPE_TRANSFORM     3       /* payload type for Transform */
242 #define NUM_LOAD_TYPES          15
243 #define loadtype2str(t) \
244   ((t < NUM_LOAD_TYPES) ? strfuncs[t].str : "Unknown payload type")
245
246 static struct strfunc {
247   const char *  str;
248   void          (*func)(tvbuff_t *, int, int, proto_tree *, int);
249 } strfuncs[NUM_LOAD_TYPES] = {
250   {"NONE",                      NULL              },
251   {"Security Association",      dissect_sa        },
252   {"Proposal",                  dissect_proposal  },
253   {"Transform",                 dissect_transform },
254   {"Key Exchange",              dissect_key_exch  },
255   {"Identification",            dissect_id        },
256   {"Certificate",               dissect_cert      },
257   {"Certificate Request",       dissect_certreq   },
258   {"Hash",                      dissect_hash      },
259   {"Signature",                 dissect_sig       },
260   {"Nonce",                     dissect_nonce     },
261   {"Notification",              dissect_notif     },
262   {"Delete",                    dissect_delete    },
263   {"Vendor ID",                 dissect_vid       },
264   {"Attrib",                    dissect_config    }
265 };
266
267 static dissector_handle_t esp_handle;
268 static dissector_handle_t ah_handle;
269
270 static void
271 dissect_payloads(tvbuff_t *tvb, proto_tree *tree, guint8 initial_payload,
272                  int offset, int length)
273 {
274   guint8 payload, next_payload;
275   guint16               payload_length;
276   proto_tree *          ntree;
277
278   for (payload = initial_payload; length != 0; payload = next_payload) {
279     if (payload == LOAD_TYPE_NONE) {
280       /*
281        * What?  There's more stuff in this chunk of data, but the
282        * previous payload had a "next payload" type of None?
283        */
284       proto_tree_add_text(tree, tvb, offset, length,
285                           "Extra data: %s",
286                           tvb_bytes_to_str(tvb, offset, length));
287       break;
288     }
289     ntree = dissect_payload_header(tvb, offset, length, payload,
290       &next_payload, &payload_length, tree);
291     if (ntree == NULL)
292       break;
293     if (payload_length >= 4) {  /* XXX = > 4? */
294       if (payload < NUM_LOAD_TYPES) {
295         (*strfuncs[payload].func)(tvb, offset + 4, payload_length - 4, ntree,
296                                   -1);
297       }
298       else {
299         proto_tree_add_text(ntree, tvb, offset + 4, payload_length - 4,
300             "Payload");
301       }
302     }
303     else {
304         proto_tree_add_text(ntree, tvb, offset + 4, 0,
305             "Payload (bogus, length is %u, must be at least 4)",
306             payload_length);
307         payload_length = 4;
308     }
309     offset += payload_length;
310     length -= payload_length;
311   }
312 }
313
314 static void
315 dissect_isakmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
316 {
317   int                   offset = 0;
318   struct isakmp_hdr *   hdr;
319   proto_item *          ti;
320   proto_tree *          isakmp_tree = NULL;
321   struct udp_encap_hdr * encap_hdr;
322   guint32               len;
323   static const guint8   non_esp_marker[4] = { 0, 0, 0, 0 };
324   tvbuff_t *            next_tvb;
325
326   if (check_col(pinfo->cinfo, COL_PROTOCOL))
327     col_set_str(pinfo->cinfo, COL_PROTOCOL, "ISAKMP");
328   if (check_col(pinfo->cinfo, COL_INFO))
329     col_clear(pinfo->cinfo, COL_INFO);
330
331   hdr = (struct isakmp_hdr *)tvb_get_ptr(tvb, 0, sizeof (struct isakmp_hdr));
332   len = pntohl(&hdr->length);
333   
334   if (tree) {
335     ti = proto_tree_add_item(tree, proto_isakmp, tvb, offset, len, FALSE);
336     isakmp_tree = proto_item_add_subtree(ti, ett_isakmp);
337   }
338     
339   encap_hdr = (struct udp_encap_hdr *)tvb_get_ptr(tvb, 0, sizeof(struct udp_encap_hdr));
340   
341   if (encap_hdr->non_esp_marker[0] == 0xFF) {
342     if (check_col(pinfo->cinfo, COL_INFO)) 
343       col_set_str(pinfo->cinfo, COL_INFO, "UDP encapsulated IPSec - NAT Keepalive");
344     return;
345   }
346   if (memcmp(encap_hdr->non_esp_marker,non_esp_marker,4) == 0) {
347     if (check_col(pinfo->cinfo, COL_INFO)) 
348           col_set_str(pinfo->cinfo, COL_INFO, "UDP encapsulated IPSec - ESP");
349     if (tree)
350       proto_tree_add_text(isakmp_tree, tvb, offset,
351                           sizeof(encap_hdr->non_esp_marker),
352                           "Non-ESP-Marker");
353     offset += sizeof(encap_hdr->non_esp_marker);
354     next_tvb = tvb_new_subset(tvb, offset, -1, -1);
355     call_dissector(esp_handle, next_tvb, pinfo, tree);
356     return;
357   }
358
359   if (check_col(pinfo->cinfo, COL_INFO))
360     col_add_str(pinfo->cinfo, COL_INFO, exchtype2str(hdr->exch_type));
361
362   if (tree) {
363     proto_tree_add_text(isakmp_tree, tvb, offset, sizeof(hdr->icookie),
364                         "Initiator cookie");
365     offset += sizeof(hdr->icookie);
366     
367     proto_tree_add_text(isakmp_tree, tvb, offset, sizeof(hdr->rcookie),
368                         "Responder cookie");
369     offset += sizeof(hdr->rcookie);
370
371     proto_tree_add_text(isakmp_tree, tvb, offset, sizeof(hdr->next_payload),
372                         "Next payload: %s (%u)",
373                         payloadtype2str(hdr->next_payload), hdr->next_payload);
374     offset += sizeof(hdr->next_payload);
375
376     proto_tree_add_text(isakmp_tree, tvb, offset, sizeof(hdr->version),
377                         "Version: %u.%u",
378                         hi_nibble(hdr->version), lo_nibble(hdr->version));
379     offset += sizeof(hdr->version);
380     
381     proto_tree_add_text(isakmp_tree, tvb, offset, sizeof(hdr->exch_type),
382                         "Exchange type: %s (%u)",
383                         exchtype2str(hdr->exch_type), hdr->exch_type);
384     offset += sizeof(hdr->exch_type);
385     
386     {
387       proto_item *      fti;
388       proto_tree *      ftree;
389       
390       fti   = proto_tree_add_text(isakmp_tree, tvb, offset, sizeof(hdr->flags), "Flags");
391       ftree = proto_item_add_subtree(fti, ett_isakmp_flags);
392       
393       proto_tree_add_text(ftree, tvb, offset, 1, "%s",
394                           decode_boolean_bitfield(hdr->flags, E_FLAG, sizeof(hdr->flags)*8,
395                                                   "Encryption", "No encryption"));
396       proto_tree_add_text(ftree, tvb, offset, 1, "%s",
397                           decode_boolean_bitfield(hdr->flags, C_FLAG, sizeof(hdr->flags)*8,
398                                                   "Commit", "No commit"));
399       proto_tree_add_text(ftree, tvb, offset, 1, "%s",
400                           decode_boolean_bitfield(hdr->flags, A_FLAG, sizeof(hdr->flags)*8,
401                                                   "Authentication", "No authentication"));
402       offset += sizeof(hdr->flags);
403     }
404
405     proto_tree_add_text(isakmp_tree, tvb, offset, sizeof(hdr->message_id),
406         "Message ID: 0x%02x%02x%02x%02x", hdr->message_id[0],
407         hdr->message_id[1], hdr->message_id[2], hdr->message_id[3]);
408     offset += sizeof(hdr->message_id);
409     
410     proto_tree_add_text(isakmp_tree, tvb, offset, sizeof(hdr->length),
411                         "Length: %u", len);
412     offset += sizeof(hdr->length);
413     len -= sizeof(*hdr);
414
415     if (hdr->flags & E_FLAG) {
416       if (len && isakmp_tree) {
417         proto_tree_add_text(isakmp_tree, tvb, offset, len,
418                         "Encrypted payload (%d byte%s)",
419                         len, plurality(len, "", "s"));
420       }
421     } else
422       dissect_payloads(tvb, isakmp_tree, hdr->next_payload, offset, len);
423   }
424 }
425
426 static proto_tree *
427 dissect_payload_header(tvbuff_t *tvb, int offset, int length, guint8 payload,
428     guint8 *next_payload_p, guint16 *payload_length_p, proto_tree *tree)
429 {
430   guint8                next_payload;
431   guint16               payload_length;
432   proto_item *          ti;
433   proto_tree *          ntree;
434
435   if (length < 4) {
436     proto_tree_add_text(tree, tvb, offset, length,
437           "Not enough room in payload for all transforms");
438     return NULL;
439   }
440   next_payload = tvb_get_guint8(tvb, offset);
441   payload_length = tvb_get_ntohs(tvb, offset + 2);
442
443   ti = proto_tree_add_text(tree, tvb, offset, payload_length,
444             "%s payload", loadtype2str(payload));
445   ntree = proto_item_add_subtree(ti, ett_isakmp_payload);
446
447   proto_tree_add_text(ntree, tvb, offset, 1,
448                       "Next payload: %s (%u)",
449                       payloadtype2str(next_payload), next_payload);
450   proto_tree_add_text(ntree, tvb, offset+2, 2, "Length: %u", payload_length);
451
452   *next_payload_p = next_payload;
453   *payload_length_p = payload_length;
454   return ntree;
455 }
456
457 static void
458 dissect_sa(tvbuff_t *tvb, int offset, int length, proto_tree *tree,
459     int unused _U_)
460 {
461   guint32               doi;
462   guint32               situation;
463
464   if (length < 4) {
465     proto_tree_add_text(tree, tvb, offset, length,
466                         "DOI %s (length is %u, should be >= 4)",
467                         tvb_bytes_to_str(tvb, offset, length), length);
468     return;
469   }
470   doi = tvb_get_ntohl(tvb, offset);
471   proto_tree_add_text(tree, tvb, offset, 4,
472                       "Domain of interpretation: %s (%u)",
473                       doitype2str(doi), doi);
474   offset += 4;
475   length -= 4;
476   
477   if (doi == 1) {
478     /* IPSEC */
479     if (length < 4) {
480       proto_tree_add_text(tree, tvb, offset, length,
481                           "Situation: %s (length is %u, should be >= 4)",
482                           tvb_bytes_to_str(tvb, offset, length), length);
483       return;
484     }
485     situation = tvb_get_ntohl(tvb, offset);
486     proto_tree_add_text(tree, tvb, offset, 4,
487                         "Situation: %s (%u)",
488                         situation2str(situation), situation);
489     offset += 4;
490     length -= 4;
491   
492     dissect_payloads(tvb, tree, LOAD_TYPE_PROPOSAL, offset, length);
493   } else {
494     /* Unknown */
495     proto_tree_add_text(tree, tvb, offset, length,
496                         "Situation: %s",
497                         tvb_bytes_to_str(tvb, offset, length));
498   }
499 }
500
501 static void
502 dissect_proposal(tvbuff_t *tvb, int offset, int length, proto_tree *tree,
503     int unused _U_)
504 {
505   guint8                protocol_id;
506   guint8                spi_size;
507   guint8                num_transforms;
508   guint8                next_payload;
509   guint16               payload_length;
510   proto_tree *          ntree;
511
512   proto_tree_add_text(tree, tvb, offset, 1,
513                       "Proposal number: %u", tvb_get_guint8(tvb, offset));
514   offset += 1;
515   length -= 1;
516   
517   protocol_id = tvb_get_guint8(tvb, offset);
518   proto_tree_add_text(tree, tvb, offset, 1,
519                       "Protocol ID: %s (%u)",
520                       proto2str(protocol_id), protocol_id);
521   offset += 1;
522   length -= 1;
523   
524   spi_size = tvb_get_guint8(tvb, offset);
525   proto_tree_add_text(tree, tvb, offset, 1,
526                       "SPI size: %u", spi_size);
527   offset += 1;
528   length -= 1;
529
530   num_transforms = tvb_get_guint8(tvb, offset);
531   proto_tree_add_text(tree, tvb, offset, 1,
532                       "Number of transforms: %u", num_transforms);
533   offset += 1;
534   length -= 1;
535
536   if (spi_size) {
537     proto_tree_add_text(tree, tvb, offset, spi_size, "SPI: %s",
538                         tvb_bytes_to_str(tvb, offset, spi_size));
539     offset += spi_size;
540     length -= spi_size;
541   }
542
543   while (num_transforms > 0) {
544     ntree = dissect_payload_header(tvb, offset, length, LOAD_TYPE_TRANSFORM,
545       &next_payload, &payload_length, tree);
546     if (ntree == NULL)
547       break;
548     if (length < payload_length) {
549       proto_tree_add_text(tree, tvb, offset + 4, length,
550           "Not enough room in payload for all transforms");
551       break;
552     }
553     if (payload_length >= 4)
554       dissect_transform(tvb, offset + 4, payload_length - 4, ntree, protocol_id);
555     else
556       proto_tree_add_text(ntree, tvb, offset + 4, payload_length - 4, "Payload");
557     offset += payload_length;
558     length -= payload_length;
559     num_transforms--;
560   }
561 }
562
563 static void
564 dissect_transform(tvbuff_t *tvb, int offset, int length, proto_tree *tree,
565     int protocol_id)
566 {
567   guint8                transform_id;
568
569   proto_tree_add_text(tree, tvb, offset, 1,
570                       "Transform number: %u", tvb_get_guint8(tvb, offset));
571   offset += 1;
572   length -= 1;
573
574   transform_id = tvb_get_guint8(tvb, offset);
575   switch (protocol_id) {
576   default:
577     proto_tree_add_text(tree, tvb, offset, 1,
578                         "Transform ID: %u", transform_id);
579     break;
580   case 1:       /* ISAKMP */
581     proto_tree_add_text(tree, tvb, offset, 1,
582                         "Transform ID: %s (%u)",
583                         trans2str(transform_id), transform_id);
584     break;
585   case 2:       /* AH */
586     proto_tree_add_text(tree, tvb, offset, 1,
587                         "Transform ID: %s (%u)",
588                         ah_trans2str(transform_id), transform_id);
589     break;
590   case 3:       /* ESP */
591     proto_tree_add_text(tree, tvb, offset, 1,
592                         "Transform ID: %s (%u)",
593                         esp_trans2str(transform_id), transform_id);
594     break;
595   case 4:       /* IPCOMP */
596     proto_tree_add_text(tree, tvb, offset, 1,
597                         "Transform ID: %s (%u)",
598                         ipcomp_trans2str(transform_id), transform_id);
599     break;
600   }
601   offset += 3;
602   length -= 3;
603   
604   while (length>0) {
605     const char *str;
606     int ike_phase1 = 0;
607     guint16 aft     = tvb_get_ntohs(tvb, offset);
608     guint16 type    = aft & 0x7fff;
609     guint16 len;
610     guint32 val;
611     guint pack_len;
612
613     if (protocol_id == 1 && transform_id == 1) {
614       ike_phase1 = 1;
615       str = p1_atttype2str(type);
616     }
617     else {
618       str = atttype2str(type);
619     }
620
621     if (aft & 0x8000) {
622       val = tvb_get_ntohs(tvb, offset + 2);
623       proto_tree_add_text(tree, tvb, offset, 4,
624                           "%s (%u): %s (%u)",
625                           str, type,
626                           value2str(ike_phase1, type, val), val);
627       offset += 4;
628       length -= 4;
629     }
630     else {
631       len = tvb_get_ntohs(tvb, offset + 2);
632       pack_len = 4 + len;
633       if (!get_num(tvb, offset + 4, len, &val)) {
634         proto_tree_add_text(tree, tvb, offset, pack_len,
635                             "%s (%u): <too big (%u bytes)>",
636                             str, type, len);
637       } else {
638         proto_tree_add_text(tree, tvb, offset, pack_len,
639                             "%s (%u): %s (%u)",
640                             str, type,
641                             value2str(ike_phase1, type, val), val);
642       }
643       offset += pack_len;
644       length -= pack_len;
645     }
646   }
647 }
648
649 static void
650 dissect_key_exch(tvbuff_t *tvb, int offset, int length, proto_tree *tree,
651     int unused _U_)
652 {
653   proto_tree_add_text(tree, tvb, offset, length, "Key Exchange Data");
654 }
655
656 static void
657 dissect_id(tvbuff_t *tvb, int offset, int length, proto_tree *tree,
658     int unused _U_)
659 {
660   guint8                id_type;
661   guint8                protocol_id;
662   guint16               port;
663
664   id_type = tvb_get_guint8(tvb, offset);
665   proto_tree_add_text(tree, tvb, offset, 1,
666                       "ID type: %s (%u)", id2str(id_type), id_type);
667   offset += 1;
668   length -= 1;
669
670   protocol_id = tvb_get_guint8(tvb, offset);
671   if (protocol_id == 0) {
672     proto_tree_add_text(tree, tvb, offset, 1,
673                         "Protocol ID: Unused");
674   } else {
675     proto_tree_add_text(tree, tvb, offset, 1,
676                         "Protocol ID: %s (%u)",
677                         ipprotostr(protocol_id), protocol_id);
678   }
679   offset += 1;
680   length -= 1;
681
682   port = tvb_get_ntohs(tvb, offset);
683   if (port == 0)
684     proto_tree_add_text(tree, tvb, offset, 2, "Port: Unused");
685   else
686     proto_tree_add_text(tree, tvb, offset, 2, "Port: %u", port);
687   offset += 2;
688   length -= 2;
689   
690   switch (id_type) {
691     case 1:
692       proto_tree_add_text(tree, tvb, offset, length,
693                           "Identification data: %s",
694                           ip_to_str(tvb_get_ptr(tvb, offset, 4)));
695       break;
696     case 2:
697     case 3:
698       proto_tree_add_text(tree, tvb, offset, length,
699                           "Identification data: %.*s", length,
700                           tvb_get_ptr(tvb, offset, length));
701       break;
702     case 4:
703       proto_tree_add_text(tree, tvb, offset, length,
704                           "Identification data: %s/%s",
705                           ip_to_str(tvb_get_ptr(tvb, offset, 4)),
706                           ip_to_str(tvb_get_ptr(tvb, offset+4, 4)));
707       break;
708     default:
709       proto_tree_add_text(tree, tvb, offset, length, "Identification Data");
710       break;
711   }
712 }
713
714 static void
715 dissect_cert(tvbuff_t *tvb, int offset, int length, proto_tree *tree,
716     int unused _U_)
717 {
718   guint8                cert_enc;
719
720   cert_enc = tvb_get_guint8(tvb, offset);
721   proto_tree_add_text(tree, tvb, offset, 1,
722                       "Certificate encoding: %u - %s",
723                       cert_enc, certtype2str(cert_enc));
724   offset += 1;
725   length -= 1;
726
727   proto_tree_add_text(tree, tvb, offset, length, "Certificate Data");
728 }
729
730 static void
731 dissect_certreq(tvbuff_t *tvb, int offset, int length, proto_tree *tree,
732     int unused _U_)
733 {
734   guint8                cert_type;
735
736   cert_type = tvb_get_guint8(tvb, offset);
737   proto_tree_add_text(tree, tvb, offset, 1,
738                       "Certificate type: %u - %s",
739                       cert_type, certtype2str(cert_type));
740   offset += 1;
741   length -= 1;
742
743   proto_tree_add_text(tree, tvb, offset, length, "Certificate Authority");
744 }
745
746 static void
747 dissect_hash(tvbuff_t *tvb, int offset, int length, proto_tree *tree,
748     int unused _U_)
749 {
750   proto_tree_add_text(tree, tvb, offset, length, "Hash Data");
751 }
752
753 static void
754 dissect_sig(tvbuff_t *tvb, int offset, int length, proto_tree *tree,
755     int unused _U_)
756 {
757   proto_tree_add_text(tree, tvb, offset, length, "Signature Data");
758 }
759
760 static void
761 dissect_nonce(tvbuff_t *tvb, int offset, int length, proto_tree *tree,
762     int unused _U_)
763 {
764   proto_tree_add_text(tree, tvb, offset, length, "Nonce Data");
765 }
766
767 static void
768 dissect_notif(tvbuff_t *tvb, int offset, int length, proto_tree *tree,
769     int unused _U_)
770 {
771   guint32               doi;
772   guint8                protocol_id;
773   guint8                spi_size;
774   guint16               msgtype;
775
776   doi = tvb_get_ntohl(tvb, offset);
777   proto_tree_add_text(tree, tvb, offset, 4,
778                       "Domain of Interpretation: %s (%u)",
779                       doitype2str(doi), doi);
780   offset += 4;
781   length -= 4;
782
783   protocol_id = tvb_get_guint8(tvb, offset);
784   proto_tree_add_text(tree, tvb, offset, 1,
785                       "Protocol ID: %s (%u)",
786                       proto2str(protocol_id), protocol_id);
787   offset += 1;
788   length -= 1;
789   
790   spi_size = tvb_get_guint8(tvb, offset);
791   proto_tree_add_text(tree, tvb, offset, 1,
792                       "SPI size: %u", spi_size);
793   offset += 1;
794   length -= 1;
795   
796   msgtype = tvb_get_ntohs(tvb, offset);
797   proto_tree_add_text(tree, tvb, offset, 2,
798                       "Message type: %s (%u)", msgtype2str(msgtype), msgtype);
799   offset += 2;
800   length -= 2;
801
802   if (spi_size) {
803     proto_tree_add_text(tree, tvb, offset, spi_size, "Security Parameter Index");
804     offset += spi_size;
805     length -= spi_size;
806   }
807
808   if (length > 0)
809     proto_tree_add_text(tree, tvb, offset, length, "Notification Data");
810 }
811
812 static void
813 dissect_delete(tvbuff_t *tvb, int offset, int length, proto_tree *tree,
814     int unused _U_)
815 {
816   guint32               doi;
817   guint8                protocol_id;
818   guint8                spi_size;
819   guint16               num_spis;
820   guint16               i;
821   
822   doi = tvb_get_ntohl(tvb, offset);
823   proto_tree_add_text(tree, tvb, offset, 4,
824                       "Domain of Interpretation: %s (%u)",
825                       doitype2str(doi), doi);
826   offset += 4;
827   length -= 4;
828
829   protocol_id = tvb_get_guint8(tvb, offset);
830   proto_tree_add_text(tree, tvb, offset, 1,
831                       "Protocol ID: %s (%u)",
832                       proto2str(protocol_id), protocol_id);
833   offset += 1;
834   length -= 1;
835   
836   spi_size = tvb_get_guint8(tvb, offset);
837   proto_tree_add_text(tree, tvb, offset, 1,
838                       "SPI size: %u", spi_size);
839   offset += 1;
840   length -= 1;
841
842   num_spis = tvb_get_ntohs(tvb, offset);
843   proto_tree_add_text(tree, tvb, offset, 2,
844                       "Number of SPIs: %u", num_spis);
845   offset += 2;
846   length -= 2;
847   
848   for (i = 0; i < num_spis; ++i) {
849     if (length < spi_size) {
850       proto_tree_add_text(tree, tvb, offset, length,
851           "Not enough room in payload for all SPI's");
852       break;
853     }
854     proto_tree_add_text(tree, tvb, offset, spi_size,
855                         "SPI (%d)", i);
856     offset += spi_size;
857     length -= spi_size;
858   }
859 }
860
861 static void
862 dissect_vid(tvbuff_t *tvb, int offset, int length, proto_tree *tree,
863     int unused _U_)
864 {
865   proto_tree_add_text(tree, tvb, offset, length, "Vendor ID");
866 }
867
868 static void
869 dissect_config(tvbuff_t *tvb, int offset, int length, proto_tree *tree,
870     int unused _U_)
871 {
872   guint8                type;
873
874   type = tvb_get_guint8(tvb, offset);
875   proto_tree_add_text(tree, tvb, offset, 1,
876                       "Type %s (%u)",attrtype2str(type),type);
877   
878   offset += 2;
879   length -= 2;
880   
881   proto_tree_add_text(tree, tvb, offset, 2,
882                       "Identifier: %u", tvb_get_ntohs(tvb, offset));
883   offset += 2;
884   length -= 2;
885   
886   while(length>0) {
887     guint16 aft     = tvb_get_ntohs(tvb, offset);
888     guint16 type    = aft & 0x7fff;
889     guint16 len;
890     guint32 val;
891     guint pack_len;
892
893     if (aft & 0x8000) {
894       val = tvb_get_ntohs(tvb, offset + 2);
895       proto_tree_add_text(tree, tvb, offset, 4,
896                           "%s (%u)", cfgattrident2str(type), val);
897       offset += 4;
898       length -= 4;
899     }
900     else {
901       len = tvb_get_ntohs(tvb, offset + 2);
902       pack_len = 4 + len;
903       if (!get_num(tvb, offset + 4, len, &val)) {
904         proto_tree_add_text(tree, tvb, offset, pack_len,
905                             "%s: <too big (%u bytes)>",
906                             cfgattrident2str(type), len);
907       } else {
908         proto_tree_add_text(tree, tvb, offset, 4,
909                             "%s (%ue)", cfgattrident2str(type),
910                             val);
911       }
912       offset += pack_len;
913       length -= pack_len;
914     }
915   }
916 }
917
918 static const char *
919 payloadtype2str(guint8 type) {
920
921   if (type < NUM_LOAD_TYPES) return strfuncs[type].str;
922   if (type < 128)            return "RESERVED";
923   if (type < 256)            return "Private USE";
924
925   return "Huh? You should never see this! Shame on you!";
926 }
927
928 static const char *
929 exchtype2str(guint8 type) {
930
931 #define NUM_EXCHSTRS    7
932   static const char * exchstrs[NUM_EXCHSTRS] = {
933     "NONE",
934     "Base",
935     "Identity Protection (Main Mode)",
936     "Authentication Only",
937     "Aggressive",
938     "Informational",
939     "Transaction (Config Mode)"
940   };
941   
942   if (type < NUM_EXCHSTRS) return exchstrs[type];
943   if (type < 32)           return "ISAKMP Future Use";
944   switch (type) {
945   case 32:
946     return "Quick Mode";
947   case 33:
948     return "New Group Mode";
949   }
950   if (type < 240)          return "DOI Specific Use";
951   if (type < 256)          return "Private Use";
952   
953   return "Huh? You should never see this! Shame on you!";
954 }
955
956 static const char *
957 doitype2str(guint32 type) {
958   if (type == 1) return "IPSEC";
959   return "Unknown DOI Type";
960 }
961
962 static const char *
963 msgtype2str(guint16 type) {
964
965 #define NUM_PREDEFINED  31
966   static const char *msgs[NUM_PREDEFINED] = {
967     "<UNKNOWN>",
968     "INVALID-PAYLOAD-TYPE",
969     "DOI-NOT-SUPPORTED",
970     "SITUATION-NOT-SUPPORTED",
971     "INVALID-COOKIE",
972     "INVALID-MAJOR-VERSION",
973     "INVALID-MINOR-VERSION",
974     "INVALID-EXCHANGE-TYPE",
975     "INVALID-FLAGS",
976     "INVALID-MESSAGE-ID",
977     "INVALID-PROTOCOL-ID",
978     "INVALID-SPI",
979     "INVALID-TRANSFORM-ID",
980     "ATTRIBUTES-NOT-SUPPORTED",
981     "NO-PROPOSAL-CHOSEN",
982     "BAD-PROPOSAL-SYNTAX",
983     "PAYLOAD-MALFORMED",
984     "INVALID-KEY-INFORMATION",
985     "INVALID-ID-INFORMATION",
986     "INVALID-CERT-ENCODING",
987     "INVALID-CERTIFICATE",
988     "CERT-TYPE-UNSUPPORTED",
989     "INVALID-CERT-AUTHORITY",
990     "INVALID-HASH-INFORMATION",
991     "AUTHENTICATION-FAILED",
992     "INVALID-SIGNATURE",
993     "ADDRESS-NOTIFICATION",
994     "NOTIFY-SA-LIFETIME",
995     "CERTIFICATE-UNAVAILABLE",
996     "UNSUPPORTED-EXCHANGE-TYPE",
997     "UNEQUAL-PAYLOAD-LENGTHS"
998   };
999
1000   if (type < NUM_PREDEFINED) return msgs[type];
1001   if (type < 8192)           return "RESERVED (Future Use)";
1002   if (type < 16384)          return "Private Use";
1003   if (type < 16385)          return "CONNECTED";
1004   if (type < 24576)          return "RESERVED (Future Use) - status";
1005   if (type < 24577)          return "RESPONDER-LIFETIME";
1006   if (type < 24578)          return "REPLAY-STATUS";
1007   if (type < 24579)          return "INITIAL-CONTACT";
1008   if (type < 32768)          return "DOI-specific codes";
1009   if (type < 40960)          return "Private Use - status";
1010   if (type < 65535)          return "RESERVED (Future Use) - status (2)";
1011
1012   return "Huh? You should never see this! Shame on you!";
1013 }
1014
1015 static const char *
1016 situation2str(guint32 type) {
1017
1018 #define SIT_MSG_NUM     1024
1019 #define SIT_IDENTITY    0x01
1020 #define SIT_SECRECY     0x02
1021 #define SIT_INTEGRITY   0x04
1022
1023   static char   msg[SIT_MSG_NUM];
1024   int           n = 0;
1025   char *        sep = "";
1026   int           ret;
1027   
1028   if (type & SIT_IDENTITY) {
1029     ret = snprintf(msg, SIT_MSG_NUM-n, "%sIDENTITY", sep);
1030     if (ret == -1) {
1031       /* Some versions of snprintf return -1 if they'd truncate the output. */
1032       return msg;
1033     }
1034     n += ret;
1035     sep = " & ";
1036   }
1037   if (type & SIT_SECRECY) {
1038     if (n >= SIT_MSG_NUM) {
1039       /* No more room. */
1040       return msg;
1041     }
1042     ret = snprintf(msg, SIT_MSG_NUM-n, "%sSECRECY", sep);
1043     if (ret == -1) {
1044       /* Some versions of snprintf return -1 if they'd truncate the output. */
1045       return msg;
1046     }
1047     n += ret;
1048     sep = " & ";
1049   }
1050   if (type & SIT_INTEGRITY) {
1051     if (n >= SIT_MSG_NUM) {
1052       /* No more room. */
1053       return msg;
1054     }
1055     ret = snprintf(msg, SIT_MSG_NUM-n, "%sINTEGRITY", sep);
1056     if (ret == -1) {
1057       /* Some versions of snprintf return -1 if they'd truncate the output. */
1058       return msg;
1059     }
1060     n += ret;
1061     sep = " & ";
1062   }
1063
1064   return msg;
1065 }
1066
1067 static const char *
1068 value2str(int ike_p1, guint16 att_type, guint16 value) {
1069   
1070   if (value == 0) return "RESERVED";
1071   
1072   if (!ike_p1) {
1073   switch (att_type) {
1074     case 1:
1075       switch (value) {
1076         case 1:  return "Seconds";
1077         case 2:  return "Kilobytes";
1078         default: return "UNKNOWN-SA-VALUE";
1079       }
1080     case 2:
1081       return "Duration-Value";
1082     case 3:
1083       return "Group-Value";
1084     case 4:
1085       switch (value) {
1086         case 1:  return "Tunnel";
1087         case 2:  return "Transport";
1088         case 61440: return "Check Point IPSec UDP Encapsulation";
1089         case 61443: return "UDP-Encapsulated-Tunnel (draft)";
1090         case 61444: return "UDP-Encapsulated-Transport (draft)";
1091         default: return "UNKNOWN-ENCAPSULATION-VALUE";
1092       }
1093     case 5:
1094       switch (value) {
1095         case 1:  return "HMAC-MD5";
1096         case 2:  return "HMAC-SHA";
1097         case 3:  return "DES-MAC";
1098         case 4:  return "KPDK";
1099         case 5:  return "HMAC-SHA2-256";
1100         case 6:  return "HMAC-SHA2-384";
1101         case 7:  return "HMAC-SHA2-512";
1102         default: return "UNKNOWN-AUTHENTICATION-VALUE";
1103       }
1104     case 6:
1105       return "Key-Length";
1106     case 7:
1107       return "Key-Rounds";
1108     case 8:
1109       return "log2-size";
1110     default: return "UNKNOWN-ATTRIBUTE-TYPE";
1111   }
1112   }
1113   else {
1114     switch (att_type) {
1115       case 1:
1116         switch (value) {
1117           case 1:  return "DES-CBC";
1118           case 2:  return "IDEA-CBC";
1119           case 3:  return "BLOWFISH-CBC";
1120           case 4:  return "RC5-R16-B64-CBC";
1121           case 5:  return "3DES-CBC";
1122           case 6:  return "CAST-CBC";
1123           case 7:  return "AES-CBC";
1124           default: return "UNKNOWN-ENCRYPTION-ALG";
1125         }
1126       case 2:
1127         switch (value) {
1128           case 1:  return "MD5";
1129           case 2:  return "SHA";
1130           case 3:  return "TIGER";
1131           case 4:  return "SHA2-256";
1132           case 5:  return "SHA2-384";
1133           case 6:  return "SHA2-512";
1134           default: return "UNKNOWN-HASH-ALG";
1135         }
1136       case 3:
1137         switch (value) {
1138           case 1:  return "PSK";
1139           case 2:  return "DSS-SIG";
1140           case 3:  return "RSA-SIG";
1141           case 4:  return "RSA-ENC";
1142           case 5:  return "RSA-Revised-ENC";
1143           case 64221: return "HybridInitRSA";
1144           case 64222: return "HybridRespRSA";
1145           case 64223: return "HybridInitDSS";
1146           case 64224: return "HybridRespDSS";
1147           case 65001: return "XAUTHInitPreShared";
1148           case 65002: return "XAUTHRespPreShared";
1149           case 65003: return "XAUTHInitDSS";
1150           case 65004: return "XAUTHRespDSS";
1151           case 65005: return "XAUTHInitRSA";
1152           case 65006: return "XAUTHRespRSA";
1153           case 65007: return "XAUTHInitRSAEncryption";
1154           case 65008: return "XAUTHRespRSAEncryption";
1155           case 65009: return "XAUTHInitRSARevisedEncryption";
1156           case 65010: return "XAUTHRespRSARevisedEncryption";
1157           default: return "UNKNOWN-AUTH-METHOD";
1158         }
1159       case 4:
1160       case 6:
1161       case 7:
1162       case 8:
1163       case 9:
1164       case 10:
1165       case 16:
1166         return "Group-Value";
1167       case 5:
1168         switch (value) {
1169           case 1:  return "MODP";
1170           case 2:  return "ECP";
1171           case 3:  return "EC2N";
1172           default: return "UNKNOWN-GROUPT-TYPE";
1173         }
1174       case 11:
1175         switch (value) {
1176           case 1:  return "Seconds";
1177           case 2:  return "Kilobytes";
1178           default: return "UNKNOWN-SA-VALUE";
1179         }
1180       case 12:
1181         return "Duration-Value";
1182       case 13:
1183         return "PRF-Value";
1184       case 14:
1185         return "Key-Length";
1186       case 15:
1187         return "Field-Size";
1188       default: return "UNKNOWN-ATTRIBUTE-TYPE";
1189     }
1190   }
1191 }
1192
1193 static const char * 
1194 attrtype2str(guint8 type) {
1195   switch (type) {
1196   case 0: return "Reserved";
1197   case 1: return "ISAKMP_CFG_REQUEST";
1198   case 2: return "ISAKMP_CFG_REPLY";
1199   case 3: return "ISAKMP_CFG_SET";
1200   case 4: return "ISAKMP_CFG_ACK";
1201   }
1202   if(type < 127)
1203     return "Future use";
1204   return "Private use";
1205 }
1206
1207 static const char * 
1208 cfgattrident2str(guint16 ident) {
1209 #define NUM_ATTR_DEFINED        12
1210   static const char *msgs[NUM_PREDEFINED] = {
1211     "RESERVED",
1212     "INTERNAL_IP4_ADDRESS",
1213     "INTERNAL_IP4_NETMASK",
1214     "INTERNAL_IP4_DNS",
1215     "INTERNAL_IP4_NBNS",
1216     "INTERNAL_ADDRESS_EXPIREY",
1217     "INTERNAL_IP4_DHCP",
1218     "APPLICATION_VERSION"
1219     "INTERNAL_IP6_ADDRESS",
1220     "INTERNAL_IP6_NETMASK",
1221     "INTERNAL_IP6_DNS",
1222     "INTERNAL_IP6_NBNS",
1223     "INTERNAL_IP6_DHCP",
1224   }; 
1225   if(ident < NUM_ATTR_DEFINED)
1226     return msgs[ident];
1227   if(ident < 16383)
1228     return "Future use";
1229   switch(ident) {
1230   case 16520: return "XAUTH_TYPE";
1231   case 16521: return "XAUTH_USER_NAME";
1232   case 16522: return "XAUTH_USER_PASSWORD";
1233   case 16523: return "XAUTH_PASSCODE";
1234   case 16524: return "XAUTH_MESSAGE";
1235   case 16525: return "XAUTH_CHALLANGE";
1236   case 16526: return "XAUTH_DOMAIN";
1237   case 16527: return "XAUTH_STATUS";
1238   case 16528: return "XAUTH_NEXT_PIN";
1239   case 16529: return "XAUTH_ANSWER";
1240   default: return "Private use";
1241   }
1242 }
1243
1244 static const char *
1245 certtype2str(guint8 type) {
1246 #define NUM_CERTTYPE 11
1247   static const char *msgs[NUM_CERTTYPE] = {
1248     "NONE",
1249     "PKCS #7 wrapped X.509 certificate",
1250     "PGP Certificate",
1251     "DNS Signed Key",
1252     "X.509 Certificate - Signature",
1253     "X.509 Certificate - Key Exchange",
1254     "Kerberos Tokens",
1255     "Certificate Revocation List (CRL)",
1256     "Authority Revocation List (ARL)",
1257     "SPKI Certificate",
1258     "X.509 Certificate - Attribute",
1259   };
1260   if(type > NUM_CERTTYPE)
1261     return "RESERVED";
1262   return msgs[type];
1263 }
1264
1265 static gboolean
1266 get_num(tvbuff_t *tvb, int offset, guint16 len, guint32 *num_p) {
1267
1268   switch (len) {
1269   case 1:
1270     *num_p = tvb_get_guint8(tvb, offset);
1271     break;
1272   case 2:
1273     *num_p = tvb_get_ntohs(tvb, offset);
1274     break;
1275   case 3:
1276     *num_p = tvb_get_ntoh24(tvb, offset);
1277     break;
1278   case 4:
1279     *num_p = tvb_get_ntohl(tvb, offset);
1280     break;
1281   default:
1282     return FALSE;
1283   }
1284
1285   return TRUE;
1286 }
1287
1288 void
1289 proto_register_isakmp(void)
1290 {
1291 /*  static hf_register_info hf[] = {
1292     { &variable,
1293     { "Name",           "isakmp.abbreviation", TYPE, VALS_POINTER }},
1294   };*/
1295   static gint *ett[] = {
1296     &ett_isakmp,
1297     &ett_isakmp_flags,
1298     &ett_isakmp_payload,
1299   };
1300
1301   proto_isakmp = proto_register_protocol("Internet Security Association and Key Management Protocol",
1302                                                "ISAKMP", "isakmp");
1303 /*  proto_register_field_array(proto_isakmp, hf, array_length(hf));*/
1304   proto_register_subtree_array(ett, array_length(ett));
1305 }
1306
1307 void
1308 proto_reg_handoff_isakmp(void)
1309 {
1310   dissector_handle_t isakmp_handle;
1311
1312   /*
1313    * Get handle for the AH & ESP dissectors.
1314    */
1315   esp_handle = find_dissector("esp");
1316   ah_handle = find_dissector("ah");
1317
1318   isakmp_handle = create_dissector_handle(dissect_isakmp, proto_isakmp);
1319   dissector_add("udp.port", UDP_PORT_ISAKMP, isakmp_handle);
1320   dissector_add("tcp.port", TCP_PORT_ISAKMP, isakmp_handle);
1321 }