Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/messages.h

    ra64c64d r91478aa  
    4848#include "structures/packet/packet.h"
    4949
     50/** @name Networking message counts
     51 */
     52/*@{*/
     53
     54/** The number of network interface driver messages.
     55 */
     56#define NET_NETIF_COUNT         6
     57
     58/** The number of general networking messages.
     59 */
     60#define NET_NET_COUNT           3
     61
     62/** The number of network interface layer messages.
     63 */
     64#define NET_NIL_COUNT           7
     65
     66/** The number of Ethernet messages.
     67 */
     68#define NET_ETH_COUNT           0
     69
     70/** The number of inter-network messages.
     71 */
     72#define NET_IL_COUNT            6
     73
     74/** The number of IP messages.
     75 */
     76#define NET_IP_COUNT            4
     77
     78/** The number of ARP messages.
     79 */
     80#define NET_ARP_COUNT           5
     81
     82/** The number of ICMP messages.
     83 */
     84#define NET_ICMP_COUNT          6
     85
     86/** The number of transport layer messages.
     87 */
     88#define NET_TL_COUNT            1
     89
     90/** The number of UDP messages.
     91 */
     92#define NET_UDP_COUNT           0
     93
     94/** The number of TCP messages.
     95 */
     96#define NET_TCP_COUNT           0
     97
     98/** The number of packet management system messages.
     99 */
     100#define NET_PACKET_COUNT        5
     101
     102/** The number of socket messages.
     103 */
     104#define NET_SOCKET_COUNT        14
     105
     106/*@}*/
     107
     108/** @name Networking message intervals
     109 */
     110/*@{*/
     111
     112/** The first networking message.
     113 */
     114#define NET_FIRST                       2000
     115
     116/** The first network interface layer message.
     117 */
     118#define NET_NETIF_FIRST         NET_FIRST
     119
     120/** The last network interface layer message.
     121 */
     122#define NET_NETIF_LAST          ( NET_NETIF_FIRST + NET_NETIF_COUNT )
     123
     124/** The first general networking message.
     125 */
     126#define NET_NET_FIRST           ( NET_NETIF_LAST + 0 )
     127
     128/** The last general networking message.
     129 */
     130#define NET_NET_LAST            ( NET_NET_FIRST + NET_NET_COUNT )
     131
     132/** The first network interface layer message.
     133 */
     134#define NET_NIL_FIRST           ( NET_NET_LAST + 0 )
     135
     136/** The last network interface layer message.
     137 */
     138#define NET_NIL_LAST            ( NET_NIL_FIRST + NET_NIL_COUNT )
     139
     140/** The first Ethernet message.
     141 */
     142#define NET_ETH_FIRST           ( NET_NIL_LAST + 0 )
     143
     144/** The last Ethernet message.
     145 */
     146#define NET_ETH_LAST            ( NET_ETH_FIRST + NET_ETH_COUNT )
     147
     148/** The first inter-network message.
     149 */
     150#define NET_IL_FIRST            ( NET_ETH_LAST + 0 )
     151
     152/** The last inter-network message.
     153 */
     154#define NET_IL_LAST                     ( NET_IL_FIRST + NET_IL_COUNT )
     155
     156/** The first IP message.
     157 */
     158#define NET_IP_FIRST            ( NET_IL_LAST + 0 )
     159
     160/** The last IP message.
     161 */
     162#define NET_IP_LAST                     ( NET_IP_FIRST + NET_IP_COUNT )
     163
     164/** The first ARP message.
     165 */
     166#define NET_ARP_FIRST           ( NET_IP_LAST + 0 )
     167
     168/** The last ARP message.
     169 */
     170#define NET_ARP_LAST            ( NET_ARP_FIRST + NET_ARP_COUNT )
     171
     172/** The first ICMP message.
     173 */
     174#define NET_ICMP_FIRST          ( NET_ARP_LAST + 0 )
     175
     176/** The last ICMP message.
     177 */
     178#define NET_ICMP_LAST           ( NET_ICMP_FIRST + NET_ICMP_COUNT )
     179
     180/** The first ICMP message.
     181 */
     182#define NET_TL_FIRST            ( NET_ICMP_LAST + 0 )
     183
     184/** The last ICMP message.
     185 */
     186#define NET_TL_LAST                     ( NET_TL_FIRST + NET_TL_COUNT )
     187
     188/** The first UDP message.
     189 */
     190#define NET_UDP_FIRST           ( NET_TL_LAST + 0 )
     191
     192/** The last UDP message.
     193 */
     194#define NET_UDP_LAST            ( NET_UDP_FIRST + NET_UDP_COUNT )
     195
     196/** The first TCP message.
     197 */
     198#define NET_TCP_FIRST           ( NET_UDP_LAST + 0 )
     199
     200/** The last TCP message.
     201 */
     202#define NET_TCP_LAST            ( NET_TCP_FIRST + NET_TCP_COUNT )
     203
     204/** The first socket message.
     205 */
     206#define NET_SOCKET_FIRST        ( NET_TCP_LAST + 0 )
     207
     208/** The last socket message.
     209 */
     210#define NET_SOCKET_LAST         ( NET_SOCKET_FIRST + NET_SOCKET_COUNT )
     211
     212/** The first packet management system message.
     213 */
     214#define NET_PACKET_FIRST        ( NET_SOCKET_LAST + 0 )
     215
     216/** The last packet management system message.
     217 */
     218#define NET_PACKET_LAST         ( NET_PACKET_FIRST + NET_PACKET_COUNT )
     219
     220/** The last networking message.
     221 */
     222#define NET_LAST                        NET_PACKET_LAST
     223
     224/** The number of networking messages.
     225 */
     226#define NET_COUNT                       ( NET_LAST - NET_FIRST )
     227
    50228/** Returns a value indicating whether the value is in the interval.
    51229 *  @param[in] item The value to be checked.
     
    53231 *  @param[in] last_exclusive The first value after the interval.
    54232 */
    55 #define IS_IN_INTERVAL(item, first_inclusive, last_exclusive)   (((item) >= (first_inclusive)) && ((item) < (last_exclusive)))
    56 
    57 /** @name Networking message counts
     233#define IS_IN_INTERVAL( item, first_inclusive, last_exclusive ) ((( item ) >= ( first_inclusive )) && (( item ) < ( last_exclusive )))
     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 */
     238#define IS_NET_MESSAGE( call )                  IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_FIRST, NET_LAST )
     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 */
     243#define IS_NET_NET_MESSAGE( call )              IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_NET_FIRST, NET_NET_LAST )
     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 */
     248#define IS_NET_NIL_MESSAGE( call )              IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_NIL_FIRST, NET_NIL_LAST )
     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 */
     253#define IS_NET_ETH_MESSAGE( call )              IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_ETH_FIRST, NET_ETH_LAST )
     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 */
     258#define IS_NET_IL_MESSAGE( call )               IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_IL_FIRST, NET_IL_LAST )
     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 */
     263#define IS_NET_IP_MESSAGE( call )               IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_IP_FIRST, NET_IP_LAST )
     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 */
     268#define IS_NET_ARP_MESSAGE( call )              IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_ARP_FIRST, NET_ARP_LAST )
     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 */
     273#define IS_NET_ICMP_MESSAGE( call )             IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_ICMP_FIRST, NET_ICMP_LAST )
     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 */
     278#define IS_NET_TL_MESSAGE( call )               IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_TL_FIRST, NET_TL_LAST )
     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 */
     283#define IS_NET_UDP_MESSAGE( call )              IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_UDP_FIRST, NET_UDP_LAST )
     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 */
     288#define IS_NET_TCP_MESSAGE( call )              IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_TCP_FIRST, NET_TCP_LAST )
     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 */
     293#define IS_NET_SOCKET_MESSAGE( call )   IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_SOCKET_FIRST, NET_SOCKET_LAST )
     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 */
     298#define IS_NET_PACKET_MESSAGE( call )   IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_PACKET_FIRST, NET_PACKET_LAST )
     299
     300/*@}*/
     301
     302/** @name Networking specific message parameters definitions
    58303 */
    59304/*@{*/
    60305
    61 /** The number of ARP messages.
    62  */
    63 #define NET_ARP_COUNT           5
    64 
    65 /** The number of Ethernet messages.
    66  */
    67 #define NET_ETH_COUNT           0
    68 
    69 /** The number of ICMP messages.
    70  */
    71 #define NET_ICMP_COUNT          6
    72 
    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 
    81 /** The number of general networking messages.
    82  */
    83 #define NET_NET_COUNT           3
    84 
    85 /** The number of network interface driver messages.
    86  */
    87 #define NET_NETIF_COUNT         6
    88 
    89 /** The number of network interface layer messages.
    90  */
    91 #define NET_NIL_COUNT           7
    92 
    93 /** The number of packet management system messages.
    94  */
    95 #define NET_PACKET_COUNT        5
    96 
    97 /** The number of socket messages.
    98  */
    99 #define NET_SOCKET_COUNT        14
    100 
    101 /** The number of TCP messages.
    102  */
    103 #define NET_TCP_COUNT           0
    104 
    105 /** The number of transport layer messages.
    106  */
    107 #define NET_TL_COUNT            1
    108 
    109 /** The number of UDP messages.
    110  */
    111 #define NET_UDP_COUNT           0
    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  */
    129 #define NET_NETIF_LAST          (NET_NETIF_FIRST + NET_NETIF_COUNT)
    130 
    131 /** The first general networking message.
    132  */
    133 #define NET_NET_FIRST           (NET_NETIF_LAST + 0)
    134 
    135 /** The last general networking message.
    136  */
    137 #define NET_NET_LAST            (NET_NET_FIRST + NET_NET_COUNT)
    138 
    139 /** The first network interface layer message.
    140  */
    141 #define NET_NIL_FIRST           (NET_NET_LAST + 0)
    142 
    143 /** The last network interface layer message.
    144  */
    145 #define NET_NIL_LAST            (NET_NIL_FIRST + NET_NIL_COUNT)
    146 
    147 /** The first Ethernet message.
    148  */
    149 #define NET_ETH_FIRST           (NET_NIL_LAST + 0)
    150 
    151 /** The last Ethernet message.
    152  */
    153 #define NET_ETH_LAST            (NET_ETH_FIRST + NET_ETH_COUNT)
    154 
    155 /** The first inter-network message.
    156  */
    157 #define NET_IL_FIRST            (NET_ETH_LAST + 0)
    158 
    159 /** The last inter-network message.
    160  */
    161 #define NET_IL_LAST                     (NET_IL_FIRST + NET_IL_COUNT)
    162 
    163 /** The first IP message.
    164  */
    165 #define NET_IP_FIRST            (NET_IL_LAST + 0)
    166 
    167 /** The last IP message.
    168  */
    169 #define NET_IP_LAST                     (NET_IP_FIRST + NET_IP_COUNT)
    170 
    171 /** The first ARP message.
    172  */
    173 #define NET_ARP_FIRST           (NET_IP_LAST + 0)
    174 
    175 /** The last ARP message.
    176  */
    177 #define NET_ARP_LAST            (NET_ARP_FIRST + NET_ARP_COUNT)
    178 
    179 /** The first ICMP message.
    180  */
    181 #define NET_ICMP_FIRST          (NET_ARP_LAST + 0)
    182 
    183 /** The last ICMP message.
    184  */
    185 #define NET_ICMP_LAST           (NET_ICMP_FIRST + NET_ICMP_COUNT)
    186 
    187 /** The first ICMP message.
    188  */
    189 #define NET_TL_FIRST            (NET_ICMP_LAST + 0)
    190 
    191 /** The last ICMP message.
    192  */
    193 #define NET_TL_LAST                     (NET_TL_FIRST + NET_TL_COUNT)
    194 
    195 /** The first UDP message.
    196  */
    197 #define NET_UDP_FIRST           (NET_TL_LAST + 0)
    198 
    199 /** The last UDP message.
    200  */
    201 #define NET_UDP_LAST            (NET_UDP_FIRST + NET_UDP_COUNT)
    202 
    203 /** The first TCP message.
    204  */
    205 #define NET_TCP_FIRST           (NET_UDP_LAST + 0)
    206 
    207 /** The last TCP message.
    208  */
    209 #define NET_TCP_LAST            (NET_TCP_FIRST + NET_TCP_COUNT)
    210 
    211 /** The first socket message.
    212  */
    213 #define NET_SOCKET_FIRST        (NET_TCP_LAST + 0)
    214 
    215 /** The last socket message.
    216  */
    217 #define NET_SOCKET_LAST         (NET_SOCKET_FIRST + NET_SOCKET_COUNT)
    218 
    219 /** The first packet management system message.
    220  */
    221 #define NET_PACKET_FIRST        (NET_SOCKET_LAST + 0)
    222 
    223 /** The last packet management system message.
    224  */
    225 #define NET_PACKET_LAST         (NET_PACKET_FIRST + NET_PACKET_COUNT)
    226 
    227 /** The last networking message.
    228  */
    229 #define NET_LAST                        NET_PACKET_LAST
    230 
    231 /** The number of networking messages.
    232  */
    233 #define NET_COUNT                       (NET_LAST - NET_FIRST)
    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  */
    238 #define IS_NET_MESSAGE(call)                    IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_FIRST, NET_LAST)
    239 
    240 /** Returns a value indicating whether the IPC call is an ARP message.
    241  *  @param[in] call The IPC call to be checked.
    242  */
    243 #define IS_NET_ARP_MESSAGE(call)                IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_ARP_FIRST, NET_ARP_LAST)
    244 
    245 /** Returns a value indicating whether the IPC call is an Ethernet message.
    246  *  @param[in] call The IPC call to be checked.
    247  */
    248 #define IS_NET_ETH_MESSAGE(call)                IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_ETH_FIRST, NET_ETH_LAST)
    249 
    250 /** Returns a value indicating whether the IPC call is an ICMP message.
    251  *  @param[in] call The IPC call to be checked.
    252  */
    253 #define IS_NET_ICMP_MESSAGE(call)               IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_ICMP_FIRST, NET_ICMP_LAST)
    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  */
    258 #define IS_NET_IL_MESSAGE(call)         IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_IL_FIRST, NET_IL_LAST)
    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  */
    263 #define IS_NET_IP_MESSAGE(call)         IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_IP_FIRST, NET_IP_LAST)
    264 
    265 /** Returns a value indicating whether the IPC call is a generic networking message.
    266  *  @param[in] call The IPC call to be checked.
    267  */
    268 #define IS_NET_NET_MESSAGE(call)                IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_NET_FIRST, NET_NET_LAST)
    269 
    270 /** Returns a value indicating whether the IPC call is a network interface layer message.
    271  *  @param[in] call The IPC call to be checked.
    272  */
    273 #define IS_NET_NIL_MESSAGE(call)                IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_NIL_FIRST, NET_NIL_LAST)
    274 
    275 /** Returns a value indicating whether the IPC call is a packet manaagement system message.
    276  *  @param[in] call The IPC call to be checked.
    277  */
    278 #define IS_NET_PACKET_MESSAGE(call)     IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_PACKET_FIRST, NET_PACKET_LAST)
    279 
    280 /** Returns a value indicating whether the IPC call is a socket message.
    281  *  @param[in] call The IPC call to be checked.
    282  */
    283 #define IS_NET_SOCKET_MESSAGE(call)     IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_SOCKET_FIRST, NET_SOCKET_LAST)
    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  */
    288 #define IS_NET_TCP_MESSAGE(call)                IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_TCP_FIRST, NET_TCP_LAST)
    289 
    290 /** Returns a value indicating whether the IPC call is a transport layer message.
    291  *  @param[in] call The IPC call to be checked.
    292  */
    293 #define IS_NET_TL_MESSAGE(call)         IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_TL_FIRST, NET_TL_LAST)
    294 
    295 /** Returns a value indicating whether the IPC call is a UDP message.
    296  *  @param[in] call The IPC call to be checked.
    297  */
    298 #define IS_NET_UDP_MESSAGE(call)                IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_UDP_FIRST, NET_UDP_LAST)
    299 
    300 /*@}*/
    301 
    302 /** @name Networking specific message arguments definitions
    303  */
    304 /*@{*/
    305 
    306 /** @name First arguments
    307  */
    308 /*@{*/
    309 
    310 /** Returns the device identifier message argument.
    311  *  @param[in] call The message call structure.
    312  */
    313 #define IPC_GET_DEVICE(call)            (device_id_t) IPC_GET_ARG1(*call)
    314 
    315 /*@}*/
    316 
    317 /** @name Second arguments
    318  */
    319 /*@{*/
    320 
    321 /** Returns the packet identifier message argument.
    322  *  @param[in] call The message call structure.
    323  */
    324 #define IPC_GET_PACKET(call)            (packet_id_t) IPC_GET_ARG2(*call)
    325 
    326 /** Returns the count message argument.
    327  *  @param[in] call The message call structure.
    328  */
    329 #define IPC_GET_COUNT(call)             (size_t) IPC_GET_ARG2(*call)
    330 
    331 /** Returns the device state message argument.
    332  *  @param[in] call The message call structure.
    333  */
    334 #define IPC_GET_STATE(call)             (device_state_t) IPC_GET_ARG2(*call)
    335 
    336 /** Returns the maximum transmission unit message argument.
    337  *  @param[in] call The message call structure.
    338  */
    339 #define IPC_GET_MTU(call)                       (size_t) IPC_GET_ARG2(*call)
    340 
    341 /*@}*/
    342 
    343 /** @name Third arguments
    344  */
    345 /*@{*/
    346 
    347 /** Returns the device driver service message argument.
    348  *  @param[in] call The message call structure.
    349  */
    350 #define IPC_GET_SERVICE(call)           (services_t) IPC_GET_ARG3(*call)
    351 
    352 /** Returns the target service message argument.
    353  *  @param[in] call The message call structure.
    354  */
    355 #define IPC_GET_TARGET(call)            (services_t) IPC_GET_ARG3(*call)
    356 
    357 /** Returns the sender service message argument.
    358  *  @param[in] call The message call structure.
    359  */
    360 #define IPC_GET_SENDER(call)            (services_t) IPC_GET_ARG3(*call)
    361 
    362 /*@}*/
    363 
    364 /** @name Fourth arguments
    365  */
    366 /*@{*/
    367 
    368 /** Returns the error service message argument.
    369  *  @param[in] call The message call structure.
    370  */
    371 #define IPC_GET_ERROR(call)             (services_t) IPC_GET_ARG4(*call)
    372 
    373 /*@}*/
    374 
    375 /** @name Fifth arguments
    376  */
    377 /*@{*/
    378 
    379 /** Returns the phone message argument.
    380  *  @param[in] call The message call structure.
    381  */
    382 #define IPC_GET_PHONE(call)             (int) IPC_GET_ARG5(*call)
    383 
    384 /*@}*/
    385 
    386 /** @name First answers
    387  */
    388 /*@{*/
     306/** Returns the device identifier message parameter.
     307 *  @param[in] call The message call structure.
     308 */
     309#define IPC_GET_DEVICE( call )          ( device_id_t ) IPC_GET_ARG1( * call )
     310
     311/** Returns the packet identifier message parameter.
     312 *  @param[in] call The message call structure.
     313 */
     314#define IPC_GET_PACKET( call )          ( packet_id_t ) IPC_GET_ARG2( * call )
     315
     316/** Returns the count message parameter.
     317 *  @param[in] call The message call structure.
     318 */
     319#define IPC_GET_COUNT( call )           ( size_t ) IPC_GET_ARG2( * call )
     320
     321/** Returns the device state message parameter.
     322 *  @param[in] call The message call structure.
     323 */
     324#define IPC_GET_STATE( call )           ( device_state_t ) IPC_GET_ARG2( * call )
     325
     326/** Returns the maximum transmission unit message parameter.
     327 *  @param[in] call The message call structure.
     328 */
     329#define IPC_GET_MTU( call )                     ( size_t ) IPC_GET_ARG2( * call )
     330
     331/** Returns the device driver service message parameter.
     332 *  @param[in] call The message call structure.
     333 */
     334#define IPC_GET_SERVICE( call )         ( services_t ) IPC_GET_ARG3( * call )
     335
     336/** Returns the target service message parameter.
     337 *  @param[in] call The message call structure.
     338 */
     339#define IPC_GET_TARGET( call )          ( services_t ) IPC_GET_ARG3( * call )
     340
     341/** Returns the sender service message parameter.
     342 *  @param[in] call The message call structure.
     343 */
     344#define IPC_GET_SENDER( call )          ( services_t ) IPC_GET_ARG3( * call )
     345
     346/** Returns the error service message parameter.
     347 *  @param[in] call The message call structure.
     348 */
     349#define IPC_GET_ERROR( call )           ( services_t ) IPC_GET_ARG4( * call )
     350
     351/** Returns the phone message parameter.
     352 *  @param[in] call The message call structure.
     353 */
     354#define IPC_GET_PHONE( call )           ( int ) IPC_GET_ARG5( * call )
    389355
    390356/** Sets the device identifier in the message answer.
    391357 *  @param[out] answer The message answer structure.
    392358 */
    393 #define IPC_SET_DEVICE(answer)  ((device_id_t *) &IPC_GET_ARG1(*answer))
     359#define IPC_SET_DEVICE( answer )        (( device_id_t * ) & IPC_GET_ARG1( * answer ))
    394360
    395361/** Sets the minimum address length in the message answer.
    396362 *  @param[out] answer The message answer structure.
    397363 */
    398 #define IPC_SET_ADDR(answer)            ((size_t *) &IPC_GET_ARG1(*answer))
    399 
    400 /*@}*/
    401 
    402 /** @name Second answers
    403  */
    404 /*@{*/
     364#define IPC_SET_ADDR( answer )          (( size_t * ) & IPC_GET_ARG1( * answer ))
    405365
    406366/** Sets the minimum prefix size in the message answer.
    407367 *  @param[out] answer The message answer structure.
    408368 */
    409 #define IPC_SET_PREFIX(answer)  ((size_t *) &IPC_GET_ARG2(*answer))
    410 
    411 /*@}*/
    412 
    413 /** @name Third answers
    414  */
    415 /*@{*/
     369#define IPC_SET_PREFIX( answer )        (( size_t * ) & IPC_GET_ARG2( * answer ))
    416370
    417371/** Sets the maximum content size in the message answer.
    418372 *  @param[out] answer The message answer structure.
    419373 */
    420 #define IPC_SET_CONTENT(answer) ((size_t *) &IPC_GET_ARG3(*answer))
    421 
    422 /*@}*/
    423 
    424 /** @name Fourth answers
    425  */
    426 /*@{*/
     374#define IPC_SET_CONTENT( answer )       (( size_t * ) & IPC_GET_ARG3( * answer ))
    427375
    428376/** Sets the minimum suffix size in the message answer.
    429377 *  @param[out] answer The message answer structure.
    430378 */
    431 #define IPC_SET_SUFFIX(answer)  ((size_t *) &IPC_GET_ARG4(*answer))
     379#define IPC_SET_SUFFIX( answer )        (( size_t * ) & IPC_GET_ARG4( * answer ))
    432380
    433381/*@}*/
    434 
    435 /*@}*/
    436 
    437 /** Notifies the module about the device state change.
    438  *  @param[in] phone The service module phone.
    439  *  @param[in] message The service specific message.
    440  *  @param[in] device_id The device identifier.
    441  *  @param[in] state The new device state.
    442  *  @param[in] target The target module service.
    443  *  @returns EOK on success.
    444  */
    445 static inline int generic_device_state_msg(int phone, int message, device_id_t device_id, int state, services_t target){
    446         async_msg_3(phone, (ipcarg_t) message, (ipcarg_t) device_id, (ipcarg_t) state, target);
    447         return EOK;
    448 }
    449 
    450 /** Notifies a module about the device.
    451  *  @param[in] phone The service module phone.
    452  *  @param[in] message The service specific message.
    453  *  @param[in] device_id The device identifier.
    454  *  @param[in] arg2 The second argument of the message.
    455  *  @param[in] service The device module service.
    456  *  @returns EOK on success.
    457  *  @returns Other error codes as defined for the specific service message.
    458  */
    459 static inline int generic_device_req(int phone, int message, device_id_t device_id, int arg2, services_t service){
    460         return (int) async_req_3_0(phone, (ipcarg_t) message, (ipcarg_t) device_id, (ipcarg_t) arg2, (ipcarg_t) service);
    461 }
    462382
    463383/** Returns the address.
     
    471391 *  @returns Other error codes as defined for the specific service message.
    472392 */
    473 static inline int generic_get_addr_req(int phone, int message, device_id_t device_id, measured_string_ref * address, char ** data){
    474         aid_t message_id;
    475         ipcarg_t result;
    476         int string;
    477 
    478         if(!(address && data)){
    479                 return EBADMEM;
     393static inline int generic_get_addr_req( int phone, int message, device_id_t device_id, measured_string_ref * address, char ** data ){
     394        aid_t                   message_id;
     395        ipcarg_t                result;
     396        int                             string;
     397
     398        if( !( address && data )) return EBADMEM;
     399        message_id = async_send_1( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, NULL );
     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 );
    480405        }
    481 
    482         // request the address
    483         message_id = async_send_1(phone, (ipcarg_t) message, (ipcarg_t) device_id, NULL);
    484         string = measured_strings_return(phone, address, data, 1);
    485         async_wait_for(message_id, &result);
    486 
    487         // if not successful
    488         if((string == EOK) && (result != EOK)){
    489                 // clear the data
    490                 free(*address);
    491                 free(*data);
    492         }
    493         return (int) result;
    494 }
    495 
    496 /** Returns the device packet dimension for sending.
    497  *  @param[in] phone The service module phone.
    498  *  @param[in] message The service specific message.
    499  *  @param[in] device_id The device identifier.
    500  *  @param[out] packet_dimension The packet dimension.
    501  *  @returns EOK on success.
    502  *  @returns EBADMEM if the packet_dimension parameter is NULL.
    503  *  @returns Other error codes as defined for the specific service message.
    504  */
    505 static inline int generic_packet_size_req(int phone, int message, device_id_t device_id, packet_dimension_ref packet_dimension){
    506         ipcarg_t result;
    507         ipcarg_t prefix;
    508         ipcarg_t content;
    509         ipcarg_t suffix;
    510         ipcarg_t addr_len;
    511 
    512         if(! packet_dimension){
    513                 return EBADMEM;
    514         }
    515         result = async_req_1_4(phone, (ipcarg_t) message, (ipcarg_t) device_id, &addr_len, &prefix, &content, &suffix);
    516         packet_dimension->prefix = (size_t) prefix;
    517         packet_dimension->content = (size_t) content;
    518         packet_dimension->suffix = (size_t) suffix;
    519         packet_dimension->addr_len = (size_t) addr_len;
    520         return (int) result;
    521 }
    522 
    523 /** Passes the packet queue to the module.
    524  *  @param[in] phone The service module phone.
    525  *  @param[in] message The service specific message.
    526  *  @param[in] device_id The device identifier.
    527  *  @param[in] packet_id The received packet or the received packet queue identifier.
    528  *  @param[in] target The target module service.
    529  *  @param[in] error The error module service.
    530  *  @returns EOK on success.
    531  */
    532 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){
    533         if(error){
    534                 async_msg_4(phone, (ipcarg_t) message, (ipcarg_t) device_id, (ipcarg_t) packet_id, (ipcarg_t) target, (ipcarg_t) error);
    535         }else{
    536                 async_msg_3(phone, (ipcarg_t) message, (ipcarg_t) device_id, (ipcarg_t) packet_id, (ipcarg_t) target);
    537         }
    538         return EOK;
    539 }
    540 
    541 /** Sends the packet queue.
    542  *  @param[in] phone The service module phone.
    543  *  @param[in] message The service specific message.
    544  *  @param[in] device_id The device identifier.
    545  *  @param[in] packet_id The packet or the packet queue identifier.
    546  *  @param[in] sender The sending module service.
    547  *  @param[in] error The error module service.
    548  *  @returns EOK on success.
    549  */
    550 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){
    551         if(error){
    552                 async_msg_4(phone, (ipcarg_t) message, (ipcarg_t) device_id, (ipcarg_t) packet_id, (ipcarg_t) sender, (ipcarg_t) error);
    553         }else{
    554                 async_msg_3(phone, (ipcarg_t) message, (ipcarg_t) device_id, (ipcarg_t) packet_id, (ipcarg_t) sender);
    555         }
    556         return EOK;
     406        return ( int ) result;
    557407}
    558408
     
    573423 *  @returns Other error codes as defined for the specific service message.
    574424 */
    575 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){
    576         aid_t message_id;
    577         ipcarg_t result;
    578         int string;
    579 
    580         if(!(configuration && (count > 0))){
    581                 return EINVAL;
     425static 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 );
    582439        }
    583         if(!(translation && data)){
    584                 return EBADMEM;
     440        return ( int ) result;
     441}
     442
     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 */
     452static 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 );
    585457        }
    586 
    587         // request the translation
    588         message_id = async_send_3(phone, (ipcarg_t) message, (ipcarg_t) device_id, (ipcarg_t) count, (ipcarg_t) service, NULL);
    589         measured_strings_send(phone, configuration, count);
    590         string = measured_strings_return(phone, translation, data, count);
    591         async_wait_for(message_id, &result);
    592 
    593         // if not successful
    594         if((string == EOK) && (result != EOK)){
    595                 // clear the data
    596                 free(*translation);
    597                 free(*data);
     458        return EOK;
     459}
     460
     461/** Returns the device packet dimension 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] packet_dimension The packet dimension.
     466 *  @returns EOK on success.
     467 *  @returns EBADMEM if the packet_dimension parameter is NULL.
     468 *  @returns Other error codes as defined for the specific service message.
     469 */
     470static inline int       generic_packet_size_req( int phone, int message, device_id_t device_id, packet_dimension_ref packet_dimension ){
     471        ipcarg_t        result;
     472        ipcarg_t        prefix;
     473        ipcarg_t        content;
     474        ipcarg_t        suffix;
     475        ipcarg_t        addr_len;
     476
     477        if( ! packet_dimension ) return EBADMEM;
     478        result = async_req_1_4( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, & addr_len, & prefix, & content, & suffix );
     479        packet_dimension->prefix = ( size_t ) prefix;
     480        packet_dimension->content = ( size_t ) content;
     481        packet_dimension->suffix = ( size_t ) suffix;
     482        packet_dimension->addr_len = ( size_t ) addr_len;
     483        return ( int ) result;
     484}
     485
     486/** Notifies the module about the device state change.
     487 *  @param[in] phone The service module phone.
     488 *  @param[in] message The service specific message.
     489 *  @param[in] device_id The device identifier.
     490 *  @param[in] state The new device state.
     491 *  @param[in] target The target module service.
     492 *  @returns EOK on success.
     493 */
     494static inline int       generic_device_state_msg( int phone, int message, device_id_t device_id, int state, services_t target ){
     495        async_msg_3( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, ( ipcarg_t ) state, target );
     496        return EOK;
     497}
     498
     499/** Passes the packet queue to the module.
     500 *  @param[in] phone The service module phone.
     501 *  @param[in] message The service specific message.
     502 *  @param[in] device_id The device identifier.
     503 *  @param[in] packet_id The received packet or the received packet queue identifier.
     504 *  @param[in] target The target module service.
     505 *  @param[in] error The error module service.
     506 *  @returns EOK on success.
     507 */
     508static 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 ){
     509        if( error ){
     510                async_msg_4( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, ( ipcarg_t ) packet_id, ( ipcarg_t ) target, ( ipcarg_t ) error );
     511        }else{
     512                async_msg_3( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, ( ipcarg_t ) packet_id, ( ipcarg_t ) target );
    598513        }
    599 
    600         return (int) result;
     514        return EOK;
     515}
     516
     517/** Notifies a module about the device.
     518 *  @param[in] phone The service module phone.
     519 *  @param[in] message The service specific message.
     520 *  @param[in] device_id The device identifier.
     521 *  @param[in] arg2 The second argument of the message.
     522 *  @param[in] service The device module service.
     523 *  @returns EOK on success.
     524 *  @returns Other error codes as defined for the specific service message.
     525 */
     526static inline int       generic_device_req( int phone, int message, device_id_t device_id, int arg2, services_t service ){
     527        return ( int ) async_req_3_0( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, ( ipcarg_t ) arg2, ( ipcarg_t ) service );
    601528}
    602529
Note: See TracChangeset for help on using the changeset viewer.