raw.h 2.3 KB
Newer Older
1
/* SPDX-License-Identifier: GPL-2.0-or-later */
L
Linus Torvalds 已提交
2 3 4 5 6 7 8 9 10 11 12 13 14 15
/*
 * 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.
 *
 *		Definitions for the RAW-IP module.
 *
 * Version:	@(#)raw.h	1.0.2	05/07/93
 *
 * Author:	Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
 */
#ifndef _RAW_H
#define _RAW_H

16
#include <net/inet_sock.h>
17
#include <net/protocol.h>
18
#include <linux/icmp.h>
19

L
Linus Torvalds 已提交
20 21
extern struct proto raw_prot;

22
extern struct raw_hashinfo raw_v4_hashinfo;
23 24
bool raw_v4_match(struct net *net, struct sock *sk, unsigned short num,
		  __be32 raddr, __be32 laddr, int dif, int sdif);
25 26

int raw_abort(struct sock *sk, int err);
27 28
void raw_icmp_error(struct sk_buff *, int, u32);
int raw_local_deliver(struct sk_buff *, int);
L
Linus Torvalds 已提交
29

30
int raw_rcv(struct sock *, struct sk_buff *);
L
Linus Torvalds 已提交
31

32 33 34 35
#define RAW_HTABLE_SIZE	MAX_INET_PROTOS

struct raw_hashinfo {
	rwlock_t lock;
E
Eric Dumazet 已提交
36
	struct hlist_nulls_head ht[RAW_HTABLE_SIZE];
37 38
};

E
Eric Dumazet 已提交
39 40 41 42 43 44 45 46 47
static inline void raw_hashinfo_init(struct raw_hashinfo *hashinfo)
{
	int i;

	rwlock_init(&hashinfo->lock);
	for (i = 0; i < RAW_HTABLE_SIZE; i++)
		INIT_HLIST_NULLS_HEAD(&hashinfo->ht[i], i);
}

48
#ifdef CONFIG_PROC_FS
49 50
int raw_proc_init(void);
void raw_proc_exit(void);
51 52

struct raw_iter_state {
53
	struct seq_net_private p;
54 55 56
	int bucket;
};

57 58 59 60
static inline struct raw_iter_state *raw_seq_private(struct seq_file *seq)
{
	return seq->private;
}
61 62 63
void *raw_seq_start(struct seq_file *seq, loff_t *pos);
void *raw_seq_next(struct seq_file *seq, void *v, loff_t *pos);
void raw_seq_stop(struct seq_file *seq, void *v);
64 65
#endif

66
int raw_hash_sk(struct sock *sk);
67
void raw_unhash_sk(struct sock *sk);
68
void raw_init(void);
69

70 71 72 73
struct raw_sock {
	/* inet_sock has to be the first member */
	struct inet_sock   inet;
	struct icmp_filter filter;
74
	u32		   ipmr_table;
75 76 77 78 79 80 81
};

static inline struct raw_sock *raw_sk(const struct sock *sk)
{
	return (struct raw_sock *)sk;
}

82 83 84 85 86 87 88 89 90 91 92
static inline bool raw_sk_bound_dev_eq(struct net *net, int bound_dev_if,
				       int dif, int sdif)
{
#if IS_ENABLED(CONFIG_NET_L3_MASTER_DEV)
	return inet_bound_dev_eq(!!net->ipv4.sysctl_raw_l3mdev_accept,
				 bound_dev_if, dif, sdif);
#else
	return inet_bound_dev_eq(true, bound_dev_if, dif, sdif);
#endif
}

L
Linus Torvalds 已提交
93
#endif	/* _RAW_H */