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/services.h>
|
---|
41 | #include <net/device.h>
|
---|
42 |
|
---|
43 | /** Return a value indicating whether the value is in the interval.
|
---|
44 | *
|
---|
45 | * @param[in] item Value to be checked.
|
---|
46 | * @param[in] first_inclusive First value in the interval inclusive.
|
---|
47 | * @param[in] last_exclusive First value after the interval.
|
---|
48 | *
|
---|
49 | */
|
---|
50 | #define IS_IN_INTERVAL(item, first_inclusive, last_exclusive) \
|
---|
51 | (((item) >= (first_inclusive)) && ((item) < (last_exclusive)))
|
---|
52 |
|
---|
53 | /** @name Networking message counts */
|
---|
54 | /*@{*/
|
---|
55 |
|
---|
56 | #define NET_ARP_COUNT 5 /**< Number of ARP messages. */
|
---|
57 | #define NET_ETH_COUNT 0 /**< Number of Ethernet messages. */
|
---|
58 | #define NET_ICMP_COUNT 6 /**< Number of ICMP messages. */
|
---|
59 | #define NET_IL_COUNT 6 /**< Number of inter-network messages. */
|
---|
60 | #define NET_IP_COUNT 4 /**< Number of IP messages. */
|
---|
61 | #define NET_NET_COUNT 3 /**< Number of general networking messages. */
|
---|
62 | #define NET_NETIF_COUNT 6 /**< Number of network interface driver messages. */
|
---|
63 | #define NET_NIL_COUNT 7 /**< Number of network interface layer messages. */
|
---|
64 | #define NET_PACKET_COUNT 5 /**< Number of packet management system messages. */
|
---|
65 | #define NET_SOCKET_COUNT 14 /**< Number of socket messages. */
|
---|
66 | #define NET_TCP_COUNT 0 /**< Number of TCP messages. */
|
---|
67 | #define NET_TL_COUNT 1 /**< Number of transport layer messages. */
|
---|
68 | #define NET_UDP_COUNT 0 /**< Number of UDP messages. */
|
---|
69 |
|
---|
70 | /*@}*/
|
---|
71 |
|
---|
72 | /** @name Networking message intervals
|
---|
73 | */
|
---|
74 | /*@{*/
|
---|
75 |
|
---|
76 |
|
---|
77 | /** First networking message. */
|
---|
78 | #define NET_FIRST 2000
|
---|
79 |
|
---|
80 | /** First network interface layer message. */
|
---|
81 | #define NET_NETIF_FIRST NET_FIRST
|
---|
82 |
|
---|
83 | /** Last network interface layer message. */
|
---|
84 | #define NET_NETIF_LAST (NET_NETIF_FIRST + NET_NETIF_COUNT)
|
---|
85 |
|
---|
86 | /** First general networking message. */
|
---|
87 | #define NET_NET_FIRST (NET_NETIF_LAST + 0)
|
---|
88 |
|
---|
89 | /** Last general networking message. */
|
---|
90 | #define NET_NET_LAST (NET_NET_FIRST + NET_NET_COUNT)
|
---|
91 |
|
---|
92 | /** First network interface layer message. */
|
---|
93 | #define NET_NIL_FIRST (NET_NET_LAST + 0)
|
---|
94 |
|
---|
95 | /** Last network interface layer message. */
|
---|
96 | #define NET_NIL_LAST (NET_NIL_FIRST + NET_NIL_COUNT)
|
---|
97 |
|
---|
98 | /** First Ethernet message. */
|
---|
99 | #define NET_ETH_FIRST (NET_NIL_LAST + 0)
|
---|
100 |
|
---|
101 | /** Last Ethernet message. */
|
---|
102 | #define NET_ETH_LAST (NET_ETH_FIRST + NET_ETH_COUNT)
|
---|
103 |
|
---|
104 | /** First inter-network message. */
|
---|
105 | #define NET_IL_FIRST (NET_ETH_LAST + 0)
|
---|
106 |
|
---|
107 | /** Last inter-network message. */
|
---|
108 | #define NET_IL_LAST (NET_IL_FIRST + NET_IL_COUNT)
|
---|
109 |
|
---|
110 | /** First IP message. */
|
---|
111 | #define NET_IP_FIRST (NET_IL_LAST + 0)
|
---|
112 |
|
---|
113 | /** Last IP message. */
|
---|
114 | #define NET_IP_LAST (NET_IP_FIRST + NET_IP_COUNT)
|
---|
115 |
|
---|
116 | /** First ARP message. */
|
---|
117 | #define NET_ARP_FIRST (NET_IP_LAST + 0)
|
---|
118 |
|
---|
119 | /** Last ARP message. */
|
---|
120 | #define NET_ARP_LAST (NET_ARP_FIRST + NET_ARP_COUNT)
|
---|
121 |
|
---|
122 | /** First ICMP message. */
|
---|
123 | #define NET_ICMP_FIRST (NET_ARP_LAST + 0)
|
---|
124 |
|
---|
125 | /** Last ICMP message. */
|
---|
126 | #define NET_ICMP_LAST (NET_ICMP_FIRST + NET_ICMP_COUNT)
|
---|
127 |
|
---|
128 | /** First ICMP message. */
|
---|
129 | #define NET_TL_FIRST (NET_ICMP_LAST + 0)
|
---|
130 |
|
---|
131 | /** Last ICMP message. */
|
---|
132 | #define NET_TL_LAST (NET_TL_FIRST + NET_TL_COUNT)
|
---|
133 |
|
---|
134 | /** First UDP message. */
|
---|
135 | #define NET_UDP_FIRST (NET_TL_LAST + 0)
|
---|
136 |
|
---|
137 | /** Last UDP message. */
|
---|
138 | #define NET_UDP_LAST (NET_UDP_FIRST + NET_UDP_COUNT)
|
---|
139 |
|
---|
140 | /** First TCP message. */
|
---|
141 | #define NET_TCP_FIRST (NET_UDP_LAST + 0)
|
---|
142 |
|
---|
143 | /** Last TCP message. */
|
---|
144 | #define NET_TCP_LAST (NET_TCP_FIRST + NET_TCP_COUNT)
|
---|
145 |
|
---|
146 | /** First socket message. */
|
---|
147 | #define NET_SOCKET_FIRST (NET_TCP_LAST + 0)
|
---|
148 |
|
---|
149 | /** Last socket message. */
|
---|
150 | #define NET_SOCKET_LAST (NET_SOCKET_FIRST + NET_SOCKET_COUNT)
|
---|
151 |
|
---|
152 | /** First packet management system message. */
|
---|
153 | #define NET_PACKET_FIRST (NET_SOCKET_LAST + 0)
|
---|
154 |
|
---|
155 | /** Last packet management system message. */
|
---|
156 | #define NET_PACKET_LAST (NET_PACKET_FIRST + NET_PACKET_COUNT)
|
---|
157 |
|
---|
158 | /** Last networking message. */
|
---|
159 | #define NET_LAST NET_PACKET_LAST
|
---|
160 |
|
---|
161 | /** Number of networking messages. */
|
---|
162 | #define NET_COUNT (NET_LAST - NET_FIRST)
|
---|
163 |
|
---|
164 | /** Check if the IPC call is a generic networking message.
|
---|
165 | *
|
---|
166 | * @param[in] call IPC call to be checked.
|
---|
167 | *
|
---|
168 | */
|
---|
169 | #define IS_NET_MESSAGE(call) \
|
---|
170 | IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_FIRST, NET_LAST)
|
---|
171 |
|
---|
172 | /** Check if the IPC call is an ARP message.
|
---|
173 | *
|
---|
174 | * @param[in] call IPC call to be checked.
|
---|
175 | *
|
---|
176 | */
|
---|
177 | #define IS_NET_ARP_MESSAGE(call) \
|
---|
178 | IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_ARP_FIRST, NET_ARP_LAST)
|
---|
179 |
|
---|
180 | /** Check if the IPC call is an Ethernet message.
|
---|
181 | *
|
---|
182 | * @param[in] call IPC call to be checked.
|
---|
183 | *
|
---|
184 | */
|
---|
185 | #define IS_NET_ETH_MESSAGE(call) \
|
---|
186 | IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_ETH_FIRST, NET_ETH_LAST)
|
---|
187 |
|
---|
188 | /** Check if the IPC call is an ICMP message.
|
---|
189 | *
|
---|
190 | * @param[in] call IPC call to be checked.
|
---|
191 | *
|
---|
192 | */
|
---|
193 | #define IS_NET_ICMP_MESSAGE(call) \
|
---|
194 | IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_ICMP_FIRST, NET_ICMP_LAST)
|
---|
195 |
|
---|
196 | /** Check if the IPC call is an inter-network layer message.
|
---|
197 | *
|
---|
198 | * @param[in] call IPC call to be checked.
|
---|
199 | *
|
---|
200 | */
|
---|
201 | #define IS_NET_IL_MESSAGE(call) \
|
---|
202 | IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_IL_FIRST, NET_IL_LAST)
|
---|
203 |
|
---|
204 | /** Check if the IPC call is an IP message.
|
---|
205 | *
|
---|
206 | * @param[in] call IPC call to be checked.
|
---|
207 | *
|
---|
208 | */
|
---|
209 | #define IS_NET_IP_MESSAGE(call) \
|
---|
210 | IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_IP_FIRST, NET_IP_LAST)
|
---|
211 |
|
---|
212 | /** Check if the IPC call is a generic networking message.
|
---|
213 | *
|
---|
214 | * @param[in] call IPC call to be checked.
|
---|
215 | *
|
---|
216 | */
|
---|
217 | #define IS_NET_NET_MESSAGE(call) \
|
---|
218 | IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_NET_FIRST, NET_NET_LAST)
|
---|
219 |
|
---|
220 | /** Check if the IPC call is a network interface layer message.
|
---|
221 | *
|
---|
222 | * @param[in] call IPC call to be checked.
|
---|
223 | *
|
---|
224 | */
|
---|
225 | #define IS_NET_NIL_MESSAGE(call) \
|
---|
226 | IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_NIL_FIRST, NET_NIL_LAST)
|
---|
227 |
|
---|
228 | /** Check if the IPC call is a packet manaagement system message.
|
---|
229 | *
|
---|
230 | * @param[in] call IPC call to be checked.
|
---|
231 | *
|
---|
232 | */
|
---|
233 | #define IS_NET_PACKET_MESSAGE(call) \
|
---|
234 | IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_PACKET_FIRST, NET_PACKET_LAST)
|
---|
235 |
|
---|
236 | /** Check if the IPC call is a socket message.
|
---|
237 | *
|
---|
238 | * @param[in] call IPC call to be checked.
|
---|
239 | *
|
---|
240 | */
|
---|
241 | #define IS_NET_SOCKET_MESSAGE(call) \
|
---|
242 | IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_SOCKET_FIRST, NET_SOCKET_LAST)
|
---|
243 |
|
---|
244 | /** Check if the IPC call is a TCP message.
|
---|
245 | *
|
---|
246 | * @param[in] call IPC call to be checked.
|
---|
247 | *
|
---|
248 | */
|
---|
249 | #define IS_NET_TCP_MESSAGE(call) \
|
---|
250 | IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_TCP_FIRST, NET_TCP_LAST)
|
---|
251 |
|
---|
252 | /** Check if the IPC call is a transport layer message.
|
---|
253 | *
|
---|
254 | * @param[in] call IPC call to be checked.
|
---|
255 | *
|
---|
256 | */
|
---|
257 | #define IS_NET_TL_MESSAGE(call) \
|
---|
258 | IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_TL_FIRST, NET_TL_LAST)
|
---|
259 |
|
---|
260 | /** Check if the IPC call is a UDP message.
|
---|
261 | *
|
---|
262 | * @param[in] call IPC call to be checked.
|
---|
263 | *
|
---|
264 | */
|
---|
265 | #define IS_NET_UDP_MESSAGE(call) \
|
---|
266 | IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_UDP_FIRST, NET_UDP_LAST)
|
---|
267 |
|
---|
268 | /*@}*/
|
---|
269 |
|
---|
270 | /** @name Networking specific message arguments definitions */
|
---|
271 | /*@{*/
|
---|
272 |
|
---|
273 | /** Return the device identifier message argument.
|
---|
274 | *
|
---|
275 | * @param[in] call Message call structure.
|
---|
276 | *
|
---|
277 | */
|
---|
278 | #define IPC_GET_DEVICE(call) ((nic_device_id_t) IPC_GET_ARG1(call))
|
---|
279 |
|
---|
280 | /** Return the packet identifier message argument.
|
---|
281 | *
|
---|
282 | * @param[in] call Message call structure.
|
---|
283 | *
|
---|
284 | */
|
---|
285 | #define IPC_GET_PACKET(call) ((packet_id_t) IPC_GET_ARG2(call))
|
---|
286 |
|
---|
287 | /** Return the count message argument.
|
---|
288 | *
|
---|
289 | * @param[in] call Message call structure.
|
---|
290 | *
|
---|
291 | */
|
---|
292 | #define IPC_GET_COUNT(call) ((size_t) IPC_GET_ARG2(call))
|
---|
293 |
|
---|
294 | /** Return the device state message argument.
|
---|
295 | *
|
---|
296 | * @param[in] call Message call structure.
|
---|
297 | *
|
---|
298 | */
|
---|
299 | #define IPC_GET_STATE(call) ((nic_device_state_t) IPC_GET_ARG2(call))
|
---|
300 |
|
---|
301 | /** Return the device handle argument
|
---|
302 | *
|
---|
303 | * @param[in] call Message call structure
|
---|
304 | *
|
---|
305 | */
|
---|
306 | #define IPC_GET_DEVICE_HANDLE(call) ((service_id_t) IPC_GET_ARG2(call))
|
---|
307 |
|
---|
308 | /** Return the device driver service message argument.
|
---|
309 | *
|
---|
310 | * @param[in] call Message call structure.
|
---|
311 | *
|
---|
312 | */
|
---|
313 | #define IPC_GET_SERVICE(call) ((services_t) IPC_GET_ARG3(call))
|
---|
314 |
|
---|
315 | /** Return the target service message argument.
|
---|
316 | *
|
---|
317 | * @param[in] call Message call structure.
|
---|
318 | *
|
---|
319 | */
|
---|
320 | #define IPC_GET_TARGET(call) ((services_t) IPC_GET_ARG3(call))
|
---|
321 |
|
---|
322 | /** Return the sender service message argument.
|
---|
323 | *
|
---|
324 | * @param[in] call Message call structure.
|
---|
325 | *
|
---|
326 | */
|
---|
327 | #define IPC_GET_SENDER(call) ((services_t) IPC_GET_ARG3(call))
|
---|
328 |
|
---|
329 | /** Return the maximum transmission unit message argument.
|
---|
330 | *
|
---|
331 | * @param[in] call Message call structure.
|
---|
332 | *
|
---|
333 | */
|
---|
334 | #define IPC_GET_MTU(call) ((size_t) IPC_GET_ARG3(call))
|
---|
335 |
|
---|
336 | /** Return the error service message argument.
|
---|
337 | &
|
---|
338 | * @param[in] call Message call structure.
|
---|
339 | *
|
---|
340 | */
|
---|
341 | #define IPC_GET_ERROR(call) ((services_t) IPC_GET_ARG4(call))
|
---|
342 |
|
---|
343 | /** Set the device identifier in the message answer.
|
---|
344 | *
|
---|
345 | * @param[out] answer Message answer structure.
|
---|
346 | * @param[in] value Value to set.
|
---|
347 | *
|
---|
348 | */
|
---|
349 | #define IPC_SET_DEVICE(answer, value) IPC_SET_ARG1(answer, (sysarg_t) (value))
|
---|
350 |
|
---|
351 | /** Set the minimum address length in the message answer.
|
---|
352 | *
|
---|
353 | * @param[out] answer Message answer structure.
|
---|
354 | * @param[in] value Value to set.
|
---|
355 | *
|
---|
356 | */
|
---|
357 | #define IPC_SET_ADDR(answer, value) IPC_SET_ARG1(answer, (sysarg_t) (value))
|
---|
358 |
|
---|
359 | /** Set the minimum prefix size in the message answer.
|
---|
360 | *
|
---|
361 | * @param[out] answer Message answer structure.
|
---|
362 | * @param[in] value Value to set.
|
---|
363 | *
|
---|
364 | */
|
---|
365 | #define IPC_SET_PREFIX(answer, value) IPC_SET_ARG2(answer, (sysarg_t) (value))
|
---|
366 |
|
---|
367 | /** Set the maximum content size in the message answer.
|
---|
368 | *
|
---|
369 | * @param[out] answer Message answer structure.
|
---|
370 | * @param[in] value Value to set.
|
---|
371 | *
|
---|
372 | */
|
---|
373 | #define IPC_SET_CONTENT(answer, value) IPC_SET_ARG3(answer, (sysarg_t) (value))
|
---|
374 |
|
---|
375 | /** Set the minimum suffix size in the message answer.
|
---|
376 | *
|
---|
377 | * @param[out] answer Message answer structure.
|
---|
378 | * @param[in] value Value to set.
|
---|
379 | *
|
---|
380 | */
|
---|
381 | #define IPC_SET_SUFFIX(answer, value) IPC_SET_ARG4(answer, (sysarg_t) (value))
|
---|
382 |
|
---|
383 | /*@}*/
|
---|
384 |
|
---|
385 | #endif
|
---|
386 |
|
---|
387 | /** @}
|
---|
388 | */
|
---|