Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * INET     An implementation of the TCP/IP protocol suite for the LINUX
0004  *      operating system.  INET is implemented using the  BSD Socket
0005  *      interface as the means of communication with the user level.
0006  *
0007  *      Definitions for the RAW-IP module.
0008  *
0009  * Version: @(#)raw.h   1.0.2   05/07/93
0010  *
0011  * Author:  Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
0012  */
0013 #ifndef _RAW_H
0014 #define _RAW_H
0015 
0016 #include <net/inet_sock.h>
0017 #include <net/protocol.h>
0018 #include <linux/icmp.h>
0019 
0020 extern struct proto raw_prot;
0021 
0022 extern struct raw_hashinfo raw_v4_hashinfo;
0023 bool raw_v4_match(struct net *net, struct sock *sk, unsigned short num,
0024           __be32 raddr, __be32 laddr, int dif, int sdif);
0025 
0026 int raw_abort(struct sock *sk, int err);
0027 void raw_icmp_error(struct sk_buff *, int, u32);
0028 int raw_local_deliver(struct sk_buff *, int);
0029 
0030 int raw_rcv(struct sock *, struct sk_buff *);
0031 
0032 #define RAW_HTABLE_SIZE MAX_INET_PROTOS
0033 
0034 struct raw_hashinfo {
0035     spinlock_t lock;
0036     struct hlist_nulls_head ht[RAW_HTABLE_SIZE];
0037 };
0038 
0039 static inline void raw_hashinfo_init(struct raw_hashinfo *hashinfo)
0040 {
0041     int i;
0042 
0043     spin_lock_init(&hashinfo->lock);
0044     for (i = 0; i < RAW_HTABLE_SIZE; i++)
0045         INIT_HLIST_NULLS_HEAD(&hashinfo->ht[i], i);
0046 }
0047 
0048 #ifdef CONFIG_PROC_FS
0049 int raw_proc_init(void);
0050 void raw_proc_exit(void);
0051 
0052 struct raw_iter_state {
0053     struct seq_net_private p;
0054     int bucket;
0055 };
0056 
0057 static inline struct raw_iter_state *raw_seq_private(struct seq_file *seq)
0058 {
0059     return seq->private;
0060 }
0061 void *raw_seq_start(struct seq_file *seq, loff_t *pos);
0062 void *raw_seq_next(struct seq_file *seq, void *v, loff_t *pos);
0063 void raw_seq_stop(struct seq_file *seq, void *v);
0064 #endif
0065 
0066 int raw_hash_sk(struct sock *sk);
0067 void raw_unhash_sk(struct sock *sk);
0068 void raw_init(void);
0069 
0070 struct raw_sock {
0071     /* inet_sock has to be the first member */
0072     struct inet_sock   inet;
0073     struct icmp_filter filter;
0074     u32        ipmr_table;
0075 };
0076 
0077 static inline struct raw_sock *raw_sk(const struct sock *sk)
0078 {
0079     return (struct raw_sock *)sk;
0080 }
0081 
0082 static inline bool raw_sk_bound_dev_eq(struct net *net, int bound_dev_if,
0083                        int dif, int sdif)
0084 {
0085 #if IS_ENABLED(CONFIG_NET_L3_MASTER_DEV)
0086     return inet_bound_dev_eq(READ_ONCE(net->ipv4.sysctl_raw_l3mdev_accept),
0087                  bound_dev_if, dif, sdif);
0088 #else
0089     return inet_bound_dev_eq(true, bound_dev_if, dif, sdif);
0090 #endif
0091 }
0092 
0093 #endif  /* _RAW_H */