Changeset a35b458 in mainline for uspace/lib/c/generic/iplink.c
- Timestamp:
- 2018-03-02T20:10:49Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1380b7
- Parents:
- 3061bc1
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/iplink.c
r3061bc1 ra35b458 53 53 if (iplink == NULL) 54 54 return ENOMEM; 55 55 56 56 iplink->sess = sess; 57 57 iplink->ev_ops = ev_ops; 58 58 iplink->arg = arg; 59 59 60 60 async_exch_t *exch = async_exchange_begin(sess); 61 61 … … 63 63 errno_t rc = async_create_callback_port(exch, INTERFACE_IPLINK_CB, 0, 0, 64 64 iplink_cb_conn, iplink, &port); 65 66 async_exchange_end(exch); 67 65 66 async_exchange_end(exch); 67 68 68 if (rc != EOK) 69 69 goto error; 70 70 71 71 *riplink = iplink; 72 72 return EOK; 73 73 74 74 error: 75 75 if (iplink != NULL) 76 76 free(iplink); 77 77 78 78 return rc; 79 79 } … … 88 88 { 89 89 async_exch_t *exch = async_exchange_begin(iplink->sess); 90 90 91 91 ipc_call_t answer; 92 92 aid_t req = async_send_2(exch, IPLINK_SEND, (sysarg_t) sdu->src, 93 93 (sysarg_t) sdu->dest, &answer); 94 94 95 95 errno_t rc = async_data_write_start(exch, sdu->data, sdu->size); 96 97 async_exchange_end(exch); 98 99 if (rc != EOK) { 100 async_forget(req); 101 return rc; 102 } 103 104 errno_t retval; 105 async_wait_for(req, &retval); 106 96 97 async_exchange_end(exch); 98 99 if (rc != EOK) { 100 async_forget(req); 101 return rc; 102 } 103 104 errno_t retval; 105 async_wait_for(req, &retval); 106 107 107 return retval; 108 108 } … … 111 111 { 112 112 async_exch_t *exch = async_exchange_begin(iplink->sess); 113 113 114 114 ipc_call_t answer; 115 115 aid_t req = async_send_0(exch, IPLINK_SEND6, &answer); 116 116 117 117 errno_t rc = async_data_write_start(exch, &sdu->dest, sizeof(addr48_t)); 118 118 if (rc != EOK) { … … 121 121 return rc; 122 122 } 123 123 124 124 rc = async_data_write_start(exch, sdu->data, sdu->size); 125 126 async_exchange_end(exch); 127 128 if (rc != EOK) { 129 async_forget(req); 130 return rc; 131 } 132 133 errno_t retval; 134 async_wait_for(req, &retval); 135 125 126 async_exchange_end(exch); 127 128 if (rc != EOK) { 129 async_forget(req); 130 return rc; 131 } 132 133 errno_t retval; 134 async_wait_for(req, &retval); 135 136 136 return retval; 137 137 } … … 140 140 { 141 141 async_exch_t *exch = async_exchange_begin(iplink->sess); 142 142 143 143 sysarg_t mtu; 144 144 errno_t rc = async_req_0_1(exch, IPLINK_GET_MTU, &mtu); 145 146 async_exchange_end(exch); 147 145 146 async_exchange_end(exch); 147 148 148 if (rc != EOK) 149 149 return rc; 150 150 151 151 *rmtu = mtu; 152 152 return EOK; … … 156 156 { 157 157 async_exch_t *exch = async_exchange_begin(iplink->sess); 158 158 159 159 ipc_call_t answer; 160 160 aid_t req = async_send_0(exch, IPLINK_GET_MAC48, &answer); 161 161 162 162 errno_t rc = async_data_read_start(exch, mac, sizeof(addr48_t)); 163 163 164 164 loc_exchange_end(exch); 165 166 if (rc != EOK) { 167 async_forget(req); 168 return rc; 169 } 170 171 errno_t retval; 172 async_wait_for(req, &retval); 173 165 166 if (rc != EOK) { 167 async_forget(req); 168 return rc; 169 } 170 171 errno_t retval; 172 async_wait_for(req, &retval); 173 174 174 return retval; 175 175 } … … 178 178 { 179 179 async_exch_t *exch = async_exchange_begin(iplink->sess); 180 180 181 181 ipc_call_t answer; 182 182 aid_t req = async_send_0(exch, IPLINK_GET_MAC48, &answer); 183 183 184 184 errno_t rc = async_data_read_start(exch, mac, sizeof(addr48_t)); 185 185 186 186 loc_exchange_end(exch); 187 188 if (rc != EOK) { 189 async_forget(req); 190 return rc; 191 } 192 193 errno_t retval; 194 async_wait_for(req, &retval); 195 187 188 if (rc != EOK) { 189 async_forget(req); 190 return rc; 191 } 192 193 errno_t retval; 194 async_wait_for(req, &retval); 195 196 196 return retval; 197 197 } … … 201 201 { 202 202 async_exch_t *exch = async_exchange_begin(iplink->sess); 203 203 204 204 ipc_call_t answer; 205 205 aid_t req = async_send_0(exch, IPLINK_ADDR_ADD, &answer); 206 206 207 207 errno_t rc = async_data_write_start(exch, addr, sizeof(inet_addr_t)); 208 208 async_exchange_end(exch); 209 210 if (rc != EOK) { 211 async_forget(req); 212 return rc; 213 } 214 215 errno_t retval; 216 async_wait_for(req, &retval); 217 209 210 if (rc != EOK) { 211 async_forget(req); 212 return rc; 213 } 214 215 errno_t retval; 216 async_wait_for(req, &retval); 217 218 218 return retval; 219 219 } … … 222 222 { 223 223 async_exch_t *exch = async_exchange_begin(iplink->sess); 224 224 225 225 ipc_call_t answer; 226 226 aid_t req = async_send_0(exch, IPLINK_ADDR_REMOVE, &answer); 227 227 228 228 errno_t rc = async_data_write_start(exch, addr, sizeof(inet_addr_t)); 229 229 async_exchange_end(exch); 230 231 if (rc != EOK) { 232 async_forget(req); 233 return rc; 234 } 235 236 errno_t retval; 237 async_wait_for(req, &retval); 238 230 231 if (rc != EOK) { 232 async_forget(req); 233 return rc; 234 } 235 236 errno_t retval; 237 async_wait_for(req, &retval); 238 239 239 return retval; 240 240 } … … 249 249 { 250 250 iplink_recv_sdu_t sdu; 251 251 252 252 ip_ver_t ver = IPC_GET_ARG1(*icall); 253 253 254 254 errno_t rc = async_data_write_accept(&sdu.data, false, 0, 0, 0, 255 255 &sdu.size); … … 258 258 return; 259 259 } 260 260 261 261 rc = iplink->ev_ops->recv(iplink, &sdu, ver); 262 262 free(sdu.data); … … 269 269 addr48_t *addr; 270 270 size_t size; 271 271 272 272 errno_t rc = async_data_write_accept((void **)&addr, false, 273 273 sizeof(addr48_t), sizeof(addr48_t), 0, &size); … … 285 285 { 286 286 iplink_t *iplink = (iplink_t *) arg; 287 287 288 288 while (true) { 289 289 ipc_call_t call; 290 290 ipc_callid_t callid = async_get_call(&call); 291 291 292 292 if (!IPC_GET_IMETHOD(call)) { 293 293 /* TODO: Handle hangup */ 294 294 return; 295 295 } 296 296 297 297 switch (IPC_GET_IMETHOD(call)) { 298 298 case IPLINK_EV_RECV:
Note:
See TracChangeset
for help on using the changeset viewer.