Thomas Gleixner | 2874c5f | 2019-05-27 08:55:01 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
| 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 RAW-IP module. |
| 8 | * |
| 9 | * Version: @(#)raw.h 1.0.2 05/07/93 |
| 10 | * |
| 11 | * Author: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | */ |
| 13 | #ifndef _RAW_H |
| 14 | #define _RAW_H |
| 15 | |
Duncan Eastoe | 7055420 | 2018-11-07 15:36:06 +0000 | [diff] [blame] | 16 | #include <net/inet_sock.h> |
Arnaldo Carvalho de Melo | 14c8502 | 2005-12-27 02:43:12 -0200 | [diff] [blame] | 17 | #include <net/protocol.h> |
Patrick McHardy | f74e49b | 2010-04-13 05:03:18 +0000 | [diff] [blame] | 18 | #include <linux/icmp.h> |
Arnaldo Carvalho de Melo | 14c8502 | 2005-12-27 02:43:12 -0200 | [diff] [blame] | 19 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | extern struct proto raw_prot; |
| 21 | |
Cyrill Gorcunov | 432490f | 2016-10-21 13:03:44 +0300 | [diff] [blame] | 22 | extern struct raw_hashinfo raw_v4_hashinfo; |
| 23 | struct sock *__raw_v4_lookup(struct net *net, struct sock *sk, |
| 24 | unsigned short num, __be32 raddr, |
David Ahern | 6735993 | 2017-08-07 08:44:18 -0700 | [diff] [blame] | 25 | __be32 laddr, int dif, int sdif); |
Cyrill Gorcunov | 432490f | 2016-10-21 13:03:44 +0300 | [diff] [blame] | 26 | |
| 27 | int raw_abort(struct sock *sk, int err); |
Pavel Emelyanov | 7bc54c9 | 2007-11-19 22:35:07 -0800 | [diff] [blame] | 28 | void raw_icmp_error(struct sk_buff *, int, u32); |
| 29 | int raw_local_deliver(struct sk_buff *, int); |
| 30 | |
Joe Perches | 0ad6ad9 | 2013-09-22 10:32:19 -0700 | [diff] [blame] | 31 | int raw_rcv(struct sock *, struct sk_buff *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | |
Pavel Emelyanov | b673e4d | 2007-11-19 22:36:45 -0800 | [diff] [blame] | 33 | #define RAW_HTABLE_SIZE MAX_INET_PROTOS |
| 34 | |
| 35 | struct raw_hashinfo { |
| 36 | rwlock_t lock; |
| 37 | struct hlist_head ht[RAW_HTABLE_SIZE]; |
| 38 | }; |
| 39 | |
Arnaldo Carvalho de Melo | 2038073 | 2005-08-16 02:18:02 -0300 | [diff] [blame] | 40 | #ifdef CONFIG_PROC_FS |
Joe Perches | 0ad6ad9 | 2013-09-22 10:32:19 -0700 | [diff] [blame] | 41 | int raw_proc_init(void); |
| 42 | void raw_proc_exit(void); |
Pavel Emelyanov | 42a7380 | 2007-11-19 22:38:33 -0800 | [diff] [blame] | 43 | |
| 44 | struct raw_iter_state { |
Pavel Emelyanov | f51d599 | 2008-01-14 05:35:57 -0800 | [diff] [blame] | 45 | struct seq_net_private p; |
Pavel Emelyanov | 42a7380 | 2007-11-19 22:38:33 -0800 | [diff] [blame] | 46 | int bucket; |
Pavel Emelyanov | 42a7380 | 2007-11-19 22:38:33 -0800 | [diff] [blame] | 47 | }; |
| 48 | |
Joe Perches | e363416 | 2010-09-07 05:55:38 +0000 | [diff] [blame] | 49 | static inline struct raw_iter_state *raw_seq_private(struct seq_file *seq) |
| 50 | { |
| 51 | return seq->private; |
| 52 | } |
Pavel Emelyanov | 42a7380 | 2007-11-19 22:38:33 -0800 | [diff] [blame] | 53 | void *raw_seq_start(struct seq_file *seq, loff_t *pos); |
| 54 | void *raw_seq_next(struct seq_file *seq, void *v, loff_t *pos); |
| 55 | void raw_seq_stop(struct seq_file *seq, void *v); |
Arnaldo Carvalho de Melo | 2038073 | 2005-08-16 02:18:02 -0300 | [diff] [blame] | 56 | #endif |
| 57 | |
Craig Gallek | 086c653 | 2016-02-10 11:50:35 -0500 | [diff] [blame] | 58 | int raw_hash_sk(struct sock *sk); |
Pavel Emelyanov | fc8717b | 2008-03-22 16:56:51 -0700 | [diff] [blame] | 59 | void raw_unhash_sk(struct sock *sk); |
Mike Manning | 6897445 | 2018-11-07 15:36:05 +0000 | [diff] [blame] | 60 | void raw_init(void); |
Pavel Emelyanov | 65b4c50 | 2007-11-19 22:37:24 -0800 | [diff] [blame] | 61 | |
Patrick McHardy | f74e49b | 2010-04-13 05:03:18 +0000 | [diff] [blame] | 62 | struct raw_sock { |
| 63 | /* inet_sock has to be the first member */ |
| 64 | struct inet_sock inet; |
| 65 | struct icmp_filter filter; |
Patrick McHardy | f0ad086 | 2010-04-13 05:03:23 +0000 | [diff] [blame] | 66 | u32 ipmr_table; |
Patrick McHardy | f74e49b | 2010-04-13 05:03:18 +0000 | [diff] [blame] | 67 | }; |
| 68 | |
| 69 | static inline struct raw_sock *raw_sk(const struct sock *sk) |
| 70 | { |
| 71 | return (struct raw_sock *)sk; |
| 72 | } |
| 73 | |
Duncan Eastoe | 7055420 | 2018-11-07 15:36:06 +0000 | [diff] [blame] | 74 | static inline bool raw_sk_bound_dev_eq(struct net *net, int bound_dev_if, |
| 75 | int dif, int sdif) |
| 76 | { |
| 77 | #if IS_ENABLED(CONFIG_NET_L3_MASTER_DEV) |
| 78 | return inet_bound_dev_eq(!!net->ipv4.sysctl_raw_l3mdev_accept, |
| 79 | bound_dev_if, dif, sdif); |
| 80 | #else |
| 81 | return inet_bound_dev_eq(true, bound_dev_if, dif, sdif); |
| 82 | #endif |
| 83 | } |
| 84 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | #endif /* _RAW_H */ |