tipc.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. /* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */
  2. /*
  3. * include/uapi/linux/tipc.h: Header for TIPC socket interface
  4. *
  5. * Copyright (c) 2003-2006, 2015-2016 Ericsson AB
  6. * Copyright (c) 2005, 2010-2011, Wind River Systems
  7. * All rights reserved.
  8. *
  9. * Redistribution and use in source and binary forms, with or without
  10. * modification, are permitted provided that the following conditions are met:
  11. *
  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.
  20. *
  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
  35. * POSSIBILITY OF SUCH DAMAGE.
  36. */
  37. #ifndef _LINUX_TIPC_H_
  38. #define _LINUX_TIPC_H_
  39. #include <linux/types.h>
  40. #include <linux/sockios.h>
  41. /*
  42. * TIPC addressing primitives
  43. */
  44. struct tipc_portid {
  45. __u32 ref;
  46. __u32 node;
  47. };
  48. struct tipc_name {
  49. __u32 type;
  50. __u32 instance;
  51. };
  52. struct tipc_name_seq {
  53. __u32 type;
  54. __u32 lower;
  55. __u32 upper;
  56. };
  57. /* TIPC Address Size, Offset, Mask specification for Z.C.N
  58. */
  59. #define TIPC_NODE_BITS 12
  60. #define TIPC_CLUSTER_BITS 12
  61. #define TIPC_ZONE_BITS 8
  62. #define TIPC_NODE_OFFSET 0
  63. #define TIPC_CLUSTER_OFFSET TIPC_NODE_BITS
  64. #define TIPC_ZONE_OFFSET (TIPC_CLUSTER_OFFSET + TIPC_CLUSTER_BITS)
  65. #define TIPC_NODE_SIZE ((1UL << TIPC_NODE_BITS) - 1)
  66. #define TIPC_CLUSTER_SIZE ((1UL << TIPC_CLUSTER_BITS) - 1)
  67. #define TIPC_ZONE_SIZE ((1UL << TIPC_ZONE_BITS) - 1)
  68. #define TIPC_NODE_MASK (TIPC_NODE_SIZE << TIPC_NODE_OFFSET)
  69. #define TIPC_CLUSTER_MASK (TIPC_CLUSTER_SIZE << TIPC_CLUSTER_OFFSET)
  70. #define TIPC_ZONE_MASK (TIPC_ZONE_SIZE << TIPC_ZONE_OFFSET)
  71. #define TIPC_ZONE_CLUSTER_MASK (TIPC_ZONE_MASK | TIPC_CLUSTER_MASK)
  72. static inline __u32 tipc_addr(unsigned int zone,
  73. unsigned int cluster,
  74. unsigned int node)
  75. {
  76. return (zone << TIPC_ZONE_OFFSET) |
  77. (cluster << TIPC_CLUSTER_OFFSET) |
  78. node;
  79. }
  80. static inline unsigned int tipc_zone(__u32 addr)
  81. {
  82. return addr >> TIPC_ZONE_OFFSET;
  83. }
  84. static inline unsigned int tipc_cluster(__u32 addr)
  85. {
  86. return (addr & TIPC_CLUSTER_MASK) >> TIPC_CLUSTER_OFFSET;
  87. }
  88. static inline unsigned int tipc_node(__u32 addr)
  89. {
  90. return addr & TIPC_NODE_MASK;
  91. }
  92. /*
  93. * Application-accessible port name types
  94. */
  95. #define TIPC_CFG_SRV 0 /* configuration service name type */
  96. #define TIPC_TOP_SRV 1 /* topology service name type */
  97. #define TIPC_LINK_STATE 2 /* link state name type */
  98. #define TIPC_RESERVED_TYPES 64 /* lowest user-publishable name type */
  99. /*
  100. * Publication scopes when binding port names and port name sequences
  101. */
  102. #define TIPC_ZONE_SCOPE 1
  103. #define TIPC_CLUSTER_SCOPE 2
  104. #define TIPC_NODE_SCOPE 3
  105. /*
  106. * Limiting values for messages
  107. */
  108. #define TIPC_MAX_USER_MSG_SIZE 66000U
  109. /*
  110. * Message importance levels
  111. */
  112. #define TIPC_LOW_IMPORTANCE 0
  113. #define TIPC_MEDIUM_IMPORTANCE 1
  114. #define TIPC_HIGH_IMPORTANCE 2
  115. #define TIPC_CRITICAL_IMPORTANCE 3
  116. /*
  117. * Msg rejection/connection shutdown reasons
  118. */
  119. #define TIPC_OK 0
  120. #define TIPC_ERR_NO_NAME 1
  121. #define TIPC_ERR_NO_PORT 2
  122. #define TIPC_ERR_NO_NODE 3
  123. #define TIPC_ERR_OVERLOAD 4
  124. #define TIPC_CONN_SHUTDOWN 5
  125. /*
  126. * TIPC topology subscription service definitions
  127. */
  128. #define TIPC_SUB_PORTS 0x01 /* filter for port availability */
  129. #define TIPC_SUB_SERVICE 0x02 /* filter for service availability */
  130. #define TIPC_SUB_CANCEL 0x04 /* cancel a subscription */
  131. #define TIPC_WAIT_FOREVER (~0) /* timeout for permanent subscription */
  132. struct tipc_subscr {
  133. struct tipc_name_seq seq; /* name sequence of interest */
  134. __u32 timeout; /* subscription duration (in ms) */
  135. __u32 filter; /* bitmask of filter options */
  136. char usr_handle[8]; /* available for subscriber use */
  137. };
  138. #define TIPC_PUBLISHED 1 /* publication event */
  139. #define TIPC_WITHDRAWN 2 /* withdraw event */
  140. #define TIPC_SUBSCR_TIMEOUT 3 /* subscription timeout event */
  141. struct tipc_event {
  142. __u32 event; /* event type */
  143. __u32 found_lower; /* matching name seq instances */
  144. __u32 found_upper; /* " " " " */
  145. struct tipc_portid port; /* associated port */
  146. struct tipc_subscr s; /* associated subscription */
  147. };
  148. /*
  149. * Socket API
  150. */
  151. #ifndef AF_TIPC
  152. #define AF_TIPC 30
  153. #endif
  154. #ifndef PF_TIPC
  155. #define PF_TIPC AF_TIPC
  156. #endif
  157. #ifndef SOL_TIPC
  158. #define SOL_TIPC 271
  159. #endif
  160. #define TIPC_ADDR_NAMESEQ 1
  161. #define TIPC_ADDR_MCAST 1
  162. #define TIPC_ADDR_NAME 2
  163. #define TIPC_ADDR_ID 3
  164. struct sockaddr_tipc {
  165. unsigned short family;
  166. unsigned char addrtype;
  167. signed char scope;
  168. union {
  169. struct tipc_portid id;
  170. struct tipc_name_seq nameseq;
  171. struct {
  172. struct tipc_name name;
  173. __u32 domain;
  174. } name;
  175. } addr;
  176. };
  177. /*
  178. * Ancillary data objects supported by recvmsg()
  179. */
  180. #define TIPC_ERRINFO 1 /* error info */
  181. #define TIPC_RETDATA 2 /* returned data */
  182. #define TIPC_DESTNAME 3 /* destination name */
  183. /*
  184. * TIPC-specific socket option names
  185. */
  186. #define TIPC_IMPORTANCE 127 /* Default: TIPC_LOW_IMPORTANCE */
  187. #define TIPC_SRC_DROPPABLE 128 /* Default: based on socket type */
  188. #define TIPC_DEST_DROPPABLE 129 /* Default: based on socket type */
  189. #define TIPC_CONN_TIMEOUT 130 /* Default: 8000 (ms) */
  190. #define TIPC_NODE_RECVQ_DEPTH 131 /* Default: none (read only) */
  191. #define TIPC_SOCK_RECVQ_DEPTH 132 /* Default: none (read only) */
  192. #define TIPC_MCAST_BROADCAST 133 /* Default: TIPC selects. No arg */
  193. #define TIPC_MCAST_REPLICAST 134 /* Default: TIPC selects. No arg */
  194. /*
  195. * Maximum sizes of TIPC bearer-related names (including terminating NULL)
  196. * The string formatting for each name element is:
  197. * media: media
  198. * interface: media:interface name
  199. * link: Z.C.N:interface-Z.C.N:interface
  200. *
  201. */
  202. #define TIPC_MAX_MEDIA_NAME 16
  203. #define TIPC_MAX_IF_NAME 16
  204. #define TIPC_MAX_BEARER_NAME 32
  205. #define TIPC_MAX_LINK_NAME 60
  206. #define SIOCGETLINKNAME SIOCPROTOPRIVATE
  207. struct tipc_sioc_ln_req {
  208. __u32 peer;
  209. __u32 bearer_id;
  210. char linkname[TIPC_MAX_LINK_NAME];
  211. };
  212. #endif