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_bc_base;
66struct tipc_link;
67struct tipc_name_table;
68struct tipc_server;
69struct tipc_monitor;
70
71#define TIPC_MOD_VER "2.0.0"
72
73#define NODE_HTABLE_SIZE 512
74#define MAX_BEARERS 3
75#define TIPC_DEF_MON_THRESHOLD 32
76
77extern unsigned int tipc_net_id __read_mostly;
78extern int sysctl_tipc_rmem[3] __read_mostly;
79extern int sysctl_tipc_named_timeout __read_mostly;
80
81struct tipc_net {
82 u32 own_addr;
83 int net_id;
84 int random;
85
86
87 spinlock_t node_list_lock;
88 struct hlist_head node_htable[NODE_HTABLE_SIZE];
89 struct list_head node_list;
90 u32 num_nodes;
91 u32 num_links;
92
93
94 struct tipc_monitor *monitors[MAX_BEARERS];
95 int mon_threshold;
96
97
98 struct tipc_bearer __rcu *bearer_list[MAX_BEARERS + 1];
99
100
101 spinlock_t bclock;
102 struct tipc_bc_base *bcbase;
103 struct tipc_link *bcl;
104
105
106 struct rhashtable sk_rht;
107
108
109 spinlock_t nametbl_lock;
110 struct name_table *nametbl;
111
112
113 struct list_head dist_queue;
114
115
116 struct tipc_server *topsrv;
117 atomic_t subscription_count;
118};
119
120static inline struct tipc_net *tipc_net(struct net *net)
121{
122 return net_generic(net, tipc_net_id);
123}
124
125static inline int tipc_netid(struct net *net)
126{
127 return tipc_net(net)->net_id;
128}
129
130static inline struct list_head *tipc_nodes(struct net *net)
131{
132 return &tipc_net(net)->node_list;
133}
134
135static inline unsigned int tipc_hashfn(u32 addr)
136{
137 return addr & (NODE_HTABLE_SIZE - 1);
138}
139
140static inline u16 mod(u16 x)
141{
142 return x & 0xffffu;
143}
144
145static inline int less_eq(u16 left, u16 right)
146{
147 return mod(right - left) < 32768u;
148}
149
150static inline int more(u16 left, u16 right)
151{
152 return !less_eq(left, right);
153}
154
155static inline int less(u16 left, u16 right)
156{
157 return less_eq(left, right) && (mod(right) != mod(left));
158}
159
160static inline int in_range(u16 val, u16 min, u16 max)
161{
162 return !less(val, min) && !more(val, max);
163}
164
165#ifdef CONFIG_SYSCTL
166int tipc_register_sysctl(void);
167void tipc_unregister_sysctl(void);
168#else
169#define tipc_register_sysctl() 0
170#define tipc_unregister_sysctl()
171#endif
172#endif
173