]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-ah.c
The stuff in the "linux-include" directory is no longer needed, as we no
[tcpdump] / print-ah.c
index 61bdf91c7ba9ac198a09c51571e9654930b25ed5..b2441aaa2d80522e0c5a94e0065b01b18efdb705 100644 (file)
  */
 
 #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[] =
+    "@(#) $Header: /tcpdump/master/tcpdump/print-ah.c,v 1.14 2000-12-12 09:58:40 itojun Exp $ (LBL)";
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
 #endif
 
 #include <sys/param.h>
@@ -32,70 +36,41 @@ static char rcsid[] =
 #include <sys/socket.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 "appletalk.h"
-
-#include "nfs.h"
-#include "bootp.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 u_char *bp2)
 {
-  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;
+       register const u_char *ep;
+       int sumlen;
+       u_int32_t spi;
+
+       ah = (struct ah *)bp;
+       ep = snapend;           /* 'ep' points to the end of available data. */
+
+       if ((u_char *)(ah + 1) >= ep - sizeof(struct ah))
+               goto trunc;
+
+       sumlen = ah->ah_len << 2;
+       spi = (u_int32_t)ntohl(ah->ah_spi);
+
+       printf("AH(spi=0x%08x", spi);
+       if (vflag)
+               printf(",sumlen=%d", sumlen);
+       printf(",seq=0x%x", (u_int32_t)ntohl(*(u_int32_t *)(ah + 1)));
+       if (bp + sizeof(struct ah) + sumlen > ep)
+               fputs("[truncated]", stdout);
+       fputs("): ", stdout);
+       
+       return sizeof(struct ah) + sumlen;
+ trunc:
+       fputs("[|AH]", stdout);
+       return 65535;
 }