^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * INET An implementation of the TCP/IP protocol suite for the LINUX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * operating system. INET is implemented using the BSD Socket
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * interface as the means of communication with the user level.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Definitions for the RAW-IP module.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * Version: @(#)raw.h 1.0.2 05/07/93
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * Author: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #ifndef _RAW_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #define _RAW_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <net/inet_sock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <net/protocol.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/icmp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) extern struct proto raw_prot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) extern struct raw_hashinfo raw_v4_hashinfo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) struct sock *__raw_v4_lookup(struct net *net, struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) unsigned short num, __be32 raddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) __be32 laddr, int dif, int sdif);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) int raw_abort(struct sock *sk, int err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) void raw_icmp_error(struct sk_buff *, int, u32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) int raw_local_deliver(struct sk_buff *, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) int raw_rcv(struct sock *, struct sk_buff *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #define RAW_HTABLE_SIZE MAX_INET_PROTOS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) struct raw_hashinfo {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) rwlock_t lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) struct hlist_head ht[RAW_HTABLE_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #ifdef CONFIG_PROC_FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) int raw_proc_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) void raw_proc_exit(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) struct raw_iter_state {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) struct seq_net_private p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) int bucket;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) static inline struct raw_iter_state *raw_seq_private(struct seq_file *seq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) return seq->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) void *raw_seq_start(struct seq_file *seq, loff_t *pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) void *raw_seq_next(struct seq_file *seq, void *v, loff_t *pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) void raw_seq_stop(struct seq_file *seq, void *v);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) int raw_hash_sk(struct sock *sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) void raw_unhash_sk(struct sock *sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) void raw_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) struct raw_sock {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) /* inet_sock has to be the first member */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) struct inet_sock inet;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) struct icmp_filter filter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) u32 ipmr_table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) static inline struct raw_sock *raw_sk(const struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) return (struct raw_sock *)sk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) static inline bool raw_sk_bound_dev_eq(struct net *net, int bound_dev_if,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) int dif, int sdif)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) #if IS_ENABLED(CONFIG_NET_L3_MASTER_DEV)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) return inet_bound_dev_eq(!!net->ipv4.sysctl_raw_l3mdev_accept,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) bound_dev_if, dif, sdif);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) return inet_bound_dev_eq(true, bound_dev_if, dif, sdif);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) #endif /* _RAW_H */