X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/2d86b23ecde8e2e815ace35e5060856fa61a7e36..d7b497cac78b6e22a66a6bae9bdec60a8044f67a:/print-ah.c?ds=sidebyside diff --git a/print-ah.c b/print-ah.c index 61bdf91c..6f1a357c 100644 --- a/print-ah.c +++ b/print-ah.c @@ -21,81 +21,44 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -#ifndef lint -static char rcsid[] = - "@(#) Header: print-ah.c,v 1.37 94/06/10 17:01:42 mccanne Exp (LBL)"; -#endif - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#undef NOERROR /* Solaris sucks */ -#include -#include +/* \summary: IPSEC Authentication Header printer */ -#ifdef SOLARIS -#include +#ifdef HAVE_CONFIG_H +#include "config.h" #endif -#include -#include -#include +#include -#include "interface.h" -#include "addrtoname.h" -#include "appletalk.h" +#include "ah.h" -#include "nfs.h" -#include "bootp.h" +#include "netdissect.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(netdissect_options *ndo, 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); - - (void)print_ipproto(nextheader, ip, nh, length-authlen); + register const struct ah *ah; + int sumlen; + + ah = (const struct ah *)bp; + + ND_TCHECK(*ah); + + sumlen = ah->ah_len << 2; + + ND_PRINT((ndo, "AH(spi=0x%08x", EXTRACT_BE_U_4(&ah->ah_spi))); + if (ndo->ndo_vflag) + ND_PRINT((ndo, ",sumlen=%d", sumlen)); + ND_TCHECK_4(ah + 1); + ND_PRINT((ndo, ",seq=0x%x", EXTRACT_BE_U_4(ah + 1))); + if (!ND_TTEST2(*bp, sizeof(struct ah) + sumlen)) { + ND_PRINT((ndo, "[truncated]):")); + return -1; + } + ND_PRINT((ndo, "): ")); + + return sizeof(struct ah) + sumlen; + trunc: + ND_PRINT((ndo, "[|AH]")); + return -1; }