source: mainline/uspace/lib/c/include/ipc/net.h@ 2aa15d4

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 2aa15d4 was 2aa15d4, checked in by Jakub Jermar <jakub@…>, 15 years ago

Move part of the defines from libsocket's net_messages.h to libc's net.h and
reduce include dependance on net_messages.h.

  • Property mode set to 100644
File size: 8.4 KB
Line 
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/** Returns a value indicating whether the value is in the interval.
44 * @param[in] item The value to be checked.
45 * @param[in] first_inclusive The first value in the interval inclusive.
46 * @param[in] last_exclusive The first value after the interval.
47 */
48#define IS_IN_INTERVAL(item, first_inclusive, last_exclusive) \
49 (((item) >= (first_inclusive)) && ((item) < (last_exclusive)))
50
51/** @name Networking message counts */
52/*@{*/
53
54/** The number of ARP messages. */
55#define NET_ARP_COUNT 5
56
57/** The number of Ethernet messages. */
58#define NET_ETH_COUNT 0
59
60/** The number of ICMP messages. */
61#define NET_ICMP_COUNT 6
62
63/** The number of inter-network messages. */
64#define NET_IL_COUNT 6
65
66/** The number of IP messages. */
67#define NET_IP_COUNT 4
68
69/** The number of general networking messages. */
70#define NET_NET_COUNT 3
71
72/** The number of network interface driver messages. */
73#define NET_NETIF_COUNT 6
74
75/** The number of network interface layer messages. */
76#define NET_NIL_COUNT 7
77
78/** The number of packet management system messages. */
79#define NET_PACKET_COUNT 5
80
81/** The number of socket messages. */
82#define NET_SOCKET_COUNT 14
83
84/** The number of TCP messages. */
85#define NET_TCP_COUNT 0
86
87/** The number of transport layer messages. */
88#define NET_TL_COUNT 1
89
90/** The number of UDP messages. */
91#define NET_UDP_COUNT 0
92
93/*@}*/
94
95/** @name Networking message intervals
96 */
97/*@{*/
98
99/** The first networking message. */
100#define NET_FIRST 2000
101
102/** The first network interface layer message. */
103#define NET_NETIF_FIRST NET_FIRST
104
105/** The last network interface layer message. */
106#define NET_NETIF_LAST (NET_NETIF_FIRST + NET_NETIF_COUNT)
107
108/** The first general networking message. */
109#define NET_NET_FIRST (NET_NETIF_LAST + 0)
110
111/** The last general networking message. */
112#define NET_NET_LAST (NET_NET_FIRST + NET_NET_COUNT)
113
114/** The first network interface layer message. */
115#define NET_NIL_FIRST (NET_NET_LAST + 0)
116
117/** The last network interface layer message. */
118#define NET_NIL_LAST (NET_NIL_FIRST + NET_NIL_COUNT)
119
120/** The first Ethernet message. */
121#define NET_ETH_FIRST (NET_NIL_LAST + 0)
122
123/** The last Ethernet message. */
124#define NET_ETH_LAST (NET_ETH_FIRST + NET_ETH_COUNT)
125
126/** The first inter-network message. */
127#define NET_IL_FIRST (NET_ETH_LAST + 0)
128
129/** The last inter-network message. */
130#define NET_IL_LAST (NET_IL_FIRST + NET_IL_COUNT)
131
132/** The first IP message. */
133#define NET_IP_FIRST (NET_IL_LAST + 0)
134
135/** The last IP message. */
136#define NET_IP_LAST (NET_IP_FIRST + NET_IP_COUNT)
137
138/** The first ARP message. */
139#define NET_ARP_FIRST (NET_IP_LAST + 0)
140
141/** The last ARP message. */
142#define NET_ARP_LAST (NET_ARP_FIRST + NET_ARP_COUNT)
143
144/** The first ICMP message. */
145#define NET_ICMP_FIRST (NET_ARP_LAST + 0)
146
147/** The last ICMP message. */
148#define NET_ICMP_LAST (NET_ICMP_FIRST + NET_ICMP_COUNT)
149
150/** The first ICMP message. */
151#define NET_TL_FIRST (NET_ICMP_LAST + 0)
152
153/** The last ICMP message. */
154#define NET_TL_LAST (NET_TL_FIRST + NET_TL_COUNT)
155
156/** The first UDP message. */
157#define NET_UDP_FIRST (NET_TL_LAST + 0)
158
159/** The last UDP message. */
160#define NET_UDP_LAST (NET_UDP_FIRST + NET_UDP_COUNT)
161
162/** The first TCP message. */
163#define NET_TCP_FIRST (NET_UDP_LAST + 0)
164
165/** The last TCP message. */
166#define NET_TCP_LAST (NET_TCP_FIRST + NET_TCP_COUNT)
167
168/** The first socket message. */
169#define NET_SOCKET_FIRST (NET_TCP_LAST + 0)
170
171/** The last socket message. */
172#define NET_SOCKET_LAST (NET_SOCKET_FIRST + NET_SOCKET_COUNT)
173
174/** The first packet management system message. */
175#define NET_PACKET_FIRST (NET_SOCKET_LAST + 0)
176
177/** The last packet management system message.
178 */
179#define NET_PACKET_LAST (NET_PACKET_FIRST + NET_PACKET_COUNT)
180
181/** The last networking message. */
182#define NET_LAST NET_PACKET_LAST
183
184/** The number of networking messages. */
185#define NET_COUNT (NET_LAST - NET_FIRST)
186
187/** Returns a value indicating whether the IPC call is a generic networking
188 * message.
189 * @param[in] call The IPC call to be checked.
190 */
191#define IS_NET_MESSAGE(call) \
192 IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_FIRST, NET_LAST)
193
194/** Returns a value indicating whether the IPC call is an ARP message.
195 * @param[in] call The IPC call to be checked.
196 */
197#define IS_NET_ARP_MESSAGE(call) \
198 IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_ARP_FIRST, NET_ARP_LAST)
199
200/** Returns a value indicating whether the IPC call is an Ethernet message.
201 * @param[in] call The IPC call to be checked.
202 */
203#define IS_NET_ETH_MESSAGE(call) \
204 IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_ETH_FIRST, NET_ETH_LAST)
205
206/** Returns a value indicating whether the IPC call is an ICMP message.
207 * @param[in] call The IPC call to be checked.
208 */
209#define IS_NET_ICMP_MESSAGE(call) \
210 IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_ICMP_FIRST, NET_ICMP_LAST)
211
212/** Returns a value indicating whether the IPC call is an inter-network layer
213 * message.
214 * @param[in] call The IPC call to be checked.
215 */
216#define IS_NET_IL_MESSAGE(call) \
217 IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_IL_FIRST, NET_IL_LAST)
218
219/** Returns a value indicating whether the IPC call is an IP message.
220 * @param[in] call The IPC call to be checked.
221 */
222#define IS_NET_IP_MESSAGE(call) \
223 IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_IP_FIRST, NET_IP_LAST)
224
225/** Returns a value indicating whether the IPC call is a generic networking
226 * message.
227 * @param[in] call The IPC call to be checked.
228 */
229#define IS_NET_NET_MESSAGE(call) \
230 IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_NET_FIRST, NET_NET_LAST)
231
232/** Returns a value indicating whether the IPC call is a network interface layer
233 * message.
234 * @param[in] call The IPC call to be checked.
235 */
236#define IS_NET_NIL_MESSAGE(call) \
237 IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_NIL_FIRST, NET_NIL_LAST)
238
239/** Returns a value indicating whether the IPC call is a packet manaagement
240 * system message.
241 * @param[in] call The IPC call to be checked.
242 */
243#define IS_NET_PACKET_MESSAGE(call) \
244 IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_PACKET_FIRST, NET_PACKET_LAST)
245
246/** Returns a value indicating whether the IPC call is a socket message.
247 * @param[in] call The IPC call to be checked.
248 */
249#define IS_NET_SOCKET_MESSAGE(call) \
250 IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_SOCKET_FIRST, NET_SOCKET_LAST)
251
252/** Returns a value indicating whether the IPC call is a TCP message.
253 * @param[in] call The IPC call to be checked.
254 */
255#define IS_NET_TCP_MESSAGE(call) \
256 IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_TCP_FIRST, NET_TCP_LAST)
257
258/** Returns a value indicating whether the IPC call is a transport layer message.
259 * @param[in] call The IPC call to be checked.
260 */
261#define IS_NET_TL_MESSAGE(call) \
262 IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_TL_FIRST, NET_TL_LAST)
263
264/** Returns a value indicating whether the IPC call is a UDP message.
265 * @param[in] call The IPC call to be checked.
266 */
267#define IS_NET_UDP_MESSAGE(call) \
268 IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_UDP_FIRST, NET_UDP_LAST)
269
270/*@}*/
271
272#endif
273
274/** @}
275 */
Note: See TracBrowser for help on using the repository browser.