blob: 14bacc7e6cef208b3cf1840022358d4403959a90 [file] [log] [blame]
Greg Kroah-Hartmane2be04c2017-11-01 15:09:13 +01001/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */
Per Lidenb97bf3f2006-01-02 19:04:38 +01002/*
Ying Xue8941bbc2013-06-17 10:54:36 -04003 * include/uapi/linux/tipc.h: Header for TIPC socket interface
Allan Stephens0e659672010-12-31 18:59:32 +00004 *
Jon Paul Maloy01fd12b2017-01-18 13:50:53 -05005 * Copyright (c) 2003-2006, 2015-2016 Ericsson AB
Allan Stephens77c81e02011-01-18 13:37:09 -05006 * Copyright (c) 2005, 2010-2011, Wind River Systems
Per Lidenb97bf3f2006-01-02 19:04:38 +01007 * All rights reserved.
8 *
Per Liden9ea1fd32006-01-11 13:30:43 +01009 * Redistribution and use in source and binary forms, with or without
Per Lidenb97bf3f2006-01-02 19:04:38 +010010 * modification, are permitted provided that the following conditions are met:
11 *
Per Liden9ea1fd32006-01-11 13:30:43 +010012 * 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.
Per Lidenb97bf3f2006-01-02 19:04:38 +010020 *
Per Liden9ea1fd32006-01-11 13:30:43 +010021 * 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
Per Lidenb97bf3f2006-01-02 19:04:38 +010035 * POSSIBILITY OF SUCH DAMAGE.
36 */
37
38#ifndef _LINUX_TIPC_H_
39#define _LINUX_TIPC_H_
40
41#include <linux/types.h>
Erik Hugne78acb1f2014-04-24 16:26:47 +020042#include <linux/sockios.h>
Per Lidenb97bf3f2006-01-02 19:04:38 +010043
44/*
45 * TIPC addressing primitives
46 */
Allan Stephens0e659672010-12-31 18:59:32 +000047
Per Lidenb97bf3f2006-01-02 19:04:38 +010048struct tipc_portid {
49 __u32 ref;
50 __u32 node;
51};
52
53struct tipc_name {
54 __u32 type;
55 __u32 instance;
56};
57
58struct tipc_name_seq {
59 __u32 type;
60 __u32 lower;
61 __u32 upper;
62};
63
Parthasarathy Bhuvaragan9ff26e92016-07-26 08:47:18 +020064/* 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
Per Lidenb97bf3f2006-01-02 19:04:38 +010084static inline __u32 tipc_addr(unsigned int zone,
85 unsigned int cluster,
86 unsigned int node)
87{
Parthasarathy Bhuvaragan9ff26e92016-07-26 08:47:18 +020088 return (zone << TIPC_ZONE_OFFSET) |
89 (cluster << TIPC_CLUSTER_OFFSET) |
90 node;
Per Lidenb97bf3f2006-01-02 19:04:38 +010091}
92
93static inline unsigned int tipc_zone(__u32 addr)
94{
Parthasarathy Bhuvaragan9ff26e92016-07-26 08:47:18 +020095 return addr >> TIPC_ZONE_OFFSET;
Per Lidenb97bf3f2006-01-02 19:04:38 +010096}
97
98static inline unsigned int tipc_cluster(__u32 addr)
99{
Parthasarathy Bhuvaragan9ff26e92016-07-26 08:47:18 +0200100 return (addr & TIPC_CLUSTER_MASK) >> TIPC_CLUSTER_OFFSET;
Per Lidenb97bf3f2006-01-02 19:04:38 +0100101}
102
103static inline unsigned int tipc_node(__u32 addr)
104{
Parthasarathy Bhuvaragan9ff26e92016-07-26 08:47:18 +0200105 return addr & TIPC_NODE_MASK;
Per Lidenb97bf3f2006-01-02 19:04:38 +0100106}
107
108/*
109 * Application-accessible port name types
110 */
111
Per Lidenea714cc2006-01-11 12:28:47 +0100112#define TIPC_CFG_SRV 0 /* configuration service name type */
113#define TIPC_TOP_SRV 1 /* topology service name type */
Erik Hugnea89778d2014-04-24 16:26:46 +0200114#define TIPC_LINK_STATE 2 /* link state name type */
Per Lidenb97bf3f2006-01-02 19:04:38 +0100115#define TIPC_RESERVED_TYPES 64 /* lowest user-publishable name type */
116
Allan Stephens0e659672010-12-31 18:59:32 +0000117/*
Per Lidenb97bf3f2006-01-02 19:04:38 +0100118 * Publication scopes when binding port names and port name sequences
119 */
Jon Maloy232d07b2018-01-08 21:03:30 +0100120#define TIPC_ZONE_SCOPE 1
121#define TIPC_CLUSTER_SCOPE 2
122#define TIPC_NODE_SCOPE 3
Per Lidenb97bf3f2006-01-02 19:04:38 +0100123
124/*
125 * Limiting values for messages
126 */
127
Allan Stephensc29c3f72010-04-20 17:58:24 -0400128#define TIPC_MAX_USER_MSG_SIZE 66000U
Per Lidenb97bf3f2006-01-02 19:04:38 +0100129
Per Lidenea714cc2006-01-11 12:28:47 +0100130/*
Per Lidenb97bf3f2006-01-02 19:04:38 +0100131 * Message importance levels
132 */
133
Allan Stephens8e1c2982010-05-11 14:30:09 +0000134#define TIPC_LOW_IMPORTANCE 0
Per Lidenb97bf3f2006-01-02 19:04:38 +0100135#define TIPC_MEDIUM_IMPORTANCE 1
136#define TIPC_HIGH_IMPORTANCE 2
137#define TIPC_CRITICAL_IMPORTANCE 3
138
Allan Stephens0e659672010-12-31 18:59:32 +0000139/*
Per Lidenb97bf3f2006-01-02 19:04:38 +0100140 * 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
Allan Stephens0e659672010-12-31 18:59:32 +0000154#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 */
Per Lidenb97bf3f2006-01-02 19:04:38 +0100157
Allan Stephens0e659672010-12-31 18:59:32 +0000158#define TIPC_WAIT_FOREVER (~0) /* timeout for permanent subscription */
Per Lidenb97bf3f2006-01-02 19:04:38 +0100159
160struct tipc_subscr {
Neil Horman8c974432010-10-21 01:06:15 +0000161 struct tipc_name_seq seq; /* name sequence of interest */
162 __u32 timeout; /* subscription duration (in ms) */
Allan Stephens0e659672010-12-31 18:59:32 +0000163 __u32 filter; /* bitmask of filter options */
Neil Horman8c974432010-10-21 01:06:15 +0000164 char usr_handle[8]; /* available for subscriber use */
Per Lidenb97bf3f2006-01-02 19:04:38 +0100165};
166
Per Lidenea714cc2006-01-11 12:28:47 +0100167#define TIPC_PUBLISHED 1 /* publication event */
168#define TIPC_WITHDRAWN 2 /* withdraw event */
169#define TIPC_SUBSCR_TIMEOUT 3 /* subscription timeout event */
Per Lidenb97bf3f2006-01-02 19:04:38 +0100170
171struct tipc_event {
Neil Horman8c974432010-10-21 01:06:15 +0000172 __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 */
Per Lidenb97bf3f2006-01-02 19:04:38 +0100177};
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
Per Lidenea714cc2006-01-11 12:28:47 +0100195#define TIPC_ADDR_NAMESEQ 1
196#define TIPC_ADDR_MCAST 1
197#define TIPC_ADDR_NAME 2
198#define TIPC_ADDR_ID 3
Per Lidenb97bf3f2006-01-02 19:04:38 +0100199
200struct 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;
Allan Stephens8e1c2982010-05-11 14:30:09 +0000209 __u32 domain;
Per Lidenb97bf3f2006-01-02 19:04:38 +0100210 } 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/*
Jon Paul Maloy01fd12b2017-01-18 13:50:53 -0500223 * TIPC-specific socket option names
Per Lidenb97bf3f2006-01-02 19:04:38 +0100224 */
225
226#define TIPC_IMPORTANCE 127 /* Default: TIPC_LOW_IMPORTANCE */
Allan Stephens8e1c2982010-05-11 14:30:09 +0000227#define TIPC_SRC_DROPPABLE 128 /* Default: based on socket type */
Per Lidenb97bf3f2006-01-02 19:04:38 +0100228#define TIPC_DEST_DROPPABLE 129 /* Default: based on socket type */
Per Lidenea714cc2006-01-11 12:28:47 +0100229#define TIPC_CONN_TIMEOUT 130 /* Default: 8000 (ms) */
oscar.medina@motorola.com66506132009-06-30 03:25:39 +0000230#define TIPC_NODE_RECVQ_DEPTH 131 /* Default: none (read only) */
231#define TIPC_SOCK_RECVQ_DEPTH 132 /* Default: none (read only) */
Jon Paul Maloy01fd12b2017-01-18 13:50:53 -0500232#define TIPC_MCAST_BROADCAST 133 /* Default: TIPC selects. No arg */
233#define TIPC_MCAST_REPLICAST 134 /* Default: TIPC selects. No arg */
Jon Maloy75da2162017-10-13 11:04:23 +0200234#define TIPC_GROUP_JOIN 135 /* Takes struct tipc_group_req* */
235#define TIPC_GROUP_LEAVE 136 /* No argument */
236
237/*
238 * Flag values
239 */
240#define TIPC_GROUP_LOOPBACK 0x1 /* Receive copy of sent msg when match */
Jon Maloyae236fb2017-10-13 11:04:25 +0200241#define TIPC_GROUP_MEMBER_EVTS 0x2 /* Receive membership events in socket */
Jon Maloy75da2162017-10-13 11:04:23 +0200242
243struct tipc_group_req {
244 __u32 type; /* group id */
245 __u32 instance; /* member id */
246 __u32 scope; /* zone/cluster/node */
247 __u32 flags;
248};
Per Lidenb97bf3f2006-01-02 19:04:38 +0100249
Erik Hugne78acb1f2014-04-24 16:26:47 +0200250/*
251 * Maximum sizes of TIPC bearer-related names (including terminating NULL)
252 * The string formatting for each name element is:
253 * media: media
254 * interface: media:interface name
255 * link: Z.C.N:interface-Z.C.N:interface
256 *
257 */
258
259#define TIPC_MAX_MEDIA_NAME 16
260#define TIPC_MAX_IF_NAME 16
261#define TIPC_MAX_BEARER_NAME 32
262#define TIPC_MAX_LINK_NAME 60
263
264#define SIOCGETLINKNAME SIOCPROTOPRIVATE
265
266struct tipc_sioc_ln_req {
267 __u32 peer;
268 __u32 bearer_id;
269 char linkname[TIPC_MAX_LINK_NAME];
270};
Per Lidenb97bf3f2006-01-02 19:04:38 +0100271#endif