linux/net/ipv4/ping.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * INET		An implementation of the TCP/IP protocol suite for the LINUX
 *		operating system.  INET is implemented using the  BSD Socket
 *		interface as the means of communication with the user level.
 *
 *		"Ping" sockets
 *
 * Based on ipv4/udp.c code.
 *
 * Authors:	Vasiliy Kulikov / Openwall (for Linux 2.6),
 *		Pavel Kankovsky (for Linux 2.4.32)
 *
 * Pavel gave all rights to bugs to Vasiliy,
 * none of the bugs are Pavel's now.
 */

#include <linux/uaccess.h>
#include <linux/types.h>
#include <linux/fcntl.h>
#include <linux/socket.h>
#include <linux/sockios.h>
#include <linux/in.h>
#include <linux/errno.h>
#include <linux/timer.h>
#include <linux/mm.h>
#include <linux/inet.h>
#include <linux/netdevice.h>
#include <net/snmp.h>
#include <net/ip.h>
#include <net/icmp.h>
#include <net/protocol.h>
#include <linux/skbuff.h>
#include <linux/proc_fs.h>
#include <linux/export.h>
#include <linux/bpf-cgroup.h>
#include <net/sock.h>
#include <net/ping.h>
#include <net/udp.h>
#include <net/route.h>
#include <net/inet_common.h>
#include <net/checksum.h>

#if IS_ENABLED(CONFIG_IPV6)
#include <linux/in6.h>
#include <linux/icmpv6.h>
#include <net/addrconf.h>
#include <net/ipv6.h>
#include <net/transp_v6.h>
#endif

struct ping_table {};

static struct ping_table ping_table;
struct pingv6_ops pingv6_ops;
EXPORT_SYMBOL_GPL();

static u16 ping_port_rover;

static inline u32 ping_hashfn(const struct net *net, u32 num, u32 mask)
{}
EXPORT_SYMBOL_GPL();

static inline struct hlist_head *ping_hashslot(struct ping_table *table,
					       struct net *net, unsigned int num)
{}

int ping_get_port(struct sock *sk, unsigned short ident)
{}
EXPORT_SYMBOL_GPL();

int ping_hash(struct sock *sk)
{}

void ping_unhash(struct sock *sk)
{}
EXPORT_SYMBOL_GPL();

/* Called under rcu_read_lock() */
static struct sock *ping_lookup(struct net *net, struct sk_buff *skb, u16 ident)
{}

static void inet_get_ping_group_range_net(struct net *net, kgid_t *low,
					  kgid_t *high)
{}


int ping_init_sock(struct sock *sk)
{}
EXPORT_SYMBOL_GPL();

void ping_close(struct sock *sk, long timeout)
{}
EXPORT_SYMBOL_GPL();

static int ping_pre_connect(struct sock *sk, struct sockaddr *uaddr,
			    int addr_len)
{}

/* Checks the bind address and possibly modifies sk->sk_bound_dev_if. */
static int ping_check_bind_addr(struct sock *sk, struct inet_sock *isk,
				struct sockaddr *uaddr, int addr_len)
{}

static void ping_set_saddr(struct sock *sk, struct sockaddr *saddr)
{}

/*
 * We need our own bind because there are no privileged id's == local ports.
 * Moreover, we don't allow binding to multi- and broadcast addresses.
 */

int ping_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)
{}
EXPORT_SYMBOL_GPL();

/*
 * Is this a supported type of ICMP message?
 */

static inline int ping_supported(int family, int type, int code)
{}

/*
 * This routine is called by the ICMP module when it gets some
 * sort of error condition.
 */

void ping_err(struct sk_buff *skb, int offset, u32 info)
{}
EXPORT_SYMBOL_GPL();

/*
 *	Copy and checksum an ICMP Echo packet from user space into a buffer
 *	starting from the payload.
 */

int ping_getfrag(void *from, char *to,
		 int offset, int fraglen, int odd, struct sk_buff *skb)
{}
EXPORT_SYMBOL_GPL();

static int ping_v4_push_pending_frames(struct sock *sk, struct pingfakehdr *pfh,
				       struct flowi4 *fl4)
{}

int ping_common_sendmsg(int family, struct msghdr *msg, size_t len,
			void *user_icmph, size_t icmph_len)
{}
EXPORT_SYMBOL_GPL();

static int ping_v4_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
{}

int ping_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int flags,
		 int *addr_len)
{}
EXPORT_SYMBOL_GPL();

static enum skb_drop_reason __ping_queue_rcv_skb(struct sock *sk,
						 struct sk_buff *skb)
{}

int ping_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
{}
EXPORT_SYMBOL_GPL();


/*
 *	All we need to do is get the socket.
 */

enum skb_drop_reason ping_rcv(struct sk_buff *skb)
{}
EXPORT_SYMBOL_GPL();

struct proto ping_prot =;
EXPORT_SYMBOL();

#ifdef CONFIG_PROC_FS

static struct sock *ping_get_first(struct seq_file *seq, int start)
{}

static struct sock *ping_get_next(struct seq_file *seq, struct sock *sk)
{}

static struct sock *ping_get_idx(struct seq_file *seq, loff_t pos)
{}

void *ping_seq_start(struct seq_file *seq, loff_t *pos, sa_family_t family)
	__acquires(ping_table.lock)
{}
EXPORT_SYMBOL_GPL();

static void *ping_v4_seq_start(struct seq_file *seq, loff_t *pos)
{}

void *ping_seq_next(struct seq_file *seq, void *v, loff_t *pos)
{}
EXPORT_SYMBOL_GPL();

void ping_seq_stop(struct seq_file *seq, void *v)
	__releases(ping_table.lock)
{}
EXPORT_SYMBOL_GPL();

static void ping_v4_format_sock(struct sock *sp, struct seq_file *f,
		int bucket)
{}

static int ping_v4_seq_show(struct seq_file *seq, void *v)
{}

static const struct seq_operations ping_v4_seq_ops =;

static int __net_init ping_v4_proc_init_net(struct net *net)
{}

static void __net_exit ping_v4_proc_exit_net(struct net *net)
{}

static struct pernet_operations ping_v4_net_ops =;

int __init ping_proc_init(void)
{}

void ping_proc_exit(void)
{}

#endif

void __init ping_init(void)
{}