Commit | Line | Data |
---|---|---|
e2be04c7 | 1 | /* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */ |
b97bf3fd | 2 | /* |
8941bbcd | 3 | * include/uapi/linux/tipc.h: Header for TIPC socket interface |
0e65967e | 4 | * |
01fd12bb | 5 | * Copyright (c) 2003-2006, 2015-2016 Ericsson AB |
77c81e0b | 6 | * Copyright (c) 2005, 2010-2011, Wind River Systems |
b97bf3fd PL |
7 | * All rights reserved. |
8 | * | |
9ea1fd3c | 9 | * Redistribution and use in source and binary forms, with or without |
b97bf3fd PL |
10 | * modification, are permitted provided that the following conditions are met: |
11 | * | |
9ea1fd3c PL |
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. | |
b97bf3fd | 20 | * |
9ea1fd3c PL |
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 | |
b97bf3fd PL |
35 | * POSSIBILITY OF SUCH DAMAGE. |
36 | */ | |
37 | ||
38 | #ifndef _LINUX_TIPC_H_ | |
39 | #define _LINUX_TIPC_H_ | |
40 | ||
41 | #include <linux/types.h> | |
78acb1f9 | 42 | #include <linux/sockios.h> |
b97bf3fd PL |
43 | |
44 | /* | |
45 | * TIPC addressing primitives | |
46 | */ | |
0e65967e | 47 | |
7a74d39c | 48 | struct tipc_socket_addr { |
b97bf3fd PL |
49 | __u32 ref; |
50 | __u32 node; | |
51 | }; | |
52 | ||
7a74d39c | 53 | struct tipc_service_addr { |
b97bf3fd PL |
54 | __u32 type; |
55 | __u32 instance; | |
56 | }; | |
57 | ||
7a74d39c | 58 | struct tipc_service_range { |
b97bf3fd PL |
59 | __u32 type; |
60 | __u32 lower; | |
61 | __u32 upper; | |
62 | }; | |
63 | ||
b97bf3fd | 64 | /* |
7a74d39c | 65 | * Application-accessible service types |
b97bf3fd PL |
66 | */ |
67 | ||
7a74d39c JM |
68 | #define TIPC_NODE_STATE 0 /* node state service type */ |
69 | #define TIPC_TOP_SRV 1 /* topology server service type */ | |
70 | #define TIPC_LINK_STATE 2 /* link state service type */ | |
71 | #define TIPC_RESERVED_TYPES 64 /* lowest user-allowed service type */ | |
b97bf3fd | 72 | |
0e65967e | 73 | /* |
7a74d39c | 74 | * Publication scopes when binding service / service range |
b97bf3fd | 75 | */ |
928df188 JM |
76 | enum tipc_scope { |
77 | TIPC_CLUSTER_SCOPE = 2, /* 0 can also be used */ | |
78 | TIPC_NODE_SCOPE = 3 | |
79 | }; | |
b97bf3fd PL |
80 | |
81 | /* | |
82 | * Limiting values for messages | |
83 | */ | |
84 | ||
c29c3f70 | 85 | #define TIPC_MAX_USER_MSG_SIZE 66000U |
b97bf3fd | 86 | |
ea714ccd | 87 | /* |
b97bf3fd PL |
88 | * Message importance levels |
89 | */ | |
90 | ||
8e1c298c | 91 | #define TIPC_LOW_IMPORTANCE 0 |
b97bf3fd PL |
92 | #define TIPC_MEDIUM_IMPORTANCE 1 |
93 | #define TIPC_HIGH_IMPORTANCE 2 | |
94 | #define TIPC_CRITICAL_IMPORTANCE 3 | |
95 | ||
0e65967e | 96 | /* |
b97bf3fd PL |
97 | * Msg rejection/connection shutdown reasons |
98 | */ | |
99 | ||
100 | #define TIPC_OK 0 | |
101 | #define TIPC_ERR_NO_NAME 1 | |
102 | #define TIPC_ERR_NO_PORT 2 | |
103 | #define TIPC_ERR_NO_NODE 3 | |
104 | #define TIPC_ERR_OVERLOAD 4 | |
105 | #define TIPC_CONN_SHUTDOWN 5 | |
106 | ||
107 | /* | |
108 | * TIPC topology subscription service definitions | |
109 | */ | |
110 | ||
7a74d39c JM |
111 | #define TIPC_SUB_PORTS 0x01 /* filter: evt at each match */ |
112 | #define TIPC_SUB_SERVICE 0x02 /* filter: evt at first up/last down */ | |
113 | #define TIPC_SUB_CANCEL 0x04 /* filter: cancel a subscription */ | |
b97bf3fd | 114 | |
0e65967e | 115 | #define TIPC_WAIT_FOREVER (~0) /* timeout for permanent subscription */ |
b97bf3fd PL |
116 | |
117 | struct tipc_subscr { | |
7a74d39c | 118 | struct tipc_service_range seq; /* range of interest */ |
8c974438 | 119 | __u32 timeout; /* subscription duration (in ms) */ |
0e65967e | 120 | __u32 filter; /* bitmask of filter options */ |
8c974438 | 121 | char usr_handle[8]; /* available for subscriber use */ |
b97bf3fd PL |
122 | }; |
123 | ||
ea714ccd | 124 | #define TIPC_PUBLISHED 1 /* publication event */ |
7a74d39c | 125 | #define TIPC_WITHDRAWN 2 /* withdrawal event */ |
ea714ccd | 126 | #define TIPC_SUBSCR_TIMEOUT 3 /* subscription timeout event */ |
b97bf3fd PL |
127 | |
128 | struct tipc_event { | |
8c974438 | 129 | __u32 event; /* event type */ |
7a74d39c JM |
130 | __u32 found_lower; /* matching range */ |
131 | __u32 found_upper; /* " " */ | |
132 | struct tipc_socket_addr port; /* associated socket */ | |
8c974438 | 133 | struct tipc_subscr s; /* associated subscription */ |
b97bf3fd PL |
134 | }; |
135 | ||
136 | /* | |
137 | * Socket API | |
138 | */ | |
139 | ||
140 | #ifndef AF_TIPC | |
141 | #define AF_TIPC 30 | |
142 | #endif | |
143 | ||
144 | #ifndef PF_TIPC | |
145 | #define PF_TIPC AF_TIPC | |
146 | #endif | |
147 | ||
148 | #ifndef SOL_TIPC | |
149 | #define SOL_TIPC 271 | |
150 | #endif | |
151 | ||
7a74d39c JM |
152 | #define TIPC_ADDR_MCAST 1 |
153 | #define TIPC_SERVICE_RANGE 1 | |
154 | #define TIPC_SERVICE_ADDR 2 | |
155 | #define TIPC_SOCKET_ADDR 3 | |
b97bf3fd PL |
156 | |
157 | struct sockaddr_tipc { | |
158 | unsigned short family; | |
159 | unsigned char addrtype; | |
160 | signed char scope; | |
161 | union { | |
7a74d39c JM |
162 | struct tipc_socket_addr id; |
163 | struct tipc_service_range nameseq; | |
b97bf3fd | 164 | struct { |
7a74d39c | 165 | struct tipc_service_addr name; |
8e1c298c | 166 | __u32 domain; |
b97bf3fd PL |
167 | } name; |
168 | } addr; | |
169 | }; | |
170 | ||
171 | /* | |
172 | * Ancillary data objects supported by recvmsg() | |
173 | */ | |
174 | ||
175 | #define TIPC_ERRINFO 1 /* error info */ | |
176 | #define TIPC_RETDATA 2 /* returned data */ | |
177 | #define TIPC_DESTNAME 3 /* destination name */ | |
178 | ||
179 | /* | |
01fd12bb | 180 | * TIPC-specific socket option names |
b97bf3fd PL |
181 | */ |
182 | ||
183 | #define TIPC_IMPORTANCE 127 /* Default: TIPC_LOW_IMPORTANCE */ | |
8e1c298c | 184 | #define TIPC_SRC_DROPPABLE 128 /* Default: based on socket type */ |
b97bf3fd | 185 | #define TIPC_DEST_DROPPABLE 129 /* Default: based on socket type */ |
ea714ccd | 186 | #define TIPC_CONN_TIMEOUT 130 /* Default: 8000 (ms) */ |
6650613d | 187 | #define TIPC_NODE_RECVQ_DEPTH 131 /* Default: none (read only) */ |
188 | #define TIPC_SOCK_RECVQ_DEPTH 132 /* Default: none (read only) */ | |
01fd12bb JPM |
189 | #define TIPC_MCAST_BROADCAST 133 /* Default: TIPC selects. No arg */ |
190 | #define TIPC_MCAST_REPLICAST 134 /* Default: TIPC selects. No arg */ | |
75da2163 JM |
191 | #define TIPC_GROUP_JOIN 135 /* Takes struct tipc_group_req* */ |
192 | #define TIPC_GROUP_LEAVE 136 /* No argument */ | |
42e5425a | 193 | #define TIPC_SOCK_RECVQ_USED 137 /* Default: none (read only) */ |
c0bceb97 | 194 | #define TIPC_NODELAY 138 /* Default: false */ |
75da2163 JM |
195 | |
196 | /* | |
197 | * Flag values | |
198 | */ | |
199 | #define TIPC_GROUP_LOOPBACK 0x1 /* Receive copy of sent msg when match */ | |
ae236fb2 | 200 | #define TIPC_GROUP_MEMBER_EVTS 0x2 /* Receive membership events in socket */ |
75da2163 JM |
201 | |
202 | struct tipc_group_req { | |
203 | __u32 type; /* group id */ | |
204 | __u32 instance; /* member id */ | |
928df188 | 205 | __u32 scope; /* cluster/node */ |
75da2163 JM |
206 | __u32 flags; |
207 | }; | |
b97bf3fd | 208 | |
78acb1f9 EH |
209 | /* |
210 | * Maximum sizes of TIPC bearer-related names (including terminating NULL) | |
211 | * The string formatting for each name element is: | |
212 | * media: media | |
213 | * interface: media:interface name | |
3e5cf362 | 214 | * link: node:interface-node:interface |
78acb1f9 | 215 | */ |
3e5cf362 | 216 | #define TIPC_NODEID_LEN 16 |
78acb1f9 EH |
217 | #define TIPC_MAX_MEDIA_NAME 16 |
218 | #define TIPC_MAX_IF_NAME 16 | |
219 | #define TIPC_MAX_BEARER_NAME 32 | |
7494cfa6 | 220 | #define TIPC_MAX_LINK_NAME 68 |
78acb1f9 | 221 | |
3e5cf362 JM |
222 | #define SIOCGETLINKNAME SIOCPROTOPRIVATE |
223 | #define SIOCGETNODEID (SIOCPROTOPRIVATE + 1) | |
78acb1f9 EH |
224 | |
225 | struct tipc_sioc_ln_req { | |
226 | __u32 peer; | |
227 | __u32 bearer_id; | |
228 | char linkname[TIPC_MAX_LINK_NAME]; | |
229 | }; | |
928df188 | 230 | |
3e5cf362 JM |
231 | struct tipc_sioc_nodeid_req { |
232 | __u32 peer; | |
233 | char node_id[TIPC_NODEID_LEN]; | |
234 | }; | |
928df188 | 235 | |
134bdac3 TL |
236 | /* |
237 | * TIPC Crypto, AEAD | |
238 | */ | |
239 | #define TIPC_AEAD_ALG_NAME (32) | |
240 | ||
241 | struct tipc_aead_key { | |
242 | char alg_name[TIPC_AEAD_ALG_NAME]; | |
243 | unsigned int keylen; /* in bytes */ | |
244 | char key[]; | |
245 | }; | |
246 | ||
247 | #define TIPC_AEAD_KEYLEN_MIN (16 + 4) | |
248 | #define TIPC_AEAD_KEYLEN_MAX (32 + 4) | |
249 | #define TIPC_AEAD_KEY_SIZE_MAX (sizeof(struct tipc_aead_key) + \ | |
250 | TIPC_AEAD_KEYLEN_MAX) | |
251 | ||
252 | static inline int tipc_aead_key_size(struct tipc_aead_key *key) | |
253 | { | |
254 | return sizeof(*key) + key->keylen; | |
255 | } | |
256 | ||
23700da2 TL |
257 | #define TIPC_REKEYING_NOW (~0U) |
258 | ||
928df188 JM |
259 | /* The macros and functions below are deprecated: |
260 | */ | |
261 | ||
7a74d39c | 262 | #define TIPC_CFG_SRV 0 |
928df188 JM |
263 | #define TIPC_ZONE_SCOPE 1 |
264 | ||
7a74d39c JM |
265 | #define TIPC_ADDR_NAMESEQ 1 |
266 | #define TIPC_ADDR_NAME 2 | |
267 | #define TIPC_ADDR_ID 3 | |
268 | ||
928df188 JM |
269 | #define TIPC_NODE_BITS 12 |
270 | #define TIPC_CLUSTER_BITS 12 | |
271 | #define TIPC_ZONE_BITS 8 | |
272 | ||
273 | #define TIPC_NODE_OFFSET 0 | |
274 | #define TIPC_CLUSTER_OFFSET TIPC_NODE_BITS | |
275 | #define TIPC_ZONE_OFFSET (TIPC_CLUSTER_OFFSET + TIPC_CLUSTER_BITS) | |
276 | ||
277 | #define TIPC_NODE_SIZE ((1UL << TIPC_NODE_BITS) - 1) | |
278 | #define TIPC_CLUSTER_SIZE ((1UL << TIPC_CLUSTER_BITS) - 1) | |
279 | #define TIPC_ZONE_SIZE ((1UL << TIPC_ZONE_BITS) - 1) | |
280 | ||
281 | #define TIPC_NODE_MASK (TIPC_NODE_SIZE << TIPC_NODE_OFFSET) | |
282 | #define TIPC_CLUSTER_MASK (TIPC_CLUSTER_SIZE << TIPC_CLUSTER_OFFSET) | |
283 | #define TIPC_ZONE_MASK (TIPC_ZONE_SIZE << TIPC_ZONE_OFFSET) | |
284 | ||
285 | #define TIPC_ZONE_CLUSTER_MASK (TIPC_ZONE_MASK | TIPC_CLUSTER_MASK) | |
286 | ||
7a74d39c JM |
287 | #define tipc_portid tipc_socket_addr |
288 | #define tipc_name tipc_service_addr | |
289 | #define tipc_name_seq tipc_service_range | |
290 | ||
928df188 JM |
291 | static inline __u32 tipc_addr(unsigned int zone, |
292 | unsigned int cluster, | |
293 | unsigned int node) | |
294 | { | |
295 | return (zone << TIPC_ZONE_OFFSET) | | |
296 | (cluster << TIPC_CLUSTER_OFFSET) | | |
297 | node; | |
298 | } | |
299 | ||
300 | static inline unsigned int tipc_zone(__u32 addr) | |
301 | { | |
302 | return addr >> TIPC_ZONE_OFFSET; | |
303 | } | |
304 | ||
305 | static inline unsigned int tipc_cluster(__u32 addr) | |
306 | { | |
307 | return (addr & TIPC_CLUSTER_MASK) >> TIPC_CLUSTER_OFFSET; | |
308 | } | |
309 | ||
310 | static inline unsigned int tipc_node(__u32 addr) | |
311 | { | |
312 | return addr & TIPC_NODE_MASK; | |
313 | } | |
314 | ||
b97bf3fd | 315 | #endif |