1b0453382SBill Fenner /* $NetBSD: print-ah.c,v 1.4 1996/05/20 00:41:16 fvdl Exp $ */
2b0453382SBill Fenner
3b0453382SBill Fenner /*
4b0453382SBill Fenner * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994
5b0453382SBill Fenner * The Regents of the University of California. All rights reserved.
6b0453382SBill Fenner *
7b0453382SBill Fenner * Redistribution and use in source and binary forms, with or without
8b0453382SBill Fenner * modification, are permitted provided that: (1) source code distributions
9b0453382SBill Fenner * retain the above copyright notice and this paragraph in its entirety, (2)
10b0453382SBill Fenner * distributions including binary code include the above copyright notice and
11b0453382SBill Fenner * this paragraph in its entirety in the documentation or other materials
12b0453382SBill Fenner * provided with the distribution, and (3) all advertising materials mentioning
13b0453382SBill Fenner * features or use of this software display the following acknowledgement:
14b0453382SBill Fenner * ``This product includes software developed by the University of California,
15b0453382SBill Fenner * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
16b0453382SBill Fenner * the University nor the names of its contributors may be used to endorse
17b0453382SBill Fenner * or promote products derived from this software without specific prior
18b0453382SBill Fenner * written permission.
19b0453382SBill Fenner * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
20b0453382SBill Fenner * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
21b0453382SBill Fenner * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22b0453382SBill Fenner */
23b0453382SBill Fenner
243340d773SGleb Smirnoff /* \summary: IPSEC Authentication Header printer */
253340d773SGleb Smirnoff
26*ee67461eSJoseph Mingrone #include <config.h>
27b0453382SBill Fenner
28*ee67461eSJoseph Mingrone #include "netdissect-stdinc.h"
29b0453382SBill Fenner
303340d773SGleb Smirnoff #include "netdissect.h"
315b0fe478SBruce M Simpson #include "extract.h"
32b0453382SBill Fenner
33*ee67461eSJoseph Mingrone #include "ah.h"
34b0453382SBill Fenner
35*ee67461eSJoseph Mingrone int
ah_print(netdissect_options * ndo,const u_char * bp)36*ee67461eSJoseph Mingrone ah_print(netdissect_options *ndo, const u_char *bp)
37*ee67461eSJoseph Mingrone {
38*ee67461eSJoseph Mingrone const struct ah *ah;
39*ee67461eSJoseph Mingrone uint8_t ah_len;
40*ee67461eSJoseph Mingrone u_int ah_hdr_len;
41*ee67461eSJoseph Mingrone uint16_t reserved;
42*ee67461eSJoseph Mingrone const u_char *p;
43*ee67461eSJoseph Mingrone
44*ee67461eSJoseph Mingrone ndo->ndo_protocol = "ah";
45a90e161bSBill Fenner ah = (const struct ah *)bp;
46b0453382SBill Fenner
47*ee67461eSJoseph Mingrone nd_print_protocol_caps(ndo);
48*ee67461eSJoseph Mingrone /*
49*ee67461eSJoseph Mingrone * RFC4302
50*ee67461eSJoseph Mingrone *
51*ee67461eSJoseph Mingrone * 2.2. Payload Length
52*ee67461eSJoseph Mingrone *
53*ee67461eSJoseph Mingrone * This 8-bit field specifies the length of AH in 32-bit words (4-byte
54*ee67461eSJoseph Mingrone * units), minus "2".
55*ee67461eSJoseph Mingrone */
56*ee67461eSJoseph Mingrone ah_len = GET_U_1(ah->ah_len);
57*ee67461eSJoseph Mingrone ah_hdr_len = (ah_len + 2) * 4;
58b0453382SBill Fenner
59*ee67461eSJoseph Mingrone ND_PRINT("(");
603c602fabSXin LI if (ndo->ndo_vflag)
61*ee67461eSJoseph Mingrone ND_PRINT("length=%u(%u-bytes),", ah_len, ah_hdr_len);
62*ee67461eSJoseph Mingrone reserved = GET_BE_U_2(ah->ah_reserved);
63*ee67461eSJoseph Mingrone if (reserved)
64*ee67461eSJoseph Mingrone ND_PRINT("reserved=0x%x[MustBeZero],", reserved);
65*ee67461eSJoseph Mingrone ND_PRINT("spi=0x%08x,", GET_BE_U_4(ah->ah_spi));
66*ee67461eSJoseph Mingrone ND_PRINT("seq=0x%x,", GET_BE_U_4(ah->ah_seq));
67*ee67461eSJoseph Mingrone ND_PRINT("icv=0x");
68*ee67461eSJoseph Mingrone for (p = (const u_char *)(ah + 1); p < bp + ah_hdr_len; p++)
69*ee67461eSJoseph Mingrone ND_PRINT("%02x", GET_U_1(p));
70*ee67461eSJoseph Mingrone ND_PRINT("): ");
71b0453382SBill Fenner
72*ee67461eSJoseph Mingrone return ah_hdr_len;
73b0453382SBill Fenner }
74