xref: /linux/include/net/icmp.h (revision 1fd07f33)
12874c5fdSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */
21da177e4SLinus Torvalds /*
31da177e4SLinus Torvalds  * INET		An implementation of the TCP/IP protocol suite for the LINUX
41da177e4SLinus Torvalds  *		operating system.  INET is implemented using the  BSD Socket
51da177e4SLinus Torvalds  *		interface as the means of communication with the user level.
61da177e4SLinus Torvalds  *
71da177e4SLinus Torvalds  *		Definitions for the ICMP module.
81da177e4SLinus Torvalds  *
91da177e4SLinus Torvalds  * Version:	@(#)icmp.h	1.0.4	05/13/93
101da177e4SLinus Torvalds  *
1102c30a84SJesper Juhl  * Authors:	Ross Biro
121da177e4SLinus Torvalds  *		Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
131da177e4SLinus Torvalds  */
141da177e4SLinus Torvalds #ifndef _ICMP_H
151da177e4SLinus Torvalds #define	_ICMP_H
161da177e4SLinus Torvalds 
171da177e4SLinus Torvalds #include <linux/icmp.h>
181da177e4SLinus Torvalds 
1914c85021SArnaldo Carvalho de Melo #include <net/inet_sock.h>
201da177e4SLinus Torvalds #include <net/snmp.h>
219ef6b42aSNazarov Sergey #include <net/ip.h>
221da177e4SLinus Torvalds 
231da177e4SLinus Torvalds struct icmp_err {
241da177e4SLinus Torvalds   int		errno;
2595c96174SEric Dumazet   unsigned int	fatal:1;
261da177e4SLinus Torvalds };
271da177e4SLinus Torvalds 
28e754834eSAlexey Dobriyan extern const struct icmp_err icmp_err_convert[];
29b60538a0SPavel Emelyanov #define ICMP_INC_STATS(net, field)	SNMP_INC_STATS((net)->mib.icmp_statistics, field)
3013415e46SEric Dumazet #define __ICMP_INC_STATS(net, field)	__SNMP_INC_STATS((net)->mib.icmp_statistics, field)
31acb32ba3SEric Dumazet #define ICMPMSGOUT_INC_STATS(net, field)	SNMP_INC_STATS_ATOMIC_LONG((net)->mib.icmpmsg_statistics, field+256)
32214d3f1fSEric Dumazet #define ICMPMSGIN_INC_STATS(net, field)		SNMP_INC_STATS_ATOMIC_LONG((net)->mib.icmpmsg_statistics, field)
331da177e4SLinus Torvalds 
3414c85021SArnaldo Carvalho de Melo struct dst_entry;
3514c85021SArnaldo Carvalho de Melo struct net_proto_family;
3614c85021SArnaldo Carvalho de Melo struct sk_buff;
370388b004SPavel Emelyanov struct net;
3814c85021SArnaldo Carvalho de Melo 
399ef6b42aSNazarov Sergey void __icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info,
409ef6b42aSNazarov Sergey 		 const struct ip_options *opt);
icmp_send(struct sk_buff * skb_in,int type,int code,__be32 info)419ef6b42aSNazarov Sergey static inline void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info)
429ef6b42aSNazarov Sergey {
439ef6b42aSNazarov Sergey 	__icmp_send(skb_in, type, code, info, &IPCB(skb_in)->opt);
449ef6b42aSNazarov Sergey }
459ef6b42aSNazarov Sergey 
460b41713bSJason A. Donenfeld #if IS_ENABLED(CONFIG_NF_NAT)
470b41713bSJason A. Donenfeld void icmp_ndo_send(struct sk_buff *skb_in, int type, int code, __be32 info);
480b41713bSJason A. Donenfeld #else
icmp_ndo_send(struct sk_buff * skb_in,int type,int code,__be32 info)49ee576c47SJason A. Donenfeld static inline void icmp_ndo_send(struct sk_buff *skb_in, int type, int code, __be32 info)
50ee576c47SJason A. Donenfeld {
51ee576c47SJason A. Donenfeld 	struct ip_options opts = { 0 };
52ee576c47SJason A. Donenfeld 	__icmp_send(skb_in, type, code, info, &opts);
53ee576c47SJason A. Donenfeld }
540b41713bSJason A. Donenfeld #endif
550b41713bSJason A. Donenfeld 
56e60ab84dSJoe Perches int icmp_rcv(struct sk_buff *skb);
5732bbd879SStefano Brivio int icmp_err(struct sk_buff *skb, u32 info);
58e60ab84dSJoe Perches int icmp_init(void);
59e60ab84dSJoe Perches void icmp_out_count(struct net *net, unsigned char type);
60*1fd07f33SAndreas Roeseler bool icmp_build_probe(struct sk_buff *skb, struct icmphdr *icmphdr);
611da177e4SLinus Torvalds 
621da177e4SLinus Torvalds #endif	/* _ICMP_H */
63