Changes in uspace/lib/c/generic/inetcfg.c [f9b2cb4c:b7fd2a0] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/inetcfg.c
rf9b2cb4c rb7fd2a0 39 39 static async_sess_t *inetcfg_sess = NULL; 40 40 41 static int inetcfg_get_ids_once(sysarg_t method, sysarg_t arg1,41 static errno_t inetcfg_get_ids_once(sysarg_t method, sysarg_t arg1, 42 42 sysarg_t *id_buf, size_t buf_size, size_t *act_size) 43 43 { … … 46 46 ipc_call_t answer; 47 47 aid_t req = async_send_1(exch, method, arg1, &answer); 48 int rc = async_data_read_start(exch, id_buf, buf_size);49 50 async_exchange_end(exch); 51 52 if (rc != EOK) { 53 async_forget(req); 54 return rc; 55 } 56 57 sysarg_t retval;48 errno_t rc = async_data_read_start(exch, id_buf, buf_size); 49 50 async_exchange_end(exch); 51 52 if (rc != EOK) { 53 async_forget(req); 54 return rc; 55 } 56 57 errno_t retval; 58 58 async_wait_for(req, &retval); 59 59 … … 74 74 * @param data Place to store pointer to array of IDs 75 75 * @param count Place to store number of IDs 76 * @return EOK on success or negativeerror code76 * @return EOK on success or an error code 77 77 */ 78 static int inetcfg_get_ids_internal(sysarg_t method, sysarg_t arg1,78 static errno_t inetcfg_get_ids_internal(sysarg_t method, sysarg_t arg1, 79 79 sysarg_t **data, size_t *count) 80 80 { … … 83 83 84 84 size_t act_size = 0; 85 int rc = inetcfg_get_ids_once(method, arg1, NULL, 0,85 errno_t rc = inetcfg_get_ids_once(method, arg1, NULL, 0, 86 86 &act_size); 87 87 if (rc != EOK) … … 113 113 } 114 114 115 int inetcfg_init(void)115 errno_t inetcfg_init(void) 116 116 { 117 117 service_id_t inet_svc; 118 int rc;118 errno_t rc; 119 119 120 120 assert(inetcfg_sess == NULL); … … 133 133 } 134 134 135 int inetcfg_addr_create_static(const char *name, inet_naddr_t *naddr,135 errno_t inetcfg_addr_create_static(const char *name, inet_naddr_t *naddr, 136 136 sysarg_t link_id, sysarg_t *addr_id) 137 137 { … … 142 142 &answer); 143 143 144 int rc = async_data_write_start(exch, naddr, sizeof(inet_naddr_t));144 errno_t rc = async_data_write_start(exch, naddr, sizeof(inet_naddr_t)); 145 145 if (rc != EOK) { 146 146 async_exchange_end(exch); … … 158 158 } 159 159 160 sysarg_t retval;160 errno_t retval; 161 161 async_wait_for(req, &retval); 162 162 163 163 *addr_id = IPC_GET_ARG1(answer); 164 164 165 return (int)retval;166 } 167 168 int inetcfg_addr_delete(sysarg_t addr_id)169 { 170 async_exch_t *exch = async_exchange_begin(inetcfg_sess); 171 172 int rc = async_req_1_0(exch, INETCFG_ADDR_DELETE, addr_id);165 return retval; 166 } 167 168 errno_t inetcfg_addr_delete(sysarg_t addr_id) 169 { 170 async_exch_t *exch = async_exchange_begin(inetcfg_sess); 171 172 errno_t rc = async_req_1_0(exch, INETCFG_ADDR_DELETE, addr_id); 173 173 async_exchange_end(exch); 174 174 … … 176 176 } 177 177 178 int inetcfg_addr_get(sysarg_t addr_id, inet_addr_info_t *ainfo)178 errno_t inetcfg_addr_get(sysarg_t addr_id, inet_addr_info_t *ainfo) 179 179 { 180 180 async_exch_t *exch = async_exchange_begin(inetcfg_sess); … … 187 187 sizeof(inet_naddr_t), &answer_naddr); 188 188 189 sysarg_t retval_naddr;189 errno_t retval_naddr; 190 190 async_wait_for(req_naddr, &retval_naddr); 191 191 … … 193 193 async_exchange_end(exch); 194 194 async_forget(req); 195 return (int)retval_naddr;195 return retval_naddr; 196 196 } 197 197 … … 203 203 async_exchange_end(exch); 204 204 205 sysarg_t retval_name;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 return (int)retval_name;211 } 212 213 sysarg_t retval;210 return retval_name; 211 } 212 213 errno_t retval; 214 214 async_wait_for(req, &retval); 215 215 216 216 if (retval != EOK) 217 return (int)retval;217 return retval; 218 218 219 219 size_t act_size = IPC_GET_ARG2(answer_name); … … 228 228 } 229 229 230 int inetcfg_addr_get_id(const char *name, sysarg_t link_id, sysarg_t *addr_id)230 errno_t inetcfg_addr_get_id(const char *name, sysarg_t link_id, sysarg_t *addr_id) 231 231 { 232 232 async_exch_t *exch = async_exchange_begin(inetcfg_sess); … … 234 234 ipc_call_t answer; 235 235 aid_t req = async_send_1(exch, INETCFG_ADDR_GET_ID, link_id, &answer); 236 sysarg_t retval = async_data_write_start(exch, name, str_size(name));236 errno_t retval = async_data_write_start(exch, name, str_size(name)); 237 237 238 238 async_exchange_end(exch); … … 249 249 } 250 250 251 int inetcfg_get_addr_list(sysarg_t **addrs, size_t *count)251 errno_t inetcfg_get_addr_list(sysarg_t **addrs, size_t *count) 252 252 { 253 253 return inetcfg_get_ids_internal(INETCFG_GET_ADDR_LIST, … … 255 255 } 256 256 257 int inetcfg_get_link_list(sysarg_t **links, size_t *count)257 errno_t inetcfg_get_link_list(sysarg_t **links, size_t *count) 258 258 { 259 259 return inetcfg_get_ids_internal(INETCFG_GET_LINK_LIST, … … 261 261 } 262 262 263 int inetcfg_get_sroute_list(sysarg_t **sroutes, size_t *count)263 errno_t inetcfg_get_sroute_list(sysarg_t **sroutes, size_t *count) 264 264 { 265 265 return inetcfg_get_ids_internal(INETCFG_GET_SROUTE_LIST, … … 267 267 } 268 268 269 int inetcfg_link_add(sysarg_t link_id)270 { 271 async_exch_t *exch = async_exchange_begin(inetcfg_sess); 272 273 int rc = async_req_1_0(exch, INETCFG_LINK_ADD, link_id);269 errno_t inetcfg_link_add(sysarg_t link_id) 270 { 271 async_exch_t *exch = async_exchange_begin(inetcfg_sess); 272 273 errno_t rc = async_req_1_0(exch, INETCFG_LINK_ADD, link_id); 274 274 async_exchange_end(exch); 275 275 … … 277 277 } 278 278 279 int inetcfg_link_get(sysarg_t link_id, inet_link_info_t *linfo)279 errno_t inetcfg_link_get(sysarg_t link_id, inet_link_info_t *linfo) 280 280 { 281 281 ipc_call_t dreply; 282 sysarg_t dretval;282 errno_t dretval; 283 283 size_t act_size; 284 284 char name_buf[LOC_NAME_MAXLEN + 1]; … … 289 289 aid_t req = async_send_1(exch, INETCFG_LINK_GET, link_id, &answer); 290 290 aid_t dreq = async_data_read(exch, name_buf, LOC_NAME_MAXLEN, &dreply); 291 int rc = async_data_read_start(exch, &linfo->mac_addr, sizeof(addr48_t));291 errno_t rc = async_data_read_start(exch, &linfo->mac_addr, sizeof(addr48_t)); 292 292 async_wait_for(dreq, &dretval); 293 293 … … 299 299 } 300 300 301 sysarg_t retval;301 errno_t retval; 302 302 async_wait_for(req, &retval); 303 303 … … 315 315 } 316 316 317 int inetcfg_link_remove(sysarg_t link_id)318 { 319 async_exch_t *exch = async_exchange_begin(inetcfg_sess); 320 321 int rc = async_req_1_0(exch, INETCFG_LINK_REMOVE, link_id);317 errno_t inetcfg_link_remove(sysarg_t link_id) 318 { 319 async_exch_t *exch = async_exchange_begin(inetcfg_sess); 320 321 errno_t rc = async_req_1_0(exch, INETCFG_LINK_REMOVE, link_id); 322 322 async_exchange_end(exch); 323 323 … … 325 325 } 326 326 327 int inetcfg_sroute_create(const char *name, inet_naddr_t *dest,327 errno_t inetcfg_sroute_create(const char *name, inet_naddr_t *dest, 328 328 inet_addr_t *router, sysarg_t *sroute_id) 329 329 { … … 333 333 aid_t req = async_send_0(exch, INETCFG_SROUTE_CREATE, &answer); 334 334 335 int rc = async_data_write_start(exch, dest, sizeof(inet_naddr_t));335 errno_t rc = async_data_write_start(exch, dest, sizeof(inet_naddr_t)); 336 336 if (rc != EOK) { 337 337 async_exchange_end(exch); … … 356 356 } 357 357 358 sysarg_t retval;358 errno_t retval; 359 359 async_wait_for(req, &retval); 360 360 361 361 *sroute_id = IPC_GET_ARG1(answer); 362 362 363 return (int)retval;364 } 365 366 int inetcfg_sroute_delete(sysarg_t sroute_id)367 { 368 async_exch_t *exch = async_exchange_begin(inetcfg_sess); 369 370 int rc = async_req_1_0(exch, INETCFG_SROUTE_DELETE, sroute_id);363 return retval; 364 } 365 366 errno_t inetcfg_sroute_delete(sysarg_t sroute_id) 367 { 368 async_exch_t *exch = async_exchange_begin(inetcfg_sess); 369 370 errno_t rc = async_req_1_0(exch, INETCFG_SROUTE_DELETE, sroute_id); 371 371 async_exchange_end(exch); 372 372 … … 374 374 } 375 375 376 int inetcfg_sroute_get(sysarg_t sroute_id, inet_sroute_info_t *srinfo)376 errno_t inetcfg_sroute_get(sysarg_t sroute_id, inet_sroute_info_t *srinfo) 377 377 { 378 378 async_exch_t *exch = async_exchange_begin(inetcfg_sess); … … 385 385 sizeof(inet_naddr_t), &answer_dest); 386 386 387 sysarg_t retval_dest;387 errno_t retval_dest; 388 388 async_wait_for(req_dest, &retval_dest); 389 389 … … 391 391 async_exchange_end(exch); 392 392 async_forget(req); 393 return (int)retval_dest;393 return retval_dest; 394 394 } 395 395 … … 398 398 sizeof(inet_addr_t), &answer_router); 399 399 400 sysarg_t retval_router;400 errno_t retval_router; 401 401 async_wait_for(req_router, &retval_router); 402 402 … … 404 404 async_exchange_end(exch); 405 405 async_forget(req); 406 return (int)retval_router;406 return retval_router; 407 407 } 408 408 … … 414 414 async_exchange_end(exch); 415 415 416 sysarg_t retval_name;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 return (int)retval_name;422 } 423 424 sysarg_t retval;421 return retval_name; 422 } 423 424 errno_t retval; 425 425 async_wait_for(req, &retval); 426 426 427 427 if (retval != EOK) 428 return (int)retval;428 return retval; 429 429 430 430 size_t act_size = IPC_GET_ARG2(answer_name); … … 438 438 } 439 439 440 int inetcfg_sroute_get_id(const char *name, sysarg_t *sroute_id)440 errno_t inetcfg_sroute_get_id(const char *name, sysarg_t *sroute_id) 441 441 { 442 442 async_exch_t *exch = async_exchange_begin(inetcfg_sess); … … 444 444 ipc_call_t answer; 445 445 aid_t req = async_send_0(exch, INETCFG_SROUTE_GET_ID, &answer); 446 sysarg_t retval = async_data_write_start(exch, name, str_size(name));446 errno_t retval = async_data_write_start(exch, name, str_size(name)); 447 447 448 448 async_exchange_end(exch);
Note:
See TracChangeset
for help on using the changeset viewer.