1139823Simp/*-
21541Srgrimes * Copyright (c) 1982, 1986, 1993
31541Srgrimes *	The Regents of the University of California.  All rights reserved.
41541Srgrimes *
51541Srgrimes * Redistribution and use in source and binary forms, with or without
61541Srgrimes * modification, are permitted provided that the following conditions
71541Srgrimes * are met:
81541Srgrimes * 1. Redistributions of source code must retain the above copyright
91541Srgrimes *    notice, this list of conditions and the following disclaimer.
101541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
111541Srgrimes *    notice, this list of conditions and the following disclaimer in the
121541Srgrimes *    documentation and/or other materials provided with the distribution.
131541Srgrimes * 4. Neither the name of the University nor the names of its contributors
141541Srgrimes *    may be used to endorse or promote products derived from this software
151541Srgrimes *    without specific prior written permission.
161541Srgrimes *
171541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
181541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
191541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
201541Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
211541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
221541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
231541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
241541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
251541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
261541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
271541Srgrimes * SUCH DAMAGE.
281541Srgrimes *
291541Srgrimes *	@(#)icmp_var.h	8.1 (Berkeley) 6/10/93
3050477Speter * $FreeBSD$
311541Srgrimes */
321541Srgrimes
332169Spaul#ifndef _NETINET_ICMP_VAR_H_
342169Spaul#define _NETINET_ICMP_VAR_H_
352169Spaul
3641487Sdillon
371541Srgrimes/*
381541Srgrimes * Variables related to this implementation
391541Srgrimes * of the internet control message protocol.
401541Srgrimes */
411541Srgrimesstruct	icmpstat {
421541Srgrimes/* statistics related to icmp packets generated */
431541Srgrimes	u_long	icps_error;		/* # of calls to icmp_error */
441541Srgrimes	u_long	icps_oldshort;		/* no error 'cuz old ip too short */
451541Srgrimes	u_long	icps_oldicmp;		/* no error 'cuz old was icmp */
461541Srgrimes	u_long	icps_outhist[ICMP_MAXTYPE + 1];
471541Srgrimes/* statistics related to input messages processed */
48133874Srwatson	u_long	icps_badcode;		/* icmp_code out of range */
491541Srgrimes	u_long	icps_tooshort;		/* packet < ICMP_MINLEN */
501541Srgrimes	u_long	icps_checksum;		/* bad checksum */
511541Srgrimes	u_long	icps_badlen;		/* calculated bound mismatch */
521541Srgrimes	u_long	icps_reflect;		/* number of responses */
531541Srgrimes	u_long	icps_inhist[ICMP_MAXTYPE + 1];
54133874Srwatson	u_long	icps_bmcastecho;	/* b/mcast echo requests dropped */
55133874Srwatson	u_long	icps_bmcasttstamp;	/* b/mcast tstamp requests dropped */
5687120Sru	u_long	icps_badaddr;		/* bad return address */
57133874Srwatson	u_long	icps_noroute;		/* no route back */
581541Srgrimes};
591541Srgrimes
60190964Srwatson#ifdef _KERNEL
61253084Sae#include <sys/counter.h>
62253084Sae
63253084SaeVNET_PCPUSTAT_DECLARE(struct icmpstat, icmpstat);
64196039Srwatson/*
65196039Srwatson * In-kernel consumers can use these accessor macros directly to update
66196039Srwatson * stats.
67196039Srwatson */
68253084Sae#define	ICMPSTAT_ADD(name, val)	\
69253084Sae    VNET_PCPUSTAT_ADD(struct icmpstat, icmpstat, name, (val))
70190964Srwatson#define	ICMPSTAT_INC(name)	ICMPSTAT_ADD(name, 1)
71196039Srwatson
72196039Srwatson/*
73196039Srwatson * Kernel module consumers must use this accessor macro.
74196039Srwatson */
75196039Srwatsonvoid	kmod_icmpstat_inc(int statnum);
76196039Srwatson#define	KMOD_ICMPSTAT_INC(name)						\
77253084Sae    kmod_icmpstat_inc(offsetof(struct icmpstat, name) / sizeof(uint64_t))
78190964Srwatson#endif
79190964Srwatson
801541Srgrimes/*
811541Srgrimes * Names for ICMP sysctl objects
821541Srgrimes */
831541Srgrimes#define	ICMPCTL_MASKREPL	1	/* allow replies to netmask requests */
846472Swollman#define	ICMPCTL_STATS		2	/* statistics (read-only) */
8541487Sdillon#define ICMPCTL_ICMPLIM		3
8641487Sdillon#define ICMPCTL_MAXID		4
871541Srgrimes
8855205Speter#ifdef _KERNEL
8944078SdfrSYSCTL_DECL(_net_inet_icmp);
90195699Srwatson
9192723Salfredextern int badport_bandlim(int);
9272357Sbmilekic#define BANDLIM_UNLIMITED -1
9372357Sbmilekic#define BANDLIM_ICMP_UNREACH 0
9487914Sjlemon#define BANDLIM_ICMP_ECHO 1
9572357Sbmilekic#define BANDLIM_ICMP_TSTAMP 2
9672357Sbmilekic#define BANDLIM_RST_CLOSEDPORT 3 /* No connection, and no listeners */
9772357Sbmilekic#define BANDLIM_RST_OPENPORT 4   /* No connection, listener */
98171508Srwatson#define BANDLIM_ICMP6_UNREACH 5
99237230Stuexen#define BANDLIM_SCTP_OOTB 6
100237230Stuexen#define BANDLIM_MAX 6
1011541Srgrimes#endif
10241487Sdillon
10341487Sdillon#endif
104