Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/net/modules.c

    r64d2b10 r7880d58  
    3232
    3333/** @file
    34  * Generic module functions implementation.
     34 * Generic module functions implementation. 
    3535 *
    3636 * @todo MAKE IT POSSIBLE TO REMOVE THIS FILE VIA EITHER REPLACING PART OF ITS
     
    4343#include <errno.h>
    4444#include <sys/time.h>
     45
     46#include <ipc/ipc.h>
    4547#include <ipc/services.h>
     48
    4649#include <net/modules.h>
    4750
     
    4952#define MODULE_WAIT_TIME        (10 * 1000)
    5053
    51 /** Answer a call.
    52  *
    53  * @param[in] callid Call identifier.
    54  * @param[in] result Message processing result.
    55  * @param[in] answer Message processing answer.
    56  * @param[in] count  Number of answer parameters.
    57  *
    58  */
    59 void answer_call(ipc_callid_t callid, int result, ipc_call_t *answer,
    60     size_t count)
    61 {
    62         /* Choose the most efficient function */
    63         if ((answer != NULL) || (count == 0)) {
    64                 switch (count) {
     54/** Answers the call.
     55 *
     56 * @param[in] callid    The call identifier.
     57 * @param[in] result    The message processing result.
     58 * @param[in] answer    The message processing answer.
     59 * @param[in] answer_count The number of answer parameters.
     60 */
     61void
     62answer_call(ipc_callid_t callid, int result, ipc_call_t *answer,
     63    int answer_count)
     64{
     65        // choose the most efficient answer function
     66        if (answer || (!answer_count)) {
     67                switch (answer_count) {
    6568                case 0:
    66                         async_answer_0(callid, (sysarg_t) result);
     69                        ipc_answer_0(callid, (sysarg_t) result);
    6770                        break;
    6871                case 1:
    69                         async_answer_1(callid, (sysarg_t) result,
     72                        ipc_answer_1(callid, (sysarg_t) result,
    7073                            IPC_GET_ARG1(*answer));
    7174                        break;
    7275                case 2:
    73                         async_answer_2(callid, (sysarg_t) result,
     76                        ipc_answer_2(callid, (sysarg_t) result,
    7477                            IPC_GET_ARG1(*answer), IPC_GET_ARG2(*answer));
    7578                        break;
    7679                case 3:
    77                         async_answer_3(callid, (sysarg_t) result,
     80                        ipc_answer_3(callid, (sysarg_t) result,
    7881                            IPC_GET_ARG1(*answer), IPC_GET_ARG2(*answer),
    7982                            IPC_GET_ARG3(*answer));
    8083                        break;
    8184                case 4:
    82                         async_answer_4(callid, (sysarg_t) result,
     85                        ipc_answer_4(callid, (sysarg_t) result,
    8386                            IPC_GET_ARG1(*answer), IPC_GET_ARG2(*answer),
    8487                            IPC_GET_ARG3(*answer), IPC_GET_ARG4(*answer));
     
    8689                case 5:
    8790                default:
    88                         async_answer_5(callid, (sysarg_t) result,
     91                        ipc_answer_5(callid, (sysarg_t) result,
    8992                            IPC_GET_ARG1(*answer), IPC_GET_ARG2(*answer),
    9093                            IPC_GET_ARG3(*answer), IPC_GET_ARG4(*answer),
     
    134137    sysarg_t arg3, async_client_conn_t client_receiver, suseconds_t timeout)
    135138{
     139        int rc;
     140       
    136141        /* Connect to the needed service */
    137142        int phone = connect_to_service_timeout(need, timeout);
    138143        if (phone >= 0) {
    139144                /* Request the bidirectional connection */
    140                 int rc = async_connect_to_me(phone, arg1, arg2, arg3, client_receiver);
     145                sysarg_t phonehash;
     146               
     147                rc = ipc_connect_to_me(phone, arg1, arg2, arg3, &phonehash);
    141148                if (rc != EOK) {
    142                         async_hangup(phone);
     149                        ipc_hangup(phone);
    143150                        return rc;
    144151                }
     152                async_new_connection(phonehash, 0, NULL, client_receiver);
    145153        }
    146154       
     
    170178        int phone;
    171179
    172         /* If no timeout is set */
     180        // if no timeout is set
    173181        if (timeout <= 0)
    174182                return async_connect_me_to_blocking(PHONE_NS, need, 0, 0);
     
    179187                        return phone;
    180188
    181                 /* Abort if no time is left */
     189                // end if no time is left
    182190                if (timeout <= 0)
    183191                        return ETIMEOUT;
    184192
    185                 /* Wait the minimum of the module wait time and the timeout */
     193                // wait the minimum of the module wait time and the timeout
    186194                usleep((timeout <= MODULE_WAIT_TIME) ?
    187195                    timeout : MODULE_WAIT_TIME);
     
    206214        ipc_callid_t callid;
    207215
    208         /* Fetch the request */
     216        // fetch the request
    209217        if (!async_data_read_receive(&callid, &length))
    210218                return EINVAL;
    211219
    212         /* Check the requested data size */
     220        // check the requested data size
    213221        if (length < data_length) {
    214222                async_data_read_finalize(callid, data, length);
     
    216224        }
    217225
    218         /* Send the data */
     226        // send the data
    219227        return async_data_read_finalize(callid, data, data_length);
    220228}
    221229
    222 /** Refresh answer structure and argument count.
    223  *
    224  * Erase all arguments.
    225  *
    226  * @param[in,out] answer Message processing answer structure.
    227  * @param[in,out] count  Number of answer arguments.
    228  *
    229  */
    230 void refresh_answer(ipc_call_t *answer, size_t *count)
    231 {
    232         if (count != NULL)
    233                 *count = 0;
    234        
    235         if (answer != NULL) {
     230/** Refreshes answer structure and parameters count.
     231 *
     232 * Erases all attributes.
     233 *
     234 * @param[in,out] answer The message processing answer structure.
     235 * @param[in,out] answer_count The number of answer parameters.
     236 */
     237void refresh_answer(ipc_call_t *answer, int *answer_count)
     238{
     239        if (answer_count)
     240                *answer_count = 0;
     241
     242        if (answer) {
    236243                IPC_SET_RETVAL(*answer, 0);
     244                // just to be precize
    237245                IPC_SET_IMETHOD(*answer, 0);
    238246                IPC_SET_ARG1(*answer, 0);
Note: See TracChangeset for help on using the changeset viewer.