X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/5c4f91da945d3cbc573b5c306ae42d2fe3723248..ffa1470e5c7ff0e50028d085a481dc797b0b51ed:/print-ah.c diff --git a/print-ah.c b/print-ah.c index b4fae2eb..ecd106b7 100644 --- a/print-ah.c +++ b/print-ah.c @@ -22,79 +22,50 @@ */ #ifndef lint -static char rcsid[] = - "@(#) Header: print-ah.c,v 1.37 94/06/10 17:01:42 mccanne Exp (LBL)"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-ah.c,v 1.22 2003-11-19 00:36:06 guy Exp $ (LBL)"; #endif -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#undef NOERROR /* Solaris sucks */ -#include -#include - -#ifdef SOLARIS -#include +#ifdef HAVE_CONFIG_H +#include "config.h" #endif -#include -#include +#include + #include +#include "ah.h" + #include "interface.h" #include "addrtoname.h" +#include "extract.h" -extern int packettype; - - -void -ah_print(register const u_char *bp, int length, register const u_char *bp2) +int +ah_print(register const u_char *bp) { - register const struct ip *ip; - register const u_char *cp, *nh; - u_short nextheader; - u_short ahlen, authlen; - u_long spi, seqno; - - ip = (struct ip *)bp2; - - (void)printf("AH %s > %s\n\t\t", - ipaddr_string(&ip->ip_src), - ipaddr_string(&ip->ip_dst)); - - if (length < 8) { - (void)printf(" [|ah] truncated-ah %d", length); - return; - } - - nextheader = bp[0]; - ahlen = bp[1]; - spi = ntohl(*((u_long *)(bp+4))); - seqno = ntohl(*((u_long *)(bp+8))); - authlen = ahlen - 12; - - nh = bp+ahlen; - - if(authlen > length || authlen == 0) - { - authlen = length; - } - - (void)printf("spi:%08x seqno:%d authlen: %d authdata: ", spi, - seqno, authlen); - (void)default_print_unaligned(bp+12, authlen); - - /* PRINT rest of packet, requires some reorg of print-ip.c */ -#if XXX - (void)ip_print(nextheader, ip, nh, length-authlen); -#endif + register const struct ah *ah; + register const u_char *ep; + int sumlen; + u_int32_t spi; + + ah = (const struct ah *)bp; + ep = snapend; /* 'ep' points to the end of available data. */ + + TCHECK(*ah); + + sumlen = ah->ah_len << 2; + spi = EXTRACT_32BITS(&ah->ah_spi); + + printf("AH(spi=0x%08x", spi); + if (vflag) + printf(",sumlen=%d", sumlen); + printf(",seq=0x%x", EXTRACT_32BITS(ah + 1)); + if (bp + sizeof(struct ah) + sumlen > ep) + fputs("[truncated]", stdout); + fputs("): ", stdout); + + return sizeof(struct ah) + sumlen; + trunc: + fputs("[|AH]", stdout); + return -1; }