Greg Kroah-Hartman | e2be04c | 2017-11-01 15:09:13 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */ |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 2 | /* |
Ying Xue | 8941bbc | 2013-06-17 10:54:36 -0400 | [diff] [blame] | 3 | * include/uapi/linux/tipc.h: Header for TIPC socket interface |
Allan Stephens | 0e65967 | 2010-12-31 18:59:32 +0000 | [diff] [blame] | 4 | * |
Jon Paul Maloy | 01fd12b | 2017-01-18 13:50:53 -0500 | [diff] [blame] | 5 | * Copyright (c) 2003-2006, 2015-2016 Ericsson AB |
Allan Stephens | 77c81e0 | 2011-01-18 13:37:09 -0500 | [diff] [blame] | 6 | * Copyright (c) 2005, 2010-2011, Wind River Systems |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 7 | * All rights reserved. |
| 8 | * |
Per Liden | 9ea1fd3 | 2006-01-11 13:30:43 +0100 | [diff] [blame] | 9 | * Redistribution and use in source and binary forms, with or without |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 10 | * modification, are permitted provided that the following conditions are met: |
| 11 | * |
Per Liden | 9ea1fd3 | 2006-01-11 13:30:43 +0100 | [diff] [blame] | 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. |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 20 | * |
Per Liden | 9ea1fd3 | 2006-01-11 13:30:43 +0100 | [diff] [blame] | 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 |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 35 | * POSSIBILITY OF SUCH DAMAGE. |
| 36 | */ |
| 37 | |
| 38 | #ifndef _LINUX_TIPC_H_ |
| 39 | #define _LINUX_TIPC_H_ |
| 40 | |
| 41 | #include <linux/types.h> |
Erik Hugne | 78acb1f | 2014-04-24 16:26:47 +0200 | [diff] [blame] | 42 | #include <linux/sockios.h> |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 43 | |
| 44 | /* |
| 45 | * TIPC addressing primitives |
| 46 | */ |
Allan Stephens | 0e65967 | 2010-12-31 18:59:32 +0000 | [diff] [blame] | 47 | |
Jon Maloy | 7a74d39 | 2018-03-29 23:20:44 +0200 | [diff] [blame] | 48 | struct tipc_socket_addr { |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 49 | __u32 ref; |
| 50 | __u32 node; |
| 51 | }; |
| 52 | |
Jon Maloy | 7a74d39 | 2018-03-29 23:20:44 +0200 | [diff] [blame] | 53 | struct tipc_service_addr { |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 54 | __u32 type; |
| 55 | __u32 instance; |
| 56 | }; |
| 57 | |
Jon Maloy | 7a74d39 | 2018-03-29 23:20:44 +0200 | [diff] [blame] | 58 | struct tipc_service_range { |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 59 | __u32 type; |
| 60 | __u32 lower; |
| 61 | __u32 upper; |
| 62 | }; |
| 63 | |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 64 | /* |
Jon Maloy | 7a74d39 | 2018-03-29 23:20:44 +0200 | [diff] [blame] | 65 | * Application-accessible service types |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 66 | */ |
| 67 | |
Jon Maloy | 7a74d39 | 2018-03-29 23:20:44 +0200 | [diff] [blame] | 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 */ |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 72 | |
Allan Stephens | 0e65967 | 2010-12-31 18:59:32 +0000 | [diff] [blame] | 73 | /* |
Jon Maloy | 7a74d39 | 2018-03-29 23:20:44 +0200 | [diff] [blame] | 74 | * Publication scopes when binding service / service range |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 75 | */ |
Jon Maloy | 928df18 | 2018-03-15 16:48:51 +0100 | [diff] [blame] | 76 | enum tipc_scope { |
| 77 | TIPC_CLUSTER_SCOPE = 2, /* 0 can also be used */ |
| 78 | TIPC_NODE_SCOPE = 3 |
| 79 | }; |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 80 | |
| 81 | /* |
| 82 | * Limiting values for messages |
| 83 | */ |
| 84 | |
Allan Stephens | c29c3f7 | 2010-04-20 17:58:24 -0400 | [diff] [blame] | 85 | #define TIPC_MAX_USER_MSG_SIZE 66000U |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 86 | |
Per Liden | ea714cc | 2006-01-11 12:28:47 +0100 | [diff] [blame] | 87 | /* |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 88 | * Message importance levels |
| 89 | */ |
| 90 | |
Allan Stephens | 8e1c298 | 2010-05-11 14:30:09 +0000 | [diff] [blame] | 91 | #define TIPC_LOW_IMPORTANCE 0 |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 92 | #define TIPC_MEDIUM_IMPORTANCE 1 |
| 93 | #define TIPC_HIGH_IMPORTANCE 2 |
| 94 | #define TIPC_CRITICAL_IMPORTANCE 3 |
| 95 | |
Allan Stephens | 0e65967 | 2010-12-31 18:59:32 +0000 | [diff] [blame] | 96 | /* |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 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 | |
Jon Maloy | 7a74d39 | 2018-03-29 23:20:44 +0200 | [diff] [blame] | 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 */ |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 114 | |
Allan Stephens | 0e65967 | 2010-12-31 18:59:32 +0000 | [diff] [blame] | 115 | #define TIPC_WAIT_FOREVER (~0) /* timeout for permanent subscription */ |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 116 | |
| 117 | struct tipc_subscr { |
Jon Maloy | 7a74d39 | 2018-03-29 23:20:44 +0200 | [diff] [blame] | 118 | struct tipc_service_range seq; /* range of interest */ |
Neil Horman | 8c97443 | 2010-10-21 01:06:15 +0000 | [diff] [blame] | 119 | __u32 timeout; /* subscription duration (in ms) */ |
Allan Stephens | 0e65967 | 2010-12-31 18:59:32 +0000 | [diff] [blame] | 120 | __u32 filter; /* bitmask of filter options */ |
Neil Horman | 8c97443 | 2010-10-21 01:06:15 +0000 | [diff] [blame] | 121 | char usr_handle[8]; /* available for subscriber use */ |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 122 | }; |
| 123 | |
Per Liden | ea714cc | 2006-01-11 12:28:47 +0100 | [diff] [blame] | 124 | #define TIPC_PUBLISHED 1 /* publication event */ |
Jon Maloy | 7a74d39 | 2018-03-29 23:20:44 +0200 | [diff] [blame] | 125 | #define TIPC_WITHDRAWN 2 /* withdrawal event */ |
Per Liden | ea714cc | 2006-01-11 12:28:47 +0100 | [diff] [blame] | 126 | #define TIPC_SUBSCR_TIMEOUT 3 /* subscription timeout event */ |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 127 | |
| 128 | struct tipc_event { |
Neil Horman | 8c97443 | 2010-10-21 01:06:15 +0000 | [diff] [blame] | 129 | __u32 event; /* event type */ |
Jon Maloy | 7a74d39 | 2018-03-29 23:20:44 +0200 | [diff] [blame] | 130 | __u32 found_lower; /* matching range */ |
| 131 | __u32 found_upper; /* " " */ |
| 132 | struct tipc_socket_addr port; /* associated socket */ |
Neil Horman | 8c97443 | 2010-10-21 01:06:15 +0000 | [diff] [blame] | 133 | struct tipc_subscr s; /* associated subscription */ |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 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 | |
Jon Maloy | 7a74d39 | 2018-03-29 23:20:44 +0200 | [diff] [blame] | 152 | #define TIPC_ADDR_MCAST 1 |
| 153 | #define TIPC_SERVICE_RANGE 1 |
| 154 | #define TIPC_SERVICE_ADDR 2 |
| 155 | #define TIPC_SOCKET_ADDR 3 |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 156 | |
| 157 | struct sockaddr_tipc { |
| 158 | unsigned short family; |
| 159 | unsigned char addrtype; |
| 160 | signed char scope; |
| 161 | union { |
Jon Maloy | 7a74d39 | 2018-03-29 23:20:44 +0200 | [diff] [blame] | 162 | struct tipc_socket_addr id; |
| 163 | struct tipc_service_range nameseq; |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 164 | struct { |
Jon Maloy | 7a74d39 | 2018-03-29 23:20:44 +0200 | [diff] [blame] | 165 | struct tipc_service_addr name; |
Allan Stephens | 8e1c298 | 2010-05-11 14:30:09 +0000 | [diff] [blame] | 166 | __u32 domain; |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 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 | /* |
Jon Paul Maloy | 01fd12b | 2017-01-18 13:50:53 -0500 | [diff] [blame] | 180 | * TIPC-specific socket option names |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 181 | */ |
| 182 | |
| 183 | #define TIPC_IMPORTANCE 127 /* Default: TIPC_LOW_IMPORTANCE */ |
Allan Stephens | 8e1c298 | 2010-05-11 14:30:09 +0000 | [diff] [blame] | 184 | #define TIPC_SRC_DROPPABLE 128 /* Default: based on socket type */ |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 185 | #define TIPC_DEST_DROPPABLE 129 /* Default: based on socket type */ |
Per Liden | ea714cc | 2006-01-11 12:28:47 +0100 | [diff] [blame] | 186 | #define TIPC_CONN_TIMEOUT 130 /* Default: 8000 (ms) */ |
oscar.medina@motorola.com | 6650613 | 2009-06-30 03:25:39 +0000 | [diff] [blame] | 187 | #define TIPC_NODE_RECVQ_DEPTH 131 /* Default: none (read only) */ |
| 188 | #define TIPC_SOCK_RECVQ_DEPTH 132 /* Default: none (read only) */ |
Jon Paul Maloy | 01fd12b | 2017-01-18 13:50:53 -0500 | [diff] [blame] | 189 | #define TIPC_MCAST_BROADCAST 133 /* Default: TIPC selects. No arg */ |
| 190 | #define TIPC_MCAST_REPLICAST 134 /* Default: TIPC selects. No arg */ |
Jon Maloy | 75da216 | 2017-10-13 11:04:23 +0200 | [diff] [blame] | 191 | #define TIPC_GROUP_JOIN 135 /* Takes struct tipc_group_req* */ |
| 192 | #define TIPC_GROUP_LEAVE 136 /* No argument */ |
| 193 | |
| 194 | /* |
| 195 | * Flag values |
| 196 | */ |
| 197 | #define TIPC_GROUP_LOOPBACK 0x1 /* Receive copy of sent msg when match */ |
Jon Maloy | ae236fb | 2017-10-13 11:04:25 +0200 | [diff] [blame] | 198 | #define TIPC_GROUP_MEMBER_EVTS 0x2 /* Receive membership events in socket */ |
Jon Maloy | 75da216 | 2017-10-13 11:04:23 +0200 | [diff] [blame] | 199 | |
| 200 | struct tipc_group_req { |
| 201 | __u32 type; /* group id */ |
| 202 | __u32 instance; /* member id */ |
Jon Maloy | 928df18 | 2018-03-15 16:48:51 +0100 | [diff] [blame] | 203 | __u32 scope; /* cluster/node */ |
Jon Maloy | 75da216 | 2017-10-13 11:04:23 +0200 | [diff] [blame] | 204 | __u32 flags; |
| 205 | }; |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 206 | |
Erik Hugne | 78acb1f | 2014-04-24 16:26:47 +0200 | [diff] [blame] | 207 | /* |
| 208 | * Maximum sizes of TIPC bearer-related names (including terminating NULL) |
| 209 | * The string formatting for each name element is: |
| 210 | * media: media |
| 211 | * interface: media:interface name |
Jon Maloy | 3e5cf36 | 2018-04-25 19:29:36 +0200 | [diff] [blame] | 212 | * link: node:interface-node:interface |
Erik Hugne | 78acb1f | 2014-04-24 16:26:47 +0200 | [diff] [blame] | 213 | */ |
Jon Maloy | 3e5cf36 | 2018-04-25 19:29:36 +0200 | [diff] [blame] | 214 | #define TIPC_NODEID_LEN 16 |
Erik Hugne | 78acb1f | 2014-04-24 16:26:47 +0200 | [diff] [blame] | 215 | #define TIPC_MAX_MEDIA_NAME 16 |
| 216 | #define TIPC_MAX_IF_NAME 16 |
| 217 | #define TIPC_MAX_BEARER_NAME 32 |
Jon Maloy | 7494cfa | 2018-03-29 23:20:45 +0200 | [diff] [blame] | 218 | #define TIPC_MAX_LINK_NAME 68 |
Erik Hugne | 78acb1f | 2014-04-24 16:26:47 +0200 | [diff] [blame] | 219 | |
Jon Maloy | 3e5cf36 | 2018-04-25 19:29:36 +0200 | [diff] [blame] | 220 | #define SIOCGETLINKNAME SIOCPROTOPRIVATE |
| 221 | #define SIOCGETNODEID (SIOCPROTOPRIVATE + 1) |
Erik Hugne | 78acb1f | 2014-04-24 16:26:47 +0200 | [diff] [blame] | 222 | |
| 223 | struct tipc_sioc_ln_req { |
| 224 | __u32 peer; |
| 225 | __u32 bearer_id; |
| 226 | char linkname[TIPC_MAX_LINK_NAME]; |
| 227 | }; |
Jon Maloy | 928df18 | 2018-03-15 16:48:51 +0100 | [diff] [blame] | 228 | |
Jon Maloy | 3e5cf36 | 2018-04-25 19:29:36 +0200 | [diff] [blame] | 229 | struct tipc_sioc_nodeid_req { |
| 230 | __u32 peer; |
| 231 | char node_id[TIPC_NODEID_LEN]; |
| 232 | }; |
Jon Maloy | 928df18 | 2018-03-15 16:48:51 +0100 | [diff] [blame] | 233 | |
| 234 | /* The macros and functions below are deprecated: |
| 235 | */ |
| 236 | |
Jon Maloy | 7a74d39 | 2018-03-29 23:20:44 +0200 | [diff] [blame] | 237 | #define TIPC_CFG_SRV 0 |
Jon Maloy | 928df18 | 2018-03-15 16:48:51 +0100 | [diff] [blame] | 238 | #define TIPC_ZONE_SCOPE 1 |
| 239 | |
Jon Maloy | 7a74d39 | 2018-03-29 23:20:44 +0200 | [diff] [blame] | 240 | #define TIPC_ADDR_NAMESEQ 1 |
| 241 | #define TIPC_ADDR_NAME 2 |
| 242 | #define TIPC_ADDR_ID 3 |
| 243 | |
Jon Maloy | 928df18 | 2018-03-15 16:48:51 +0100 | [diff] [blame] | 244 | #define TIPC_NODE_BITS 12 |
| 245 | #define TIPC_CLUSTER_BITS 12 |
| 246 | #define TIPC_ZONE_BITS 8 |
| 247 | |
| 248 | #define TIPC_NODE_OFFSET 0 |
| 249 | #define TIPC_CLUSTER_OFFSET TIPC_NODE_BITS |
| 250 | #define TIPC_ZONE_OFFSET (TIPC_CLUSTER_OFFSET + TIPC_CLUSTER_BITS) |
| 251 | |
| 252 | #define TIPC_NODE_SIZE ((1UL << TIPC_NODE_BITS) - 1) |
| 253 | #define TIPC_CLUSTER_SIZE ((1UL << TIPC_CLUSTER_BITS) - 1) |
| 254 | #define TIPC_ZONE_SIZE ((1UL << TIPC_ZONE_BITS) - 1) |
| 255 | |
| 256 | #define TIPC_NODE_MASK (TIPC_NODE_SIZE << TIPC_NODE_OFFSET) |
| 257 | #define TIPC_CLUSTER_MASK (TIPC_CLUSTER_SIZE << TIPC_CLUSTER_OFFSET) |
| 258 | #define TIPC_ZONE_MASK (TIPC_ZONE_SIZE << TIPC_ZONE_OFFSET) |
| 259 | |
| 260 | #define TIPC_ZONE_CLUSTER_MASK (TIPC_ZONE_MASK | TIPC_CLUSTER_MASK) |
| 261 | |
Jon Maloy | 7a74d39 | 2018-03-29 23:20:44 +0200 | [diff] [blame] | 262 | #define tipc_portid tipc_socket_addr |
| 263 | #define tipc_name tipc_service_addr |
| 264 | #define tipc_name_seq tipc_service_range |
| 265 | |
Jon Maloy | 928df18 | 2018-03-15 16:48:51 +0100 | [diff] [blame] | 266 | static inline __u32 tipc_addr(unsigned int zone, |
| 267 | unsigned int cluster, |
| 268 | unsigned int node) |
| 269 | { |
| 270 | return (zone << TIPC_ZONE_OFFSET) | |
| 271 | (cluster << TIPC_CLUSTER_OFFSET) | |
| 272 | node; |
| 273 | } |
| 274 | |
| 275 | static inline unsigned int tipc_zone(__u32 addr) |
| 276 | { |
| 277 | return addr >> TIPC_ZONE_OFFSET; |
| 278 | } |
| 279 | |
| 280 | static inline unsigned int tipc_cluster(__u32 addr) |
| 281 | { |
| 282 | return (addr & TIPC_CLUSTER_MASK) >> TIPC_CLUSTER_OFFSET; |
| 283 | } |
| 284 | |
| 285 | static inline unsigned int tipc_node(__u32 addr) |
| 286 | { |
| 287 | return addr & TIPC_NODE_MASK; |
| 288 | } |
| 289 | |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 290 | #endif |