linux/net/ipv4/raw.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.
 *
 *		RAW - implementation of IP "raw" sockets.
 *
 * Authors:	Ross Biro
 *		Fred N. van Kempen, <[email protected]>
 *
 * Fixes:
 *		Alan Cox	:	verify_area() fixed up
 *		Alan Cox	:	ICMP error handling
 *		Alan Cox	:	EMSGSIZE if you send too big a packet
 *		Alan Cox	: 	Now uses generic datagrams and shared
 *					skbuff library. No more peek crashes,
 *					no more backlogs
 *		Alan Cox	:	Checks sk->broadcast.
 *		Alan Cox	:	Uses skb_free_datagram/skb_copy_datagram
 *		Alan Cox	:	Raw passes ip options too
 *		Alan Cox	:	Setsocketopt added
 *		Alan Cox	:	Fixed error return for broadcasts
 *		Alan Cox	:	Removed wake_up calls
 *		Alan Cox	:	Use ttl/tos
 *		Alan Cox	:	Cleaned up old debugging
 *		Alan Cox	:	Use new kernel side addresses
 *	Arnt Gulbrandsen	:	Fixed MSG_DONTROUTE in raw sockets.
 *		Alan Cox	:	BSD style RAW socket demultiplexing.
 *		Alan Cox	:	Beginnings of mrouted support.
 *		Alan Cox	:	Added IP_HDRINCL option.
 *		Alan Cox	:	Skip broadcast check if BSDism set.
 *		David S. Miller	:	New socket lookup architecture.
 */

#include <linux/types.h>
#include <linux/atomic.h>
#include <asm/byteorder.h>
#include <asm/current.h>
#include <linux/uaccess.h>
#include <asm/ioctls.h>
#include <linux/stddef.h>
#include <linux/slab.h>
#include <linux/errno.h>
#include <linux/kernel.h>
#include <linux/export.h>
#include <linux/spinlock.h>
#include <linux/sockios.h>
#include <linux/socket.h>
#include <linux/in.h>
#include <linux/mroute.h>
#include <linux/netdevice.h>
#include <linux/in_route.h>
#include <linux/route.h>
#include <linux/skbuff.h>
#include <linux/igmp.h>
#include <net/net_namespace.h>
#include <net/dst.h>
#include <net/sock.h>
#include <linux/ip.h>
#include <linux/net.h>
#include <net/ip.h>
#include <net/icmp.h>
#include <net/udp.h>
#include <net/raw.h>
#include <net/snmp.h>
#include <net/tcp_states.h>
#include <net/inet_common.h>
#include <net/checksum.h>
#include <net/xfrm.h>
#include <linux/rtnetlink.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/netfilter.h>
#include <linux/netfilter_ipv4.h>
#include <linux/compat.h>
#include <linux/uio.h>

struct raw_frag_vec {};

struct raw_hashinfo raw_v4_hashinfo;
EXPORT_SYMBOL_GPL();

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

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

bool raw_v4_match(struct net *net, const struct sock *sk, unsigned short num,
		  __be32 raddr, __be32 laddr, int dif, int sdif)
{}
EXPORT_SYMBOL_GPL();

/*
 *	0 - deliver
 *	1 - block
 */
static int icmp_filter(const struct sock *sk, const struct sk_buff *skb)
{}

/* IP input processing comes here for RAW socket delivery.
 * Caller owns SKB, so we must make clones.
 *
 * RFC 1122: SHOULD pass TOS value up to the transport layer.
 * -> It does. And not only TOS, but all IP header.
 */
static int raw_v4_input(struct net *net, struct sk_buff *skb,
			const struct iphdr *iph, int hash)
{}

int raw_local_deliver(struct sk_buff *skb, int protocol)
{}

static void raw_err(struct sock *sk, struct sk_buff *skb, u32 info)
{}

void raw_icmp_error(struct sk_buff *skb, int protocol, u32 info)
{}

static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
{}

int raw_rcv(struct sock *sk, struct sk_buff *skb)
{}

static int raw_send_hdrinc(struct sock *sk, struct flowi4 *fl4,
			   struct msghdr *msg, size_t length,
			   struct rtable **rtp, unsigned int flags,
			   const struct sockcm_cookie *sockc)
{}

static int raw_probe_proto_opt(struct raw_frag_vec *rfv, struct flowi4 *fl4)
{}

static int raw_getfrag(void *from, char *to, int offset, int len, int odd,
		       struct sk_buff *skb)
{}

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

static void raw_close(struct sock *sk, long timeout)
{}

static void raw_destroy(struct sock *sk)
{}

/* This gets rid of all the nasties in af_inet. -DaveM */
static int raw_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)
{}

/*
 *	This should be easy, if there is something there
 *	we return it, otherwise we block.
 */

static int raw_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
		       int flags, int *addr_len)
{}

static int raw_sk_init(struct sock *sk)
{}

static int raw_seticmpfilter(struct sock *sk, sockptr_t optval, int optlen)
{}

static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
{}

static int do_raw_setsockopt(struct sock *sk, int optname,
			     sockptr_t optval, unsigned int optlen)
{}

static int raw_setsockopt(struct sock *sk, int level, int optname,
			  sockptr_t optval, unsigned int optlen)
{}

static int do_raw_getsockopt(struct sock *sk, int optname,
			     char __user *optval, int __user *optlen)
{}

static int raw_getsockopt(struct sock *sk, int level, int optname,
			  char __user *optval, int __user *optlen)
{}

static int raw_ioctl(struct sock *sk, int cmd, int *karg)
{}

#ifdef CONFIG_COMPAT
static int compat_raw_ioctl(struct sock *sk, unsigned int cmd, unsigned long arg)
{}
#endif

int raw_abort(struct sock *sk, int err)
{}
EXPORT_SYMBOL_GPL();

struct proto raw_prot =;

#ifdef CONFIG_PROC_FS
static struct sock *raw_get_first(struct seq_file *seq, int bucket)
{}

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

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

void *raw_seq_start(struct seq_file *seq, loff_t *pos)
	__acquires(&h->lock)
{}
EXPORT_SYMBOL_GPL();

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

void raw_seq_stop(struct seq_file *seq, void *v)
	__releases(&h->lock)
{}
EXPORT_SYMBOL_GPL();

static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
{}

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

static const struct seq_operations raw_seq_ops =;

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

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

static __net_initdata struct pernet_operations raw_net_ops =;

int __init raw_proc_init(void)
{}

void __init raw_proc_exit(void)
{}
#endif /* CONFIG_PROC_FS */

static void raw_sysctl_init_net(struct net *net)
{}

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

static struct pernet_operations __net_initdata raw_sysctl_ops =;

void __init raw_init(void)
{}