aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/tipc
diff options
context:
space:
mode:
Diffstat (limited to 'include/net/tipc')
-rw-r--r--include/net/tipc/tipc.h255
-rw-r--r--include/net/tipc/tipc_bearer.h92
-rw-r--r--include/net/tipc/tipc_msg.h220
-rw-r--r--include/net/tipc/tipc_port.h105
4 files changed, 672 insertions, 0 deletions
diff --git a/include/net/tipc/tipc.h b/include/net/tipc/tipc.h
new file mode 100644
index 000000000000..1d4d8d0701e3
--- /dev/null
+++ b/include/net/tipc/tipc.h
@@ -0,0 +1,255 @@
1/*
2 * include/net/tipc/tipc.h: Main include file for TIPC users
3 *
4 * Copyright (c) 2003-2005, Ericsson Research Canada
5 * Copyright (c) 2005, Wind River Systems
6 * Copyright (c) 2005-2006, Ericsson AB
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 * Redistributions of source code must retain the above copyright notice, this
13 * list of conditions and the following disclaimer.
14 * Redistributions in binary form must reproduce the above copyright notice,
15 * this list of conditions and the following disclaimer in the documentation
16 * and/or other materials provided with the distribution.
17 * Neither the names of the copyright holders nor the names of its
18 * contributors may be used to endorse or promote products derived from this
19 * software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
32 */
33
34#ifndef _NET_TIPC_H_
35#define _NET_TIPC_H_
36
37#ifdef __KERNEL__
38
39#include <linux/tipc.h>
40#include <linux/skbuff.h>
41
42/*
43 * Native API
44 * ----------
45 */
46
47/*
48 * TIPC operating mode routines
49 */
50
51u32 tipc_get_addr(void);
52
53#define TIPC_NOT_RUNNING 0
54#define TIPC_NODE_MODE 1
55#define TIPC_NET_MODE 2
56
57typedef void (*tipc_mode_event)(void *usr_handle, int mode, u32 addr);
58
59int tipc_attach(unsigned int *userref, tipc_mode_event, void *usr_handle);
60
61void tipc_detach(unsigned int userref);
62
63int tipc_get_mode(void);
64
65/*
66 * TIPC port manipulation routines
67 */
68
69typedef void (*tipc_msg_err_event) (void *usr_handle,
70 u32 portref,
71 struct sk_buff **buf,
72 unsigned char const *data,
73 unsigned int size,
74 int reason,
75 struct tipc_portid const *attmpt_destid);
76
77typedef void (*tipc_named_msg_err_event) (void *usr_handle,
78 u32 portref,
79 struct sk_buff **buf,
80 unsigned char const *data,
81 unsigned int size,
82 int reason,
83 struct tipc_name_seq const *attmpt_dest);
84
85typedef void (*tipc_conn_shutdown_event) (void *usr_handle,
86 u32 portref,
87 struct sk_buff **buf,
88 unsigned char const *data,
89 unsigned int size,
90 int reason);
91
92typedef void (*tipc_msg_event) (void *usr_handle,
93 u32 portref,
94 struct sk_buff **buf,
95 unsigned char const *data,
96 unsigned int size,
97 unsigned int importance,
98 struct tipc_portid const *origin);
99
100typedef void (*tipc_named_msg_event) (void *usr_handle,
101 u32 portref,
102 struct sk_buff **buf,
103 unsigned char const *data,
104 unsigned int size,
105 unsigned int importance,
106 struct tipc_portid const *orig,
107 struct tipc_name_seq const *dest);
108
109typedef void (*tipc_conn_msg_event) (void *usr_handle,
110 u32 portref,
111 struct sk_buff **buf,
112 unsigned char const *data,
113 unsigned int size);
114
115typedef void (*tipc_continue_event) (void *usr_handle,
116 u32 portref);
117
118int tipc_createport(unsigned int tipc_user,
119 void *usr_handle,
120 unsigned int importance,
121 tipc_msg_err_event error_cb,
122 tipc_named_msg_err_event named_error_cb,
123 tipc_conn_shutdown_event conn_error_cb,
124 tipc_msg_event message_cb,
125 tipc_named_msg_event named_message_cb,
126 tipc_conn_msg_event conn_message_cb,
127 tipc_continue_event continue_event_cb,/* May be zero */
128 u32 *portref);
129
130int tipc_deleteport(u32 portref);
131
132int tipc_ownidentity(u32 portref, struct tipc_portid *port);
133
134int tipc_portimportance(u32 portref, unsigned int *importance);
135int tipc_set_portimportance(u32 portref, unsigned int importance);
136
137int tipc_portunreliable(u32 portref, unsigned int *isunreliable);
138int tipc_set_portunreliable(u32 portref, unsigned int isunreliable);
139
140int tipc_portunreturnable(u32 portref, unsigned int *isunreturnable);
141int tipc_set_portunreturnable(u32 portref, unsigned int isunreturnable);
142
143int tipc_publish(u32 portref, unsigned int scope,
144 struct tipc_name_seq const *name_seq);
145int tipc_withdraw(u32 portref, unsigned int scope,
146 struct tipc_name_seq const *name_seq); /* 0: all */
147
148int tipc_connect2port(u32 portref, struct tipc_portid const *port);
149
150int tipc_disconnect(u32 portref);
151
152int tipc_shutdown(u32 ref); /* Sends SHUTDOWN msg */
153
154int tipc_isconnected(u32 portref, int *isconnected);
155
156int tipc_peer(u32 portref, struct tipc_portid *peer);
157
158int tipc_ref_valid(u32 portref);
159
160/*
161 * TIPC messaging routines
162 */
163
164#define TIPC_PORT_IMPORTANCE 100 /* send using current port setting */
165
166
167int tipc_send(u32 portref,
168 unsigned int num_sect,
169 struct iovec const *msg_sect);
170
171int tipc_send_buf(u32 portref,
172 struct sk_buff *buf,
173 unsigned int dsz);
174
175int tipc_send2name(u32 portref,
176 struct tipc_name const *name,
177 u32 domain, /* 0:own zone */
178 unsigned int num_sect,
179 struct iovec const *msg_sect);
180
181int tipc_send_buf2name(u32 portref,
182 struct tipc_name const *name,
183 u32 domain,
184 struct sk_buff *buf,
185 unsigned int dsz);
186
187int tipc_forward2name(u32 portref,
188 struct tipc_name const *name,
189 u32 domain, /*0: own zone */
190 unsigned int section_count,
191 struct iovec const *msg_sect,
192 struct tipc_portid const *origin,
193 unsigned int importance);
194
195int tipc_forward_buf2name(u32 portref,
196 struct tipc_name const *name,
197 u32 domain,
198 struct sk_buff *buf,
199 unsigned int dsz,
200 struct tipc_portid const *orig,
201 unsigned int importance);
202
203int tipc_send2port(u32 portref,
204 struct tipc_portid const *dest,
205 unsigned int num_sect,
206 struct iovec const *msg_sect);
207
208int tipc_send_buf2port(u32 portref,
209 struct tipc_portid const *dest,
210 struct sk_buff *buf,
211 unsigned int dsz);
212
213int tipc_forward2port(u32 portref,
214 struct tipc_portid const *dest,
215 unsigned int num_sect,
216 struct iovec const *msg_sect,
217 struct tipc_portid const *origin,
218 unsigned int importance);
219
220int tipc_forward_buf2port(u32 portref,
221 struct tipc_portid const *dest,
222 struct sk_buff *buf,
223 unsigned int dsz,
224 struct tipc_portid const *orig,
225 unsigned int importance);
226
227int tipc_multicast(u32 portref,
228 struct tipc_name_seq const *seq,
229 u32 domain, /* 0:own zone */
230 unsigned int section_count,
231 struct iovec const *msg);
232
233#if 0
234int tipc_multicast_buf(u32 portref,
235 struct tipc_name_seq const *seq,
236 u32 domain, /* 0:own zone */
237 void *buf,
238 unsigned int size);
239#endif
240
241/*
242 * TIPC subscription routines
243 */
244
245int tipc_ispublished(struct tipc_name const *name);
246
247/*
248 * Get number of available nodes within specified domain (excluding own node)
249 */
250
251unsigned int tipc_available_nodes(const u32 domain);
252
253#endif
254
255#endif
diff --git a/include/net/tipc/tipc_bearer.h b/include/net/tipc/tipc_bearer.h
new file mode 100644
index 000000000000..a3daf697b6b6
--- /dev/null
+++ b/include/net/tipc/tipc_bearer.h
@@ -0,0 +1,92 @@
1/*
2 * include/net/tipc/tipc_bearer.h: Include file for privileged access to TIPC bearers
3 *
4 * Copyright (c) 2003-2005, Ericsson Research Canada
5 * Copyright (c) 2005, Wind River Systems
6 * Copyright (c) 2005-2006, Ericsson AB
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 * Redistributions of source code must retain the above copyright notice, this
13 * list of conditions and the following disclaimer.
14 * Redistributions in binary form must reproduce the above copyright notice,
15 * this list of conditions and the following disclaimer in the documentation
16 * and/or other materials provided with the distribution.
17 * Neither the names of the copyright holders nor the names of its
18 * contributors may be used to endorse or promote products derived from this
19 * software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
32 */
33
34#ifndef _NET_TIPC_BEARER_H_
35#define _NET_TIPC_BEARER_H_
36
37#ifdef __KERNEL__
38
39#include <linux/tipc.h>
40#include <linux/skbuff.h>
41#include <linux/spinlock.h>
42
43/**
44 * struct tipc_bearer - TIPC bearer info available to privileged users
45 * @usr_handle: pointer to additional user-defined information about bearer
46 * @mtu: max packet size bearer can support
47 * @blocked: non-zero if bearer is blocked
48 * @lock: spinlock for controlling access to bearer
49 * @addr: media-specific address associated with bearer
50 * @name: bearer name (format = media:interface)
51 *
52 * Note: TIPC initializes "name" and "lock" fields; user is responsible for
53 * initialization all other fields when a bearer is enabled.
54 */
55
56struct tipc_bearer {
57 void *usr_handle;
58 u32 mtu;
59 int blocked;
60 spinlock_t lock;
61 struct tipc_media_addr addr;
62 char name[TIPC_MAX_BEARER_NAME];
63};
64
65
66int tipc_register_media(u32 media_type,
67 char *media_name,
68 int (*enable)(struct tipc_bearer *),
69 void (*disable)(struct tipc_bearer *),
70 int (*send_msg)(struct sk_buff *,
71 struct tipc_bearer *,
72 struct tipc_media_addr *),
73 char *(*addr2str)(struct tipc_media_addr *a,
74 char *str_buf,
75 int str_size),
76 struct tipc_media_addr *bcast_addr,
77 const u32 bearer_priority,
78 const u32 link_tolerance, /* [ms] */
79 const u32 send_window_limit);
80
81void tipc_recv_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr);
82
83int tipc_block_bearer(const char *name);
84void tipc_continue(struct tipc_bearer *tb_ptr);
85
86int tipc_enable_bearer(const char *bearer_name, u32 bcast_scope, u32 priority);
87int tipc_disable_bearer(const char *name);
88
89
90#endif
91
92#endif
diff --git a/include/net/tipc/tipc_msg.h b/include/net/tipc/tipc_msg.h
new file mode 100644
index 000000000000..78513f5236bb
--- /dev/null
+++ b/include/net/tipc/tipc_msg.h
@@ -0,0 +1,220 @@
1/*
2 * include/net/tipc/tipc_msg.h: Include file for privileged access to TIPC message headers
3 *
4 * Copyright (c) 2003-2005, Ericsson Research Canada
5 * Copyright (c) 2005, Wind River Systems
6 * Copyright (c) 2005-2006, Ericsson AB
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 * Redistributions of source code must retain the above copyright notice, this
13 * list of conditions and the following disclaimer.
14 * Redistributions in binary form must reproduce the above copyright notice,
15 * this list of conditions and the following disclaimer in the documentation
16 * and/or other materials provided with the distribution.
17 * Neither the names of the copyright holders nor the names of its
18 * contributors may be used to endorse or promote products derived from this
19 * software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
32 */
33
34#ifndef _NET_TIPC_MSG_H_
35#define _NET_TIPC_MSG_H_
36
37#ifdef __KERNEL__
38
39struct tipc_msg {
40 u32 hdr[15];
41};
42
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
85static inline u32 msg_word(struct tipc_msg *m, u32 pos)
86{
87 return ntohl(m->hdr[pos]);
88}
89
90static inline u32 msg_bits(struct tipc_msg *m, u32 w, u32 pos, u32 mask)
91{
92 return (msg_word(m, w) >> pos) & mask;
93}
94
95static inline u32 msg_importance(struct tipc_msg *m)
96{
97 return msg_bits(m, 0, 25, 0xf);
98}
99
100static inline u32 msg_hdr_sz(struct tipc_msg *m)
101{
102 return msg_bits(m, 0, 21, 0xf) << 2;
103}
104
105static inline int msg_short(struct tipc_msg *m)
106{
107 return (msg_hdr_sz(m) == 24);
108}
109
110static inline u32 msg_size(struct tipc_msg *m)
111{
112 return msg_bits(m, 0, 0, 0x1ffff);
113}
114
115static inline u32 msg_data_sz(struct tipc_msg *m)
116{
117 return (msg_size(m) - msg_hdr_sz(m));
118}
119
120static inline unchar *msg_data(struct tipc_msg *m)
121{
122 return ((unchar *)m) + msg_hdr_sz(m);
123}
124
125static inline u32 msg_type(struct tipc_msg *m)
126{
127 return msg_bits(m, 1, 29, 0x7);
128}
129
130static inline u32 msg_direct(struct tipc_msg *m)
131{
132 return (msg_type(m) == TIPC_DIRECT_MSG);
133}
134
135static inline u32 msg_named(struct tipc_msg *m)
136{
137 return (msg_type(m) == TIPC_NAMED_MSG);
138}
139
140static inline u32 msg_mcast(struct tipc_msg *m)
141{
142 return (msg_type(m) == TIPC_MCAST_MSG);
143}
144
145static inline u32 msg_connected(struct tipc_msg *m)
146{
147 return (msg_type(m) == TIPC_CONN_MSG);
148}
149
150static inline u32 msg_errcode(struct tipc_msg *m)
151{
152 return msg_bits(m, 1, 25, 0xf);
153}
154
155static inline u32 msg_prevnode(struct tipc_msg *m)
156{
157 return msg_word(m, 3);
158}
159
160static inline u32 msg_origport(struct tipc_msg *m)
161{
162 return msg_word(m, 4);
163}
164
165static inline u32 msg_destport(struct tipc_msg *m)
166{
167 return msg_word(m, 5);
168}
169
170static inline u32 msg_mc_netid(struct tipc_msg *m)
171{
172 return msg_word(m, 5);
173}
174
175static inline u32 msg_orignode(struct tipc_msg *m)
176{
177 if (likely(msg_short(m)))
178 return msg_prevnode(m);
179 return msg_word(m, 6);
180}
181
182static inline u32 msg_destnode(struct tipc_msg *m)
183{
184 return msg_word(m, 7);
185}
186
187static inline u32 msg_nametype(struct tipc_msg *m)
188{
189 return msg_word(m, 8);
190}
191
192static inline u32 msg_nameinst(struct tipc_msg *m)
193{
194 return msg_word(m, 9);
195}
196
197static inline u32 msg_namelower(struct tipc_msg *m)
198{
199 return msg_nameinst(m);
200}
201
202static inline u32 msg_nameupper(struct tipc_msg *m)
203{
204 return msg_word(m, 10);
205}
206
207static inline char *msg_options(struct tipc_msg *m, u32 *len)
208{
209 u32 pos = msg_bits(m, 1, 16, 0x7);
210
211 if (!pos)
212 return 0;
213 pos = (pos * 4) + 28;
214 *len = msg_hdr_sz(m) - pos;
215 return (char *)&m->hdr[pos/4];
216}
217
218#endif
219
220#endif
diff --git a/include/net/tipc/tipc_port.h b/include/net/tipc/tipc_port.h
new file mode 100644
index 000000000000..ec0f0de7f0e2
--- /dev/null
+++ b/include/net/tipc/tipc_port.h
@@ -0,0 +1,105 @@
1/*
2 * include/net/tipc/tipc_port.h: Include file for privileged access to TIPC ports
3 *
4 * Copyright (c) 2003-2005, Ericsson Research Canada
5 * Copyright (c) 2005, Wind River Systems
6 * Copyright (c) 2005-2006, Ericsson AB
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 * Redistributions of source code must retain the above copyright notice, this
13 * list of conditions and the following disclaimer.
14 * Redistributions in binary form must reproduce the above copyright notice,
15 * this list of conditions and the following disclaimer in the documentation
16 * and/or other materials provided with the distribution.
17 * Neither the names of the copyright holders nor the names of its
18 * contributors may be used to endorse or promote products derived from this
19 * software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
32 */
33
34#ifndef _NET_TIPC_PORT_H_
35#define _NET_TIPC_PORT_H_
36
37#ifdef __KERNEL__
38
39#include <linux/tipc.h>
40#include <linux/skbuff.h>
41#include <net/tipc/tipc_msg.h>
42
43#define TIPC_FLOW_CONTROL_WIN 512
44
45/**
46 * struct tipc_port - native TIPC port info available to privileged users
47 * @usr_handle: pointer to additional user-defined information about port
48 * @lock: pointer to spinlock for controlling access to port
49 * @connected: non-zero if port is currently connected to a peer port
50 * @conn_type: TIPC type used when connection was established
51 * @conn_instance: TIPC instance used when connection was established
52 * @conn_unacked: number of unacknowledged messages received from peer port
53 * @published: non-zero if port has one or more associated names
54 * @congested: non-zero if cannot send because of link or port congestion
55 * @ref: unique reference to port in TIPC object registry
56 * @phdr: preformatted message header used when sending messages
57 */
58
59struct tipc_port {
60 void *usr_handle;
61 spinlock_t *lock;
62 int connected;
63 u32 conn_type;
64 u32 conn_instance;
65 u32 conn_unacked;
66 int published;
67 u32 congested;
68 u32 ref;
69 struct tipc_msg phdr;
70};
71
72
73/**
74 * tipc_createport_raw - create a native TIPC port and return it's reference
75 *
76 * Note: 'dispatcher' and 'wakeup' deliver a locked port.
77 */
78
79u32 tipc_createport_raw(void *usr_handle,
80 u32 (*dispatcher)(struct tipc_port *, struct sk_buff *),
81 void (*wakeup)(struct tipc_port *),
82 const u32 importance);
83
84/*
85 * tipc_set_msg_option(): port must be locked.
86 */
87int tipc_set_msg_option(struct tipc_port *tp_ptr,
88 const char *opt,
89 const u32 len);
90
91int tipc_reject_msg(struct sk_buff *buf, u32 err);
92
93int tipc_send_buf_fast(struct sk_buff *buf, u32 destnode);
94
95void tipc_acknowledge(u32 port_ref,u32 ack);
96
97struct tipc_port *tipc_get_port(const u32 ref);
98
99void *tipc_get_handle(const u32 ref);
100
101
102#endif
103
104#endif
105