]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-ah.c
document SIGUSR1 in manual page
[tcpdump] / print-ah.c
index b4fae2eb338f152a47cf811d10a08c5646a3c98c..0badf48233bffc1b915278c12529d9e779009735 100644 (file)
  * 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)";
+#define NETDISSECT_REWORKED
+#ifdef HAVE_CONFIG_H
+#include "config.h"
 #endif
 
-#include <sys/param.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+#include <tcpdump-stdinc.h>
 
-#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#include <netinet/ip_var.h>
-#include <netinet/udp.h>
-#include <netinet/udp_var.h>
-
-#undef NOERROR                                 /* Solaris sucks */
-#include <arpa/nameser.h>
-#include <arpa/tftp.h>
-
-#ifdef SOLARIS
-#include <tiuser.h>
-#endif
-#include <rpc/rpc.h>
-
-#include <errno.h>
-#include <stdio.h>
+#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(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);
-
-  /* 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;
+       uint32_t spi;
+
+       ah = (const struct ah *)bp;
+       ep = ndo->ndo_snapend;          /* 'ep' points to the end of available data. */
+
+       ND_TCHECK(*ah);
+
+       sumlen = ah->ah_len << 2;
+       spi = EXTRACT_32BITS(&ah->ah_spi);
+
+       ND_PRINT((ndo, "AH(spi=0x%08x", spi));
+       if (ndo->ndo_vflag)
+               ND_PRINT((ndo, ",sumlen=%d", sumlen));
+       ND_PRINT((ndo, ",seq=0x%x", EXTRACT_32BITS(ah + 1)));
+       if (bp + sizeof(struct ah) + sumlen > ep)
+               ND_PRINT((ndo, "[truncated]"));
+       ND_PRINT((ndo, "): "));
+
+       return sizeof(struct ah) + sumlen;
+ trunc:
+       ND_PRINT((ndo, "[|AH]"));
+       return -1;
 }