Changes in uspace/lib/c/generic/iplink.c [02a09ed:77ad86c] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/iplink.c
r02a09ed r77ad86c 39 39 #include <errno.h> 40 40 #include <inet/iplink.h> 41 #include <inet/addr.h>42 41 #include <ipc/iplink.h> 43 42 #include <ipc/services.h> … … 84 83 { 85 84 async_exch_t *exch = async_exchange_begin(iplink->sess); 86 85 87 86 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); 106 90 async_exchange_end(exch); 107 91 108 92 if (rc != EOK) { 109 93 async_forget(req); 110 94 return rc; 111 95 } 112 96 113 97 sysarg_t retval; 114 98 async_wait_for(req, &retval); 115 116 return (int) retval; 99 if (retval != EOK) 100 return retval; 101 102 return EOK; 117 103 } 118 104 … … 132 118 } 133 119 134 int iplink_addr_add(iplink_t *iplink, i net_addr_t *addr)120 int iplink_addr_add(iplink_t *iplink, iplink_addr_t *addr) 135 121 { 136 122 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); 142 125 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; 153 128 } 154 129 155 int iplink_addr_remove(iplink_t *iplink, i net_addr_t *addr)130 int iplink_addr_remove(iplink_t *iplink, iplink_addr_t *addr) 156 131 { 157 132 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); 163 135 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; 174 138 } 175 139 176 static void iplink_ev_recv(iplink_t *iplink, ipc_callid_t iid,177 ipc_call_t * icall)140 static void iplink_ev_recv(iplink_t *iplink, ipc_callid_t callid, 141 ipc_call_t *call) 178 142 { 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); 185 150 if (rc != EOK) { 186 async_answer_0( iid, rc);151 async_answer_0(callid, rc); 187 152 return; 188 153 } 189 190 rc = iplink->ev_ops->recv(iplink, &sdu , af);154 155 rc = iplink->ev_ops->recv(iplink, &sdu); 191 156 free(sdu.data); 192 async_answer_0( iid, rc);157 async_answer_0(callid, rc); 193 158 } 194 159 195 160 static void iplink_cb_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg) 196 161 { 197 iplink_t *iplink = (iplink_t *) 198 162 iplink_t *iplink = (iplink_t *)arg; 163 199 164 while (true) { 200 165 ipc_call_t call; 201 166 ipc_callid_t callid = async_get_call(&call); 202 167 203 168 if (!IPC_GET_IMETHOD(call)) { 204 169 /* TODO: Handle hangup */ 205 170 return; 206 171 } 207 172 208 173 switch (IPC_GET_IMETHOD(call)) { 209 174 case IPLINK_EV_RECV:
Note:
See TracChangeset
for help on using the changeset viewer.