Rev 4743 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3466 | mejdrech | 1 | /* |
3912 | mejdrech | 2 | * Copyright (c) 2009 Lukas Mejdrech |
3466 | 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 |
||
3912 | mejdrech | 30 | * @{ |
3466 | mejdrech | 31 | */ |
32 | |||
33 | /** @file |
||
4756 | mejdrech | 34 | * Networking common message definitions. |
3466 | mejdrech | 35 | */ |
36 | |||
3846 | mejdrech | 37 | #ifndef __NET_MESSAGES_H__ |
38 | #define __NET_MESSAGES_H__ |
||
39 | |||
4261 | mejdrech | 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 | |||
4756 | mejdrech | 50 | /** @name Networking message counts |
51 | */ |
||
52 | /*@{*/ |
||
53 | |||
54 | /** The number of network interface driver messages. |
||
55 | */ |
||
4703 | mejdrech | 56 | #define NET_NETIF_COUNT 6 |
4756 | mejdrech | 57 | |
58 | /** The number of general networking messages. |
||
59 | */ |
||
4743 | mejdrech | 60 | #define NET_NET_COUNT 3 |
4756 | mejdrech | 61 | |
62 | /** The number of network interface layer messages. |
||
63 | */ |
||
4261 | mejdrech | 64 | #define NET_NIL_COUNT 7 |
4756 | mejdrech | 65 | |
66 | /** The number of Ethernet messages. |
||
67 | */ |
||
3846 | mejdrech | 68 | #define NET_ETH_COUNT 0 |
4756 | mejdrech | 69 | |
70 | /** The number of inter-network messages. |
||
71 | */ |
||
4695 | mejdrech | 72 | #define NET_IL_COUNT 6 |
4756 | mejdrech | 73 | |
74 | /** The number of IP messages. |
||
75 | */ |
||
4722 | mejdrech | 76 | #define NET_IP_COUNT 4 |
4756 | mejdrech | 77 | |
78 | /** The number of ARP messages. |
||
79 | */ |
||
4695 | mejdrech | 80 | #define NET_ARP_COUNT 5 |
4756 | mejdrech | 81 | |
82 | /** The number of ICMP messages. |
||
83 | */ |
||
4743 | mejdrech | 84 | #define NET_ICMP_COUNT 6 |
4756 | mejdrech | 85 | |
86 | /** The number of transport layer messages. |
||
87 | */ |
||
4502 | mejdrech | 88 | #define NET_TL_COUNT 1 |
4756 | mejdrech | 89 | |
90 | /** The number of UDP messages. |
||
91 | */ |
||
3666 | mejdrech | 92 | #define NET_UDP_COUNT 0 |
4756 | mejdrech | 93 | |
94 | /** The number of TCP messages. |
||
95 | */ |
||
3666 | mejdrech | 96 | #define NET_TCP_COUNT 0 |
4756 | mejdrech | 97 | |
98 | /** The number of packet management system messages. |
||
99 | */ |
||
3901 | mejdrech | 100 | #define NET_PACKET_COUNT 5 |
4756 | mejdrech | 101 | |
102 | /** The number of socket messages. |
||
103 | */ |
||
4578 | mejdrech | 104 | #define NET_SOCKET_COUNT 14 |
3666 | mejdrech | 105 | |
4756 | mejdrech | 106 | /*@}*/ |
107 | |||
108 | /** @name Networking message intervals |
||
109 | */ |
||
110 | /*@{*/ |
||
111 | |||
112 | /** The first networking message. |
||
113 | */ |
||
4307 | mejdrech | 114 | #define NET_FIRST 2000 |
3666 | mejdrech | 115 | |
4756 | mejdrech | 116 | /** The first network interface layer message. |
117 | */ |
||
3666 | mejdrech | 118 | #define NET_NETIF_FIRST NET_FIRST |
4756 | mejdrech | 119 | |
120 | /** The last network interface layer message. |
||
121 | */ |
||
3666 | mejdrech | 122 | #define NET_NETIF_LAST ( NET_NETIF_FIRST + NET_NETIF_COUNT ) |
123 | |||
4756 | mejdrech | 124 | /** The first general networking message. |
125 | */ |
||
3846 | mejdrech | 126 | #define NET_NET_FIRST ( NET_NETIF_LAST + 0 ) |
4756 | mejdrech | 127 | |
128 | /** The last general networking message. |
||
129 | */ |
||
3846 | mejdrech | 130 | #define NET_NET_LAST ( NET_NET_FIRST + NET_NET_COUNT ) |
3666 | mejdrech | 131 | |
4756 | mejdrech | 132 | /** The first network interface layer message. |
133 | */ |
||
3846 | mejdrech | 134 | #define NET_NIL_FIRST ( NET_NET_LAST + 0 ) |
4756 | mejdrech | 135 | |
136 | /** The last network interface layer message. |
||
137 | */ |
||
3846 | mejdrech | 138 | #define NET_NIL_LAST ( NET_NIL_FIRST + NET_NIL_COUNT ) |
4756 | mejdrech | 139 | |
140 | /** The first Ethernet message. |
||
141 | */ |
||
3846 | mejdrech | 142 | #define NET_ETH_FIRST ( NET_NIL_LAST + 0 ) |
4756 | mejdrech | 143 | |
144 | /** The last Ethernet message. |
||
145 | */ |
||
3846 | mejdrech | 146 | #define NET_ETH_LAST ( NET_ETH_FIRST + NET_ETH_COUNT ) |
3666 | mejdrech | 147 | |
4756 | mejdrech | 148 | /** The first inter-network message. |
149 | */ |
||
3846 | mejdrech | 150 | #define NET_IL_FIRST ( NET_ETH_LAST + 0 ) |
4756 | mejdrech | 151 | |
152 | /** The last inter-network message. |
||
153 | */ |
||
4307 | mejdrech | 154 | #define NET_IL_LAST ( NET_IL_FIRST + NET_IL_COUNT ) |
4756 | mejdrech | 155 | |
156 | /** The first IP message. |
||
157 | */ |
||
3666 | mejdrech | 158 | #define NET_IP_FIRST ( NET_IL_LAST + 0 ) |
4756 | mejdrech | 159 | |
160 | /** The last IP message. |
||
161 | */ |
||
4307 | mejdrech | 162 | #define NET_IP_LAST ( NET_IP_FIRST + NET_IP_COUNT ) |
3666 | mejdrech | 163 | |
4756 | mejdrech | 164 | /** The first ARP message. |
165 | */ |
||
3466 | mejdrech | 166 | #define NET_ARP_FIRST ( NET_IP_LAST + 0 ) |
4756 | mejdrech | 167 | |
168 | /** The last ARP message. |
||
169 | */ |
||
3666 | mejdrech | 170 | #define NET_ARP_LAST ( NET_ARP_FIRST + NET_ARP_COUNT ) |
4756 | mejdrech | 171 | |
172 | /** The first ICMP message. |
||
173 | */ |
||
4743 | mejdrech | 174 | #define NET_ICMP_FIRST ( NET_ARP_LAST + 0 ) |
4756 | mejdrech | 175 | |
176 | /** The last ICMP message. |
||
177 | */ |
||
3666 | mejdrech | 178 | #define NET_ICMP_LAST ( NET_ICMP_FIRST + NET_ICMP_COUNT ) |
4502 | mejdrech | 179 | |
4756 | mejdrech | 180 | /** The first ICMP message. |
181 | */ |
||
4502 | mejdrech | 182 | #define NET_TL_FIRST ( NET_ICMP_LAST + 0 ) |
4756 | mejdrech | 183 | |
184 | /** The last ICMP message. |
||
185 | */ |
||
4502 | mejdrech | 186 | #define NET_TL_LAST ( NET_TL_FIRST + NET_TL_COUNT ) |
4756 | mejdrech | 187 | |
188 | /** The first UDP message. |
||
189 | */ |
||
4502 | mejdrech | 190 | #define NET_UDP_FIRST ( NET_TL_LAST + 0 ) |
4756 | mejdrech | 191 | |
192 | /** The last UDP message. |
||
193 | */ |
||
3666 | mejdrech | 194 | #define NET_UDP_LAST ( NET_UDP_FIRST + NET_UDP_COUNT ) |
4756 | mejdrech | 195 | |
196 | /** The first TCP message. |
||
197 | */ |
||
3466 | mejdrech | 198 | #define NET_TCP_FIRST ( NET_UDP_LAST + 0 ) |
4756 | mejdrech | 199 | |
200 | /** The last TCP message. |
||
201 | */ |
||
3666 | mejdrech | 202 | #define NET_TCP_LAST ( NET_TCP_FIRST + NET_TCP_COUNT ) |
203 | |||
4756 | mejdrech | 204 | /** The first socket message. |
205 | */ |
||
3466 | mejdrech | 206 | #define NET_SOCKET_FIRST ( NET_TCP_LAST + 0 ) |
4756 | mejdrech | 207 | |
208 | /** The last socket message. |
||
209 | */ |
||
3666 | mejdrech | 210 | #define NET_SOCKET_LAST ( NET_SOCKET_FIRST + NET_SOCKET_COUNT ) |
3466 | mejdrech | 211 | |
4756 | mejdrech | 212 | /** The first packet management system message. |
213 | */ |
||
3901 | mejdrech | 214 | #define NET_PACKET_FIRST ( NET_SOCKET_LAST + 0 ) |
4756 | mejdrech | 215 | |
216 | /** The last packet management system message. |
||
217 | */ |
||
3901 | mejdrech | 218 | #define NET_PACKET_LAST ( NET_PACKET_FIRST + NET_PACKET_COUNT ) |
3666 | mejdrech | 219 | |
4756 | mejdrech | 220 | /** The last networking message. |
221 | */ |
||
4307 | mejdrech | 222 | #define NET_LAST NET_PACKET_LAST |
3901 | mejdrech | 223 | |
4756 | mejdrech | 224 | /** The number of networking messages. |
225 | */ |
||
4307 | mejdrech | 226 | #define NET_COUNT ( NET_LAST - NET_FIRST ) |
3666 | mejdrech | 227 | |
4756 | mejdrech | 228 | /** Returns a value indicating whether the value is in the interval. |
229 | * @param[in] item The value to be checked. |
||
230 | * @param[in] first_inclusive The first value in the interval inclusive. |
||
231 | * @param[in] last_exclusive The first value after the interval. |
||
232 | */ |
||
3666 | mejdrech | 233 | #define IS_IN_INTERVAL( item, first_inclusive, last_exclusive ) ((( item ) >= ( first_inclusive )) && (( item ) < ( last_exclusive ))) |
234 | |||
4756 | mejdrech | 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 | */ |
||
3901 | mejdrech | 238 | #define IS_NET_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_FIRST, NET_LAST ) |
4756 | mejdrech | 239 | |
240 | /** Returns a value indicating whether the IPC call is a generic networking message. |
||
241 | * @param[in] call The IPC call to be checked. |
||
242 | */ |
||
3901 | mejdrech | 243 | #define IS_NET_NET_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_NET_FIRST, NET_NET_LAST ) |
4756 | mejdrech | 244 | |
245 | /** Returns a value indicating whether the IPC call is a network interface layer message. |
||
246 | * @param[in] call The IPC call to be checked. |
||
247 | */ |
||
3901 | mejdrech | 248 | #define IS_NET_NIL_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_NIL_FIRST, NET_NIL_LAST ) |
4756 | mejdrech | 249 | |
250 | /** Returns a value indicating whether the IPC call is an Ethernet message. |
||
251 | * @param[in] call The IPC call to be checked. |
||
252 | */ |
||
3901 | mejdrech | 253 | #define IS_NET_ETH_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_ETH_FIRST, NET_ETH_LAST ) |
4756 | mejdrech | 254 | |
255 | /** Returns a value indicating whether the IPC call is an inter-network layer message. |
||
256 | * @param[in] call The IPC call to be checked. |
||
257 | */ |
||
3901 | mejdrech | 258 | #define IS_NET_IL_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_IL_FIRST, NET_IL_LAST ) |
4756 | mejdrech | 259 | |
260 | /** Returns a value indicating whether the IPC call is an IP message. |
||
261 | * @param[in] call The IPC call to be checked. |
||
262 | */ |
||
3901 | mejdrech | 263 | #define IS_NET_IP_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_IP_FIRST, NET_IP_LAST ) |
4756 | mejdrech | 264 | |
265 | /** Returns a value indicating whether the IPC call is an ARP message. |
||
266 | * @param[in] call The IPC call to be checked. |
||
267 | */ |
||
3901 | mejdrech | 268 | #define IS_NET_ARP_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_ARP_FIRST, NET_ARP_LAST ) |
4756 | mejdrech | 269 | |
270 | /** Returns a value indicating whether the IPC call is an ICMP message. |
||
271 | * @param[in] call The IPC call to be checked. |
||
272 | */ |
||
4707 | mejdrech | 273 | #define IS_NET_ICMP_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_ICMP_FIRST, NET_ICMP_LAST ) |
4756 | mejdrech | 274 | |
275 | /** Returns a value indicating whether the IPC call is a transport layer message. |
||
276 | * @param[in] call The IPC call to be checked. |
||
277 | */ |
||
4502 | mejdrech | 278 | #define IS_NET_TL_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_TL_FIRST, NET_TL_LAST ) |
4756 | mejdrech | 279 | |
280 | /** Returns a value indicating whether the IPC call is a UDP message. |
||
281 | * @param[in] call The IPC call to be checked. |
||
282 | */ |
||
3901 | mejdrech | 283 | #define IS_NET_UDP_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_UDP_FIRST, NET_UDP_LAST ) |
4756 | mejdrech | 284 | |
285 | /** Returns a value indicating whether the IPC call is a TCP message. |
||
286 | * @param[in] call The IPC call to be checked. |
||
287 | */ |
||
3901 | mejdrech | 288 | #define IS_NET_TCP_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_TCP_FIRST, NET_TCP_LAST ) |
4756 | mejdrech | 289 | |
290 | /** Returns a value indicating whether the IPC call is a socket message. |
||
291 | * @param[in] call The IPC call to be checked. |
||
292 | */ |
||
3901 | mejdrech | 293 | #define IS_NET_SOCKET_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_SOCKET_FIRST, NET_SOCKET_LAST ) |
4756 | mejdrech | 294 | |
295 | /** Returns a value indicating whether the IPC call is a packet manaagement system message. |
||
296 | * @param[in] call The IPC call to be checked. |
||
297 | */ |
||
3901 | mejdrech | 298 | #define IS_NET_PACKET_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_PACKET_FIRST, NET_PACKET_LAST ) |
3666 | mejdrech | 299 | |
4756 | mejdrech | 300 | /*@}*/ |
301 | |||
302 | /** @name Networking specific message parameters definitions |
||
303 | */ |
||
304 | /*@{*/ |
||
305 | |||
4261 | mejdrech | 306 | /** Returns the device identifier message parameter. |
4756 | mejdrech | 307 | * @param[in] call The message call structure. |
4261 | mejdrech | 308 | */ |
309 | #define IPC_GET_DEVICE( call ) ( device_id_t ) IPC_GET_ARG1( * call ) |
||
310 | |||
311 | /** Returns the packet identifier message parameter. |
||
4756 | mejdrech | 312 | * @param[in] call The message call structure. |
4261 | mejdrech | 313 | */ |
314 | #define IPC_GET_PACKET( call ) ( packet_id_t ) IPC_GET_ARG2( * call ) |
||
4756 | mejdrech | 315 | |
316 | /** Returns the count message parameter. |
||
317 | * @param[in] call The message call structure. |
||
318 | */ |
||
4502 | mejdrech | 319 | #define IPC_GET_COUNT( call ) ( size_t ) IPC_GET_ARG2( * call ) |
4756 | mejdrech | 320 | |
321 | /** Returns the device state message parameter. |
||
322 | * @param[in] call The message call structure. |
||
323 | */ |
||
4261 | mejdrech | 324 | #define IPC_GET_STATE( call ) ( device_state_t ) IPC_GET_ARG2( * call ) |
325 | |||
4695 | mejdrech | 326 | /** Returns the maximum transmission unit message parameter. |
4756 | mejdrech | 327 | * @param[in] call The message call structure. |
4695 | mejdrech | 328 | */ |
329 | #define IPC_GET_MTU( call ) ( size_t ) IPC_GET_ARG2( * call ) |
||
330 | |||
4261 | mejdrech | 331 | /** Returns the device driver service message parameter. |
4756 | mejdrech | 332 | * @param[in] call The message call structure. |
4261 | mejdrech | 333 | */ |
334 | #define IPC_GET_SERVICE( call ) ( services_t ) IPC_GET_ARG3( * call ) |
||
4756 | mejdrech | 335 | |
336 | /** Returns the target service message parameter. |
||
337 | * @param[in] call The message call structure. |
||
338 | */ |
||
4261 | mejdrech | 339 | #define IPC_GET_TARGET( call ) ( services_t ) IPC_GET_ARG3( * call ) |
4756 | mejdrech | 340 | |
341 | /** Returns the sender service message parameter. |
||
342 | * @param[in] call The message call structure. |
||
343 | */ |
||
4261 | mejdrech | 344 | #define IPC_GET_SENDER( call ) ( services_t ) IPC_GET_ARG3( * call ) |
345 | |||
4756 | mejdrech | 346 | /** Returns the error service message parameter. |
347 | * @param[in] call The message call structure. |
||
348 | */ |
||
4707 | mejdrech | 349 | #define IPC_GET_ERROR( call ) ( services_t ) IPC_GET_ARG4( * call ) |
350 | |||
4756 | mejdrech | 351 | /** Returns the phone message parameter. |
352 | * @param[in] call The message call structure. |
||
353 | */ |
||
4243 | mejdrech | 354 | #define IPC_GET_PHONE( call ) ( int ) IPC_GET_ARG5( * call ) |
355 | |||
4756 | mejdrech | 356 | /** Sets the device identifier in the message answer. |
357 | * @param[out] answer The message answer structure. |
||
358 | */ |
||
4722 | mejdrech | 359 | #define IPC_SET_DEVICE( answer ) (( device_id_t * ) & IPC_GET_ARG1( * answer )) |
360 | |||
4756 | mejdrech | 361 | /** Sets the minimum address length in the message answer. |
362 | * @param[out] answer The message answer structure. |
||
363 | */ |
||
4261 | mejdrech | 364 | #define IPC_SET_ADDR( answer ) (( size_t * ) & IPC_GET_ARG1( * answer )) |
4756 | mejdrech | 365 | |
366 | /** Sets the minimum prefix size in the message answer. |
||
367 | * @param[out] answer The message answer structure. |
||
368 | */ |
||
4261 | mejdrech | 369 | #define IPC_SET_PREFIX( answer ) (( size_t * ) & IPC_GET_ARG2( * answer )) |
4756 | mejdrech | 370 | |
371 | /** Sets the maximum content size in the message answer. |
||
372 | * @param[out] answer The message answer structure. |
||
373 | */ |
||
4261 | mejdrech | 374 | #define IPC_SET_CONTENT( answer ) (( size_t * ) & IPC_GET_ARG3( * answer )) |
4756 | mejdrech | 375 | |
376 | /** Sets the minimum suffix size in the message answer. |
||
377 | * @param[out] answer The message answer structure. |
||
378 | */ |
||
4261 | mejdrech | 379 | #define IPC_SET_SUFFIX( answer ) (( size_t * ) & IPC_GET_ARG4( * answer )) |
380 | |||
4756 | mejdrech | 381 | /*@}*/ |
382 | |||
383 | /** Returns the address. |
||
384 | * @param[in] phone The service module phone. |
||
385 | * @param[in] message The service specific message. |
||
386 | * @param[in] device_id The device identifier. |
||
387 | * @param[out] address The desired address. |
||
388 | * @param[out] data The address data container. |
||
389 | * @returns EOK on success. |
||
390 | * @returns EBADMEM if the address parameter and/or the data parameter is NULL. |
||
391 | * @returns Other error codes as defined for the specific service message. |
||
392 | */ |
||
4743 | mejdrech | 393 | static inline int generic_get_addr_req( int phone, int message, device_id_t device_id, measured_string_ref * address, char ** data ){ |
4261 | mejdrech | 394 | aid_t message_id; |
395 | ipcarg_t result; |
||
396 | int string; |
||
397 | |||
398 | if( !( address && data )) return EBADMEM; |
||
4307 | mejdrech | 399 | message_id = async_send_1( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, NULL ); |
4261 | mejdrech | 400 | string = measured_strings_return( phone, address, data, 1 ); |
401 | async_wait_for( message_id, & result ); |
||
402 | if(( string == EOK ) && ( result != EOK )){ |
||
403 | free( * address ); |
||
404 | free( * data ); |
||
405 | } |
||
4307 | mejdrech | 406 | return ( int ) result; |
4261 | mejdrech | 407 | } |
408 | |||
4756 | mejdrech | 409 | /** Translates the given strings. |
410 | * Allocates and returns the needed memory block as the data parameter. |
||
411 | * @param[in] phone The service module phone. |
||
412 | * @param[in] message The service specific message. |
||
413 | * @param[in] device_id The device identifier. |
||
414 | * @param[in] service The module service. |
||
415 | * @param[in] configuration The key strings. |
||
416 | * @param[in] count The number of configuration keys. |
||
417 | * @param[out] translation The translated values. |
||
418 | * @param[out] data The translation data container. |
||
419 | * @returns EOK on success. |
||
420 | * @returns EINVAL if the configuration parameter is NULL. |
||
421 | * @returns EINVAL if the count parameter is zero (0). |
||
422 | * @returns EBADMEM if the translation or the data parameters are NULL. |
||
423 | * @returns Other error codes as defined for the specific service message. |
||
424 | */ |
||
4307 | mejdrech | 425 | 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 ){ |
426 | aid_t message_id; |
||
427 | ipcarg_t result; |
||
428 | int string; |
||
429 | |||
430 | if( !( configuration && ( count > 0 ))) return EINVAL; |
||
431 | if( !( translation && data )) return EBADMEM; |
||
432 | message_id = async_send_3( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, ( ipcarg_t ) count, ( ipcarg_t ) service, NULL ); |
||
433 | measured_strings_send( phone, configuration, count ); |
||
434 | string = measured_strings_return( phone, translation, data, count ); |
||
435 | async_wait_for( message_id, & result ); |
||
436 | if(( string == EOK ) && ( result != EOK )){ |
||
437 | free( * translation ); |
||
438 | free( * data ); |
||
439 | } |
||
440 | return ( int ) result; |
||
4261 | mejdrech | 441 | } |
442 | |||
4756 | mejdrech | 443 | /** Sends the packet queue. |
444 | * @param[in] phone The service module phone. |
||
445 | * @param[in] message The service specific message. |
||
446 | * @param[in] device_id The device identifier. |
||
447 | * @param[in] packet_id The packet or the packet queue identifier. |
||
448 | * @param[in] sender The sending module service. |
||
449 | * @param[in] error The error module service. |
||
450 | * @returns EOK on success. |
||
451 | */ |
||
4707 | mejdrech | 452 | 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 ){ |
453 | if( error ){ |
||
454 | async_msg_4( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, ( ipcarg_t ) packet_id, ( ipcarg_t ) sender, ( ipcarg_t ) error ); |
||
455 | }else{ |
||
456 | async_msg_3( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, ( ipcarg_t ) packet_id, ( ipcarg_t ) sender ); |
||
457 | } |
||
4307 | mejdrech | 458 | return EOK; |
459 | } |
||
460 | |||
4756 | mejdrech | 461 | /** Returns the device packet dimensions for sending. |
462 | * @param[in] phone The service module phone. |
||
463 | * @param[in] message The service specific message. |
||
464 | * @param[in] device_id The device identifier. |
||
465 | * @param[out] addr_len The minimum reserved address length. |
||
466 | * @param[out] prefix The minimum reserved prefix size. |
||
467 | * @param[out] content The maximum content size. |
||
468 | * @param[out] suffix The minimum reserved suffix size. |
||
469 | * @returns EOK on success. |
||
470 | * @returns Other error codes as defined for the specific service message. |
||
471 | */ |
||
4261 | mejdrech | 472 | static inline int generic_packet_size_req( int phone, int message, device_id_t device_id, size_t * addr_len, size_t * prefix, size_t * content, size_t * suffix ){ |
4307 | mejdrech | 473 | return ( int ) async_req_1_4( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, ( ipcarg_t * ) addr_len, ( ipcarg_t * ) prefix, ( ipcarg_t * ) content, ( ipcarg_t * ) suffix ); |
4261 | mejdrech | 474 | } |
475 | |||
4756 | mejdrech | 476 | /** Notifies the module about the device state change. |
477 | * @param[in] phone The service module phone. |
||
478 | * @param[in] message The service specific message. |
||
479 | * @param[in] device_id The device identifier. |
||
480 | * @param[in] state The new device state. |
||
481 | * @param[in] target The target module service. |
||
482 | * @returns EOK on success. |
||
483 | */ |
||
4351 | mejdrech | 484 | static inline int generic_device_state_msg( int phone, int message, device_id_t device_id, int state, services_t target ){ |
485 | async_msg_3( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, ( ipcarg_t ) state, target ); |
||
4307 | mejdrech | 486 | return EOK; |
4261 | mejdrech | 487 | } |
488 | |||
4756 | mejdrech | 489 | /** Passes the packet queue to the module. |
490 | * @param[in] phone The service module phone. |
||
491 | * @param[in] message The service specific message. |
||
492 | * @param[in] device_id The device identifier. |
||
493 | * @param[in] packet_id The received packet or the received packet queue identifier. |
||
494 | * @param[in] target The target module service. |
||
495 | * @param[in] error The error module service. |
||
496 | * @returns EOK on success. |
||
497 | */ |
||
4707 | mejdrech | 498 | 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 ){ |
499 | if( error ){ |
||
500 | async_msg_4( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, ( ipcarg_t ) packet_id, ( ipcarg_t ) target, ( ipcarg_t ) error ); |
||
501 | }else{ |
||
502 | async_msg_3( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, ( ipcarg_t ) packet_id, ( ipcarg_t ) target ); |
||
503 | } |
||
4307 | mejdrech | 504 | return EOK; |
4261 | mejdrech | 505 | } |
506 | |||
4756 | mejdrech | 507 | /** Notifies a module about the device. |
508 | * @param[in] phone The service module phone. |
||
509 | * @param[in] message The service specific message. |
||
510 | * @param[in] device_id The device identifier. |
||
511 | * @param[in] arg2 The second argument of the message. |
||
512 | * @param[in] service The device module service. |
||
513 | * @returns EOK on success. |
||
514 | * @returns Other error codes as defined for the specific service message. |
||
515 | */ |
||
4261 | mejdrech | 516 | static inline int generic_device_req( int phone, int message, device_id_t device_id, int arg2, services_t service ){ |
4307 | mejdrech | 517 | return ( int ) async_req_3_0( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, ( ipcarg_t ) arg2, ( ipcarg_t ) service ); |
4261 | mejdrech | 518 | } |
519 | |||
3846 | mejdrech | 520 | #endif |
521 | |||
3466 | mejdrech | 522 | /** @} |
523 | */ |