]>
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 | |
b97bf3fd PL |
48 | struct tipc_portid { |
49 | __u32 ref; | |
50 | __u32 node; | |
51 | }; | |
52 | ||
53 | struct tipc_name { | |
54 | __u32 type; | |
55 | __u32 instance; | |
56 | }; | |
57 | ||
58 | struct tipc_name_seq { | |
59 | __u32 type; | |
60 | __u32 lower; | |
61 | __u32 upper; | |
62 | }; | |
63 | ||
9ff26e9f PB |
64 | /* TIPC Address Size, Offset, Mask specification for Z.C.N |
65 | */ | |
66 | #define TIPC_NODE_BITS 12 | |
67 | #define TIPC_CLUSTER_BITS 12 | |
68 | #define TIPC_ZONE_BITS 8 | |
69 | ||
70 | #define TIPC_NODE_OFFSET 0 | |
71 | #define TIPC_CLUSTER_OFFSET TIPC_NODE_BITS | |
72 | #define TIPC_ZONE_OFFSET (TIPC_CLUSTER_OFFSET + TIPC_CLUSTER_BITS) | |
73 | ||
74 | #define TIPC_NODE_SIZE ((1UL << TIPC_NODE_BITS) - 1) | |
75 | #define TIPC_CLUSTER_SIZE ((1UL << TIPC_CLUSTER_BITS) - 1) | |
76 | #define TIPC_ZONE_SIZE ((1UL << TIPC_ZONE_BITS) - 1) | |
77 | ||
78 | #define TIPC_NODE_MASK (TIPC_NODE_SIZE << TIPC_NODE_OFFSET) | |
79 | #define TIPC_CLUSTER_MASK (TIPC_CLUSTER_SIZE << TIPC_CLUSTER_OFFSET) | |
80 | #define TIPC_ZONE_MASK (TIPC_ZONE_SIZE << TIPC_ZONE_OFFSET) | |
81 | ||
82 | #define TIPC_ZONE_CLUSTER_MASK (TIPC_ZONE_MASK | TIPC_CLUSTER_MASK) | |
83 | ||
b97bf3fd PL |
84 | static inline __u32 tipc_addr(unsigned int zone, |
85 | unsigned int cluster, | |
86 | unsigned int node) | |
87 | { | |
9ff26e9f PB |
88 | return (zone << TIPC_ZONE_OFFSET) | |
89 | (cluster << TIPC_CLUSTER_OFFSET) | | |
90 | node; | |
b97bf3fd PL |
91 | } |
92 | ||
93 | static inline unsigned int tipc_zone(__u32 addr) | |
94 | { | |
9ff26e9f | 95 | return addr >> TIPC_ZONE_OFFSET; |
b97bf3fd PL |
96 | } |
97 | ||
98 | static inline unsigned int tipc_cluster(__u32 addr) | |
99 | { | |
9ff26e9f | 100 | return (addr & TIPC_CLUSTER_MASK) >> TIPC_CLUSTER_OFFSET; |
b97bf3fd PL |
101 | } |
102 | ||
103 | static inline unsigned int tipc_node(__u32 addr) | |
104 | { | |
9ff26e9f | 105 | return addr & TIPC_NODE_MASK; |
b97bf3fd PL |
106 | } |
107 | ||
108 | /* | |
109 | * Application-accessible port name types | |
110 | */ | |
111 | ||
ea714ccd PL |
112 | #define TIPC_CFG_SRV 0 /* configuration service name type */ |
113 | #define TIPC_TOP_SRV 1 /* topology service name type */ | |
a89778d8 | 114 | #define TIPC_LINK_STATE 2 /* link state name type */ |
b97bf3fd PL |
115 | #define TIPC_RESERVED_TYPES 64 /* lowest user-publishable name type */ |
116 | ||
0e65967e | 117 | /* |
b97bf3fd PL |
118 | * Publication scopes when binding port names and port name sequences |
119 | */ | |
120 | ||
ea714ccd PL |
121 | #define TIPC_ZONE_SCOPE 1 |
122 | #define TIPC_CLUSTER_SCOPE 2 | |
123 | #define TIPC_NODE_SCOPE 3 | |
b97bf3fd PL |
124 | |
125 | /* | |
126 | * Limiting values for messages | |
127 | */ | |
128 | ||
c29c3f70 | 129 | #define TIPC_MAX_USER_MSG_SIZE 66000U |
b97bf3fd | 130 | |
ea714ccd | 131 | /* |
b97bf3fd PL |
132 | * Message importance levels |
133 | */ | |
134 | ||
8e1c298c | 135 | #define TIPC_LOW_IMPORTANCE 0 |
b97bf3fd PL |
136 | #define TIPC_MEDIUM_IMPORTANCE 1 |
137 | #define TIPC_HIGH_IMPORTANCE 2 | |
138 | #define TIPC_CRITICAL_IMPORTANCE 3 | |
139 | ||
0e65967e | 140 | /* |
b97bf3fd PL |
141 | * Msg rejection/connection shutdown reasons |
142 | */ | |
143 | ||
144 | #define TIPC_OK 0 | |
145 | #define TIPC_ERR_NO_NAME 1 | |
146 | #define TIPC_ERR_NO_PORT 2 | |
147 | #define TIPC_ERR_NO_NODE 3 | |
148 | #define TIPC_ERR_OVERLOAD 4 | |
149 | #define TIPC_CONN_SHUTDOWN 5 | |
150 | ||
151 | /* | |
152 | * TIPC topology subscription service definitions | |
153 | */ | |
154 | ||
0e65967e AS |
155 | #define TIPC_SUB_PORTS 0x01 /* filter for port availability */ |
156 | #define TIPC_SUB_SERVICE 0x02 /* filter for service availability */ | |
157 | #define TIPC_SUB_CANCEL 0x04 /* cancel a subscription */ | |
b97bf3fd | 158 | |
0e65967e | 159 | #define TIPC_WAIT_FOREVER (~0) /* timeout for permanent subscription */ |
b97bf3fd PL |
160 | |
161 | struct tipc_subscr { | |
8c974438 NH |
162 | struct tipc_name_seq seq; /* name sequence of interest */ |
163 | __u32 timeout; /* subscription duration (in ms) */ | |
0e65967e | 164 | __u32 filter; /* bitmask of filter options */ |
8c974438 | 165 | char usr_handle[8]; /* available for subscriber use */ |
b97bf3fd PL |
166 | }; |
167 | ||
ea714ccd PL |
168 | #define TIPC_PUBLISHED 1 /* publication event */ |
169 | #define TIPC_WITHDRAWN 2 /* withdraw event */ | |
170 | #define TIPC_SUBSCR_TIMEOUT 3 /* subscription timeout event */ | |
b97bf3fd PL |
171 | |
172 | struct tipc_event { | |
8c974438 NH |
173 | __u32 event; /* event type */ |
174 | __u32 found_lower; /* matching name seq instances */ | |
175 | __u32 found_upper; /* " " " " */ | |
176 | struct tipc_portid port; /* associated port */ | |
177 | struct tipc_subscr s; /* associated subscription */ | |
b97bf3fd PL |
178 | }; |
179 | ||
180 | /* | |
181 | * Socket API | |
182 | */ | |
183 | ||
184 | #ifndef AF_TIPC | |
185 | #define AF_TIPC 30 | |
186 | #endif | |
187 | ||
188 | #ifndef PF_TIPC | |
189 | #define PF_TIPC AF_TIPC | |
190 | #endif | |
191 | ||
192 | #ifndef SOL_TIPC | |
193 | #define SOL_TIPC 271 | |
194 | #endif | |
195 | ||
ea714ccd PL |
196 | #define TIPC_ADDR_NAMESEQ 1 |
197 | #define TIPC_ADDR_MCAST 1 | |
198 | #define TIPC_ADDR_NAME 2 | |
199 | #define TIPC_ADDR_ID 3 | |
b97bf3fd PL |
200 | |
201 | struct sockaddr_tipc { | |
202 | unsigned short family; | |
203 | unsigned char addrtype; | |
204 | signed char scope; | |
205 | union { | |
206 | struct tipc_portid id; | |
207 | struct tipc_name_seq nameseq; | |
208 | struct { | |
209 | struct tipc_name name; | |
8e1c298c | 210 | __u32 domain; |
b97bf3fd PL |
211 | } name; |
212 | } addr; | |
213 | }; | |
214 | ||
215 | /* | |
216 | * Ancillary data objects supported by recvmsg() | |
217 | */ | |
218 | ||
219 | #define TIPC_ERRINFO 1 /* error info */ | |
220 | #define TIPC_RETDATA 2 /* returned data */ | |
221 | #define TIPC_DESTNAME 3 /* destination name */ | |
222 | ||
223 | /* | |
01fd12bb | 224 | * TIPC-specific socket option names |
b97bf3fd PL |
225 | */ |
226 | ||
227 | #define TIPC_IMPORTANCE 127 /* Default: TIPC_LOW_IMPORTANCE */ | |
8e1c298c | 228 | #define TIPC_SRC_DROPPABLE 128 /* Default: based on socket type */ |
b97bf3fd | 229 | #define TIPC_DEST_DROPPABLE 129 /* Default: based on socket type */ |
ea714ccd | 230 | #define TIPC_CONN_TIMEOUT 130 /* Default: 8000 (ms) */ |
6650613d | 231 | #define TIPC_NODE_RECVQ_DEPTH 131 /* Default: none (read only) */ |
232 | #define TIPC_SOCK_RECVQ_DEPTH 132 /* Default: none (read only) */ | |
01fd12bb JPM |
233 | #define TIPC_MCAST_BROADCAST 133 /* Default: TIPC selects. No arg */ |
234 | #define TIPC_MCAST_REPLICAST 134 /* Default: TIPC selects. No arg */ | |
b97bf3fd | 235 | |
78acb1f9 EH |
236 | /* |
237 | * Maximum sizes of TIPC bearer-related names (including terminating NULL) | |
238 | * The string formatting for each name element is: | |
239 | * media: media | |
240 | * interface: media:interface name | |
241 | * link: Z.C.N:interface-Z.C.N:interface | |
242 | * | |
243 | */ | |
244 | ||
245 | #define TIPC_MAX_MEDIA_NAME 16 | |
246 | #define TIPC_MAX_IF_NAME 16 | |
247 | #define TIPC_MAX_BEARER_NAME 32 | |
248 | #define TIPC_MAX_LINK_NAME 60 | |
249 | ||
250 | #define SIOCGETLINKNAME SIOCPROTOPRIVATE | |
251 | ||
252 | struct tipc_sioc_ln_req { | |
253 | __u32 peer; | |
254 | __u32 bearer_id; | |
255 | char linkname[TIPC_MAX_LINK_NAME]; | |
256 | }; | |
b97bf3fd | 257 | #endif |