]>
Commit | Line | Data |
---|---|---|
b97bf3fd | 1 | /* |
8941bbcd | 2 | * include/uapi/linux/tipc.h: Header for TIPC socket interface |
0e65967e | 3 | * |
9da1c8b6 | 4 | * Copyright (c) 2003-2006, Ericsson AB |
77c81e0b | 5 | * Copyright (c) 2005, 2010-2011, Wind River Systems |
b97bf3fd PL |
6 | * All rights reserved. |
7 | * | |
9ea1fd3c | 8 | * Redistribution and use in source and binary forms, with or without |
b97bf3fd PL |
9 | * modification, are permitted provided that the following conditions are met: |
10 | * | |
9ea1fd3c PL |
11 | * 1. Redistributions of source code must retain the above copyright |
12 | * notice, this list of conditions and the following disclaimer. | |
13 | * 2. Redistributions in binary form must reproduce the above copyright | |
14 | * notice, this list of conditions and the following disclaimer in the | |
15 | * documentation and/or other materials provided with the distribution. | |
16 | * 3. Neither the names of the copyright holders nor the names of its | |
17 | * contributors may be used to endorse or promote products derived from | |
18 | * this software without specific prior written permission. | |
b97bf3fd | 19 | * |
9ea1fd3c PL |
20 | * Alternatively, this software may be distributed under the terms of the |
21 | * GNU General Public License ("GPL") version 2 as published by the Free | |
22 | * Software Foundation. | |
23 | * | |
24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
27 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | |
28 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
29 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
30 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
31 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
32 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
b97bf3fd PL |
34 | * POSSIBILITY OF SUCH DAMAGE. |
35 | */ | |
36 | ||
37 | #ifndef _LINUX_TIPC_H_ | |
38 | #define _LINUX_TIPC_H_ | |
39 | ||
40 | #include <linux/types.h> | |
78acb1f9 | 41 | #include <linux/sockios.h> |
b97bf3fd PL |
42 | |
43 | /* | |
44 | * TIPC addressing primitives | |
45 | */ | |
0e65967e | 46 | |
b97bf3fd PL |
47 | struct tipc_portid { |
48 | __u32 ref; | |
49 | __u32 node; | |
50 | }; | |
51 | ||
52 | struct tipc_name { | |
53 | __u32 type; | |
54 | __u32 instance; | |
55 | }; | |
56 | ||
57 | struct tipc_name_seq { | |
58 | __u32 type; | |
59 | __u32 lower; | |
60 | __u32 upper; | |
61 | }; | |
62 | ||
9ff26e9f PB |
63 | /* TIPC Address Size, Offset, Mask specification for Z.C.N |
64 | */ | |
65 | #define TIPC_NODE_BITS 12 | |
66 | #define TIPC_CLUSTER_BITS 12 | |
67 | #define TIPC_ZONE_BITS 8 | |
68 | ||
69 | #define TIPC_NODE_OFFSET 0 | |
70 | #define TIPC_CLUSTER_OFFSET TIPC_NODE_BITS | |
71 | #define TIPC_ZONE_OFFSET (TIPC_CLUSTER_OFFSET + TIPC_CLUSTER_BITS) | |
72 | ||
73 | #define TIPC_NODE_SIZE ((1UL << TIPC_NODE_BITS) - 1) | |
74 | #define TIPC_CLUSTER_SIZE ((1UL << TIPC_CLUSTER_BITS) - 1) | |
75 | #define TIPC_ZONE_SIZE ((1UL << TIPC_ZONE_BITS) - 1) | |
76 | ||
77 | #define TIPC_NODE_MASK (TIPC_NODE_SIZE << TIPC_NODE_OFFSET) | |
78 | #define TIPC_CLUSTER_MASK (TIPC_CLUSTER_SIZE << TIPC_CLUSTER_OFFSET) | |
79 | #define TIPC_ZONE_MASK (TIPC_ZONE_SIZE << TIPC_ZONE_OFFSET) | |
80 | ||
81 | #define TIPC_ZONE_CLUSTER_MASK (TIPC_ZONE_MASK | TIPC_CLUSTER_MASK) | |
82 | ||
b97bf3fd PL |
83 | static inline __u32 tipc_addr(unsigned int zone, |
84 | unsigned int cluster, | |
85 | unsigned int node) | |
86 | { | |
9ff26e9f PB |
87 | return (zone << TIPC_ZONE_OFFSET) | |
88 | (cluster << TIPC_CLUSTER_OFFSET) | | |
89 | node; | |
b97bf3fd PL |
90 | } |
91 | ||
92 | static inline unsigned int tipc_zone(__u32 addr) | |
93 | { | |
9ff26e9f | 94 | return addr >> TIPC_ZONE_OFFSET; |
b97bf3fd PL |
95 | } |
96 | ||
97 | static inline unsigned int tipc_cluster(__u32 addr) | |
98 | { | |
9ff26e9f | 99 | return (addr & TIPC_CLUSTER_MASK) >> TIPC_CLUSTER_OFFSET; |
b97bf3fd PL |
100 | } |
101 | ||
102 | static inline unsigned int tipc_node(__u32 addr) | |
103 | { | |
9ff26e9f | 104 | return addr & TIPC_NODE_MASK; |
b97bf3fd PL |
105 | } |
106 | ||
107 | /* | |
108 | * Application-accessible port name types | |
109 | */ | |
110 | ||
ea714ccd PL |
111 | #define TIPC_CFG_SRV 0 /* configuration service name type */ |
112 | #define TIPC_TOP_SRV 1 /* topology service name type */ | |
a89778d8 | 113 | #define TIPC_LINK_STATE 2 /* link state name type */ |
b97bf3fd PL |
114 | #define TIPC_RESERVED_TYPES 64 /* lowest user-publishable name type */ |
115 | ||
0e65967e | 116 | /* |
b97bf3fd PL |
117 | * Publication scopes when binding port names and port name sequences |
118 | */ | |
119 | ||
ea714ccd PL |
120 | #define TIPC_ZONE_SCOPE 1 |
121 | #define TIPC_CLUSTER_SCOPE 2 | |
122 | #define TIPC_NODE_SCOPE 3 | |
b97bf3fd PL |
123 | |
124 | /* | |
125 | * Limiting values for messages | |
126 | */ | |
127 | ||
c29c3f70 | 128 | #define TIPC_MAX_USER_MSG_SIZE 66000U |
b97bf3fd | 129 | |
ea714ccd | 130 | /* |
b97bf3fd PL |
131 | * Message importance levels |
132 | */ | |
133 | ||
8e1c298c | 134 | #define TIPC_LOW_IMPORTANCE 0 |
b97bf3fd PL |
135 | #define TIPC_MEDIUM_IMPORTANCE 1 |
136 | #define TIPC_HIGH_IMPORTANCE 2 | |
137 | #define TIPC_CRITICAL_IMPORTANCE 3 | |
138 | ||
0e65967e | 139 | /* |
b97bf3fd PL |
140 | * Msg rejection/connection shutdown reasons |
141 | */ | |
142 | ||
143 | #define TIPC_OK 0 | |
144 | #define TIPC_ERR_NO_NAME 1 | |
145 | #define TIPC_ERR_NO_PORT 2 | |
146 | #define TIPC_ERR_NO_NODE 3 | |
147 | #define TIPC_ERR_OVERLOAD 4 | |
148 | #define TIPC_CONN_SHUTDOWN 5 | |
149 | ||
150 | /* | |
151 | * TIPC topology subscription service definitions | |
152 | */ | |
153 | ||
0e65967e AS |
154 | #define TIPC_SUB_PORTS 0x01 /* filter for port availability */ |
155 | #define TIPC_SUB_SERVICE 0x02 /* filter for service availability */ | |
156 | #define TIPC_SUB_CANCEL 0x04 /* cancel a subscription */ | |
b97bf3fd | 157 | |
0e65967e | 158 | #define TIPC_WAIT_FOREVER (~0) /* timeout for permanent subscription */ |
b97bf3fd PL |
159 | |
160 | struct tipc_subscr { | |
8c974438 NH |
161 | struct tipc_name_seq seq; /* name sequence of interest */ |
162 | __u32 timeout; /* subscription duration (in ms) */ | |
0e65967e | 163 | __u32 filter; /* bitmask of filter options */ |
8c974438 | 164 | char usr_handle[8]; /* available for subscriber use */ |
b97bf3fd PL |
165 | }; |
166 | ||
ea714ccd PL |
167 | #define TIPC_PUBLISHED 1 /* publication event */ |
168 | #define TIPC_WITHDRAWN 2 /* withdraw event */ | |
169 | #define TIPC_SUBSCR_TIMEOUT 3 /* subscription timeout event */ | |
b97bf3fd PL |
170 | |
171 | struct tipc_event { | |
8c974438 NH |
172 | __u32 event; /* event type */ |
173 | __u32 found_lower; /* matching name seq instances */ | |
174 | __u32 found_upper; /* " " " " */ | |
175 | struct tipc_portid port; /* associated port */ | |
176 | struct tipc_subscr s; /* associated subscription */ | |
b97bf3fd PL |
177 | }; |
178 | ||
179 | /* | |
180 | * Socket API | |
181 | */ | |
182 | ||
183 | #ifndef AF_TIPC | |
184 | #define AF_TIPC 30 | |
185 | #endif | |
186 | ||
187 | #ifndef PF_TIPC | |
188 | #define PF_TIPC AF_TIPC | |
189 | #endif | |
190 | ||
191 | #ifndef SOL_TIPC | |
192 | #define SOL_TIPC 271 | |
193 | #endif | |
194 | ||
ea714ccd PL |
195 | #define TIPC_ADDR_NAMESEQ 1 |
196 | #define TIPC_ADDR_MCAST 1 | |
197 | #define TIPC_ADDR_NAME 2 | |
198 | #define TIPC_ADDR_ID 3 | |
b97bf3fd PL |
199 | |
200 | struct sockaddr_tipc { | |
201 | unsigned short family; | |
202 | unsigned char addrtype; | |
203 | signed char scope; | |
204 | union { | |
205 | struct tipc_portid id; | |
206 | struct tipc_name_seq nameseq; | |
207 | struct { | |
208 | struct tipc_name name; | |
8e1c298c | 209 | __u32 domain; |
b97bf3fd PL |
210 | } name; |
211 | } addr; | |
212 | }; | |
213 | ||
214 | /* | |
215 | * Ancillary data objects supported by recvmsg() | |
216 | */ | |
217 | ||
218 | #define TIPC_ERRINFO 1 /* error info */ | |
219 | #define TIPC_RETDATA 2 /* returned data */ | |
220 | #define TIPC_DESTNAME 3 /* destination name */ | |
221 | ||
222 | /* | |
223 | * TIPC-specific socket option values | |
224 | */ | |
225 | ||
226 | #define TIPC_IMPORTANCE 127 /* Default: TIPC_LOW_IMPORTANCE */ | |
8e1c298c | 227 | #define TIPC_SRC_DROPPABLE 128 /* Default: based on socket type */ |
b97bf3fd | 228 | #define TIPC_DEST_DROPPABLE 129 /* Default: based on socket type */ |
ea714ccd | 229 | #define TIPC_CONN_TIMEOUT 130 /* Default: 8000 (ms) */ |
6650613d | 230 | #define TIPC_NODE_RECVQ_DEPTH 131 /* Default: none (read only) */ |
231 | #define TIPC_SOCK_RECVQ_DEPTH 132 /* Default: none (read only) */ | |
b97bf3fd | 232 | |
78acb1f9 EH |
233 | /* |
234 | * Maximum sizes of TIPC bearer-related names (including terminating NULL) | |
235 | * The string formatting for each name element is: | |
236 | * media: media | |
237 | * interface: media:interface name | |
238 | * link: Z.C.N:interface-Z.C.N:interface | |
239 | * | |
240 | */ | |
241 | ||
242 | #define TIPC_MAX_MEDIA_NAME 16 | |
243 | #define TIPC_MAX_IF_NAME 16 | |
244 | #define TIPC_MAX_BEARER_NAME 32 | |
245 | #define TIPC_MAX_LINK_NAME 60 | |
246 | ||
247 | #define SIOCGETLINKNAME SIOCPROTOPRIVATE | |
248 | ||
249 | struct tipc_sioc_ln_req { | |
250 | __u32 peer; | |
251 | __u32 bearer_id; | |
252 | char linkname[TIPC_MAX_LINK_NAME]; | |
253 | }; | |
b97bf3fd | 254 | #endif |