Changeset b8b1adb1 in mainline for uspace/srv
- Timestamp:
- 2013-09-15T16:00:37Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 947e2ef
- Parents:
- 695b6ff
- Location:
- uspace/srv/net/inetsrv
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/inetsrv/inet_link.c
r695b6ff rb8b1adb1 493 493 } 494 494 495 /** Get IDs of all links. */ 496 int inet_link_get_id_list(sysarg_t **rid_list, size_t *rcount) 497 { 498 sysarg_t *id_list; 499 size_t count, i; 500 501 fibril_mutex_lock(&inet_discovery_lock); 502 count = list_count(&inet_link_list); 503 504 id_list = calloc(count, sizeof(sysarg_t)); 505 if (id_list == NULL) { 506 fibril_mutex_unlock(&inet_discovery_lock); 507 return ENOMEM; 508 } 509 510 i = 0; 511 list_foreach(inet_link_list, link_list, inet_link_t, ilink) { 512 id_list[i++] = ilink->svc_id; 513 log_msg(LOG_DEFAULT, LVL_NOTE, "add link to list"); 514 } 515 516 fibril_mutex_unlock(&inet_discovery_lock); 517 518 log_msg(LOG_DEFAULT, LVL_NOTE, "return %zu links", count); 519 *rid_list = id_list; 520 *rcount = count; 521 522 return EOK; 523 } 524 495 525 /** @} 496 526 */ -
uspace/srv/net/inetsrv/inet_link.h
r695b6ff rb8b1adb1 47 47 uint8_t, uint8_t, int); 48 48 extern inet_link_t *inet_link_get_by_id(sysarg_t); 49 extern int inet_link_get_id_list(sysarg_t **, size_t *); 49 50 50 51 #endif -
uspace/srv/net/inetsrv/inetcfg.c
r695b6ff rb8b1adb1 44 44 #include <str.h> 45 45 #include <sys/types.h> 46 #include <types/inetcfg.h> 46 47 47 48 #include "addrobj.h" … … 151 152 static int inetcfg_get_link_list(sysarg_t **addrs, size_t *count) 152 153 { 153 return ENOTSUP;154 return inet_link_get_id_list(addrs, count); 154 155 } 155 156 … … 170 171 linfo->name = str_dup(ilink->svc_name); 171 172 linfo->def_mtu = ilink->def_mtu; 173 if (ilink->mac_valid) { 174 addr48(ilink->mac, linfo->mac_addr); 175 } else { 176 memset(linfo->mac_addr, 0, sizeof(linfo->mac_addr)); 177 } 178 172 179 return EOK; 173 180 } … … 411 418 { 412 419 ipc_callid_t rcallid; 420 size_t count; 413 421 size_t max_size; 414 422 size_t act_size; … … 417 425 int rc; 418 426 419 log_msg(LOG_DEFAULT, LVL_DEBUG, "inetcfg_get_ link_list_srv()");427 log_msg(LOG_DEFAULT, LVL_DEBUG, "inetcfg_get_addr_list_srv()"); 420 428 421 429 if (!async_data_read_receive(&rcallid, &max_size)) { … … 425 433 } 426 434 427 rc = inetcfg_get_link_list(&id_buf, & act_size);435 rc = inetcfg_get_link_list(&id_buf, &count); 428 436 if (rc != EOK) { 429 437 async_answer_0(rcallid, rc); … … 432 440 } 433 441 442 act_size = count * sizeof(sysarg_t); 434 443 size = min(act_size, max_size); 435 444 … … 476 485 static void inetcfg_link_get_srv(ipc_callid_t callid, ipc_call_t *call) 477 486 { 478 ipc_callid_t rcallid; 479 size_t max_size; 487 ipc_callid_t name_callid; 488 ipc_callid_t laddr_callid; 489 size_t name_max_size; 490 size_t laddr_max_size; 480 491 481 492 sysarg_t link_id; … … 488 499 linfo.name = NULL; 489 500 490 if (!async_data_read_receive(&rcallid, &max_size)) { 491 async_answer_0(rcallid, EREFUSED); 501 if (!async_data_read_receive(&name_callid, &name_max_size)) { 502 async_answer_0(name_callid, EREFUSED); 503 async_answer_0(callid, EREFUSED); 504 return; 505 } 506 507 if (!async_data_read_receive(&laddr_callid, &laddr_max_size)) { 508 async_answer_0(name_callid, EREFUSED); 492 509 async_answer_0(callid, EREFUSED); 493 510 return; … … 496 513 rc = inetcfg_link_get(link_id, &linfo); 497 514 if (rc != EOK) { 498 async_answer_0(rcallid, rc); 499 async_answer_0(callid, rc); 500 return; 501 } 502 503 sysarg_t retval = async_data_read_finalize(rcallid, linfo.name, 504 min(max_size, str_size(linfo.name))); 515 async_answer_0(laddr_callid, rc); 516 async_answer_0(name_callid, rc); 517 async_answer_0(callid, rc); 518 return; 519 } 520 521 sysarg_t retval = async_data_read_finalize(name_callid, linfo.name, 522 min(name_max_size, str_size(linfo.name))); 523 if (retval != EOK) { 524 free(linfo.name); 525 async_answer_0(laddr_callid, retval); 526 async_answer_0(callid, retval); 527 return; 528 } 529 530 retval = async_data_read_finalize(laddr_callid, &linfo.mac_addr, 531 min(laddr_max_size, sizeof(linfo.mac_addr))); 532 505 533 free(linfo.name); 506 534 -
uspace/srv/net/inetsrv/inetsrv.h
r695b6ff rb8b1adb1 44 44 #include <ipc/loc.h> 45 45 #include <sys/types.h> 46 #include <types/inet.h> 46 47 #include <async.h> 47 48 … … 73 74 } inetping6_client_t; 74 75 75 /** Address object info */76 typedef struct {77 /** Network address */78 inet_naddr_t naddr;79 /** Link service ID */80 sysarg_t ilink;81 /** Address object name */82 char *name;83 } inet_addr_info_t;84 85 /** IP link info */86 typedef struct {87 /** Link service name */88 char *name;89 /** Default MTU */90 size_t def_mtu;91 } inet_link_info_t;92 93 /** Static route info */94 typedef struct {95 /** Destination network address */96 inet_naddr_t dest;97 /** Router address */98 inet_addr_t router;99 /** Static route name */100 char *name;101 } inet_sroute_info_t;102 103 76 typedef struct { 104 77 /** Source address */ … … 125 98 size_t size; 126 99 } inet_packet_t; 127 128 typedef struct {129 service_id_t iplink;130 inet_addr_t src;131 inet_addr_t dest;132 uint8_t tos;133 void *data;134 size_t size;135 } inet_dgram_t;136 100 137 101 typedef struct {
Note:
See TracChangeset
for help on using the changeset viewer.