Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/iplink.c

    r02a09ed r77ad86c  
    3939#include <errno.h>
    4040#include <inet/iplink.h>
    41 #include <inet/addr.h>
    4241#include <ipc/iplink.h>
    4342#include <ipc/services.h>
     
    8483{
    8584        async_exch_t *exch = async_exchange_begin(iplink->sess);
    86        
     85
    8786        ipc_call_t answer;
    88         aid_t req = async_send_0(exch, IPLINK_SEND, &answer);
    89        
    90         int rc = async_data_write_start(exch, &sdu->src, sizeof(inet_addr_t));
    91         if (rc != EOK) {
    92                 async_exchange_end(exch);
    93                 async_forget(req);
    94                 return rc;
    95         }
    96        
    97         rc = async_data_write_start(exch, &sdu->dest, sizeof(inet_addr_t));
    98         if (rc != EOK) {
    99                 async_exchange_end(exch);
    100                 async_forget(req);
    101                 return rc;
    102         }
    103        
    104         rc = async_data_write_start(exch, sdu->data, sdu->size);
    105        
     87        aid_t req = async_send_2(exch, IPLINK_SEND, sdu->lsrc.ipv4,
     88            sdu->ldest.ipv4, &answer);
     89        int rc = async_data_write_start(exch, sdu->data, sdu->size);
    10690        async_exchange_end(exch);
    107        
     91
    10892        if (rc != EOK) {
    10993                async_forget(req);
    11094                return rc;
    11195        }
    112        
     96
    11397        sysarg_t retval;
    11498        async_wait_for(req, &retval);
    115        
    116         return (int) retval;
     99        if (retval != EOK)
     100                return retval;
     101
     102        return EOK;
    117103}
    118104
     
    132118}
    133119
    134 int iplink_addr_add(iplink_t *iplink, inet_addr_t *addr)
     120int iplink_addr_add(iplink_t *iplink, iplink_addr_t *addr)
    135121{
    136122        async_exch_t *exch = async_exchange_begin(iplink->sess);
    137        
    138         ipc_call_t answer;
    139         aid_t req = async_send_0(exch, IPLINK_ADDR_ADD, &answer);
    140        
    141         int rc = async_data_write_start(exch, addr, sizeof(inet_addr_t));
     123
     124        int rc = async_req_1_0(exch, IPLINK_ADDR_ADD, (sysarg_t)addr->ipv4);
    142125        async_exchange_end(exch);
    143        
    144         if (rc != EOK) {
    145                 async_forget(req);
    146                 return rc;
    147         }
    148        
    149         sysarg_t retval;
    150         async_wait_for(req, &retval);
    151        
    152         return (int) retval;
     126
     127        return rc;
    153128}
    154129
    155 int iplink_addr_remove(iplink_t *iplink, inet_addr_t *addr)
     130int iplink_addr_remove(iplink_t *iplink, iplink_addr_t *addr)
    156131{
    157132        async_exch_t *exch = async_exchange_begin(iplink->sess);
    158        
    159         ipc_call_t answer;
    160         aid_t req = async_send_0(exch, IPLINK_ADDR_REMOVE, &answer);
    161        
    162         int rc = async_data_write_start(exch, addr, sizeof(inet_addr_t));
     133
     134        int rc = async_req_1_0(exch, IPLINK_ADDR_REMOVE, (sysarg_t)addr->ipv4);
    163135        async_exchange_end(exch);
    164        
    165         if (rc != EOK) {
    166                 async_forget(req);
    167                 return rc;
    168         }
    169        
    170         sysarg_t retval;
    171         async_wait_for(req, &retval);
    172        
    173         return (int) retval;
     136
     137        return rc;
    174138}
    175139
    176 static void iplink_ev_recv(iplink_t *iplink, ipc_callid_t iid,
    177     ipc_call_t *icall)
     140static void iplink_ev_recv(iplink_t *iplink, ipc_callid_t callid,
     141    ipc_call_t *call)
    178142{
    179         iplink_recv_sdu_t sdu;
    180        
    181         uint16_t af = IPC_GET_ARG1(*icall);
    182        
    183         int rc = async_data_write_accept(&sdu.data, false, 0, 0, 0,
    184             &sdu.size);
     143        int rc;
     144        iplink_sdu_t sdu;
     145
     146        sdu.lsrc.ipv4 = IPC_GET_ARG1(*call);
     147        sdu.ldest.ipv4 = IPC_GET_ARG2(*call);
     148
     149        rc = async_data_write_accept(&sdu.data, false, 0, 0, 0, &sdu.size);
    185150        if (rc != EOK) {
    186                 async_answer_0(iid, rc);
     151                async_answer_0(callid, rc);
    187152                return;
    188153        }
    189        
    190         rc = iplink->ev_ops->recv(iplink, &sdu, af);
     154
     155        rc = iplink->ev_ops->recv(iplink, &sdu);
    191156        free(sdu.data);
    192         async_answer_0(iid, rc);
     157        async_answer_0(callid, rc);
    193158}
    194159
    195160static void iplink_cb_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    196161{
    197         iplink_t *iplink = (iplink_t *) arg;
    198        
     162        iplink_t *iplink = (iplink_t *)arg;
     163
    199164        while (true) {
    200165                ipc_call_t call;
    201166                ipc_callid_t callid = async_get_call(&call);
    202                
     167
    203168                if (!IPC_GET_IMETHOD(call)) {
    204169                        /* TODO: Handle hangup */
    205170                        return;
    206171                }
    207                
     172
    208173                switch (IPC_GET_IMETHOD(call)) {
    209174                case IPLINK_EV_RECV:
Note: See TracChangeset for help on using the changeset viewer.