/*-1* SPDX-License-Identifier: BSD-3-Clause2*3* Copyright (c) 1982, 1986, 19934* The Regents of the University of California. All rights reserved.5*6* Redistribution and use in source and binary forms, with or without7* modification, are permitted provided that the following conditions8* are met:9* 1. Redistributions of source code must retain the above copyright10* notice, this list of conditions and the following disclaimer.11* 2. Redistributions in binary form must reproduce the above copyright12* notice, this list of conditions and the following disclaimer in the13* documentation and/or other materials provided with the distribution.14* 3. Neither the name of the University nor the names of its contributors15* may be used to endorse or promote products derived from this software16* without specific prior written permission.17*18* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND19* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE20* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE21* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE22* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL23* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS24* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)25* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT26* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF28* SUCH DAMAGE.29*/3031#ifndef _NETINET_ICMP_VAR_H_32#define _NETINET_ICMP_VAR_H_3334/*35* Variables related to this implementation36* of the internet control message protocol.37*/38struct icmpstat {39/* statistics related to icmp packets generated */40u_long icps_error; /* # of calls to icmp_error */41u_long icps_oldshort; /* no error 'cuz old ip too short */42u_long icps_oldicmp; /* no error 'cuz old was icmp */43u_long icps_outhist[ICMP_MAXTYPE + 1];44/* statistics related to input messages processed */45u_long icps_badcode; /* icmp_code out of range */46u_long icps_tooshort; /* packet < ICMP_MINLEN */47u_long icps_checksum; /* bad checksum */48u_long icps_badlen; /* calculated bound mismatch */49u_long icps_reflect; /* number of responses */50u_long icps_inhist[ICMP_MAXTYPE + 1];51u_long icps_bmcastecho; /* b/mcast echo requests dropped */52u_long icps_bmcasttstamp; /* b/mcast tstamp requests dropped */53u_long icps_badaddr; /* bad return address */54u_long icps_noroute; /* no route back */55};5657#ifdef _KERNEL58#include <sys/counter.h>59#include <netinet/in_kdtrace.h>6061VNET_PCPUSTAT_DECLARE(struct icmpstat, icmpstat);62/*63* In-kernel consumers can use these accessor macros directly to update64* stats.65*/66#define ICMPSTAT_ADD(name, val) \67do { \68MIB_SDT_PROBE1(icmp, count, name, (val)); \69VNET_PCPUSTAT_ADD(struct icmpstat, icmpstat, name, (val)); \70} while (0)7172#define ICMPSTAT_INC(name) ICMPSTAT_ADD(name, 1)73#define ICMPSTAT_INC2(name, type) \74do { \75MIB_SDT_PROBE2(icmp, count, name, 1, type); \76VNET_PCPUSTAT_ADD(struct icmpstat, icmpstat, name[type], 1); \77} while (0)7879/*80* Kernel module consumers must use this accessor macro.81*/82void kmod_icmpstat_inc(int statnum);83#define KMOD_ICMPSTAT_INC(name) \84do { \85MIB_SDT_PROBE1(icmp, count, name, 1); \86kmod_icmpstat_inc( \87offsetof(struct icmpstat, name) / sizeof(uint64_t)); \88} while (0)89#endif9091/*92* Identifiers for ICMP sysctl nodes93*/94#define ICMPCTL_MASKREPL 1 /* allow replies to netmask requests */95#define ICMPCTL_STATS 2 /* statistics (read-only) */96#define ICMPCTL_ICMPLIM 39798#ifdef _KERNEL99SYSCTL_DECL(_net_inet_icmp);100101extern int badport_bandlim(int);102#define BANDLIM_ICMP_UNREACH 0103#define BANDLIM_ICMP_ECHO 1104#define BANDLIM_ICMP_TSTAMP 2105#define BANDLIM_TCP_RST 3106#define BANDLIM_ICMP6_UNREACH 4107#define BANDLIM_SCTP_OOTB 5108#define BANDLIM_MAX 6109#endif110111#endif112113114