1*1eaf0ac3Slogwang /*- 2*1eaf0ac3Slogwang * Copyright (c) 1982, 1986, 1993 3*1eaf0ac3Slogwang * The Regents of the University of California. All rights reserved. 4*1eaf0ac3Slogwang * 5*1eaf0ac3Slogwang * Redistribution and use in source and binary forms, with or without 6*1eaf0ac3Slogwang * modification, are permitted provided that the following conditions 7*1eaf0ac3Slogwang * are met: 8*1eaf0ac3Slogwang * 1. Redistributions of source code must retain the above copyright 9*1eaf0ac3Slogwang * notice, this list of conditions and the following disclaimer. 10*1eaf0ac3Slogwang * 2. Redistributions in binary form must reproduce the above copyright 11*1eaf0ac3Slogwang * notice, this list of conditions and the following disclaimer in the 12*1eaf0ac3Slogwang * documentation and/or other materials provided with the distribution. 13*1eaf0ac3Slogwang * 4. Neither the name of the University nor the names of its contributors 14*1eaf0ac3Slogwang * may be used to endorse or promote products derived from this software 15*1eaf0ac3Slogwang * without specific prior written permission. 16*1eaf0ac3Slogwang * 17*1eaf0ac3Slogwang * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18*1eaf0ac3Slogwang * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19*1eaf0ac3Slogwang * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20*1eaf0ac3Slogwang * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21*1eaf0ac3Slogwang * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22*1eaf0ac3Slogwang * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23*1eaf0ac3Slogwang * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24*1eaf0ac3Slogwang * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25*1eaf0ac3Slogwang * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26*1eaf0ac3Slogwang * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27*1eaf0ac3Slogwang * SUCH DAMAGE. 28*1eaf0ac3Slogwang * 29*1eaf0ac3Slogwang * @(#)icmp_var.h 8.1 (Berkeley) 6/10/93 30*1eaf0ac3Slogwang * $FreeBSD$ 31*1eaf0ac3Slogwang */ 32*1eaf0ac3Slogwang 33*1eaf0ac3Slogwang #ifndef _NETINET_ICMP_VAR_H_ 34*1eaf0ac3Slogwang #define _NETINET_ICMP_VAR_H_ 35*1eaf0ac3Slogwang 36*1eaf0ac3Slogwang 37*1eaf0ac3Slogwang /* 38*1eaf0ac3Slogwang * Variables related to this implementation 39*1eaf0ac3Slogwang * of the internet control message protocol. 40*1eaf0ac3Slogwang */ 41*1eaf0ac3Slogwang struct icmpstat { 42*1eaf0ac3Slogwang /* statistics related to icmp packets generated */ 43*1eaf0ac3Slogwang u_long icps_error; /* # of calls to icmp_error */ 44*1eaf0ac3Slogwang u_long icps_oldshort; /* no error 'cuz old ip too short */ 45*1eaf0ac3Slogwang u_long icps_oldicmp; /* no error 'cuz old was icmp */ 46*1eaf0ac3Slogwang u_long icps_outhist[ICMP_MAXTYPE + 1]; 47*1eaf0ac3Slogwang /* statistics related to input messages processed */ 48*1eaf0ac3Slogwang u_long icps_badcode; /* icmp_code out of range */ 49*1eaf0ac3Slogwang u_long icps_tooshort; /* packet < ICMP_MINLEN */ 50*1eaf0ac3Slogwang u_long icps_checksum; /* bad checksum */ 51*1eaf0ac3Slogwang u_long icps_badlen; /* calculated bound mismatch */ 52*1eaf0ac3Slogwang u_long icps_reflect; /* number of responses */ 53*1eaf0ac3Slogwang u_long icps_inhist[ICMP_MAXTYPE + 1]; 54*1eaf0ac3Slogwang u_long icps_bmcastecho; /* b/mcast echo requests dropped */ 55*1eaf0ac3Slogwang u_long icps_bmcasttstamp; /* b/mcast tstamp requests dropped */ 56*1eaf0ac3Slogwang u_long icps_badaddr; /* bad return address */ 57*1eaf0ac3Slogwang u_long icps_noroute; /* no route back */ 58*1eaf0ac3Slogwang }; 59*1eaf0ac3Slogwang 60*1eaf0ac3Slogwang #ifdef _KERNEL 61*1eaf0ac3Slogwang #include <sys/counter.h> 62*1eaf0ac3Slogwang 63*1eaf0ac3Slogwang VNET_PCPUSTAT_DECLARE(struct icmpstat, icmpstat); 64*1eaf0ac3Slogwang /* 65*1eaf0ac3Slogwang * In-kernel consumers can use these accessor macros directly to update 66*1eaf0ac3Slogwang * stats. 67*1eaf0ac3Slogwang */ 68*1eaf0ac3Slogwang #define ICMPSTAT_ADD(name, val) \ 69*1eaf0ac3Slogwang VNET_PCPUSTAT_ADD(struct icmpstat, icmpstat, name, (val)) 70*1eaf0ac3Slogwang #define ICMPSTAT_INC(name) ICMPSTAT_ADD(name, 1) 71*1eaf0ac3Slogwang 72*1eaf0ac3Slogwang /* 73*1eaf0ac3Slogwang * Kernel module consumers must use this accessor macro. 74*1eaf0ac3Slogwang */ 75*1eaf0ac3Slogwang void kmod_icmpstat_inc(int statnum); 76*1eaf0ac3Slogwang #define KMOD_ICMPSTAT_INC(name) \ 77*1eaf0ac3Slogwang kmod_icmpstat_inc(offsetof(struct icmpstat, name) / sizeof(uint64_t)) 78*1eaf0ac3Slogwang #endif 79*1eaf0ac3Slogwang 80*1eaf0ac3Slogwang /* 81*1eaf0ac3Slogwang * Identifiers for ICMP sysctl nodes 82*1eaf0ac3Slogwang */ 83*1eaf0ac3Slogwang #define ICMPCTL_MASKREPL 1 /* allow replies to netmask requests */ 84*1eaf0ac3Slogwang #define ICMPCTL_STATS 2 /* statistics (read-only) */ 85*1eaf0ac3Slogwang #define ICMPCTL_ICMPLIM 3 86*1eaf0ac3Slogwang 87*1eaf0ac3Slogwang #ifdef _KERNEL 88*1eaf0ac3Slogwang SYSCTL_DECL(_net_inet_icmp); 89*1eaf0ac3Slogwang 90*1eaf0ac3Slogwang extern int badport_bandlim(int); 91*1eaf0ac3Slogwang #define BANDLIM_UNLIMITED -1 92*1eaf0ac3Slogwang #define BANDLIM_ICMP_UNREACH 0 93*1eaf0ac3Slogwang #define BANDLIM_ICMP_ECHO 1 94*1eaf0ac3Slogwang #define BANDLIM_ICMP_TSTAMP 2 95*1eaf0ac3Slogwang #define BANDLIM_RST_CLOSEDPORT 3 /* No connection, and no listeners */ 96*1eaf0ac3Slogwang #define BANDLIM_RST_OPENPORT 4 /* No connection, listener */ 97*1eaf0ac3Slogwang #define BANDLIM_ICMP6_UNREACH 5 98*1eaf0ac3Slogwang #define BANDLIM_SCTP_OOTB 6 99*1eaf0ac3Slogwang #define BANDLIM_MAX 6 100*1eaf0ac3Slogwang #endif 101*1eaf0ac3Slogwang 102*1eaf0ac3Slogwang #endif 103