111b3aaa1Schristos /* NetBSD: print-ah.c,v 1.4 1996/05/20 00:41:16 fvdl Exp */ 20f74e101Schristos 30f74e101Schristos /* 40f74e101Schristos * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 50f74e101Schristos * The Regents of the University of California. All rights reserved. 60f74e101Schristos * 70f74e101Schristos * Redistribution and use in source and binary forms, with or without 80f74e101Schristos * modification, are permitted provided that: (1) source code distributions 90f74e101Schristos * retain the above copyright notice and this paragraph in its entirety, (2) 100f74e101Schristos * distributions including binary code include the above copyright notice and 110f74e101Schristos * this paragraph in its entirety in the documentation or other materials 120f74e101Schristos * provided with the distribution, and (3) all advertising materials mentioning 130f74e101Schristos * features or use of this software display the following acknowledgement: 140f74e101Schristos * ``This product includes software developed by the University of California, 150f74e101Schristos * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 160f74e101Schristos * the University nor the names of its contributors may be used to endorse 170f74e101Schristos * or promote products derived from this software without specific prior 180f74e101Schristos * written permission. 190f74e101Schristos * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 200f74e101Schristos * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 210f74e101Schristos * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 220f74e101Schristos */ 230f74e101Schristos 2411b3aaa1Schristos #include <sys/cdefs.h> 250f74e101Schristos #ifndef lint 26*26ba0b50Schristos __RCSID("$NetBSD: print-ah.c,v 1.9 2024/09/02 16:15:30 christos Exp $"); 270f74e101Schristos #endif 280f74e101Schristos 29dc860a36Sspz /* \summary: IPSEC Authentication Header printer */ 30dc860a36Sspz 31c74ad251Schristos #include <config.h> 320f74e101Schristos 33c74ad251Schristos #include "netdissect-stdinc.h" 340f74e101Schristos 35fdccd7e4Schristos #include "netdissect.h" 360f74e101Schristos #include "extract.h" 370f74e101Schristos 38c74ad251Schristos #include "ah.h" 390f74e101Schristos 40c74ad251Schristos int 41c74ad251Schristos ah_print(netdissect_options *ndo, const u_char *bp) 42c74ad251Schristos { 43c74ad251Schristos const struct ah *ah; 44c74ad251Schristos uint8_t ah_len; 45c74ad251Schristos u_int ah_hdr_len; 46c74ad251Schristos uint16_t reserved; 47c74ad251Schristos const u_char *p; 48c74ad251Schristos 49c74ad251Schristos ndo->ndo_protocol = "ah"; 500f74e101Schristos ah = (const struct ah *)bp; 510f74e101Schristos 52c74ad251Schristos nd_print_protocol_caps(ndo); 53c74ad251Schristos /* 54c74ad251Schristos * RFC4302 55c74ad251Schristos * 56c74ad251Schristos * 2.2. Payload Length 57c74ad251Schristos * 58c74ad251Schristos * This 8-bit field specifies the length of AH in 32-bit words (4-byte 59c74ad251Schristos * units), minus "2". 60c74ad251Schristos */ 61c74ad251Schristos ah_len = GET_U_1(ah->ah_len); 62c74ad251Schristos ah_hdr_len = (ah_len + 2) * 4; 630f74e101Schristos 64c74ad251Schristos ND_PRINT("("); 65b3a00663Schristos if (ndo->ndo_vflag) 66c74ad251Schristos ND_PRINT("length=%u(%u-bytes),", ah_len, ah_hdr_len); 67c74ad251Schristos reserved = GET_BE_U_2(ah->ah_reserved); 68c74ad251Schristos if (reserved) 69c74ad251Schristos ND_PRINT("reserved=0x%x[MustBeZero],", reserved); 70c74ad251Schristos ND_PRINT("spi=0x%08x,", GET_BE_U_4(ah->ah_spi)); 71c74ad251Schristos ND_PRINT("seq=0x%x,", GET_BE_U_4(ah->ah_seq)); 72c74ad251Schristos ND_PRINT("icv=0x"); 73c74ad251Schristos for (p = (const u_char *)(ah + 1); p < bp + ah_hdr_len; p++) 74c74ad251Schristos ND_PRINT("%02x", GET_U_1(p)); 75c74ad251Schristos ND_PRINT("): "); 760f74e101Schristos 77c74ad251Schristos return ah_hdr_len; 780f74e101Schristos } 79