* 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 <sys/param.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#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>
+/* \summary: IPSEC Authentication Header printer */
-#undef NOERROR /* Solaris sucks */
-#include <arpa/nameser.h>
-#include <arpa/tftp.h>
-
-#ifdef SOLARIS
-#include <tiuser.h>
+#ifdef HAVE_CONFIG_H
+#include <config.h>
#endif
-#include <rpc/rpc.h>
-
-#include <errno.h>
-#include <stdio.h>
-#include "interface.h"
-#include "addrtoname.h"
+#include "netdissect-stdinc.h"
-extern int packettype;
+#include "netdissect.h"
+#include "extract.h"
+#include "ah.h"
-void
-ah_print(register const u_char *bp, int length, register const u_char *bp2)
+int
+ah_print(netdissect_options *ndo, 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;
+ const struct ah *ah;
+ u_int sumlen;
- ip = (struct ip *)bp2;
+ ndo->ndo_protocol = "ah";
+ ah = (const struct ah *)bp;
- (void)printf("AH %s > %s\n\t\t",
- ipaddr_string(&ip->ip_src),
- ipaddr_string(&ip->ip_dst));
+ ND_TCHECK_SIZE(ah);
- if (length < 8) {
- (void)printf(" [|ah] truncated-ah %d", length);
- return;
- }
+ sumlen = EXTRACT_U_1(ah->ah_len) << 2;
- nextheader = bp[0];
- ahlen = bp[1];
- spi = ntohl(*((u_long *)(bp+4)));
- seqno = ntohl(*((u_long *)(bp+8)));
- authlen = ahlen - 12;
+ ND_PRINT("AH(spi=0x%08x", EXTRACT_BE_U_4(ah->ah_spi));
+ if (ndo->ndo_vflag)
+ ND_PRINT(",sumlen=%u", sumlen);
+ ND_TCHECK_4(ah + 1);
+ ND_PRINT(",seq=0x%x", EXTRACT_BE_U_4(ah + 1));
+ ND_TCHECK_LEN(bp, sizeof(struct ah) + sumlen);
+ ND_PRINT("): ");
- 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
+ return sizeof(struct ah) + sumlen;
+ trunc:
+ nd_print_trunc(ndo);
+ return -1;
}