Changeset a46e56b in mainline for uspace/lib/c/generic/iplink_srv.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/lib/c/generic/iplink_srv.c

    r3e242d2 ra46e56b  
    4242#include <inet/iplink_srv.h>
    4343
    44 static void iplink_get_mtu_srv(iplink_srv_t *srv, cap_call_handle_t callid,
     44static void iplink_get_mtu_srv(iplink_srv_t *srv, cap_call_handle_t chandle,
    4545    ipc_call_t *call)
    4646{
    4747        size_t mtu;
    4848        errno_t rc = srv->ops->get_mtu(srv, &mtu);
    49         async_answer_1(callid, rc, mtu);
    50 }
    51 
    52 static void iplink_get_mac48_srv(iplink_srv_t *srv, cap_call_handle_t iid,
     49        async_answer_1(chandle, rc, mtu);
     50}
     51
     52static void iplink_get_mac48_srv(iplink_srv_t *srv, cap_call_handle_t icall_handle,
    5353    ipc_call_t *icall)
    5454{
     
    5656        errno_t rc = srv->ops->get_mac48(srv, &mac);
    5757        if (rc != EOK) {
    58                 async_answer_0(iid, rc);
    59                 return;
    60         }
    61 
    62         cap_call_handle_t callid;
    63         size_t size;
    64         if (!async_data_read_receive(&callid, &size)) {
    65                 async_answer_0(callid, EREFUSED);
    66                 async_answer_0(iid, EREFUSED);
     58                async_answer_0(icall_handle, rc);
     59                return;
     60        }
     61
     62        cap_call_handle_t chandle;
     63        size_t size;
     64        if (!async_data_read_receive(&chandle, &size)) {
     65                async_answer_0(chandle, EREFUSED);
     66                async_answer_0(icall_handle, EREFUSED);
    6767                return;
    6868        }
    6969
    7070        if (size != sizeof(addr48_t)) {
    71                 async_answer_0(callid, EINVAL);
    72                 async_answer_0(iid, EINVAL);
    73                 return;
    74         }
    75 
    76         rc = async_data_read_finalize(callid, &mac, size);
     71                async_answer_0(chandle, EINVAL);
     72                async_answer_0(icall_handle, EINVAL);
     73                return;
     74        }
     75
     76        rc = async_data_read_finalize(chandle, &mac, size);
    7777        if (rc != EOK)
    78                 async_answer_0(callid, rc);
    79 
    80         async_answer_0(iid, rc);
    81 }
    82 
    83 static void iplink_set_mac48_srv(iplink_srv_t *srv, cap_call_handle_t iid,
     78                async_answer_0(chandle, rc);
     79
     80        async_answer_0(icall_handle, rc);
     81}
     82
     83static void iplink_set_mac48_srv(iplink_srv_t *srv, cap_call_handle_t icall_handle,
    8484    ipc_call_t *icall)
    8585{
     
    8787        size_t size;
    8888        addr48_t mac;
    89         cap_call_handle_t callid;
    90 
    91         if (!async_data_write_receive(&callid, &size)) {
    92                 async_answer_0(callid, EREFUSED);
    93                 async_answer_0(iid, EREFUSED);
     89        cap_call_handle_t chandle;
     90
     91        if (!async_data_write_receive(&chandle, &size)) {
     92                async_answer_0(chandle, EREFUSED);
     93                async_answer_0(icall_handle, EREFUSED);
    9494        }
    9595
    9696        rc = srv->ops->set_mac48(srv, &mac);
    9797        if (rc != EOK) {
    98                 async_answer_0(iid, rc);
    99                 return;
    100         }
    101 
    102         rc = async_data_read_finalize(callid, &mac, sizeof(addr48_t));
     98                async_answer_0(icall_handle, rc);
     99                return;
     100        }
     101
     102        rc = async_data_read_finalize(chandle, &mac, sizeof(addr48_t));
    103103        if (rc != EOK)
    104                 async_answer_0(callid, rc);
    105 
    106         async_answer_0(iid, rc);
    107 }
    108 
    109 static void iplink_addr_add_srv(iplink_srv_t *srv, cap_call_handle_t iid,
    110     ipc_call_t *icall)
    111 {
    112         cap_call_handle_t callid;
    113         size_t size;
    114         if (!async_data_write_receive(&callid, &size)) {
    115                 async_answer_0(callid, EREFUSED);
    116                 async_answer_0(iid, EREFUSED);
     104                async_answer_0(chandle, rc);
     105
     106        async_answer_0(icall_handle, rc);
     107}
     108
     109static void iplink_addr_add_srv(iplink_srv_t *srv, cap_call_handle_t icall_handle,
     110    ipc_call_t *icall)
     111{
     112        cap_call_handle_t chandle;
     113        size_t size;
     114        if (!async_data_write_receive(&chandle, &size)) {
     115                async_answer_0(chandle, EREFUSED);
     116                async_answer_0(icall_handle, EREFUSED);
    117117                return;
    118118        }
    119119
    120120        if (size != sizeof(inet_addr_t)) {
    121                 async_answer_0(callid, EINVAL);
    122                 async_answer_0(iid, EINVAL);
     121                async_answer_0(chandle, EINVAL);
     122                async_answer_0(icall_handle, EINVAL);
    123123                return;
    124124        }
    125125
    126126        inet_addr_t addr;
    127         errno_t rc = async_data_write_finalize(callid, &addr, size);
    128         if (rc != EOK) {
    129                 async_answer_0(callid, rc);
    130                 async_answer_0(iid, rc);
     127        errno_t rc = async_data_write_finalize(chandle, &addr, size);
     128        if (rc != EOK) {
     129                async_answer_0(chandle, rc);
     130                async_answer_0(icall_handle, rc);
    131131        }
    132132
    133133        rc = srv->ops->addr_add(srv, &addr);
    134         async_answer_0(iid, rc);
    135 }
    136 
    137 static void iplink_addr_remove_srv(iplink_srv_t *srv, cap_call_handle_t iid,
    138     ipc_call_t *icall)
    139 {
    140         cap_call_handle_t callid;
    141         size_t size;
    142         if (!async_data_write_receive(&callid, &size)) {
    143                 async_answer_0(callid, EREFUSED);
    144                 async_answer_0(iid, EREFUSED);
     134        async_answer_0(icall_handle, rc);
     135}
     136
     137static void iplink_addr_remove_srv(iplink_srv_t *srv, cap_call_handle_t icall_handle,
     138    ipc_call_t *icall)
     139{
     140        cap_call_handle_t chandle;
     141        size_t size;
     142        if (!async_data_write_receive(&chandle, &size)) {
     143                async_answer_0(chandle, EREFUSED);
     144                async_answer_0(icall_handle, EREFUSED);
    145145                return;
    146146        }
    147147
    148148        if (size != sizeof(inet_addr_t)) {
    149                 async_answer_0(callid, EINVAL);
    150                 async_answer_0(iid, EINVAL);
     149                async_answer_0(chandle, EINVAL);
     150                async_answer_0(icall_handle, EINVAL);
    151151                return;
    152152        }
    153153
    154154        inet_addr_t addr;
    155         errno_t rc = async_data_write_finalize(callid, &addr, size);
    156         if (rc != EOK) {
    157                 async_answer_0(callid, rc);
    158                 async_answer_0(iid, rc);
     155        errno_t rc = async_data_write_finalize(chandle, &addr, size);
     156        if (rc != EOK) {
     157                async_answer_0(chandle, rc);
     158                async_answer_0(icall_handle, rc);
    159159        }
    160160
    161161        rc = srv->ops->addr_remove(srv, &addr);
    162         async_answer_0(iid, rc);
    163 }
    164 
    165 static void iplink_send_srv(iplink_srv_t *srv, cap_call_handle_t iid,
     162        async_answer_0(icall_handle, rc);
     163}
     164
     165static void iplink_send_srv(iplink_srv_t *srv, cap_call_handle_t icall_handle,
    166166    ipc_call_t *icall)
    167167{
     
    174174            &sdu.size);
    175175        if (rc != EOK) {
    176                 async_answer_0(iid, rc);
     176                async_answer_0(icall_handle, rc);
    177177                return;
    178178        }
     
    180180        rc = srv->ops->send(srv, &sdu);
    181181        free(sdu.data);
    182         async_answer_0(iid, rc);
    183 }
    184 
    185 static void iplink_send6_srv(iplink_srv_t *srv, cap_call_handle_t iid,
     182        async_answer_0(icall_handle, rc);
     183}
     184
     185static void iplink_send6_srv(iplink_srv_t *srv, cap_call_handle_t icall_handle,
    186186    ipc_call_t *icall)
    187187{
    188188        iplink_sdu6_t sdu;
    189189
    190         cap_call_handle_t callid;
    191         size_t size;
    192         if (!async_data_write_receive(&callid, &size)) {
    193                 async_answer_0(callid, EREFUSED);
    194                 async_answer_0(iid, EREFUSED);
     190        cap_call_handle_t chandle;
     191        size_t size;
     192        if (!async_data_write_receive(&chandle, &size)) {
     193                async_answer_0(chandle, EREFUSED);
     194                async_answer_0(icall_handle, EREFUSED);
    195195                return;
    196196        }
    197197
    198198        if (size != sizeof(addr48_t)) {
    199                 async_answer_0(callid, EINVAL);
    200                 async_answer_0(iid, EINVAL);
    201                 return;
    202         }
    203 
    204         errno_t rc = async_data_write_finalize(callid, &sdu.dest, size);
    205         if (rc != EOK) {
    206                 async_answer_0(callid, rc);
    207                 async_answer_0(iid, rc);
     199                async_answer_0(chandle, EINVAL);
     200                async_answer_0(icall_handle, EINVAL);
     201                return;
     202        }
     203
     204        errno_t rc = async_data_write_finalize(chandle, &sdu.dest, size);
     205        if (rc != EOK) {
     206                async_answer_0(chandle, rc);
     207                async_answer_0(icall_handle, rc);
    208208        }
    209209
     
    211211            &sdu.size);
    212212        if (rc != EOK) {
    213                 async_answer_0(iid, rc);
     213                async_answer_0(icall_handle, rc);
    214214                return;
    215215        }
     
    217217        rc = srv->ops->send6(srv, &sdu);
    218218        free(sdu.data);
    219         async_answer_0(iid, rc);
     219        async_answer_0(icall_handle, rc);
    220220}
    221221
     
    229229}
    230230
    231 errno_t iplink_conn(cap_call_handle_t iid, ipc_call_t *icall, void *arg)
     231errno_t iplink_conn(cap_call_handle_t icall_handle, ipc_call_t *icall, void *arg)
    232232{
    233233        iplink_srv_t *srv = (iplink_srv_t *) arg;
     
    237237        if (srv->connected) {
    238238                fibril_mutex_unlock(&srv->lock);
    239                 async_answer_0(iid, EBUSY);
     239                async_answer_0(icall_handle, EBUSY);
    240240                return EBUSY;
    241241        }
     
    245245
    246246        /* Accept the connection */
    247         async_answer_0(iid, EOK);
     247        async_answer_0(icall_handle, EOK);
    248248
    249249        async_sess_t *sess = async_callback_receive(EXCHANGE_SERIALIZE);
     
    259259        while (true) {
    260260                ipc_call_t call;
    261                 cap_call_handle_t callid = async_get_call(&call);
     261                cap_call_handle_t chandle = async_get_call(&call);
    262262                sysarg_t method = IPC_GET_IMETHOD(call);
    263263
     
    267267                        srv->connected = false;
    268268                        fibril_mutex_unlock(&srv->lock);
    269                         async_answer_0(callid, EOK);
     269                        async_answer_0(chandle, EOK);
    270270                        break;
    271271                }
     
    273273                switch (method) {
    274274                case IPLINK_GET_MTU:
    275                         iplink_get_mtu_srv(srv, callid, &call);
     275                        iplink_get_mtu_srv(srv, chandle, &call);
    276276                        break;
    277277                case IPLINK_GET_MAC48:
    278                         iplink_get_mac48_srv(srv, callid, &call);
     278                        iplink_get_mac48_srv(srv, chandle, &call);
    279279                        break;
    280280                case IPLINK_SET_MAC48:
    281                         iplink_set_mac48_srv(srv, callid, &call);
     281                        iplink_set_mac48_srv(srv, chandle, &call);
    282282                        break;
    283283                case IPLINK_SEND:
    284                         iplink_send_srv(srv, callid, &call);
     284                        iplink_send_srv(srv, chandle, &call);
    285285                        break;
    286286                case IPLINK_SEND6:
    287                         iplink_send6_srv(srv, callid, &call);
     287                        iplink_send6_srv(srv, chandle, &call);
    288288                        break;
    289289                case IPLINK_ADDR_ADD:
    290                         iplink_addr_add_srv(srv, callid, &call);
     290                        iplink_addr_add_srv(srv, chandle, &call);
    291291                        break;
    292292                case IPLINK_ADDR_REMOVE:
    293                         iplink_addr_remove_srv(srv, callid, &call);
     293                        iplink_addr_remove_srv(srv, chandle, &call);
    294294                        break;
    295295                default:
    296                         async_answer_0(callid, EINVAL);
     296                        async_answer_0(chandle, EINVAL);
    297297                }
    298298        }
Note: See TracChangeset for help on using the changeset viewer.