tipc.h 6.8 KB

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