diff options
author | Per Liden <per.liden@nospam.ericsson.com> | 2006-01-02 13:04:38 -0500 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2006-01-12 17:06:31 -0500 |
commit | b97bf3fd8f6a16966d4f18983b2c40993ff937d4 (patch) | |
tree | 59959f8a0f3087455efdcb430846686f303c5991 /include/net/tipc/tipc_msg.h | |
parent | 58cba4650a7a414eabd2b40cc9d8e45fcdf192d9 (diff) |
[TIPC] Initial merge
TIPC (Transparent Inter Process Communication) is a protocol designed for
intra cluster communication. For more information see
http://tipc.sourceforge.net
Signed-off-by: Per Liden <per.liden@nospam.ericsson.com>
Diffstat (limited to 'include/net/tipc/tipc_msg.h')
-rw-r--r-- | include/net/tipc/tipc_msg.h | 220 |
1 files changed, 220 insertions, 0 deletions
diff --git a/include/net/tipc/tipc_msg.h b/include/net/tipc/tipc_msg.h new file mode 100644 index 000000000000..78513f5236bb --- /dev/null +++ b/include/net/tipc/tipc_msg.h | |||
@@ -0,0 +1,220 @@ | |||
1 | /* | ||
2 | * include/net/tipc/tipc_msg.h: Include file for privileged access to TIPC message headers | ||
3 | * | ||
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 _NET_TIPC_MSG_H_ | ||
35 | #define _NET_TIPC_MSG_H_ | ||
36 | |||
37 | #ifdef __KERNEL__ | ||
38 | |||
39 | struct tipc_msg { | ||
40 | u32 hdr[15]; | ||
41 | }; | ||
42 | |||
43 | |||
44 | /* | ||
45 | TIPC user data message header format, version 2: | ||
46 | |||
47 | |||
48 | 1 0 9 8 7 6 5 4|3 2 1 0 9 8 7 6|5 4 3 2 1 0 9 8|7 6 5 4 3 2 1 0 | ||
49 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
50 | w0:|vers | user |hdr sz |n|d|s|-| message size | | ||
51 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
52 | w1:|mstyp| error |rer cnt|lsc|opt p| broadcast ack no | | ||
53 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
54 | w2:| link level ack no | broadcast/link level seq no | | ||
55 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
56 | w3:| previous node | | ||
57 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
58 | w4:| originating port | | ||
59 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
60 | w5:| destination port | | ||
61 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
62 | w6:| originating node | | ||
63 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
64 | w7:| destination node | | ||
65 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
66 | w8:| name type / transport sequence number | | ||
67 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
68 | w9:| name instance/multicast lower bound | | ||
69 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
70 | wA:| multicast upper bound | | ||
71 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
72 | / / | ||
73 | \ options \ | ||
74 | / / | ||
75 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
76 | |||
77 | */ | ||
78 | |||
79 | #define TIPC_CONN_MSG 0 | ||
80 | #define TIPC_MCAST_MSG 1 | ||
81 | #define TIPC_NAMED_MSG 2 | ||
82 | #define TIPC_DIRECT_MSG 3 | ||
83 | |||
84 | |||
85 | static inline u32 msg_word(struct tipc_msg *m, u32 pos) | ||
86 | { | ||
87 | return ntohl(m->hdr[pos]); | ||
88 | } | ||
89 | |||
90 | static inline u32 msg_bits(struct tipc_msg *m, u32 w, u32 pos, u32 mask) | ||
91 | { | ||
92 | return (msg_word(m, w) >> pos) & mask; | ||
93 | } | ||
94 | |||
95 | static inline u32 msg_importance(struct tipc_msg *m) | ||
96 | { | ||
97 | return msg_bits(m, 0, 25, 0xf); | ||
98 | } | ||
99 | |||
100 | static inline u32 msg_hdr_sz(struct tipc_msg *m) | ||
101 | { | ||
102 | return msg_bits(m, 0, 21, 0xf) << 2; | ||
103 | } | ||
104 | |||
105 | static inline int msg_short(struct tipc_msg *m) | ||
106 | { | ||
107 | return (msg_hdr_sz(m) == 24); | ||
108 | } | ||
109 | |||
110 | static inline u32 msg_size(struct tipc_msg *m) | ||
111 | { | ||
112 | return msg_bits(m, 0, 0, 0x1ffff); | ||
113 | } | ||
114 | |||
115 | static inline u32 msg_data_sz(struct tipc_msg *m) | ||
116 | { | ||
117 | return (msg_size(m) - msg_hdr_sz(m)); | ||
118 | } | ||
119 | |||
120 | static inline unchar *msg_data(struct tipc_msg *m) | ||
121 | { | ||
122 | return ((unchar *)m) + msg_hdr_sz(m); | ||
123 | } | ||
124 | |||
125 | static inline u32 msg_type(struct tipc_msg *m) | ||
126 | { | ||
127 | return msg_bits(m, 1, 29, 0x7); | ||
128 | } | ||
129 | |||
130 | static inline u32 msg_direct(struct tipc_msg *m) | ||
131 | { | ||
132 | return (msg_type(m) == TIPC_DIRECT_MSG); | ||
133 | } | ||
134 | |||
135 | static inline u32 msg_named(struct tipc_msg *m) | ||
136 | { | ||
137 | return (msg_type(m) == TIPC_NAMED_MSG); | ||
138 | } | ||
139 | |||
140 | static inline u32 msg_mcast(struct tipc_msg *m) | ||
141 | { | ||
142 | return (msg_type(m) == TIPC_MCAST_MSG); | ||
143 | } | ||
144 | |||
145 | static inline u32 msg_connected(struct tipc_msg *m) | ||
146 | { | ||
147 | return (msg_type(m) == TIPC_CONN_MSG); | ||
148 | } | ||
149 | |||
150 | static inline u32 msg_errcode(struct tipc_msg *m) | ||
151 | { | ||
152 | return msg_bits(m, 1, 25, 0xf); | ||
153 | } | ||
154 | |||
155 | static inline u32 msg_prevnode(struct tipc_msg *m) | ||
156 | { | ||
157 | return msg_word(m, 3); | ||
158 | } | ||
159 | |||
160 | static inline u32 msg_origport(struct tipc_msg *m) | ||
161 | { | ||
162 | return msg_word(m, 4); | ||
163 | } | ||
164 | |||
165 | static inline u32 msg_destport(struct tipc_msg *m) | ||
166 | { | ||
167 | return msg_word(m, 5); | ||
168 | } | ||
169 | |||
170 | static inline u32 msg_mc_netid(struct tipc_msg *m) | ||
171 | { | ||
172 | return msg_word(m, 5); | ||
173 | } | ||
174 | |||
175 | static inline u32 msg_orignode(struct tipc_msg *m) | ||
176 | { | ||
177 | if (likely(msg_short(m))) | ||
178 | return msg_prevnode(m); | ||
179 | return msg_word(m, 6); | ||
180 | } | ||
181 | |||
182 | static inline u32 msg_destnode(struct tipc_msg *m) | ||
183 | { | ||
184 | return msg_word(m, 7); | ||
185 | } | ||
186 | |||
187 | static inline u32 msg_nametype(struct tipc_msg *m) | ||
188 | { | ||
189 | return msg_word(m, 8); | ||
190 | } | ||
191 | |||
192 | static inline u32 msg_nameinst(struct tipc_msg *m) | ||
193 | { | ||
194 | return msg_word(m, 9); | ||
195 | } | ||
196 | |||
197 | static inline u32 msg_namelower(struct tipc_msg *m) | ||
198 | { | ||
199 | return msg_nameinst(m); | ||
200 | } | ||
201 | |||
202 | static inline u32 msg_nameupper(struct tipc_msg *m) | ||
203 | { | ||
204 | return msg_word(m, 10); | ||
205 | } | ||
206 | |||
207 | static inline char *msg_options(struct tipc_msg *m, u32 *len) | ||
208 | { | ||
209 | u32 pos = msg_bits(m, 1, 16, 0x7); | ||
210 | |||
211 | if (!pos) | ||
212 | return 0; | ||
213 | pos = (pos * 4) + 28; | ||
214 | *len = msg_hdr_sz(m) - pos; | ||
215 | return (char *)&m->hdr[pos/4]; | ||
216 | } | ||
217 | |||
218 | #endif | ||
219 | |||
220 | #endif | ||