blob: ff109c1c14140654e4149a81ac7c4c1e11d13b40 [file] [log] [blame]
Per Lidenb97bf3f2006-01-02 19:04:38 +01001/*
Per Lidenea714cc2006-01-11 12:28:47 +01002 * include/linux/tipc.h: Include file for TIPC socket interface
Per Lidenb97bf3f2006-01-02 19:04:38 +01003 *
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 *
Per Liden9ea1fd32006-01-11 13:30:43 +01009 * Redistribution and use in source and binary forms, with or without
Per Lidenb97bf3f2006-01-02 19:04:38 +010010 * modification, are permitted provided that the following conditions are met:
11 *
Per Liden9ea1fd32006-01-11 13:30:43 +010012 * 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.
Per Lidenb97bf3f2006-01-02 19:04:38 +010020 *
Per Liden9ea1fd32006-01-11 13:30:43 +010021 * 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
Per Lidenb97bf3f2006-01-02 19:04:38 +010035 * POSSIBILITY OF SUCH DAMAGE.
36 */
37
38#ifndef _LINUX_TIPC_H_
39#define _LINUX_TIPC_H_
40
41#include <linux/types.h>
Per Lidenb97bf3f2006-01-02 19:04:38 +010042
43/*
44 * TIPC addressing primitives
45 */
46
47struct tipc_portid {
48 __u32 ref;
49 __u32 node;
50};
51
52struct tipc_name {
53 __u32 type;
54 __u32 instance;
55};
56
57struct tipc_name_seq {
58 __u32 type;
59 __u32 lower;
60 __u32 upper;
61};
62
63static inline __u32 tipc_addr(unsigned int zone,
64 unsigned int cluster,
65 unsigned int node)
66{
Per Lidenea714cc2006-01-11 12:28:47 +010067 return (zone << 24) | (cluster << 12) | node;
Per Lidenb97bf3f2006-01-02 19:04:38 +010068}
69
70static inline unsigned int tipc_zone(__u32 addr)
71{
Per Lidenea714cc2006-01-11 12:28:47 +010072 return addr >> 24;
Per Lidenb97bf3f2006-01-02 19:04:38 +010073}
74
75static inline unsigned int tipc_cluster(__u32 addr)
76{
Per Lidenea714cc2006-01-11 12:28:47 +010077 return (addr >> 12) & 0xfff;
Per Lidenb97bf3f2006-01-02 19:04:38 +010078}
79
80static inline unsigned int tipc_node(__u32 addr)
81{
Per Lidenea714cc2006-01-11 12:28:47 +010082 return addr & 0xfff;
Per Lidenb97bf3f2006-01-02 19:04:38 +010083}
84
85/*
86 * Application-accessible port name types
87 */
88
Per Lidenea714cc2006-01-11 12:28:47 +010089#define TIPC_CFG_SRV 0 /* configuration service name type */
90#define TIPC_TOP_SRV 1 /* topology service name type */
Per Lidenb97bf3f2006-01-02 19:04:38 +010091#define TIPC_RESERVED_TYPES 64 /* lowest user-publishable name type */
92
93/*
94 * Publication scopes when binding port names and port name sequences
95 */
96
Per Lidenea714cc2006-01-11 12:28:47 +010097#define TIPC_ZONE_SCOPE 1
98#define TIPC_CLUSTER_SCOPE 2
99#define TIPC_NODE_SCOPE 3
Per Lidenb97bf3f2006-01-02 19:04:38 +0100100
101/*
102 * Limiting values for messages
103 */
104
Per Lidenea714cc2006-01-11 12:28:47 +0100105#define TIPC_MAX_USER_MSG_SIZE 66000
Per Lidenb97bf3f2006-01-02 19:04:38 +0100106
Per Lidenea714cc2006-01-11 12:28:47 +0100107/*
Per Lidenb97bf3f2006-01-02 19:04:38 +0100108 * Message importance levels
109 */
110
Per Lidenea714cc2006-01-11 12:28:47 +0100111#define TIPC_LOW_IMPORTANCE 0 /* default */
Per Lidenb97bf3f2006-01-02 19:04:38 +0100112#define TIPC_MEDIUM_IMPORTANCE 1
113#define TIPC_HIGH_IMPORTANCE 2
114#define TIPC_CRITICAL_IMPORTANCE 3
115
116/*
117 * Msg rejection/connection shutdown reasons
118 */
119
120#define TIPC_OK 0
121#define TIPC_ERR_NO_NAME 1
122#define TIPC_ERR_NO_PORT 2
123#define TIPC_ERR_NO_NODE 3
124#define TIPC_ERR_OVERLOAD 4
125#define TIPC_CONN_SHUTDOWN 5
126
127/*
128 * TIPC topology subscription service definitions
129 */
130
131#define TIPC_SUB_PORTS 0x01 /* filter for port availability */
132#define TIPC_SUB_SERVICE 0x02 /* filter for service availability */
133#if 0
134/* The following filter options are not currently implemented */
135#define TIPC_SUB_NO_BIND_EVTS 0x04 /* filter out "publish" events */
136#define TIPC_SUB_NO_UNBIND_EVTS 0x08 /* filter out "withdraw" events */
137#define TIPC_SUB_SINGLE_EVT 0x10 /* expire after first event */
138#endif
139
Per Lidenea714cc2006-01-11 12:28:47 +0100140#define TIPC_WAIT_FOREVER ~0 /* timeout for permanent subscription */
Per Lidenb97bf3f2006-01-02 19:04:38 +0100141
142struct tipc_subscr {
143 struct tipc_name_seq seq; /* name sequence of interest */
144 __u32 timeout; /* subscription duration (in ms) */
145 __u32 filter; /* bitmask of filter options */
146 char usr_handle[8]; /* available for subscriber use */
147};
148
Per Lidenea714cc2006-01-11 12:28:47 +0100149#define TIPC_PUBLISHED 1 /* publication event */
150#define TIPC_WITHDRAWN 2 /* withdraw event */
151#define TIPC_SUBSCR_TIMEOUT 3 /* subscription timeout event */
Per Lidenb97bf3f2006-01-02 19:04:38 +0100152
153struct tipc_event {
154 __u32 event; /* event type */
155 __u32 found_lower; /* matching name seq instances */
156 __u32 found_upper; /* " " " " */
Per Lidenea714cc2006-01-11 12:28:47 +0100157 struct tipc_portid port; /* associated port */
Per Lidenb97bf3f2006-01-02 19:04:38 +0100158 struct tipc_subscr s; /* associated subscription */
159};
160
161/*
162 * Socket API
163 */
164
165#ifndef AF_TIPC
166#define AF_TIPC 30
167#endif
168
169#ifndef PF_TIPC
170#define PF_TIPC AF_TIPC
171#endif
172
173#ifndef SOL_TIPC
174#define SOL_TIPC 271
175#endif
176
Per Lidenea714cc2006-01-11 12:28:47 +0100177#define TIPC_ADDR_NAMESEQ 1
178#define TIPC_ADDR_MCAST 1
179#define TIPC_ADDR_NAME 2
180#define TIPC_ADDR_ID 3
Per Lidenb97bf3f2006-01-02 19:04:38 +0100181
182struct sockaddr_tipc {
183 unsigned short family;
184 unsigned char addrtype;
185 signed char scope;
186 union {
187 struct tipc_portid id;
188 struct tipc_name_seq nameseq;
189 struct {
190 struct tipc_name name;
191 __u32 domain; /* 0: own zone */
192 } name;
193 } addr;
194};
195
196/*
197 * Ancillary data objects supported by recvmsg()
198 */
199
200#define TIPC_ERRINFO 1 /* error info */
201#define TIPC_RETDATA 2 /* returned data */
202#define TIPC_DESTNAME 3 /* destination name */
203
204/*
205 * TIPC-specific socket option values
206 */
207
208#define TIPC_IMPORTANCE 127 /* Default: TIPC_LOW_IMPORTANCE */
209#define TIPC_SRC_DROPPABLE 128 /* Default: 0 (resend congested msg) */
210#define TIPC_DEST_DROPPABLE 129 /* Default: based on socket type */
Per Lidenea714cc2006-01-11 12:28:47 +0100211#define TIPC_CONN_TIMEOUT 130 /* Default: 8000 (ms) */
Per Lidenb97bf3f2006-01-02 19:04:38 +0100212
213#endif