Changeset a46e56b in mainline for uspace/srv/net/inetsrv/inetsrv.c


Ignore:
Timestamp:
2018-03-22T06:49:35Z (7 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
77f0a1d
Parents:
3e242d2
git-author:
Jakub Jermar <jakub@…> (2018-03-21 23:29:06)
git-committer:
Jakub Jermar <jakub@…> (2018-03-22 06:49:35)
Message:

Prefer handle over ID in naming handle variables

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/inetsrv/inetsrv.c

    r3e242d2 ra46e56b  
    120120}
    121121
    122 static void inet_callback_create_srv(inet_client_t *client, cap_call_handle_t callid,
     122static void inet_callback_create_srv(inet_client_t *client, cap_call_handle_t chandle,
    123123    ipc_call_t *call)
    124124{
     
    127127        async_sess_t *sess = async_callback_receive(EXCHANGE_SERIALIZE);
    128128        if (sess == NULL) {
    129                 async_answer_0(callid, ENOMEM);
     129                async_answer_0(chandle, ENOMEM);
    130130                return;
    131131        }
    132132
    133133        client->sess = sess;
    134         async_answer_0(callid, EOK);
     134        async_answer_0(chandle, EOK);
    135135}
    136136
     
    230230}
    231231
    232 static void inet_get_srcaddr_srv(inet_client_t *client, cap_call_handle_t iid,
     232static void inet_get_srcaddr_srv(inet_client_t *client, cap_call_handle_t icall_handle,
    233233    ipc_call_t *icall)
    234234{
     
    237237        uint8_t tos = IPC_GET_ARG1(*icall);
    238238
    239         cap_call_handle_t callid;
     239        cap_call_handle_t chandle;
    240240        size_t size;
    241         if (!async_data_write_receive(&callid, &size)) {
    242                 async_answer_0(callid, EREFUSED);
    243                 async_answer_0(iid, EREFUSED);
     241        if (!async_data_write_receive(&chandle, &size)) {
     242                async_answer_0(chandle, EREFUSED);
     243                async_answer_0(icall_handle, EREFUSED);
    244244                return;
    245245        }
    246246
    247247        if (size != sizeof(inet_addr_t)) {
    248                 async_answer_0(callid, EINVAL);
    249                 async_answer_0(iid, EINVAL);
     248                async_answer_0(chandle, EINVAL);
     249                async_answer_0(icall_handle, EINVAL);
    250250                return;
    251251        }
    252252
    253253        inet_addr_t remote;
    254         errno_t rc = async_data_write_finalize(callid, &remote, size);
    255         if (rc != EOK) {
    256                 async_answer_0(callid, rc);
    257                 async_answer_0(iid, rc);
     254        errno_t rc = async_data_write_finalize(chandle, &remote, size);
     255        if (rc != EOK) {
     256                async_answer_0(chandle, rc);
     257                async_answer_0(icall_handle, rc);
    258258        }
    259259
     
    261261        rc = inet_get_srcaddr(&remote, tos, &local);
    262262        if (rc != EOK) {
    263                 async_answer_0(iid, rc);
    264                 return;
    265         }
    266 
    267         if (!async_data_read_receive(&callid, &size)) {
    268                 async_answer_0(callid, EREFUSED);
    269                 async_answer_0(iid, EREFUSED);
     263                async_answer_0(icall_handle, rc);
     264                return;
     265        }
     266
     267        if (!async_data_read_receive(&chandle, &size)) {
     268                async_answer_0(chandle, EREFUSED);
     269                async_answer_0(icall_handle, EREFUSED);
    270270                return;
    271271        }
    272272
    273273        if (size != sizeof(inet_addr_t)) {
    274                 async_answer_0(callid, EINVAL);
    275                 async_answer_0(iid, EINVAL);
    276                 return;
    277         }
    278 
    279         rc = async_data_read_finalize(callid, &local, size);
    280         if (rc != EOK) {
    281                 async_answer_0(callid, rc);
    282                 async_answer_0(iid, rc);
    283                 return;
    284         }
    285 
    286         async_answer_0(iid, rc);
    287 }
    288 
    289 static void inet_send_srv(inet_client_t *client, cap_call_handle_t iid,
     274                async_answer_0(chandle, EINVAL);
     275                async_answer_0(icall_handle, EINVAL);
     276                return;
     277        }
     278
     279        rc = async_data_read_finalize(chandle, &local, size);
     280        if (rc != EOK) {
     281                async_answer_0(chandle, rc);
     282                async_answer_0(icall_handle, rc);
     283                return;
     284        }
     285
     286        async_answer_0(icall_handle, rc);
     287}
     288
     289static void inet_send_srv(inet_client_t *client, cap_call_handle_t icall_handle,
    290290    ipc_call_t *icall)
    291291{
     
    300300        int df = IPC_GET_ARG4(*icall);
    301301
    302         cap_call_handle_t callid;
     302        cap_call_handle_t chandle;
    303303        size_t size;
    304         if (!async_data_write_receive(&callid, &size)) {
    305                 async_answer_0(callid, EREFUSED);
    306                 async_answer_0(iid, EREFUSED);
     304        if (!async_data_write_receive(&chandle, &size)) {
     305                async_answer_0(chandle, EREFUSED);
     306                async_answer_0(icall_handle, EREFUSED);
    307307                return;
    308308        }
    309309
    310310        if (size != sizeof(inet_addr_t)) {
    311                 async_answer_0(callid, EINVAL);
    312                 async_answer_0(iid, EINVAL);
    313                 return;
    314         }
    315 
    316         errno_t rc = async_data_write_finalize(callid, &dgram.src, size);
    317         if (rc != EOK) {
    318                 async_answer_0(callid, rc);
    319                 async_answer_0(iid, rc);
    320         }
    321 
    322         if (!async_data_write_receive(&callid, &size)) {
    323                 async_answer_0(callid, EREFUSED);
    324                 async_answer_0(iid, EREFUSED);
     311                async_answer_0(chandle, EINVAL);
     312                async_answer_0(icall_handle, EINVAL);
     313                return;
     314        }
     315
     316        errno_t rc = async_data_write_finalize(chandle, &dgram.src, size);
     317        if (rc != EOK) {
     318                async_answer_0(chandle, rc);
     319                async_answer_0(icall_handle, rc);
     320        }
     321
     322        if (!async_data_write_receive(&chandle, &size)) {
     323                async_answer_0(chandle, EREFUSED);
     324                async_answer_0(icall_handle, EREFUSED);
    325325                return;
    326326        }
    327327
    328328        if (size != sizeof(inet_addr_t)) {
    329                 async_answer_0(callid, EINVAL);
    330                 async_answer_0(iid, EINVAL);
    331                 return;
    332         }
    333 
    334         rc = async_data_write_finalize(callid, &dgram.dest, size);
    335         if (rc != EOK) {
    336                 async_answer_0(callid, rc);
    337                 async_answer_0(iid, rc);
     329                async_answer_0(chandle, EINVAL);
     330                async_answer_0(icall_handle, EINVAL);
     331                return;
     332        }
     333
     334        rc = async_data_write_finalize(chandle, &dgram.dest, size);
     335        if (rc != EOK) {
     336                async_answer_0(chandle, rc);
     337                async_answer_0(icall_handle, rc);
    338338        }
    339339
     
    341341            &dgram.size);
    342342        if (rc != EOK) {
    343                 async_answer_0(iid, rc);
     343                async_answer_0(icall_handle, rc);
    344344                return;
    345345        }
     
    348348
    349349        free(dgram.data);
    350         async_answer_0(iid, rc);
    351 }
    352 
    353 static void inet_set_proto_srv(inet_client_t *client, cap_call_handle_t callid,
     350        async_answer_0(icall_handle, rc);
     351}
     352
     353static void inet_set_proto_srv(inet_client_t *client, cap_call_handle_t chandle,
    354354    ipc_call_t *call)
    355355{
     
    360360
    361361        if (proto > UINT8_MAX) {
    362                 async_answer_0(callid, EINVAL);
     362                async_answer_0(chandle, EINVAL);
    363363                return;
    364364        }
    365365
    366366        client->protocol = proto;
    367         async_answer_0(callid, EOK);
     367        async_answer_0(chandle, EOK);
    368368}
    369369
     
    387387}
    388388
    389 static void inet_default_conn(cap_call_handle_t iid, ipc_call_t *icall, void *arg)
     389static void inet_default_conn(cap_call_handle_t icall_handle, ipc_call_t *icall, void *arg)
    390390{
    391391        inet_client_t client;
     
    394394
    395395        /* Accept the connection */
    396         async_answer_0(iid, EOK);
     396        async_answer_0(icall_handle, EOK);
    397397
    398398        inet_client_init(&client);
     
    400400        while (true) {
    401401                ipc_call_t call;
    402                 cap_call_handle_t callid = async_get_call(&call);
     402                cap_call_handle_t chandle = async_get_call(&call);
    403403                sysarg_t method = IPC_GET_IMETHOD(call);
    404404
    405405                if (!method) {
    406406                        /* The other side has hung up */
    407                         async_answer_0(callid, EOK);
     407                        async_answer_0(chandle, EOK);
    408408                        return;
    409409                }
     
    411411                switch (method) {
    412412                case INET_CALLBACK_CREATE:
    413                         inet_callback_create_srv(&client, callid, &call);
     413                        inet_callback_create_srv(&client, chandle, &call);
    414414                        break;
    415415                case INET_GET_SRCADDR:
    416                         inet_get_srcaddr_srv(&client, callid, &call);
     416                        inet_get_srcaddr_srv(&client, chandle, &call);
    417417                        break;
    418418                case INET_SEND:
    419                         inet_send_srv(&client, callid, &call);
     419                        inet_send_srv(&client, chandle, &call);
    420420                        break;
    421421                case INET_SET_PROTO:
    422                         inet_set_proto_srv(&client, callid, &call);
     422                        inet_set_proto_srv(&client, chandle, &call);
    423423                        break;
    424424                default:
    425                         async_answer_0(callid, EINVAL);
     425                        async_answer_0(chandle, EINVAL);
    426426                }
    427427        }
Note: See TracChangeset for help on using the changeset viewer.