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