print-ah.c revision 75115
156893Sfenner/*	$NetBSD: print-ah.c,v 1.4 1996/05/20 00:41:16 fvdl Exp $	*/
256893Sfenner
356893Sfenner/*
456893Sfenner * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994
556893Sfenner *	The Regents of the University of California.  All rights reserved.
656893Sfenner *
756893Sfenner * Redistribution and use in source and binary forms, with or without
856893Sfenner * modification, are permitted provided that: (1) source code distributions
956893Sfenner * retain the above copyright notice and this paragraph in its entirety, (2)
1056893Sfenner * distributions including binary code include the above copyright notice and
1156893Sfenner * this paragraph in its entirety in the documentation or other materials
1256893Sfenner * provided with the distribution, and (3) all advertising materials mentioning
1356893Sfenner * features or use of this software display the following acknowledgement:
1456893Sfenner * ``This product includes software developed by the University of California,
1556893Sfenner * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
1656893Sfenner * the University nor the names of its contributors may be used to endorse
1756893Sfenner * or promote products derived from this software without specific prior
1856893Sfenner * written permission.
1956893Sfenner * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
2056893Sfenner * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
2156893Sfenner * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
2256893Sfenner */
2356893Sfenner
2456893Sfenner#ifndef lint
2556893Sfennerstatic const char rcsid[] =
2675115Sfenner    "@(#) $Header: /tcpdump/master/tcpdump/print-ah.c,v 1.14 2000/12/12 09:58:40 itojun Exp $ (LBL)";
2756893Sfenner#endif
2856893Sfenner
2956893Sfenner#ifdef HAVE_CONFIG_H
3056893Sfenner#include "config.h"
3156893Sfenner#endif
3256893Sfenner
3356893Sfenner#include <sys/param.h>
3456893Sfenner#include <sys/time.h>
3556893Sfenner#include <sys/types.h>
3656893Sfenner#include <sys/socket.h>
3756893Sfenner
3856893Sfenner#include <netinet/in.h>
3956893Sfenner
4056893Sfenner#include <stdio.h>
4156893Sfenner
4275115Sfenner#include "ah.h"
4356893Sfenner
4456893Sfenner#include "interface.h"
4556893Sfenner#include "addrtoname.h"
4656893Sfenner
4756893Sfennerint
4856893Sfennerah_print(register const u_char *bp, register const u_char *bp2)
4956893Sfenner{
5056893Sfenner	register const struct ah *ah;
5156893Sfenner	register const u_char *ep;
5256893Sfenner	int sumlen;
5356893Sfenner	u_int32_t spi;
5456893Sfenner
5556893Sfenner	ah = (struct ah *)bp;
5675115Sfenner	ep = snapend;		/* 'ep' points to the end of available data. */
5756893Sfenner
5856893Sfenner	if ((u_char *)(ah + 1) >= ep - sizeof(struct ah))
5956893Sfenner		goto trunc;
6056893Sfenner
6156893Sfenner	sumlen = ah->ah_len << 2;
6256893Sfenner	spi = (u_int32_t)ntohl(ah->ah_spi);
6356893Sfenner
6475115Sfenner	printf("AH(spi=0x%08x", spi);
6556893Sfenner	if (vflag)
6656893Sfenner		printf(",sumlen=%d", sumlen);
6756893Sfenner	printf(",seq=0x%x", (u_int32_t)ntohl(*(u_int32_t *)(ah + 1)));
6856893Sfenner	if (bp + sizeof(struct ah) + sumlen > ep)
6956893Sfenner		fputs("[truncated]", stdout);
7056893Sfenner	fputs("): ", stdout);
7156893Sfenner
7256893Sfenner	return sizeof(struct ah) + sumlen;
7356893Sfenner trunc:
7456893Sfenner	fputs("[|AH]", stdout);
7556893Sfenner	return 65535;
7656893Sfenner}
77