1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37#ifndef _TIPC_CORE_H
38#define _TIPC_CORE_H
39
40#include <linux/tipc.h>
41#include <linux/tipc_config.h>
42#include <linux/tipc_netlink.h>
43#include <linux/types.h>
44#include <linux/kernel.h>
45#include <linux/errno.h>
46#include <linux/mm.h>
47#include <linux/timer.h>
48#include <linux/string.h>
49#include <linux/uaccess.h>
50#include <linux/interrupt.h>
51#include <linux/atomic.h>
52#include <asm/hardirq.h>
53#include <linux/netdevice.h>
54#include <linux/in.h>
55#include <linux/list.h>
56#include <linux/slab.h>
57#include <linux/vmalloc.h>
58#include <linux/rtnetlink.h>
59#include <linux/etherdevice.h>
60#include <net/netns/generic.h>
61#include <linux/rhashtable.h>
62
63struct tipc_node;
64struct tipc_bearer;
65struct tipc_bcbearer;
66struct tipc_bclink;
67struct tipc_link;
68struct tipc_name_table;
69struct tipc_server;
70
71#define TIPC_MOD_VER "2.0.0"
72
73#define NODE_HTABLE_SIZE 512
74#define MAX_BEARERS 3
75
76extern int tipc_net_id __read_mostly;
77extern int sysctl_tipc_rmem[3] __read_mostly;
78extern int sysctl_tipc_named_timeout __read_mostly;
79
80struct tipc_net {
81 u32 own_addr;
82 int net_id;
83 int random;
84
85
86 spinlock_t node_list_lock;
87 struct hlist_head node_htable[NODE_HTABLE_SIZE];
88 struct list_head node_list;
89 u32 num_nodes;
90 u32 num_links;
91
92
93 struct tipc_bearer __rcu *bearer_list[MAX_BEARERS + 1];
94
95
96 struct tipc_bcbearer *bcbearer;
97 struct tipc_bclink *bclink;
98 struct tipc_link *bcl;
99
100
101 struct rhashtable sk_rht;
102
103
104 spinlock_t nametbl_lock;
105 struct name_table *nametbl;
106
107
108 struct tipc_server *topsrv;
109 atomic_t subscription_count;
110};
111
112static inline struct tipc_net *tipc_net(struct net *net)
113{
114 return net_generic(net, tipc_net_id);
115}
116
117static inline u16 mod(u16 x)
118{
119 return x & 0xffffu;
120}
121
122static inline int less_eq(u16 left, u16 right)
123{
124 return mod(right - left) < 32768u;
125}
126
127static inline int more(u16 left, u16 right)
128{
129 return !less_eq(left, right);
130}
131
132static inline int less(u16 left, u16 right)
133{
134 return less_eq(left, right) && (mod(right) != mod(left));
135}
136
137static inline int in_range(u16 val, u16 min, u16 max)
138{
139 return !less(val, min) && !more(val, max);
140}
141
142#ifdef CONFIG_SYSCTL
143int tipc_register_sysctl(void);
144void tipc_unregister_sysctl(void);
145#else
146#define tipc_register_sysctl() 0
147#define tipc_unregister_sysctl()
148#endif
149#endif
150