print-ah.c revision 75115
1184610Salfred/* $NetBSD: print-ah.c,v 1.4 1996/05/20 00:41:16 fvdl Exp $ */ 2184610Salfred 3184610Salfred/* 4184610Salfred * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 5184610Salfred * The Regents of the University of California. All rights reserved. 6184610Salfred * 7184610Salfred * Redistribution and use in source and binary forms, with or without 8184610Salfred * modification, are permitted provided that: (1) source code distributions 9184610Salfred * retain the above copyright notice and this paragraph in its entirety, (2) 10184610Salfred * distributions including binary code include the above copyright notice and 11184610Salfred * this paragraph in its entirety in the documentation or other materials 12184610Salfred * provided with the distribution, and (3) all advertising materials mentioning 13184610Salfred * features or use of this software display the following acknowledgement: 14184610Salfred * ``This product includes software developed by the University of California, 15184610Salfred * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 16184610Salfred * the University nor the names of its contributors may be used to endorse 17184610Salfred * or promote products derived from this software without specific prior 18184610Salfred * written permission. 19184610Salfred * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 20184610Salfred * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 21184610Salfred * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 22184610Salfred */ 23184610Salfred 24184610Salfred#ifndef lint 25184610Salfredstatic const char rcsid[] = 26184610Salfred "@(#) $Header: /tcpdump/master/tcpdump/print-ah.c,v 1.14 2000/12/12 09:58:40 itojun Exp $ (LBL)"; 27184610Salfred#endif 28184610Salfred 29184610Salfred#ifdef HAVE_CONFIG_H 30184610Salfred#include "config.h" 31184610Salfred#endif 32184610Salfred 33184610Salfred#include <sys/param.h> 34184610Salfred#include <sys/time.h> 35184610Salfred#include <sys/types.h> 36184610Salfred#include <sys/socket.h> 37184610Salfred 38184610Salfred#include <netinet/in.h> 39184610Salfred 40184610Salfred#include <stdio.h> 41184610Salfred 42184610Salfred#include "ah.h" 43184610Salfred 44184610Salfred#include "interface.h" 45184610Salfred#include "addrtoname.h" 46184610Salfred 47194677Sthompsaint 48194677Sthompsaah_print(register const u_char *bp, register const u_char *bp2) 49194677Sthompsa{ 50194677Sthompsa register const struct ah *ah; 51194677Sthompsa register const u_char *ep; 52194677Sthompsa int sumlen; 53194677Sthompsa u_int32_t spi; 54194677Sthompsa 55194677Sthompsa ah = (struct ah *)bp; 56194677Sthompsa ep = snapend; /* 'ep' points to the end of available data. */ 57194677Sthompsa 58194677Sthompsa if ((u_char *)(ah + 1) >= ep - sizeof(struct ah)) 59194677Sthompsa goto trunc; 60194677Sthompsa 61194677Sthompsa sumlen = ah->ah_len << 2; 62194677Sthompsa spi = (u_int32_t)ntohl(ah->ah_spi); 63194677Sthompsa 64194677Sthompsa printf("AH(spi=0x%08x", spi); 65194677Sthompsa if (vflag) 66194677Sthompsa printf(",sumlen=%d", sumlen); 67194677Sthompsa printf(",seq=0x%x", (u_int32_t)ntohl(*(u_int32_t *)(ah + 1))); 68194677Sthompsa if (bp + sizeof(struct ah) + sumlen > ep) 69194677Sthompsa fputs("[truncated]", stdout); 70194677Sthompsa fputs("): ", stdout); 71188746Sthompsa 72194677Sthompsa return sizeof(struct ah) + sumlen; 73188942Sthompsa trunc: 74194677Sthompsa fputs("[|AH]", stdout); 75184610Salfred return 65535; 76184610Salfred} 77188942Sthompsa