11eaf0ac3Slogwang /*- 2*d4a07e70Sfengbojiang * SPDX-License-Identifier: BSD-3-Clause 3*d4a07e70Sfengbojiang * 41eaf0ac3Slogwang * Copyright (c) 1982, 1986, 1993 51eaf0ac3Slogwang * The Regents of the University of California. All rights reserved. 61eaf0ac3Slogwang * 71eaf0ac3Slogwang * Redistribution and use in source and binary forms, with or without 81eaf0ac3Slogwang * modification, are permitted provided that the following conditions 91eaf0ac3Slogwang * are met: 101eaf0ac3Slogwang * 1. Redistributions of source code must retain the above copyright 111eaf0ac3Slogwang * notice, this list of conditions and the following disclaimer. 121eaf0ac3Slogwang * 2. Redistributions in binary form must reproduce the above copyright 131eaf0ac3Slogwang * notice, this list of conditions and the following disclaimer in the 141eaf0ac3Slogwang * documentation and/or other materials provided with the distribution. 15*d4a07e70Sfengbojiang * 3. Neither the name of the University nor the names of its contributors 161eaf0ac3Slogwang * may be used to endorse or promote products derived from this software 171eaf0ac3Slogwang * without specific prior written permission. 181eaf0ac3Slogwang * 191eaf0ac3Slogwang * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 201eaf0ac3Slogwang * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 211eaf0ac3Slogwang * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 221eaf0ac3Slogwang * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 231eaf0ac3Slogwang * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 241eaf0ac3Slogwang * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 251eaf0ac3Slogwang * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 261eaf0ac3Slogwang * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 271eaf0ac3Slogwang * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 281eaf0ac3Slogwang * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 291eaf0ac3Slogwang * SUCH DAMAGE. 301eaf0ac3Slogwang * 311eaf0ac3Slogwang * @(#)icmp_var.h 8.1 (Berkeley) 6/10/93 321eaf0ac3Slogwang * $FreeBSD$ 331eaf0ac3Slogwang */ 341eaf0ac3Slogwang 351eaf0ac3Slogwang #ifndef _NETINET_ICMP_VAR_H_ 361eaf0ac3Slogwang #define _NETINET_ICMP_VAR_H_ 371eaf0ac3Slogwang 381eaf0ac3Slogwang /* 391eaf0ac3Slogwang * Variables related to this implementation 401eaf0ac3Slogwang * of the internet control message protocol. 411eaf0ac3Slogwang */ 421eaf0ac3Slogwang struct icmpstat { 431eaf0ac3Slogwang /* statistics related to icmp packets generated */ 441eaf0ac3Slogwang u_long icps_error; /* # of calls to icmp_error */ 451eaf0ac3Slogwang u_long icps_oldshort; /* no error 'cuz old ip too short */ 461eaf0ac3Slogwang u_long icps_oldicmp; /* no error 'cuz old was icmp */ 471eaf0ac3Slogwang u_long icps_outhist[ICMP_MAXTYPE + 1]; 481eaf0ac3Slogwang /* statistics related to input messages processed */ 491eaf0ac3Slogwang u_long icps_badcode; /* icmp_code out of range */ 501eaf0ac3Slogwang u_long icps_tooshort; /* packet < ICMP_MINLEN */ 511eaf0ac3Slogwang u_long icps_checksum; /* bad checksum */ 521eaf0ac3Slogwang u_long icps_badlen; /* calculated bound mismatch */ 531eaf0ac3Slogwang u_long icps_reflect; /* number of responses */ 541eaf0ac3Slogwang u_long icps_inhist[ICMP_MAXTYPE + 1]; 551eaf0ac3Slogwang u_long icps_bmcastecho; /* b/mcast echo requests dropped */ 561eaf0ac3Slogwang u_long icps_bmcasttstamp; /* b/mcast tstamp requests dropped */ 571eaf0ac3Slogwang u_long icps_badaddr; /* bad return address */ 581eaf0ac3Slogwang u_long icps_noroute; /* no route back */ 591eaf0ac3Slogwang }; 601eaf0ac3Slogwang 611eaf0ac3Slogwang #ifdef _KERNEL 621eaf0ac3Slogwang #include <sys/counter.h> 631eaf0ac3Slogwang 641eaf0ac3Slogwang VNET_PCPUSTAT_DECLARE(struct icmpstat, icmpstat); 651eaf0ac3Slogwang /* 661eaf0ac3Slogwang * In-kernel consumers can use these accessor macros directly to update 671eaf0ac3Slogwang * stats. 681eaf0ac3Slogwang */ 691eaf0ac3Slogwang #define ICMPSTAT_ADD(name, val) \ 701eaf0ac3Slogwang VNET_PCPUSTAT_ADD(struct icmpstat, icmpstat, name, (val)) 711eaf0ac3Slogwang #define ICMPSTAT_INC(name) ICMPSTAT_ADD(name, 1) 721eaf0ac3Slogwang 731eaf0ac3Slogwang /* 741eaf0ac3Slogwang * Kernel module consumers must use this accessor macro. 751eaf0ac3Slogwang */ 761eaf0ac3Slogwang void kmod_icmpstat_inc(int statnum); 771eaf0ac3Slogwang #define KMOD_ICMPSTAT_INC(name) \ 781eaf0ac3Slogwang kmod_icmpstat_inc(offsetof(struct icmpstat, name) / sizeof(uint64_t)) 791eaf0ac3Slogwang #endif 801eaf0ac3Slogwang 811eaf0ac3Slogwang /* 821eaf0ac3Slogwang * Identifiers for ICMP sysctl nodes 831eaf0ac3Slogwang */ 841eaf0ac3Slogwang #define ICMPCTL_MASKREPL 1 /* allow replies to netmask requests */ 851eaf0ac3Slogwang #define ICMPCTL_STATS 2 /* statistics (read-only) */ 861eaf0ac3Slogwang #define ICMPCTL_ICMPLIM 3 871eaf0ac3Slogwang 881eaf0ac3Slogwang #ifdef _KERNEL 891eaf0ac3Slogwang SYSCTL_DECL(_net_inet_icmp); 901eaf0ac3Slogwang 911eaf0ac3Slogwang extern int badport_bandlim(int); 921eaf0ac3Slogwang #define BANDLIM_UNLIMITED -1 931eaf0ac3Slogwang #define BANDLIM_ICMP_UNREACH 0 941eaf0ac3Slogwang #define BANDLIM_ICMP_ECHO 1 951eaf0ac3Slogwang #define BANDLIM_ICMP_TSTAMP 2 961eaf0ac3Slogwang #define BANDLIM_RST_CLOSEDPORT 3 /* No connection, and no listeners */ 971eaf0ac3Slogwang #define BANDLIM_RST_OPENPORT 4 /* No connection, listener */ 981eaf0ac3Slogwang #define BANDLIM_ICMP6_UNREACH 5 991eaf0ac3Slogwang #define BANDLIM_SCTP_OOTB 6 100*d4a07e70Sfengbojiang #define BANDLIM_MAX 7 1011eaf0ac3Slogwang #endif 1021eaf0ac3Slogwang 1031eaf0ac3Slogwang #endif 104