blob: 243a15f54002445f5b8b4938981ec90430b73ec6 [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 *
Per Liden9da1c8b2006-01-11 18:40:41 +01004 * Copyright (c) 2003-2006, Ericsson AB
Per Lidenb97bf3f2006-01-02 19:04:38 +01005 * Copyright (c) 2005, Wind River Systems
Per Lidenb97bf3f2006-01-02 19:04:38 +01006 * All rights reserved.
7 *
Per Liden9ea1fd32006-01-11 13:30:43 +01008 * Redistribution and use in source and binary forms, with or without
Per Lidenb97bf3f2006-01-02 19:04:38 +01009 * modification, are permitted provided that the following conditions are met:
10 *
Per Liden9ea1fd32006-01-11 13:30:43 +010011 * 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.
Per Lidenb97bf3f2006-01-02 19:04:38 +010019 *
Per Liden9ea1fd32006-01-11 13:30:43 +010020 * 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
Per Lidenb97bf3f2006-01-02 19:04:38 +010034 * POSSIBILITY OF SUCH DAMAGE.
35 */
36
37#ifndef _LINUX_TIPC_H_
38#define _LINUX_TIPC_H_
39
40#include <linux/types.h>
Per Lidenb97bf3f2006-01-02 19:04:38 +010041
42/*
43 * TIPC addressing primitives
44 */
45
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{
Per Lidenea714cc2006-01-11 12:28:47 +010066 return (zone << 24) | (cluster << 12) | node;
Per Lidenb97bf3f2006-01-02 19:04:38 +010067}
68
69static inline unsigned int tipc_zone(__u32 addr)
70{
Per Lidenea714cc2006-01-11 12:28:47 +010071 return addr >> 24;
Per Lidenb97bf3f2006-01-02 19:04:38 +010072}
73
74static inline unsigned int tipc_cluster(__u32 addr)
75{
Per Lidenea714cc2006-01-11 12:28:47 +010076 return (addr >> 12) & 0xfff;
Per Lidenb97bf3f2006-01-02 19:04:38 +010077}
78
79static inline unsigned int tipc_node(__u32 addr)
80{
Per Lidenea714cc2006-01-11 12:28:47 +010081 return addr & 0xfff;
Per Lidenb97bf3f2006-01-02 19:04:38 +010082}
83
84/*
85 * Application-accessible port name types
86 */
87
Per Lidenea714cc2006-01-11 12:28:47 +010088#define TIPC_CFG_SRV 0 /* configuration service name type */
89#define TIPC_TOP_SRV 1 /* topology service name type */
Per Lidenb97bf3f2006-01-02 19:04:38 +010090#define TIPC_RESERVED_TYPES 64 /* lowest user-publishable name type */
91
92/*
93 * Publication scopes when binding port names and port name sequences
94 */
95
Per Lidenea714cc2006-01-11 12:28:47 +010096#define TIPC_ZONE_SCOPE 1
97#define TIPC_CLUSTER_SCOPE 2
98#define TIPC_NODE_SCOPE 3
Per Lidenb97bf3f2006-01-02 19:04:38 +010099
100/*
101 * Limiting values for messages
102 */
103
Per Lidenea714cc2006-01-11 12:28:47 +0100104#define TIPC_MAX_USER_MSG_SIZE 66000
Per Lidenb97bf3f2006-01-02 19:04:38 +0100105
Per Lidenea714cc2006-01-11 12:28:47 +0100106/*
Per Lidenb97bf3f2006-01-02 19:04:38 +0100107 * Message importance levels
108 */
109
Per Lidenea714cc2006-01-11 12:28:47 +0100110#define TIPC_LOW_IMPORTANCE 0 /* default */
Per Lidenb97bf3f2006-01-02 19:04:38 +0100111#define TIPC_MEDIUM_IMPORTANCE 1
112#define TIPC_HIGH_IMPORTANCE 2
113#define TIPC_CRITICAL_IMPORTANCE 3
114
115/*
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
130#define TIPC_SUB_PORTS 0x01 /* filter for port availability */
131#define TIPC_SUB_SERVICE 0x02 /* filter for service availability */
132#if 0
133/* The following filter options are not currently implemented */
134#define TIPC_SUB_NO_BIND_EVTS 0x04 /* filter out "publish" events */
135#define TIPC_SUB_NO_UNBIND_EVTS 0x08 /* filter out "withdraw" events */
136#define TIPC_SUB_SINGLE_EVT 0x10 /* expire after first event */
137#endif
138
Per Lidenea714cc2006-01-11 12:28:47 +0100139#define TIPC_WAIT_FOREVER ~0 /* timeout for permanent subscription */
Per Lidenb97bf3f2006-01-02 19:04:38 +0100140
141struct tipc_subscr {
142 struct tipc_name_seq seq; /* name sequence of interest */
143 __u32 timeout; /* subscription duration (in ms) */
144 __u32 filter; /* bitmask of filter options */
145 char usr_handle[8]; /* available for subscriber use */
146};
147
Per Lidenea714cc2006-01-11 12:28:47 +0100148#define TIPC_PUBLISHED 1 /* publication event */
149#define TIPC_WITHDRAWN 2 /* withdraw event */
150#define TIPC_SUBSCR_TIMEOUT 3 /* subscription timeout event */
Per Lidenb97bf3f2006-01-02 19:04:38 +0100151
152struct tipc_event {
153 __u32 event; /* event type */
154 __u32 found_lower; /* matching name seq instances */
155 __u32 found_upper; /* " " " " */
Per Lidenea714cc2006-01-11 12:28:47 +0100156 struct tipc_portid port; /* associated port */
Per Lidenb97bf3f2006-01-02 19:04:38 +0100157 struct tipc_subscr s; /* associated subscription */
158};
159
160/*
161 * Socket API
162 */
163
164#ifndef AF_TIPC
165#define AF_TIPC 30
166#endif
167
168#ifndef PF_TIPC
169#define PF_TIPC AF_TIPC
170#endif
171
172#ifndef SOL_TIPC
173#define SOL_TIPC 271
174#endif
175
Per Lidenea714cc2006-01-11 12:28:47 +0100176#define TIPC_ADDR_NAMESEQ 1
177#define TIPC_ADDR_MCAST 1
178#define TIPC_ADDR_NAME 2
179#define TIPC_ADDR_ID 3
Per Lidenb97bf3f2006-01-02 19:04:38 +0100180
181struct sockaddr_tipc {
182 unsigned short family;
183 unsigned char addrtype;
184 signed char scope;
185 union {
186 struct tipc_portid id;
187 struct tipc_name_seq nameseq;
188 struct {
189 struct tipc_name name;
190 __u32 domain; /* 0: own zone */
191 } name;
192 } addr;
193};
194
195/*
196 * Ancillary data objects supported by recvmsg()
197 */
198
199#define TIPC_ERRINFO 1 /* error info */
200#define TIPC_RETDATA 2 /* returned data */
201#define TIPC_DESTNAME 3 /* destination name */
202
203/*
204 * TIPC-specific socket option values
205 */
206
207#define TIPC_IMPORTANCE 127 /* Default: TIPC_LOW_IMPORTANCE */
208#define TIPC_SRC_DROPPABLE 128 /* Default: 0 (resend congested msg) */
209#define TIPC_DEST_DROPPABLE 129 /* Default: based on socket type */
Per Lidenea714cc2006-01-11 12:28:47 +0100210#define TIPC_CONN_TIMEOUT 130 /* Default: 8000 (ms) */
Per Lidenb97bf3f2006-01-02 19:04:38 +0100211
212#endif