Ignore:
File:
1 edited

Legend:

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

    ra17356fd rf9b2cb4c  
    4747static void iplink_cb_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg);
    4848
    49 int iplink_open(async_sess_t *sess, iplink_ev_ops_t *ev_ops,
     49int iplink_open(async_sess_t *sess, iplink_ev_ops_t *ev_ops, void *arg,
    5050    iplink_t **riplink)
    5151{
     
    5656        iplink->sess = sess;
    5757        iplink->ev_ops = ev_ops;
     58        iplink->arg = arg;
    5859       
    5960        async_exch_t *exch = async_exchange_begin(sess);
    60        
    61         int rc = async_connect_to_me(exch, 0, 0, 0, iplink_cb_conn, iplink);
     61
     62        port_id_t port;
     63        int rc = async_create_callback_port(exch, INTERFACE_IPLINK_CB, 0, 0,
     64            iplink_cb_conn, iplink, &port);
     65       
    6266        async_exchange_end(exch);
    6367       
     
    171175}
    172176
     177int iplink_set_mac48(iplink_t *iplink, addr48_t mac)
     178{
     179        async_exch_t *exch = async_exchange_begin(iplink->sess);
     180       
     181        ipc_call_t answer;
     182        aid_t req = async_send_0(exch, IPLINK_GET_MAC48, &answer);
     183       
     184        int rc = async_data_read_start(exch, mac, sizeof(addr48_t));
     185       
     186        loc_exchange_end(exch);
     187       
     188        if (rc != EOK) {
     189                async_forget(req);
     190                return rc;
     191        }
     192       
     193        sysarg_t retval;
     194        async_wait_for(req, &retval);
     195       
     196        return (int) retval;
     197}
     198
     199
    173200int iplink_addr_add(iplink_t *iplink, inet_addr_t *addr)
    174201{
     
    211238       
    212239        return (int) retval;
     240}
     241
     242void *iplink_get_userptr(iplink_t *iplink)
     243{
     244        return iplink->arg;
    213245}
    214246
     
    218250        iplink_recv_sdu_t sdu;
    219251       
    220         uint16_t af = IPC_GET_ARG1(*icall);
     252        ip_ver_t ver = IPC_GET_ARG1(*icall);
    221253       
    222254        int rc = async_data_write_accept(&sdu.data, false, 0, 0, 0,
     
    227259        }
    228260       
    229         rc = iplink->ev_ops->recv(iplink, &sdu, af);
     261        rc = iplink->ev_ops->recv(iplink, &sdu, ver);
    230262        free(sdu.data);
    231263        async_answer_0(iid, rc);
     264}
     265
     266static void iplink_ev_change_addr(iplink_t *iplink, ipc_callid_t iid,
     267    ipc_call_t *icall)
     268{
     269        addr48_t *addr;
     270        size_t size;
     271       
     272        int rc = async_data_write_accept((void **)&addr, false,
     273            sizeof(addr48_t), sizeof(addr48_t), 0, &size);
     274        if (rc != EOK) {
     275                async_answer_0(iid, rc);
     276                return;
     277        }
     278
     279        rc = iplink->ev_ops->change_addr(iplink, *addr);
     280        free(addr);
     281        async_answer_0(iid, EOK);
    232282}
    233283
     
    249299                        iplink_ev_recv(iplink, callid, &call);
    250300                        break;
     301                case IPLINK_EV_CHANGE_ADDR:
     302                        iplink_ev_change_addr(iplink, callid, &call);
    251303                default:
    252304                        async_answer_0(callid, ENOTSUP);
Note: See TracChangeset for help on using the changeset viewer.