source: mainline/uspace/srv/net/messages.h@ 3db8889

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