blob: caddf4a59ad118603e8d11d77accf87200f8c917 [file] [log] [blame]
Thomas Gleixner2874c5f2019-05-27 08:55:01 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
3 * INET An implementation of the TCP/IP protocol suite for the LINUX
4 * operating system. INET is implemented using the BSD Socket
5 * interface as the means of communication with the user level.
6 *
7 * Definitions for the ICMP module.
8 *
9 * Version: @(#)icmp.h 1.0.4 05/13/93
10 *
Jesper Juhl02c30a82005-05-05 16:16:16 -070011 * Authors: Ross Biro
Linus Torvalds1da177e2005-04-16 15:20:36 -070012 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
Linus Torvalds1da177e2005-04-16 15:20:36 -070013 */
14#ifndef _ICMP_H
15#define _ICMP_H
16
Linus Torvalds1da177e2005-04-16 15:20:36 -070017#include <linux/icmp.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070018
Arnaldo Carvalho de Melo14c85022005-12-27 02:43:12 -020019#include <net/inet_sock.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020#include <net/snmp.h>
Nazarov Sergey9ef6b422019-02-25 19:24:15 +030021#include <net/ip.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070022
23struct icmp_err {
24 int errno;
Eric Dumazet95c96172012-04-15 05:58:06 +000025 unsigned int fatal:1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070026};
27
Alexey Dobriyane7548342010-01-22 10:18:25 +000028extern const struct icmp_err icmp_err_convert[];
Pavel Emelyanovb60538a2008-07-18 04:04:02 -070029#define ICMP_INC_STATS(net, field) SNMP_INC_STATS((net)->mib.icmp_statistics, field)
Eric Dumazet13415e42016-04-27 16:44:43 -070030#define __ICMP_INC_STATS(net, field) __SNMP_INC_STATS((net)->mib.icmp_statistics, field)
Eric Dumazetacb32ba2011-11-08 13:04:43 +000031#define ICMPMSGOUT_INC_STATS(net, field) SNMP_INC_STATS_ATOMIC_LONG((net)->mib.icmpmsg_statistics, field+256)
Eric Dumazet214d3f12016-04-27 16:44:33 -070032#define ICMPMSGIN_INC_STATS(net, field) SNMP_INC_STATS_ATOMIC_LONG((net)->mib.icmpmsg_statistics, field)
Linus Torvalds1da177e2005-04-16 15:20:36 -070033
Arnaldo Carvalho de Melo14c85022005-12-27 02:43:12 -020034struct dst_entry;
35struct net_proto_family;
36struct sk_buff;
Pavel Emelyanov0388b002008-07-14 23:00:43 -070037struct net;
Arnaldo Carvalho de Melo14c85022005-12-27 02:43:12 -020038
Nazarov Sergey9ef6b422019-02-25 19:24:15 +030039void __icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info,
40 const struct ip_options *opt);
41static inline void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info)
42{
43 __icmp_send(skb_in, type, code, info, &IPCB(skb_in)->opt);
44}
45
Jason A. Donenfeld0b417132020-02-11 20:47:05 +010046#if IS_ENABLED(CONFIG_NF_NAT)
47void icmp_ndo_send(struct sk_buff *skb_in, int type, int code, __be32 info);
48#else
Jason A. Donenfeldee576c42021-02-23 14:18:58 +010049static inline void icmp_ndo_send(struct sk_buff *skb_in, int type, int code, __be32 info)
50{
51 struct ip_options opts = { 0 };
52 __icmp_send(skb_in, type, code, info, &opts);
53}
Jason A. Donenfeld0b417132020-02-11 20:47:05 +010054#endif
55
Joe Perchese60ab842013-09-20 11:23:28 -070056int icmp_rcv(struct sk_buff *skb);
Stefano Brivio32bbd872018-11-08 12:19:21 +010057int icmp_err(struct sk_buff *skb, u32 info);
Joe Perchese60ab842013-09-20 11:23:28 -070058int icmp_init(void);
59void icmp_out_count(struct net *net, unsigned char type);
Andreas Roeseler1fd07f32021-06-26 09:07:46 -050060bool icmp_build_probe(struct sk_buff *skb, struct icmphdr *icmphdr);
Linus Torvalds1da177e2005-04-16 15:20:36 -070061
Linus Torvalds1da177e2005-04-16 15:20:36 -070062#endif /* _ICMP_H */