1 | /*
|
---|
2 | * Copyright (c) 2009 Lukas Mejdrech
|
---|
3 | * All rights reserved.
|
---|
4 | *
|
---|
5 | * Redistribution and use in source and binary forms, with or without
|
---|
6 | * modification, are permitted provided that the following conditions
|
---|
7 | * are met:
|
---|
8 | *
|
---|
9 | * - Redistributions of source code must retain the above copyright
|
---|
10 | * notice, this list of conditions and the following disclaimer.
|
---|
11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
12 | * notice, this list of conditions and the following disclaimer in the
|
---|
13 | * documentation and/or other materials provided with the distribution.
|
---|
14 | * - The name of the author may not be used to endorse or promote products
|
---|
15 | * derived from this software without specific prior written permission.
|
---|
16 | *
|
---|
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
27 | */
|
---|
28 |
|
---|
29 | /** @addtogroup libcipc
|
---|
30 | * @{
|
---|
31 | */
|
---|
32 |
|
---|
33 | /** @file
|
---|
34 | * Networking common message definitions.
|
---|
35 | */
|
---|
36 |
|
---|
37 | #ifndef LIBC_NET_MESSAGES_H_
|
---|
38 | #define LIBC_NET_MESSAGES_H_
|
---|
39 |
|
---|
40 | #include <ipc/ipc.h>
|
---|
41 | #include <ipc/services.h>
|
---|
42 |
|
---|
43 | #include <net/device.h>
|
---|
44 | #include <net/packet.h>
|
---|
45 |
|
---|
46 | /** Returns a value indicating whether the value is in the interval.
|
---|
47 | * @param[in] item The value to be checked.
|
---|
48 | * @param[in] first_inclusive The first value in the interval inclusive.
|
---|
49 | * @param[in] last_exclusive The first value after the interval.
|
---|
50 | */
|
---|
51 | #define IS_IN_INTERVAL(item, first_inclusive, last_exclusive) \
|
---|
52 | (((item) >= (first_inclusive)) && ((item) < (last_exclusive)))
|
---|
53 |
|
---|
54 | /** @name Networking message counts */
|
---|
55 | /*@{*/
|
---|
56 |
|
---|
57 | /** The number of ARP messages. */
|
---|
58 | #define NET_ARP_COUNT 5
|
---|
59 |
|
---|
60 | /** The number of Ethernet messages. */
|
---|
61 | #define NET_ETH_COUNT 0
|
---|
62 |
|
---|
63 | /** The number of ICMP messages. */
|
---|
64 | #define NET_ICMP_COUNT 6
|
---|
65 |
|
---|
66 | /** The number of inter-network messages. */
|
---|
67 | #define NET_IL_COUNT 6
|
---|
68 |
|
---|
69 | /** The number of IP messages. */
|
---|
70 | #define NET_IP_COUNT 4
|
---|
71 |
|
---|
72 | /** The number of general networking messages. */
|
---|
73 | #define NET_NET_COUNT 3
|
---|
74 |
|
---|
75 | /** The number of network interface driver messages. */
|
---|
76 | #define NET_NETIF_COUNT 6
|
---|
77 |
|
---|
78 | /** The number of network interface layer messages. */
|
---|
79 | #define NET_NIL_COUNT 7
|
---|
80 |
|
---|
81 | /** The number of packet management system messages. */
|
---|
82 | #define NET_PACKET_COUNT 5
|
---|
83 |
|
---|
84 | /** The number of socket messages. */
|
---|
85 | #define NET_SOCKET_COUNT 14
|
---|
86 |
|
---|
87 | /** The number of TCP messages. */
|
---|
88 | #define NET_TCP_COUNT 0
|
---|
89 |
|
---|
90 | /** The number of transport layer messages. */
|
---|
91 | #define NET_TL_COUNT 1
|
---|
92 |
|
---|
93 | /** The number of UDP messages. */
|
---|
94 | #define NET_UDP_COUNT 0
|
---|
95 |
|
---|
96 | /*@}*/
|
---|
97 |
|
---|
98 | /** @name Networking message intervals
|
---|
99 | */
|
---|
100 | /*@{*/
|
---|
101 |
|
---|
102 | /** The first networking message. */
|
---|
103 | #define NET_FIRST 2000
|
---|
104 |
|
---|
105 | /** The first network interface layer message. */
|
---|
106 | #define NET_NETIF_FIRST NET_FIRST
|
---|
107 |
|
---|
108 | /** The last network interface layer message. */
|
---|
109 | #define NET_NETIF_LAST (NET_NETIF_FIRST + NET_NETIF_COUNT)
|
---|
110 |
|
---|
111 | /** The first general networking message. */
|
---|
112 | #define NET_NET_FIRST (NET_NETIF_LAST + 0)
|
---|
113 |
|
---|
114 | /** The last general networking message. */
|
---|
115 | #define NET_NET_LAST (NET_NET_FIRST + NET_NET_COUNT)
|
---|
116 |
|
---|
117 | /** The first network interface layer message. */
|
---|
118 | #define NET_NIL_FIRST (NET_NET_LAST + 0)
|
---|
119 |
|
---|
120 | /** The last network interface layer message. */
|
---|
121 | #define NET_NIL_LAST (NET_NIL_FIRST + NET_NIL_COUNT)
|
---|
122 |
|
---|
123 | /** The first Ethernet message. */
|
---|
124 | #define NET_ETH_FIRST (NET_NIL_LAST + 0)
|
---|
125 |
|
---|
126 | /** The last Ethernet message. */
|
---|
127 | #define NET_ETH_LAST (NET_ETH_FIRST + NET_ETH_COUNT)
|
---|
128 |
|
---|
129 | /** The first inter-network message. */
|
---|
130 | #define NET_IL_FIRST (NET_ETH_LAST + 0)
|
---|
131 |
|
---|
132 | /** The last inter-network message. */
|
---|
133 | #define NET_IL_LAST (NET_IL_FIRST + NET_IL_COUNT)
|
---|
134 |
|
---|
135 | /** The first IP message. */
|
---|
136 | #define NET_IP_FIRST (NET_IL_LAST + 0)
|
---|
137 |
|
---|
138 | /** The last IP message. */
|
---|
139 | #define NET_IP_LAST (NET_IP_FIRST + NET_IP_COUNT)
|
---|
140 |
|
---|
141 | /** The first ARP message. */
|
---|
142 | #define NET_ARP_FIRST (NET_IP_LAST + 0)
|
---|
143 |
|
---|
144 | /** The last ARP message. */
|
---|
145 | #define NET_ARP_LAST (NET_ARP_FIRST + NET_ARP_COUNT)
|
---|
146 |
|
---|
147 | /** The first ICMP message. */
|
---|
148 | #define NET_ICMP_FIRST (NET_ARP_LAST + 0)
|
---|
149 |
|
---|
150 | /** The last ICMP message. */
|
---|
151 | #define NET_ICMP_LAST (NET_ICMP_FIRST + NET_ICMP_COUNT)
|
---|
152 |
|
---|
153 | /** The first ICMP message. */
|
---|
154 | #define NET_TL_FIRST (NET_ICMP_LAST + 0)
|
---|
155 |
|
---|
156 | /** The last ICMP message. */
|
---|
157 | #define NET_TL_LAST (NET_TL_FIRST + NET_TL_COUNT)
|
---|
158 |
|
---|
159 | /** The first UDP message. */
|
---|
160 | #define NET_UDP_FIRST (NET_TL_LAST + 0)
|
---|
161 |
|
---|
162 | /** The last UDP message. */
|
---|
163 | #define NET_UDP_LAST (NET_UDP_FIRST + NET_UDP_COUNT)
|
---|
164 |
|
---|
165 | /** The first TCP message. */
|
---|
166 | #define NET_TCP_FIRST (NET_UDP_LAST + 0)
|
---|
167 |
|
---|
168 | /** The last TCP message. */
|
---|
169 | #define NET_TCP_LAST (NET_TCP_FIRST + NET_TCP_COUNT)
|
---|
170 |
|
---|
171 | /** The first socket message. */
|
---|
172 | #define NET_SOCKET_FIRST (NET_TCP_LAST + 0)
|
---|
173 |
|
---|
174 | /** The last socket message. */
|
---|
175 | #define NET_SOCKET_LAST (NET_SOCKET_FIRST + NET_SOCKET_COUNT)
|
---|
176 |
|
---|
177 | /** The first packet management system message. */
|
---|
178 | #define NET_PACKET_FIRST (NET_SOCKET_LAST + 0)
|
---|
179 |
|
---|
180 | /** The last packet management system message. */
|
---|
181 | #define NET_PACKET_LAST (NET_PACKET_FIRST + NET_PACKET_COUNT)
|
---|
182 |
|
---|
183 | /** The last networking message. */
|
---|
184 | #define NET_LAST NET_PACKET_LAST
|
---|
185 |
|
---|
186 | /** The number of networking messages. */
|
---|
187 | #define NET_COUNT (NET_LAST - NET_FIRST)
|
---|
188 |
|
---|
189 | /** Returns a value indicating whether the IPC call is a generic networking
|
---|
190 | * message.
|
---|
191 | * @param[in] call The IPC call to be checked.
|
---|
192 | */
|
---|
193 | #define IS_NET_MESSAGE(call) \
|
---|
194 | IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_FIRST, NET_LAST)
|
---|
195 |
|
---|
196 | /** Returns a value indicating whether the IPC call is an ARP message.
|
---|
197 | * @param[in] call The IPC call to be checked.
|
---|
198 | */
|
---|
199 | #define IS_NET_ARP_MESSAGE(call) \
|
---|
200 | IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_ARP_FIRST, NET_ARP_LAST)
|
---|
201 |
|
---|
202 | /** Returns a value indicating whether the IPC call is an Ethernet message.
|
---|
203 | * @param[in] call The IPC call to be checked.
|
---|
204 | */
|
---|
205 | #define IS_NET_ETH_MESSAGE(call) \
|
---|
206 | IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_ETH_FIRST, NET_ETH_LAST)
|
---|
207 |
|
---|
208 | /** Returns a value indicating whether the IPC call is an ICMP message.
|
---|
209 | * @param[in] call The IPC call to be checked.
|
---|
210 | */
|
---|
211 | #define IS_NET_ICMP_MESSAGE(call) \
|
---|
212 | IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_ICMP_FIRST, NET_ICMP_LAST)
|
---|
213 |
|
---|
214 | /** Returns a value indicating whether the IPC call is an inter-network layer
|
---|
215 | * message.
|
---|
216 | * @param[in] call The IPC call to be checked.
|
---|
217 | */
|
---|
218 | #define IS_NET_IL_MESSAGE(call) \
|
---|
219 | IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_IL_FIRST, NET_IL_LAST)
|
---|
220 |
|
---|
221 | /** Returns a value indicating whether the IPC call is an IP message.
|
---|
222 | * @param[in] call The IPC call to be checked.
|
---|
223 | */
|
---|
224 | #define IS_NET_IP_MESSAGE(call) \
|
---|
225 | IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_IP_FIRST, NET_IP_LAST)
|
---|
226 |
|
---|
227 | /** Returns a value indicating whether the IPC call is a generic networking
|
---|
228 | * message.
|
---|
229 | * @param[in] call The IPC call to be checked.
|
---|
230 | */
|
---|
231 | #define IS_NET_NET_MESSAGE(call) \
|
---|
232 | IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_NET_FIRST, NET_NET_LAST)
|
---|
233 |
|
---|
234 | /** Returns a value indicating whether the IPC call is a network interface layer
|
---|
235 | * message.
|
---|
236 | * @param[in] call The IPC call to be checked.
|
---|
237 | */
|
---|
238 | #define IS_NET_NIL_MESSAGE(call) \
|
---|
239 | IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_NIL_FIRST, NET_NIL_LAST)
|
---|
240 |
|
---|
241 | /** Returns a value indicating whether the IPC call is a packet manaagement
|
---|
242 | * system message.
|
---|
243 | * @param[in] call The IPC call to be checked.
|
---|
244 | */
|
---|
245 | #define IS_NET_PACKET_MESSAGE(call) \
|
---|
246 | IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_PACKET_FIRST, NET_PACKET_LAST)
|
---|
247 |
|
---|
248 | /** Returns a value indicating whether the IPC call is a socket message.
|
---|
249 | * @param[in] call The IPC call to be checked.
|
---|
250 | */
|
---|
251 | #define IS_NET_SOCKET_MESSAGE(call) \
|
---|
252 | IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_SOCKET_FIRST, NET_SOCKET_LAST)
|
---|
253 |
|
---|
254 | /** Returns a value indicating whether the IPC call is a TCP message.
|
---|
255 | * @param[in] call The IPC call to be checked.
|
---|
256 | */
|
---|
257 | #define IS_NET_TCP_MESSAGE(call) \
|
---|
258 | IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_TCP_FIRST, NET_TCP_LAST)
|
---|
259 |
|
---|
260 | /** Returns a value indicating whether the IPC call is a transport layer message.
|
---|
261 | * @param[in] call The IPC call to be checked.
|
---|
262 | */
|
---|
263 | #define IS_NET_TL_MESSAGE(call) \
|
---|
264 | IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_TL_FIRST, NET_TL_LAST)
|
---|
265 |
|
---|
266 | /** Returns a value indicating whether the IPC call is a UDP message.
|
---|
267 | * @param[in] call The IPC call to be checked.
|
---|
268 | */
|
---|
269 | #define IS_NET_UDP_MESSAGE(call) \
|
---|
270 | IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_UDP_FIRST, NET_UDP_LAST)
|
---|
271 |
|
---|
272 | /*@}*/
|
---|
273 |
|
---|
274 | /** @name Networking specific message arguments definitions */
|
---|
275 | /*@{*/
|
---|
276 |
|
---|
277 | /** Returns the device identifier message argument.
|
---|
278 | * @param[in] call The message call structure.
|
---|
279 | */
|
---|
280 | #define IPC_GET_DEVICE(call) \
|
---|
281 | ({ \
|
---|
282 | device_id_t device_id = (device_id_t) IPC_GET_ARG1(*call); \
|
---|
283 | device_id; \
|
---|
284 | })
|
---|
285 |
|
---|
286 | /** Returns the packet identifier message argument.
|
---|
287 | * @param[in] call The message call structure.
|
---|
288 | */
|
---|
289 | #define IPC_GET_PACKET(call) \
|
---|
290 | ({ \
|
---|
291 | packet_id_t packet_id = (packet_id_t) IPC_GET_ARG2(*call); \
|
---|
292 | packet_id; \
|
---|
293 | })
|
---|
294 |
|
---|
295 | /** Returns the count message argument.
|
---|
296 | * @param[in] call The message call structure.
|
---|
297 | */
|
---|
298 | #define IPC_GET_COUNT(call) \
|
---|
299 | ({ \
|
---|
300 | size_t size = (size_t) IPC_GET_ARG2(*call); \
|
---|
301 | size; \
|
---|
302 | })
|
---|
303 |
|
---|
304 | /** Returns the device state message argument.
|
---|
305 | * @param[in] call The message call structure.
|
---|
306 | */
|
---|
307 | #define IPC_GET_STATE(call) \
|
---|
308 | ({ \
|
---|
309 | device_state_t state = (device_state_t) IPC_GET_ARG2(*call); \
|
---|
310 | state; \
|
---|
311 | })
|
---|
312 |
|
---|
313 | /** Returns the maximum transmission unit message argument.
|
---|
314 | * @param[in] call The message call structure.
|
---|
315 | */
|
---|
316 | #define IPC_GET_MTU(call) \
|
---|
317 | ({ \
|
---|
318 | size_t size = (size_t) IPC_GET_ARG2(*call); \
|
---|
319 | size; \
|
---|
320 | })
|
---|
321 |
|
---|
322 | /** Returns the device driver service message argument.
|
---|
323 | * @param[in] call The message call structure.
|
---|
324 | */
|
---|
325 | #define IPC_GET_SERVICE(call) \
|
---|
326 | ({ \
|
---|
327 | services_t service = (services_t) IPC_GET_ARG3(*call); \
|
---|
328 | service; \
|
---|
329 | })
|
---|
330 |
|
---|
331 | /** Returns the target service message argument.
|
---|
332 | * @param[in] call The message call structure.
|
---|
333 | */
|
---|
334 | #define IPC_GET_TARGET(call) \
|
---|
335 | ({ \
|
---|
336 | services_t service = (services_t) IPC_GET_ARG3(*call); \
|
---|
337 | service; \
|
---|
338 | })
|
---|
339 |
|
---|
340 | /** Returns the sender service message argument.
|
---|
341 | * @param[in] call The message call structure.
|
---|
342 | */
|
---|
343 | #define IPC_GET_SENDER(call) \
|
---|
344 | ({ \
|
---|
345 | services_t service = (services_t) IPC_GET_ARG3(*call); \
|
---|
346 | service; \
|
---|
347 | })
|
---|
348 |
|
---|
349 | /** Returns the error service message argument.
|
---|
350 | * @param[in] call The message call structure.
|
---|
351 | */
|
---|
352 | #define IPC_GET_ERROR(call) \
|
---|
353 | ({ \
|
---|
354 | services_t service = (services_t) IPC_GET_ARG4(*call); \
|
---|
355 | service; \
|
---|
356 | })
|
---|
357 |
|
---|
358 | /** Returns the phone message argument.
|
---|
359 | * @param[in] call The message call structure.
|
---|
360 | */
|
---|
361 | #define IPC_GET_PHONE(call) \
|
---|
362 | ({ \
|
---|
363 | int phone = (int) IPC_GET_ARG5(*call); \
|
---|
364 | phone; \
|
---|
365 | })
|
---|
366 |
|
---|
367 | /** Sets the device identifier in the message answer.
|
---|
368 | * @param[out] answer The message answer structure.
|
---|
369 | */
|
---|
370 | #define IPC_SET_DEVICE(answer, value) \
|
---|
371 | do { \
|
---|
372 | sysarg_t argument = (sysarg_t) (value); \
|
---|
373 | IPC_SET_ARG1(*answer, argument); \
|
---|
374 | } while (0)
|
---|
375 |
|
---|
376 | /** Sets the minimum address length in the message answer.
|
---|
377 | * @param[out] answer The message answer structure.
|
---|
378 | */
|
---|
379 | #define IPC_SET_ADDR(answer, value) \
|
---|
380 | do { \
|
---|
381 | sysarg_t argument = (sysarg_t) (value); \
|
---|
382 | IPC_SET_ARG1(*answer, argument); \
|
---|
383 | } while (0)
|
---|
384 |
|
---|
385 | /** Sets the minimum prefix size in the message answer.
|
---|
386 | * @param[out] answer The message answer structure.
|
---|
387 | */
|
---|
388 | #define IPC_SET_PREFIX(answer, value) \
|
---|
389 | do { \
|
---|
390 | sysarg_t argument = (sysarg_t) (value); \
|
---|
391 | IPC_SET_ARG2(*answer, argument); \
|
---|
392 | } while (0)
|
---|
393 |
|
---|
394 | /** Sets the maximum content size in the message answer.
|
---|
395 | * @param[out] answer The message answer structure.
|
---|
396 | */
|
---|
397 | #define IPC_SET_CONTENT(answer, value) \
|
---|
398 | do { \
|
---|
399 | sysarg_t argument = (sysarg_t) (value); \
|
---|
400 | IPC_SET_ARG3(*answer, argument); \
|
---|
401 | } while (0)
|
---|
402 |
|
---|
403 | /** Sets the minimum suffix size in the message answer.
|
---|
404 | * @param[out] answer The message answer structure.
|
---|
405 | */
|
---|
406 | #define IPC_SET_SUFFIX(answer, value) \
|
---|
407 | do { \
|
---|
408 | sysarg_t argument = (sysarg_t) (value); \
|
---|
409 | IPC_SET_ARG4(*answer, argument); \
|
---|
410 | } while (0)
|
---|
411 |
|
---|
412 | /*@}*/
|
---|
413 |
|
---|
414 | #endif
|
---|
415 |
|
---|
416 | /** @}
|
---|
417 | */
|
---|