b763d556355d992c5cb1234ed28dbb15ba3f0eba
[linux-3.10.git] / include / net / tipc / tipc.h
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  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  * 3. Neither the names of the copyright holders nor the names of its
18  *    contributors may be used to endorse or promote products derived from
19  *    this software without specific prior written permission.
20  *
21  * Alternatively, this software may be distributed under the terms of the
22  * GNU General Public License ("GPL") version 2 as published by the Free
23  * Software Foundation.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
29  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35  * POSSIBILITY OF SUCH DAMAGE.
36  */
37
38 #ifndef _NET_TIPC_H_
39 #define _NET_TIPC_H_
40
41 #ifdef __KERNEL__
42
43 #include <linux/tipc.h>
44 #include <linux/skbuff.h>
45
46 /* 
47  * Native API
48  * ----------
49  */
50
51 /*
52  * TIPC operating mode routines
53  */
54
55 u32 tipc_get_addr(void);
56
57 #define TIPC_NOT_RUNNING  0
58 #define TIPC_NODE_MODE    1
59 #define TIPC_NET_MODE     2
60
61 typedef void (*tipc_mode_event)(void *usr_handle, int mode, u32 addr);
62
63 int tipc_attach(unsigned int *userref, tipc_mode_event, void *usr_handle);
64
65 void tipc_detach(unsigned int userref);
66
67 int tipc_get_mode(void);
68
69 /*
70  * TIPC port manipulation routines
71  */
72
73 typedef void (*tipc_msg_err_event) (void *usr_handle,
74                                     u32 portref,
75                                     struct sk_buff **buf,
76                                     unsigned char const *data,
77                                     unsigned int size,
78                                     int reason, 
79                                     struct tipc_portid const *attmpt_destid);
80
81 typedef void (*tipc_named_msg_err_event) (void *usr_handle,
82                                           u32 portref,
83                                           struct sk_buff **buf,
84                                           unsigned char const *data,
85                                           unsigned int size,
86                                           int reason, 
87                                           struct tipc_name_seq const *attmpt_dest);
88
89 typedef void (*tipc_conn_shutdown_event) (void *usr_handle,
90                                           u32 portref,
91                                           struct sk_buff **buf,
92                                           unsigned char const *data,
93                                           unsigned int size,
94                                           int reason);
95
96 typedef void (*tipc_msg_event) (void *usr_handle,
97                                 u32 portref,
98                                 struct sk_buff **buf,
99                                 unsigned char const *data,
100                                 unsigned int size,
101                                 unsigned int importance, 
102                                 struct tipc_portid const *origin);
103
104 typedef void (*tipc_named_msg_event) (void *usr_handle,
105                                       u32 portref,
106                                       struct sk_buff **buf,
107                                       unsigned char const *data,
108                                       unsigned int size,
109                                       unsigned int importance, 
110                                       struct tipc_portid const *orig,
111                                       struct tipc_name_seq const *dest);
112
113 typedef void (*tipc_conn_msg_event) (void *usr_handle,
114                                      u32 portref,
115                                      struct sk_buff **buf,
116                                      unsigned char const *data,
117                                      unsigned int size);
118
119 typedef void (*tipc_continue_event) (void *usr_handle, 
120                                      u32 portref);
121
122 int tipc_createport(unsigned int tipc_user, 
123                     void *usr_handle, 
124                     unsigned int importance, 
125                     tipc_msg_err_event error_cb, 
126                     tipc_named_msg_err_event named_error_cb, 
127                     tipc_conn_shutdown_event conn_error_cb, 
128                     tipc_msg_event message_cb, 
129                     tipc_named_msg_event named_message_cb, 
130                     tipc_conn_msg_event conn_message_cb, 
131                     tipc_continue_event continue_event_cb,/* May be zero */
132                     u32 *portref);
133
134 int tipc_deleteport(u32 portref);
135
136 int tipc_ownidentity(u32 portref, struct tipc_portid *port);
137
138 int tipc_portimportance(u32 portref, unsigned int *importance);
139 int tipc_set_portimportance(u32 portref, unsigned int importance);
140
141 int tipc_portunreliable(u32 portref, unsigned int *isunreliable);
142 int tipc_set_portunreliable(u32 portref, unsigned int isunreliable);
143
144 int tipc_portunreturnable(u32 portref, unsigned int *isunreturnable);
145 int tipc_set_portunreturnable(u32 portref, unsigned int isunreturnable);
146
147 int tipc_publish(u32 portref, unsigned int scope, 
148                  struct tipc_name_seq const *name_seq);
149 int tipc_withdraw(u32 portref, unsigned int scope,
150                   struct tipc_name_seq const *name_seq); /* 0: all */
151
152 int tipc_connect2port(u32 portref, struct tipc_portid const *port);
153
154 int tipc_disconnect(u32 portref);
155
156 int tipc_shutdown(u32 ref); /* Sends SHUTDOWN msg */
157
158 int tipc_isconnected(u32 portref, int *isconnected);
159
160 int tipc_peer(u32 portref, struct tipc_portid *peer);
161
162 int tipc_ref_valid(u32 portref); 
163
164 /*
165  * TIPC messaging routines
166  */
167
168 #define TIPC_PORT_IMPORTANCE 100        /* send using current port setting */
169
170
171 int tipc_send(u32 portref,
172               unsigned int num_sect,
173               struct iovec const *msg_sect);
174
175 int tipc_send_buf(u32 portref,
176                   struct sk_buff *buf,
177                   unsigned int dsz);
178
179 int tipc_send2name(u32 portref, 
180                    struct tipc_name const *name, 
181                    u32 domain,  /* 0:own zone */
182                    unsigned int num_sect,
183                    struct iovec const *msg_sect);
184
185 int tipc_send_buf2name(u32 portref,
186                        struct tipc_name const *name,
187                        u32 domain,
188                        struct sk_buff *buf,
189                        unsigned int dsz);
190
191 int tipc_forward2name(u32 portref, 
192                       struct tipc_name const *name, 
193                       u32 domain,   /*0: own zone */
194                       unsigned int section_count,
195                       struct iovec const *msg_sect,
196                       struct tipc_portid const *origin,
197                       unsigned int importance);
198
199 int tipc_forward_buf2name(u32 portref,
200                           struct tipc_name const *name,
201                           u32 domain,
202                           struct sk_buff *buf,
203                           unsigned int dsz,
204                           struct tipc_portid const *orig,
205                           unsigned int importance);
206
207 int tipc_send2port(u32 portref,
208                    struct tipc_portid const *dest,
209                    unsigned int num_sect,
210                    struct iovec const *msg_sect);
211
212 int tipc_send_buf2port(u32 portref,
213                        struct tipc_portid const *dest,
214                        struct sk_buff *buf,
215                        unsigned int dsz);
216
217 int tipc_forward2port(u32 portref,
218                       struct tipc_portid const *dest,
219                       unsigned int num_sect,
220                       struct iovec const *msg_sect,
221                       struct tipc_portid const *origin,
222                       unsigned int importance);
223
224 int tipc_forward_buf2port(u32 portref,
225                           struct tipc_portid const *dest,
226                           struct sk_buff *buf,
227                           unsigned int dsz,
228                           struct tipc_portid const *orig,
229                           unsigned int importance);
230
231 int tipc_multicast(u32 portref, 
232                    struct tipc_name_seq const *seq, 
233                    u32 domain,  /* 0:own zone */
234                    unsigned int section_count,
235                    struct iovec const *msg);
236
237 #if 0
238 int tipc_multicast_buf(u32 portref, 
239                        struct tipc_name_seq const *seq, 
240                        u32 domain,      /* 0:own zone */
241                        void *buf,
242                        unsigned int size);
243 #endif
244
245 /*
246  * TIPC subscription routines
247  */
248
249 int tipc_ispublished(struct tipc_name const *name);
250
251 /*
252  * Get number of available nodes within specified domain (excluding own node)
253  */
254
255 unsigned int tipc_available_nodes(const u32 domain);
256
257 #endif
258
259 #endif