source: mainline/uspace/lib/c/include/ipc/net.h@ 774e6d1a

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 774e6d1a was 774e6d1a, checked in by martin@…>, 14 years ago

partial networking stack overhaul

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