xref: /freebsd/sys/netipsec/ah_var.h (revision b1c3a4d75f4ff74218434a11cdd4e56632e13711)
188768458SSam Leffler /*	$OpenBSD: ip_ah.h,v 1.29 2002/06/09 16:26:10 itojun Exp $	*/
2c398230bSWarner Losh /*-
388768458SSam Leffler  * The authors of this code are John Ioannidis (ji@tla.org),
488768458SSam Leffler  * Angelos D. Keromytis (kermit@csd.uch.gr) and
588768458SSam Leffler  * Niels Provos (provos@physnet.uni-hamburg.de).
688768458SSam Leffler  *
788768458SSam Leffler  * The original version of this code was written by John Ioannidis
888768458SSam Leffler  * for BSD/OS in Athens, Greece, in November 1995.
988768458SSam Leffler  *
1088768458SSam Leffler  * Ported to OpenBSD and NetBSD, with additional transforms, in December 1996,
1188768458SSam Leffler  * by Angelos D. Keromytis.
1288768458SSam Leffler  *
1388768458SSam Leffler  * Additional transforms and features in 1997 and 1998 by Angelos D. Keromytis
1488768458SSam Leffler  * and Niels Provos.
1588768458SSam Leffler  *
1688768458SSam Leffler  * Additional features in 1999 by Angelos D. Keromytis.
1788768458SSam Leffler  *
1888768458SSam Leffler  * Copyright (C) 1995, 1996, 1997, 1998, 1999 John Ioannidis,
1988768458SSam Leffler  * Angelos D. Keromytis and Niels Provos.
2088768458SSam Leffler  * Copyright (c) 2001 Angelos D. Keromytis.
2188768458SSam Leffler  *
2288768458SSam Leffler  * Permission to use, copy, and modify this software with or without fee
2388768458SSam Leffler  * is hereby granted, provided that this entire notice is included in
2488768458SSam Leffler  * all copies of any software which is or includes a copy or
2588768458SSam Leffler  * modification of this software.
2688768458SSam Leffler  * You may use this code under the GNU public license if you so wish. Please
2788768458SSam Leffler  * contribute changes back to the authors under this freer than GPL license
2888768458SSam Leffler  * so that we may further the use of strong encryption without limitations to
2988768458SSam Leffler  * all.
3088768458SSam Leffler  *
3188768458SSam Leffler  * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR
3288768458SSam Leffler  * IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY
3388768458SSam Leffler  * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE
3488768458SSam Leffler  * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR
3588768458SSam Leffler  * PURPOSE.
3688768458SSam Leffler  */
3788768458SSam Leffler 
3888768458SSam Leffler #ifndef _NETIPSEC_AH_VAR_H_
3988768458SSam Leffler #define _NETIPSEC_AH_VAR_H_
4088768458SSam Leffler 
4188768458SSam Leffler /*
4288768458SSam Leffler  * These define the algorithm indices into the histogram.  They're
4388768458SSam Leffler  * presently based on the PF_KEY v2 protocol values which is bogus;
4488768458SSam Leffler  * they should be decoupled from the protocol at which time we can
4588768458SSam Leffler  * pack them and reduce the size of the array to a minimum.
4688768458SSam Leffler  */
4788768458SSam Leffler #define	AH_ALG_MAX	16
4888768458SSam Leffler 
4988768458SSam Leffler struct ahstat {
50c80211e3SAndrey V. Elsukov 	uint64_t	ahs_hdrops;	/* Packet shorter than header shows */
51c80211e3SAndrey V. Elsukov 	uint64_t	ahs_nopf;	/* Protocol family not supported */
52c80211e3SAndrey V. Elsukov 	uint64_t	ahs_notdb;
53c80211e3SAndrey V. Elsukov 	uint64_t	ahs_badkcr;
54c80211e3SAndrey V. Elsukov 	uint64_t	ahs_badauth;
55c80211e3SAndrey V. Elsukov 	uint64_t	ahs_noxform;
56c80211e3SAndrey V. Elsukov 	uint64_t	ahs_qfull;
57c80211e3SAndrey V. Elsukov 	uint64_t	ahs_wrap;
58c80211e3SAndrey V. Elsukov 	uint64_t	ahs_replay;
59c80211e3SAndrey V. Elsukov 	uint64_t	ahs_badauthl;	/* Bad authenticator length */
60c80211e3SAndrey V. Elsukov 	uint64_t	ahs_input;	/* Input AH packets */
61c80211e3SAndrey V. Elsukov 	uint64_t	ahs_output;	/* Output AH packets */
62c80211e3SAndrey V. Elsukov 	uint64_t	ahs_invalid;	/* Trying to use an invalid TDB */
63c80211e3SAndrey V. Elsukov 	uint64_t	ahs_ibytes;	/* Input bytes */
64c80211e3SAndrey V. Elsukov 	uint64_t	ahs_obytes;	/* Output bytes */
65c80211e3SAndrey V. Elsukov 	uint64_t	ahs_toobig;	/* Packet got larger than IP_MAXPACKET */
66c80211e3SAndrey V. Elsukov 	uint64_t	ahs_pdrops;	/* Packet blocked due to policy */
67c80211e3SAndrey V. Elsukov 	uint64_t	ahs_crypto;	/* Crypto processing failure */
68c80211e3SAndrey V. Elsukov 	uint64_t	ahs_tunnel;	/* Tunnel sanity check failure */
69c80211e3SAndrey V. Elsukov 	uint64_t	ahs_hist[AH_ALG_MAX];	/* Per-algorithm op count */
7088768458SSam Leffler };
7188768458SSam Leffler 
7288768458SSam Leffler #ifdef _KERNEL
73db8c0879SAndrey V. Elsukov #include <sys/counter.h>
74*b1c3a4d7SKristof Provost #include <netinet/in_kdtrace.h>
75db8c0879SAndrey V. Elsukov 
76eddfbb76SRobert Watson VNET_DECLARE(int, ah_enable);
77eddfbb76SRobert Watson VNET_DECLARE(int, ah_cleartos);
78db8c0879SAndrey V. Elsukov VNET_PCPUSTAT_DECLARE(struct ahstat, ahstat);
7982cea7e6SBjoern A. Zeeb 
80db8c0879SAndrey V. Elsukov #define AHSTAT_ADD(name, val)                                          \
81*b1c3a4d7SKristof Provost 	do {                                                           \
82*b1c3a4d7SKristof Provost 		MIB_SDT_PROBE1(ah, count, name, (val));                \
83*b1c3a4d7SKristof Provost 		VNET_PCPUSTAT_ADD(struct ahstat, ahstat, name, (val)); \
84*b1c3a4d7SKristof Provost 	} while (0)
85*b1c3a4d7SKristof Provost #define AHSTAT_INC2(name, type)                                          \
86*b1c3a4d7SKristof Provost 	do {                                                             \
87*b1c3a4d7SKristof Provost 		MIB_SDT_PROBE2(ah, count, name, 1, (type));              \
88*b1c3a4d7SKristof Provost 		VNET_PCPUSTAT_ADD(struct ahstat, ahstat, name[type], 1); \
89*b1c3a4d7SKristof Provost 	} while (0)
90a04d64d8SAndrey V. Elsukov #define	AHSTAT_INC(name)	AHSTAT_ADD(name, 1)
9182cea7e6SBjoern A. Zeeb #define	V_ah_enable		VNET(ah_enable)
9282cea7e6SBjoern A. Zeeb #define	V_ah_cleartos		VNET(ah_cleartos)
9388768458SSam Leffler #endif /* _KERNEL */
9488768458SSam Leffler #endif /*_NETIPSEC_AH_VAR_H_*/
95