Changeset a35b458 in mainline for uspace/lib/c/generic/inetcfg.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/inetcfg.c
r3061bc1 ra35b458 119 119 120 120 assert(inetcfg_sess == NULL); 121 121 122 122 rc = loc_service_get_id(SERVICE_NAME_INET, &inet_svc, 123 123 IPC_FLAG_BLOCKING); 124 124 if (rc != EOK) 125 125 return ENOENT; 126 126 127 127 inetcfg_sess = loc_service_connect(inet_svc, INTERFACE_INETCFG, 128 128 IPC_FLAG_BLOCKING); 129 129 if (inetcfg_sess == NULL) 130 130 return ENOENT; 131 131 132 132 return EOK; 133 133 } … … 137 137 { 138 138 async_exch_t *exch = async_exchange_begin(inetcfg_sess); 139 139 140 140 ipc_call_t answer; 141 141 aid_t req = async_send_1(exch, INETCFG_ADDR_CREATE_STATIC, link_id, 142 142 &answer); 143 143 144 144 errno_t rc = async_data_write_start(exch, naddr, sizeof(inet_naddr_t)); 145 145 if (rc != EOK) { … … 148 148 return rc; 149 149 } 150 150 151 151 rc = async_data_write_start(exch, name, str_size(name)); 152 153 async_exchange_end(exch); 154 155 if (rc != EOK) { 156 async_forget(req); 157 return rc; 158 } 159 160 errno_t retval; 161 async_wait_for(req, &retval); 162 152 153 async_exchange_end(exch); 154 155 if (rc != EOK) { 156 async_forget(req); 157 return rc; 158 } 159 160 errno_t retval; 161 async_wait_for(req, &retval); 162 163 163 *addr_id = IPC_GET_ARG1(answer); 164 164 165 165 return retval; 166 166 } … … 179 179 { 180 180 async_exch_t *exch = async_exchange_begin(inetcfg_sess); 181 181 182 182 ipc_call_t answer; 183 183 aid_t req = async_send_1(exch, INETCFG_ADDR_GET, addr_id, &answer); 184 184 185 185 ipc_call_t answer_naddr; 186 186 aid_t req_naddr = async_data_read(exch, &ainfo->naddr, 187 187 sizeof(inet_naddr_t), &answer_naddr); 188 188 189 189 errno_t retval_naddr; 190 190 async_wait_for(req_naddr, &retval_naddr); 191 191 192 192 if (retval_naddr != EOK) { 193 193 async_exchange_end(exch); … … 195 195 return retval_naddr; 196 196 } 197 197 198 198 ipc_call_t answer_name; 199 199 char name_buf[LOC_NAME_MAXLEN + 1]; 200 200 aid_t req_name = async_data_read(exch, name_buf, LOC_NAME_MAXLEN, 201 201 &answer_name); 202 203 async_exchange_end(exch); 204 202 203 async_exchange_end(exch); 204 205 205 errno_t retval_name; 206 206 async_wait_for(req_name, &retval_name); 207 207 208 208 if (retval_name != EOK) { 209 209 async_forget(req); 210 210 return retval_name; 211 211 } 212 213 errno_t retval; 214 async_wait_for(req, &retval); 215 212 213 errno_t retval; 214 async_wait_for(req, &retval); 215 216 216 if (retval != EOK) 217 217 return retval; 218 218 219 219 size_t act_size = IPC_GET_ARG2(answer_name); 220 220 assert(act_size <= LOC_NAME_MAXLEN); 221 221 222 222 name_buf[act_size] = '\0'; 223 223 224 224 ainfo->ilink = IPC_GET_ARG1(answer); 225 225 ainfo->name = str_dup(name_buf); 226 226 227 227 return EOK; 228 228 } … … 329 329 { 330 330 async_exch_t *exch = async_exchange_begin(inetcfg_sess); 331 331 332 332 ipc_call_t answer; 333 333 aid_t req = async_send_0(exch, INETCFG_SROUTE_CREATE, &answer); 334 334 335 335 errno_t rc = async_data_write_start(exch, dest, sizeof(inet_naddr_t)); 336 336 if (rc != EOK) { … … 339 339 return rc; 340 340 } 341 341 342 342 rc = async_data_write_start(exch, router, sizeof(inet_addr_t)); 343 343 if (rc != EOK) { … … 346 346 return rc; 347 347 } 348 348 349 349 rc = async_data_write_start(exch, name, str_size(name)); 350 351 async_exchange_end(exch); 352 353 if (rc != EOK) { 354 async_forget(req); 355 return rc; 356 } 357 358 errno_t retval; 359 async_wait_for(req, &retval); 360 350 351 async_exchange_end(exch); 352 353 if (rc != EOK) { 354 async_forget(req); 355 return rc; 356 } 357 358 errno_t retval; 359 async_wait_for(req, &retval); 360 361 361 *sroute_id = IPC_GET_ARG1(answer); 362 362 363 363 return retval; 364 364 } … … 377 377 { 378 378 async_exch_t *exch = async_exchange_begin(inetcfg_sess); 379 379 380 380 ipc_call_t answer; 381 381 aid_t req = async_send_1(exch, INETCFG_SROUTE_GET, sroute_id, &answer); 382 382 383 383 ipc_call_t answer_dest; 384 384 aid_t req_dest = async_data_read(exch, &srinfo->dest, 385 385 sizeof(inet_naddr_t), &answer_dest); 386 386 387 387 errno_t retval_dest; 388 388 async_wait_for(req_dest, &retval_dest); 389 389 390 390 if (retval_dest != EOK) { 391 391 async_exchange_end(exch); … … 393 393 return retval_dest; 394 394 } 395 395 396 396 ipc_call_t answer_router; 397 397 aid_t req_router = async_data_read(exch, &srinfo->router, 398 398 sizeof(inet_addr_t), &answer_router); 399 399 400 400 errno_t retval_router; 401 401 async_wait_for(req_router, &retval_router); 402 402 403 403 if (retval_router != EOK) { 404 404 async_exchange_end(exch); … … 406 406 return retval_router; 407 407 } 408 408 409 409 ipc_call_t answer_name; 410 410 char name_buf[LOC_NAME_MAXLEN + 1]; 411 411 aid_t req_name = async_data_read(exch, name_buf, LOC_NAME_MAXLEN, 412 412 &answer_name); 413 414 async_exchange_end(exch); 415 413 414 async_exchange_end(exch); 415 416 416 errno_t retval_name; 417 417 async_wait_for(req_name, &retval_name); 418 418 419 419 if (retval_name != EOK) { 420 420 async_forget(req); 421 421 return retval_name; 422 422 } 423 424 errno_t retval; 425 async_wait_for(req, &retval); 426 423 424 errno_t retval; 425 async_wait_for(req, &retval); 426 427 427 if (retval != EOK) 428 428 return retval; 429 429 430 430 size_t act_size = IPC_GET_ARG2(answer_name); 431 431 assert(act_size <= LOC_NAME_MAXLEN); 432 432 433 433 name_buf[act_size] = '\0'; 434 434 435 435 srinfo->name = str_dup(name_buf); 436 436 437 437 return EOK; 438 438 }
Note:
See TracChangeset
for help on using the changeset viewer.