1 /** 2 * D header file for Linux TIPC sockets. 3 * 4 * Copyright: Public Domain 5 * License: Public Domain 6 * Authors: Leandro Lucarella, based on the TIPC linux C header. 7 */ 8 9 module tango.sys.linux.tipc; 10 11 extern (C): 12 13 struct tipc_portid 14 { 15 uint ref_; 16 uint node; 17 } 18 19 struct tipc_name 20 { 21 uint type; 22 uint instance; 23 } 24 25 struct tipc_name_seq 26 { 27 uint type; 28 uint lower; 29 uint upper; 30 } 31 32 struct tipc_subscr 33 { 34 tipc_name_seq seq; 35 uint timeout; 36 uint filter; 37 ubyte[8] usr_handle; 38 } 39 40 struct tipc_event 41 { 42 uint event; 43 uint found_lower; 44 uint found_upper; 45 tipc_portid port; 46 tipc_subscr s; 47 } 48 49 struct sockaddr_tipc 50 { 51 ushort family; 52 ubyte addrtype; 53 byte scope_; 54 union Addr 55 { 56 tipc_portid id; 57 tipc_name_seq nameseq; 58 static struct Name 59 { 60 tipc_name name; 61 uint domain; 62 } 63 Name name; 64 } 65 Addr addr; 66 } 67 68 static uint tipc_addr(uint zone, uint cluster, uint node) 69 { 70 return (zone << 24) | (cluster << 12) | node; 71 } 72 73 unittest 74 { 75 assert (tipc_addr(0, 0, 0) == 0); 76 assert (tipc_addr(1, 1, 1) == 16781313); 77 assert (tipc_addr(2, 1, 27) == 33558555); 78 assert (tipc_addr(3, 1, 63) == 50335807); 79 } 80 81 static uint tipc_zone(uint addr) 82 { 83 return addr >> 24; 84 } 85 86 unittest 87 { 88 assert (tipc_zone(0u) == 0); 89 assert (tipc_zone(16781313u) == 1); 90 assert (tipc_zone(33558555u) == 2); 91 assert (tipc_zone(50335807u) == 3); 92 } 93 94 static uint tipc_cluster(uint addr) 95 { 96 return (addr >> 12) & 0xfff; 97 } 98 99 unittest 100 { 101 assert (tipc_cluster(0u) == 0); 102 assert (tipc_cluster(16781313u) == 1); 103 assert (tipc_cluster(33558555u) == 1); 104 assert (tipc_cluster(50335807u) == 1); 105 } 106 107 static uint tipc_node(uint addr) 108 { 109 return addr & 0xfff; 110 } 111 112 unittest 113 { 114 assert (tipc_node(0u) == 0); 115 assert (tipc_node(16781313u) == 1); 116 assert (tipc_node(33558555u) == 27); 117 assert (tipc_node(50335807u) == 63); 118 } 119 120 enum: int 121 { 122 TIPC_CFG_SRV = 0, 123 TIPC_TOP_SRV = 1, 124 TIPC_RESERVED_TYPES = 64, 125 } 126 127 enum: int 128 { 129 TIPC_ZONE_SCOPE = 1, 130 TIPC_CLUSTER_SCOPE = 2, 131 TIPC_NODE_SCOPE = 3, 132 } 133 134 enum: int 135 { 136 TIPC_MAX_USER_MSG_SIZE = 66000, 137 } 138 139 enum: int 140 { 141 TIPC_LOW_IMPORTANCE = 0, 142 TIPC_MEDIUM_IMPORTANCE = 1, 143 TIPC_HIGH_IMPORTANCE = 2, 144 TIPC_CRITICAL_IMPORTANCE = 3, 145 } 146 147 enum: int 148 { 149 TIPC_OK = 0, 150 TIPC_ERR_NO_NAME = 1, 151 TIPC_ERR_NO_PORT = 2, 152 TIPC_ERR_NO_NODE = 3, 153 TIPC_ERR_OVERLOAD = 4, 154 TIPC_CONN_SHUTDOWN = 5, 155 } 156 157 enum: int 158 { 159 TIPC_SUB_PORTS = 0x01, 160 TIPC_SUB_SERVICE = 0x02, 161 TIPC_SUB_CANCEL = 0x04, 162 } 163 164 // not implemented in the current TIPC version 165 version (none) enum: int 166 { 167 TIPC_SUB_NO_BIND_EVTS = 0x04, 168 TIPC_SUB_NO_UNBIND_EVTS = 0x08, 169 TIPC_SUB_SINGLE_EVT = 0x10, 170 } 171 172 enum: int 173 { 174 TIPC_WAIT_FOREVER = ~0, 175 } 176 177 enum: int 178 { 179 180 TIPC_PUBLISHED = 1, 181 TIPC_WITHDRAWN = 2, 182 TIPC_SUBSCR_TIMEOUT = 3, 183 } 184 185 enum: int 186 { 187 AF_TIPC = 30, 188 PF_TIPC = 30, 189 SOL_TIPC = 271, 190 TIPC_ADDR_NAMESEQ = 1, 191 TIPC_ADDR_MCAST = 1, 192 TIPC_ADDR_NAME = 2, 193 TIPC_ADDR_ID = 3, 194 } 195 196 enum: int 197 { 198 TIPC_ERRINFO = 1, 199 TIPC_RETDATA = 2, 200 TIPC_DESTNAME = 3, 201 } 202 203 enum: int 204 { 205 TIPC_IMPORTANCE = 127, 206 TIPC_SRC_DROPPABLE = 128, 207 TIPC_DEST_DROPPABLE = 129, 208 TIPC_CONN_TIMEOUT = 130, 209 }