1105197Ssam/*	$FreeBSD: releng/10.2/sys/netipsec/ah_var.h 253088 2013-07-09 10:08:13Z ae $	*/
2105197Ssam/*	$OpenBSD: ip_ah.h,v 1.29 2002/06/09 16:26:10 itojun Exp $	*/
3139823Simp/*-
4105197Ssam * The authors of this code are John Ioannidis (ji@tla.org),
5105197Ssam * Angelos D. Keromytis (kermit@csd.uch.gr) and
6105197Ssam * Niels Provos (provos@physnet.uni-hamburg.de).
7105197Ssam *
8105197Ssam * The original version of this code was written by John Ioannidis
9105197Ssam * for BSD/OS in Athens, Greece, in November 1995.
10105197Ssam *
11105197Ssam * Ported to OpenBSD and NetBSD, with additional transforms, in December 1996,
12105197Ssam * by Angelos D. Keromytis.
13105197Ssam *
14105197Ssam * Additional transforms and features in 1997 and 1998 by Angelos D. Keromytis
15105197Ssam * and Niels Provos.
16105197Ssam *
17105197Ssam * Additional features in 1999 by Angelos D. Keromytis.
18105197Ssam *
19105197Ssam * Copyright (C) 1995, 1996, 1997, 1998, 1999 John Ioannidis,
20105197Ssam * Angelos D. Keromytis and Niels Provos.
21105197Ssam * Copyright (c) 2001 Angelos D. Keromytis.
22105197Ssam *
23105197Ssam * Permission to use, copy, and modify this software with or without fee
24105197Ssam * is hereby granted, provided that this entire notice is included in
25105197Ssam * all copies of any software which is or includes a copy or
26105197Ssam * modification of this software.
27105197Ssam * You may use this code under the GNU public license if you so wish. Please
28105197Ssam * contribute changes back to the authors under this freer than GPL license
29105197Ssam * so that we may further the use of strong encryption without limitations to
30105197Ssam * all.
31105197Ssam *
32105197Ssam * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR
33105197Ssam * IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY
34105197Ssam * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE
35105197Ssam * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR
36105197Ssam * PURPOSE.
37105197Ssam */
38105197Ssam
39105197Ssam#ifndef _NETIPSEC_AH_VAR_H_
40105197Ssam#define _NETIPSEC_AH_VAR_H_
41105197Ssam
42105197Ssam/*
43105197Ssam * These define the algorithm indices into the histogram.  They're
44105197Ssam * presently based on the PF_KEY v2 protocol values which is bogus;
45105197Ssam * they should be decoupled from the protocol at which time we can
46105197Ssam * pack them and reduce the size of the array to a minimum.
47105197Ssam */
48105197Ssam#define	AH_ALG_MAX	16
49105197Ssam
50105197Ssamstruct ahstat {
51253081Sae	uint64_t	ahs_hdrops;	/* Packet shorter than header shows */
52253081Sae	uint64_t	ahs_nopf;	/* Protocol family not supported */
53253081Sae	uint64_t	ahs_notdb;
54253081Sae	uint64_t	ahs_badkcr;
55253081Sae	uint64_t	ahs_badauth;
56253081Sae	uint64_t	ahs_noxform;
57253081Sae	uint64_t	ahs_qfull;
58253081Sae	uint64_t	ahs_wrap;
59253081Sae	uint64_t	ahs_replay;
60253081Sae	uint64_t	ahs_badauthl;	/* Bad authenticator length */
61253081Sae	uint64_t	ahs_input;	/* Input AH packets */
62253081Sae	uint64_t	ahs_output;	/* Output AH packets */
63253081Sae	uint64_t	ahs_invalid;	/* Trying to use an invalid TDB */
64253081Sae	uint64_t	ahs_ibytes;	/* Input bytes */
65253081Sae	uint64_t	ahs_obytes;	/* Output bytes */
66253081Sae	uint64_t	ahs_toobig;	/* Packet got larger than IP_MAXPACKET */
67253081Sae	uint64_t	ahs_pdrops;	/* Packet blocked due to policy */
68253081Sae	uint64_t	ahs_crypto;	/* Crypto processing failure */
69253081Sae	uint64_t	ahs_tunnel;	/* Tunnel sanity check failure */
70253081Sae	uint64_t	ahs_hist[AH_ALG_MAX];	/* Per-algorithm op count */
71105197Ssam};
72105197Ssam
73105197Ssam#ifdef _KERNEL
74253088Sae#include <sys/counter.h>
75253088Sae
76195699SrwatsonVNET_DECLARE(int, ah_enable);
77207369SbzVNET_DECLARE(int, ah_cleartos);
78253088SaeVNET_PCPUSTAT_DECLARE(struct ahstat, ahstat);
79207369Sbz
80253088Sae#define	AHSTAT_ADD(name, val)	\
81253088Sae    VNET_PCPUSTAT_ADD(struct ahstat, ahstat, name , (val))
82252028Sae#define	AHSTAT_INC(name)	AHSTAT_ADD(name, 1)
83195727Srwatson#define	V_ah_enable		VNET(ah_enable)
84195727Srwatson#define	V_ah_cleartos		VNET(ah_cleartos)
85105197Ssam#endif /* _KERNEL */
86105197Ssam#endif /*_NETIPSEC_AH_VAR_H_*/
87