use new ip_print_demux() routine in ISAKMP UDP-ESP encap

printer.
This commit is contained in:
mcr 2005-04-07 00:28:17 +00:00
parent 289b2a35d4
commit 8c59e1bd93
4 changed files with 62 additions and 18 deletions

View File

@ -21,7 +21,7 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* @(#) $Header: /tcpdump/master/tcpdump/netdissect.h,v 1.15 2005-04-06 21:33:27 mcr Exp $ (LBL)
* @(#) $Header: /tcpdump/master/tcpdump/netdissect.h,v 1.16 2005-04-07 00:28:17 mcr Exp $ (LBL)
*/
#ifndef netdissect_h
@ -255,7 +255,11 @@ extern void isakmp_print(netdissect_options *,const u_char *,
extern void isakmp_rfc3948_print(netdissect_options *,const u_char *,
u_int, const u_char *);
extern void ip_print(netdissect_options *,const u_char *, u_int);
extern void ip_print_inner(netdissect_options *ndo,
const u_char *bp, u_int length, u_int nh,
const u_char *bp2);
/* stuff that has not yet been rototiled */
#if 0
extern void ascii_print_with_offset(netdissect_options *, const char *,
u_int, u_int);

View File

@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.148 2005-04-06 21:33:02 mcr Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.149 2005-04-07 00:28:17 mcr Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -359,7 +359,7 @@ static struct tok ip_frag_values[] = {
struct ip_print_demux_state {
const struct ip *ip;
const u_char *cp;
u_int hlen, len, off;
u_int len, off;
u_char nh;
int advance;
};
@ -512,6 +512,24 @@ again:
}
}
void
ip_print_inner(netdissect_options *ndo,
const u_char *bp,
u_int length, u_int nh,
const u_char *bp2)
{
struct ip_print_demux_state ipd;
ipd.ip = (const struct ip *)bp2;
ipd.cp = bp;
ipd.len = length;
ipd.off = 0;
ipd.nh = nh;
ipd.advance = 0;
ip_print_demux(ndo, &ipd);
}
/*
* print an IP datagram.
@ -524,6 +542,7 @@ ip_print(netdissect_options *ndo,
struct ip_print_demux_state ipd;
struct ip_print_demux_state *ipds=&ipd;
const u_char *ipend;
u_int hlen;
u_int16_t sum, ip_sum;
struct protoent *proto;
@ -544,9 +563,9 @@ ip_print(netdissect_options *ndo,
(void)printf("truncated-ip %u", length);
return;
}
ipds->hlen = IP_HL(ipds->ip) * 4;
if (ipds->hlen < sizeof (struct ip)) {
(void)printf("bad-hlen %u", ipds->hlen);
hlen = IP_HL(ipds->ip) * 4;
if (hlen < sizeof (struct ip)) {
(void)printf("bad-hlen %u", hlen);
return;
}
@ -554,7 +573,7 @@ ip_print(netdissect_options *ndo,
if (length < ipds->len)
(void)printf("truncated-ip - %u bytes missing! ",
ipds->len - length);
if (ipds->len < ipds->hlen) {
if (ipds->len < hlen) {
#ifdef GUESS_TSO
if (ipds->len) {
(void)printf("bad-len %u", ipds->len);
@ -577,7 +596,7 @@ ip_print(netdissect_options *ndo,
if (ipend < snapend)
snapend = ipend;
ipds->len -= ipds->hlen;
ipds->len -= hlen;
ipds->off = EXTRACT_16BITS(&ipds->ip->ip_off);
@ -615,14 +634,14 @@ ip_print(netdissect_options *ndo,
(void)printf(", length: %u", EXTRACT_16BITS(&ipds->ip->ip_len));
if ((ipds->hlen - sizeof(struct ip)) > 0) {
if ((hlen - sizeof(struct ip)) > 0) {
printf(", options ( ");
ip_optprint((u_char *)(ipds->ip + 1), ipds->hlen - sizeof(struct ip));
ip_optprint((u_char *)(ipds->ip + 1), hlen - sizeof(struct ip));
printf(" )");
}
if ((u_char *)ipds->ip + ipds->hlen <= snapend) {
sum = in_cksum((const u_short *)ipds->ip, ipds->hlen, 0);
if ((u_char *)ipds->ip + hlen <= snapend) {
sum = in_cksum((const u_short *)ipds->ip, hlen, 0);
if (sum != 0) {
ip_sum = EXTRACT_16BITS(&ipds->ip->ip_sum);
(void)printf(", bad cksum %x (->%x)!", ip_sum,
@ -638,7 +657,7 @@ ip_print(netdissect_options *ndo,
* level protocol.
*/
if ((ipds->off & 0x1fff) == 0) {
ipds->cp = (const u_char *)ipds->ip + ipds->hlen;
ipds->cp = (const u_char *)ipds->ip + hlen;
ipds->nh = ipds->ip->ip_p;
if (ipds->nh != IPPROTO_TCP && ipds->nh != IPPROTO_UDP &&
@ -694,5 +713,11 @@ ipN_print(register const u_char *bp, register u_int length)
}
}
/*
* Local Variables:
* c-style: whitesmith
* c-basic-offset: 8
* End:
*/

View File

@ -30,7 +30,7 @@
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/print-isakmp.c,v 1.50 2005-04-06 21:33:27 mcr Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-isakmp.c,v 1.51 2005-04-07 00:28:17 mcr Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -1400,12 +1400,15 @@ isakmp_rfc3948_print(netdissect_options *ndo,
return;
}
ND_TCHECK2(bp, 4);
if(length < 4) {
goto trunc;
}
/*
* see if this is an IKE packet
*/
if(bp[0]==0 && bp[1]==0 && bp[2]==0 && bp[3]==0) {
ND_PRINT((ndo, "NONESP-encap: "));
isakmp_print(ndo, bp+4, length-4, bp2);
return;
}
@ -1415,6 +1418,8 @@ isakmp_rfc3948_print(netdissect_options *ndo,
int nh, enh, padlen;
int advance;
ND_PRINT((ndo, "UDP-encap: "));
advance = esp_print(ndo, bp, length, bp2, &enh, &padlen);
if(advance <= 0)
return;
@ -1423,7 +1428,7 @@ isakmp_rfc3948_print(netdissect_options *ndo,
length -= advance + padlen;
nh = enh & 0xff;
/* now need to jump into ip_print(). */
ip_print_inner(ndo, bp, length, nh, bp2);
return;
}
@ -1432,5 +1437,13 @@ trunc:
return;
}
/*
* Local Variables:
* c-style: whitesmith
* c-basic-offset: 8
* End:
*/

View File

@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/print-udp.c,v 1.137 2005-04-06 21:33:28 mcr Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-udp.c,v 1.138 2005-04-07 00:28:17 mcr Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -615,8 +615,10 @@ udp_print(register const u_char *bp, u_int length,
#else
0);
#endif
else if (ISPORT(ISAKMP_PORT) || ISPORT(ISAKMP_PORT_NATT))
else if (ISPORT(ISAKMP_PORT))
isakmp_print(gndo, (const u_char *)(up + 1), length, bp2);
else if (ISPORT(ISAKMP_PORT_NATT))
isakmp_rfc3948_print(gndo, (const u_char *)(up + 1), length, bp2);
#if 1 /*???*/
else if (ISPORT(ISAKMP_PORT_USER1) || ISPORT(ISAKMP_PORT_USER2))
isakmp_print(gndo, (const u_char *)(up + 1), length, bp2);