Merge branch 'next' of git://git.monstr.eu/linux-2.6-microblaze
[linux-2.6-block.git] / include / linux / tipc.h
CommitLineData
b97bf3fd 1/*
ea714ccd 2 * include/linux/tipc.h: Include file for TIPC socket interface
0e65967e 3 *
9da1c8b6 4 * Copyright (c) 2003-2006, Ericsson AB
77c81e0b 5 * Copyright (c) 2005, 2010-2011, Wind River Systems
b97bf3fd
PL
6 * All rights reserved.
7 *
9ea1fd3c 8 * Redistribution and use in source and binary forms, with or without
b97bf3fd
PL
9 * modification, are permitted provided that the following conditions are met:
10 *
9ea1fd3c
PL
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.
b97bf3fd 19 *
9ea1fd3c
PL
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
b97bf3fd
PL
34 * POSSIBILITY OF SUCH DAMAGE.
35 */
36
37#ifndef _LINUX_TIPC_H_
38#define _LINUX_TIPC_H_
39
40#include <linux/types.h>
b97bf3fd
PL
41
42/*
43 * TIPC addressing primitives
44 */
0e65967e 45
b97bf3fd
PL
46struct tipc_portid {
47 __u32 ref;
48 __u32 node;
49};
50
51struct tipc_name {
52 __u32 type;
53 __u32 instance;
54};
55
56struct tipc_name_seq {
57 __u32 type;
58 __u32 lower;
59 __u32 upper;
60};
61
62static inline __u32 tipc_addr(unsigned int zone,
63 unsigned int cluster,
64 unsigned int node)
65{
ea714ccd 66 return (zone << 24) | (cluster << 12) | node;
b97bf3fd
PL
67}
68
69static inline unsigned int tipc_zone(__u32 addr)
70{
ea714ccd 71 return addr >> 24;
b97bf3fd
PL
72}
73
74static inline unsigned int tipc_cluster(__u32 addr)
75{
ea714ccd 76 return (addr >> 12) & 0xfff;
b97bf3fd
PL
77}
78
79static inline unsigned int tipc_node(__u32 addr)
80{
ea714ccd 81 return addr & 0xfff;
b97bf3fd
PL
82}
83
84/*
85 * Application-accessible port name types
86 */
87
ea714ccd
PL
88#define TIPC_CFG_SRV 0 /* configuration service name type */
89#define TIPC_TOP_SRV 1 /* topology service name type */
b97bf3fd
PL
90#define TIPC_RESERVED_TYPES 64 /* lowest user-publishable name type */
91
0e65967e 92/*
b97bf3fd
PL
93 * Publication scopes when binding port names and port name sequences
94 */
95
ea714ccd
PL
96#define TIPC_ZONE_SCOPE 1
97#define TIPC_CLUSTER_SCOPE 2
98#define TIPC_NODE_SCOPE 3
b97bf3fd
PL
99
100/*
101 * Limiting values for messages
102 */
103
c29c3f70 104#define TIPC_MAX_USER_MSG_SIZE 66000U
b97bf3fd 105
ea714ccd 106/*
b97bf3fd
PL
107 * Message importance levels
108 */
109
8e1c298c 110#define TIPC_LOW_IMPORTANCE 0
b97bf3fd
PL
111#define TIPC_MEDIUM_IMPORTANCE 1
112#define TIPC_HIGH_IMPORTANCE 2
113#define TIPC_CRITICAL_IMPORTANCE 3
114
0e65967e 115/*
b97bf3fd
PL
116 * Msg rejection/connection shutdown reasons
117 */
118
119#define TIPC_OK 0
120#define TIPC_ERR_NO_NAME 1
121#define TIPC_ERR_NO_PORT 2
122#define TIPC_ERR_NO_NODE 3
123#define TIPC_ERR_OVERLOAD 4
124#define TIPC_CONN_SHUTDOWN 5
125
126/*
127 * TIPC topology subscription service definitions
128 */
129
0e65967e
AS
130#define TIPC_SUB_PORTS 0x01 /* filter for port availability */
131#define TIPC_SUB_SERVICE 0x02 /* filter for service availability */
132#define TIPC_SUB_CANCEL 0x04 /* cancel a subscription */
b97bf3fd 133
0e65967e 134#define TIPC_WAIT_FOREVER (~0) /* timeout for permanent subscription */
b97bf3fd
PL
135
136struct tipc_subscr {
8c974438
NH
137 struct tipc_name_seq seq; /* name sequence of interest */
138 __u32 timeout; /* subscription duration (in ms) */
0e65967e 139 __u32 filter; /* bitmask of filter options */
8c974438 140 char usr_handle[8]; /* available for subscriber use */
b97bf3fd
PL
141};
142
ea714ccd
PL
143#define TIPC_PUBLISHED 1 /* publication event */
144#define TIPC_WITHDRAWN 2 /* withdraw event */
145#define TIPC_SUBSCR_TIMEOUT 3 /* subscription timeout event */
b97bf3fd
PL
146
147struct tipc_event {
8c974438
NH
148 __u32 event; /* event type */
149 __u32 found_lower; /* matching name seq instances */
150 __u32 found_upper; /* " " " " */
151 struct tipc_portid port; /* associated port */
152 struct tipc_subscr s; /* associated subscription */
b97bf3fd
PL
153};
154
155/*
156 * Socket API
157 */
158
159#ifndef AF_TIPC
160#define AF_TIPC 30
161#endif
162
163#ifndef PF_TIPC
164#define PF_TIPC AF_TIPC
165#endif
166
167#ifndef SOL_TIPC
168#define SOL_TIPC 271
169#endif
170
ea714ccd
PL
171#define TIPC_ADDR_NAMESEQ 1
172#define TIPC_ADDR_MCAST 1
173#define TIPC_ADDR_NAME 2
174#define TIPC_ADDR_ID 3
b97bf3fd
PL
175
176struct sockaddr_tipc {
177 unsigned short family;
178 unsigned char addrtype;
179 signed char scope;
180 union {
181 struct tipc_portid id;
182 struct tipc_name_seq nameseq;
183 struct {
184 struct tipc_name name;
8e1c298c 185 __u32 domain;
b97bf3fd
PL
186 } name;
187 } addr;
188};
189
190/*
191 * Ancillary data objects supported by recvmsg()
192 */
193
194#define TIPC_ERRINFO 1 /* error info */
195#define TIPC_RETDATA 2 /* returned data */
196#define TIPC_DESTNAME 3 /* destination name */
197
198/*
199 * TIPC-specific socket option values
200 */
201
202#define TIPC_IMPORTANCE 127 /* Default: TIPC_LOW_IMPORTANCE */
8e1c298c 203#define TIPC_SRC_DROPPABLE 128 /* Default: based on socket type */
b97bf3fd 204#define TIPC_DEST_DROPPABLE 129 /* Default: based on socket type */
ea714ccd 205#define TIPC_CONN_TIMEOUT 130 /* Default: 8000 (ms) */
6650613d 206#define TIPC_NODE_RECVQ_DEPTH 131 /* Default: none (read only) */
207#define TIPC_SOCK_RECVQ_DEPTH 132 /* Default: none (read only) */
b97bf3fd
PL
208
209#endif