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