1999-10-18 05:59:12 +08:00
|
|
|
/*
|
1999-10-30 13:11:06 +08:00
|
|
|
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
|
|
|
* All rights reserved.
|
2002-06-12 01:08:37 +08:00
|
|
|
*
|
1999-10-18 05:59:12 +08:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
1999-10-30 13:11:06 +08:00
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. Neither the name of the project nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
2002-06-12 01:08:37 +08:00
|
|
|
*
|
1999-10-30 13:11:06 +08:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
1999-10-18 05:59:12 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2003-11-16 17:36:07 +08:00
|
|
|
#ifndef lint
|
|
|
|
static const char rcsid[] _U_ =
|
2008-02-06 03:34:25 +08:00
|
|
|
"@(#) $Header: /tcpdump/master/tcpdump/print-isakmp.c,v 1.61 2008-02-05 19:34:25 guy Exp $ (LBL)";
|
2003-11-16 17:36:07 +08:00
|
|
|
#endif
|
1999-11-21 17:36:43 +08:00
|
|
|
|
2007-08-29 20:31:00 +08:00
|
|
|
#define NETDISSECT_REWORKED
|
1999-11-21 17:36:43 +08:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
1999-10-18 05:59:12 +08:00
|
|
|
#endif
|
|
|
|
|
2002-08-01 16:52:55 +08:00
|
|
|
#include <tcpdump-stdinc.h>
|
1999-10-18 05:59:12 +08:00
|
|
|
|
2002-08-01 16:52:55 +08:00
|
|
|
#include <string.h>
|
1999-10-30 13:11:06 +08:00
|
|
|
|
1999-10-18 05:59:12 +08:00
|
|
|
#include <stdio.h>
|
|
|
|
|
1999-10-30 13:11:06 +08:00
|
|
|
#include "isakmp.h"
|
|
|
|
#include "ipsec_doi.h"
|
|
|
|
#include "oakley.h"
|
1999-10-18 05:59:12 +08:00
|
|
|
#include "interface.h"
|
|
|
|
#include "addrtoname.h"
|
1999-10-30 13:11:06 +08:00
|
|
|
#include "extract.h" /* must come after interface.h */
|
|
|
|
|
2000-09-23 16:54:24 +08:00
|
|
|
#include "ip.h"
|
2000-10-07 13:53:09 +08:00
|
|
|
#ifdef INET6
|
|
|
|
#include "ip6.h"
|
|
|
|
#endif
|
2000-09-23 16:54:24 +08:00
|
|
|
|
1999-10-30 13:30:20 +08:00
|
|
|
#ifndef HAVE_SOCKADDR_STORAGE
|
|
|
|
#define sockaddr_storage sockaddr
|
|
|
|
#endif
|
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
#define DECLARE_PRINTER(func) static const u_char *ike##func##_print( \
|
|
|
|
netdissect_options *ndo, u_char tpay, \
|
|
|
|
const struct isakmp_gen *ext, \
|
|
|
|
u_int item_len, \
|
|
|
|
const u_char *end_pointer, \
|
|
|
|
u_int32_t phase,\
|
|
|
|
u_int32_t doi0, \
|
|
|
|
u_int32_t proto0, int depth)
|
|
|
|
|
|
|
|
DECLARE_PRINTER(v1_sa);
|
|
|
|
DECLARE_PRINTER(v1_p);
|
|
|
|
DECLARE_PRINTER(v1_t);
|
|
|
|
DECLARE_PRINTER(v1_ke);
|
|
|
|
DECLARE_PRINTER(v1_id);
|
|
|
|
DECLARE_PRINTER(v1_cert);
|
|
|
|
DECLARE_PRINTER(v1_cr);
|
|
|
|
DECLARE_PRINTER(v1_sig);
|
|
|
|
DECLARE_PRINTER(v1_hash);
|
|
|
|
DECLARE_PRINTER(v1_nonce);
|
|
|
|
DECLARE_PRINTER(v1_n);
|
|
|
|
DECLARE_PRINTER(v1_d);
|
|
|
|
DECLARE_PRINTER(v1_vid);
|
|
|
|
|
|
|
|
DECLARE_PRINTER(v2_sa);
|
|
|
|
DECLARE_PRINTER(v2_ke);
|
|
|
|
DECLARE_PRINTER(v2_ID);
|
|
|
|
DECLARE_PRINTER(v2_cert);
|
|
|
|
DECLARE_PRINTER(v2_cr);
|
|
|
|
DECLARE_PRINTER(v2_auth);
|
|
|
|
DECLARE_PRINTER(v2_nonce);
|
|
|
|
DECLARE_PRINTER(v2_n);
|
|
|
|
DECLARE_PRINTER(v2_d);
|
|
|
|
DECLARE_PRINTER(v2_vid);
|
|
|
|
DECLARE_PRINTER(v2_TS);
|
|
|
|
DECLARE_PRINTER(v2_cp);
|
|
|
|
DECLARE_PRINTER(v2_eap);
|
|
|
|
|
2007-11-25 02:13:33 +08:00
|
|
|
static const u_char *ikev2_e_print(netdissect_options *ndo,
|
|
|
|
struct isakmp *base,
|
|
|
|
u_char tpay,
|
|
|
|
const struct isakmp_gen *ext,
|
|
|
|
u_int item_len,
|
|
|
|
const u_char *end_pointer,
|
|
|
|
u_int32_t phase,
|
|
|
|
u_int32_t doi0,
|
|
|
|
u_int32_t proto0, int depth);
|
|
|
|
|
|
|
|
|
2007-08-29 10:58:43 +08:00
|
|
|
static const u_char *ike_sub0_print(netdissect_options *ndo,u_char, const struct isakmp_gen *,
|
2002-09-05 08:43:21 +08:00
|
|
|
const u_char *, u_int32_t, u_int32_t, u_int32_t, int);
|
2007-08-29 10:38:14 +08:00
|
|
|
static const u_char *ikev1_sub_print(netdissect_options *ndo,u_char, const struct isakmp_gen *,
|
2002-09-05 08:43:21 +08:00
|
|
|
const u_char *, u_int32_t, u_int32_t, u_int32_t, int);
|
2007-08-29 10:38:14 +08:00
|
|
|
|
|
|
|
static const u_char *ikev2_sub_print(netdissect_options *ndo,
|
2007-11-25 02:13:33 +08:00
|
|
|
struct isakmp *base,
|
2007-08-29 10:38:14 +08:00
|
|
|
u_char np, const struct isakmp_gen *ext,
|
|
|
|
const u_char *ep, u_int32_t phase,
|
|
|
|
u_int32_t doi, u_int32_t proto,
|
|
|
|
int depth);
|
|
|
|
|
|
|
|
|
2000-09-24 15:50:35 +08:00
|
|
|
static char *numstr(int);
|
2002-09-05 08:43:21 +08:00
|
|
|
static void safememcpy(void *, const void *, size_t);
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
static void
|
|
|
|
ikev1_print(netdissect_options *ndo,
|
|
|
|
const u_char *bp, u_int length,
|
|
|
|
const u_char *bp2, struct isakmp *base);
|
|
|
|
|
1999-10-30 13:11:06 +08:00
|
|
|
#define MAXINITIATORS 20
|
|
|
|
int ninitiator = 0;
|
|
|
|
struct {
|
|
|
|
cookie_t initiator;
|
|
|
|
struct sockaddr_storage iaddr;
|
|
|
|
struct sockaddr_storage raddr;
|
|
|
|
} cookiecache[MAXINITIATORS];
|
|
|
|
|
|
|
|
/* protocol id */
|
Add a few more GCC warnings on GCC >= 2 for ".devel" builds.
From Neil T. Spring: fixes for many of those warnings:
addrtoname.c, configure.in: Linux needs netinet/ether.h for
ether_ntohost
print-*.c: change char *foo = "bar" to const char *foo = "bar"
to appease -Wwrite-strings; should affect no run-time behavior.
print-*.c: make some variables unsigned.
print-bgp.c: plen ('prefix len') is unsigned, no reason to
validate by comparing to zero.
print-cnfp.c, print-rx.c: use intoa, provided by addrtoname,
instead of inet_ntoa.
print-domain.c: unsigned int l; (l=foo()) < 0 is guaranteed to
be false, so check for (u_int)-1, which represents failure,
explicitly.
print-isakmp.c: complete initialization of attrmap objects.
print-lwres.c: "if(x); print foo;" seemed much more likely to be
intended to be "if(x) { print foo; }".
print-smb.c: complete initialization of some structures.
In addition, add some fixes for the signed vs. unsigned comparison
warnings:
extract.h: cast the result of the byte-extraction-and-combining,
as, at least for the 16-bit version, C's integral promotions
will turn "u_int16_t" into "int" if there are other "int"s
nearby.
print-*.c: make some more variables unsigned, or add casts to an
unsigned type of signed values known not to be negative, or add
casts to "int" of unsigned values known to fit in an "int", and
make other changes needed to handle the aforementioned variables
now being unsigned.
print-isakmp.c: clean up the handling of error/status indicators
in notify messages.
print-ppp.c: get rid of a check that an unsigned quantity is >=
0.
print-radius.c: clean up some of the bounds checking.
print-smb.c: extract the word count into a "u_int" to avoid the
aforementioned problems with C's integral promotions.
print-snmp.c: change a check that an unsigned variable is >= 0
to a check that it's != 0.
Also, fix some formats to use "%u" rather than "%d" for unsigned
quantities.
2002-09-05 08:00:07 +08:00
|
|
|
static const char *protoidstr[] = {
|
1999-10-30 13:11:06 +08:00
|
|
|
NULL, "isakmp", "ipsec-ah", "ipsec-esp", "ipcomp",
|
|
|
|
};
|
|
|
|
|
|
|
|
/* isakmp->np */
|
Add a few more GCC warnings on GCC >= 2 for ".devel" builds.
From Neil T. Spring: fixes for many of those warnings:
addrtoname.c, configure.in: Linux needs netinet/ether.h for
ether_ntohost
print-*.c: change char *foo = "bar" to const char *foo = "bar"
to appease -Wwrite-strings; should affect no run-time behavior.
print-*.c: make some variables unsigned.
print-bgp.c: plen ('prefix len') is unsigned, no reason to
validate by comparing to zero.
print-cnfp.c, print-rx.c: use intoa, provided by addrtoname,
instead of inet_ntoa.
print-domain.c: unsigned int l; (l=foo()) < 0 is guaranteed to
be false, so check for (u_int)-1, which represents failure,
explicitly.
print-isakmp.c: complete initialization of attrmap objects.
print-lwres.c: "if(x); print foo;" seemed much more likely to be
intended to be "if(x) { print foo; }".
print-smb.c: complete initialization of some structures.
In addition, add some fixes for the signed vs. unsigned comparison
warnings:
extract.h: cast the result of the byte-extraction-and-combining,
as, at least for the 16-bit version, C's integral promotions
will turn "u_int16_t" into "int" if there are other "int"s
nearby.
print-*.c: make some more variables unsigned, or add casts to an
unsigned type of signed values known not to be negative, or add
casts to "int" of unsigned values known to fit in an "int", and
make other changes needed to handle the aforementioned variables
now being unsigned.
print-isakmp.c: clean up the handling of error/status indicators
in notify messages.
print-ppp.c: get rid of a check that an unsigned quantity is >=
0.
print-radius.c: clean up some of the bounds checking.
print-smb.c: extract the word count into a "u_int" to avoid the
aforementioned problems with C's integral promotions.
print-snmp.c: change a check that an unsigned variable is >= 0
to a check that it's != 0.
Also, fix some formats to use "%u" rather than "%d" for unsigned
quantities.
2002-09-05 08:00:07 +08:00
|
|
|
static const char *npstr[] = {
|
2007-08-29 10:38:14 +08:00
|
|
|
"none", "sa", "p", "t", "ke", "id", "cert", "cr", "hash", /* 0 - 8 */
|
|
|
|
"sig", "nonce", "n", "d", "vid", /* 9 - 13 */
|
|
|
|
"pay14", "pay15", "pay16", "pay17", "pay18", /* 14- 18 */
|
|
|
|
"pay19", "pay20", "pay21", "pay22", "pay23", /* 19- 23 */
|
|
|
|
"pay24", "pay25", "pay26", "pay27", "pay28", /* 24- 28 */
|
|
|
|
"pay29", "pay30", "pay31", "pay32", /* 29- 32 */
|
|
|
|
"v2sa", "v2ke", "v2IDi", "v2IDr", "v2cert",/* 33- 37 */
|
|
|
|
"v2cr", "v2auth","v2nonce", "v2n", "v2d", /* 38- 42 */
|
|
|
|
"v2vid", "v2TSi", "v2TSr", "v2e", "v2cp", /* 43- 47 */
|
|
|
|
"v2eap", /* 48 */
|
|
|
|
|
1999-10-30 13:11:06 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* isakmp->np */
|
2007-08-29 10:38:14 +08:00
|
|
|
static const u_char *(*npfunc[])(netdissect_options *ndo, u_char tpay,
|
|
|
|
const struct isakmp_gen *ext,
|
|
|
|
u_int item_len,
|
|
|
|
const u_char *end_pointer,
|
|
|
|
u_int32_t phase,
|
|
|
|
u_int32_t doi0,
|
|
|
|
u_int32_t proto0, int depth) = {
|
1999-10-30 13:11:06 +08:00
|
|
|
NULL,
|
2007-08-29 10:38:14 +08:00
|
|
|
ikev1_sa_print,
|
|
|
|
ikev1_p_print,
|
|
|
|
ikev1_t_print,
|
|
|
|
ikev1_ke_print,
|
|
|
|
ikev1_id_print,
|
|
|
|
ikev1_cert_print,
|
|
|
|
ikev1_cr_print,
|
|
|
|
ikev1_hash_print,
|
|
|
|
ikev1_sig_print,
|
|
|
|
ikev1_nonce_print,
|
|
|
|
ikev1_n_print,
|
|
|
|
ikev1_d_print,
|
|
|
|
ikev1_vid_print, /* 13 */
|
|
|
|
NULL, NULL, NULL, NULL, NULL, /* 14- 18 */
|
|
|
|
NULL, NULL, NULL, NULL, NULL, /* 19- 23 */
|
|
|
|
NULL, NULL, NULL, NULL, NULL, /* 24- 28 */
|
|
|
|
NULL, NULL, NULL, NULL, /* 29- 32 */
|
|
|
|
ikev2_sa_print, /* 33 */
|
|
|
|
ikev2_ke_print, /* 34 */
|
|
|
|
ikev2_ID_print, /* 35 */
|
|
|
|
ikev2_ID_print, /* 36 */
|
|
|
|
ikev2_cert_print, /* 37 */
|
|
|
|
ikev2_cr_print, /* 38 */
|
|
|
|
ikev2_auth_print, /* 39 */
|
|
|
|
ikev2_nonce_print, /* 40 */
|
|
|
|
ikev2_n_print, /* 41 */
|
|
|
|
ikev2_d_print, /* 42 */
|
|
|
|
ikev2_vid_print, /* 43 */
|
|
|
|
ikev2_TS_print, /* 44 */
|
|
|
|
ikev2_TS_print, /* 45 */
|
2007-11-25 02:13:33 +08:00
|
|
|
NULL, /* ikev2_e_print,*/ /* 46 - special */
|
2007-08-29 10:38:14 +08:00
|
|
|
ikev2_cp_print, /* 47 */
|
|
|
|
ikev2_eap_print, /* 48 */
|
1999-10-30 13:11:06 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* isakmp->etype */
|
Add a few more GCC warnings on GCC >= 2 for ".devel" builds.
From Neil T. Spring: fixes for many of those warnings:
addrtoname.c, configure.in: Linux needs netinet/ether.h for
ether_ntohost
print-*.c: change char *foo = "bar" to const char *foo = "bar"
to appease -Wwrite-strings; should affect no run-time behavior.
print-*.c: make some variables unsigned.
print-bgp.c: plen ('prefix len') is unsigned, no reason to
validate by comparing to zero.
print-cnfp.c, print-rx.c: use intoa, provided by addrtoname,
instead of inet_ntoa.
print-domain.c: unsigned int l; (l=foo()) < 0 is guaranteed to
be false, so check for (u_int)-1, which represents failure,
explicitly.
print-isakmp.c: complete initialization of attrmap objects.
print-lwres.c: "if(x); print foo;" seemed much more likely to be
intended to be "if(x) { print foo; }".
print-smb.c: complete initialization of some structures.
In addition, add some fixes for the signed vs. unsigned comparison
warnings:
extract.h: cast the result of the byte-extraction-and-combining,
as, at least for the 16-bit version, C's integral promotions
will turn "u_int16_t" into "int" if there are other "int"s
nearby.
print-*.c: make some more variables unsigned, or add casts to an
unsigned type of signed values known not to be negative, or add
casts to "int" of unsigned values known to fit in an "int", and
make other changes needed to handle the aforementioned variables
now being unsigned.
print-isakmp.c: clean up the handling of error/status indicators
in notify messages.
print-ppp.c: get rid of a check that an unsigned quantity is >=
0.
print-radius.c: clean up some of the bounds checking.
print-smb.c: extract the word count into a "u_int" to avoid the
aforementioned problems with C's integral promotions.
print-snmp.c: change a check that an unsigned variable is >= 0
to a check that it's != 0.
Also, fix some formats to use "%u" rather than "%d" for unsigned
quantities.
2002-09-05 08:00:07 +08:00
|
|
|
static const char *etypestr[] = {
|
2007-08-29 10:38:14 +08:00
|
|
|
/* IKEv1 exchange types */
|
|
|
|
"none", "base", "ident", "auth", "agg", "inf", NULL, NULL, /* 0-7 */
|
|
|
|
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 8-15 */
|
|
|
|
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 16-23 */
|
|
|
|
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 24-31 */
|
|
|
|
"oakley-quick", "oakley-newgroup", /* 32-33 */
|
|
|
|
/* IKEv2 exchange types */
|
|
|
|
"ikev2_init", "ikev2_auth", "child_sa", "inf2" /* 34-37 */
|
1999-10-30 13:11:06 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#define STR_OR_ID(x, tab) \
|
|
|
|
(((x) < sizeof(tab)/sizeof(tab[0]) && tab[(x)]) ? tab[(x)] : numstr(x))
|
|
|
|
#define PROTOIDSTR(x) STR_OR_ID(x, protoidstr)
|
|
|
|
#define NPSTR(x) STR_OR_ID(x, npstr)
|
|
|
|
#define ETYPESTR(x) STR_OR_ID(x, etypestr)
|
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
#define CHECKLEN(p, np) \
|
|
|
|
if (ep < (u_char *)(p)) { \
|
|
|
|
ND_PRINT((ndo," [|%s]", NPSTR(np))); \
|
|
|
|
goto done; \
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-30 13:11:06 +08:00
|
|
|
#define NPFUNC(x) \
|
|
|
|
(((x) < sizeof(npfunc)/sizeof(npfunc[0]) && npfunc[(x)]) \
|
|
|
|
? npfunc[(x)] : NULL)
|
|
|
|
|
|
|
|
static int
|
|
|
|
iszero(u_char *p, size_t l)
|
|
|
|
{
|
|
|
|
while (l--) {
|
|
|
|
if (*p++)
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* find cookie from initiator cache */
|
|
|
|
static int
|
|
|
|
cookie_find(cookie_t *in)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < MAXINITIATORS; i++) {
|
|
|
|
if (memcmp(in, &cookiecache[i].initiator, sizeof(*in)) == 0)
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* record initiator */
|
|
|
|
static void
|
|
|
|
cookie_record(cookie_t *in, const u_char *bp2)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
struct ip *ip;
|
|
|
|
struct sockaddr_in *sin;
|
|
|
|
#ifdef INET6
|
|
|
|
struct ip6_hdr *ip6;
|
|
|
|
struct sockaddr_in6 *sin6;
|
1999-10-18 05:59:12 +08:00
|
|
|
#endif
|
1999-10-30 13:11:06 +08:00
|
|
|
|
|
|
|
i = cookie_find(in);
|
|
|
|
if (0 <= i) {
|
|
|
|
ninitiator = (i + 1) % MAXINITIATORS;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ip = (struct ip *)bp2;
|
2000-10-03 10:54:54 +08:00
|
|
|
switch (IP_V(ip)) {
|
1999-10-30 13:11:06 +08:00
|
|
|
case 4:
|
|
|
|
memset(&cookiecache[ninitiator].iaddr, 0,
|
|
|
|
sizeof(cookiecache[ninitiator].iaddr));
|
|
|
|
memset(&cookiecache[ninitiator].raddr, 0,
|
|
|
|
sizeof(cookiecache[ninitiator].raddr));
|
|
|
|
|
|
|
|
sin = (struct sockaddr_in *)&cookiecache[ninitiator].iaddr;
|
1999-10-30 15:36:34 +08:00
|
|
|
#ifdef HAVE_SOCKADDR_SA_LEN
|
1999-10-30 13:11:06 +08:00
|
|
|
sin->sin_len = sizeof(struct sockaddr_in);
|
1999-10-30 15:36:34 +08:00
|
|
|
#endif
|
1999-10-30 13:11:06 +08:00
|
|
|
sin->sin_family = AF_INET;
|
|
|
|
memcpy(&sin->sin_addr, &ip->ip_src, sizeof(ip->ip_src));
|
|
|
|
sin = (struct sockaddr_in *)&cookiecache[ninitiator].raddr;
|
1999-10-30 15:36:34 +08:00
|
|
|
#ifdef HAVE_SOCKADDR_SA_LEN
|
1999-10-30 13:11:06 +08:00
|
|
|
sin->sin_len = sizeof(struct sockaddr_in);
|
1999-10-30 15:36:34 +08:00
|
|
|
#endif
|
1999-10-30 13:11:06 +08:00
|
|
|
sin->sin_family = AF_INET;
|
|
|
|
memcpy(&sin->sin_addr, &ip->ip_dst, sizeof(ip->ip_dst));
|
|
|
|
break;
|
|
|
|
#ifdef INET6
|
|
|
|
case 6:
|
|
|
|
memset(&cookiecache[ninitiator].iaddr, 0,
|
|
|
|
sizeof(cookiecache[ninitiator].iaddr));
|
|
|
|
memset(&cookiecache[ninitiator].raddr, 0,
|
|
|
|
sizeof(cookiecache[ninitiator].raddr));
|
|
|
|
|
|
|
|
ip6 = (struct ip6_hdr *)bp2;
|
|
|
|
sin6 = (struct sockaddr_in6 *)&cookiecache[ninitiator].iaddr;
|
1999-10-30 15:36:34 +08:00
|
|
|
#ifdef HAVE_SOCKADDR_SA_LEN
|
1999-10-30 13:11:06 +08:00
|
|
|
sin6->sin6_len = sizeof(struct sockaddr_in6);
|
1999-10-30 15:36:34 +08:00
|
|
|
#endif
|
1999-10-30 13:11:06 +08:00
|
|
|
sin6->sin6_family = AF_INET6;
|
|
|
|
memcpy(&sin6->sin6_addr, &ip6->ip6_src, sizeof(ip6->ip6_src));
|
|
|
|
sin6 = (struct sockaddr_in6 *)&cookiecache[ninitiator].raddr;
|
1999-10-30 15:36:34 +08:00
|
|
|
#ifdef HAVE_SOCKADDR_SA_LEN
|
1999-10-30 13:11:06 +08:00
|
|
|
sin6->sin6_len = sizeof(struct sockaddr_in6);
|
1999-10-30 15:36:34 +08:00
|
|
|
#endif
|
1999-10-30 13:11:06 +08:00
|
|
|
sin6->sin6_family = AF_INET6;
|
|
|
|
memcpy(&sin6->sin6_addr, &ip6->ip6_dst, sizeof(ip6->ip6_dst));
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
memcpy(&cookiecache[ninitiator].initiator, in, sizeof(*in));
|
|
|
|
ninitiator = (ninitiator + 1) % MAXINITIATORS;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define cookie_isinitiator(x, y) cookie_sidecheck((x), (y), 1)
|
|
|
|
#define cookie_isresponder(x, y) cookie_sidecheck((x), (y), 0)
|
|
|
|
static int
|
|
|
|
cookie_sidecheck(int i, const u_char *bp2, int initiator)
|
|
|
|
{
|
|
|
|
struct sockaddr_storage ss;
|
1999-10-30 13:30:20 +08:00
|
|
|
struct sockaddr *sa;
|
1999-10-30 13:11:06 +08:00
|
|
|
struct ip *ip;
|
|
|
|
struct sockaddr_in *sin;
|
|
|
|
#ifdef INET6
|
|
|
|
struct ip6_hdr *ip6;
|
|
|
|
struct sockaddr_in6 *sin6;
|
|
|
|
#endif
|
1999-10-30 13:37:35 +08:00
|
|
|
int salen;
|
1999-10-30 13:11:06 +08:00
|
|
|
|
|
|
|
memset(&ss, 0, sizeof(ss));
|
|
|
|
ip = (struct ip *)bp2;
|
2000-10-03 10:54:54 +08:00
|
|
|
switch (IP_V(ip)) {
|
1999-10-30 13:11:06 +08:00
|
|
|
case 4:
|
|
|
|
sin = (struct sockaddr_in *)&ss;
|
1999-10-30 15:36:34 +08:00
|
|
|
#ifdef HAVE_SOCKADDR_SA_LEN
|
1999-10-30 13:11:06 +08:00
|
|
|
sin->sin_len = sizeof(struct sockaddr_in);
|
1999-10-30 15:36:34 +08:00
|
|
|
#endif
|
1999-10-30 13:11:06 +08:00
|
|
|
sin->sin_family = AF_INET;
|
|
|
|
memcpy(&sin->sin_addr, &ip->ip_src, sizeof(ip->ip_src));
|
|
|
|
break;
|
|
|
|
#ifdef INET6
|
|
|
|
case 6:
|
|
|
|
ip6 = (struct ip6_hdr *)bp2;
|
|
|
|
sin6 = (struct sockaddr_in6 *)&ss;
|
1999-10-30 15:36:34 +08:00
|
|
|
#ifdef HAVE_SOCKADDR_SA_LEN
|
1999-10-30 13:11:06 +08:00
|
|
|
sin6->sin6_len = sizeof(struct sockaddr_in6);
|
1999-10-30 15:36:34 +08:00
|
|
|
#endif
|
1999-10-30 13:11:06 +08:00
|
|
|
sin6->sin6_family = AF_INET6;
|
|
|
|
memcpy(&sin6->sin6_addr, &ip6->ip6_src, sizeof(ip6->ip6_src));
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1999-10-30 13:30:20 +08:00
|
|
|
sa = (struct sockaddr *)&ss;
|
1999-10-30 13:11:06 +08:00
|
|
|
if (initiator) {
|
1999-10-30 13:30:20 +08:00
|
|
|
if (sa->sa_family != ((struct sockaddr *)&cookiecache[i].iaddr)->sa_family)
|
1999-10-30 13:11:06 +08:00
|
|
|
return 0;
|
1999-10-30 13:37:35 +08:00
|
|
|
#ifdef HAVE_SOCKADDR_SA_LEN
|
|
|
|
salen = sa->sa_len;
|
|
|
|
#else
|
|
|
|
#ifdef INET6
|
|
|
|
if (sa->sa_family == AF_INET6)
|
|
|
|
salen = sizeof(struct sockaddr_in6);
|
|
|
|
else
|
|
|
|
salen = sizeof(struct sockaddr);
|
|
|
|
#else
|
|
|
|
salen = sizeof(struct sockaddr);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
if (memcmp(&ss, &cookiecache[i].iaddr, salen) == 0)
|
1999-10-30 13:11:06 +08:00
|
|
|
return 1;
|
|
|
|
} else {
|
1999-10-30 13:30:20 +08:00
|
|
|
if (sa->sa_family != ((struct sockaddr *)&cookiecache[i].raddr)->sa_family)
|
1999-10-30 13:11:06 +08:00
|
|
|
return 0;
|
1999-10-30 13:37:35 +08:00
|
|
|
#ifdef HAVE_SOCKADDR_SA_LEN
|
|
|
|
salen = sa->sa_len;
|
|
|
|
#else
|
|
|
|
#ifdef INET6
|
|
|
|
if (sa->sa_family == AF_INET6)
|
|
|
|
salen = sizeof(struct sockaddr_in6);
|
|
|
|
else
|
|
|
|
salen = sizeof(struct sockaddr);
|
|
|
|
#else
|
|
|
|
salen = sizeof(struct sockaddr);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
if (memcmp(&ss, &cookiecache[i].raddr, salen) == 0)
|
1999-10-30 13:11:06 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-11-25 02:13:33 +08:00
|
|
|
static void
|
|
|
|
hexprint(netdissect_options *ndo, caddr_t loc, size_t len)
|
1999-10-30 13:11:06 +08:00
|
|
|
{
|
2007-11-25 02:13:33 +08:00
|
|
|
u_char *p;
|
Add a few more GCC warnings on GCC >= 2 for ".devel" builds.
From Neil T. Spring: fixes for many of those warnings:
addrtoname.c, configure.in: Linux needs netinet/ether.h for
ether_ntohost
print-*.c: change char *foo = "bar" to const char *foo = "bar"
to appease -Wwrite-strings; should affect no run-time behavior.
print-*.c: make some variables unsigned.
print-bgp.c: plen ('prefix len') is unsigned, no reason to
validate by comparing to zero.
print-cnfp.c, print-rx.c: use intoa, provided by addrtoname,
instead of inet_ntoa.
print-domain.c: unsigned int l; (l=foo()) < 0 is guaranteed to
be false, so check for (u_int)-1, which represents failure,
explicitly.
print-isakmp.c: complete initialization of attrmap objects.
print-lwres.c: "if(x); print foo;" seemed much more likely to be
intended to be "if(x) { print foo; }".
print-smb.c: complete initialization of some structures.
In addition, add some fixes for the signed vs. unsigned comparison
warnings:
extract.h: cast the result of the byte-extraction-and-combining,
as, at least for the 16-bit version, C's integral promotions
will turn "u_int16_t" into "int" if there are other "int"s
nearby.
print-*.c: make some more variables unsigned, or add casts to an
unsigned type of signed values known not to be negative, or add
casts to "int" of unsigned values known to fit in an "int", and
make other changes needed to handle the aforementioned variables
now being unsigned.
print-isakmp.c: clean up the handling of error/status indicators
in notify messages.
print-ppp.c: get rid of a check that an unsigned quantity is >=
0.
print-radius.c: clean up some of the bounds checking.
print-smb.c: extract the word count into a "u_int" to avoid the
aforementioned problems with C's integral promotions.
print-snmp.c: change a check that an unsigned variable is >= 0
to a check that it's != 0.
Also, fix some formats to use "%u" rather than "%d" for unsigned
quantities.
2002-09-05 08:00:07 +08:00
|
|
|
size_t i;
|
1999-10-30 13:11:06 +08:00
|
|
|
|
|
|
|
p = (u_char *)loc;
|
|
|
|
for (i = 0; i < len; i++)
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo,"%02x", p[i] & 0xff));
|
2007-11-25 02:13:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
rawprint(netdissect_options *ndo, caddr_t loc, size_t len)
|
|
|
|
{
|
|
|
|
ND_TCHECK2(*loc, len);
|
|
|
|
|
|
|
|
hexprint(ndo, loc, len);
|
2007-08-29 10:38:14 +08:00
|
|
|
return 1;
|
|
|
|
trunc:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-11-25 02:13:33 +08:00
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
/*
|
|
|
|
* returns false if we run out of data buffer
|
|
|
|
*/
|
|
|
|
static int ike_show_somedata(struct netdissect_options *ndo,
|
|
|
|
const u_char *cp, const u_char *ep)
|
|
|
|
{
|
|
|
|
/* there is too much data, just show some of it */
|
|
|
|
const u_char *end = ep - 20;
|
|
|
|
int elen = 20;
|
|
|
|
int len = ep - cp;
|
|
|
|
if(len > 10) {
|
|
|
|
len = 10;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* really shouldn't happen because of above */
|
|
|
|
if(end < cp + len) {
|
|
|
|
end = cp+len;
|
|
|
|
elen = ep - end;
|
|
|
|
}
|
|
|
|
|
|
|
|
ND_PRINT((ndo," data=("));
|
|
|
|
if(!rawprint(ndo, (caddr_t)(cp), len)) goto trunc;
|
|
|
|
ND_PRINT((ndo, "..."));
|
|
|
|
if(elen) {
|
|
|
|
if(!rawprint(ndo, (caddr_t)(end), elen)) goto trunc;
|
|
|
|
}
|
|
|
|
ND_PRINT((ndo,")"));
|
2004-03-12 10:17:18 +08:00
|
|
|
return 1;
|
2007-08-29 10:38:14 +08:00
|
|
|
|
2004-01-07 16:00:51 +08:00
|
|
|
trunc:
|
2004-03-12 10:17:18 +08:00
|
|
|
return 0;
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
struct attrmap {
|
Add a few more GCC warnings on GCC >= 2 for ".devel" builds.
From Neil T. Spring: fixes for many of those warnings:
addrtoname.c, configure.in: Linux needs netinet/ether.h for
ether_ntohost
print-*.c: change char *foo = "bar" to const char *foo = "bar"
to appease -Wwrite-strings; should affect no run-time behavior.
print-*.c: make some variables unsigned.
print-bgp.c: plen ('prefix len') is unsigned, no reason to
validate by comparing to zero.
print-cnfp.c, print-rx.c: use intoa, provided by addrtoname,
instead of inet_ntoa.
print-domain.c: unsigned int l; (l=foo()) < 0 is guaranteed to
be false, so check for (u_int)-1, which represents failure,
explicitly.
print-isakmp.c: complete initialization of attrmap objects.
print-lwres.c: "if(x); print foo;" seemed much more likely to be
intended to be "if(x) { print foo; }".
print-smb.c: complete initialization of some structures.
In addition, add some fixes for the signed vs. unsigned comparison
warnings:
extract.h: cast the result of the byte-extraction-and-combining,
as, at least for the 16-bit version, C's integral promotions
will turn "u_int16_t" into "int" if there are other "int"s
nearby.
print-*.c: make some more variables unsigned, or add casts to an
unsigned type of signed values known not to be negative, or add
casts to "int" of unsigned values known to fit in an "int", and
make other changes needed to handle the aforementioned variables
now being unsigned.
print-isakmp.c: clean up the handling of error/status indicators
in notify messages.
print-ppp.c: get rid of a check that an unsigned quantity is >=
0.
print-radius.c: clean up some of the bounds checking.
print-smb.c: extract the word count into a "u_int" to avoid the
aforementioned problems with C's integral promotions.
print-snmp.c: change a check that an unsigned variable is >= 0
to a check that it's != 0.
Also, fix some formats to use "%u" rather than "%d" for unsigned
quantities.
2002-09-05 08:00:07 +08:00
|
|
|
const char *type;
|
|
|
|
u_int nvalue;
|
|
|
|
const char *value[30]; /*XXX*/
|
1999-10-18 05:59:12 +08:00
|
|
|
};
|
|
|
|
|
2002-09-05 08:43:21 +08:00
|
|
|
static const u_char *
|
2007-08-29 10:38:14 +08:00
|
|
|
ikev1_attrmap_print(netdissect_options *ndo,
|
|
|
|
const u_char *p, const u_char *ep,
|
|
|
|
const struct attrmap *map, size_t nmap)
|
1999-10-30 13:11:06 +08:00
|
|
|
{
|
2000-04-28 19:14:47 +08:00
|
|
|
u_int16_t *q;
|
1999-10-30 13:11:06 +08:00
|
|
|
int totlen;
|
|
|
|
u_int32_t t, v;
|
|
|
|
|
2000-04-28 19:14:47 +08:00
|
|
|
q = (u_int16_t *)p;
|
1999-10-30 13:11:06 +08:00
|
|
|
if (p[0] & 0x80)
|
|
|
|
totlen = 4;
|
|
|
|
else
|
2002-12-11 15:13:49 +08:00
|
|
|
totlen = 4 + EXTRACT_16BITS(&q[1]);
|
1999-10-30 13:11:06 +08:00
|
|
|
if (ep < p + totlen) {
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo,"[|attr]"));
|
1999-10-30 13:11:06 +08:00
|
|
|
return ep + 1;
|
|
|
|
}
|
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo,"("));
|
2002-12-11 15:13:49 +08:00
|
|
|
t = EXTRACT_16BITS(&q[0]) & 0x7fff;
|
1999-10-30 13:11:06 +08:00
|
|
|
if (map && t < nmap && map[t].type)
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo,"type=%s ", map[t].type));
|
1999-10-30 13:11:06 +08:00
|
|
|
else
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo,"type=#%d ", t));
|
1999-10-30 13:11:06 +08:00
|
|
|
if (p[0] & 0x80) {
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo,"value="));
|
2002-12-11 15:13:49 +08:00
|
|
|
v = EXTRACT_16BITS(&q[1]);
|
1999-10-30 13:11:06 +08:00
|
|
|
if (map && t < nmap && v < map[t].nvalue && map[t].value[v])
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo,"%s", map[t].value[v]));
|
1999-10-30 13:11:06 +08:00
|
|
|
else
|
2007-08-29 10:38:14 +08:00
|
|
|
rawprint(ndo, (caddr_t)&q[1], 2);
|
1999-10-30 13:11:06 +08:00
|
|
|
} else {
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo,"len=%d value=", EXTRACT_16BITS(&q[1])));
|
|
|
|
rawprint(ndo, (caddr_t)&p[4], EXTRACT_16BITS(&q[1]));
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo,")"));
|
1999-10-30 13:11:06 +08:00
|
|
|
return p + totlen;
|
|
|
|
}
|
|
|
|
|
2002-09-05 08:43:21 +08:00
|
|
|
static const u_char *
|
2007-08-29 10:38:14 +08:00
|
|
|
ikev1_attr_print(netdissect_options *ndo, const u_char *p, const u_char *ep)
|
1999-10-30 13:11:06 +08:00
|
|
|
{
|
2000-04-28 19:14:47 +08:00
|
|
|
u_int16_t *q;
|
1999-10-30 13:11:06 +08:00
|
|
|
int totlen;
|
|
|
|
u_int32_t t;
|
|
|
|
|
2000-04-28 19:14:47 +08:00
|
|
|
q = (u_int16_t *)p;
|
1999-10-30 13:11:06 +08:00
|
|
|
if (p[0] & 0x80)
|
|
|
|
totlen = 4;
|
|
|
|
else
|
2002-12-11 15:13:49 +08:00
|
|
|
totlen = 4 + EXTRACT_16BITS(&q[1]);
|
1999-10-30 13:11:06 +08:00
|
|
|
if (ep < p + totlen) {
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo,"[|attr]"));
|
1999-10-30 13:11:06 +08:00
|
|
|
return ep + 1;
|
|
|
|
}
|
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo,"("));
|
2002-12-11 15:13:49 +08:00
|
|
|
t = EXTRACT_16BITS(&q[0]) & 0x7fff;
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo,"type=#%d ", t));
|
1999-10-30 13:11:06 +08:00
|
|
|
if (p[0] & 0x80) {
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo,"value="));
|
1999-10-30 13:11:06 +08:00
|
|
|
t = q[1];
|
2007-08-29 10:38:14 +08:00
|
|
|
rawprint(ndo, (caddr_t)&q[1], 2);
|
1999-10-30 13:11:06 +08:00
|
|
|
} else {
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo,"len=%d value=", EXTRACT_16BITS(&q[1])));
|
|
|
|
rawprint(ndo, (caddr_t)&p[2], EXTRACT_16BITS(&q[1]));
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo,")"));
|
1999-10-30 13:11:06 +08:00
|
|
|
return p + totlen;
|
|
|
|
}
|
|
|
|
|
2002-09-05 08:43:21 +08:00
|
|
|
static const u_char *
|
2007-08-29 10:58:43 +08:00
|
|
|
ikev1_sa_print(netdissect_options *ndo, u_char tpay _U_,
|
2007-08-29 10:38:14 +08:00
|
|
|
const struct isakmp_gen *ext,
|
2004-03-25 11:30:55 +08:00
|
|
|
u_int item_len _U_,
|
|
|
|
const u_char *ep, u_int32_t phase, u_int32_t doi0 _U_,
|
|
|
|
u_int32_t proto0, int depth)
|
1999-10-30 13:11:06 +08:00
|
|
|
{
|
2007-08-29 10:38:14 +08:00
|
|
|
const struct ikev1_pl_sa *p;
|
|
|
|
struct ikev1_pl_sa sa;
|
2002-09-05 08:43:21 +08:00
|
|
|
const u_int32_t *q;
|
2000-12-12 17:20:26 +08:00
|
|
|
u_int32_t doi, sit, ident;
|
2002-09-05 08:43:21 +08:00
|
|
|
const u_char *cp, *np;
|
1999-10-30 13:11:06 +08:00
|
|
|
int t;
|
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_SA)));
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
p = (struct ikev1_pl_sa *)ext;
|
2007-08-29 20:31:00 +08:00
|
|
|
ND_TCHECK(*p);
|
2000-10-03 13:16:38 +08:00
|
|
|
safememcpy(&sa, ext, sizeof(sa));
|
|
|
|
doi = ntohl(sa.doi);
|
2000-12-12 17:20:26 +08:00
|
|
|
sit = ntohl(sa.sit);
|
1999-10-30 13:11:06 +08:00
|
|
|
if (doi != 1) {
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," doi=%d", doi));
|
|
|
|
ND_PRINT((ndo," situation=%u", (u_int32_t)ntohl(sa.sit)));
|
1999-10-30 13:11:06 +08:00
|
|
|
return (u_char *)(p + 1);
|
|
|
|
}
|
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," doi=ipsec"));
|
2000-10-03 13:16:38 +08:00
|
|
|
q = (u_int32_t *)&sa.sit;
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," situation="));
|
1999-10-30 13:11:06 +08:00
|
|
|
t = 0;
|
2000-12-12 17:20:26 +08:00
|
|
|
if (sit & 0x01) {
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo,"identity"));
|
1999-10-30 13:11:06 +08:00
|
|
|
t++;
|
|
|
|
}
|
2000-12-12 17:20:26 +08:00
|
|
|
if (sit & 0x02) {
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo,"%ssecrecy", t ? "+" : ""));
|
1999-10-30 13:11:06 +08:00
|
|
|
t++;
|
|
|
|
}
|
2000-12-12 17:20:26 +08:00
|
|
|
if (sit & 0x04)
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo,"%sintegrity", t ? "+" : ""));
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2000-12-12 17:20:26 +08:00
|
|
|
np = (u_char *)ext + sizeof(sa);
|
|
|
|
if (sit != 0x01) {
|
2007-08-29 20:31:00 +08:00
|
|
|
ND_TCHECK2(*(ext + 1), sizeof(ident));
|
2000-12-12 17:20:26 +08:00
|
|
|
safememcpy(&ident, ext + 1, sizeof(ident));
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," ident=%u", (u_int32_t)ntohl(ident)));
|
2000-12-12 17:20:26 +08:00
|
|
|
np += sizeof(ident);
|
|
|
|
}
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2000-12-12 17:20:26 +08:00
|
|
|
ext = (struct isakmp_gen *)np;
|
2007-08-29 20:31:00 +08:00
|
|
|
ND_TCHECK(*ext);
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
cp = ikev1_sub_print(ndo, ISAKMP_NPTYPE_P, ext, ep, phase, doi, proto0,
|
2002-09-05 08:43:21 +08:00
|
|
|
depth);
|
1999-10-30 13:11:06 +08:00
|
|
|
|
|
|
|
return cp;
|
2004-03-12 10:17:18 +08:00
|
|
|
trunc:
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_SA)));
|
2004-03-12 10:17:18 +08:00
|
|
|
return NULL;
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
|
|
|
|
2002-09-05 08:43:21 +08:00
|
|
|
static const u_char *
|
2007-08-29 10:58:43 +08:00
|
|
|
ikev1_p_print(netdissect_options *ndo, u_char tpay _U_,
|
2007-08-29 10:38:14 +08:00
|
|
|
const struct isakmp_gen *ext, u_int item_len _U_,
|
2004-03-25 11:30:55 +08:00
|
|
|
const u_char *ep, u_int32_t phase, u_int32_t doi0,
|
|
|
|
u_int32_t proto0 _U_, int depth)
|
1999-10-30 13:11:06 +08:00
|
|
|
{
|
2007-08-29 10:38:14 +08:00
|
|
|
const struct ikev1_pl_p *p;
|
|
|
|
struct ikev1_pl_p prop;
|
2002-09-05 08:43:21 +08:00
|
|
|
const u_char *cp;
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_P)));
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
p = (struct ikev1_pl_p *)ext;
|
2007-08-29 20:31:00 +08:00
|
|
|
ND_TCHECK(*p);
|
2000-10-03 13:16:38 +08:00
|
|
|
safememcpy(&prop, ext, sizeof(prop));
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," #%d protoid=%s transform=%d",
|
|
|
|
prop.p_no, PROTOIDSTR(prop.prot_id), prop.num_t));
|
2000-10-03 13:16:38 +08:00
|
|
|
if (prop.spi_size) {
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," spi="));
|
|
|
|
if (!rawprint(ndo, (caddr_t)(p + 1), prop.spi_size))
|
2004-03-12 10:17:18 +08:00
|
|
|
goto trunc;
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
|
|
|
|
2000-10-03 13:16:38 +08:00
|
|
|
ext = (struct isakmp_gen *)((u_char *)(p + 1) + prop.spi_size);
|
2007-08-29 20:31:00 +08:00
|
|
|
ND_TCHECK(*ext);
|
2007-08-29 10:38:14 +08:00
|
|
|
|
|
|
|
cp = ikev1_sub_print(ndo, ISAKMP_NPTYPE_T, ext, ep, phase, doi0,
|
|
|
|
prop.prot_id, depth);
|
|
|
|
|
1999-10-30 13:11:06 +08:00
|
|
|
return cp;
|
2004-03-12 10:17:18 +08:00
|
|
|
trunc:
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_P)));
|
2004-03-12 10:17:18 +08:00
|
|
|
return NULL;
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
static const char *ikev1_p_map[] = {
|
|
|
|
NULL, "ike",
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char *ikev2_t_type_map[]={
|
|
|
|
NULL, "encr", "prf", "integ", "dh", "esn"
|
|
|
|
};
|
|
|
|
|
Add a few more GCC warnings on GCC >= 2 for ".devel" builds.
From Neil T. Spring: fixes for many of those warnings:
addrtoname.c, configure.in: Linux needs netinet/ether.h for
ether_ntohost
print-*.c: change char *foo = "bar" to const char *foo = "bar"
to appease -Wwrite-strings; should affect no run-time behavior.
print-*.c: make some variables unsigned.
print-bgp.c: plen ('prefix len') is unsigned, no reason to
validate by comparing to zero.
print-cnfp.c, print-rx.c: use intoa, provided by addrtoname,
instead of inet_ntoa.
print-domain.c: unsigned int l; (l=foo()) < 0 is guaranteed to
be false, so check for (u_int)-1, which represents failure,
explicitly.
print-isakmp.c: complete initialization of attrmap objects.
print-lwres.c: "if(x); print foo;" seemed much more likely to be
intended to be "if(x) { print foo; }".
print-smb.c: complete initialization of some structures.
In addition, add some fixes for the signed vs. unsigned comparison
warnings:
extract.h: cast the result of the byte-extraction-and-combining,
as, at least for the 16-bit version, C's integral promotions
will turn "u_int16_t" into "int" if there are other "int"s
nearby.
print-*.c: make some more variables unsigned, or add casts to an
unsigned type of signed values known not to be negative, or add
casts to "int" of unsigned values known to fit in an "int", and
make other changes needed to handle the aforementioned variables
now being unsigned.
print-isakmp.c: clean up the handling of error/status indicators
in notify messages.
print-ppp.c: get rid of a check that an unsigned quantity is >=
0.
print-radius.c: clean up some of the bounds checking.
print-smb.c: extract the word count into a "u_int" to avoid the
aforementioned problems with C's integral promotions.
print-snmp.c: change a check that an unsigned variable is >= 0
to a check that it's != 0.
Also, fix some formats to use "%u" rather than "%d" for unsigned
quantities.
2002-09-05 08:00:07 +08:00
|
|
|
static const char *ah_p_map[] = {
|
2000-04-24 20:49:11 +08:00
|
|
|
NULL, "(reserved)", "md5", "sha", "1des",
|
2000-10-04 10:54:40 +08:00
|
|
|
"sha2-256", "sha2-384", "sha2-512",
|
1999-10-30 13:11:06 +08:00
|
|
|
};
|
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
static const char *prf_p_map[] = {
|
|
|
|
NULL, "hmac-md5", "hmac-sha", "hmac-tiger",
|
|
|
|
"aes128_xcbc"
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char *integ_p_map[] = {
|
|
|
|
NULL, "hmac-md5", "hmac-sha", "dec-mac",
|
|
|
|
"kpdk-md5", "aes-xcbc"
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char *esn_p_map[] = {
|
|
|
|
"no-esn", "esn"
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char *dh_p_map[] = {
|
|
|
|
NULL, "modp768",
|
|
|
|
"modp1024", /* group 2 */
|
|
|
|
"EC2N 2^155", /* group 3 */
|
|
|
|
"EC2N 2^185", /* group 4 */
|
|
|
|
"modp1536", /* group 5 */
|
|
|
|
"iana-grp06", "iana-grp07", /* reserved */
|
|
|
|
"iana-grp08", "iana-grp09",
|
|
|
|
"iana-grp10", "iana-grp11",
|
|
|
|
"iana-grp12", "iana-grp13",
|
|
|
|
"modp2048", /* group 14 */
|
|
|
|
"modp3072", /* group 15 */
|
|
|
|
"modp4096", /* group 16 */
|
|
|
|
"modp6144", /* group 17 */
|
|
|
|
"modp8192", /* group 18 */
|
|
|
|
};
|
|
|
|
|
Add a few more GCC warnings on GCC >= 2 for ".devel" builds.
From Neil T. Spring: fixes for many of those warnings:
addrtoname.c, configure.in: Linux needs netinet/ether.h for
ether_ntohost
print-*.c: change char *foo = "bar" to const char *foo = "bar"
to appease -Wwrite-strings; should affect no run-time behavior.
print-*.c: make some variables unsigned.
print-bgp.c: plen ('prefix len') is unsigned, no reason to
validate by comparing to zero.
print-cnfp.c, print-rx.c: use intoa, provided by addrtoname,
instead of inet_ntoa.
print-domain.c: unsigned int l; (l=foo()) < 0 is guaranteed to
be false, so check for (u_int)-1, which represents failure,
explicitly.
print-isakmp.c: complete initialization of attrmap objects.
print-lwres.c: "if(x); print foo;" seemed much more likely to be
intended to be "if(x) { print foo; }".
print-smb.c: complete initialization of some structures.
In addition, add some fixes for the signed vs. unsigned comparison
warnings:
extract.h: cast the result of the byte-extraction-and-combining,
as, at least for the 16-bit version, C's integral promotions
will turn "u_int16_t" into "int" if there are other "int"s
nearby.
print-*.c: make some more variables unsigned, or add casts to an
unsigned type of signed values known not to be negative, or add
casts to "int" of unsigned values known to fit in an "int", and
make other changes needed to handle the aforementioned variables
now being unsigned.
print-isakmp.c: clean up the handling of error/status indicators
in notify messages.
print-ppp.c: get rid of a check that an unsigned quantity is >=
0.
print-radius.c: clean up some of the bounds checking.
print-smb.c: extract the word count into a "u_int" to avoid the
aforementioned problems with C's integral promotions.
print-snmp.c: change a check that an unsigned variable is >= 0
to a check that it's != 0.
Also, fix some formats to use "%u" rather than "%d" for unsigned
quantities.
2002-09-05 08:00:07 +08:00
|
|
|
static const char *esp_p_map[] = {
|
1999-10-30 13:11:06 +08:00
|
|
|
NULL, "1des-iv64", "1des", "3des", "rc5", "idea", "cast",
|
2000-10-04 10:54:40 +08:00
|
|
|
"blowfish", "3idea", "1des-iv32", "rc4", "null", "aes"
|
1999-10-30 13:11:06 +08:00
|
|
|
};
|
|
|
|
|
Add a few more GCC warnings on GCC >= 2 for ".devel" builds.
From Neil T. Spring: fixes for many of those warnings:
addrtoname.c, configure.in: Linux needs netinet/ether.h for
ether_ntohost
print-*.c: change char *foo = "bar" to const char *foo = "bar"
to appease -Wwrite-strings; should affect no run-time behavior.
print-*.c: make some variables unsigned.
print-bgp.c: plen ('prefix len') is unsigned, no reason to
validate by comparing to zero.
print-cnfp.c, print-rx.c: use intoa, provided by addrtoname,
instead of inet_ntoa.
print-domain.c: unsigned int l; (l=foo()) < 0 is guaranteed to
be false, so check for (u_int)-1, which represents failure,
explicitly.
print-isakmp.c: complete initialization of attrmap objects.
print-lwres.c: "if(x); print foo;" seemed much more likely to be
intended to be "if(x) { print foo; }".
print-smb.c: complete initialization of some structures.
In addition, add some fixes for the signed vs. unsigned comparison
warnings:
extract.h: cast the result of the byte-extraction-and-combining,
as, at least for the 16-bit version, C's integral promotions
will turn "u_int16_t" into "int" if there are other "int"s
nearby.
print-*.c: make some more variables unsigned, or add casts to an
unsigned type of signed values known not to be negative, or add
casts to "int" of unsigned values known to fit in an "int", and
make other changes needed to handle the aforementioned variables
now being unsigned.
print-isakmp.c: clean up the handling of error/status indicators
in notify messages.
print-ppp.c: get rid of a check that an unsigned quantity is >=
0.
print-radius.c: clean up some of the bounds checking.
print-smb.c: extract the word count into a "u_int" to avoid the
aforementioned problems with C's integral promotions.
print-snmp.c: change a check that an unsigned variable is >= 0
to a check that it's != 0.
Also, fix some formats to use "%u" rather than "%d" for unsigned
quantities.
2002-09-05 08:00:07 +08:00
|
|
|
static const char *ipcomp_p_map[] = {
|
1999-10-30 13:11:06 +08:00
|
|
|
NULL, "oui", "deflate", "lzs",
|
|
|
|
};
|
|
|
|
|
2002-09-05 08:43:21 +08:00
|
|
|
const struct attrmap ipsec_t_map[] = {
|
Add a few more GCC warnings on GCC >= 2 for ".devel" builds.
From Neil T. Spring: fixes for many of those warnings:
addrtoname.c, configure.in: Linux needs netinet/ether.h for
ether_ntohost
print-*.c: change char *foo = "bar" to const char *foo = "bar"
to appease -Wwrite-strings; should affect no run-time behavior.
print-*.c: make some variables unsigned.
print-bgp.c: plen ('prefix len') is unsigned, no reason to
validate by comparing to zero.
print-cnfp.c, print-rx.c: use intoa, provided by addrtoname,
instead of inet_ntoa.
print-domain.c: unsigned int l; (l=foo()) < 0 is guaranteed to
be false, so check for (u_int)-1, which represents failure,
explicitly.
print-isakmp.c: complete initialization of attrmap objects.
print-lwres.c: "if(x); print foo;" seemed much more likely to be
intended to be "if(x) { print foo; }".
print-smb.c: complete initialization of some structures.
In addition, add some fixes for the signed vs. unsigned comparison
warnings:
extract.h: cast the result of the byte-extraction-and-combining,
as, at least for the 16-bit version, C's integral promotions
will turn "u_int16_t" into "int" if there are other "int"s
nearby.
print-*.c: make some more variables unsigned, or add casts to an
unsigned type of signed values known not to be negative, or add
casts to "int" of unsigned values known to fit in an "int", and
make other changes needed to handle the aforementioned variables
now being unsigned.
print-isakmp.c: clean up the handling of error/status indicators
in notify messages.
print-ppp.c: get rid of a check that an unsigned quantity is >=
0.
print-radius.c: clean up some of the bounds checking.
print-smb.c: extract the word count into a "u_int" to avoid the
aforementioned problems with C's integral promotions.
print-snmp.c: change a check that an unsigned variable is >= 0
to a check that it's != 0.
Also, fix some formats to use "%u" rather than "%d" for unsigned
quantities.
2002-09-05 08:00:07 +08:00
|
|
|
{ NULL, 0, { NULL } },
|
1999-10-30 13:11:06 +08:00
|
|
|
{ "lifetype", 3, { NULL, "sec", "kb", }, },
|
Add a few more GCC warnings on GCC >= 2 for ".devel" builds.
From Neil T. Spring: fixes for many of those warnings:
addrtoname.c, configure.in: Linux needs netinet/ether.h for
ether_ntohost
print-*.c: change char *foo = "bar" to const char *foo = "bar"
to appease -Wwrite-strings; should affect no run-time behavior.
print-*.c: make some variables unsigned.
print-bgp.c: plen ('prefix len') is unsigned, no reason to
validate by comparing to zero.
print-cnfp.c, print-rx.c: use intoa, provided by addrtoname,
instead of inet_ntoa.
print-domain.c: unsigned int l; (l=foo()) < 0 is guaranteed to
be false, so check for (u_int)-1, which represents failure,
explicitly.
print-isakmp.c: complete initialization of attrmap objects.
print-lwres.c: "if(x); print foo;" seemed much more likely to be
intended to be "if(x) { print foo; }".
print-smb.c: complete initialization of some structures.
In addition, add some fixes for the signed vs. unsigned comparison
warnings:
extract.h: cast the result of the byte-extraction-and-combining,
as, at least for the 16-bit version, C's integral promotions
will turn "u_int16_t" into "int" if there are other "int"s
nearby.
print-*.c: make some more variables unsigned, or add casts to an
unsigned type of signed values known not to be negative, or add
casts to "int" of unsigned values known to fit in an "int", and
make other changes needed to handle the aforementioned variables
now being unsigned.
print-isakmp.c: clean up the handling of error/status indicators
in notify messages.
print-ppp.c: get rid of a check that an unsigned quantity is >=
0.
print-radius.c: clean up some of the bounds checking.
print-smb.c: extract the word count into a "u_int" to avoid the
aforementioned problems with C's integral promotions.
print-snmp.c: change a check that an unsigned variable is >= 0
to a check that it's != 0.
Also, fix some formats to use "%u" rather than "%d" for unsigned
quantities.
2002-09-05 08:00:07 +08:00
|
|
|
{ "life", 0, { NULL } },
|
2006-08-28 02:48:29 +08:00
|
|
|
{ "group desc", 18, { NULL, "modp768",
|
2006-08-28 02:46:39 +08:00
|
|
|
"modp1024", /* group 2 */
|
|
|
|
"EC2N 2^155", /* group 3 */
|
|
|
|
"EC2N 2^185", /* group 4 */
|
|
|
|
"modp1536", /* group 5 */
|
|
|
|
"iana-grp06", "iana-grp07", /* reserved */
|
|
|
|
"iana-grp08", "iana-grp09",
|
|
|
|
"iana-grp10", "iana-grp11",
|
|
|
|
"iana-grp12", "iana-grp13",
|
|
|
|
"modp2048", /* group 14 */
|
|
|
|
"modp3072", /* group 15 */
|
|
|
|
"modp4096", /* group 16 */
|
|
|
|
"modp6144", /* group 17 */
|
|
|
|
"modp8192", /* group 18 */
|
|
|
|
}, },
|
1999-10-30 13:11:06 +08:00
|
|
|
{ "enc mode", 3, { NULL, "tunnel", "transport", }, },
|
|
|
|
{ "auth", 5, { NULL, "hmac-md5", "hmac-sha1", "1des-mac", "keyed", }, },
|
Add a few more GCC warnings on GCC >= 2 for ".devel" builds.
From Neil T. Spring: fixes for many of those warnings:
addrtoname.c, configure.in: Linux needs netinet/ether.h for
ether_ntohost
print-*.c: change char *foo = "bar" to const char *foo = "bar"
to appease -Wwrite-strings; should affect no run-time behavior.
print-*.c: make some variables unsigned.
print-bgp.c: plen ('prefix len') is unsigned, no reason to
validate by comparing to zero.
print-cnfp.c, print-rx.c: use intoa, provided by addrtoname,
instead of inet_ntoa.
print-domain.c: unsigned int l; (l=foo()) < 0 is guaranteed to
be false, so check for (u_int)-1, which represents failure,
explicitly.
print-isakmp.c: complete initialization of attrmap objects.
print-lwres.c: "if(x); print foo;" seemed much more likely to be
intended to be "if(x) { print foo; }".
print-smb.c: complete initialization of some structures.
In addition, add some fixes for the signed vs. unsigned comparison
warnings:
extract.h: cast the result of the byte-extraction-and-combining,
as, at least for the 16-bit version, C's integral promotions
will turn "u_int16_t" into "int" if there are other "int"s
nearby.
print-*.c: make some more variables unsigned, or add casts to an
unsigned type of signed values known not to be negative, or add
casts to "int" of unsigned values known to fit in an "int", and
make other changes needed to handle the aforementioned variables
now being unsigned.
print-isakmp.c: clean up the handling of error/status indicators
in notify messages.
print-ppp.c: get rid of a check that an unsigned quantity is >=
0.
print-radius.c: clean up some of the bounds checking.
print-smb.c: extract the word count into a "u_int" to avoid the
aforementioned problems with C's integral promotions.
print-snmp.c: change a check that an unsigned variable is >= 0
to a check that it's != 0.
Also, fix some formats to use "%u" rather than "%d" for unsigned
quantities.
2002-09-05 08:00:07 +08:00
|
|
|
{ "keylen", 0, { NULL } },
|
|
|
|
{ "rounds", 0, { NULL } },
|
|
|
|
{ "dictsize", 0, { NULL } },
|
|
|
|
{ "privalg", 0, { NULL } },
|
1999-10-30 13:11:06 +08:00
|
|
|
};
|
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
const struct attrmap encr_t_map[] = {
|
|
|
|
{ NULL, 0, { NULL } }, { NULL, 0, { NULL } }, /* 0, 1 */
|
|
|
|
{ NULL, 0, { NULL } }, { NULL, 0, { NULL } }, /* 2, 3 */
|
|
|
|
{ NULL, 0, { NULL } }, { NULL, 0, { NULL } }, /* 4, 5 */
|
|
|
|
{ NULL, 0, { NULL } }, { NULL, 0, { NULL } }, /* 6, 7 */
|
|
|
|
{ NULL, 0, { NULL } }, { NULL, 0, { NULL } }, /* 8, 9 */
|
|
|
|
{ NULL, 0, { NULL } }, { NULL, 0, { NULL } }, /* 10,11*/
|
|
|
|
{ NULL, 0, { NULL } }, { NULL, 0, { NULL } }, /* 12,13*/
|
|
|
|
{ "keylen", 14, { NULL }},
|
|
|
|
};
|
|
|
|
|
2002-09-05 08:43:21 +08:00
|
|
|
const struct attrmap oakley_t_map[] = {
|
Add a few more GCC warnings on GCC >= 2 for ".devel" builds.
From Neil T. Spring: fixes for many of those warnings:
addrtoname.c, configure.in: Linux needs netinet/ether.h for
ether_ntohost
print-*.c: change char *foo = "bar" to const char *foo = "bar"
to appease -Wwrite-strings; should affect no run-time behavior.
print-*.c: make some variables unsigned.
print-bgp.c: plen ('prefix len') is unsigned, no reason to
validate by comparing to zero.
print-cnfp.c, print-rx.c: use intoa, provided by addrtoname,
instead of inet_ntoa.
print-domain.c: unsigned int l; (l=foo()) < 0 is guaranteed to
be false, so check for (u_int)-1, which represents failure,
explicitly.
print-isakmp.c: complete initialization of attrmap objects.
print-lwres.c: "if(x); print foo;" seemed much more likely to be
intended to be "if(x) { print foo; }".
print-smb.c: complete initialization of some structures.
In addition, add some fixes for the signed vs. unsigned comparison
warnings:
extract.h: cast the result of the byte-extraction-and-combining,
as, at least for the 16-bit version, C's integral promotions
will turn "u_int16_t" into "int" if there are other "int"s
nearby.
print-*.c: make some more variables unsigned, or add casts to an
unsigned type of signed values known not to be negative, or add
casts to "int" of unsigned values known to fit in an "int", and
make other changes needed to handle the aforementioned variables
now being unsigned.
print-isakmp.c: clean up the handling of error/status indicators
in notify messages.
print-ppp.c: get rid of a check that an unsigned quantity is >=
0.
print-radius.c: clean up some of the bounds checking.
print-smb.c: extract the word count into a "u_int" to avoid the
aforementioned problems with C's integral promotions.
print-snmp.c: change a check that an unsigned variable is >= 0
to a check that it's != 0.
Also, fix some formats to use "%u" rather than "%d" for unsigned
quantities.
2002-09-05 08:00:07 +08:00
|
|
|
{ NULL, 0, { NULL } },
|
2000-10-04 10:54:40 +08:00
|
|
|
{ "enc", 8, { NULL, "1des", "idea", "blowfish", "rc5",
|
|
|
|
"3des", "cast", "aes", }, },
|
|
|
|
{ "hash", 7, { NULL, "md5", "sha1", "tiger",
|
|
|
|
"sha2-256", "sha2-384", "sha2-512", }, },
|
1999-10-30 13:11:06 +08:00
|
|
|
{ "auth", 6, { NULL, "preshared", "dss", "rsa sig", "rsa enc",
|
|
|
|
"rsa enc revised", }, },
|
2006-08-28 02:48:29 +08:00
|
|
|
{ "group desc", 18, { NULL, "modp768",
|
2006-08-28 02:46:39 +08:00
|
|
|
"modp1024", /* group 2 */
|
|
|
|
"EC2N 2^155", /* group 3 */
|
|
|
|
"EC2N 2^185", /* group 4 */
|
|
|
|
"modp1536", /* group 5 */
|
|
|
|
"iana-grp06", "iana-grp07", /* reserved */
|
|
|
|
"iana-grp08", "iana-grp09",
|
|
|
|
"iana-grp10", "iana-grp11",
|
|
|
|
"iana-grp12", "iana-grp13",
|
|
|
|
"modp2048", /* group 14 */
|
|
|
|
"modp3072", /* group 15 */
|
|
|
|
"modp4096", /* group 16 */
|
|
|
|
"modp6144", /* group 17 */
|
|
|
|
"modp8192", /* group 18 */
|
|
|
|
}, },
|
1999-10-30 13:11:06 +08:00
|
|
|
{ "group type", 4, { NULL, "MODP", "ECP", "EC2N", }, },
|
Add a few more GCC warnings on GCC >= 2 for ".devel" builds.
From Neil T. Spring: fixes for many of those warnings:
addrtoname.c, configure.in: Linux needs netinet/ether.h for
ether_ntohost
print-*.c: change char *foo = "bar" to const char *foo = "bar"
to appease -Wwrite-strings; should affect no run-time behavior.
print-*.c: make some variables unsigned.
print-bgp.c: plen ('prefix len') is unsigned, no reason to
validate by comparing to zero.
print-cnfp.c, print-rx.c: use intoa, provided by addrtoname,
instead of inet_ntoa.
print-domain.c: unsigned int l; (l=foo()) < 0 is guaranteed to
be false, so check for (u_int)-1, which represents failure,
explicitly.
print-isakmp.c: complete initialization of attrmap objects.
print-lwres.c: "if(x); print foo;" seemed much more likely to be
intended to be "if(x) { print foo; }".
print-smb.c: complete initialization of some structures.
In addition, add some fixes for the signed vs. unsigned comparison
warnings:
extract.h: cast the result of the byte-extraction-and-combining,
as, at least for the 16-bit version, C's integral promotions
will turn "u_int16_t" into "int" if there are other "int"s
nearby.
print-*.c: make some more variables unsigned, or add casts to an
unsigned type of signed values known not to be negative, or add
casts to "int" of unsigned values known to fit in an "int", and
make other changes needed to handle the aforementioned variables
now being unsigned.
print-isakmp.c: clean up the handling of error/status indicators
in notify messages.
print-ppp.c: get rid of a check that an unsigned quantity is >=
0.
print-radius.c: clean up some of the bounds checking.
print-smb.c: extract the word count into a "u_int" to avoid the
aforementioned problems with C's integral promotions.
print-snmp.c: change a check that an unsigned variable is >= 0
to a check that it's != 0.
Also, fix some formats to use "%u" rather than "%d" for unsigned
quantities.
2002-09-05 08:00:07 +08:00
|
|
|
{ "group prime", 0, { NULL } },
|
|
|
|
{ "group gen1", 0, { NULL } },
|
|
|
|
{ "group gen2", 0, { NULL } },
|
|
|
|
{ "group curve A", 0, { NULL } },
|
|
|
|
{ "group curve B", 0, { NULL } },
|
1999-10-30 13:11:06 +08:00
|
|
|
{ "lifetype", 3, { NULL, "sec", "kb", }, },
|
Add a few more GCC warnings on GCC >= 2 for ".devel" builds.
From Neil T. Spring: fixes for many of those warnings:
addrtoname.c, configure.in: Linux needs netinet/ether.h for
ether_ntohost
print-*.c: change char *foo = "bar" to const char *foo = "bar"
to appease -Wwrite-strings; should affect no run-time behavior.
print-*.c: make some variables unsigned.
print-bgp.c: plen ('prefix len') is unsigned, no reason to
validate by comparing to zero.
print-cnfp.c, print-rx.c: use intoa, provided by addrtoname,
instead of inet_ntoa.
print-domain.c: unsigned int l; (l=foo()) < 0 is guaranteed to
be false, so check for (u_int)-1, which represents failure,
explicitly.
print-isakmp.c: complete initialization of attrmap objects.
print-lwres.c: "if(x); print foo;" seemed much more likely to be
intended to be "if(x) { print foo; }".
print-smb.c: complete initialization of some structures.
In addition, add some fixes for the signed vs. unsigned comparison
warnings:
extract.h: cast the result of the byte-extraction-and-combining,
as, at least for the 16-bit version, C's integral promotions
will turn "u_int16_t" into "int" if there are other "int"s
nearby.
print-*.c: make some more variables unsigned, or add casts to an
unsigned type of signed values known not to be negative, or add
casts to "int" of unsigned values known to fit in an "int", and
make other changes needed to handle the aforementioned variables
now being unsigned.
print-isakmp.c: clean up the handling of error/status indicators
in notify messages.
print-ppp.c: get rid of a check that an unsigned quantity is >=
0.
print-radius.c: clean up some of the bounds checking.
print-smb.c: extract the word count into a "u_int" to avoid the
aforementioned problems with C's integral promotions.
print-snmp.c: change a check that an unsigned variable is >= 0
to a check that it's != 0.
Also, fix some formats to use "%u" rather than "%d" for unsigned
quantities.
2002-09-05 08:00:07 +08:00
|
|
|
{ "lifeduration", 0, { NULL } },
|
|
|
|
{ "prf", 0, { NULL } },
|
|
|
|
{ "keylen", 0, { NULL } },
|
|
|
|
{ "field", 0, { NULL } },
|
|
|
|
{ "order", 0, { NULL } },
|
1999-10-30 13:11:06 +08:00
|
|
|
};
|
|
|
|
|
2002-09-05 08:43:21 +08:00
|
|
|
static const u_char *
|
2007-08-29 10:58:43 +08:00
|
|
|
ikev1_t_print(netdissect_options *ndo, u_char tpay _U_,
|
2007-08-29 10:38:14 +08:00
|
|
|
const struct isakmp_gen *ext, u_int item_len,
|
|
|
|
const u_char *ep, u_int32_t phase _U_, u_int32_t doi _U_,
|
|
|
|
u_int32_t proto, int depth _U_)
|
1999-10-30 13:11:06 +08:00
|
|
|
{
|
2007-08-29 10:38:14 +08:00
|
|
|
const struct ikev1_pl_t *p;
|
|
|
|
struct ikev1_pl_t t;
|
2002-09-05 08:43:21 +08:00
|
|
|
const u_char *cp;
|
Add a few more GCC warnings on GCC >= 2 for ".devel" builds.
From Neil T. Spring: fixes for many of those warnings:
addrtoname.c, configure.in: Linux needs netinet/ether.h for
ether_ntohost
print-*.c: change char *foo = "bar" to const char *foo = "bar"
to appease -Wwrite-strings; should affect no run-time behavior.
print-*.c: make some variables unsigned.
print-bgp.c: plen ('prefix len') is unsigned, no reason to
validate by comparing to zero.
print-cnfp.c, print-rx.c: use intoa, provided by addrtoname,
instead of inet_ntoa.
print-domain.c: unsigned int l; (l=foo()) < 0 is guaranteed to
be false, so check for (u_int)-1, which represents failure,
explicitly.
print-isakmp.c: complete initialization of attrmap objects.
print-lwres.c: "if(x); print foo;" seemed much more likely to be
intended to be "if(x) { print foo; }".
print-smb.c: complete initialization of some structures.
In addition, add some fixes for the signed vs. unsigned comparison
warnings:
extract.h: cast the result of the byte-extraction-and-combining,
as, at least for the 16-bit version, C's integral promotions
will turn "u_int16_t" into "int" if there are other "int"s
nearby.
print-*.c: make some more variables unsigned, or add casts to an
unsigned type of signed values known not to be negative, or add
casts to "int" of unsigned values known to fit in an "int", and
make other changes needed to handle the aforementioned variables
now being unsigned.
print-isakmp.c: clean up the handling of error/status indicators
in notify messages.
print-ppp.c: get rid of a check that an unsigned quantity is >=
0.
print-radius.c: clean up some of the bounds checking.
print-smb.c: extract the word count into a "u_int" to avoid the
aforementioned problems with C's integral promotions.
print-snmp.c: change a check that an unsigned variable is >= 0
to a check that it's != 0.
Also, fix some formats to use "%u" rather than "%d" for unsigned
quantities.
2002-09-05 08:00:07 +08:00
|
|
|
const char *idstr;
|
2002-09-05 08:43:21 +08:00
|
|
|
const struct attrmap *map;
|
1999-10-30 13:11:06 +08:00
|
|
|
size_t nmap;
|
2002-09-05 08:43:21 +08:00
|
|
|
const u_char *ep2;
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_T)));
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
p = (struct ikev1_pl_t *)ext;
|
2007-08-29 20:31:00 +08:00
|
|
|
ND_TCHECK(*p);
|
2000-10-03 13:16:38 +08:00
|
|
|
safememcpy(&t, ext, sizeof(t));
|
1999-10-30 13:11:06 +08:00
|
|
|
|
|
|
|
switch (proto) {
|
|
|
|
case 1:
|
2007-08-29 10:38:14 +08:00
|
|
|
idstr = STR_OR_ID(t.t_id, ikev1_p_map);
|
1999-10-30 13:11:06 +08:00
|
|
|
map = oakley_t_map;
|
|
|
|
nmap = sizeof(oakley_t_map)/sizeof(oakley_t_map[0]);
|
|
|
|
break;
|
|
|
|
case 2:
|
2000-10-03 13:16:38 +08:00
|
|
|
idstr = STR_OR_ID(t.t_id, ah_p_map);
|
1999-10-30 13:11:06 +08:00
|
|
|
map = ipsec_t_map;
|
|
|
|
nmap = sizeof(ipsec_t_map)/sizeof(ipsec_t_map[0]);
|
|
|
|
break;
|
|
|
|
case 3:
|
2000-10-03 13:16:38 +08:00
|
|
|
idstr = STR_OR_ID(t.t_id, esp_p_map);
|
1999-10-30 13:11:06 +08:00
|
|
|
map = ipsec_t_map;
|
|
|
|
nmap = sizeof(ipsec_t_map)/sizeof(ipsec_t_map[0]);
|
|
|
|
break;
|
|
|
|
case 4:
|
2000-10-03 13:16:38 +08:00
|
|
|
idstr = STR_OR_ID(t.t_id, ipcomp_p_map);
|
1999-10-30 13:11:06 +08:00
|
|
|
map = ipsec_t_map;
|
|
|
|
nmap = sizeof(ipsec_t_map)/sizeof(ipsec_t_map[0]);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
idstr = NULL;
|
|
|
|
map = NULL;
|
|
|
|
nmap = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (idstr)
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," #%d id=%s ", t.t_no, idstr));
|
1999-10-30 13:11:06 +08:00
|
|
|
else
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," #%d id=%d ", t.t_no, t.t_id));
|
1999-10-30 13:11:06 +08:00
|
|
|
cp = (u_char *)(p + 1);
|
2004-03-12 09:26:59 +08:00
|
|
|
ep2 = (u_char *)p + item_len;
|
1999-10-30 13:11:06 +08:00
|
|
|
while (cp < ep && cp < ep2) {
|
|
|
|
if (map && nmap) {
|
2007-08-29 10:38:14 +08:00
|
|
|
cp = ikev1_attrmap_print(ndo, cp, (ep < ep2) ? ep : ep2,
|
1999-10-30 13:11:06 +08:00
|
|
|
map, nmap);
|
|
|
|
} else
|
2007-08-29 10:38:14 +08:00
|
|
|
cp = ikev1_attr_print(ndo, cp, (ep < ep2) ? ep : ep2);
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
|
|
|
if (ep < ep2)
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo,"..."));
|
1999-10-30 13:11:06 +08:00
|
|
|
return cp;
|
2004-03-12 10:17:18 +08:00
|
|
|
trunc:
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_T)));
|
2004-03-12 10:17:18 +08:00
|
|
|
return NULL;
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
|
|
|
|
2002-09-05 08:43:21 +08:00
|
|
|
static const u_char *
|
2007-08-29 10:58:43 +08:00
|
|
|
ikev1_ke_print(netdissect_options *ndo, u_char tpay _U_,
|
2007-08-29 10:38:14 +08:00
|
|
|
const struct isakmp_gen *ext, u_int item_len _U_,
|
|
|
|
const u_char *ep _U_, u_int32_t phase _U_, u_int32_t doi _U_,
|
|
|
|
u_int32_t proto _U_, int depth _U_)
|
1999-10-30 13:11:06 +08:00
|
|
|
{
|
2000-10-03 13:16:38 +08:00
|
|
|
struct isakmp_gen e;
|
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_KE)));
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2007-08-29 20:31:00 +08:00
|
|
|
ND_TCHECK(*ext);
|
2000-10-03 13:16:38 +08:00
|
|
|
safememcpy(&e, ext, sizeof(e));
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," key len=%d", ntohs(e.len) - 4));
|
2007-08-29 20:31:00 +08:00
|
|
|
if (2 < ndo->ndo_vflag && 4 < ntohs(e.len)) {
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," "));
|
|
|
|
if (!rawprint(ndo, (caddr_t)(ext + 1), ntohs(e.len) - 4))
|
2004-03-12 10:17:18 +08:00
|
|
|
goto trunc;
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
2000-10-03 13:16:38 +08:00
|
|
|
return (u_char *)ext + ntohs(e.len);
|
2004-03-12 10:17:18 +08:00
|
|
|
trunc:
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_KE)));
|
2004-03-12 10:17:18 +08:00
|
|
|
return NULL;
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
|
|
|
|
2002-09-05 08:43:21 +08:00
|
|
|
static const u_char *
|
2007-08-29 10:58:43 +08:00
|
|
|
ikev1_id_print(netdissect_options *ndo, u_char tpay _U_,
|
2007-08-29 10:38:14 +08:00
|
|
|
const struct isakmp_gen *ext, u_int item_len _U_,
|
|
|
|
const u_char *ep _U_, u_int32_t phase, u_int32_t doi _U_,
|
|
|
|
u_int32_t proto _U_, int depth _U_)
|
1999-10-30 13:11:06 +08:00
|
|
|
{
|
|
|
|
#define USE_IPSECDOI_IN_PHASE1 1
|
2007-08-29 10:38:14 +08:00
|
|
|
const struct ikev1_pl_id *p;
|
|
|
|
struct ikev1_pl_id id;
|
Add a few more GCC warnings on GCC >= 2 for ".devel" builds.
From Neil T. Spring: fixes for many of those warnings:
addrtoname.c, configure.in: Linux needs netinet/ether.h for
ether_ntohost
print-*.c: change char *foo = "bar" to const char *foo = "bar"
to appease -Wwrite-strings; should affect no run-time behavior.
print-*.c: make some variables unsigned.
print-bgp.c: plen ('prefix len') is unsigned, no reason to
validate by comparing to zero.
print-cnfp.c, print-rx.c: use intoa, provided by addrtoname,
instead of inet_ntoa.
print-domain.c: unsigned int l; (l=foo()) < 0 is guaranteed to
be false, so check for (u_int)-1, which represents failure,
explicitly.
print-isakmp.c: complete initialization of attrmap objects.
print-lwres.c: "if(x); print foo;" seemed much more likely to be
intended to be "if(x) { print foo; }".
print-smb.c: complete initialization of some structures.
In addition, add some fixes for the signed vs. unsigned comparison
warnings:
extract.h: cast the result of the byte-extraction-and-combining,
as, at least for the 16-bit version, C's integral promotions
will turn "u_int16_t" into "int" if there are other "int"s
nearby.
print-*.c: make some more variables unsigned, or add casts to an
unsigned type of signed values known not to be negative, or add
casts to "int" of unsigned values known to fit in an "int", and
make other changes needed to handle the aforementioned variables
now being unsigned.
print-isakmp.c: clean up the handling of error/status indicators
in notify messages.
print-ppp.c: get rid of a check that an unsigned quantity is >=
0.
print-radius.c: clean up some of the bounds checking.
print-smb.c: extract the word count into a "u_int" to avoid the
aforementioned problems with C's integral promotions.
print-snmp.c: change a check that an unsigned variable is >= 0
to a check that it's != 0.
Also, fix some formats to use "%u" rather than "%d" for unsigned
quantities.
2002-09-05 08:00:07 +08:00
|
|
|
static const char *idtypestr[] = {
|
1999-10-30 13:11:06 +08:00
|
|
|
"IPv4", "IPv4net", "IPv6", "IPv6net",
|
|
|
|
};
|
Add a few more GCC warnings on GCC >= 2 for ".devel" builds.
From Neil T. Spring: fixes for many of those warnings:
addrtoname.c, configure.in: Linux needs netinet/ether.h for
ether_ntohost
print-*.c: change char *foo = "bar" to const char *foo = "bar"
to appease -Wwrite-strings; should affect no run-time behavior.
print-*.c: make some variables unsigned.
print-bgp.c: plen ('prefix len') is unsigned, no reason to
validate by comparing to zero.
print-cnfp.c, print-rx.c: use intoa, provided by addrtoname,
instead of inet_ntoa.
print-domain.c: unsigned int l; (l=foo()) < 0 is guaranteed to
be false, so check for (u_int)-1, which represents failure,
explicitly.
print-isakmp.c: complete initialization of attrmap objects.
print-lwres.c: "if(x); print foo;" seemed much more likely to be
intended to be "if(x) { print foo; }".
print-smb.c: complete initialization of some structures.
In addition, add some fixes for the signed vs. unsigned comparison
warnings:
extract.h: cast the result of the byte-extraction-and-combining,
as, at least for the 16-bit version, C's integral promotions
will turn "u_int16_t" into "int" if there are other "int"s
nearby.
print-*.c: make some more variables unsigned, or add casts to an
unsigned type of signed values known not to be negative, or add
casts to "int" of unsigned values known to fit in an "int", and
make other changes needed to handle the aforementioned variables
now being unsigned.
print-isakmp.c: clean up the handling of error/status indicators
in notify messages.
print-ppp.c: get rid of a check that an unsigned quantity is >=
0.
print-radius.c: clean up some of the bounds checking.
print-smb.c: extract the word count into a "u_int" to avoid the
aforementioned problems with C's integral promotions.
print-snmp.c: change a check that an unsigned variable is >= 0
to a check that it's != 0.
Also, fix some formats to use "%u" rather than "%d" for unsigned
quantities.
2002-09-05 08:00:07 +08:00
|
|
|
static const char *ipsecidtypestr[] = {
|
1999-10-30 13:11:06 +08:00
|
|
|
NULL, "IPv4", "FQDN", "user FQDN", "IPv4net", "IPv6",
|
|
|
|
"IPv6net", "IPv4range", "IPv6range", "ASN1 DN", "ASN1 GN",
|
|
|
|
"keyid",
|
|
|
|
};
|
|
|
|
int len;
|
2002-09-05 08:43:21 +08:00
|
|
|
const u_char *data;
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_ID)));
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
p = (struct ikev1_pl_id *)ext;
|
2007-08-29 20:31:00 +08:00
|
|
|
ND_TCHECK(*p);
|
2000-10-03 13:16:38 +08:00
|
|
|
safememcpy(&id, ext, sizeof(id));
|
2004-03-12 09:26:59 +08:00
|
|
|
if (sizeof(*p) < item_len) {
|
1999-10-30 13:11:06 +08:00
|
|
|
data = (u_char *)(p + 1);
|
2004-03-12 09:26:59 +08:00
|
|
|
len = item_len - sizeof(*p);
|
|
|
|
} else {
|
1999-10-30 13:11:06 +08:00
|
|
|
data = NULL;
|
2004-03-12 09:26:59 +08:00
|
|
|
len = 0;
|
|
|
|
}
|
1999-10-30 13:11:06 +08:00
|
|
|
|
|
|
|
#if 0 /*debug*/
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," [phase=%d doi=%d proto=%d]", phase, doi, proto));
|
1999-10-30 13:11:06 +08:00
|
|
|
#endif
|
|
|
|
switch (phase) {
|
|
|
|
#ifndef USE_IPSECDOI_IN_PHASE1
|
|
|
|
case 1:
|
|
|
|
#endif
|
|
|
|
default:
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," idtype=%s", STR_OR_ID(id.d.id_type, idtypestr)));
|
|
|
|
ND_PRINT((ndo," doi_data=%u",
|
|
|
|
(u_int32_t)(ntohl(id.d.doi_data) & 0xffffff)));
|
1999-10-30 13:11:06 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
#ifdef USE_IPSECDOI_IN_PHASE1
|
|
|
|
case 1:
|
|
|
|
#endif
|
|
|
|
case 2:
|
|
|
|
{
|
2002-09-05 08:43:21 +08:00
|
|
|
const struct ipsecdoi_id *p;
|
|
|
|
struct ipsecdoi_id id;
|
1999-10-30 13:11:06 +08:00
|
|
|
struct protoent *pe;
|
|
|
|
|
|
|
|
p = (struct ipsecdoi_id *)ext;
|
2007-08-29 20:31:00 +08:00
|
|
|
ND_TCHECK(*p);
|
2000-10-03 13:16:38 +08:00
|
|
|
safememcpy(&id, ext, sizeof(id));
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," idtype=%s", STR_OR_ID(id.type, ipsecidtypestr)));
|
2000-10-03 13:16:38 +08:00
|
|
|
if (id.proto_id) {
|
2002-08-01 16:52:55 +08:00
|
|
|
#ifndef WIN32
|
2000-09-23 04:35:34 +08:00
|
|
|
setprotoent(1);
|
2002-08-01 16:52:55 +08:00
|
|
|
#endif /* WIN32 */
|
2000-10-03 13:16:38 +08:00
|
|
|
pe = getprotobynumber(id.proto_id);
|
2000-09-23 04:35:34 +08:00
|
|
|
if (pe)
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," protoid=%s", pe->p_name));
|
2002-08-01 16:52:55 +08:00
|
|
|
#ifndef WIN32
|
2000-09-23 04:35:34 +08:00
|
|
|
endprotoent();
|
2002-08-01 16:52:55 +08:00
|
|
|
#endif /* WIN32 */
|
2000-09-23 04:35:34 +08:00
|
|
|
} else {
|
|
|
|
/* it DOES NOT mean IPPROTO_IP! */
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," protoid=%s", "0"));
|
2000-09-23 04:35:34 +08:00
|
|
|
}
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," port=%d", ntohs(id.port)));
|
1999-10-30 13:11:06 +08:00
|
|
|
if (!len)
|
|
|
|
break;
|
2004-03-12 10:17:18 +08:00
|
|
|
if (data == NULL)
|
|
|
|
goto trunc;
|
2007-08-29 20:31:00 +08:00
|
|
|
ND_TCHECK2(*data, len);
|
2000-10-03 13:16:38 +08:00
|
|
|
switch (id.type) {
|
1999-10-30 13:11:06 +08:00
|
|
|
case IPSECDOI_ID_IPV4_ADDR:
|
2004-03-24 09:32:20 +08:00
|
|
|
if (len < 4)
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," len=%d [bad: < 4]", len));
|
2004-03-24 09:32:20 +08:00
|
|
|
else
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," len=%d %s", len, ipaddr_string(data)));
|
1999-10-30 13:11:06 +08:00
|
|
|
len = 0;
|
|
|
|
break;
|
|
|
|
case IPSECDOI_ID_FQDN:
|
|
|
|
case IPSECDOI_ID_USER_FQDN:
|
|
|
|
{
|
|
|
|
int i;
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," len=%d ", len));
|
2001-01-28 16:06:06 +08:00
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
safeputchar(data[i]);
|
1999-10-30 13:11:06 +08:00
|
|
|
len = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case IPSECDOI_ID_IPV4_ADDR_SUBNET:
|
|
|
|
{
|
2002-09-05 08:43:21 +08:00
|
|
|
const u_char *mask;
|
2004-03-24 09:32:20 +08:00
|
|
|
if (len < 8)
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," len=%d [bad: < 8]", len));
|
2004-03-24 09:32:20 +08:00
|
|
|
else {
|
|
|
|
mask = data + sizeof(struct in_addr);
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," len=%d %s/%u.%u.%u.%u", len,
|
|
|
|
ipaddr_string(data),
|
|
|
|
mask[0], mask[1], mask[2], mask[3]));
|
2004-03-24 09:32:20 +08:00
|
|
|
}
|
1999-10-30 13:11:06 +08:00
|
|
|
len = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#ifdef INET6
|
|
|
|
case IPSECDOI_ID_IPV6_ADDR:
|
2004-03-24 09:32:20 +08:00
|
|
|
if (len < 16)
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," len=%d [bad: < 16]", len));
|
2004-03-24 09:32:20 +08:00
|
|
|
else
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," len=%d %s", len, ip6addr_string(data)));
|
1999-10-30 13:11:06 +08:00
|
|
|
len = 0;
|
|
|
|
break;
|
|
|
|
case IPSECDOI_ID_IPV6_ADDR_SUBNET:
|
|
|
|
{
|
2002-09-05 08:43:21 +08:00
|
|
|
const u_int32_t *mask;
|
2004-03-24 09:32:20 +08:00
|
|
|
if (len < 20)
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," len=%d [bad: < 20]", len));
|
2004-03-24 09:32:20 +08:00
|
|
|
else {
|
|
|
|
mask = (u_int32_t *)(data + sizeof(struct in6_addr));
|
|
|
|
/*XXX*/
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," len=%d %s/0x%08x%08x%08x%08x", len,
|
|
|
|
ip6addr_string(data),
|
|
|
|
mask[0], mask[1], mask[2], mask[3]));
|
2004-03-24 09:32:20 +08:00
|
|
|
}
|
1999-10-30 13:11:06 +08:00
|
|
|
len = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif /*INET6*/
|
|
|
|
case IPSECDOI_ID_IPV4_ADDR_RANGE:
|
2004-03-24 09:32:20 +08:00
|
|
|
if (len < 8)
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," len=%d [bad: < 8]", len));
|
2004-03-24 09:32:20 +08:00
|
|
|
else {
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," len=%d %s-%s", len,
|
|
|
|
ipaddr_string(data),
|
|
|
|
ipaddr_string(data + sizeof(struct in_addr))));
|
2004-03-24 09:32:20 +08:00
|
|
|
}
|
1999-10-30 13:11:06 +08:00
|
|
|
len = 0;
|
|
|
|
break;
|
|
|
|
#ifdef INET6
|
|
|
|
case IPSECDOI_ID_IPV6_ADDR_RANGE:
|
2004-03-24 09:32:20 +08:00
|
|
|
if (len < 32)
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," len=%d [bad: < 32]", len));
|
2004-03-24 09:32:20 +08:00
|
|
|
else {
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," len=%d %s-%s", len,
|
|
|
|
ip6addr_string(data),
|
|
|
|
ip6addr_string(data + sizeof(struct in6_addr))));
|
2004-03-24 09:32:20 +08:00
|
|
|
}
|
1999-10-30 13:11:06 +08:00
|
|
|
len = 0;
|
|
|
|
break;
|
|
|
|
#endif /*INET6*/
|
|
|
|
case IPSECDOI_ID_DER_ASN1_DN:
|
|
|
|
case IPSECDOI_ID_DER_ASN1_GN:
|
|
|
|
case IPSECDOI_ID_KEY_ID:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (data && len) {
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," len=%d", len));
|
2007-08-29 20:31:00 +08:00
|
|
|
if (2 < ndo->ndo_vflag) {
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," "));
|
|
|
|
if (!rawprint(ndo, (caddr_t)data, len))
|
2004-03-12 10:17:18 +08:00
|
|
|
goto trunc;
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
|
|
|
}
|
2004-03-12 09:26:59 +08:00
|
|
|
return (u_char *)ext + item_len;
|
2004-03-12 10:17:18 +08:00
|
|
|
trunc:
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_ID)));
|
2004-03-12 10:17:18 +08:00
|
|
|
return NULL;
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
|
|
|
|
2002-09-05 08:43:21 +08:00
|
|
|
static const u_char *
|
2007-08-29 10:58:43 +08:00
|
|
|
ikev1_cert_print(netdissect_options *ndo, u_char tpay _U_,
|
2007-08-29 10:38:14 +08:00
|
|
|
const struct isakmp_gen *ext, u_int item_len _U_,
|
|
|
|
const u_char *ep _U_, u_int32_t phase _U_,
|
|
|
|
u_int32_t doi0 _U_,
|
|
|
|
u_int32_t proto0 _U_, int depth _U_)
|
2000-04-24 20:49:11 +08:00
|
|
|
{
|
2007-08-29 10:38:14 +08:00
|
|
|
const struct ikev1_pl_cert *p;
|
|
|
|
struct ikev1_pl_cert cert;
|
Add a few more GCC warnings on GCC >= 2 for ".devel" builds.
From Neil T. Spring: fixes for many of those warnings:
addrtoname.c, configure.in: Linux needs netinet/ether.h for
ether_ntohost
print-*.c: change char *foo = "bar" to const char *foo = "bar"
to appease -Wwrite-strings; should affect no run-time behavior.
print-*.c: make some variables unsigned.
print-bgp.c: plen ('prefix len') is unsigned, no reason to
validate by comparing to zero.
print-cnfp.c, print-rx.c: use intoa, provided by addrtoname,
instead of inet_ntoa.
print-domain.c: unsigned int l; (l=foo()) < 0 is guaranteed to
be false, so check for (u_int)-1, which represents failure,
explicitly.
print-isakmp.c: complete initialization of attrmap objects.
print-lwres.c: "if(x); print foo;" seemed much more likely to be
intended to be "if(x) { print foo; }".
print-smb.c: complete initialization of some structures.
In addition, add some fixes for the signed vs. unsigned comparison
warnings:
extract.h: cast the result of the byte-extraction-and-combining,
as, at least for the 16-bit version, C's integral promotions
will turn "u_int16_t" into "int" if there are other "int"s
nearby.
print-*.c: make some more variables unsigned, or add casts to an
unsigned type of signed values known not to be negative, or add
casts to "int" of unsigned values known to fit in an "int", and
make other changes needed to handle the aforementioned variables
now being unsigned.
print-isakmp.c: clean up the handling of error/status indicators
in notify messages.
print-ppp.c: get rid of a check that an unsigned quantity is >=
0.
print-radius.c: clean up some of the bounds checking.
print-smb.c: extract the word count into a "u_int" to avoid the
aforementioned problems with C's integral promotions.
print-snmp.c: change a check that an unsigned variable is >= 0
to a check that it's != 0.
Also, fix some formats to use "%u" rather than "%d" for unsigned
quantities.
2002-09-05 08:00:07 +08:00
|
|
|
static const char *certstr[] = {
|
2000-04-24 20:49:11 +08:00
|
|
|
"none", "pkcs7", "pgp", "dns",
|
|
|
|
"x509sign", "x509ke", "kerberos", "crl",
|
|
|
|
"arl", "spki", "x509attr",
|
|
|
|
};
|
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_CERT)));
|
2000-04-24 20:49:11 +08:00
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
p = (struct ikev1_pl_cert *)ext;
|
2007-08-29 20:31:00 +08:00
|
|
|
ND_TCHECK(*p);
|
2000-10-03 13:16:38 +08:00
|
|
|
safememcpy(&cert, ext, sizeof(cert));
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," len=%d", item_len - 4));
|
|
|
|
ND_PRINT((ndo," type=%s", STR_OR_ID((cert.encode), certstr)));
|
2007-08-29 20:31:00 +08:00
|
|
|
if (2 < ndo->ndo_vflag && 4 < item_len) {
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," "));
|
|
|
|
if (!rawprint(ndo, (caddr_t)(ext + 1), item_len - 4))
|
2004-03-12 10:17:18 +08:00
|
|
|
goto trunc;
|
2000-04-24 20:49:11 +08:00
|
|
|
}
|
2004-03-12 09:26:59 +08:00
|
|
|
return (u_char *)ext + item_len;
|
2004-03-12 10:17:18 +08:00
|
|
|
trunc:
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_CERT)));
|
2004-03-12 10:17:18 +08:00
|
|
|
return NULL;
|
2000-04-24 20:49:11 +08:00
|
|
|
}
|
|
|
|
|
2002-09-05 08:43:21 +08:00
|
|
|
static const u_char *
|
2007-08-29 10:58:43 +08:00
|
|
|
ikev1_cr_print(netdissect_options *ndo, u_char tpay _U_,
|
2007-08-29 10:38:14 +08:00
|
|
|
const struct isakmp_gen *ext, u_int item_len _U_,
|
|
|
|
const u_char *ep _U_, u_int32_t phase _U_, u_int32_t doi0 _U_,
|
|
|
|
u_int32_t proto0 _U_, int depth _U_)
|
2000-09-23 12:43:42 +08:00
|
|
|
{
|
2007-08-29 10:38:14 +08:00
|
|
|
const struct ikev1_pl_cert *p;
|
|
|
|
struct ikev1_pl_cert cert;
|
Add a few more GCC warnings on GCC >= 2 for ".devel" builds.
From Neil T. Spring: fixes for many of those warnings:
addrtoname.c, configure.in: Linux needs netinet/ether.h for
ether_ntohost
print-*.c: change char *foo = "bar" to const char *foo = "bar"
to appease -Wwrite-strings; should affect no run-time behavior.
print-*.c: make some variables unsigned.
print-bgp.c: plen ('prefix len') is unsigned, no reason to
validate by comparing to zero.
print-cnfp.c, print-rx.c: use intoa, provided by addrtoname,
instead of inet_ntoa.
print-domain.c: unsigned int l; (l=foo()) < 0 is guaranteed to
be false, so check for (u_int)-1, which represents failure,
explicitly.
print-isakmp.c: complete initialization of attrmap objects.
print-lwres.c: "if(x); print foo;" seemed much more likely to be
intended to be "if(x) { print foo; }".
print-smb.c: complete initialization of some structures.
In addition, add some fixes for the signed vs. unsigned comparison
warnings:
extract.h: cast the result of the byte-extraction-and-combining,
as, at least for the 16-bit version, C's integral promotions
will turn "u_int16_t" into "int" if there are other "int"s
nearby.
print-*.c: make some more variables unsigned, or add casts to an
unsigned type of signed values known not to be negative, or add
casts to "int" of unsigned values known to fit in an "int", and
make other changes needed to handle the aforementioned variables
now being unsigned.
print-isakmp.c: clean up the handling of error/status indicators
in notify messages.
print-ppp.c: get rid of a check that an unsigned quantity is >=
0.
print-radius.c: clean up some of the bounds checking.
print-smb.c: extract the word count into a "u_int" to avoid the
aforementioned problems with C's integral promotions.
print-snmp.c: change a check that an unsigned variable is >= 0
to a check that it's != 0.
Also, fix some formats to use "%u" rather than "%d" for unsigned
quantities.
2002-09-05 08:00:07 +08:00
|
|
|
static const char *certstr[] = {
|
2000-09-23 12:43:42 +08:00
|
|
|
"none", "pkcs7", "pgp", "dns",
|
|
|
|
"x509sign", "x509ke", "kerberos", "crl",
|
|
|
|
"arl", "spki", "x509attr",
|
|
|
|
};
|
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_CR)));
|
2000-09-23 12:43:42 +08:00
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
p = (struct ikev1_pl_cert *)ext;
|
2007-08-29 20:31:00 +08:00
|
|
|
ND_TCHECK(*p);
|
2000-10-03 13:16:38 +08:00
|
|
|
safememcpy(&cert, ext, sizeof(cert));
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," len=%d", item_len - 4));
|
|
|
|
ND_PRINT((ndo," type=%s", STR_OR_ID((cert.encode), certstr)));
|
2007-08-29 20:31:00 +08:00
|
|
|
if (2 < ndo->ndo_vflag && 4 < item_len) {
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," "));
|
|
|
|
if (!rawprint(ndo, (caddr_t)(ext + 1), item_len - 4))
|
2004-03-12 10:17:18 +08:00
|
|
|
goto trunc;
|
2000-09-23 12:43:42 +08:00
|
|
|
}
|
2004-03-12 09:26:59 +08:00
|
|
|
return (u_char *)ext + item_len;
|
2004-03-12 10:17:18 +08:00
|
|
|
trunc:
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_CR)));
|
2004-03-12 10:17:18 +08:00
|
|
|
return NULL;
|
2000-09-23 12:43:42 +08:00
|
|
|
}
|
|
|
|
|
2002-09-05 08:43:21 +08:00
|
|
|
static const u_char *
|
2007-08-29 10:58:43 +08:00
|
|
|
ikev1_hash_print(netdissect_options *ndo, u_char tpay _U_,
|
2007-08-29 10:38:14 +08:00
|
|
|
const struct isakmp_gen *ext, u_int item_len _U_,
|
|
|
|
const u_char *ep _U_, u_int32_t phase _U_, u_int32_t doi _U_,
|
|
|
|
u_int32_t proto _U_, int depth _U_)
|
1999-10-30 13:11:06 +08:00
|
|
|
{
|
2000-10-03 13:16:38 +08:00
|
|
|
struct isakmp_gen e;
|
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_HASH)));
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2007-08-29 20:31:00 +08:00
|
|
|
ND_TCHECK(*ext);
|
2000-10-03 13:16:38 +08:00
|
|
|
safememcpy(&e, ext, sizeof(e));
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," len=%d", ntohs(e.len) - 4));
|
2007-08-29 20:31:00 +08:00
|
|
|
if (2 < ndo->ndo_vflag && 4 < ntohs(e.len)) {
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," "));
|
|
|
|
if (!rawprint(ndo, (caddr_t)(ext + 1), ntohs(e.len) - 4))
|
2004-03-12 10:17:18 +08:00
|
|
|
goto trunc;
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
2000-10-03 13:16:38 +08:00
|
|
|
return (u_char *)ext + ntohs(e.len);
|
2004-03-12 10:17:18 +08:00
|
|
|
trunc:
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_HASH)));
|
2004-03-12 10:17:18 +08:00
|
|
|
return NULL;
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
|
|
|
|
2002-09-05 08:43:21 +08:00
|
|
|
static const u_char *
|
2007-08-29 10:58:43 +08:00
|
|
|
ikev1_sig_print(netdissect_options *ndo, u_char tpay _U_,
|
2007-08-29 10:38:14 +08:00
|
|
|
const struct isakmp_gen *ext, u_int item_len _U_,
|
|
|
|
const u_char *ep _U_, u_int32_t phase _U_, u_int32_t doi _U_,
|
|
|
|
u_int32_t proto _U_, int depth _U_)
|
2000-04-24 20:49:11 +08:00
|
|
|
{
|
2000-10-03 13:16:38 +08:00
|
|
|
struct isakmp_gen e;
|
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_SIG)));
|
2000-04-24 20:49:11 +08:00
|
|
|
|
2007-08-29 20:31:00 +08:00
|
|
|
ND_TCHECK(*ext);
|
2000-10-03 13:16:38 +08:00
|
|
|
safememcpy(&e, ext, sizeof(e));
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," len=%d", ntohs(e.len) - 4));
|
2007-08-29 20:31:00 +08:00
|
|
|
if (2 < ndo->ndo_vflag && 4 < ntohs(e.len)) {
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," "));
|
|
|
|
if (!rawprint(ndo, (caddr_t)(ext + 1), ntohs(e.len) - 4))
|
2004-03-12 10:17:18 +08:00
|
|
|
goto trunc;
|
2000-04-24 20:49:11 +08:00
|
|
|
}
|
2000-10-03 13:16:38 +08:00
|
|
|
return (u_char *)ext + ntohs(e.len);
|
2004-03-12 10:17:18 +08:00
|
|
|
trunc:
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_SIG)));
|
2004-03-12 10:17:18 +08:00
|
|
|
return NULL;
|
2000-04-24 20:49:11 +08:00
|
|
|
}
|
|
|
|
|
2002-09-05 08:43:21 +08:00
|
|
|
static const u_char *
|
2007-08-29 10:58:43 +08:00
|
|
|
ikev1_nonce_print(netdissect_options *ndo, u_char tpay _U_,
|
2007-08-29 10:38:14 +08:00
|
|
|
const struct isakmp_gen *ext,
|
|
|
|
u_int item_len _U_,
|
|
|
|
const u_char *ep _U_,
|
|
|
|
u_int32_t phase _U_, u_int32_t doi _U_,
|
|
|
|
u_int32_t proto _U_, int depth _U_)
|
1999-10-30 13:11:06 +08:00
|
|
|
{
|
2000-10-03 13:16:38 +08:00
|
|
|
struct isakmp_gen e;
|
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_NONCE)));
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2007-08-29 20:31:00 +08:00
|
|
|
ND_TCHECK(*ext);
|
2000-10-03 13:16:38 +08:00
|
|
|
safememcpy(&e, ext, sizeof(e));
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," n len=%d", ntohs(e.len) - 4));
|
2007-08-29 20:31:00 +08:00
|
|
|
if (2 < ndo->ndo_vflag && 4 < ntohs(e.len)) {
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," "));
|
|
|
|
if (!rawprint(ndo, (caddr_t)(ext + 1), ntohs(e.len) - 4))
|
|
|
|
goto trunc;
|
2007-08-29 20:31:00 +08:00
|
|
|
} else if (1 < ndo->ndo_vflag && 4 < ntohs(e.len)) {
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," "));
|
|
|
|
if (!ike_show_somedata(ndo, (u_char *)(caddr_t)(ext + 1), ep))
|
2004-03-12 10:17:18 +08:00
|
|
|
goto trunc;
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
2000-10-03 13:16:38 +08:00
|
|
|
return (u_char *)ext + ntohs(e.len);
|
2004-03-12 10:17:18 +08:00
|
|
|
trunc:
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_NONCE)));
|
2004-03-12 10:17:18 +08:00
|
|
|
return NULL;
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
|
|
|
|
2002-09-05 08:43:21 +08:00
|
|
|
static const u_char *
|
2007-08-29 10:58:43 +08:00
|
|
|
ikev1_n_print(netdissect_options *ndo, u_char tpay _U_,
|
2007-08-29 10:38:14 +08:00
|
|
|
const struct isakmp_gen *ext, u_int item_len,
|
|
|
|
const u_char *ep, u_int32_t phase, u_int32_t doi0 _U_,
|
|
|
|
u_int32_t proto0 _U_, int depth)
|
1999-10-30 13:11:06 +08:00
|
|
|
{
|
2007-08-29 10:38:14 +08:00
|
|
|
struct ikev1_pl_n *p, n;
|
2002-09-05 08:43:21 +08:00
|
|
|
const u_char *cp;
|
1999-10-30 13:11:06 +08:00
|
|
|
u_char *ep2;
|
|
|
|
u_int32_t doi;
|
|
|
|
u_int32_t proto;
|
Add a few more GCC warnings on GCC >= 2 for ".devel" builds.
From Neil T. Spring: fixes for many of those warnings:
addrtoname.c, configure.in: Linux needs netinet/ether.h for
ether_ntohost
print-*.c: change char *foo = "bar" to const char *foo = "bar"
to appease -Wwrite-strings; should affect no run-time behavior.
print-*.c: make some variables unsigned.
print-bgp.c: plen ('prefix len') is unsigned, no reason to
validate by comparing to zero.
print-cnfp.c, print-rx.c: use intoa, provided by addrtoname,
instead of inet_ntoa.
print-domain.c: unsigned int l; (l=foo()) < 0 is guaranteed to
be false, so check for (u_int)-1, which represents failure,
explicitly.
print-isakmp.c: complete initialization of attrmap objects.
print-lwres.c: "if(x); print foo;" seemed much more likely to be
intended to be "if(x) { print foo; }".
print-smb.c: complete initialization of some structures.
In addition, add some fixes for the signed vs. unsigned comparison
warnings:
extract.h: cast the result of the byte-extraction-and-combining,
as, at least for the 16-bit version, C's integral promotions
will turn "u_int16_t" into "int" if there are other "int"s
nearby.
print-*.c: make some more variables unsigned, or add casts to an
unsigned type of signed values known not to be negative, or add
casts to "int" of unsigned values known to fit in an "int", and
make other changes needed to handle the aforementioned variables
now being unsigned.
print-isakmp.c: clean up the handling of error/status indicators
in notify messages.
print-ppp.c: get rid of a check that an unsigned quantity is >=
0.
print-radius.c: clean up some of the bounds checking.
print-smb.c: extract the word count into a "u_int" to avoid the
aforementioned problems with C's integral promotions.
print-snmp.c: change a check that an unsigned variable is >= 0
to a check that it's != 0.
Also, fix some formats to use "%u" rather than "%d" for unsigned
quantities.
2002-09-05 08:00:07 +08:00
|
|
|
static const char *notify_error_str[] = {
|
1999-10-30 13:11:06 +08:00
|
|
|
NULL, "INVALID-PAYLOAD-TYPE",
|
|
|
|
"DOI-NOT-SUPPORTED", "SITUATION-NOT-SUPPORTED",
|
|
|
|
"INVALID-COOKIE", "INVALID-MAJOR-VERSION",
|
|
|
|
"INVALID-MINOR-VERSION", "INVALID-EXCHANGE-TYPE",
|
|
|
|
"INVALID-FLAGS", "INVALID-MESSAGE-ID",
|
|
|
|
"INVALID-PROTOCOL-ID", "INVALID-SPI",
|
|
|
|
"INVALID-TRANSFORM-ID", "ATTRIBUTES-NOT-SUPPORTED",
|
|
|
|
"NO-PROPOSAL-CHOSEN", "BAD-PROPOSAL-SYNTAX",
|
|
|
|
"PAYLOAD-MALFORMED", "INVALID-KEY-INFORMATION",
|
|
|
|
"INVALID-ID-INFORMATION", "INVALID-CERT-ENCODING",
|
|
|
|
"INVALID-CERTIFICATE", "CERT-TYPE-UNSUPPORTED",
|
|
|
|
"INVALID-CERT-AUTHORITY", "INVALID-HASH-INFORMATION",
|
|
|
|
"AUTHENTICATION-FAILED", "INVALID-SIGNATURE",
|
|
|
|
"ADDRESS-NOTIFICATION", "NOTIFY-SA-LIFETIME",
|
|
|
|
"CERTIFICATE-UNAVAILABLE", "UNSUPPORTED-EXCHANGE-TYPE",
|
|
|
|
"UNEQUAL-PAYLOAD-LENGTHS",
|
|
|
|
};
|
Add a few more GCC warnings on GCC >= 2 for ".devel" builds.
From Neil T. Spring: fixes for many of those warnings:
addrtoname.c, configure.in: Linux needs netinet/ether.h for
ether_ntohost
print-*.c: change char *foo = "bar" to const char *foo = "bar"
to appease -Wwrite-strings; should affect no run-time behavior.
print-*.c: make some variables unsigned.
print-bgp.c: plen ('prefix len') is unsigned, no reason to
validate by comparing to zero.
print-cnfp.c, print-rx.c: use intoa, provided by addrtoname,
instead of inet_ntoa.
print-domain.c: unsigned int l; (l=foo()) < 0 is guaranteed to
be false, so check for (u_int)-1, which represents failure,
explicitly.
print-isakmp.c: complete initialization of attrmap objects.
print-lwres.c: "if(x); print foo;" seemed much more likely to be
intended to be "if(x) { print foo; }".
print-smb.c: complete initialization of some structures.
In addition, add some fixes for the signed vs. unsigned comparison
warnings:
extract.h: cast the result of the byte-extraction-and-combining,
as, at least for the 16-bit version, C's integral promotions
will turn "u_int16_t" into "int" if there are other "int"s
nearby.
print-*.c: make some more variables unsigned, or add casts to an
unsigned type of signed values known not to be negative, or add
casts to "int" of unsigned values known to fit in an "int", and
make other changes needed to handle the aforementioned variables
now being unsigned.
print-isakmp.c: clean up the handling of error/status indicators
in notify messages.
print-ppp.c: get rid of a check that an unsigned quantity is >=
0.
print-radius.c: clean up some of the bounds checking.
print-smb.c: extract the word count into a "u_int" to avoid the
aforementioned problems with C's integral promotions.
print-snmp.c: change a check that an unsigned variable is >= 0
to a check that it's != 0.
Also, fix some formats to use "%u" rather than "%d" for unsigned
quantities.
2002-09-05 08:00:07 +08:00
|
|
|
static const char *ipsec_notify_error_str[] = {
|
|
|
|
"RESERVED",
|
|
|
|
};
|
|
|
|
static const char *notify_status_str[] = {
|
|
|
|
"CONNECTED",
|
|
|
|
};
|
|
|
|
static const char *ipsec_notify_status_str[] = {
|
1999-10-30 13:11:06 +08:00
|
|
|
"RESPONDER-LIFETIME", "REPLAY-STATUS",
|
|
|
|
"INITIAL-CONTACT",
|
|
|
|
};
|
|
|
|
/* NOTE: these macro must be called with x in proper range */
|
Add a few more GCC warnings on GCC >= 2 for ".devel" builds.
From Neil T. Spring: fixes for many of those warnings:
addrtoname.c, configure.in: Linux needs netinet/ether.h for
ether_ntohost
print-*.c: change char *foo = "bar" to const char *foo = "bar"
to appease -Wwrite-strings; should affect no run-time behavior.
print-*.c: make some variables unsigned.
print-bgp.c: plen ('prefix len') is unsigned, no reason to
validate by comparing to zero.
print-cnfp.c, print-rx.c: use intoa, provided by addrtoname,
instead of inet_ntoa.
print-domain.c: unsigned int l; (l=foo()) < 0 is guaranteed to
be false, so check for (u_int)-1, which represents failure,
explicitly.
print-isakmp.c: complete initialization of attrmap objects.
print-lwres.c: "if(x); print foo;" seemed much more likely to be
intended to be "if(x) { print foo; }".
print-smb.c: complete initialization of some structures.
In addition, add some fixes for the signed vs. unsigned comparison
warnings:
extract.h: cast the result of the byte-extraction-and-combining,
as, at least for the 16-bit version, C's integral promotions
will turn "u_int16_t" into "int" if there are other "int"s
nearby.
print-*.c: make some more variables unsigned, or add casts to an
unsigned type of signed values known not to be negative, or add
casts to "int" of unsigned values known to fit in an "int", and
make other changes needed to handle the aforementioned variables
now being unsigned.
print-isakmp.c: clean up the handling of error/status indicators
in notify messages.
print-ppp.c: get rid of a check that an unsigned quantity is >=
0.
print-radius.c: clean up some of the bounds checking.
print-smb.c: extract the word count into a "u_int" to avoid the
aforementioned problems with C's integral promotions.
print-snmp.c: change a check that an unsigned variable is >= 0
to a check that it's != 0.
Also, fix some formats to use "%u" rather than "%d" for unsigned
quantities.
2002-09-05 08:00:07 +08:00
|
|
|
|
|
|
|
/* 0 - 8191 */
|
|
|
|
#define NOTIFY_ERROR_STR(x) \
|
|
|
|
STR_OR_ID((x), notify_error_str)
|
|
|
|
|
|
|
|
/* 8192 - 16383 */
|
|
|
|
#define IPSEC_NOTIFY_ERROR_STR(x) \
|
|
|
|
STR_OR_ID((u_int)((x) - 8192), ipsec_notify_error_str)
|
|
|
|
|
|
|
|
/* 16384 - 24575 */
|
|
|
|
#define NOTIFY_STATUS_STR(x) \
|
|
|
|
STR_OR_ID((u_int)((x) - 16384), notify_status_str)
|
|
|
|
|
|
|
|
/* 24576 - 32767 */
|
|
|
|
#define IPSEC_NOTIFY_STATUS_STR(x) \
|
|
|
|
STR_OR_ID((u_int)((x) - 24576), ipsec_notify_status_str)
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_N)));
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
p = (struct ikev1_pl_n *)ext;
|
2007-08-29 20:31:00 +08:00
|
|
|
ND_TCHECK(*p);
|
2000-10-03 13:16:38 +08:00
|
|
|
safememcpy(&n, ext, sizeof(n));
|
|
|
|
doi = ntohl(n.doi);
|
|
|
|
proto = n.prot_id;
|
1999-10-30 13:11:06 +08:00
|
|
|
if (doi != 1) {
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," doi=%d", doi));
|
|
|
|
ND_PRINT((ndo," proto=%d", proto));
|
Add a few more GCC warnings on GCC >= 2 for ".devel" builds.
From Neil T. Spring: fixes for many of those warnings:
addrtoname.c, configure.in: Linux needs netinet/ether.h for
ether_ntohost
print-*.c: change char *foo = "bar" to const char *foo = "bar"
to appease -Wwrite-strings; should affect no run-time behavior.
print-*.c: make some variables unsigned.
print-bgp.c: plen ('prefix len') is unsigned, no reason to
validate by comparing to zero.
print-cnfp.c, print-rx.c: use intoa, provided by addrtoname,
instead of inet_ntoa.
print-domain.c: unsigned int l; (l=foo()) < 0 is guaranteed to
be false, so check for (u_int)-1, which represents failure,
explicitly.
print-isakmp.c: complete initialization of attrmap objects.
print-lwres.c: "if(x); print foo;" seemed much more likely to be
intended to be "if(x) { print foo; }".
print-smb.c: complete initialization of some structures.
In addition, add some fixes for the signed vs. unsigned comparison
warnings:
extract.h: cast the result of the byte-extraction-and-combining,
as, at least for the 16-bit version, C's integral promotions
will turn "u_int16_t" into "int" if there are other "int"s
nearby.
print-*.c: make some more variables unsigned, or add casts to an
unsigned type of signed values known not to be negative, or add
casts to "int" of unsigned values known to fit in an "int", and
make other changes needed to handle the aforementioned variables
now being unsigned.
print-isakmp.c: clean up the handling of error/status indicators
in notify messages.
print-ppp.c: get rid of a check that an unsigned quantity is >=
0.
print-radius.c: clean up some of the bounds checking.
print-smb.c: extract the word count into a "u_int" to avoid the
aforementioned problems with C's integral promotions.
print-snmp.c: change a check that an unsigned variable is >= 0
to a check that it's != 0.
Also, fix some formats to use "%u" rather than "%d" for unsigned
quantities.
2002-09-05 08:00:07 +08:00
|
|
|
if (ntohs(n.type) < 8192)
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," type=%s", NOTIFY_ERROR_STR(ntohs(n.type))));
|
Add a few more GCC warnings on GCC >= 2 for ".devel" builds.
From Neil T. Spring: fixes for many of those warnings:
addrtoname.c, configure.in: Linux needs netinet/ether.h for
ether_ntohost
print-*.c: change char *foo = "bar" to const char *foo = "bar"
to appease -Wwrite-strings; should affect no run-time behavior.
print-*.c: make some variables unsigned.
print-bgp.c: plen ('prefix len') is unsigned, no reason to
validate by comparing to zero.
print-cnfp.c, print-rx.c: use intoa, provided by addrtoname,
instead of inet_ntoa.
print-domain.c: unsigned int l; (l=foo()) < 0 is guaranteed to
be false, so check for (u_int)-1, which represents failure,
explicitly.
print-isakmp.c: complete initialization of attrmap objects.
print-lwres.c: "if(x); print foo;" seemed much more likely to be
intended to be "if(x) { print foo; }".
print-smb.c: complete initialization of some structures.
In addition, add some fixes for the signed vs. unsigned comparison
warnings:
extract.h: cast the result of the byte-extraction-and-combining,
as, at least for the 16-bit version, C's integral promotions
will turn "u_int16_t" into "int" if there are other "int"s
nearby.
print-*.c: make some more variables unsigned, or add casts to an
unsigned type of signed values known not to be negative, or add
casts to "int" of unsigned values known to fit in an "int", and
make other changes needed to handle the aforementioned variables
now being unsigned.
print-isakmp.c: clean up the handling of error/status indicators
in notify messages.
print-ppp.c: get rid of a check that an unsigned quantity is >=
0.
print-radius.c: clean up some of the bounds checking.
print-smb.c: extract the word count into a "u_int" to avoid the
aforementioned problems with C's integral promotions.
print-snmp.c: change a check that an unsigned variable is >= 0
to a check that it's != 0.
Also, fix some formats to use "%u" rather than "%d" for unsigned
quantities.
2002-09-05 08:00:07 +08:00
|
|
|
else if (ntohs(n.type) < 16384)
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," type=%s", numstr(ntohs(n.type))));
|
Add a few more GCC warnings on GCC >= 2 for ".devel" builds.
From Neil T. Spring: fixes for many of those warnings:
addrtoname.c, configure.in: Linux needs netinet/ether.h for
ether_ntohost
print-*.c: change char *foo = "bar" to const char *foo = "bar"
to appease -Wwrite-strings; should affect no run-time behavior.
print-*.c: make some variables unsigned.
print-bgp.c: plen ('prefix len') is unsigned, no reason to
validate by comparing to zero.
print-cnfp.c, print-rx.c: use intoa, provided by addrtoname,
instead of inet_ntoa.
print-domain.c: unsigned int l; (l=foo()) < 0 is guaranteed to
be false, so check for (u_int)-1, which represents failure,
explicitly.
print-isakmp.c: complete initialization of attrmap objects.
print-lwres.c: "if(x); print foo;" seemed much more likely to be
intended to be "if(x) { print foo; }".
print-smb.c: complete initialization of some structures.
In addition, add some fixes for the signed vs. unsigned comparison
warnings:
extract.h: cast the result of the byte-extraction-and-combining,
as, at least for the 16-bit version, C's integral promotions
will turn "u_int16_t" into "int" if there are other "int"s
nearby.
print-*.c: make some more variables unsigned, or add casts to an
unsigned type of signed values known not to be negative, or add
casts to "int" of unsigned values known to fit in an "int", and
make other changes needed to handle the aforementioned variables
now being unsigned.
print-isakmp.c: clean up the handling of error/status indicators
in notify messages.
print-ppp.c: get rid of a check that an unsigned quantity is >=
0.
print-radius.c: clean up some of the bounds checking.
print-smb.c: extract the word count into a "u_int" to avoid the
aforementioned problems with C's integral promotions.
print-snmp.c: change a check that an unsigned variable is >= 0
to a check that it's != 0.
Also, fix some formats to use "%u" rather than "%d" for unsigned
quantities.
2002-09-05 08:00:07 +08:00
|
|
|
else if (ntohs(n.type) < 24576)
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," type=%s", NOTIFY_STATUS_STR(ntohs(n.type))));
|
Add a few more GCC warnings on GCC >= 2 for ".devel" builds.
From Neil T. Spring: fixes for many of those warnings:
addrtoname.c, configure.in: Linux needs netinet/ether.h for
ether_ntohost
print-*.c: change char *foo = "bar" to const char *foo = "bar"
to appease -Wwrite-strings; should affect no run-time behavior.
print-*.c: make some variables unsigned.
print-bgp.c: plen ('prefix len') is unsigned, no reason to
validate by comparing to zero.
print-cnfp.c, print-rx.c: use intoa, provided by addrtoname,
instead of inet_ntoa.
print-domain.c: unsigned int l; (l=foo()) < 0 is guaranteed to
be false, so check for (u_int)-1, which represents failure,
explicitly.
print-isakmp.c: complete initialization of attrmap objects.
print-lwres.c: "if(x); print foo;" seemed much more likely to be
intended to be "if(x) { print foo; }".
print-smb.c: complete initialization of some structures.
In addition, add some fixes for the signed vs. unsigned comparison
warnings:
extract.h: cast the result of the byte-extraction-and-combining,
as, at least for the 16-bit version, C's integral promotions
will turn "u_int16_t" into "int" if there are other "int"s
nearby.
print-*.c: make some more variables unsigned, or add casts to an
unsigned type of signed values known not to be negative, or add
casts to "int" of unsigned values known to fit in an "int", and
make other changes needed to handle the aforementioned variables
now being unsigned.
print-isakmp.c: clean up the handling of error/status indicators
in notify messages.
print-ppp.c: get rid of a check that an unsigned quantity is >=
0.
print-radius.c: clean up some of the bounds checking.
print-smb.c: extract the word count into a "u_int" to avoid the
aforementioned problems with C's integral promotions.
print-snmp.c: change a check that an unsigned variable is >= 0
to a check that it's != 0.
Also, fix some formats to use "%u" rather than "%d" for unsigned
quantities.
2002-09-05 08:00:07 +08:00
|
|
|
else
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," type=%s", numstr(ntohs(n.type))));
|
2000-10-03 13:16:38 +08:00
|
|
|
if (n.spi_size) {
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," spi="));
|
|
|
|
if (!rawprint(ndo, (caddr_t)(p + 1), n.spi_size))
|
2004-03-12 10:17:18 +08:00
|
|
|
goto trunc;
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
2000-10-03 13:16:38 +08:00
|
|
|
return (u_char *)(p + 1) + n.spi_size;
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," doi=ipsec"));
|
|
|
|
ND_PRINT((ndo," proto=%s", PROTOIDSTR(proto)));
|
2000-10-03 13:16:38 +08:00
|
|
|
if (ntohs(n.type) < 8192)
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," type=%s", NOTIFY_ERROR_STR(ntohs(n.type))));
|
2000-10-03 13:16:38 +08:00
|
|
|
else if (ntohs(n.type) < 16384)
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," type=%s", IPSEC_NOTIFY_ERROR_STR(ntohs(n.type))));
|
2000-10-03 13:16:38 +08:00
|
|
|
else if (ntohs(n.type) < 24576)
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," type=%s", NOTIFY_STATUS_STR(ntohs(n.type))));
|
Add a few more GCC warnings on GCC >= 2 for ".devel" builds.
From Neil T. Spring: fixes for many of those warnings:
addrtoname.c, configure.in: Linux needs netinet/ether.h for
ether_ntohost
print-*.c: change char *foo = "bar" to const char *foo = "bar"
to appease -Wwrite-strings; should affect no run-time behavior.
print-*.c: make some variables unsigned.
print-bgp.c: plen ('prefix len') is unsigned, no reason to
validate by comparing to zero.
print-cnfp.c, print-rx.c: use intoa, provided by addrtoname,
instead of inet_ntoa.
print-domain.c: unsigned int l; (l=foo()) < 0 is guaranteed to
be false, so check for (u_int)-1, which represents failure,
explicitly.
print-isakmp.c: complete initialization of attrmap objects.
print-lwres.c: "if(x); print foo;" seemed much more likely to be
intended to be "if(x) { print foo; }".
print-smb.c: complete initialization of some structures.
In addition, add some fixes for the signed vs. unsigned comparison
warnings:
extract.h: cast the result of the byte-extraction-and-combining,
as, at least for the 16-bit version, C's integral promotions
will turn "u_int16_t" into "int" if there are other "int"s
nearby.
print-*.c: make some more variables unsigned, or add casts to an
unsigned type of signed values known not to be negative, or add
casts to "int" of unsigned values known to fit in an "int", and
make other changes needed to handle the aforementioned variables
now being unsigned.
print-isakmp.c: clean up the handling of error/status indicators
in notify messages.
print-ppp.c: get rid of a check that an unsigned quantity is >=
0.
print-radius.c: clean up some of the bounds checking.
print-smb.c: extract the word count into a "u_int" to avoid the
aforementioned problems with C's integral promotions.
print-snmp.c: change a check that an unsigned variable is >= 0
to a check that it's != 0.
Also, fix some formats to use "%u" rather than "%d" for unsigned
quantities.
2002-09-05 08:00:07 +08:00
|
|
|
else if (ntohs(n.type) < 32768)
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," type=%s", IPSEC_NOTIFY_STATUS_STR(ntohs(n.type))));
|
1999-10-30 13:11:06 +08:00
|
|
|
else
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," type=%s", numstr(ntohs(n.type))));
|
2000-10-03 13:16:38 +08:00
|
|
|
if (n.spi_size) {
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," spi="));
|
|
|
|
if (!rawprint(ndo, (caddr_t)(p + 1), n.spi_size))
|
2004-03-12 10:17:18 +08:00
|
|
|
goto trunc;
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
|
|
|
|
2000-10-03 13:16:38 +08:00
|
|
|
cp = (u_char *)(p + 1) + n.spi_size;
|
2004-03-12 09:26:59 +08:00
|
|
|
ep2 = (u_char *)p + item_len;
|
1999-10-30 13:11:06 +08:00
|
|
|
|
|
|
|
if (cp < ep) {
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," orig=("));
|
2000-10-03 13:16:38 +08:00
|
|
|
switch (ntohs(n.type)) {
|
1999-10-30 13:11:06 +08:00
|
|
|
case IPSECDOI_NTYPE_RESPONDER_LIFETIME:
|
|
|
|
{
|
2002-09-05 08:43:21 +08:00
|
|
|
const struct attrmap *map = oakley_t_map;
|
1999-10-30 13:11:06 +08:00
|
|
|
size_t nmap = sizeof(oakley_t_map)/sizeof(oakley_t_map[0]);
|
|
|
|
while (cp < ep && cp < ep2) {
|
2007-08-29 10:38:14 +08:00
|
|
|
cp = ikev1_attrmap_print(ndo, cp,
|
1999-10-30 13:11:06 +08:00
|
|
|
(ep < ep2) ? ep : ep2, map, nmap);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case IPSECDOI_NTYPE_REPLAY_STATUS:
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo,"replay detection %sabled",
|
|
|
|
(*(u_int32_t *)cp) ? "en" : "dis"));
|
1999-10-30 13:11:06 +08:00
|
|
|
break;
|
|
|
|
case ISAKMP_NTYPE_NO_PROPOSAL_CHOSEN:
|
2007-08-29 10:38:14 +08:00
|
|
|
if (ikev1_sub_print(ndo, ISAKMP_NPTYPE_SA,
|
|
|
|
(struct isakmp_gen *)cp, ep, phase, doi, proto,
|
|
|
|
depth) == NULL)
|
2002-09-05 08:43:21 +08:00
|
|
|
return NULL;
|
1999-10-30 13:11:06 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* NULL is dummy */
|
2007-08-29 20:31:00 +08:00
|
|
|
isakmp_print(ndo, cp,
|
2005-04-07 05:33:27 +08:00
|
|
|
item_len - sizeof(*p) - n.spi_size,
|
|
|
|
NULL);
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo,")"));
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
2004-03-12 09:26:59 +08:00
|
|
|
return (u_char *)ext + item_len;
|
2004-03-12 10:17:18 +08:00
|
|
|
trunc:
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_N)));
|
2004-03-12 10:17:18 +08:00
|
|
|
return NULL;
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
|
|
|
|
2002-09-05 08:43:21 +08:00
|
|
|
static const u_char *
|
2007-08-29 10:58:43 +08:00
|
|
|
ikev1_d_print(netdissect_options *ndo, u_char tpay _U_,
|
2007-08-29 10:38:14 +08:00
|
|
|
const struct isakmp_gen *ext, u_int item_len _U_,
|
|
|
|
const u_char *ep _U_, u_int32_t phase _U_, u_int32_t doi0 _U_,
|
|
|
|
u_int32_t proto0 _U_, int depth _U_)
|
1999-10-30 13:11:06 +08:00
|
|
|
{
|
2007-08-29 10:38:14 +08:00
|
|
|
const struct ikev1_pl_d *p;
|
|
|
|
struct ikev1_pl_d d;
|
2002-09-05 08:43:21 +08:00
|
|
|
const u_int8_t *q;
|
1999-10-30 13:11:06 +08:00
|
|
|
u_int32_t doi;
|
|
|
|
u_int32_t proto;
|
|
|
|
int i;
|
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_D)));
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
p = (struct ikev1_pl_d *)ext;
|
2007-08-29 20:31:00 +08:00
|
|
|
ND_TCHECK(*p);
|
2000-10-03 13:16:38 +08:00
|
|
|
safememcpy(&d, ext, sizeof(d));
|
|
|
|
doi = ntohl(d.doi);
|
|
|
|
proto = d.prot_id;
|
1999-10-30 13:11:06 +08:00
|
|
|
if (doi != 1) {
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," doi=%u", doi));
|
|
|
|
ND_PRINT((ndo," proto=%u", proto));
|
1999-10-30 13:11:06 +08:00
|
|
|
} else {
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," doi=ipsec"));
|
|
|
|
ND_PRINT((ndo," proto=%s", PROTOIDSTR(proto)));
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," spilen=%u", d.spi_size));
|
|
|
|
ND_PRINT((ndo," nspi=%u", ntohs(d.num_spi)));
|
|
|
|
ND_PRINT((ndo," spi="));
|
1999-10-30 13:11:06 +08:00
|
|
|
q = (u_int8_t *)(p + 1);
|
2000-10-03 13:16:38 +08:00
|
|
|
for (i = 0; i < ntohs(d.num_spi); i++) {
|
1999-10-30 13:11:06 +08:00
|
|
|
if (i != 0)
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo,","));
|
|
|
|
if (!rawprint(ndo, (caddr_t)q, d.spi_size))
|
2004-03-12 10:17:18 +08:00
|
|
|
goto trunc;
|
2000-10-03 13:16:38 +08:00
|
|
|
q += d.spi_size;
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
|
|
|
return q;
|
2004-03-12 10:17:18 +08:00
|
|
|
trunc:
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_D)));
|
2004-03-12 10:17:18 +08:00
|
|
|
return NULL;
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
|
|
|
|
2002-09-05 08:43:21 +08:00
|
|
|
static const u_char *
|
2007-08-29 10:58:43 +08:00
|
|
|
ikev1_vid_print(netdissect_options *ndo, u_char tpay _U_,
|
2007-08-29 10:38:14 +08:00
|
|
|
const struct isakmp_gen *ext,
|
|
|
|
u_int item_len _U_, const u_char *ep _U_,
|
|
|
|
u_int32_t phase _U_, u_int32_t doi _U_,
|
|
|
|
u_int32_t proto _U_, int depth _U_)
|
1999-10-30 13:11:06 +08:00
|
|
|
{
|
2000-10-03 13:16:38 +08:00
|
|
|
struct isakmp_gen e;
|
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_VID)));
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2007-08-29 20:31:00 +08:00
|
|
|
ND_TCHECK(*ext);
|
2000-10-03 13:16:38 +08:00
|
|
|
safememcpy(&e, ext, sizeof(e));
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," len=%d", ntohs(e.len) - 4));
|
2007-08-29 20:31:00 +08:00
|
|
|
if (2 < ndo->ndo_vflag && 4 < ntohs(e.len)) {
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," "));
|
|
|
|
if (!rawprint(ndo, (caddr_t)(ext + 1), ntohs(e.len) - 4))
|
2004-03-12 10:17:18 +08:00
|
|
|
goto trunc;
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
2000-10-03 13:16:38 +08:00
|
|
|
return (u_char *)ext + ntohs(e.len);
|
2004-03-12 10:17:18 +08:00
|
|
|
trunc:
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_VID)));
|
2004-03-12 10:17:18 +08:00
|
|
|
return NULL;
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
/************************************************************/
|
|
|
|
/* */
|
|
|
|
/* IKE v2 - rfc4306 - dissector */
|
|
|
|
/* */
|
|
|
|
/************************************************************/
|
|
|
|
|
|
|
|
static void
|
|
|
|
ikev2_pay_print(netdissect_options *ndo, const char *payname, int critical)
|
|
|
|
{
|
|
|
|
ND_PRINT((ndo,"%s%s:", payname, critical&0x80 ? "[C]" : ""));
|
|
|
|
}
|
|
|
|
|
2002-09-05 08:43:21 +08:00
|
|
|
static const u_char *
|
2007-08-29 10:58:43 +08:00
|
|
|
ikev2_gen_print(netdissect_options *ndo, u_char tpay,
|
2007-08-29 10:38:14 +08:00
|
|
|
const struct isakmp_gen *ext)
|
1999-10-30 13:11:06 +08:00
|
|
|
{
|
2000-10-03 13:16:38 +08:00
|
|
|
struct isakmp_gen e;
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2007-08-29 20:31:00 +08:00
|
|
|
ND_TCHECK(*ext);
|
2000-10-03 13:16:38 +08:00
|
|
|
safememcpy(&e, ext, sizeof(e));
|
2007-08-29 10:38:14 +08:00
|
|
|
ikev2_pay_print(ndo, NPSTR(tpay), e.critical);
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," len=%d", ntohs(e.len) - 4));
|
2007-08-29 20:31:00 +08:00
|
|
|
if (2 < ndo->ndo_vflag && 4 < ntohs(e.len)) {
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," "));
|
|
|
|
if (!rawprint(ndo, (caddr_t)(ext + 1), ntohs(e.len) - 4))
|
|
|
|
goto trunc;
|
|
|
|
}
|
|
|
|
return (u_char *)ext + ntohs(e.len);
|
|
|
|
trunc:
|
|
|
|
ND_PRINT((ndo," [|%s]", NPSTR(tpay)));
|
|
|
|
return NULL;
|
|
|
|
}
|
2003-12-15 18:40:13 +08:00
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
static const u_char *
|
2007-08-29 10:58:43 +08:00
|
|
|
ikev2_t_print(netdissect_options *ndo, u_char tpay _U_, int pcount,
|
2007-08-29 10:38:14 +08:00
|
|
|
const struct isakmp_gen *ext, u_int item_len,
|
|
|
|
const u_char *ep, u_int32_t phase _U_, u_int32_t doi _U_,
|
2007-08-29 10:58:43 +08:00
|
|
|
u_int32_t proto _U_, int depth _U_)
|
2007-08-29 10:38:14 +08:00
|
|
|
{
|
|
|
|
const struct ikev2_t *p;
|
|
|
|
struct ikev2_t t;
|
|
|
|
u_int16_t t_id;
|
|
|
|
const u_char *cp;
|
|
|
|
const char *idstr;
|
|
|
|
const struct attrmap *map;
|
|
|
|
size_t nmap;
|
|
|
|
const u_char *ep2;
|
|
|
|
|
|
|
|
p = (struct ikev2_t *)ext;
|
2007-08-29 20:31:00 +08:00
|
|
|
ND_TCHECK(*p);
|
2007-08-29 10:38:14 +08:00
|
|
|
safememcpy(&t, ext, sizeof(t));
|
|
|
|
ikev2_pay_print(ndo, NPSTR(ISAKMP_NPTYPE_T), t.h.critical);
|
|
|
|
|
|
|
|
t_id = ntohs(t.t_id);
|
|
|
|
|
|
|
|
map = NULL;
|
|
|
|
nmap = 0;
|
|
|
|
|
|
|
|
switch (t.t_type) {
|
|
|
|
case IV2_T_ENCR:
|
|
|
|
idstr = STR_OR_ID(t_id, esp_p_map);
|
|
|
|
map = encr_t_map;
|
|
|
|
nmap = sizeof(encr_t_map)/sizeof(encr_t_map[0]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IV2_T_PRF:
|
|
|
|
idstr = STR_OR_ID(t_id, prf_p_map);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IV2_T_INTEG:
|
|
|
|
idstr = STR_OR_ID(t_id, integ_p_map);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IV2_T_DH:
|
|
|
|
idstr = STR_OR_ID(t_id, dh_p_map);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IV2_T_ESN:
|
|
|
|
idstr = STR_OR_ID(t_id, esn_p_map);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
idstr = NULL;
|
|
|
|
break;
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
2002-09-05 08:43:21 +08:00
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
if (idstr)
|
|
|
|
ND_PRINT((ndo," #%u type=%s id=%s ", pcount,
|
|
|
|
STR_OR_ID(t.t_type, ikev2_t_type_map),
|
|
|
|
idstr));
|
|
|
|
else
|
|
|
|
ND_PRINT((ndo," #%u type=%s id=%u ", pcount,
|
|
|
|
STR_OR_ID(t.t_type, ikev2_t_type_map),
|
|
|
|
t.t_id));
|
|
|
|
cp = (u_char *)(p + 1);
|
|
|
|
ep2 = (u_char *)p + item_len;
|
|
|
|
while (cp < ep && cp < ep2) {
|
|
|
|
if (map && nmap) {
|
|
|
|
cp = ikev1_attrmap_print(ndo, cp, (ep < ep2) ? ep : ep2,
|
|
|
|
map, nmap);
|
|
|
|
} else
|
|
|
|
cp = ikev1_attr_print(ndo, cp, (ep < ep2) ? ep : ep2);
|
|
|
|
}
|
|
|
|
if (ep < ep2)
|
|
|
|
ND_PRINT((ndo,"..."));
|
1999-10-30 13:11:06 +08:00
|
|
|
return cp;
|
2004-03-12 10:17:18 +08:00
|
|
|
trunc:
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_T)));
|
2004-03-12 10:17:18 +08:00
|
|
|
return NULL;
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
|
|
|
|
2002-09-05 08:43:21 +08:00
|
|
|
static const u_char *
|
2007-08-29 10:58:43 +08:00
|
|
|
ikev2_p_print(netdissect_options *ndo, u_char tpay _U_, int pcount _U_,
|
2007-08-29 10:38:14 +08:00
|
|
|
const struct isakmp_gen *ext, u_int item_len _U_,
|
|
|
|
const u_char *ep, u_int32_t phase, u_int32_t doi0,
|
|
|
|
u_int32_t proto0 _U_, int depth)
|
1999-10-30 13:11:06 +08:00
|
|
|
{
|
2007-08-29 10:38:14 +08:00
|
|
|
const struct ikev2_p *p;
|
|
|
|
struct ikev2_p prop;
|
2002-09-05 08:43:21 +08:00
|
|
|
const u_char *cp;
|
2007-08-29 10:38:14 +08:00
|
|
|
|
|
|
|
p = (struct ikev2_p *)ext;
|
2007-08-29 20:31:00 +08:00
|
|
|
ND_TCHECK(*p);
|
2007-08-29 10:38:14 +08:00
|
|
|
safememcpy(&prop, ext, sizeof(prop));
|
|
|
|
ikev2_pay_print(ndo, NPSTR(ISAKMP_NPTYPE_P), prop.h.critical);
|
|
|
|
|
2007-11-23 05:53:43 +08:00
|
|
|
ND_PRINT((ndo," #%u protoid=%s transform=%d len=%u",
|
|
|
|
prop.p_no, PROTOIDSTR(prop.prot_id),
|
|
|
|
prop.num_t, ntohs(prop.h.len)));
|
2007-08-29 10:38:14 +08:00
|
|
|
if (prop.spi_size) {
|
|
|
|
ND_PRINT((ndo," spi="));
|
|
|
|
if (!rawprint(ndo, (caddr_t)(p + 1), prop.spi_size))
|
|
|
|
goto trunc;
|
|
|
|
}
|
|
|
|
|
|
|
|
ext = (struct isakmp_gen *)((u_char *)(p + 1) + prop.spi_size);
|
2007-08-29 20:31:00 +08:00
|
|
|
ND_TCHECK(*ext);
|
2007-11-23 05:53:43 +08:00
|
|
|
|
2007-11-25 02:13:33 +08:00
|
|
|
cp = ikev2_sub_print(ndo, NULL, ISAKMP_NPTYPE_T, ext, ep, phase, doi0,
|
2007-08-29 10:38:14 +08:00
|
|
|
prop.prot_id, depth);
|
|
|
|
|
|
|
|
return cp;
|
|
|
|
trunc:
|
|
|
|
ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_P)));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const u_char *
|
|
|
|
ikev2_sa_print(netdissect_options *ndo, u_char tpay,
|
|
|
|
const struct isakmp_gen *ext1,
|
|
|
|
u_int item_len _U_, const u_char *ep _U_,
|
|
|
|
u_int32_t phase _U_, u_int32_t doi _U_,
|
|
|
|
u_int32_t proto _U_, int depth _U_)
|
|
|
|
{
|
2000-10-03 13:16:38 +08:00
|
|
|
struct isakmp_gen e;
|
2009-06-29 15:55:07 +08:00
|
|
|
int osa_length, sa_length;
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2007-08-29 20:31:00 +08:00
|
|
|
ND_TCHECK(*ext1);
|
2007-08-29 10:38:14 +08:00
|
|
|
safememcpy(&e, ext1, sizeof(e));
|
|
|
|
ikev2_pay_print(ndo, "sa", e.critical);
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2009-06-29 15:55:07 +08:00
|
|
|
osa_length= ntohs(e.len);
|
|
|
|
sa_length = osa_length - 4;
|
|
|
|
ND_PRINT((ndo," len=%d", sa_length));
|
2000-10-03 13:16:38 +08:00
|
|
|
|
2007-11-25 02:13:33 +08:00
|
|
|
ikev2_sub_print(ndo, NULL, ISAKMP_NPTYPE_P,
|
2007-08-29 10:38:14 +08:00
|
|
|
ext1+1, ep,
|
|
|
|
0, 0, 0, depth);
|
2004-03-12 10:17:18 +08:00
|
|
|
|
2009-06-29 15:55:07 +08:00
|
|
|
return (u_char *)ext1 + osa_length;
|
2007-08-29 10:38:14 +08:00
|
|
|
trunc:
|
|
|
|
ND_PRINT((ndo," [|%s]", NPSTR(tpay)));
|
|
|
|
return NULL;
|
|
|
|
}
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
static const u_char *
|
|
|
|
ikev2_ke_print(netdissect_options *ndo, u_char tpay,
|
|
|
|
const struct isakmp_gen *ext,
|
|
|
|
u_int item_len _U_, const u_char *ep _U_,
|
|
|
|
u_int32_t phase _U_, u_int32_t doi _U_,
|
|
|
|
u_int32_t proto _U_, int depth _U_)
|
|
|
|
{
|
|
|
|
struct ikev2_ke ke;
|
|
|
|
struct ikev2_ke *k;
|
2002-09-05 08:43:21 +08:00
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
k = (struct ikev2_ke *)ext;
|
2007-08-29 20:31:00 +08:00
|
|
|
ND_TCHECK(*ext);
|
2007-08-29 10:38:14 +08:00
|
|
|
safememcpy(&ke, ext, sizeof(ke));
|
|
|
|
ikev2_pay_print(ndo, NPSTR(tpay), ke.h.critical);
|
|
|
|
|
|
|
|
ND_PRINT((ndo," len=%u group=%s", ntohs(ke.h.len) - 8,
|
|
|
|
STR_OR_ID(ntohs(ke.ke_group), dh_p_map)));
|
|
|
|
|
2007-08-29 20:31:00 +08:00
|
|
|
if (2 < ndo->ndo_vflag && 8 < ntohs(ke.h.len)) {
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," "));
|
|
|
|
if (!rawprint(ndo, (caddr_t)(k + 1), ntohs(ke.h.len) - 8))
|
|
|
|
goto trunc;
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
2007-08-29 10:38:14 +08:00
|
|
|
return (u_char *)ext + ntohs(ke.h.len);
|
2004-01-07 16:00:51 +08:00
|
|
|
trunc:
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," [|%s]", NPSTR(tpay)));
|
2004-01-07 16:00:51 +08:00
|
|
|
return NULL;
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
static const u_char *
|
|
|
|
ikev2_ID_print(netdissect_options *ndo, u_char tpay,
|
|
|
|
const struct isakmp_gen *ext,
|
|
|
|
u_int item_len _U_, const u_char *ep _U_,
|
|
|
|
u_int32_t phase _U_, u_int32_t doi _U_,
|
|
|
|
u_int32_t proto _U_, int depth _U_)
|
1999-10-30 13:11:06 +08:00
|
|
|
{
|
2007-11-25 02:13:33 +08:00
|
|
|
struct ikev2_id id;
|
|
|
|
int id_len, idtype_len, i;
|
|
|
|
unsigned int dumpascii, dumphex;
|
|
|
|
unsigned char *typedata;
|
|
|
|
|
|
|
|
ND_TCHECK(*ext);
|
|
|
|
safememcpy(&id, ext, sizeof(id));
|
|
|
|
ikev2_pay_print(ndo, NPSTR(tpay), id.h.critical);
|
|
|
|
|
|
|
|
id_len = ntohs(id.h.len);
|
|
|
|
|
|
|
|
ND_PRINT((ndo," len=%d", id_len - 4));
|
|
|
|
if (2 < ndo->ndo_vflag && 4 < id_len) {
|
|
|
|
ND_PRINT((ndo," "));
|
|
|
|
if (!rawprint(ndo, (caddr_t)(ext + 1), id_len - 4))
|
|
|
|
goto trunc;
|
|
|
|
}
|
|
|
|
|
|
|
|
idtype_len =id_len - sizeof(struct ikev2_id);
|
|
|
|
dumpascii = 0;
|
|
|
|
dumphex = 0;
|
|
|
|
typedata = (unsigned char *)(ext)+sizeof(struct ikev2_id);
|
|
|
|
|
|
|
|
switch(id.type) {
|
|
|
|
case ID_IPV4_ADDR:
|
|
|
|
ND_PRINT((ndo, " ipv4:"));
|
|
|
|
dumphex=1;
|
|
|
|
break;
|
|
|
|
case ID_FQDN:
|
|
|
|
ND_PRINT((ndo, " fqdn:"));
|
|
|
|
dumpascii=1;
|
|
|
|
break;
|
|
|
|
case ID_RFC822_ADDR:
|
|
|
|
ND_PRINT((ndo, " rfc822:"));
|
|
|
|
dumpascii=1;
|
|
|
|
break;
|
|
|
|
case ID_IPV6_ADDR:
|
|
|
|
ND_PRINT((ndo, " ipv6:"));
|
|
|
|
dumphex=1;
|
|
|
|
break;
|
|
|
|
case ID_DER_ASN1_DN:
|
|
|
|
ND_PRINT((ndo, " dn:"));
|
|
|
|
dumphex=1;
|
|
|
|
break;
|
|
|
|
case ID_DER_ASN1_GN:
|
|
|
|
ND_PRINT((ndo, " gn:"));
|
|
|
|
dumphex=1;
|
|
|
|
break;
|
|
|
|
case ID_KEY_ID:
|
|
|
|
ND_PRINT((ndo, " keyid:"));
|
|
|
|
dumphex=1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(dumpascii) {
|
|
|
|
ND_TCHECK2(*typedata, idtype_len);
|
|
|
|
for(i=0; i<idtype_len; i++) {
|
|
|
|
if(isprint(typedata[i])) {
|
|
|
|
ND_PRINT((ndo, "%c", typedata[i]));
|
|
|
|
} else {
|
|
|
|
ND_PRINT((ndo, "."));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(dumphex) {
|
2007-11-27 11:57:20 +08:00
|
|
|
if (!rawprint(ndo, (caddr_t)typedata, idtype_len))
|
2007-11-25 02:13:33 +08:00
|
|
|
goto trunc;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (u_char *)ext + id_len;
|
|
|
|
trunc:
|
|
|
|
ND_PRINT((ndo," [|%s]", NPSTR(tpay)));
|
|
|
|
return NULL;
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
1999-10-18 05:59:12 +08:00
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
static const u_char *
|
|
|
|
ikev2_cert_print(netdissect_options *ndo, u_char tpay,
|
|
|
|
const struct isakmp_gen *ext,
|
|
|
|
u_int item_len _U_, const u_char *ep _U_,
|
|
|
|
u_int32_t phase _U_, u_int32_t doi _U_,
|
|
|
|
u_int32_t proto _U_, int depth _U_)
|
2000-10-03 13:16:38 +08:00
|
|
|
{
|
2007-08-29 10:38:14 +08:00
|
|
|
return ikev2_gen_print(ndo, tpay, ext);
|
2000-10-03 13:16:38 +08:00
|
|
|
}
|
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
static const u_char *
|
|
|
|
ikev2_cr_print(netdissect_options *ndo, u_char tpay,
|
|
|
|
const struct isakmp_gen *ext,
|
|
|
|
u_int item_len _U_, const u_char *ep _U_,
|
|
|
|
u_int32_t phase _U_, u_int32_t doi _U_,
|
|
|
|
u_int32_t proto _U_, int depth _U_)
|
1999-10-30 13:11:06 +08:00
|
|
|
{
|
2007-08-29 10:38:14 +08:00
|
|
|
return ikev2_gen_print(ndo, tpay, ext);
|
|
|
|
}
|
1999-10-18 05:59:12 +08:00
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
static const u_char *
|
|
|
|
ikev2_auth_print(netdissect_options *ndo, u_char tpay,
|
|
|
|
const struct isakmp_gen *ext,
|
|
|
|
u_int item_len _U_, const u_char *ep _U_,
|
|
|
|
u_int32_t phase _U_, u_int32_t doi _U_,
|
|
|
|
u_int32_t proto _U_, int depth _U_)
|
|
|
|
{
|
2007-11-27 11:57:20 +08:00
|
|
|
struct ikev2_auth a;
|
2007-08-29 10:58:43 +08:00
|
|
|
const char *v2_auth[]={ "invalid", "rsasig",
|
|
|
|
"shared-secret", "dsssig" };
|
2007-11-27 11:57:20 +08:00
|
|
|
u_char *authdata = (u_char*)ext + sizeof(a);
|
|
|
|
unsigned int len;
|
1999-10-18 05:59:12 +08:00
|
|
|
|
2007-08-29 20:31:00 +08:00
|
|
|
ND_TCHECK(*ext);
|
2007-11-27 11:57:20 +08:00
|
|
|
safememcpy(&a, ext, sizeof(a));
|
|
|
|
ikev2_pay_print(ndo, NPSTR(tpay), a.h.critical);
|
|
|
|
len = ntohs(a.h.len);
|
2000-10-03 13:16:38 +08:00
|
|
|
|
2007-11-27 11:57:20 +08:00
|
|
|
ND_PRINT((ndo," len=%d method=%s", len-4,
|
|
|
|
STR_OR_ID(a.auth_method, v2_auth)));
|
1999-10-18 05:59:12 +08:00
|
|
|
|
2007-11-27 11:57:20 +08:00
|
|
|
if (1 < ndo->ndo_vflag && 4 < len) {
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," authdata=("));
|
2007-11-27 11:57:20 +08:00
|
|
|
if (!rawprint(ndo, (caddr_t)authdata, len - sizeof(a)))
|
2007-08-29 10:38:14 +08:00
|
|
|
goto trunc;
|
|
|
|
ND_PRINT((ndo,") "));
|
2007-11-27 11:57:20 +08:00
|
|
|
} else if(ndo->ndo_vflag && 4 < len) {
|
|
|
|
if(!ike_show_somedata(ndo, authdata, ep)) goto trunc;
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
|
|
|
|
2007-11-27 11:57:20 +08:00
|
|
|
return (u_char *)ext + len;
|
2007-08-29 10:38:14 +08:00
|
|
|
trunc:
|
|
|
|
ND_PRINT((ndo," [|%s]", NPSTR(tpay)));
|
|
|
|
return NULL;
|
|
|
|
}
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
static const u_char *
|
|
|
|
ikev2_nonce_print(netdissect_options *ndo, u_char tpay,
|
|
|
|
const struct isakmp_gen *ext,
|
|
|
|
u_int item_len _U_, const u_char *ep _U_,
|
|
|
|
u_int32_t phase _U_, u_int32_t doi _U_,
|
|
|
|
u_int32_t proto _U_, int depth _U_)
|
|
|
|
{
|
|
|
|
struct isakmp_gen e;
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2007-08-29 20:31:00 +08:00
|
|
|
ND_TCHECK(*ext);
|
2007-08-29 10:38:14 +08:00
|
|
|
safememcpy(&e, ext, sizeof(e));
|
|
|
|
ikev2_pay_print(ndo, "nonce", e.critical);
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," len=%d", ntohs(e.len) - 4));
|
|
|
|
if (1 < ndo->ndo_vflag && 4 < ntohs(e.len)) {
|
|
|
|
ND_PRINT((ndo," nonce=("));
|
|
|
|
if (!rawprint(ndo, (caddr_t)(ext + 1), ntohs(e.len) - 4))
|
|
|
|
goto trunc;
|
|
|
|
ND_PRINT((ndo,") "));
|
|
|
|
} else if(ndo->ndo_vflag && 4 < ntohs(e.len)) {
|
|
|
|
if(!ike_show_somedata(ndo, (const u_char *)(ext+1), ep)) goto trunc;
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
1999-10-18 05:59:12 +08:00
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
return (u_char *)ext + ntohs(e.len);
|
|
|
|
trunc:
|
|
|
|
ND_PRINT((ndo," [|%s]", NPSTR(tpay)));
|
|
|
|
return NULL;
|
|
|
|
}
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
/* notify payloads */
|
|
|
|
static const u_char *
|
2007-08-29 10:58:43 +08:00
|
|
|
ikev2_n_print(netdissect_options *ndo, u_char tpay _U_,
|
2007-08-29 10:38:14 +08:00
|
|
|
const struct isakmp_gen *ext,
|
|
|
|
u_int item_len _U_, const u_char *ep _U_,
|
|
|
|
u_int32_t phase _U_, u_int32_t doi _U_,
|
|
|
|
u_int32_t proto _U_, int depth _U_)
|
|
|
|
{
|
|
|
|
struct ikev2_n *p, n;
|
|
|
|
const u_char *cp;
|
|
|
|
u_char *ep2;
|
|
|
|
u_char showspi, showdata, showsomedata;
|
2007-08-29 10:58:43 +08:00
|
|
|
const char *notify_name;
|
2007-08-29 10:38:14 +08:00
|
|
|
u_int32_t type;
|
|
|
|
|
|
|
|
p = (struct ikev2_n *)ext;
|
2007-08-29 20:31:00 +08:00
|
|
|
ND_TCHECK(*p);
|
2007-08-29 10:38:14 +08:00
|
|
|
safememcpy(&n, ext, sizeof(n));
|
|
|
|
ikev2_pay_print(ndo, NPSTR(ISAKMP_NPTYPE_N), n.h.critical);
|
|
|
|
|
|
|
|
showspi = 1;
|
|
|
|
showdata = 0;
|
|
|
|
showsomedata=0;
|
|
|
|
notify_name=NULL;
|
|
|
|
|
|
|
|
ND_PRINT((ndo," prot_id=%s", PROTOIDSTR(n.prot_id)));
|
|
|
|
|
|
|
|
type = ntohs(n.type);
|
|
|
|
|
|
|
|
/* notify space is annoying sparse */
|
|
|
|
switch(type) {
|
|
|
|
case IV2_NOTIFY_UNSUPPORTED_CRITICAL_PAYLOAD:
|
|
|
|
notify_name = "unsupported_critical_payload";
|
|
|
|
showspi = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IV2_NOTIFY_INVALID_IKE_SPI:
|
|
|
|
notify_name = "invalid_ike_spi";
|
|
|
|
showspi = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IV2_NOTIFY_INVALID_MAJOR_VERSION:
|
|
|
|
notify_name = "invalid_major_version";
|
|
|
|
showspi = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IV2_NOTIFY_INVALID_SYNTAX:
|
|
|
|
notify_name = "invalid_syntax";
|
|
|
|
showspi = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IV2_NOTIFY_INVALID_MESSAGE_ID:
|
|
|
|
notify_name = "invalid_message_id";
|
|
|
|
showspi = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IV2_NOTIFY_INVALID_SPI:
|
|
|
|
notify_name = "invalid_spi";
|
|
|
|
showspi = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IV2_NOTIFY_NO_PROPOSAL_CHOSEN:
|
|
|
|
notify_name = "no_protocol_chosen";
|
|
|
|
showspi = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IV2_NOTIFY_INVALID_KE_PAYLOAD:
|
|
|
|
notify_name = "invalid_ke_payload";
|
|
|
|
showspi = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IV2_NOTIFY_AUTHENTICATION_FAILED:
|
|
|
|
notify_name = "authentication_failed";
|
|
|
|
showspi = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IV2_NOTIFY_SINGLE_PAIR_REQUIRED:
|
|
|
|
notify_name = "single_pair_required";
|
|
|
|
showspi = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IV2_NOTIFY_NO_ADDITIONAL_SAS:
|
|
|
|
notify_name = "no_additional_sas";
|
|
|
|
showspi = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IV2_NOTIFY_INTERNAL_ADDRESS_FAILURE:
|
|
|
|
notify_name = "internal_address_failure";
|
|
|
|
showspi = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IV2_NOTIFY_FAILED_CP_REQUIRED:
|
|
|
|
notify_name = "failed:cp_required";
|
|
|
|
showspi = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IV2_NOTIFY_INVALID_SELECTORS:
|
|
|
|
notify_name = "invalid_selectors";
|
|
|
|
showspi = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IV2_NOTIFY_INITIAL_CONTACT:
|
|
|
|
notify_name = "initial_contact";
|
|
|
|
showspi = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IV2_NOTIFY_SET_WINDOW_SIZE:
|
|
|
|
notify_name = "set_window_size";
|
|
|
|
showspi = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IV2_NOTIFY_ADDITIONAL_TS_POSSIBLE:
|
|
|
|
notify_name = "additional_ts_possible";
|
|
|
|
showspi = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IV2_NOTIFY_IPCOMP_SUPPORTED:
|
|
|
|
notify_name = "ipcomp_supported";
|
|
|
|
showspi = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IV2_NOTIFY_NAT_DETECTION_SOURCE_IP:
|
|
|
|
notify_name = "nat_detection_source_ip";
|
|
|
|
showspi = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IV2_NOTIFY_NAT_DETECTION_DESTINATION_IP:
|
|
|
|
notify_name = "nat_detection_destination_ip";
|
|
|
|
showspi = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IV2_NOTIFY_COOKIE:
|
|
|
|
notify_name = "cookie";
|
|
|
|
showspi = 1;
|
|
|
|
showsomedata= 1;
|
|
|
|
showdata= 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IV2_NOTIFY_USE_TRANSPORT_MODE:
|
|
|
|
notify_name = "use_transport_mode";
|
|
|
|
showspi = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IV2_NOTIFY_HTTP_CERT_LOOKUP_SUPPORTED:
|
|
|
|
notify_name = "http_cert_lookup_supported";
|
|
|
|
showspi = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IV2_NOTIFY_REKEY_SA:
|
|
|
|
notify_name = "rekey_sa";
|
|
|
|
showspi = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IV2_NOTIFY_ESP_TFC_PADDING_NOT_SUPPORTED:
|
|
|
|
notify_name = "tfc_padding_not_supported";
|
|
|
|
showspi = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IV2_NOTIFY_NON_FIRST_FRAGMENTS_ALSO:
|
|
|
|
notify_name = "non_first_fragment_also";
|
|
|
|
showspi = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
if (type < 8192) {
|
|
|
|
notify_name="error";
|
|
|
|
} else if(type < 16384) {
|
|
|
|
notify_name="private-error";
|
|
|
|
} else if(type < 40960) {
|
|
|
|
notify_name="status";
|
|
|
|
} else {
|
|
|
|
notify_name="private-status";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(notify_name) {
|
|
|
|
ND_PRINT((ndo," type=%u(%s)", type, notify_name));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (showspi && n.spi_size) {
|
|
|
|
ND_PRINT((ndo," spi="));
|
|
|
|
if (!rawprint(ndo, (caddr_t)(p + 1), n.spi_size))
|
|
|
|
goto trunc;
|
|
|
|
}
|
|
|
|
|
|
|
|
cp = (u_char *)(p + 1) + n.spi_size;
|
|
|
|
ep2 = (u_char *)p + item_len;
|
|
|
|
|
|
|
|
if(3 < ndo->ndo_vflag) {
|
|
|
|
showdata = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((showdata || (showsomedata && ep-cp < 30)) && cp < ep) {
|
|
|
|
ND_PRINT((ndo," data=("));
|
|
|
|
if (!rawprint(ndo, (caddr_t)(cp), ep - cp))
|
|
|
|
goto trunc;
|
|
|
|
|
|
|
|
ND_PRINT((ndo,")"));
|
|
|
|
|
|
|
|
} else if(showsomedata && cp < ep) {
|
|
|
|
if(!ike_show_somedata(ndo, cp, ep)) goto trunc;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (u_char *)ext + item_len;
|
|
|
|
trunc:
|
|
|
|
ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_N)));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const u_char *
|
|
|
|
ikev2_d_print(netdissect_options *ndo, u_char tpay,
|
|
|
|
const struct isakmp_gen *ext,
|
|
|
|
u_int item_len _U_, const u_char *ep _U_,
|
|
|
|
u_int32_t phase _U_, u_int32_t doi _U_,
|
|
|
|
u_int32_t proto _U_, int depth _U_)
|
|
|
|
{
|
|
|
|
return ikev2_gen_print(ndo, tpay, ext);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const u_char *
|
|
|
|
ikev2_vid_print(netdissect_options *ndo, u_char tpay,
|
|
|
|
const struct isakmp_gen *ext,
|
|
|
|
u_int item_len _U_, const u_char *ep _U_,
|
|
|
|
u_int32_t phase _U_, u_int32_t doi _U_,
|
|
|
|
u_int32_t proto _U_, int depth _U_)
|
|
|
|
{
|
|
|
|
struct isakmp_gen e;
|
|
|
|
const u_char *vid;
|
|
|
|
int i, len;
|
|
|
|
|
2007-08-29 20:31:00 +08:00
|
|
|
ND_TCHECK(*ext);
|
2007-08-29 10:38:14 +08:00
|
|
|
safememcpy(&e, ext, sizeof(e));
|
|
|
|
ikev2_pay_print(ndo, NPSTR(tpay), e.critical);
|
|
|
|
ND_PRINT((ndo," len=%d vid=", ntohs(e.len) - 4));
|
|
|
|
|
|
|
|
vid = (const u_char *)(ext+1);
|
|
|
|
len = ntohs(e.len) - 4;
|
2007-08-29 20:31:00 +08:00
|
|
|
ND_TCHECK2(*vid, len);
|
2007-08-29 10:38:14 +08:00
|
|
|
for(i=0; i<len; i++) {
|
|
|
|
if(isprint(vid[i])) ND_PRINT((ndo, "%c", vid[i]));
|
2009-05-25 05:06:10 +08:00
|
|
|
else ND_PRINT((ndo, "."));
|
2007-08-29 10:38:14 +08:00
|
|
|
}
|
2007-08-29 20:31:00 +08:00
|
|
|
if (2 < ndo->ndo_vflag && 4 < len) {
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo," "));
|
|
|
|
if (!rawprint(ndo, (caddr_t)(ext + 1), ntohs(e.len) - 4))
|
|
|
|
goto trunc;
|
|
|
|
}
|
|
|
|
return (u_char *)ext + ntohs(e.len);
|
|
|
|
trunc:
|
|
|
|
ND_PRINT((ndo," [|%s]", NPSTR(tpay)));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const u_char *
|
|
|
|
ikev2_TS_print(netdissect_options *ndo, u_char tpay,
|
|
|
|
const struct isakmp_gen *ext,
|
|
|
|
u_int item_len _U_, const u_char *ep _U_,
|
|
|
|
u_int32_t phase _U_, u_int32_t doi _U_,
|
|
|
|
u_int32_t proto _U_, int depth _U_)
|
|
|
|
{
|
|
|
|
return ikev2_gen_print(ndo, tpay, ext);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const u_char *
|
2008-02-06 03:34:25 +08:00
|
|
|
ikev2_e_print(netdissect_options *ndo,
|
|
|
|
#ifndef HAVE_LIBCRYPTO
|
|
|
|
_U_
|
|
|
|
#endif
|
|
|
|
struct isakmp *base,
|
2007-11-25 02:13:33 +08:00
|
|
|
u_char tpay,
|
2008-02-06 03:34:25 +08:00
|
|
|
const struct isakmp_gen *ext,
|
|
|
|
u_int item_len _U_, const u_char *ep _U_,
|
|
|
|
#ifndef HAVE_LIBCRYPTO
|
|
|
|
_U_
|
|
|
|
#endif
|
|
|
|
u_int32_t phase,
|
|
|
|
#ifndef HAVE_LIBCRYPTO
|
|
|
|
_U_
|
|
|
|
#endif
|
|
|
|
u_int32_t doi,
|
|
|
|
#ifndef HAVE_LIBCRYPTO
|
|
|
|
_U_
|
|
|
|
#endif
|
|
|
|
u_int32_t proto,
|
|
|
|
#ifndef HAVE_LIBCRYPTO
|
|
|
|
_U_
|
|
|
|
#endif
|
|
|
|
int depth)
|
2007-08-29 10:38:14 +08:00
|
|
|
{
|
2007-11-23 05:53:43 +08:00
|
|
|
struct isakmp_gen e;
|
2007-11-25 02:13:33 +08:00
|
|
|
u_char *dat;
|
|
|
|
volatile int dlen;
|
2007-11-23 05:53:43 +08:00
|
|
|
|
|
|
|
ND_TCHECK(*ext);
|
|
|
|
safememcpy(&e, ext, sizeof(e));
|
|
|
|
ikev2_pay_print(ndo, NPSTR(tpay), e.critical);
|
|
|
|
|
2007-11-25 02:13:33 +08:00
|
|
|
dlen = ntohs(e.len)-4;
|
|
|
|
|
|
|
|
ND_PRINT((ndo," len=%d", dlen));
|
|
|
|
if (2 < ndo->ndo_vflag && 4 < dlen) {
|
2007-11-23 05:53:43 +08:00
|
|
|
ND_PRINT((ndo," "));
|
2007-11-25 02:13:33 +08:00
|
|
|
if (!rawprint(ndo, (caddr_t)(ext + 1), dlen))
|
2007-11-23 05:53:43 +08:00
|
|
|
goto trunc;
|
|
|
|
}
|
|
|
|
|
2007-11-25 02:13:33 +08:00
|
|
|
dat = (u_char *)(ext+1);
|
|
|
|
ND_TCHECK2(*dat, dlen);
|
|
|
|
|
2008-01-25 03:57:46 +08:00
|
|
|
#ifdef HAVE_LIBCRYPTO
|
2007-11-25 02:13:33 +08:00
|
|
|
/* try to decypt it! */
|
|
|
|
if(esp_print_decrypt_buffer_by_ikev2(ndo,
|
|
|
|
base->flags & ISAKMP_FLAG_I,
|
|
|
|
base->i_ck, base->r_ck,
|
|
|
|
dat, dat+dlen)) {
|
|
|
|
|
|
|
|
ext = (const struct isakmp_gen *)ndo->ndo_packetp;
|
|
|
|
|
|
|
|
/* got it decrypted, print stuff inside. */
|
|
|
|
ikev2_sub_print(ndo, base, e.np, ext, ndo->ndo_snapend,
|
|
|
|
phase, doi, proto, depth+1);
|
|
|
|
}
|
2008-01-25 03:57:46 +08:00
|
|
|
#endif
|
2007-11-25 02:13:33 +08:00
|
|
|
|
|
|
|
|
2007-11-23 05:53:43 +08:00
|
|
|
/* always return NULL, because E must be at end, and NP refers
|
|
|
|
* to what was inside.
|
|
|
|
*/
|
|
|
|
return NULL;
|
|
|
|
trunc:
|
|
|
|
ND_PRINT((ndo," [|%s]", NPSTR(tpay)));
|
|
|
|
return NULL;
|
2007-08-29 10:38:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static const u_char *
|
|
|
|
ikev2_cp_print(netdissect_options *ndo, u_char tpay,
|
|
|
|
const struct isakmp_gen *ext,
|
|
|
|
u_int item_len _U_, const u_char *ep _U_,
|
|
|
|
u_int32_t phase _U_, u_int32_t doi _U_,
|
|
|
|
u_int32_t proto _U_, int depth _U_)
|
|
|
|
{
|
|
|
|
return ikev2_gen_print(ndo, tpay, ext);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const u_char *
|
|
|
|
ikev2_eap_print(netdissect_options *ndo, u_char tpay,
|
|
|
|
const struct isakmp_gen *ext,
|
|
|
|
u_int item_len _U_, const u_char *ep _U_,
|
|
|
|
u_int32_t phase _U_, u_int32_t doi _U_,
|
|
|
|
u_int32_t proto _U_, int depth _U_)
|
|
|
|
{
|
|
|
|
return ikev2_gen_print(ndo, tpay, ext);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const u_char *
|
|
|
|
ike_sub0_print(netdissect_options *ndo,
|
|
|
|
u_char np, const struct isakmp_gen *ext, const u_char *ep,
|
2007-11-23 05:53:43 +08:00
|
|
|
|
|
|
|
u_int32_t phase, u_int32_t doi, u_int32_t proto, int depth)
|
2007-08-29 10:38:14 +08:00
|
|
|
{
|
|
|
|
const u_char *cp;
|
|
|
|
struct isakmp_gen e;
|
|
|
|
u_int item_len;
|
|
|
|
|
|
|
|
cp = (u_char *)ext;
|
2007-08-29 20:31:00 +08:00
|
|
|
ND_TCHECK(*ext);
|
2007-08-29 10:38:14 +08:00
|
|
|
safememcpy(&e, ext, sizeof(e));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Since we can't have a payload length of less than 4 bytes,
|
|
|
|
* we need to bail out here if the generic header is nonsensical
|
|
|
|
* or truncated, otherwise we could loop forever processing
|
|
|
|
* zero-length items or otherwise misdissect the packet.
|
|
|
|
*/
|
|
|
|
item_len = ntohs(e.len);
|
|
|
|
if (item_len <= 4)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (NPFUNC(np)) {
|
|
|
|
/*
|
|
|
|
* XXX - what if item_len is too short, or too long,
|
|
|
|
* for this payload type?
|
|
|
|
*/
|
|
|
|
cp = (*npfunc[np])(ndo, np, ext, item_len, ep, phase, doi, proto, depth);
|
|
|
|
} else {
|
|
|
|
ND_PRINT((ndo,"%s", NPSTR(np)));
|
|
|
|
cp += item_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
return cp;
|
|
|
|
trunc:
|
|
|
|
ND_PRINT((ndo," [|isakmp]"));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const u_char *
|
|
|
|
ikev1_sub_print(netdissect_options *ndo,
|
|
|
|
u_char np, const struct isakmp_gen *ext, const u_char *ep,
|
|
|
|
u_int32_t phase, u_int32_t doi, u_int32_t proto, int depth)
|
|
|
|
{
|
|
|
|
const u_char *cp;
|
|
|
|
int i;
|
|
|
|
struct isakmp_gen e;
|
|
|
|
|
|
|
|
cp = (const u_char *)ext;
|
|
|
|
|
|
|
|
while (np) {
|
2007-08-29 20:31:00 +08:00
|
|
|
ND_TCHECK(*ext);
|
2007-08-29 10:38:14 +08:00
|
|
|
|
|
|
|
safememcpy(&e, ext, sizeof(e));
|
|
|
|
|
2007-08-29 20:31:00 +08:00
|
|
|
ND_TCHECK2(*ext, ntohs(e.len));
|
2007-08-29 10:38:14 +08:00
|
|
|
|
|
|
|
depth++;
|
|
|
|
ND_PRINT((ndo,"\n"));
|
|
|
|
for (i = 0; i < depth; i++)
|
|
|
|
ND_PRINT((ndo," "));
|
|
|
|
ND_PRINT((ndo,"("));
|
|
|
|
cp = ike_sub0_print(ndo, np, ext, ep, phase, doi, proto, depth);
|
|
|
|
ND_PRINT((ndo,")"));
|
|
|
|
depth--;
|
|
|
|
|
|
|
|
if (cp == NULL) {
|
|
|
|
/* Zero-length subitem */
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
np = e.np;
|
|
|
|
ext = (struct isakmp_gen *)cp;
|
|
|
|
}
|
|
|
|
return cp;
|
|
|
|
trunc:
|
|
|
|
ND_PRINT((ndo," [|%s]", NPSTR(np)));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
numstr(int x)
|
|
|
|
{
|
|
|
|
static char buf[20];
|
|
|
|
snprintf(buf, sizeof(buf), "#%d", x);
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* some compiler tries to optimize memcpy(), using the alignment constraint
|
|
|
|
* on the argument pointer type. by using this function, we try to avoid the
|
|
|
|
* optimization.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
safememcpy(void *p, const void *q, size_t l)
|
|
|
|
{
|
|
|
|
memcpy(p, q, l);
|
|
|
|
}
|
|
|
|
|
2009-06-10 08:18:31 +08:00
|
|
|
static void
|
2007-08-29 10:38:14 +08:00
|
|
|
ikev1_print(netdissect_options *ndo,
|
|
|
|
const u_char *bp, u_int length,
|
|
|
|
const u_char *bp2, struct isakmp *base)
|
|
|
|
{
|
|
|
|
const struct isakmp *p;
|
|
|
|
const u_char *ep;
|
|
|
|
u_char np;
|
|
|
|
int i;
|
|
|
|
int phase;
|
|
|
|
|
|
|
|
p = (const struct isakmp *)bp;
|
|
|
|
ep = ndo->ndo_snapend;
|
|
|
|
|
|
|
|
phase = (*(u_int32_t *)base->msgid == 0) ? 1 : 2;
|
|
|
|
if (phase == 1)
|
|
|
|
ND_PRINT((ndo," phase %d", phase));
|
|
|
|
else
|
|
|
|
ND_PRINT((ndo," phase %d/others", phase));
|
|
|
|
|
|
|
|
i = cookie_find(&base->i_ck);
|
|
|
|
if (i < 0) {
|
|
|
|
if (iszero((u_char *)&base->r_ck, sizeof(base->r_ck))) {
|
|
|
|
/* the first packet */
|
|
|
|
ND_PRINT((ndo," I"));
|
|
|
|
if (bp2)
|
|
|
|
cookie_record(&base->i_ck, bp2);
|
|
|
|
} else
|
|
|
|
ND_PRINT((ndo," ?"));
|
|
|
|
} else {
|
|
|
|
if (bp2 && cookie_isinitiator(i, bp2))
|
|
|
|
ND_PRINT((ndo," I"));
|
|
|
|
else if (bp2 && cookie_isresponder(i, bp2))
|
|
|
|
ND_PRINT((ndo," R"));
|
|
|
|
else
|
|
|
|
ND_PRINT((ndo," ?"));
|
|
|
|
}
|
|
|
|
|
|
|
|
ND_PRINT((ndo," %s", ETYPESTR(base->etype)));
|
|
|
|
if (base->flags) {
|
|
|
|
ND_PRINT((ndo,"[%s%s]", base->flags & ISAKMP_FLAG_E ? "E" : "",
|
|
|
|
base->flags & ISAKMP_FLAG_C ? "C" : ""));
|
|
|
|
}
|
|
|
|
|
2007-08-29 20:31:00 +08:00
|
|
|
if (ndo->ndo_vflag) {
|
2007-08-29 10:38:14 +08:00
|
|
|
const struct isakmp_gen *ext;
|
|
|
|
int nparen;
|
|
|
|
|
|
|
|
ND_PRINT((ndo,":"));
|
|
|
|
|
|
|
|
/* regardless of phase... */
|
|
|
|
if (base->flags & ISAKMP_FLAG_E) {
|
|
|
|
/*
|
|
|
|
* encrypted, nothing we can do right now.
|
|
|
|
* we hope to decrypt the packet in the future...
|
|
|
|
*/
|
|
|
|
ND_PRINT((ndo," [encrypted %s]", NPSTR(base->np)));
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
nparen = 0;
|
|
|
|
CHECKLEN(p + 1, base->np);
|
|
|
|
np = base->np;
|
|
|
|
ext = (struct isakmp_gen *)(p + 1);
|
|
|
|
ikev1_sub_print(ndo, np, ext, ep, phase, 0, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
2007-08-29 20:31:00 +08:00
|
|
|
if (ndo->ndo_vflag) {
|
2007-08-29 10:38:14 +08:00
|
|
|
if (ntohl(base->len) != length) {
|
|
|
|
ND_PRINT((ndo," (len mismatch: isakmp %u/ip %u)",
|
|
|
|
(u_int32_t)ntohl(base->len), length));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const u_char *
|
2007-11-25 02:13:33 +08:00
|
|
|
ikev2_sub0_print(netdissect_options *ndo, struct isakmp *base,
|
|
|
|
u_char np, int pcount,
|
2007-08-29 10:38:14 +08:00
|
|
|
const struct isakmp_gen *ext, const u_char *ep,
|
|
|
|
u_int32_t phase, u_int32_t doi, u_int32_t proto, int depth)
|
|
|
|
{
|
|
|
|
const u_char *cp;
|
|
|
|
struct isakmp_gen e;
|
|
|
|
u_int item_len;
|
|
|
|
|
|
|
|
cp = (u_char *)ext;
|
2007-08-29 20:31:00 +08:00
|
|
|
ND_TCHECK(*ext);
|
2007-08-29 10:38:14 +08:00
|
|
|
safememcpy(&e, ext, sizeof(e));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Since we can't have a payload length of less than 4 bytes,
|
|
|
|
* we need to bail out here if the generic header is nonsensical
|
|
|
|
* or truncated, otherwise we could loop forever processing
|
|
|
|
* zero-length items or otherwise misdissect the packet.
|
|
|
|
*/
|
|
|
|
item_len = ntohs(e.len);
|
|
|
|
if (item_len <= 4)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if(np == ISAKMP_NPTYPE_P) {
|
|
|
|
cp = ikev2_p_print(ndo, np, pcount, ext, item_len,
|
|
|
|
ep, phase, doi, proto, depth);
|
|
|
|
} else if(np == ISAKMP_NPTYPE_T) {
|
|
|
|
cp = ikev2_t_print(ndo, np, pcount, ext, item_len,
|
|
|
|
ep, phase, doi, proto, depth);
|
2007-11-25 02:13:33 +08:00
|
|
|
} else if(np == ISAKMP_NPTYPE_v2E) {
|
|
|
|
cp = ikev2_e_print(ndo, base, np, ext, item_len,
|
|
|
|
ep, phase, doi, proto, depth);
|
2007-08-29 10:38:14 +08:00
|
|
|
} else if (NPFUNC(np)) {
|
|
|
|
/*
|
|
|
|
* XXX - what if item_len is too short, or too long,
|
|
|
|
* for this payload type?
|
|
|
|
*/
|
|
|
|
cp = (*npfunc[np])(ndo, np, /*pcount,*/ ext, item_len,
|
|
|
|
ep, phase, doi, proto, depth);
|
|
|
|
} else {
|
|
|
|
ND_PRINT((ndo,"%s", NPSTR(np)));
|
|
|
|
cp += item_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
return cp;
|
|
|
|
trunc:
|
|
|
|
ND_PRINT((ndo," [|isakmp]"));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const u_char *
|
|
|
|
ikev2_sub_print(netdissect_options *ndo,
|
2007-11-25 02:13:33 +08:00
|
|
|
struct isakmp *base,
|
2007-08-29 10:38:14 +08:00
|
|
|
u_char np, const struct isakmp_gen *ext, const u_char *ep,
|
|
|
|
u_int32_t phase, u_int32_t doi, u_int32_t proto, int depth)
|
|
|
|
{
|
|
|
|
const u_char *cp;
|
|
|
|
int i;
|
|
|
|
int pcount;
|
|
|
|
struct isakmp_gen e;
|
|
|
|
|
|
|
|
cp = (const u_char *)ext;
|
|
|
|
pcount = 0;
|
|
|
|
while (np) {
|
|
|
|
pcount++;
|
2007-08-29 20:31:00 +08:00
|
|
|
ND_TCHECK(*ext);
|
2007-08-29 10:38:14 +08:00
|
|
|
|
|
|
|
safememcpy(&e, ext, sizeof(e));
|
|
|
|
|
2007-08-29 20:31:00 +08:00
|
|
|
ND_TCHECK2(*ext, ntohs(e.len));
|
2007-08-29 10:38:14 +08:00
|
|
|
|
|
|
|
depth++;
|
|
|
|
ND_PRINT((ndo,"\n"));
|
|
|
|
for (i = 0; i < depth; i++)
|
|
|
|
ND_PRINT((ndo," "));
|
|
|
|
ND_PRINT((ndo,"("));
|
2007-11-25 02:13:33 +08:00
|
|
|
cp = ikev2_sub0_print(ndo, base, np, pcount,
|
2007-08-29 10:38:14 +08:00
|
|
|
ext, ep, phase, doi, proto, depth);
|
|
|
|
ND_PRINT((ndo,")"));
|
|
|
|
depth--;
|
|
|
|
|
|
|
|
if (cp == NULL) {
|
|
|
|
/* Zero-length subitem */
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
np = e.np;
|
|
|
|
ext = (struct isakmp_gen *)cp;
|
|
|
|
}
|
|
|
|
return cp;
|
|
|
|
trunc:
|
|
|
|
ND_PRINT((ndo," [|%s]", NPSTR(np)));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2007-08-29 10:58:43 +08:00
|
|
|
static void
|
2007-08-29 10:38:14 +08:00
|
|
|
ikev2_print(netdissect_options *ndo,
|
|
|
|
const u_char *bp, u_int length,
|
2007-08-29 10:58:43 +08:00
|
|
|
const u_char *bp2 _U_, struct isakmp *base)
|
2007-08-29 10:38:14 +08:00
|
|
|
{
|
|
|
|
const struct isakmp *p;
|
|
|
|
const u_char *ep;
|
|
|
|
u_char np;
|
|
|
|
int phase;
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
p = (const struct isakmp *)bp;
|
|
|
|
ep = ndo->ndo_snapend;
|
|
|
|
|
|
|
|
phase = (*(u_int32_t *)base->msgid == 0) ? 1 : 2;
|
|
|
|
if (phase == 1)
|
|
|
|
ND_PRINT((ndo, " parent_sa"));
|
|
|
|
else
|
|
|
|
ND_PRINT((ndo, " child_sa "));
|
|
|
|
|
|
|
|
ND_PRINT((ndo, " %s", ETYPESTR(base->etype)));
|
|
|
|
if (base->flags) {
|
2009-05-25 05:06:10 +08:00
|
|
|
ND_PRINT((ndo, "[%s%s%s]",
|
2007-08-29 10:38:14 +08:00
|
|
|
base->flags & ISAKMP_FLAG_I ? "I" : "",
|
|
|
|
base->flags & ISAKMP_FLAG_V ? "V" : "",
|
|
|
|
base->flags & ISAKMP_FLAG_R ? "R" : ""));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ndo->ndo_vflag) {
|
|
|
|
const struct isakmp_gen *ext;
|
|
|
|
int nparen;
|
|
|
|
|
|
|
|
ND_PRINT((ndo, ":"));
|
2003-12-20 18:03:19 +08:00
|
|
|
|
2003-12-20 17:58:10 +08:00
|
|
|
/* regardless of phase... */
|
2007-08-29 10:38:14 +08:00
|
|
|
if (base->flags & ISAKMP_FLAG_E) {
|
2003-12-20 17:58:10 +08:00
|
|
|
/*
|
|
|
|
* encrypted, nothing we can do right now.
|
|
|
|
* we hope to decrypt the packet in the future...
|
|
|
|
*/
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo, " [encrypted %s]", NPSTR(base->np)));
|
2003-12-20 17:58:10 +08:00
|
|
|
goto done;
|
|
|
|
}
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2003-12-20 17:58:10 +08:00
|
|
|
nparen = 0;
|
2007-08-29 10:38:14 +08:00
|
|
|
CHECKLEN(p + 1, base->np)
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
np = base->np;
|
2003-12-20 17:58:10 +08:00
|
|
|
ext = (struct isakmp_gen *)(p + 1);
|
2007-11-25 02:13:33 +08:00
|
|
|
ikev2_sub_print(ndo, base, np, ext, ep, phase, 0, 0, 0);
|
2003-12-20 17:58:10 +08:00
|
|
|
}
|
1999-10-18 05:59:12 +08:00
|
|
|
|
1999-10-30 13:11:06 +08:00
|
|
|
done:
|
2007-08-29 10:38:14 +08:00
|
|
|
if (ndo->ndo_vflag) {
|
|
|
|
if (ntohl(base->len) != length) {
|
|
|
|
ND_PRINT((ndo, " (len mismatch: isakmp %u/ip %u)",
|
|
|
|
(u_int32_t)ntohl(base->len), length));
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
|
|
|
}
|
1999-10-18 05:59:12 +08:00
|
|
|
}
|
2005-04-07 05:33:27 +08:00
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
void
|
|
|
|
isakmp_print(netdissect_options *ndo,
|
|
|
|
const u_char *bp, u_int length,
|
|
|
|
const u_char *bp2)
|
|
|
|
{
|
|
|
|
const struct isakmp *p;
|
|
|
|
struct isakmp base;
|
|
|
|
const u_char *ep;
|
|
|
|
int major, minor;
|
|
|
|
|
2008-01-25 03:57:46 +08:00
|
|
|
#ifdef HAVE_LIBCRYPTO
|
|
|
|
/* initialize SAs */
|
2007-11-25 02:13:33 +08:00
|
|
|
if (ndo->ndo_sa_list_head == NULL) {
|
|
|
|
if (ndo->ndo_espsecret)
|
|
|
|
esp_print_decodesecret(ndo);
|
|
|
|
}
|
2008-01-25 03:57:46 +08:00
|
|
|
#endif
|
2007-11-25 02:13:33 +08:00
|
|
|
|
2007-08-29 10:38:14 +08:00
|
|
|
p = (const struct isakmp *)bp;
|
|
|
|
ep = ndo->ndo_snapend;
|
|
|
|
|
|
|
|
if ((struct isakmp *)ep < p + 1) {
|
|
|
|
ND_PRINT((ndo,"[|isakmp]"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
safememcpy(&base, p, sizeof(base));
|
|
|
|
|
|
|
|
ND_PRINT((ndo,"isakmp"));
|
|
|
|
major = (base.vers & ISAKMP_VERS_MAJOR)
|
|
|
|
>> ISAKMP_VERS_MAJOR_SHIFT;
|
|
|
|
minor = (base.vers & ISAKMP_VERS_MINOR)
|
|
|
|
>> ISAKMP_VERS_MINOR_SHIFT;
|
|
|
|
|
|
|
|
if (ndo->ndo_vflag) {
|
|
|
|
ND_PRINT((ndo," %d.%d", major, minor));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ndo->ndo_vflag) {
|
|
|
|
ND_PRINT((ndo," msgid "));
|
2007-11-25 02:13:33 +08:00
|
|
|
hexprint(ndo, (caddr_t)&base.msgid, sizeof(base.msgid));
|
2007-08-29 10:38:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (1 < ndo->ndo_vflag) {
|
|
|
|
ND_PRINT((ndo," cookie "));
|
2007-11-25 02:13:33 +08:00
|
|
|
hexprint(ndo, (caddr_t)&base.i_ck, sizeof(base.i_ck));
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo,"->"));
|
2007-11-25 02:13:33 +08:00
|
|
|
hexprint(ndo, (caddr_t)&base.r_ck, sizeof(base.r_ck));
|
2007-08-29 10:38:14 +08:00
|
|
|
}
|
|
|
|
ND_PRINT((ndo,":"));
|
|
|
|
|
|
|
|
switch(major) {
|
|
|
|
case IKEv1_MAJOR_VERSION:
|
|
|
|
ikev1_print(ndo, bp, length, bp2, &base);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IKEv2_MAJOR_VERSION:
|
|
|
|
ikev2_print(ndo, bp, length, bp2, &base);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-07 05:33:27 +08:00
|
|
|
void
|
|
|
|
isakmp_rfc3948_print(netdissect_options *ndo,
|
|
|
|
const u_char *bp, u_int length,
|
|
|
|
const u_char *bp2)
|
|
|
|
{
|
|
|
|
const u_char *ep;
|
|
|
|
ep = ndo->ndo_snapend;
|
|
|
|
|
|
|
|
if(length == 1 && bp[0]==0xff) {
|
|
|
|
ND_PRINT((ndo, "isakmp-nat-keep-alive"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-04-07 08:28:17 +08:00
|
|
|
if(length < 4) {
|
|
|
|
goto trunc;
|
|
|
|
}
|
2007-08-29 10:38:14 +08:00
|
|
|
|
2005-04-07 05:33:27 +08:00
|
|
|
/*
|
|
|
|
* see if this is an IKE packet
|
|
|
|
*/
|
|
|
|
if(bp[0]==0 && bp[1]==0 && bp[2]==0 && bp[3]==0) {
|
2005-04-07 08:28:17 +08:00
|
|
|
ND_PRINT((ndo, "NONESP-encap: "));
|
2005-04-07 05:33:27 +08:00
|
|
|
isakmp_print(ndo, bp+4, length-4, bp2);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* must be an ESP packet */
|
|
|
|
{
|
|
|
|
int nh, enh, padlen;
|
|
|
|
int advance;
|
|
|
|
|
2005-04-07 08:28:17 +08:00
|
|
|
ND_PRINT((ndo, "UDP-encap: "));
|
|
|
|
|
2005-04-07 05:33:27 +08:00
|
|
|
advance = esp_print(ndo, bp, length, bp2, &enh, &padlen);
|
|
|
|
if(advance <= 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
bp += advance;
|
|
|
|
length -= advance + padlen;
|
|
|
|
nh = enh & 0xff;
|
|
|
|
|
2005-04-07 08:28:17 +08:00
|
|
|
ip_print_inner(ndo, bp, length, nh, bp2);
|
2005-04-07 05:33:27 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
trunc:
|
2007-08-29 10:38:14 +08:00
|
|
|
ND_PRINT((ndo,"[|isakmp]"));
|
2005-04-07 05:33:27 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-04-07 08:28:17 +08:00
|
|
|
/*
|
|
|
|
* Local Variables:
|
|
|
|
* c-style: whitesmith
|
|
|
|
* c-basic-offset: 8
|
|
|
|
* End:
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2005-04-07 05:33:27 +08:00
|
|
|
|
|
|
|
|