1285SN/A/*-
2462SN/A * Copyright (c) 1982, 1986, 1993
3285SN/A *	The Regents of the University of California.  All rights reserved.
4285SN/A *
5285SN/A * Redistribution and use in source and binary forms, with or without
6285SN/A * modification, are permitted provided that the following conditions
7285SN/A * are met:
8285SN/A * 1. Redistributions of source code must retain the above copyright
9285SN/A *    notice, this list of conditions and the following disclaimer.
10285SN/A * 2. Redistributions in binary form must reproduce the above copyright
11285SN/A *    notice, this list of conditions and the following disclaimer in the
12285SN/A *    documentation and/or other materials provided with the distribution.
13285SN/A * 4. Neither the name of the University nor the names of its contributors
14285SN/A *    may be used to endorse or promote products derived from this software
15285SN/A *    without specific prior written permission.
16285SN/A *
17285SN/A * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18285SN/A * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19285SN/A * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20285SN/A * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21285SN/A * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22285SN/A * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23285SN/A * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24285SN/A * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25285SN/A * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26285SN/A * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27285SN/A * SUCH DAMAGE.
28285SN/A *
29285SN/A *	@(#)icmp_var.h	8.1 (Berkeley) 6/10/93
30285SN/A * $FreeBSD$
31285SN/A */
32285SN/A
33285SN/A#ifndef _NETINET_ICMP_VAR_H_
34285SN/A#define _NETINET_ICMP_VAR_H_
35285SN/A
36285SN/A
37285SN/A/*
38285SN/A * Variables related to this implementation
39285SN/A * of the internet control message protocol.
40285SN/A */
41285SN/Astruct	icmpstat {
42285SN/A/* statistics related to icmp packets generated */
43285SN/A	u_long	icps_error;		/* # of calls to icmp_error */
44285SN/A	u_long	icps_oldshort;		/* no error 'cuz old ip too short */
45285SN/A	u_long	icps_oldicmp;		/* no error 'cuz old was icmp */
46285SN/A	u_long	icps_outhist[ICMP_MAXTYPE + 1];
47285SN/A/* statistics related to input messages processed */
48285SN/A	u_long	icps_badcode;		/* icmp_code out of range */
49285SN/A	u_long	icps_tooshort;		/* packet < ICMP_MINLEN */
50285SN/A	u_long	icps_checksum;		/* bad checksum */
51285SN/A	u_long	icps_badlen;		/* calculated bound mismatch */
52285SN/A	u_long	icps_reflect;		/* number of responses */
53285SN/A	u_long	icps_inhist[ICMP_MAXTYPE + 1];
54285SN/A	u_long	icps_bmcastecho;	/* b/mcast echo requests dropped */
55285SN/A	u_long	icps_bmcasttstamp;	/* b/mcast tstamp requests dropped */
56285SN/A	u_long	icps_badaddr;		/* bad return address */
57285SN/A	u_long	icps_noroute;		/* no route back */
58285SN/A};
59285SN/A
60285SN/A#ifdef _KERNEL
61285SN/A#include <sys/counter.h>
62285SN/A
63285SN/AVNET_PCPUSTAT_DECLARE(struct icmpstat, icmpstat);
64285SN/A/*
65285SN/A * In-kernel consumers can use these accessor macros directly to update
66285SN/A * stats.
67285SN/A */
68285SN/A#define	ICMPSTAT_ADD(name, val)	\
69285SN/A    VNET_PCPUSTAT_ADD(struct icmpstat, icmpstat, name, (val))
70285SN/A#define	ICMPSTAT_INC(name)	ICMPSTAT_ADD(name, 1)
71285SN/A
72285SN/A/*
73285SN/A * Kernel module consumers must use this accessor macro.
74285SN/A */
75285SN/Avoid	kmod_icmpstat_inc(int statnum);
76285SN/A#define	KMOD_ICMPSTAT_INC(name)						\
77285SN/A    kmod_icmpstat_inc(offsetof(struct icmpstat, name) / sizeof(uint64_t))
78285SN/A#endif
79285SN/A
80285SN/A/*
81285SN/A * Names for ICMP sysctl objects
82285SN/A */
83285SN/A#define	ICMPCTL_MASKREPL	1	/* allow replies to netmask requests */
84285SN/A#define	ICMPCTL_STATS		2	/* statistics (read-only) */
85285SN/A#define ICMPCTL_ICMPLIM		3
86285SN/A#define ICMPCTL_MAXID		4
87285SN/A
88285SN/A#ifdef _KERNEL
89285SN/ASYSCTL_DECL(_net_inet_icmp);
90285SN/A
91285SN/Aextern int badport_bandlim(int);
92285SN/A#define BANDLIM_UNLIMITED -1
93285SN/A#define BANDLIM_ICMP_UNREACH 0
94285SN/A#define BANDLIM_ICMP_ECHO 1
95285SN/A#define BANDLIM_ICMP_TSTAMP 2
96285SN/A#define BANDLIM_RST_CLOSEDPORT 3 /* No connection, and no listeners */
97285SN/A#define BANDLIM_RST_OPENPORT 4   /* No connection, listener */
98285SN/A#define BANDLIM_ICMP6_UNREACH 5
99285SN/A#define BANDLIM_SCTP_OOTB 6
100285SN/A#define BANDLIM_MAX 6
101285SN/A#endif
102285SN/A
103285SN/A#endif
104285SN/A