Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 1 | /* |
Ying Xue | 8941bbc | 2013-06-17 10:54:36 -0400 | [diff] [blame] | 2 | * include/uapi/linux/tipc.h: Header for TIPC socket interface |
Allan Stephens | 0e65967 | 2010-12-31 18:59:32 +0000 | [diff] [blame] | 3 | * |
Per Liden | 9da1c8b | 2006-01-11 18:40:41 +0100 | [diff] [blame] | 4 | * Copyright (c) 2003-2006, Ericsson AB |
Allan Stephens | 77c81e0 | 2011-01-18 13:37:09 -0500 | [diff] [blame] | 5 | * Copyright (c) 2005, 2010-2011, Wind River Systems |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 6 | * All rights reserved. |
| 7 | * |
Per Liden | 9ea1fd3 | 2006-01-11 13:30:43 +0100 | [diff] [blame] | 8 | * Redistribution and use in source and binary forms, with or without |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 9 | * modification, are permitted provided that the following conditions are met: |
| 10 | * |
Per Liden | 9ea1fd3 | 2006-01-11 13:30:43 +0100 | [diff] [blame] | 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. |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 19 | * |
Per Liden | 9ea1fd3 | 2006-01-11 13:30:43 +0100 | [diff] [blame] | 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 |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 34 | * POSSIBILITY OF SUCH DAMAGE. |
| 35 | */ |
| 36 | |
| 37 | #ifndef _LINUX_TIPC_H_ |
| 38 | #define _LINUX_TIPC_H_ |
| 39 | |
| 40 | #include <linux/types.h> |
Erik Hugne | 78acb1f | 2014-04-24 16:26:47 +0200 | [diff] [blame] | 41 | #include <linux/sockios.h> |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 42 | |
| 43 | /* |
| 44 | * TIPC addressing primitives |
| 45 | */ |
Allan Stephens | 0e65967 | 2010-12-31 18:59:32 +0000 | [diff] [blame] | 46 | |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 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 | |
| 63 | static inline __u32 tipc_addr(unsigned int zone, |
| 64 | unsigned int cluster, |
| 65 | unsigned int node) |
| 66 | { |
Per Liden | ea714cc | 2006-01-11 12:28:47 +0100 | [diff] [blame] | 67 | return (zone << 24) | (cluster << 12) | node; |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | static inline unsigned int tipc_zone(__u32 addr) |
| 71 | { |
Per Liden | ea714cc | 2006-01-11 12:28:47 +0100 | [diff] [blame] | 72 | return addr >> 24; |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | static inline unsigned int tipc_cluster(__u32 addr) |
| 76 | { |
Per Liden | ea714cc | 2006-01-11 12:28:47 +0100 | [diff] [blame] | 77 | return (addr >> 12) & 0xfff; |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | static inline unsigned int tipc_node(__u32 addr) |
| 81 | { |
Per Liden | ea714cc | 2006-01-11 12:28:47 +0100 | [diff] [blame] | 82 | return addr & 0xfff; |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | /* |
| 86 | * Application-accessible port name types |
| 87 | */ |
| 88 | |
Per Liden | ea714cc | 2006-01-11 12:28:47 +0100 | [diff] [blame] | 89 | #define TIPC_CFG_SRV 0 /* configuration service name type */ |
| 90 | #define TIPC_TOP_SRV 1 /* topology service name type */ |
Erik Hugne | a89778d | 2014-04-24 16:26:46 +0200 | [diff] [blame] | 91 | #define TIPC_LINK_STATE 2 /* link state name type */ |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 92 | #define TIPC_RESERVED_TYPES 64 /* lowest user-publishable name type */ |
| 93 | |
Allan Stephens | 0e65967 | 2010-12-31 18:59:32 +0000 | [diff] [blame] | 94 | /* |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 95 | * Publication scopes when binding port names and port name sequences |
| 96 | */ |
| 97 | |
Per Liden | ea714cc | 2006-01-11 12:28:47 +0100 | [diff] [blame] | 98 | #define TIPC_ZONE_SCOPE 1 |
| 99 | #define TIPC_CLUSTER_SCOPE 2 |
| 100 | #define TIPC_NODE_SCOPE 3 |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 101 | |
| 102 | /* |
| 103 | * Limiting values for messages |
| 104 | */ |
| 105 | |
Allan Stephens | c29c3f7 | 2010-04-20 17:58:24 -0400 | [diff] [blame] | 106 | #define TIPC_MAX_USER_MSG_SIZE 66000U |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 107 | |
Per Liden | ea714cc | 2006-01-11 12:28:47 +0100 | [diff] [blame] | 108 | /* |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 109 | * Message importance levels |
| 110 | */ |
| 111 | |
Allan Stephens | 8e1c298 | 2010-05-11 14:30:09 +0000 | [diff] [blame] | 112 | #define TIPC_LOW_IMPORTANCE 0 |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 113 | #define TIPC_MEDIUM_IMPORTANCE 1 |
| 114 | #define TIPC_HIGH_IMPORTANCE 2 |
| 115 | #define TIPC_CRITICAL_IMPORTANCE 3 |
| 116 | |
Allan Stephens | 0e65967 | 2010-12-31 18:59:32 +0000 | [diff] [blame] | 117 | /* |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 118 | * Msg rejection/connection shutdown reasons |
| 119 | */ |
| 120 | |
| 121 | #define TIPC_OK 0 |
| 122 | #define TIPC_ERR_NO_NAME 1 |
| 123 | #define TIPC_ERR_NO_PORT 2 |
| 124 | #define TIPC_ERR_NO_NODE 3 |
| 125 | #define TIPC_ERR_OVERLOAD 4 |
| 126 | #define TIPC_CONN_SHUTDOWN 5 |
| 127 | |
| 128 | /* |
| 129 | * TIPC topology subscription service definitions |
| 130 | */ |
| 131 | |
Allan Stephens | 0e65967 | 2010-12-31 18:59:32 +0000 | [diff] [blame] | 132 | #define TIPC_SUB_PORTS 0x01 /* filter for port availability */ |
| 133 | #define TIPC_SUB_SERVICE 0x02 /* filter for service availability */ |
| 134 | #define TIPC_SUB_CANCEL 0x04 /* cancel a subscription */ |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 135 | |
Allan Stephens | 0e65967 | 2010-12-31 18:59:32 +0000 | [diff] [blame] | 136 | #define TIPC_WAIT_FOREVER (~0) /* timeout for permanent subscription */ |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 137 | |
| 138 | struct tipc_subscr { |
Neil Horman | 8c97443 | 2010-10-21 01:06:15 +0000 | [diff] [blame] | 139 | struct tipc_name_seq seq; /* name sequence of interest */ |
| 140 | __u32 timeout; /* subscription duration (in ms) */ |
Allan Stephens | 0e65967 | 2010-12-31 18:59:32 +0000 | [diff] [blame] | 141 | __u32 filter; /* bitmask of filter options */ |
Neil Horman | 8c97443 | 2010-10-21 01:06:15 +0000 | [diff] [blame] | 142 | char usr_handle[8]; /* available for subscriber use */ |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 143 | }; |
| 144 | |
Per Liden | ea714cc | 2006-01-11 12:28:47 +0100 | [diff] [blame] | 145 | #define TIPC_PUBLISHED 1 /* publication event */ |
| 146 | #define TIPC_WITHDRAWN 2 /* withdraw event */ |
| 147 | #define TIPC_SUBSCR_TIMEOUT 3 /* subscription timeout event */ |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 148 | |
| 149 | struct tipc_event { |
Neil Horman | 8c97443 | 2010-10-21 01:06:15 +0000 | [diff] [blame] | 150 | __u32 event; /* event type */ |
| 151 | __u32 found_lower; /* matching name seq instances */ |
| 152 | __u32 found_upper; /* " " " " */ |
| 153 | struct tipc_portid port; /* associated port */ |
| 154 | struct tipc_subscr s; /* associated subscription */ |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 155 | }; |
| 156 | |
| 157 | /* |
| 158 | * Socket API |
| 159 | */ |
| 160 | |
| 161 | #ifndef AF_TIPC |
| 162 | #define AF_TIPC 30 |
| 163 | #endif |
| 164 | |
| 165 | #ifndef PF_TIPC |
| 166 | #define PF_TIPC AF_TIPC |
| 167 | #endif |
| 168 | |
| 169 | #ifndef SOL_TIPC |
| 170 | #define SOL_TIPC 271 |
| 171 | #endif |
| 172 | |
Per Liden | ea714cc | 2006-01-11 12:28:47 +0100 | [diff] [blame] | 173 | #define TIPC_ADDR_NAMESEQ 1 |
| 174 | #define TIPC_ADDR_MCAST 1 |
| 175 | #define TIPC_ADDR_NAME 2 |
| 176 | #define TIPC_ADDR_ID 3 |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 177 | |
| 178 | struct sockaddr_tipc { |
| 179 | unsigned short family; |
| 180 | unsigned char addrtype; |
| 181 | signed char scope; |
| 182 | union { |
| 183 | struct tipc_portid id; |
| 184 | struct tipc_name_seq nameseq; |
| 185 | struct { |
| 186 | struct tipc_name name; |
Allan Stephens | 8e1c298 | 2010-05-11 14:30:09 +0000 | [diff] [blame] | 187 | __u32 domain; |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 188 | } name; |
| 189 | } addr; |
| 190 | }; |
| 191 | |
| 192 | /* |
| 193 | * Ancillary data objects supported by recvmsg() |
| 194 | */ |
| 195 | |
| 196 | #define TIPC_ERRINFO 1 /* error info */ |
| 197 | #define TIPC_RETDATA 2 /* returned data */ |
| 198 | #define TIPC_DESTNAME 3 /* destination name */ |
| 199 | |
| 200 | /* |
| 201 | * TIPC-specific socket option values |
| 202 | */ |
| 203 | |
| 204 | #define TIPC_IMPORTANCE 127 /* Default: TIPC_LOW_IMPORTANCE */ |
Allan Stephens | 8e1c298 | 2010-05-11 14:30:09 +0000 | [diff] [blame] | 205 | #define TIPC_SRC_DROPPABLE 128 /* Default: based on socket type */ |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 206 | #define TIPC_DEST_DROPPABLE 129 /* Default: based on socket type */ |
Per Liden | ea714cc | 2006-01-11 12:28:47 +0100 | [diff] [blame] | 207 | #define TIPC_CONN_TIMEOUT 130 /* Default: 8000 (ms) */ |
oscar.medina@motorola.com | 6650613 | 2009-06-30 03:25:39 +0000 | [diff] [blame] | 208 | #define TIPC_NODE_RECVQ_DEPTH 131 /* Default: none (read only) */ |
| 209 | #define TIPC_SOCK_RECVQ_DEPTH 132 /* Default: none (read only) */ |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 210 | |
Erik Hugne | 78acb1f | 2014-04-24 16:26:47 +0200 | [diff] [blame] | 211 | /* |
| 212 | * Maximum sizes of TIPC bearer-related names (including terminating NULL) |
| 213 | * The string formatting for each name element is: |
| 214 | * media: media |
| 215 | * interface: media:interface name |
| 216 | * link: Z.C.N:interface-Z.C.N:interface |
| 217 | * |
| 218 | */ |
| 219 | |
| 220 | #define TIPC_MAX_MEDIA_NAME 16 |
| 221 | #define TIPC_MAX_IF_NAME 16 |
| 222 | #define TIPC_MAX_BEARER_NAME 32 |
| 223 | #define TIPC_MAX_LINK_NAME 60 |
| 224 | |
| 225 | #define SIOCGETLINKNAME SIOCPROTOPRIVATE |
| 226 | |
| 227 | struct tipc_sioc_ln_req { |
| 228 | __u32 peer; |
| 229 | __u32 bearer_id; |
| 230 | char linkname[TIPC_MAX_LINK_NAME]; |
| 231 | }; |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 232 | #endif |