tipc.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. /*
  2. * include/linux/tipc.h: Include file for TIPC socket interface
  3. *
  4. * Copyright (c) 2003-2005, Ericsson Research Canada
  5. * Copyright (c) 2005, Wind River Systems
  6. * Copyright (c) 2005-2006, Ericsson AB
  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. * Redistributions of source code must retain the above copyright notice, this
  13. * list of conditions and the following disclaimer.
  14. * Redistributions in binary form must reproduce the above copyright notice,
  15. * this list of conditions and the following disclaimer in the documentation
  16. * and/or other materials provided with the distribution.
  17. * Neither the names of the copyright holders nor the names of its
  18. * contributors may be used to endorse or promote products derived from this
  19. * software without specific prior written permission.
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  22. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  25. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  26. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  27. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  28. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  29. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  30. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  31. * POSSIBILITY OF SUCH DAMAGE.
  32. */
  33. #ifndef _LINUX_TIPC_H_
  34. #define _LINUX_TIPC_H_
  35. #include <linux/types.h>
  36. /*
  37. * TIPC addressing primitives
  38. */
  39. struct tipc_portid {
  40. __u32 ref;
  41. __u32 node;
  42. };
  43. struct tipc_name {
  44. __u32 type;
  45. __u32 instance;
  46. };
  47. struct tipc_name_seq {
  48. __u32 type;
  49. __u32 lower;
  50. __u32 upper;
  51. };
  52. static inline __u32 tipc_addr(unsigned int zone,
  53. unsigned int cluster,
  54. unsigned int node)
  55. {
  56. return (zone << 24) | (cluster << 12) | node;
  57. }
  58. static inline unsigned int tipc_zone(__u32 addr)
  59. {
  60. return addr >> 24;
  61. }
  62. static inline unsigned int tipc_cluster(__u32 addr)
  63. {
  64. return (addr >> 12) & 0xfff;
  65. }
  66. static inline unsigned int tipc_node(__u32 addr)
  67. {
  68. return addr & 0xfff;
  69. }
  70. /*
  71. * Application-accessible port name types
  72. */
  73. #define TIPC_CFG_SRV 0 /* configuration service name type */
  74. #define TIPC_TOP_SRV 1 /* topology service name type */
  75. #define TIPC_RESERVED_TYPES 64 /* lowest user-publishable name type */
  76. /*
  77. * Publication scopes when binding port names and port name sequences
  78. */
  79. #define TIPC_ZONE_SCOPE 1
  80. #define TIPC_CLUSTER_SCOPE 2
  81. #define TIPC_NODE_SCOPE 3
  82. /*
  83. * Limiting values for messages
  84. */
  85. #define TIPC_MAX_USER_MSG_SIZE 66000
  86. /*
  87. * Message importance levels
  88. */
  89. #define TIPC_LOW_IMPORTANCE 0 /* default */
  90. #define TIPC_MEDIUM_IMPORTANCE 1
  91. #define TIPC_HIGH_IMPORTANCE 2
  92. #define TIPC_CRITICAL_IMPORTANCE 3
  93. /*
  94. * Msg rejection/connection shutdown reasons
  95. */
  96. #define TIPC_OK 0
  97. #define TIPC_ERR_NO_NAME 1
  98. #define TIPC_ERR_NO_PORT 2
  99. #define TIPC_ERR_NO_NODE 3
  100. #define TIPC_ERR_OVERLOAD 4
  101. #define TIPC_CONN_SHUTDOWN 5
  102. /*
  103. * TIPC topology subscription service definitions
  104. */
  105. #define TIPC_SUB_PORTS 0x01 /* filter for port availability */
  106. #define TIPC_SUB_SERVICE 0x02 /* filter for service availability */
  107. #if 0
  108. /* The following filter options are not currently implemented */
  109. #define TIPC_SUB_NO_BIND_EVTS 0x04 /* filter out "publish" events */
  110. #define TIPC_SUB_NO_UNBIND_EVTS 0x08 /* filter out "withdraw" events */
  111. #define TIPC_SUB_SINGLE_EVT 0x10 /* expire after first event */
  112. #endif
  113. #define TIPC_WAIT_FOREVER ~0 /* timeout for permanent subscription */
  114. struct tipc_subscr {
  115. struct tipc_name_seq seq; /* name sequence of interest */
  116. __u32 timeout; /* subscription duration (in ms) */
  117. __u32 filter; /* bitmask of filter options */
  118. char usr_handle[8]; /* available for subscriber use */
  119. };
  120. #define TIPC_PUBLISHED 1 /* publication event */
  121. #define TIPC_WITHDRAWN 2 /* withdraw event */
  122. #define TIPC_SUBSCR_TIMEOUT 3 /* subscription timeout event */
  123. struct tipc_event {
  124. __u32 event; /* event type */
  125. __u32 found_lower; /* matching name seq instances */
  126. __u32 found_upper; /* " " " " */
  127. struct tipc_portid port; /* associated port */
  128. struct tipc_subscr s; /* associated subscription */
  129. };
  130. /*
  131. * Socket API
  132. */
  133. #ifndef AF_TIPC
  134. #define AF_TIPC 30
  135. #endif
  136. #ifndef PF_TIPC
  137. #define PF_TIPC AF_TIPC
  138. #endif
  139. #ifndef SOL_TIPC
  140. #define SOL_TIPC 271
  141. #endif
  142. #define TIPC_ADDR_NAMESEQ 1
  143. #define TIPC_ADDR_MCAST 1
  144. #define TIPC_ADDR_NAME 2
  145. #define TIPC_ADDR_ID 3
  146. struct sockaddr_tipc {
  147. unsigned short family;
  148. unsigned char addrtype;
  149. signed char scope;
  150. union {
  151. struct tipc_portid id;
  152. struct tipc_name_seq nameseq;
  153. struct {
  154. struct tipc_name name;
  155. __u32 domain; /* 0: own zone */
  156. } name;
  157. } addr;
  158. };
  159. /*
  160. * Ancillary data objects supported by recvmsg()
  161. */
  162. #define TIPC_ERRINFO 1 /* error info */
  163. #define TIPC_RETDATA 2 /* returned data */
  164. #define TIPC_DESTNAME 3 /* destination name */
  165. /*
  166. * TIPC-specific socket option values
  167. */
  168. #define TIPC_IMPORTANCE 127 /* Default: TIPC_LOW_IMPORTANCE */
  169. #define TIPC_SRC_DROPPABLE 128 /* Default: 0 (resend congested msg) */
  170. #define TIPC_DEST_DROPPABLE 129 /* Default: based on socket type */
  171. #define TIPC_CONN_TIMEOUT 130 /* Default: 8000 (ms) */
  172. #endif