blob: 4ecd0047550b315f5b0fd6daa13ec960b5eec87b [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 *
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
34#ifndef _LINUX_TIPC_H_
35#define _LINUX_TIPC_H_
36
37#include <linux/types.h>
Per Lidenb97bf3f2006-01-02 19:04:38 +010038
39/*
40 * TIPC addressing primitives
41 */
42
43struct tipc_portid {
44 __u32 ref;
45 __u32 node;
46};
47
48struct tipc_name {
49 __u32 type;
50 __u32 instance;
51};
52
53struct tipc_name_seq {
54 __u32 type;
55 __u32 lower;
56 __u32 upper;
57};
58
59static inline __u32 tipc_addr(unsigned int zone,
60 unsigned int cluster,
61 unsigned int node)
62{
Per Lidenea714cc2006-01-11 12:28:47 +010063 return (zone << 24) | (cluster << 12) | node;
Per Lidenb97bf3f2006-01-02 19:04:38 +010064}
65
66static inline unsigned int tipc_zone(__u32 addr)
67{
Per Lidenea714cc2006-01-11 12:28:47 +010068 return addr >> 24;
Per Lidenb97bf3f2006-01-02 19:04:38 +010069}
70
71static inline unsigned int tipc_cluster(__u32 addr)
72{
Per Lidenea714cc2006-01-11 12:28:47 +010073 return (addr >> 12) & 0xfff;
Per Lidenb97bf3f2006-01-02 19:04:38 +010074}
75
76static inline unsigned int tipc_node(__u32 addr)
77{
Per Lidenea714cc2006-01-11 12:28:47 +010078 return addr & 0xfff;
Per Lidenb97bf3f2006-01-02 19:04:38 +010079}
80
81/*
82 * Application-accessible port name types
83 */
84
Per Lidenea714cc2006-01-11 12:28:47 +010085#define TIPC_CFG_SRV 0 /* configuration service name type */
86#define TIPC_TOP_SRV 1 /* topology service name type */
Per Lidenb97bf3f2006-01-02 19:04:38 +010087#define TIPC_RESERVED_TYPES 64 /* lowest user-publishable name type */
88
89/*
90 * Publication scopes when binding port names and port name sequences
91 */
92
Per Lidenea714cc2006-01-11 12:28:47 +010093#define TIPC_ZONE_SCOPE 1
94#define TIPC_CLUSTER_SCOPE 2
95#define TIPC_NODE_SCOPE 3
Per Lidenb97bf3f2006-01-02 19:04:38 +010096
97/*
98 * Limiting values for messages
99 */
100
Per Lidenea714cc2006-01-11 12:28:47 +0100101#define TIPC_MAX_USER_MSG_SIZE 66000
Per Lidenb97bf3f2006-01-02 19:04:38 +0100102
Per Lidenea714cc2006-01-11 12:28:47 +0100103/*
Per Lidenb97bf3f2006-01-02 19:04:38 +0100104 * Message importance levels
105 */
106
Per Lidenea714cc2006-01-11 12:28:47 +0100107#define TIPC_LOW_IMPORTANCE 0 /* default */
Per Lidenb97bf3f2006-01-02 19:04:38 +0100108#define TIPC_MEDIUM_IMPORTANCE 1
109#define TIPC_HIGH_IMPORTANCE 2
110#define TIPC_CRITICAL_IMPORTANCE 3
111
112/*
113 * Msg rejection/connection shutdown reasons
114 */
115
116#define TIPC_OK 0
117#define TIPC_ERR_NO_NAME 1
118#define TIPC_ERR_NO_PORT 2
119#define TIPC_ERR_NO_NODE 3
120#define TIPC_ERR_OVERLOAD 4
121#define TIPC_CONN_SHUTDOWN 5
122
123/*
124 * TIPC topology subscription service definitions
125 */
126
127#define TIPC_SUB_PORTS 0x01 /* filter for port availability */
128#define TIPC_SUB_SERVICE 0x02 /* filter for service availability */
129#if 0
130/* The following filter options are not currently implemented */
131#define TIPC_SUB_NO_BIND_EVTS 0x04 /* filter out "publish" events */
132#define TIPC_SUB_NO_UNBIND_EVTS 0x08 /* filter out "withdraw" events */
133#define TIPC_SUB_SINGLE_EVT 0x10 /* expire after first event */
134#endif
135
Per Lidenea714cc2006-01-11 12:28:47 +0100136#define TIPC_WAIT_FOREVER ~0 /* timeout for permanent subscription */
Per Lidenb97bf3f2006-01-02 19:04:38 +0100137
138struct tipc_subscr {
139 struct tipc_name_seq seq; /* name sequence of interest */
140 __u32 timeout; /* subscription duration (in ms) */
141 __u32 filter; /* bitmask of filter options */
142 char usr_handle[8]; /* available for subscriber use */
143};
144
Per Lidenea714cc2006-01-11 12:28:47 +0100145#define TIPC_PUBLISHED 1 /* publication event */
146#define TIPC_WITHDRAWN 2 /* withdraw event */
147#define TIPC_SUBSCR_TIMEOUT 3 /* subscription timeout event */
Per Lidenb97bf3f2006-01-02 19:04:38 +0100148
149struct tipc_event {
150 __u32 event; /* event type */
151 __u32 found_lower; /* matching name seq instances */
152 __u32 found_upper; /* " " " " */
Per Lidenea714cc2006-01-11 12:28:47 +0100153 struct tipc_portid port; /* associated port */
Per Lidenb97bf3f2006-01-02 19:04:38 +0100154 struct tipc_subscr s; /* associated subscription */
155};
156
157/*
158 * Socket API
159 */
160
161#ifndef AF_TIPC
162#define AF_TIPC 30
163#endif
164
165#ifndef PF_TIPC
166#define PF_TIPC AF_TIPC
167#endif
168
169#ifndef SOL_TIPC
170#define SOL_TIPC 271
171#endif
172
Per Lidenea714cc2006-01-11 12:28:47 +0100173#define TIPC_ADDR_NAMESEQ 1
174#define TIPC_ADDR_MCAST 1
175#define TIPC_ADDR_NAME 2
176#define TIPC_ADDR_ID 3
Per Lidenb97bf3f2006-01-02 19:04:38 +0100177
178struct sockaddr_tipc {
179 unsigned short family;
180 unsigned char addrtype;
181 signed char scope;
182 union {
183 struct tipc_portid id;
184 struct tipc_name_seq nameseq;
185 struct {
186 struct tipc_name name;
187 __u32 domain; /* 0: own zone */
188 } name;
189 } addr;
190};
191
192/*
193 * Ancillary data objects supported by recvmsg()
194 */
195
196#define TIPC_ERRINFO 1 /* error info */
197#define TIPC_RETDATA 2 /* returned data */
198#define TIPC_DESTNAME 3 /* destination name */
199
200/*
201 * TIPC-specific socket option values
202 */
203
204#define TIPC_IMPORTANCE 127 /* Default: TIPC_LOW_IMPORTANCE */
205#define TIPC_SRC_DROPPABLE 128 /* Default: 0 (resend congested msg) */
206#define TIPC_DEST_DROPPABLE 129 /* Default: based on socket type */
Per Lidenea714cc2006-01-11 12:28:47 +0100207#define TIPC_CONN_TIMEOUT 130 /* Default: 8000 (ms) */
Per Lidenb97bf3f2006-01-02 19:04:38 +0100208
209#endif