Changes in uspace/lib/c/generic/inetcfg.c [347768d:02a09ed] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/inetcfg.c
r347768d r02a09ed 51 51 52 52 if (rc != EOK) { 53 async_ wait_for(req, NULL);53 async_forget(req); 54 54 return rc; 55 55 } … … 119 119 120 120 assert(inetcfg_sess == NULL); 121 121 122 122 rc = loc_service_get_id(SERVICE_NAME_INETCFG, &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(EXCHANGE_SERIALIZE, inet_svc, 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 140 ipc_call_t answer; 141 aid_t req = async_send_3(exch, INETCFG_ADDR_CREATE_STATIC, naddr->ipv4, 142 naddr->bits, link_id, &answer); 139 140 ipc_call_t answer; 141 aid_t req = async_send_1(exch, INETCFG_ADDR_CREATE_STATIC, link_id, 142 &answer); 143 144 int rc = async_data_write_start(exch, naddr, sizeof(inet_naddr_t)); 145 if (rc != EOK) { 146 async_exchange_end(exch); 147 async_forget(req); 148 return rc; 149 } 150 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 sysarg_t retval; 161 async_wait_for(req, &retval); 162 163 *addr_id = IPC_GET_ARG1(answer); 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); 173 async_exchange_end(exch); 174 175 return rc; 176 } 177 178 int inetcfg_addr_get(sysarg_t addr_id, inet_addr_info_t *ainfo) 179 { 180 async_exch_t *exch = async_exchange_begin(inetcfg_sess); 181 182 ipc_call_t answer; 183 aid_t req = async_send_1(exch, INETCFG_ADDR_GET, addr_id, &answer); 184 185 ipc_call_t answer_naddr; 186 aid_t req_naddr = async_data_read(exch, &ainfo->naddr, 187 sizeof(inet_naddr_t), &answer_naddr); 188 189 sysarg_t retval_naddr; 190 async_wait_for(req_naddr, &retval_naddr); 191 192 if (retval_naddr != EOK) { 193 async_exchange_end(exch); 194 async_forget(req); 195 return (int) retval_naddr; 196 } 197 198 ipc_call_t answer_name; 199 char name_buf[LOC_NAME_MAXLEN + 1]; 200 aid_t req_name = async_data_read(exch, name_buf, LOC_NAME_MAXLEN, 201 &answer_name); 202 203 async_exchange_end(exch); 204 205 sysarg_t retval_name; 206 async_wait_for(req_name, &retval_name); 207 208 if (retval_name != EOK) { 209 async_forget(req); 210 return (int) retval_name; 211 } 212 213 sysarg_t retval; 214 async_wait_for(req, &retval); 215 216 if (retval != EOK) 217 return (int) retval; 218 219 size_t act_size = IPC_GET_ARG2(answer_name); 220 assert(act_size <= LOC_NAME_MAXLEN); 221 222 name_buf[act_size] = '\0'; 223 224 ainfo->ilink = IPC_GET_ARG1(answer); 225 ainfo->name = str_dup(name_buf); 226 227 return EOK; 228 } 229 230 int inetcfg_addr_get_id(const char *name, sysarg_t link_id, sysarg_t *addr_id) 231 { 232 async_exch_t *exch = async_exchange_begin(inetcfg_sess); 233 234 ipc_call_t answer; 235 aid_t req = async_send_1(exch, INETCFG_ADDR_GET_ID, link_id, &answer); 143 236 sysarg_t retval = async_data_write_start(exch, name, str_size(name)); 144 237 … … 146 239 147 240 if (retval != EOK) { 148 async_ wait_for(req, NULL);241 async_forget(req); 149 242 return retval; 150 243 } … … 156 249 } 157 250 158 int inetcfg_addr_delete(sysarg_t addr_id) 159 { 160 async_exch_t *exch = async_exchange_begin(inetcfg_sess); 161 162 int rc = async_req_1_0(exch, INETCFG_ADDR_DELETE, addr_id); 163 async_exchange_end(exch); 164 165 return rc; 166 } 167 168 int inetcfg_addr_get(sysarg_t addr_id, inet_addr_info_t *ainfo) 251 int inetcfg_get_addr_list(sysarg_t **addrs, size_t *count) 252 { 253 return inetcfg_get_ids_internal(INETCFG_GET_ADDR_LIST, 254 0, addrs, count); 255 } 256 257 int inetcfg_get_link_list(sysarg_t **links, size_t *count) 258 { 259 return inetcfg_get_ids_internal(INETCFG_GET_LINK_LIST, 260 0, links, count); 261 } 262 263 int inetcfg_get_sroute_list(sysarg_t **sroutes, size_t *count) 264 { 265 return inetcfg_get_ids_internal(INETCFG_GET_SROUTE_LIST, 266 0, sroutes, count); 267 } 268 269 int inetcfg_link_get(sysarg_t link_id, inet_link_info_t *linfo) 169 270 { 170 271 ipc_call_t dreply; … … 176 277 177 278 ipc_call_t answer; 178 aid_t req = async_send_1(exch, INETCFG_ ADDR_GET, addr_id, &answer);279 aid_t req = async_send_1(exch, INETCFG_LINK_GET, link_id, &answer); 179 280 aid_t dreq = async_data_read(exch, name_buf, LOC_NAME_MAXLEN, &dreply); 180 281 async_wait_for(dreq, &dretval); … … 183 284 184 285 if (dretval != EOK) { 185 async_ wait_for(req, NULL);286 async_forget(req); 186 287 return dretval; 187 288 } … … 197 298 name_buf[act_size] = '\0'; 198 299 199 ainfo->naddr.ipv4 = IPC_GET_ARG1(answer);200 ainfo->naddr.bits = IPC_GET_ARG2(answer);201 ainfo->ilink = IPC_GET_ARG3(answer);202 ainfo->name = str_dup(name_buf);203 204 return EOK;205 }206 207 int inetcfg_addr_get_id(const char *name, sysarg_t link_id, sysarg_t *addr_id)208 {209 async_exch_t *exch = async_exchange_begin(inetcfg_sess);210 211 ipc_call_t answer;212 aid_t req = async_send_1(exch, INETCFG_ADDR_GET_ID, link_id, &answer);213 sysarg_t retval = async_data_write_start(exch, name, str_size(name));214 215 async_exchange_end(exch);216 217 if (retval != EOK) {218 async_wait_for(req, NULL);219 return retval;220 }221 222 async_wait_for(req, &retval);223 *addr_id = IPC_GET_ARG1(answer);224 225 return retval;226 }227 228 int inetcfg_get_addr_list(sysarg_t **addrs, size_t *count)229 {230 return inetcfg_get_ids_internal(INETCFG_GET_ADDR_LIST,231 0, addrs, count);232 }233 234 int inetcfg_get_link_list(sysarg_t **links, size_t *count)235 {236 return inetcfg_get_ids_internal(INETCFG_GET_LINK_LIST,237 0, links, count);238 }239 240 int inetcfg_get_sroute_list(sysarg_t **sroutes, size_t *count)241 {242 return inetcfg_get_ids_internal(INETCFG_GET_SROUTE_LIST,243 0, sroutes, count);244 }245 246 int inetcfg_link_get(sysarg_t link_id, inet_link_info_t *linfo)247 {248 ipc_call_t dreply;249 sysarg_t dretval;250 size_t act_size;251 char name_buf[LOC_NAME_MAXLEN + 1];252 253 async_exch_t *exch = async_exchange_begin(inetcfg_sess);254 255 ipc_call_t answer;256 aid_t req = async_send_1(exch, INETCFG_LINK_GET, link_id, &answer);257 aid_t dreq = async_data_read(exch, name_buf, LOC_NAME_MAXLEN, &dreply);258 async_wait_for(dreq, &dretval);259 260 async_exchange_end(exch);261 262 if (dretval != EOK) {263 async_wait_for(req, NULL);264 return dretval;265 }266 267 sysarg_t retval;268 async_wait_for(req, &retval);269 270 if (retval != EOK)271 return retval;272 273 act_size = IPC_GET_ARG2(dreply);274 assert(act_size <= LOC_NAME_MAXLEN);275 name_buf[act_size] = '\0';276 277 300 linfo->name = str_dup(name_buf); 278 301 linfo->def_mtu = IPC_GET_ARG1(answer); … … 285 308 { 286 309 async_exch_t *exch = async_exchange_begin(inetcfg_sess); 287 288 ipc_call_t answer; 289 aid_t req = async_send_3(exch, INETCFG_SROUTE_CREATE, 290 dest->ipv4, dest->bits, router->ipv4, &answer); 291 sysarg_t retval = async_data_write_start(exch, name, str_size(name)); 292 293 async_exchange_end(exch); 294 295 if (retval != EOK) { 296 async_wait_for(req, NULL); 297 return retval; 298 } 299 300 async_wait_for(req, &retval); 310 311 ipc_call_t answer; 312 aid_t req = async_send_0(exch, INETCFG_SROUTE_CREATE, &answer); 313 314 int rc = async_data_write_start(exch, dest, sizeof(inet_naddr_t)); 315 if (rc != EOK) { 316 async_exchange_end(exch); 317 async_forget(req); 318 return rc; 319 } 320 321 rc = async_data_write_start(exch, router, sizeof(inet_addr_t)); 322 if (rc != EOK) { 323 async_exchange_end(exch); 324 async_forget(req); 325 return rc; 326 } 327 328 rc = async_data_write_start(exch, name, str_size(name)); 329 330 async_exchange_end(exch); 331 332 if (rc != EOK) { 333 async_forget(req); 334 return rc; 335 } 336 337 sysarg_t retval; 338 async_wait_for(req, &retval); 339 301 340 *sroute_id = IPC_GET_ARG1(answer); 302 303 return retval;341 342 return (int) retval; 304 343 } 305 344 … … 316 355 int inetcfg_sroute_get(sysarg_t sroute_id, inet_sroute_info_t *srinfo) 317 356 { 318 ipc_call_t dreply; 319 sysarg_t dretval; 320 size_t act_size; 357 async_exch_t *exch = async_exchange_begin(inetcfg_sess); 358 359 ipc_call_t answer; 360 aid_t req = async_send_1(exch, INETCFG_SROUTE_GET, sroute_id, &answer); 361 362 ipc_call_t answer_dest; 363 aid_t req_dest = async_data_read(exch, &srinfo->dest, 364 sizeof(inet_naddr_t), &answer_dest); 365 366 sysarg_t retval_dest; 367 async_wait_for(req_dest, &retval_dest); 368 369 if (retval_dest != EOK) { 370 async_exchange_end(exch); 371 async_forget(req); 372 return (int) retval_dest; 373 } 374 375 ipc_call_t answer_router; 376 aid_t req_router = async_data_read(exch, &srinfo->router, 377 sizeof(inet_addr_t), &answer_router); 378 379 sysarg_t retval_router; 380 async_wait_for(req_router, &retval_router); 381 382 if (retval_router != EOK) { 383 async_exchange_end(exch); 384 async_forget(req); 385 return (int) retval_router; 386 } 387 388 ipc_call_t answer_name; 321 389 char name_buf[LOC_NAME_MAXLEN + 1]; 322 323 async_exch_t *exch = async_exchange_begin(inetcfg_sess); 324 325 ipc_call_t answer; 326 aid_t req = async_send_1(exch, INETCFG_SROUTE_GET, sroute_id, &answer); 327 aid_t dreq = async_data_read(exch, name_buf, LOC_NAME_MAXLEN, &dreply); 328 async_wait_for(dreq, &dretval); 329 330 async_exchange_end(exch); 331 332 if (dretval != EOK) { 333 async_wait_for(req, NULL); 334 return dretval; 335 } 336 337 sysarg_t retval; 338 async_wait_for(req, &retval); 339 390 aid_t req_name = async_data_read(exch, name_buf, LOC_NAME_MAXLEN, 391 &answer_name); 392 393 async_exchange_end(exch); 394 395 sysarg_t retval_name; 396 async_wait_for(req_name, &retval_name); 397 398 if (retval_name != EOK) { 399 async_forget(req); 400 return (int) retval_name; 401 } 402 403 sysarg_t retval; 404 async_wait_for(req, &retval); 405 340 406 if (retval != EOK) 341 return retval;342 343 act_size = IPC_GET_ARG2(dreply);407 return (int) retval; 408 409 size_t act_size = IPC_GET_ARG2(answer_name); 344 410 assert(act_size <= LOC_NAME_MAXLEN); 411 345 412 name_buf[act_size] = '\0'; 346 347 srinfo->dest.ipv4 = IPC_GET_ARG1(answer); 348 srinfo->dest.bits = IPC_GET_ARG2(answer); 349 srinfo->router.ipv4 = IPC_GET_ARG3(answer); 413 350 414 srinfo->name = str_dup(name_buf); 351 415 352 416 return EOK; 353 417 } … … 364 428 365 429 if (retval != EOK) { 366 async_ wait_for(req, NULL);430 async_forget(req); 367 431 return retval; 368 432 }
Note:
See TracChangeset
for help on using the changeset viewer.