[21580dd] | 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 net
|
---|
| 30 | * @{
|
---|
| 31 | */
|
---|
| 32 |
|
---|
| 33 | /** @file
|
---|
| 34 | * Networking common message definitions.
|
---|
| 35 | */
|
---|
| 36 |
|
---|
| 37 | #ifndef __NET_MESSAGES_H__
|
---|
| 38 | #define __NET_MESSAGES_H__
|
---|
| 39 |
|
---|
| 40 | #include <async.h>
|
---|
| 41 |
|
---|
| 42 | #include <ipc/ipc.h>
|
---|
| 43 | #include <ipc/services.h>
|
---|
| 44 |
|
---|
[849ed54] | 45 | #include <net_device.h>
|
---|
| 46 | #include <adt/measured_strings.h>
|
---|
| 47 | #include <packet/packet.h>
|
---|
[21580dd] | 48 |
|
---|
[a64c64d] | 49 | /** Returns a value indicating whether the value is in the interval.
|
---|
| 50 | * @param[in] item The value to be checked.
|
---|
| 51 | * @param[in] first_inclusive The first value in the interval inclusive.
|
---|
| 52 | * @param[in] last_exclusive The first value after the interval.
|
---|
[21580dd] | 53 | */
|
---|
[a64c64d] | 54 | #define IS_IN_INTERVAL(item, first_inclusive, last_exclusive) (((item) >= (first_inclusive)) && ((item) < (last_exclusive)))
|
---|
[21580dd] | 55 |
|
---|
[a64c64d] | 56 | /** @name Networking message counts
|
---|
[21580dd] | 57 | */
|
---|
[a64c64d] | 58 | /*@{*/
|
---|
[21580dd] | 59 |
|
---|
[a64c64d] | 60 | /** The number of ARP messages.
|
---|
[21580dd] | 61 | */
|
---|
[a64c64d] | 62 | #define NET_ARP_COUNT 5
|
---|
[21580dd] | 63 |
|
---|
| 64 | /** The number of Ethernet messages.
|
---|
| 65 | */
|
---|
| 66 | #define NET_ETH_COUNT 0
|
---|
| 67 |
|
---|
[a64c64d] | 68 | /** The number of ICMP messages.
|
---|
| 69 | */
|
---|
| 70 | #define NET_ICMP_COUNT 6
|
---|
| 71 |
|
---|
[21580dd] | 72 | /** The number of inter-network messages.
|
---|
| 73 | */
|
---|
| 74 | #define NET_IL_COUNT 6
|
---|
| 75 |
|
---|
| 76 | /** The number of IP messages.
|
---|
| 77 | */
|
---|
| 78 | #define NET_IP_COUNT 4
|
---|
| 79 |
|
---|
[a64c64d] | 80 | /** The number of general networking messages.
|
---|
[21580dd] | 81 | */
|
---|
[a64c64d] | 82 | #define NET_NET_COUNT 3
|
---|
[21580dd] | 83 |
|
---|
[a64c64d] | 84 | /** The number of network interface driver messages.
|
---|
[21580dd] | 85 | */
|
---|
[a64c64d] | 86 | #define NET_NETIF_COUNT 6
|
---|
[21580dd] | 87 |
|
---|
[a64c64d] | 88 | /** The number of network interface layer messages.
|
---|
[21580dd] | 89 | */
|
---|
[a64c64d] | 90 | #define NET_NIL_COUNT 7
|
---|
[21580dd] | 91 |
|
---|
[a64c64d] | 92 | /** The number of packet management system messages.
|
---|
[21580dd] | 93 | */
|
---|
[a64c64d] | 94 | #define NET_PACKET_COUNT 5
|
---|
| 95 |
|
---|
| 96 | /** The number of socket messages.
|
---|
| 97 | */
|
---|
| 98 | #define NET_SOCKET_COUNT 14
|
---|
[21580dd] | 99 |
|
---|
| 100 | /** The number of TCP messages.
|
---|
| 101 | */
|
---|
| 102 | #define NET_TCP_COUNT 0
|
---|
| 103 |
|
---|
[a64c64d] | 104 | /** The number of transport layer messages.
|
---|
[21580dd] | 105 | */
|
---|
[a64c64d] | 106 | #define NET_TL_COUNT 1
|
---|
[21580dd] | 107 |
|
---|
[a64c64d] | 108 | /** The number of UDP messages.
|
---|
[21580dd] | 109 | */
|
---|
[a64c64d] | 110 | #define NET_UDP_COUNT 0
|
---|
[21580dd] | 111 |
|
---|
| 112 | /*@}*/
|
---|
| 113 |
|
---|
| 114 | /** @name Networking message intervals
|
---|
| 115 | */
|
---|
| 116 | /*@{*/
|
---|
| 117 |
|
---|
| 118 | /** The first networking message.
|
---|
| 119 | */
|
---|
| 120 | #define NET_FIRST 2000
|
---|
| 121 |
|
---|
| 122 | /** The first network interface layer message.
|
---|
| 123 | */
|
---|
| 124 | #define NET_NETIF_FIRST NET_FIRST
|
---|
| 125 |
|
---|
| 126 | /** The last network interface layer message.
|
---|
| 127 | */
|
---|
[aadf01e] | 128 | #define NET_NETIF_LAST (NET_NETIF_FIRST + NET_NETIF_COUNT)
|
---|
[21580dd] | 129 |
|
---|
| 130 | /** The first general networking message.
|
---|
| 131 | */
|
---|
[aadf01e] | 132 | #define NET_NET_FIRST (NET_NETIF_LAST + 0)
|
---|
[21580dd] | 133 |
|
---|
| 134 | /** The last general networking message.
|
---|
| 135 | */
|
---|
[aadf01e] | 136 | #define NET_NET_LAST (NET_NET_FIRST + NET_NET_COUNT)
|
---|
[21580dd] | 137 |
|
---|
| 138 | /** The first network interface layer message.
|
---|
| 139 | */
|
---|
[aadf01e] | 140 | #define NET_NIL_FIRST (NET_NET_LAST + 0)
|
---|
[21580dd] | 141 |
|
---|
| 142 | /** The last network interface layer message.
|
---|
| 143 | */
|
---|
[aadf01e] | 144 | #define NET_NIL_LAST (NET_NIL_FIRST + NET_NIL_COUNT)
|
---|
[21580dd] | 145 |
|
---|
| 146 | /** The first Ethernet message.
|
---|
| 147 | */
|
---|
[aadf01e] | 148 | #define NET_ETH_FIRST (NET_NIL_LAST + 0)
|
---|
[21580dd] | 149 |
|
---|
| 150 | /** The last Ethernet message.
|
---|
| 151 | */
|
---|
[aadf01e] | 152 | #define NET_ETH_LAST (NET_ETH_FIRST + NET_ETH_COUNT)
|
---|
[21580dd] | 153 |
|
---|
| 154 | /** The first inter-network message.
|
---|
| 155 | */
|
---|
[aadf01e] | 156 | #define NET_IL_FIRST (NET_ETH_LAST + 0)
|
---|
[21580dd] | 157 |
|
---|
| 158 | /** The last inter-network message.
|
---|
| 159 | */
|
---|
[aadf01e] | 160 | #define NET_IL_LAST (NET_IL_FIRST + NET_IL_COUNT)
|
---|
[21580dd] | 161 |
|
---|
| 162 | /** The first IP message.
|
---|
| 163 | */
|
---|
[aadf01e] | 164 | #define NET_IP_FIRST (NET_IL_LAST + 0)
|
---|
[21580dd] | 165 |
|
---|
| 166 | /** The last IP message.
|
---|
| 167 | */
|
---|
[aadf01e] | 168 | #define NET_IP_LAST (NET_IP_FIRST + NET_IP_COUNT)
|
---|
[21580dd] | 169 |
|
---|
| 170 | /** The first ARP message.
|
---|
| 171 | */
|
---|
[aadf01e] | 172 | #define NET_ARP_FIRST (NET_IP_LAST + 0)
|
---|
[21580dd] | 173 |
|
---|
| 174 | /** The last ARP message.
|
---|
| 175 | */
|
---|
[aadf01e] | 176 | #define NET_ARP_LAST (NET_ARP_FIRST + NET_ARP_COUNT)
|
---|
[21580dd] | 177 |
|
---|
| 178 | /** The first ICMP message.
|
---|
| 179 | */
|
---|
[aadf01e] | 180 | #define NET_ICMP_FIRST (NET_ARP_LAST + 0)
|
---|
[21580dd] | 181 |
|
---|
| 182 | /** The last ICMP message.
|
---|
| 183 | */
|
---|
[aadf01e] | 184 | #define NET_ICMP_LAST (NET_ICMP_FIRST + NET_ICMP_COUNT)
|
---|
[21580dd] | 185 |
|
---|
| 186 | /** The first ICMP message.
|
---|
| 187 | */
|
---|
[aadf01e] | 188 | #define NET_TL_FIRST (NET_ICMP_LAST + 0)
|
---|
[21580dd] | 189 |
|
---|
| 190 | /** The last ICMP message.
|
---|
| 191 | */
|
---|
[aadf01e] | 192 | #define NET_TL_LAST (NET_TL_FIRST + NET_TL_COUNT)
|
---|
[21580dd] | 193 |
|
---|
| 194 | /** The first UDP message.
|
---|
| 195 | */
|
---|
[aadf01e] | 196 | #define NET_UDP_FIRST (NET_TL_LAST + 0)
|
---|
[21580dd] | 197 |
|
---|
| 198 | /** The last UDP message.
|
---|
| 199 | */
|
---|
[aadf01e] | 200 | #define NET_UDP_LAST (NET_UDP_FIRST + NET_UDP_COUNT)
|
---|
[21580dd] | 201 |
|
---|
| 202 | /** The first TCP message.
|
---|
| 203 | */
|
---|
[aadf01e] | 204 | #define NET_TCP_FIRST (NET_UDP_LAST + 0)
|
---|
[21580dd] | 205 |
|
---|
| 206 | /** The last TCP message.
|
---|
| 207 | */
|
---|
[aadf01e] | 208 | #define NET_TCP_LAST (NET_TCP_FIRST + NET_TCP_COUNT)
|
---|
[21580dd] | 209 |
|
---|
| 210 | /** The first socket message.
|
---|
| 211 | */
|
---|
[aadf01e] | 212 | #define NET_SOCKET_FIRST (NET_TCP_LAST + 0)
|
---|
[21580dd] | 213 |
|
---|
| 214 | /** The last socket message.
|
---|
| 215 | */
|
---|
[aadf01e] | 216 | #define NET_SOCKET_LAST (NET_SOCKET_FIRST + NET_SOCKET_COUNT)
|
---|
[21580dd] | 217 |
|
---|
| 218 | /** The first packet management system message.
|
---|
| 219 | */
|
---|
[aadf01e] | 220 | #define NET_PACKET_FIRST (NET_SOCKET_LAST + 0)
|
---|
[21580dd] | 221 |
|
---|
| 222 | /** The last packet management system message.
|
---|
| 223 | */
|
---|
[aadf01e] | 224 | #define NET_PACKET_LAST (NET_PACKET_FIRST + NET_PACKET_COUNT)
|
---|
[21580dd] | 225 |
|
---|
| 226 | /** The last networking message.
|
---|
| 227 | */
|
---|
| 228 | #define NET_LAST NET_PACKET_LAST
|
---|
| 229 |
|
---|
| 230 | /** The number of networking messages.
|
---|
| 231 | */
|
---|
[aadf01e] | 232 | #define NET_COUNT (NET_LAST - NET_FIRST)
|
---|
[21580dd] | 233 |
|
---|
| 234 | /** Returns a value indicating whether the IPC call is a generic networking message.
|
---|
| 235 | * @param[in] call The IPC call to be checked.
|
---|
| 236 | */
|
---|
[e417b96] | 237 | #define IS_NET_MESSAGE(call) \
|
---|
| 238 | IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_FIRST, NET_LAST)
|
---|
[21580dd] | 239 |
|
---|
[a64c64d] | 240 | /** Returns a value indicating whether the IPC call is an ARP message.
|
---|
[21580dd] | 241 | * @param[in] call The IPC call to be checked.
|
---|
| 242 | */
|
---|
[e417b96] | 243 | #define IS_NET_ARP_MESSAGE(call) \
|
---|
| 244 | IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_ARP_FIRST, NET_ARP_LAST)
|
---|
[21580dd] | 245 |
|
---|
[a64c64d] | 246 | /** Returns a value indicating whether the IPC call is an Ethernet message.
|
---|
[21580dd] | 247 | * @param[in] call The IPC call to be checked.
|
---|
| 248 | */
|
---|
[e417b96] | 249 | #define IS_NET_ETH_MESSAGE(call) \
|
---|
| 250 | IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_ETH_FIRST, NET_ETH_LAST)
|
---|
[21580dd] | 251 |
|
---|
[a64c64d] | 252 | /** Returns a value indicating whether the IPC call is an ICMP message.
|
---|
[21580dd] | 253 | * @param[in] call The IPC call to be checked.
|
---|
| 254 | */
|
---|
[e417b96] | 255 | #define IS_NET_ICMP_MESSAGE(call) \
|
---|
| 256 | IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_ICMP_FIRST, NET_ICMP_LAST)
|
---|
[21580dd] | 257 |
|
---|
| 258 | /** Returns a value indicating whether the IPC call is an inter-network layer message.
|
---|
| 259 | * @param[in] call The IPC call to be checked.
|
---|
| 260 | */
|
---|
[e417b96] | 261 | #define IS_NET_IL_MESSAGE(call) \
|
---|
| 262 | IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_IL_FIRST, NET_IL_LAST)
|
---|
[21580dd] | 263 |
|
---|
| 264 | /** Returns a value indicating whether the IPC call is an IP message.
|
---|
| 265 | * @param[in] call The IPC call to be checked.
|
---|
| 266 | */
|
---|
[e417b96] | 267 | #define IS_NET_IP_MESSAGE(call) \
|
---|
| 268 | IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_IP_FIRST, NET_IP_LAST)
|
---|
[21580dd] | 269 |
|
---|
[a64c64d] | 270 | /** Returns a value indicating whether the IPC call is a generic networking message.
|
---|
[21580dd] | 271 | * @param[in] call The IPC call to be checked.
|
---|
| 272 | */
|
---|
[e417b96] | 273 | #define IS_NET_NET_MESSAGE(call) \
|
---|
| 274 | IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_NET_FIRST, NET_NET_LAST)
|
---|
[21580dd] | 275 |
|
---|
[a64c64d] | 276 | /** Returns a value indicating whether the IPC call is a network interface layer message.
|
---|
[21580dd] | 277 | * @param[in] call The IPC call to be checked.
|
---|
| 278 | */
|
---|
[e417b96] | 279 | #define IS_NET_NIL_MESSAGE(call) \
|
---|
| 280 | IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_NIL_FIRST, NET_NIL_LAST)
|
---|
[21580dd] | 281 |
|
---|
[a64c64d] | 282 | /** Returns a value indicating whether the IPC call is a packet manaagement system message.
|
---|
[21580dd] | 283 | * @param[in] call The IPC call to be checked.
|
---|
| 284 | */
|
---|
[e417b96] | 285 | #define IS_NET_PACKET_MESSAGE(call) \
|
---|
| 286 | IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_PACKET_FIRST, NET_PACKET_LAST)
|
---|
[21580dd] | 287 |
|
---|
[a64c64d] | 288 | /** Returns a value indicating whether the IPC call is a socket message.
|
---|
[21580dd] | 289 | * @param[in] call The IPC call to be checked.
|
---|
| 290 | */
|
---|
[e417b96] | 291 | #define IS_NET_SOCKET_MESSAGE(call) \
|
---|
| 292 | IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_SOCKET_FIRST, NET_SOCKET_LAST)
|
---|
[21580dd] | 293 |
|
---|
| 294 | /** Returns a value indicating whether the IPC call is a TCP message.
|
---|
| 295 | * @param[in] call The IPC call to be checked.
|
---|
| 296 | */
|
---|
[e417b96] | 297 | #define IS_NET_TCP_MESSAGE(call) \
|
---|
| 298 | IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_TCP_FIRST, NET_TCP_LAST)
|
---|
[21580dd] | 299 |
|
---|
[a64c64d] | 300 | /** Returns a value indicating whether the IPC call is a transport layer message.
|
---|
[21580dd] | 301 | * @param[in] call The IPC call to be checked.
|
---|
| 302 | */
|
---|
[e417b96] | 303 | #define IS_NET_TL_MESSAGE(call) \
|
---|
| 304 | IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_TL_FIRST, NET_TL_LAST)
|
---|
[21580dd] | 305 |
|
---|
[a64c64d] | 306 | /** Returns a value indicating whether the IPC call is a UDP message.
|
---|
[21580dd] | 307 | * @param[in] call The IPC call to be checked.
|
---|
| 308 | */
|
---|
[e417b96] | 309 | #define IS_NET_UDP_MESSAGE(call) \
|
---|
| 310 | IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_UDP_FIRST, NET_UDP_LAST)
|
---|
[21580dd] | 311 |
|
---|
| 312 | /*@}*/
|
---|
| 313 |
|
---|
[a64c64d] | 314 | /** @name Networking specific message arguments definitions
|
---|
[21580dd] | 315 | */
|
---|
| 316 | /*@{*/
|
---|
| 317 |
|
---|
[a64c64d] | 318 | /** @name First arguments
|
---|
| 319 | */
|
---|
| 320 | /*@{*/
|
---|
| 321 |
|
---|
| 322 | /** Returns the device identifier message argument.
|
---|
[21580dd] | 323 | * @param[in] call The message call structure.
|
---|
| 324 | */
|
---|
[e417b96] | 325 | #define IPC_GET_DEVICE(call) \
|
---|
| 326 | ({device_id_t device_id = (device_id_t) IPC_GET_ARG1(*call); device_id;})
|
---|
[21580dd] | 327 |
|
---|
[e417b96] | 328 | /*@;})*/
|
---|
[a64c64d] | 329 |
|
---|
| 330 | /** @name Second arguments
|
---|
| 331 | */
|
---|
[e417b96] | 332 | /*@({*/
|
---|
[a64c64d] | 333 |
|
---|
| 334 | /** Returns the packet identifier message argument.
|
---|
[21580dd] | 335 | * @param[in] call The message call structure.
|
---|
| 336 | */
|
---|
[e417b96] | 337 | #define IPC_GET_PACKET(call) \
|
---|
| 338 | ({packet_id_t packet_id = (packet_id_t) IPC_GET_ARG2(*call); packet_id;})
|
---|
[21580dd] | 339 |
|
---|
[a64c64d] | 340 | /** Returns the count message argument.
|
---|
[21580dd] | 341 | * @param[in] call The message call structure.
|
---|
| 342 | */
|
---|
[e417b96] | 343 | #define IPC_GET_COUNT(call) \
|
---|
| 344 | ({size_t size = (size_t) IPC_GET_ARG2(*call); size;})
|
---|
[21580dd] | 345 |
|
---|
[a64c64d] | 346 | /** Returns the device state message argument.
|
---|
[21580dd] | 347 | * @param[in] call The message call structure.
|
---|
| 348 | */
|
---|
[e417b96] | 349 | #define IPC_GET_STATE(call) \
|
---|
| 350 | ({device_state_t device_state = (device_state_t) IPC_GET_ARG2(*call); device_state;})
|
---|
[21580dd] | 351 |
|
---|
[a64c64d] | 352 | /** Returns the maximum transmission unit message argument.
|
---|
[21580dd] | 353 | * @param[in] call The message call structure.
|
---|
| 354 | */
|
---|
[e417b96] | 355 | #define IPC_GET_MTU(call) \
|
---|
| 356 | ({size_t size = (size_t) IPC_GET_ARG2(*call); size;})
|
---|
[21580dd] | 357 |
|
---|
[e417b96] | 358 | /*@;})*/
|
---|
[a64c64d] | 359 |
|
---|
| 360 | /** @name Third arguments
|
---|
| 361 | */
|
---|
[e417b96] | 362 | /*@({*/
|
---|
[a64c64d] | 363 |
|
---|
| 364 | /** Returns the device driver service message argument.
|
---|
[21580dd] | 365 | * @param[in] call The message call structure.
|
---|
| 366 | */
|
---|
[e417b96] | 367 | #define IPC_GET_SERVICE(call) \
|
---|
| 368 | ({services_t service = (services_t) IPC_GET_ARG3(*call); service;})
|
---|
[21580dd] | 369 |
|
---|
[a64c64d] | 370 | /** Returns the target service message argument.
|
---|
[21580dd] | 371 | * @param[in] call The message call structure.
|
---|
| 372 | */
|
---|
[e417b96] | 373 | #define IPC_GET_TARGET(call) \
|
---|
| 374 | ({services_t service = (services_t) IPC_GET_ARG3(*call); service;})
|
---|
[21580dd] | 375 |
|
---|
[a64c64d] | 376 | /** Returns the sender service message argument.
|
---|
[21580dd] | 377 | * @param[in] call The message call structure.
|
---|
| 378 | */
|
---|
[e417b96] | 379 | #define IPC_GET_SENDER(call) \
|
---|
| 380 | ({services_t service = (services_t) IPC_GET_ARG3(*call); service;})
|
---|
[21580dd] | 381 |
|
---|
[e417b96] | 382 | /*@;})*/
|
---|
[a64c64d] | 383 |
|
---|
| 384 | /** @name Fourth arguments
|
---|
| 385 | */
|
---|
[e417b96] | 386 | /*@({*/
|
---|
[a64c64d] | 387 |
|
---|
| 388 | /** Returns the error service message argument.
|
---|
[21580dd] | 389 | * @param[in] call The message call structure.
|
---|
| 390 | */
|
---|
[e417b96] | 391 | #define IPC_GET_ERROR(call) \
|
---|
| 392 | ({services_t service = (services_t) IPC_GET_ARG4(*call); service;})
|
---|
[21580dd] | 393 |
|
---|
[e417b96] | 394 | /*@;})*/
|
---|
[a64c64d] | 395 |
|
---|
| 396 | /** @name Fifth arguments
|
---|
| 397 | */
|
---|
[e417b96] | 398 | /*@({*/
|
---|
[a64c64d] | 399 |
|
---|
| 400 | /** Returns the phone message argument.
|
---|
[21580dd] | 401 | * @param[in] call The message call structure.
|
---|
| 402 | */
|
---|
[e417b96] | 403 | #define IPC_GET_PHONE(call) \
|
---|
| 404 | ({int phone = (int) IPC_GET_ARG5(*call); phone;})
|
---|
[21580dd] | 405 |
|
---|
[a64c64d] | 406 | /*@}*/
|
---|
| 407 |
|
---|
| 408 | /** @name First answers
|
---|
| 409 | */
|
---|
| 410 | /*@{*/
|
---|
| 411 |
|
---|
[21580dd] | 412 | /** Sets the device identifier in the message answer.
|
---|
| 413 | * @param[out] answer The message answer structure.
|
---|
| 414 | */
|
---|
[e417b96] | 415 | #define IPC_SET_DEVICE(answer, value) \
|
---|
[3db8889] | 416 | {ipcarg_t argument = (ipcarg_t) (value); IPC_SET_ARG1(*answer, argument);}
|
---|
[21580dd] | 417 |
|
---|
| 418 | /** Sets the minimum address length in the message answer.
|
---|
| 419 | * @param[out] answer The message answer structure.
|
---|
| 420 | */
|
---|
[e417b96] | 421 | #define IPC_SET_ADDR(answer, value) \
|
---|
[3db8889] | 422 | {ipcarg_t argument = (ipcarg_t) (value); IPC_SET_ARG1(*answer, argument);}
|
---|
[21580dd] | 423 |
|
---|
[a64c64d] | 424 | /*@}*/
|
---|
| 425 |
|
---|
| 426 | /** @name Second answers
|
---|
| 427 | */
|
---|
| 428 | /*@{*/
|
---|
| 429 |
|
---|
[21580dd] | 430 | /** Sets the minimum prefix size in the message answer.
|
---|
| 431 | * @param[out] answer The message answer structure.
|
---|
| 432 | */
|
---|
[e417b96] | 433 | #define IPC_SET_PREFIX(answer, value) \
|
---|
[3db8889] | 434 | {ipcarg_t argument = (ipcarg_t) (value); IPC_SET_ARG2(*answer, argument);}
|
---|
[21580dd] | 435 |
|
---|
[a64c64d] | 436 | /*@}*/
|
---|
| 437 |
|
---|
| 438 | /** @name Third answers
|
---|
| 439 | */
|
---|
| 440 | /*@{*/
|
---|
| 441 |
|
---|
[21580dd] | 442 | /** Sets the maximum content size in the message answer.
|
---|
| 443 | * @param[out] answer The message answer structure.
|
---|
| 444 | */
|
---|
[e417b96] | 445 | #define IPC_SET_CONTENT(answer, value) \
|
---|
[3db8889] | 446 | {ipcarg_t argument = (ipcarg_t) (value); IPC_SET_ARG3(*answer, argument);}
|
---|
[21580dd] | 447 |
|
---|
[a64c64d] | 448 | /*@}*/
|
---|
| 449 |
|
---|
| 450 | /** @name Fourth answers
|
---|
| 451 | */
|
---|
| 452 | /*@{*/
|
---|
| 453 |
|
---|
[21580dd] | 454 | /** Sets the minimum suffix size in the message answer.
|
---|
| 455 | * @param[out] answer The message answer structure.
|
---|
| 456 | */
|
---|
[e417b96] | 457 | #define IPC_SET_SUFFIX(answer, value) \
|
---|
[3db8889] | 458 | {ipcarg_t argument = (ipcarg_t) (value); IPC_SET_ARG4(*answer, argument);}
|
---|
[21580dd] | 459 |
|
---|
| 460 | /*@}*/
|
---|
| 461 |
|
---|
[a64c64d] | 462 | /*@}*/
|
---|
| 463 |
|
---|
| 464 | /** Notifies the module about the device state change.
|
---|
| 465 | * @param[in] phone The service module phone.
|
---|
| 466 | * @param[in] message The service specific message.
|
---|
| 467 | * @param[in] device_id The device identifier.
|
---|
| 468 | * @param[in] state The new device state.
|
---|
| 469 | * @param[in] target The target module service.
|
---|
| 470 | * @returns EOK on success.
|
---|
| 471 | */
|
---|
| 472 | static inline int generic_device_state_msg(int phone, int message, device_id_t device_id, int state, services_t target){
|
---|
| 473 | async_msg_3(phone, (ipcarg_t) message, (ipcarg_t) device_id, (ipcarg_t) state, target);
|
---|
| 474 | return EOK;
|
---|
| 475 | }
|
---|
| 476 |
|
---|
| 477 | /** Notifies a module about the device.
|
---|
| 478 | * @param[in] phone The service module phone.
|
---|
| 479 | * @param[in] message The service specific message.
|
---|
| 480 | * @param[in] device_id The device identifier.
|
---|
| 481 | * @param[in] arg2 The second argument of the message.
|
---|
| 482 | * @param[in] service The device module service.
|
---|
| 483 | * @returns EOK on success.
|
---|
| 484 | * @returns Other error codes as defined for the specific service message.
|
---|
| 485 | */
|
---|
| 486 | static inline int generic_device_req(int phone, int message, device_id_t device_id, int arg2, services_t service){
|
---|
| 487 | return (int) async_req_3_0(phone, (ipcarg_t) message, (ipcarg_t) device_id, (ipcarg_t) arg2, (ipcarg_t) service);
|
---|
| 488 | }
|
---|
| 489 |
|
---|
[21580dd] | 490 | /** Returns the address.
|
---|
| 491 | * @param[in] phone The service module phone.
|
---|
| 492 | * @param[in] message The service specific message.
|
---|
| 493 | * @param[in] device_id The device identifier.
|
---|
| 494 | * @param[out] address The desired address.
|
---|
| 495 | * @param[out] data The address data container.
|
---|
| 496 | * @returns EOK on success.
|
---|
| 497 | * @returns EBADMEM if the address parameter and/or the data parameter is NULL.
|
---|
| 498 | * @returns Other error codes as defined for the specific service message.
|
---|
| 499 | */
|
---|
[aadf01e] | 500 | static inline int generic_get_addr_req(int phone, int message, device_id_t device_id, measured_string_ref * address, char ** data){
|
---|
| 501 | aid_t message_id;
|
---|
| 502 | ipcarg_t result;
|
---|
| 503 | int string;
|
---|
| 504 |
|
---|
| 505 | if(!(address && data)){
|
---|
| 506 | return EBADMEM;
|
---|
| 507 | }
|
---|
[a64c64d] | 508 |
|
---|
| 509 | // request the address
|
---|
[aadf01e] | 510 | message_id = async_send_1(phone, (ipcarg_t) message, (ipcarg_t) device_id, NULL);
|
---|
| 511 | string = measured_strings_return(phone, address, data, 1);
|
---|
| 512 | async_wait_for(message_id, &result);
|
---|
| 513 |
|
---|
[a64c64d] | 514 | // if not successful
|
---|
[aadf01e] | 515 | if((string == EOK) && (result != EOK)){
|
---|
[a64c64d] | 516 | // clear the data
|
---|
| 517 | free(*address);
|
---|
[aadf01e] | 518 | free(*data);
|
---|
| 519 | }
|
---|
| 520 | return (int) result;
|
---|
[21580dd] | 521 | }
|
---|
| 522 |
|
---|
[91478aa] | 523 | /** Returns the device packet dimension for sending.
|
---|
[21580dd] | 524 | * @param[in] phone The service module phone.
|
---|
| 525 | * @param[in] message The service specific message.
|
---|
| 526 | * @param[in] device_id The device identifier.
|
---|
[91478aa] | 527 | * @param[out] packet_dimension The packet dimension.
|
---|
[21580dd] | 528 | * @returns EOK on success.
|
---|
[91478aa] | 529 | * @returns EBADMEM if the packet_dimension parameter is NULL.
|
---|
[21580dd] | 530 | * @returns Other error codes as defined for the specific service message.
|
---|
| 531 | */
|
---|
[aadf01e] | 532 | static inline int generic_packet_size_req(int phone, int message, device_id_t device_id, packet_dimension_ref packet_dimension){
|
---|
| 533 | ipcarg_t result;
|
---|
| 534 | ipcarg_t prefix;
|
---|
| 535 | ipcarg_t content;
|
---|
| 536 | ipcarg_t suffix;
|
---|
| 537 | ipcarg_t addr_len;
|
---|
| 538 |
|
---|
| 539 | if(! packet_dimension){
|
---|
| 540 | return EBADMEM;
|
---|
| 541 | }
|
---|
| 542 | result = async_req_1_4(phone, (ipcarg_t) message, (ipcarg_t) device_id, &addr_len, &prefix, &content, &suffix);
|
---|
| 543 | packet_dimension->prefix = (size_t) prefix;
|
---|
| 544 | packet_dimension->content = (size_t) content;
|
---|
| 545 | packet_dimension->suffix = (size_t) suffix;
|
---|
| 546 | packet_dimension->addr_len = (size_t) addr_len;
|
---|
| 547 | return (int) result;
|
---|
[21580dd] | 548 | }
|
---|
| 549 |
|
---|
[a64c64d] | 550 | /** Passes the packet queue to the module.
|
---|
[21580dd] | 551 | * @param[in] phone The service module phone.
|
---|
| 552 | * @param[in] message The service specific message.
|
---|
| 553 | * @param[in] device_id The device identifier.
|
---|
[a64c64d] | 554 | * @param[in] packet_id The received packet or the received packet queue identifier.
|
---|
[21580dd] | 555 | * @param[in] target The target module service.
|
---|
[a64c64d] | 556 | * @param[in] error The error module service.
|
---|
[21580dd] | 557 | * @returns EOK on success.
|
---|
| 558 | */
|
---|
[a64c64d] | 559 | static inline int generic_received_msg(int phone, int message, device_id_t device_id, packet_id_t packet_id, services_t target, services_t error){
|
---|
| 560 | if(error){
|
---|
| 561 | async_msg_4(phone, (ipcarg_t) message, (ipcarg_t) device_id, (ipcarg_t) packet_id, (ipcarg_t) target, (ipcarg_t) error);
|
---|
| 562 | }else{
|
---|
| 563 | async_msg_3(phone, (ipcarg_t) message, (ipcarg_t) device_id, (ipcarg_t) packet_id, (ipcarg_t) target);
|
---|
| 564 | }
|
---|
[21580dd] | 565 | return EOK;
|
---|
| 566 | }
|
---|
| 567 |
|
---|
[a64c64d] | 568 | /** Sends the packet queue.
|
---|
[21580dd] | 569 | * @param[in] phone The service module phone.
|
---|
| 570 | * @param[in] message The service specific message.
|
---|
| 571 | * @param[in] device_id The device identifier.
|
---|
[a64c64d] | 572 | * @param[in] packet_id The packet or the packet queue identifier.
|
---|
| 573 | * @param[in] sender The sending module service.
|
---|
[21580dd] | 574 | * @param[in] error The error module service.
|
---|
| 575 | * @returns EOK on success.
|
---|
| 576 | */
|
---|
[a64c64d] | 577 | static inline int generic_send_msg(int phone, int message, device_id_t device_id, packet_id_t packet_id, services_t sender, services_t error){
|
---|
[aadf01e] | 578 | if(error){
|
---|
[a64c64d] | 579 | async_msg_4(phone, (ipcarg_t) message, (ipcarg_t) device_id, (ipcarg_t) packet_id, (ipcarg_t) sender, (ipcarg_t) error);
|
---|
[21580dd] | 580 | }else{
|
---|
[a64c64d] | 581 | async_msg_3(phone, (ipcarg_t) message, (ipcarg_t) device_id, (ipcarg_t) packet_id, (ipcarg_t) sender);
|
---|
[21580dd] | 582 | }
|
---|
| 583 | return EOK;
|
---|
| 584 | }
|
---|
| 585 |
|
---|
[a64c64d] | 586 | /** Translates the given strings.
|
---|
| 587 | * Allocates and returns the needed memory block as the data parameter.
|
---|
[21580dd] | 588 | * @param[in] phone The service module phone.
|
---|
| 589 | * @param[in] message The service specific message.
|
---|
| 590 | * @param[in] device_id The device identifier.
|
---|
[a64c64d] | 591 | * @param[in] service The module service.
|
---|
| 592 | * @param[in] configuration The key strings.
|
---|
| 593 | * @param[in] count The number of configuration keys.
|
---|
| 594 | * @param[out] translation The translated values.
|
---|
| 595 | * @param[out] data The translation data container.
|
---|
[21580dd] | 596 | * @returns EOK on success.
|
---|
[a64c64d] | 597 | * @returns EINVAL if the configuration parameter is NULL.
|
---|
| 598 | * @returns EINVAL if the count parameter is zero (0).
|
---|
| 599 | * @returns EBADMEM if the translation or the data parameters are NULL.
|
---|
[21580dd] | 600 | * @returns Other error codes as defined for the specific service message.
|
---|
| 601 | */
|
---|
[a64c64d] | 602 | static inline int generic_translate_req(int phone, int message, device_id_t device_id, services_t service, measured_string_ref configuration, size_t count, measured_string_ref * translation, char ** data){
|
---|
| 603 | aid_t message_id;
|
---|
| 604 | ipcarg_t result;
|
---|
| 605 | int string;
|
---|
| 606 |
|
---|
| 607 | if(!(configuration && (count > 0))){
|
---|
| 608 | return EINVAL;
|
---|
| 609 | }
|
---|
| 610 | if(!(translation && data)){
|
---|
| 611 | return EBADMEM;
|
---|
| 612 | }
|
---|
| 613 |
|
---|
| 614 | // request the translation
|
---|
| 615 | message_id = async_send_3(phone, (ipcarg_t) message, (ipcarg_t) device_id, (ipcarg_t) count, (ipcarg_t) service, NULL);
|
---|
| 616 | measured_strings_send(phone, configuration, count);
|
---|
| 617 | string = measured_strings_return(phone, translation, data, count);
|
---|
| 618 | async_wait_for(message_id, &result);
|
---|
| 619 |
|
---|
| 620 | // if not successful
|
---|
| 621 | if((string == EOK) && (result != EOK)){
|
---|
| 622 | // clear the data
|
---|
| 623 | free(*translation);
|
---|
| 624 | free(*data);
|
---|
| 625 | }
|
---|
| 626 |
|
---|
| 627 | return (int) result;
|
---|
[21580dd] | 628 | }
|
---|
| 629 |
|
---|
| 630 | #endif
|
---|
| 631 |
|
---|
| 632 | /** @}
|
---|
| 633 | */
|
---|