diff options
Diffstat (limited to 'net')
-rw-r--r-- | net/tipc/bcast.c | 1 | ||||
-rw-r--r-- | net/tipc/bearer.h | 69 | ||||
-rw-r--r-- | net/tipc/config.c | 2 | ||||
-rw-r--r-- | net/tipc/core.c | 40 | ||||
-rw-r--r-- | net/tipc/core.h | 14 | ||||
-rw-r--r-- | net/tipc/eth_media.c | 6 | ||||
-rw-r--r-- | net/tipc/msg.h | 168 | ||||
-rw-r--r-- | net/tipc/port.h | 131 | ||||
-rw-r--r-- | net/tipc/socket.c | 3 | ||||
-rw-r--r-- | net/tipc/subscr.c | 1 | ||||
-rw-r--r-- | net/tipc/user_reg.h | 5 |
11 files changed, 382 insertions, 58 deletions
diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c index 22a60fc98392..7d449f03c385 100644 --- a/net/tipc/bcast.c +++ b/net/tipc/bcast.c | |||
@@ -47,6 +47,7 @@ | |||
47 | #include "name_distr.h" | 47 | #include "name_distr.h" |
48 | #include "bearer.h" | 48 | #include "bearer.h" |
49 | #include "name_table.h" | 49 | #include "name_table.h" |
50 | #include "port.h" | ||
50 | #include "bcast.h" | 51 | #include "bcast.h" |
51 | 52 | ||
52 | #define MAX_PKT_DEFAULT_MCAST 1500 /* bcast link max packet size (fixed) */ | 53 | #define MAX_PKT_DEFAULT_MCAST 1500 /* bcast link max packet size (fixed) */ |
diff --git a/net/tipc/bearer.h b/net/tipc/bearer.h index a850b389663e..49af7fae8b5a 100644 --- a/net/tipc/bearer.h +++ b/net/tipc/bearer.h | |||
@@ -43,6 +43,45 @@ | |||
43 | #define MAX_BEARERS 8 | 43 | #define MAX_BEARERS 8 |
44 | #define MAX_MEDIA 4 | 44 | #define MAX_MEDIA 4 |
45 | 45 | ||
46 | /* | ||
47 | * Identifiers of supported TIPC media types | ||
48 | */ | ||
49 | #define TIPC_MEDIA_TYPE_ETH 1 | ||
50 | |||
51 | /* | ||
52 | * Destination address structure used by TIPC bearers when sending messages | ||
53 | * | ||
54 | * IMPORTANT: The fields of this structure MUST be stored using the specified | ||
55 | * byte order indicated below, as the structure is exchanged between nodes | ||
56 | * as part of a link setup process. | ||
57 | */ | ||
58 | struct tipc_media_addr { | ||
59 | __be32 type; /* bearer type (network byte order) */ | ||
60 | union { | ||
61 | __u8 eth_addr[6]; /* 48 bit Ethernet addr (byte array) */ | ||
62 | } dev_addr; | ||
63 | }; | ||
64 | |||
65 | /** | ||
66 | * struct tipc_bearer - TIPC bearer info available to media code | ||
67 | * @usr_handle: pointer to additional media-specific information about bearer | ||
68 | * @mtu: max packet size bearer can support | ||
69 | * @blocked: non-zero if bearer is blocked | ||
70 | * @lock: spinlock for controlling access to bearer | ||
71 | * @addr: media-specific address associated with bearer | ||
72 | * @name: bearer name (format = media:interface) | ||
73 | * | ||
74 | * Note: TIPC initializes "name" and "lock" fields; media code is responsible | ||
75 | * for initialization all other fields when a bearer is enabled. | ||
76 | */ | ||
77 | struct tipc_bearer { | ||
78 | void *usr_handle; | ||
79 | u32 mtu; | ||
80 | int blocked; | ||
81 | spinlock_t lock; | ||
82 | struct tipc_media_addr addr; | ||
83 | char name[TIPC_MAX_BEARER_NAME]; | ||
84 | }; | ||
46 | 85 | ||
47 | /** | 86 | /** |
48 | * struct media - TIPC media information available to internal users | 87 | * struct media - TIPC media information available to internal users |
@@ -55,7 +94,7 @@ | |||
55 | * @priority: default link (and bearer) priority | 94 | * @priority: default link (and bearer) priority |
56 | * @tolerance: default time (in ms) before declaring link failure | 95 | * @tolerance: default time (in ms) before declaring link failure |
57 | * @window: default window (in packets) before declaring link congestion | 96 | * @window: default window (in packets) before declaring link congestion |
58 | * @type_id: TIPC media identifier [defined in tipc_bearer.h] | 97 | * @type_id: TIPC media identifier |
59 | * @name: media name | 98 | * @name: media name |
60 | */ | 99 | */ |
61 | 100 | ||
@@ -116,6 +155,34 @@ struct link; | |||
116 | 155 | ||
117 | extern struct bearer tipc_bearers[]; | 156 | extern struct bearer tipc_bearers[]; |
118 | 157 | ||
158 | /* | ||
159 | * TIPC routines available to supported media types | ||
160 | */ | ||
161 | int tipc_register_media(u32 media_type, | ||
162 | char *media_name, int (*enable)(struct tipc_bearer *), | ||
163 | void (*disable)(struct tipc_bearer *), | ||
164 | int (*send_msg)(struct sk_buff *, | ||
165 | struct tipc_bearer *, struct tipc_media_addr *), | ||
166 | char *(*addr2str)(struct tipc_media_addr *a, | ||
167 | char *str_buf, int str_size), | ||
168 | struct tipc_media_addr *bcast_addr, const u32 bearer_priority, | ||
169 | const u32 link_tolerance, /* [ms] */ | ||
170 | const u32 send_window_limit); | ||
171 | |||
172 | void tipc_recv_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr); | ||
173 | |||
174 | int tipc_block_bearer(const char *name); | ||
175 | void tipc_continue(struct tipc_bearer *tb_ptr); | ||
176 | |||
177 | int tipc_enable_bearer(const char *bearer_name, u32 bcast_scope, u32 priority); | ||
178 | int tipc_disable_bearer(const char *name); | ||
179 | |||
180 | /* | ||
181 | * Routines made available to TIPC by supported media types | ||
182 | */ | ||
183 | int tipc_eth_media_start(void); | ||
184 | void tipc_eth_media_stop(void); | ||
185 | |||
119 | void tipc_media_addr_printf(struct print_buf *pb, struct tipc_media_addr *a); | 186 | void tipc_media_addr_printf(struct print_buf *pb, struct tipc_media_addr *a); |
120 | struct sk_buff *tipc_media_get_names(void); | 187 | struct sk_buff *tipc_media_get_names(void); |
121 | 188 | ||
diff --git a/net/tipc/config.c b/net/tipc/config.c index 50a6133a3668..82267f3cd3b7 100644 --- a/net/tipc/config.c +++ b/net/tipc/config.c | |||
@@ -43,8 +43,8 @@ | |||
43 | #include "addr.h" | 43 | #include "addr.h" |
44 | #include "name_table.h" | 44 | #include "name_table.h" |
45 | #include "node.h" | 45 | #include "node.h" |
46 | #include "user_reg.h" | ||
46 | #include "config.h" | 47 | #include "config.h" |
47 | #include "discover.h" | ||
48 | 48 | ||
49 | struct subscr_data { | 49 | struct subscr_data { |
50 | char usr_handle[8]; | 50 | char usr_handle[8]; |
diff --git a/net/tipc/core.c b/net/tipc/core.c index e2a09eb8efd4..785362f6a411 100644 --- a/net/tipc/core.c +++ b/net/tipc/core.c | |||
@@ -236,43 +236,3 @@ module_exit(tipc_exit); | |||
236 | MODULE_DESCRIPTION("TIPC: Transparent Inter Process Communication"); | 236 | MODULE_DESCRIPTION("TIPC: Transparent Inter Process Communication"); |
237 | MODULE_LICENSE("Dual BSD/GPL"); | 237 | MODULE_LICENSE("Dual BSD/GPL"); |
238 | MODULE_VERSION(TIPC_MOD_VER); | 238 | MODULE_VERSION(TIPC_MOD_VER); |
239 | |||
240 | /* Native TIPC API for kernel-space applications (see tipc.h) */ | ||
241 | |||
242 | EXPORT_SYMBOL(tipc_attach); | ||
243 | EXPORT_SYMBOL(tipc_detach); | ||
244 | EXPORT_SYMBOL(tipc_createport); | ||
245 | EXPORT_SYMBOL(tipc_deleteport); | ||
246 | EXPORT_SYMBOL(tipc_ownidentity); | ||
247 | EXPORT_SYMBOL(tipc_portimportance); | ||
248 | EXPORT_SYMBOL(tipc_set_portimportance); | ||
249 | EXPORT_SYMBOL(tipc_portunreliable); | ||
250 | EXPORT_SYMBOL(tipc_set_portunreliable); | ||
251 | EXPORT_SYMBOL(tipc_portunreturnable); | ||
252 | EXPORT_SYMBOL(tipc_set_portunreturnable); | ||
253 | EXPORT_SYMBOL(tipc_publish); | ||
254 | EXPORT_SYMBOL(tipc_withdraw); | ||
255 | EXPORT_SYMBOL(tipc_connect2port); | ||
256 | EXPORT_SYMBOL(tipc_disconnect); | ||
257 | EXPORT_SYMBOL(tipc_shutdown); | ||
258 | EXPORT_SYMBOL(tipc_send); | ||
259 | EXPORT_SYMBOL(tipc_send2name); | ||
260 | EXPORT_SYMBOL(tipc_send2port); | ||
261 | EXPORT_SYMBOL(tipc_multicast); | ||
262 | |||
263 | /* TIPC API for external bearers (see tipc_bearer.h) */ | ||
264 | |||
265 | EXPORT_SYMBOL(tipc_block_bearer); | ||
266 | EXPORT_SYMBOL(tipc_continue); | ||
267 | EXPORT_SYMBOL(tipc_disable_bearer); | ||
268 | EXPORT_SYMBOL(tipc_enable_bearer); | ||
269 | EXPORT_SYMBOL(tipc_recv_msg); | ||
270 | EXPORT_SYMBOL(tipc_register_media); | ||
271 | |||
272 | /* TIPC API for external APIs (see tipc_port.h) */ | ||
273 | |||
274 | EXPORT_SYMBOL(tipc_createport_raw); | ||
275 | EXPORT_SYMBOL(tipc_reject_msg); | ||
276 | EXPORT_SYMBOL(tipc_send_buf_fast); | ||
277 | EXPORT_SYMBOL(tipc_acknowledge); | ||
278 | |||
diff --git a/net/tipc/core.h b/net/tipc/core.h index e19389e57227..ca7e171c1043 100644 --- a/net/tipc/core.h +++ b/net/tipc/core.h | |||
@@ -39,10 +39,6 @@ | |||
39 | 39 | ||
40 | #include <linux/tipc.h> | 40 | #include <linux/tipc.h> |
41 | #include <linux/tipc_config.h> | 41 | #include <linux/tipc_config.h> |
42 | #include <net/tipc/tipc_msg.h> | ||
43 | #include <net/tipc/tipc_port.h> | ||
44 | #include <net/tipc/tipc_bearer.h> | ||
45 | #include <net/tipc/tipc.h> | ||
46 | #include <linux/types.h> | 42 | #include <linux/types.h> |
47 | #include <linux/kernel.h> | 43 | #include <linux/kernel.h> |
48 | #include <linux/errno.h> | 44 | #include <linux/errno.h> |
@@ -62,6 +58,9 @@ | |||
62 | 58 | ||
63 | #define TIPC_MOD_VER "2.0.0" | 59 | #define TIPC_MOD_VER "2.0.0" |
64 | 60 | ||
61 | struct tipc_msg; /* msg.h */ | ||
62 | struct print_buf; /* dbg.h */ | ||
63 | |||
65 | /* | 64 | /* |
66 | * TIPC sanity test macros | 65 | * TIPC sanity test macros |
67 | */ | 66 | */ |
@@ -174,6 +173,13 @@ void tipc_dump_dbg(struct print_buf *, const char *fmt, ...); | |||
174 | #define ELINKCONG EAGAIN /* link congestion <=> resource unavailable */ | 173 | #define ELINKCONG EAGAIN /* link congestion <=> resource unavailable */ |
175 | 174 | ||
176 | /* | 175 | /* |
176 | * TIPC operating mode routines | ||
177 | */ | ||
178 | #define TIPC_NOT_RUNNING 0 | ||
179 | #define TIPC_NODE_MODE 1 | ||
180 | #define TIPC_NET_MODE 2 | ||
181 | |||
182 | /* | ||
177 | * Global configuration variables | 183 | * Global configuration variables |
178 | */ | 184 | */ |
179 | 185 | ||
diff --git a/net/tipc/eth_media.c b/net/tipc/eth_media.c index 6e988ba485fd..ee683cc8f4b1 100644 --- a/net/tipc/eth_media.c +++ b/net/tipc/eth_media.c | |||
@@ -34,13 +34,13 @@ | |||
34 | * POSSIBILITY OF SUCH DAMAGE. | 34 | * POSSIBILITY OF SUCH DAMAGE. |
35 | */ | 35 | */ |
36 | 36 | ||
37 | #include <net/tipc/tipc.h> | ||
38 | #include <net/tipc/tipc_bearer.h> | ||
39 | #include <net/tipc/tipc_msg.h> | ||
40 | #include <linux/netdevice.h> | 37 | #include <linux/netdevice.h> |
41 | #include <linux/slab.h> | 38 | #include <linux/slab.h> |
42 | #include <net/net_namespace.h> | 39 | #include <net/net_namespace.h> |
43 | 40 | ||
41 | #include "core.h" | ||
42 | #include "bearer.h" | ||
43 | |||
44 | #define MAX_ETH_BEARERS 2 | 44 | #define MAX_ETH_BEARERS 2 |
45 | #define ETH_LINK_PRIORITY TIPC_DEF_LINK_PRI | 45 | #define ETH_LINK_PRIORITY TIPC_DEF_LINK_PRI |
46 | #define ETH_LINK_TOLERANCE TIPC_DEF_LINK_TOL | 46 | #define ETH_LINK_TOLERANCE TIPC_DEF_LINK_TOL |
diff --git a/net/tipc/msg.h b/net/tipc/msg.h index 031aad18efce..aee53864d7a0 100644 --- a/net/tipc/msg.h +++ b/net/tipc/msg.h | |||
@@ -37,10 +37,51 @@ | |||
37 | #ifndef _TIPC_MSG_H | 37 | #ifndef _TIPC_MSG_H |
38 | #define _TIPC_MSG_H | 38 | #define _TIPC_MSG_H |
39 | 39 | ||
40 | #include "core.h" | 40 | #include "bearer.h" |
41 | 41 | ||
42 | #define TIPC_VERSION 2 | 42 | #define TIPC_VERSION 2 |
43 | 43 | ||
44 | /* | ||
45 | * TIPC user data message header format, version 2: | ||
46 | * | ||
47 | * | ||
48 | * 1 0 9 8 7 6 5 4|3 2 1 0 9 8 7 6|5 4 3 2 1 0 9 8|7 6 5 4 3 2 1 0 | ||
49 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
50 | * w0:|vers | user |hdr sz |n|d|s|-| message size | | ||
51 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
52 | * w1:|mstyp| error |rer cnt|lsc|opt p| broadcast ack no | | ||
53 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
54 | * w2:| link level ack no | broadcast/link level seq no | | ||
55 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
56 | * w3:| previous node | | ||
57 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
58 | * w4:| originating port | | ||
59 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
60 | * w5:| destination port | | ||
61 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
62 | * w6:| originating node | | ||
63 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
64 | * w7:| destination node | | ||
65 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
66 | * w8:| name type / transport sequence number | | ||
67 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
68 | * w9:| name instance/multicast lower bound | | ||
69 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
70 | * wA:| multicast upper bound | | ||
71 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
72 | * / / | ||
73 | * \ options \ | ||
74 | * / / | ||
75 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
76 | * | ||
77 | */ | ||
78 | |||
79 | #define TIPC_CONN_MSG 0 | ||
80 | #define TIPC_MCAST_MSG 1 | ||
81 | #define TIPC_NAMED_MSG 2 | ||
82 | #define TIPC_DIRECT_MSG 3 | ||
83 | |||
84 | |||
44 | #define SHORT_H_SIZE 24 /* Connected, in-cluster messages */ | 85 | #define SHORT_H_SIZE 24 /* Connected, in-cluster messages */ |
45 | #define DIR_MSG_H_SIZE 32 /* Directly addressed messages */ | 86 | #define DIR_MSG_H_SIZE 32 /* Directly addressed messages */ |
46 | #define LONG_H_SIZE 40 /* Named messages */ | 87 | #define LONG_H_SIZE 40 /* Named messages */ |
@@ -52,20 +93,26 @@ | |||
52 | #define MAX_MSG_SIZE (MAX_H_SIZE + TIPC_MAX_USER_MSG_SIZE) | 93 | #define MAX_MSG_SIZE (MAX_H_SIZE + TIPC_MAX_USER_MSG_SIZE) |
53 | 94 | ||
54 | 95 | ||
55 | /* | 96 | struct tipc_msg { |
56 | TIPC user data message header format, version 2 | 97 | __be32 hdr[15]; |
98 | }; | ||
57 | 99 | ||
58 | - Fundamental definitions available to privileged TIPC users | ||
59 | are located in tipc_msg.h. | ||
60 | - Remaining definitions available to TIPC internal users appear below. | ||
61 | */ | ||
62 | 100 | ||
101 | static inline u32 msg_word(struct tipc_msg *m, u32 pos) | ||
102 | { | ||
103 | return ntohl(m->hdr[pos]); | ||
104 | } | ||
63 | 105 | ||
64 | static inline void msg_set_word(struct tipc_msg *m, u32 w, u32 val) | 106 | static inline void msg_set_word(struct tipc_msg *m, u32 w, u32 val) |
65 | { | 107 | { |
66 | m->hdr[w] = htonl(val); | 108 | m->hdr[w] = htonl(val); |
67 | } | 109 | } |
68 | 110 | ||
111 | static inline u32 msg_bits(struct tipc_msg *m, u32 w, u32 pos, u32 mask) | ||
112 | { | ||
113 | return (msg_word(m, w) >> pos) & mask; | ||
114 | } | ||
115 | |||
69 | static inline void msg_set_bits(struct tipc_msg *m, u32 w, | 116 | static inline void msg_set_bits(struct tipc_msg *m, u32 w, |
70 | u32 pos, u32 mask, u32 val) | 117 | u32 pos, u32 mask, u32 val) |
71 | { | 118 | { |
@@ -112,16 +159,36 @@ static inline void msg_set_user(struct tipc_msg *m, u32 n) | |||
112 | msg_set_bits(m, 0, 25, 0xf, n); | 159 | msg_set_bits(m, 0, 25, 0xf, n); |
113 | } | 160 | } |
114 | 161 | ||
162 | static inline u32 msg_importance(struct tipc_msg *m) | ||
163 | { | ||
164 | return msg_bits(m, 0, 25, 0xf); | ||
165 | } | ||
166 | |||
115 | static inline void msg_set_importance(struct tipc_msg *m, u32 i) | 167 | static inline void msg_set_importance(struct tipc_msg *m, u32 i) |
116 | { | 168 | { |
117 | msg_set_user(m, i); | 169 | msg_set_user(m, i); |
118 | } | 170 | } |
119 | 171 | ||
172 | static inline u32 msg_hdr_sz(struct tipc_msg *m) | ||
173 | { | ||
174 | return msg_bits(m, 0, 21, 0xf) << 2; | ||
175 | } | ||
176 | |||
120 | static inline void msg_set_hdr_sz(struct tipc_msg *m,u32 n) | 177 | static inline void msg_set_hdr_sz(struct tipc_msg *m,u32 n) |
121 | { | 178 | { |
122 | msg_set_bits(m, 0, 21, 0xf, n>>2); | 179 | msg_set_bits(m, 0, 21, 0xf, n>>2); |
123 | } | 180 | } |
124 | 181 | ||
182 | static inline u32 msg_size(struct tipc_msg *m) | ||
183 | { | ||
184 | return msg_bits(m, 0, 0, 0x1ffff); | ||
185 | } | ||
186 | |||
187 | static inline u32 msg_data_sz(struct tipc_msg *m) | ||
188 | { | ||
189 | return msg_size(m) - msg_hdr_sz(m); | ||
190 | } | ||
191 | |||
125 | static inline int msg_non_seq(struct tipc_msg *m) | 192 | static inline int msg_non_seq(struct tipc_msg *m) |
126 | { | 193 | { |
127 | return msg_bits(m, 0, 20, 1); | 194 | return msg_bits(m, 0, 20, 1); |
@@ -162,11 +229,36 @@ static inline void msg_set_size(struct tipc_msg *m, u32 sz) | |||
162 | * Word 1 | 229 | * Word 1 |
163 | */ | 230 | */ |
164 | 231 | ||
232 | static inline u32 msg_type(struct tipc_msg *m) | ||
233 | { | ||
234 | return msg_bits(m, 1, 29, 0x7); | ||
235 | } | ||
236 | |||
165 | static inline void msg_set_type(struct tipc_msg *m, u32 n) | 237 | static inline void msg_set_type(struct tipc_msg *m, u32 n) |
166 | { | 238 | { |
167 | msg_set_bits(m, 1, 29, 0x7, n); | 239 | msg_set_bits(m, 1, 29, 0x7, n); |
168 | } | 240 | } |
169 | 241 | ||
242 | static inline u32 msg_named(struct tipc_msg *m) | ||
243 | { | ||
244 | return msg_type(m) == TIPC_NAMED_MSG; | ||
245 | } | ||
246 | |||
247 | static inline u32 msg_mcast(struct tipc_msg *m) | ||
248 | { | ||
249 | return msg_type(m) == TIPC_MCAST_MSG; | ||
250 | } | ||
251 | |||
252 | static inline u32 msg_connected(struct tipc_msg *m) | ||
253 | { | ||
254 | return msg_type(m) == TIPC_CONN_MSG; | ||
255 | } | ||
256 | |||
257 | static inline u32 msg_errcode(struct tipc_msg *m) | ||
258 | { | ||
259 | return msg_bits(m, 1, 25, 0xf); | ||
260 | } | ||
261 | |||
170 | static inline void msg_set_errcode(struct tipc_msg *m, u32 err) | 262 | static inline void msg_set_errcode(struct tipc_msg *m, u32 err) |
171 | { | 263 | { |
172 | msg_set_bits(m, 1, 25, 0xf, err); | 264 | msg_set_bits(m, 1, 25, 0xf, err); |
@@ -257,31 +349,68 @@ static inline void msg_set_destnode_cache(struct tipc_msg *m, u32 dnode) | |||
257 | */ | 349 | */ |
258 | 350 | ||
259 | 351 | ||
352 | static inline u32 msg_prevnode(struct tipc_msg *m) | ||
353 | { | ||
354 | return msg_word(m, 3); | ||
355 | } | ||
356 | |||
260 | static inline void msg_set_prevnode(struct tipc_msg *m, u32 a) | 357 | static inline void msg_set_prevnode(struct tipc_msg *m, u32 a) |
261 | { | 358 | { |
262 | msg_set_word(m, 3, a); | 359 | msg_set_word(m, 3, a); |
263 | } | 360 | } |
264 | 361 | ||
362 | static inline u32 msg_origport(struct tipc_msg *m) | ||
363 | { | ||
364 | return msg_word(m, 4); | ||
365 | } | ||
366 | |||
265 | static inline void msg_set_origport(struct tipc_msg *m, u32 p) | 367 | static inline void msg_set_origport(struct tipc_msg *m, u32 p) |
266 | { | 368 | { |
267 | msg_set_word(m, 4, p); | 369 | msg_set_word(m, 4, p); |
268 | } | 370 | } |
269 | 371 | ||
372 | static inline u32 msg_destport(struct tipc_msg *m) | ||
373 | { | ||
374 | return msg_word(m, 5); | ||
375 | } | ||
376 | |||
270 | static inline void msg_set_destport(struct tipc_msg *m, u32 p) | 377 | static inline void msg_set_destport(struct tipc_msg *m, u32 p) |
271 | { | 378 | { |
272 | msg_set_word(m, 5, p); | 379 | msg_set_word(m, 5, p); |
273 | } | 380 | } |
274 | 381 | ||
382 | static inline u32 msg_mc_netid(struct tipc_msg *m) | ||
383 | { | ||
384 | return msg_word(m, 5); | ||
385 | } | ||
386 | |||
275 | static inline void msg_set_mc_netid(struct tipc_msg *m, u32 p) | 387 | static inline void msg_set_mc_netid(struct tipc_msg *m, u32 p) |
276 | { | 388 | { |
277 | msg_set_word(m, 5, p); | 389 | msg_set_word(m, 5, p); |
278 | } | 390 | } |
279 | 391 | ||
392 | static inline int msg_short(struct tipc_msg *m) | ||
393 | { | ||
394 | return msg_hdr_sz(m) == 24; | ||
395 | } | ||
396 | |||
397 | static inline u32 msg_orignode(struct tipc_msg *m) | ||
398 | { | ||
399 | if (likely(msg_short(m))) | ||
400 | return msg_prevnode(m); | ||
401 | return msg_word(m, 6); | ||
402 | } | ||
403 | |||
280 | static inline void msg_set_orignode(struct tipc_msg *m, u32 a) | 404 | static inline void msg_set_orignode(struct tipc_msg *m, u32 a) |
281 | { | 405 | { |
282 | msg_set_word(m, 6, a); | 406 | msg_set_word(m, 6, a); |
283 | } | 407 | } |
284 | 408 | ||
409 | static inline u32 msg_destnode(struct tipc_msg *m) | ||
410 | { | ||
411 | return msg_word(m, 7); | ||
412 | } | ||
413 | |||
285 | static inline void msg_set_destnode(struct tipc_msg *m, u32 a) | 414 | static inline void msg_set_destnode(struct tipc_msg *m, u32 a) |
286 | { | 415 | { |
287 | msg_set_word(m, 7, a); | 416 | msg_set_word(m, 7, a); |
@@ -299,6 +428,11 @@ static inline u32 msg_routed(struct tipc_msg *m) | |||
299 | return(msg_destnode(m) ^ msg_orignode(m)) >> 11; | 428 | return(msg_destnode(m) ^ msg_orignode(m)) >> 11; |
300 | } | 429 | } |
301 | 430 | ||
431 | static inline u32 msg_nametype(struct tipc_msg *m) | ||
432 | { | ||
433 | return msg_word(m, 8); | ||
434 | } | ||
435 | |||
302 | static inline void msg_set_nametype(struct tipc_msg *m, u32 n) | 436 | static inline void msg_set_nametype(struct tipc_msg *m, u32 n) |
303 | { | 437 | { |
304 | msg_set_word(m, 8, n); | 438 | msg_set_word(m, 8, n); |
@@ -324,6 +458,16 @@ static inline void msg_set_transp_seqno(struct tipc_msg *m, u32 n) | |||
324 | msg_set_word(m, 8, n); | 458 | msg_set_word(m, 8, n); |
325 | } | 459 | } |
326 | 460 | ||
461 | static inline u32 msg_nameinst(struct tipc_msg *m) | ||
462 | { | ||
463 | return msg_word(m, 9); | ||
464 | } | ||
465 | |||
466 | static inline u32 msg_namelower(struct tipc_msg *m) | ||
467 | { | ||
468 | return msg_nameinst(m); | ||
469 | } | ||
470 | |||
327 | static inline void msg_set_namelower(struct tipc_msg *m, u32 n) | 471 | static inline void msg_set_namelower(struct tipc_msg *m, u32 n) |
328 | { | 472 | { |
329 | msg_set_word(m, 9, n); | 473 | msg_set_word(m, 9, n); |
@@ -334,11 +478,21 @@ static inline void msg_set_nameinst(struct tipc_msg *m, u32 n) | |||
334 | msg_set_namelower(m, n); | 478 | msg_set_namelower(m, n); |
335 | } | 479 | } |
336 | 480 | ||
481 | static inline u32 msg_nameupper(struct tipc_msg *m) | ||
482 | { | ||
483 | return msg_word(m, 10); | ||
484 | } | ||
485 | |||
337 | static inline void msg_set_nameupper(struct tipc_msg *m, u32 n) | 486 | static inline void msg_set_nameupper(struct tipc_msg *m, u32 n) |
338 | { | 487 | { |
339 | msg_set_word(m, 10, n); | 488 | msg_set_word(m, 10, n); |
340 | } | 489 | } |
341 | 490 | ||
491 | static inline unchar *msg_data(struct tipc_msg *m) | ||
492 | { | ||
493 | return ((unchar *)m) + msg_hdr_sz(m); | ||
494 | } | ||
495 | |||
342 | static inline struct tipc_msg *msg_get_wrapped(struct tipc_msg *m) | 496 | static inline struct tipc_msg *msg_get_wrapped(struct tipc_msg *m) |
343 | { | 497 | { |
344 | return (struct tipc_msg *)msg_data(m); | 498 | return (struct tipc_msg *)msg_data(m); |
diff --git a/net/tipc/port.h b/net/tipc/port.h index 73bbf442b346..8b9d87a3efae 100644 --- a/net/tipc/port.h +++ b/net/tipc/port.h | |||
@@ -44,6 +44,39 @@ | |||
44 | #include "dbg.h" | 44 | #include "dbg.h" |
45 | #include "node_subscr.h" | 45 | #include "node_subscr.h" |
46 | 46 | ||
47 | #define TIPC_FLOW_CONTROL_WIN 512 | ||
48 | |||
49 | typedef void (*tipc_msg_err_event) (void *usr_handle, u32 portref, | ||
50 | struct sk_buff **buf, unsigned char const *data, | ||
51 | unsigned int size, int reason, | ||
52 | struct tipc_portid const *attmpt_destid); | ||
53 | |||
54 | typedef void (*tipc_named_msg_err_event) (void *usr_handle, u32 portref, | ||
55 | struct sk_buff **buf, unsigned char const *data, | ||
56 | unsigned int size, int reason, | ||
57 | struct tipc_name_seq const *attmpt_dest); | ||
58 | |||
59 | typedef void (*tipc_conn_shutdown_event) (void *usr_handle, u32 portref, | ||
60 | struct sk_buff **buf, unsigned char const *data, | ||
61 | unsigned int size, int reason); | ||
62 | |||
63 | typedef void (*tipc_msg_event) (void *usr_handle, u32 portref, | ||
64 | struct sk_buff **buf, unsigned char const *data, | ||
65 | unsigned int size, unsigned int importance, | ||
66 | struct tipc_portid const *origin); | ||
67 | |||
68 | typedef void (*tipc_named_msg_event) (void *usr_handle, u32 portref, | ||
69 | struct sk_buff **buf, unsigned char const *data, | ||
70 | unsigned int size, unsigned int importance, | ||
71 | struct tipc_portid const *orig, | ||
72 | struct tipc_name_seq const *dest); | ||
73 | |||
74 | typedef void (*tipc_conn_msg_event) (void *usr_handle, u32 portref, | ||
75 | struct sk_buff **buf, unsigned char const *data, | ||
76 | unsigned int size); | ||
77 | |||
78 | typedef void (*tipc_continue_event) (void *usr_handle, u32 portref); | ||
79 | |||
47 | /** | 80 | /** |
48 | * struct user_port - TIPC user port (used with native API) | 81 | * struct user_port - TIPC user port (used with native API) |
49 | * @user_ref: id of user who created user port | 82 | * @user_ref: id of user who created user port |
@@ -68,6 +101,34 @@ struct user_port { | |||
68 | }; | 101 | }; |
69 | 102 | ||
70 | /** | 103 | /** |
104 | * struct tipc_port - TIPC port info available to socket API | ||
105 | * @usr_handle: pointer to additional user-defined information about port | ||
106 | * @lock: pointer to spinlock for controlling access to port | ||
107 | * @connected: non-zero if port is currently connected to a peer port | ||
108 | * @conn_type: TIPC type used when connection was established | ||
109 | * @conn_instance: TIPC instance used when connection was established | ||
110 | * @conn_unacked: number of unacknowledged messages received from peer port | ||
111 | * @published: non-zero if port has one or more associated names | ||
112 | * @congested: non-zero if cannot send because of link or port congestion | ||
113 | * @max_pkt: maximum packet size "hint" used when building messages sent by port | ||
114 | * @ref: unique reference to port in TIPC object registry | ||
115 | * @phdr: preformatted message header used when sending messages | ||
116 | */ | ||
117 | struct tipc_port { | ||
118 | void *usr_handle; | ||
119 | spinlock_t *lock; | ||
120 | int connected; | ||
121 | u32 conn_type; | ||
122 | u32 conn_instance; | ||
123 | u32 conn_unacked; | ||
124 | int published; | ||
125 | u32 congested; | ||
126 | u32 max_pkt; | ||
127 | u32 ref; | ||
128 | struct tipc_msg phdr; | ||
129 | }; | ||
130 | |||
131 | /** | ||
71 | * struct port - TIPC port structure | 132 | * struct port - TIPC port structure |
72 | * @publ: TIPC port info available to privileged users | 133 | * @publ: TIPC port info available to privileged users |
73 | * @port_list: adjacent ports in TIPC's global list of ports | 134 | * @port_list: adjacent ports in TIPC's global list of ports |
@@ -109,6 +170,76 @@ struct port { | |||
109 | extern spinlock_t tipc_port_list_lock; | 170 | extern spinlock_t tipc_port_list_lock; |
110 | struct port_list; | 171 | struct port_list; |
111 | 172 | ||
173 | /* | ||
174 | * TIPC port manipulation routines | ||
175 | */ | ||
176 | struct tipc_port *tipc_createport_raw(void *usr_handle, | ||
177 | u32 (*dispatcher)(struct tipc_port *, struct sk_buff *), | ||
178 | void (*wakeup)(struct tipc_port *), const u32 importance); | ||
179 | |||
180 | int tipc_reject_msg(struct sk_buff *buf, u32 err); | ||
181 | |||
182 | int tipc_send_buf_fast(struct sk_buff *buf, u32 destnode); | ||
183 | |||
184 | void tipc_acknowledge(u32 port_ref, u32 ack); | ||
185 | |||
186 | int tipc_createport(unsigned int tipc_user, void *usr_handle, | ||
187 | unsigned int importance, tipc_msg_err_event error_cb, | ||
188 | tipc_named_msg_err_event named_error_cb, | ||
189 | tipc_conn_shutdown_event conn_error_cb, tipc_msg_event msg_cb, | ||
190 | tipc_named_msg_event named_msg_cb, | ||
191 | tipc_conn_msg_event conn_msg_cb, | ||
192 | tipc_continue_event continue_event_cb, u32 *portref); | ||
193 | |||
194 | int tipc_deleteport(u32 portref); | ||
195 | |||
196 | int tipc_ownidentity(u32 portref, struct tipc_portid *port); | ||
197 | |||
198 | int tipc_portimportance(u32 portref, unsigned int *importance); | ||
199 | int tipc_set_portimportance(u32 portref, unsigned int importance); | ||
200 | |||
201 | int tipc_portunreliable(u32 portref, unsigned int *isunreliable); | ||
202 | int tipc_set_portunreliable(u32 portref, unsigned int isunreliable); | ||
203 | |||
204 | int tipc_portunreturnable(u32 portref, unsigned int *isunreturnable); | ||
205 | int tipc_set_portunreturnable(u32 portref, unsigned int isunreturnable); | ||
206 | |||
207 | int tipc_publish(u32 portref, unsigned int scope, | ||
208 | struct tipc_name_seq const *name_seq); | ||
209 | int tipc_withdraw(u32 portref, unsigned int scope, | ||
210 | struct tipc_name_seq const *name_seq); | ||
211 | |||
212 | int tipc_connect2port(u32 portref, struct tipc_portid const *port); | ||
213 | |||
214 | int tipc_disconnect(u32 portref); | ||
215 | |||
216 | int tipc_shutdown(u32 ref); | ||
217 | |||
218 | |||
219 | /* | ||
220 | * The following routines require that the port be locked on entry | ||
221 | */ | ||
222 | int tipc_disconnect_port(struct tipc_port *tp_ptr); | ||
223 | |||
224 | /* | ||
225 | * TIPC messaging routines | ||
226 | */ | ||
227 | #define TIPC_PORT_IMPORTANCE 100 /* send using current port setting */ | ||
228 | |||
229 | int tipc_send(u32 portref, unsigned int num_sect, struct iovec const *msg_sect); | ||
230 | |||
231 | int tipc_send2name(u32 portref, struct tipc_name const *name, u32 domain, | ||
232 | unsigned int num_sect, struct iovec const *msg_sect); | ||
233 | |||
234 | int tipc_send2port(u32 portref, struct tipc_portid const *dest, | ||
235 | unsigned int num_sect, struct iovec const *msg_sect); | ||
236 | |||
237 | int tipc_send_buf2port(u32 portref, struct tipc_portid const *dest, | ||
238 | struct sk_buff *buf, unsigned int dsz); | ||
239 | |||
240 | int tipc_multicast(u32 portref, struct tipc_name_seq const *seq, u32 domain, | ||
241 | unsigned int section_count, struct iovec const *msg); | ||
242 | |||
112 | int tipc_port_reject_sections(struct port *p_ptr, struct tipc_msg *hdr, | 243 | int tipc_port_reject_sections(struct port *p_ptr, struct tipc_msg *hdr, |
113 | struct iovec const *msg_sect, u32 num_sect, | 244 | struct iovec const *msg_sect, u32 num_sect, |
114 | int err); | 245 | int err); |
diff --git a/net/tipc/socket.c b/net/tipc/socket.c index e9f0d5004483..23a12e44347f 100644 --- a/net/tipc/socket.c +++ b/net/tipc/socket.c | |||
@@ -49,10 +49,9 @@ | |||
49 | 49 | ||
50 | #include <linux/tipc.h> | 50 | #include <linux/tipc.h> |
51 | #include <linux/tipc_config.h> | 51 | #include <linux/tipc_config.h> |
52 | #include <net/tipc/tipc_msg.h> | ||
53 | #include <net/tipc/tipc_port.h> | ||
54 | 52 | ||
55 | #include "core.h" | 53 | #include "core.h" |
54 | #include "port.h" | ||
56 | 55 | ||
57 | #define SS_LISTENING -1 /* socket is listening */ | 56 | #define SS_LISTENING -1 /* socket is listening */ |
58 | #define SS_READY -2 /* socket is connectionless */ | 57 | #define SS_READY -2 /* socket is connectionless */ |
diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c index 33313961d010..a857e6ea857e 100644 --- a/net/tipc/subscr.c +++ b/net/tipc/subscr.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include "core.h" | 37 | #include "core.h" |
38 | #include "dbg.h" | 38 | #include "dbg.h" |
39 | #include "name_table.h" | 39 | #include "name_table.h" |
40 | #include "user_reg.h" | ||
40 | #include "port.h" | 41 | #include "port.h" |
41 | #include "ref.h" | 42 | #include "ref.h" |
42 | #include "subscr.h" | 43 | #include "subscr.h" |
diff --git a/net/tipc/user_reg.h b/net/tipc/user_reg.h index 81dc12e2882f..a05981fb9176 100644 --- a/net/tipc/user_reg.h +++ b/net/tipc/user_reg.h | |||
@@ -42,6 +42,11 @@ | |||
42 | int tipc_reg_start(void); | 42 | int tipc_reg_start(void); |
43 | void tipc_reg_stop(void); | 43 | void tipc_reg_stop(void); |
44 | 44 | ||
45 | typedef void (*tipc_mode_event)(void *usr_handle, int mode, u32 addr); | ||
46 | |||
47 | int tipc_attach(unsigned int *userref, tipc_mode_event, void *usr_handle); | ||
48 | void tipc_detach(unsigned int userref); | ||
49 | |||
45 | int tipc_reg_add_port(struct user_port *up_ptr); | 50 | int tipc_reg_add_port(struct user_port *up_ptr); |
46 | int tipc_reg_remove_port(struct user_port *up_ptr); | 51 | int tipc_reg_remove_port(struct user_port *up_ptr); |
47 | 52 | ||