Changes in uspace/lib/c/generic/iplink.c [417a2ba1:77ad86c] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/iplink.c
r417a2ba1 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_2(exch, IPLINK_SEND, (sysarg_t) sdu->src, 89 (sysarg_t) sdu->dest, &answer); 90 87 aid_t req = async_send_2(exch, IPLINK_SEND, sdu->lsrc.ipv4, 88 sdu->ldest.ipv4, &answer); 91 89 int rc = async_data_write_start(exch, sdu->data, sdu->size); 92 93 90 async_exchange_end(exch); 94 91 95 92 if (rc != EOK) { 96 93 async_forget(req); 97 94 return rc; 98 95 } 99 96 100 97 sysarg_t retval; 101 98 async_wait_for(req, &retval); 102 103 return (int) retval; 104 } 99 if (retval != EOK) 100 return retval; 105 101 106 int iplink_send6(iplink_t *iplink, iplink_sdu6_t *sdu) 107 { 108 async_exch_t *exch = async_exchange_begin(iplink->sess); 109 110 ipc_call_t answer; 111 aid_t req = async_send_0(exch, IPLINK_SEND6, &answer); 112 113 int rc = async_data_write_start(exch, &sdu->dest, sizeof(addr48_t)); 114 if (rc != EOK) { 115 async_exchange_end(exch); 116 async_forget(req); 117 return rc; 118 } 119 120 rc = async_data_write_start(exch, sdu->data, sdu->size); 121 122 async_exchange_end(exch); 123 124 if (rc != EOK) { 125 async_forget(req); 126 return rc; 127 } 128 129 sysarg_t retval; 130 async_wait_for(req, &retval); 131 132 return (int) retval; 102 return EOK; 133 103 } 134 104 135 105 int iplink_get_mtu(iplink_t *iplink, size_t *rmtu) 136 106 { 107 sysarg_t mtu; 137 108 async_exch_t *exch = async_exchange_begin(iplink->sess); 138 139 sysarg_t mtu; 109 140 110 int rc = async_req_0_1(exch, IPLINK_GET_MTU, &mtu); 141 142 111 async_exchange_end(exch); 143 112 144 113 if (rc != EOK) 145 114 return rc; 146 115 147 116 *rmtu = mtu; 148 117 return EOK; 149 118 } 150 119 151 int iplink_ get_mac48(iplink_t *iplink, addr48_t *mac)120 int iplink_addr_add(iplink_t *iplink, iplink_addr_t *addr) 152 121 { 153 122 async_exch_t *exch = async_exchange_begin(iplink->sess); 154 155 ipc_call_t answer; 156 aid_t req = async_send_0(exch, IPLINK_GET_MAC48, &answer); 157 158 int rc = async_data_read_start(exch, mac, sizeof(addr48_t)); 159 160 loc_exchange_end(exch); 161 162 if (rc != EOK) { 163 async_forget(req); 164 return rc; 165 } 166 167 sysarg_t retval; 168 async_wait_for(req, &retval); 169 170 return (int) retval; 123 124 int rc = async_req_1_0(exch, IPLINK_ADDR_ADD, (sysarg_t)addr->ipv4); 125 async_exchange_end(exch); 126 127 return rc; 171 128 } 172 129 173 int iplink_addr_ add(iplink_t *iplink, inet_addr_t *addr)130 int iplink_addr_remove(iplink_t *iplink, iplink_addr_t *addr) 174 131 { 175 132 async_exch_t *exch = async_exchange_begin(iplink->sess); 176 177 ipc_call_t answer; 178 aid_t req = async_send_0(exch, IPLINK_ADDR_ADD, &answer); 179 180 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); 181 135 async_exchange_end(exch); 182 183 if (rc != EOK) { 184 async_forget(req); 185 return rc; 186 } 187 188 sysarg_t retval; 189 async_wait_for(req, &retval); 190 191 return (int) retval; 136 137 return rc; 192 138 } 193 139 194 int iplink_addr_remove(iplink_t *iplink, inet_addr_t *addr) 140 static void iplink_ev_recv(iplink_t *iplink, ipc_callid_t callid, 141 ipc_call_t *call) 195 142 { 196 async_exch_t *exch = async_exchange_begin(iplink->sess); 197 198 ipc_call_t answer; 199 aid_t req = async_send_0(exch, IPLINK_ADDR_REMOVE, &answer); 200 201 int rc = async_data_write_start(exch, addr, sizeof(inet_addr_t)); 202 async_exchange_end(exch); 203 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); 204 150 if (rc != EOK) { 205 async_forget(req); 206 return rc; 207 } 208 209 sysarg_t retval; 210 async_wait_for(req, &retval); 211 212 return (int) retval; 213 } 214 215 static void iplink_ev_recv(iplink_t *iplink, ipc_callid_t iid, 216 ipc_call_t *icall) 217 { 218 iplink_recv_sdu_t sdu; 219 220 ip_ver_t ver = IPC_GET_ARG1(*icall); 221 222 int rc = async_data_write_accept(&sdu.data, false, 0, 0, 0, 223 &sdu.size); 224 if (rc != EOK) { 225 async_answer_0(iid, rc); 151 async_answer_0(callid, rc); 226 152 return; 227 153 } 228 229 rc = iplink->ev_ops->recv(iplink, &sdu , ver);154 155 rc = iplink->ev_ops->recv(iplink, &sdu); 230 156 free(sdu.data); 231 async_answer_0( iid, rc);157 async_answer_0(callid, rc); 232 158 } 233 159 234 160 static void iplink_cb_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg) 235 161 { 236 iplink_t *iplink = (iplink_t *) 237 162 iplink_t *iplink = (iplink_t *)arg; 163 238 164 while (true) { 239 165 ipc_call_t call; 240 166 ipc_callid_t callid = async_get_call(&call); 241 167 242 168 if (!IPC_GET_IMETHOD(call)) { 243 169 /* TODO: Handle hangup */ 244 170 return; 245 171 } 246 172 247 173 switch (IPC_GET_IMETHOD(call)) { 248 174 case IPLINK_EV_RECV:
Note:
See TracChangeset
for help on using the changeset viewer.