tipc.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. /*
  2. * include/linux/tipc.h: Include file 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. /*
  40. * TIPC addressing primitives
  41. */
  42. struct tipc_portid {
  43. __u32 ref;
  44. __u32 node;
  45. };
  46. struct tipc_name {
  47. __u32 type;
  48. __u32 instance;
  49. };
  50. struct tipc_name_seq {
  51. __u32 type;
  52. __u32 lower;
  53. __u32 upper;
  54. };
  55. static inline __u32 tipc_addr(unsigned int zone,
  56. unsigned int cluster,
  57. unsigned int node)
  58. {
  59. return (zone << 24) | (cluster << 12) | node;
  60. }
  61. static inline unsigned int tipc_zone(__u32 addr)
  62. {
  63. return addr >> 24;
  64. }
  65. static inline unsigned int tipc_cluster(__u32 addr)
  66. {
  67. return (addr >> 12) & 0xfff;
  68. }
  69. static inline unsigned int tipc_node(__u32 addr)
  70. {
  71. return addr & 0xfff;
  72. }
  73. /*
  74. * Application-accessible port name types
  75. */
  76. #define TIPC_CFG_SRV 0 /* configuration service name type */
  77. #define TIPC_TOP_SRV 1 /* topology service name type */
  78. #define TIPC_RESERVED_TYPES 64 /* lowest user-publishable name type */
  79. /*
  80. * Publication scopes when binding port names and port name sequences
  81. */
  82. #define TIPC_ZONE_SCOPE 1
  83. #define TIPC_CLUSTER_SCOPE 2
  84. #define TIPC_NODE_SCOPE 3
  85. /*
  86. * Limiting values for messages
  87. */
  88. #define TIPC_MAX_USER_MSG_SIZE 66000U
  89. /*
  90. * Message importance levels
  91. */
  92. #define TIPC_LOW_IMPORTANCE 0
  93. #define TIPC_MEDIUM_IMPORTANCE 1
  94. #define TIPC_HIGH_IMPORTANCE 2
  95. #define TIPC_CRITICAL_IMPORTANCE 3
  96. /*
  97. * Msg rejection/connection shutdown reasons
  98. */
  99. #define TIPC_OK 0
  100. #define TIPC_ERR_NO_NAME 1
  101. #define TIPC_ERR_NO_PORT 2
  102. #define TIPC_ERR_NO_NODE 3
  103. #define TIPC_ERR_OVERLOAD 4
  104. #define TIPC_CONN_SHUTDOWN 5
  105. /*
  106. * TIPC topology subscription service definitions
  107. */
  108. #define TIPC_SUB_PORTS 0x01 /* filter for port availability */
  109. #define TIPC_SUB_SERVICE 0x02 /* filter for service availability */
  110. #define TIPC_SUB_CANCEL 0x04 /* cancel a subscription */
  111. #define TIPC_WAIT_FOREVER (~0) /* timeout for permanent subscription */
  112. struct tipc_subscr {
  113. struct tipc_name_seq seq; /* name sequence of interest */
  114. __u32 timeout; /* subscription duration (in ms) */
  115. __u32 filter; /* bitmask of filter options */
  116. char usr_handle[8]; /* available for subscriber use */
  117. };
  118. #define TIPC_PUBLISHED 1 /* publication event */
  119. #define TIPC_WITHDRAWN 2 /* withdraw event */
  120. #define TIPC_SUBSCR_TIMEOUT 3 /* subscription timeout event */
  121. struct tipc_event {
  122. __u32 event; /* event type */
  123. __u32 found_lower; /* matching name seq instances */
  124. __u32 found_upper; /* " " " " */
  125. struct tipc_portid port; /* associated port */
  126. struct tipc_subscr s; /* associated subscription */
  127. };
  128. /*
  129. * Socket API
  130. */
  131. #ifndef AF_TIPC
  132. #define AF_TIPC 30
  133. #endif
  134. #ifndef PF_TIPC
  135. #define PF_TIPC AF_TIPC
  136. #endif
  137. #ifndef SOL_TIPC
  138. #define SOL_TIPC 271
  139. #endif
  140. #define TIPC_ADDR_NAMESEQ 1
  141. #define TIPC_ADDR_MCAST 1
  142. #define TIPC_ADDR_NAME 2
  143. #define TIPC_ADDR_ID 3
  144. struct sockaddr_tipc {
  145. unsigned short family;
  146. unsigned char addrtype;
  147. signed char scope;
  148. union {
  149. struct tipc_portid id;
  150. struct tipc_name_seq nameseq;
  151. struct {
  152. struct tipc_name name;
  153. __u32 domain;
  154. } name;
  155. } addr;
  156. };
  157. /*
  158. * Ancillary data objects supported by recvmsg()
  159. */
  160. #define TIPC_ERRINFO 1 /* error info */
  161. #define TIPC_RETDATA 2 /* returned data */
  162. #define TIPC_DESTNAME 3 /* destination name */
  163. /*
  164. * TIPC-specific socket option values
  165. */
  166. #define TIPC_IMPORTANCE 127 /* Default: TIPC_LOW_IMPORTANCE */
  167. #define TIPC_SRC_DROPPABLE 128 /* Default: based on socket type */
  168. #define TIPC_DEST_DROPPABLE 129 /* Default: based on socket type */
  169. #define TIPC_CONN_TIMEOUT 130 /* Default: 8000 (ms) */
  170. #define TIPC_NODE_RECVQ_DEPTH 131 /* Default: none (read only) */
  171. #define TIPC_SOCK_RECVQ_DEPTH 132 /* Default: none (read only) */
  172. #endif