Add net_listen_address function to lookup bind address of a listen socket

This commit is contained in:
Doug MacEachern 2007-04-06 12:50:05 +00:00
parent fbaa233617
commit f6f395d68e
3 changed files with 33 additions and 0 deletions

View File

@ -1,5 +1,7 @@
2007-04-05 Doug MacEachern <dougm@hyperic.com> 2007-04-05 Doug MacEachern <dougm@hyperic.com>
* Add net_listen_address function to lookup bind address of a listen socket
* Add net_stat_port function to provide metrics on specific port+address * Add net_stat_port function to provide metrics on specific port+address
* [SIGAR-46] Fix cpu_info.{mhz,cache_size} fields in UML vms * [SIGAR-46] Fix cpu_info.{mhz,cache_size} fields in UML vms

View File

@ -686,6 +686,10 @@ sigar_net_stat_port_get(sigar_t *sigar,
unsigned long port); unsigned long port);
SIGAR_DECLARE(int)sigar_net_listen_address_get(sigar_t *sigar,
unsigned long port,
sigar_net_address_t *address);
SIGAR_DECLARE(const char *)sigar_net_connection_type_get(int type); SIGAR_DECLARE(const char *)sigar_net_connection_type_get(int type);
SIGAR_DECLARE(const char *)sigar_net_connection_state_get(int state); SIGAR_DECLARE(const char *)sigar_net_connection_state_get(int state);

View File

@ -859,6 +859,33 @@ static void sigar_net_listen_address_add(sigar_t *sigar,
sizeof(conn->local_address)); sizeof(conn->local_address));
} }
SIGAR_DECLARE(int)sigar_net_listen_address_get(sigar_t *sigar,
unsigned long port,
sigar_net_address_t *address)
{
if (!sigar->net_listen ||
sigar_cache_find(sigar->net_listen, port))
{
sigar_net_stat_t netstat;
int status =
sigar_net_stat_get(sigar, &netstat,
SIGAR_NETCONN_SERVER|SIGAR_NETCONN_TCP);
if (status != SIGAR_OK) {
return status;
}
}
if (sigar_cache_find(sigar->net_listen, port)) {
void *value = sigar_cache_get(sigar->net_listen, port)->value;
memcpy(address, value, sizeof(*address));
return SIGAR_OK;
}
else {
return ENOENT;
}
}
typedef struct { typedef struct {
sigar_net_stat_t *netstat; sigar_net_stat_t *netstat;
sigar_net_connection_list_t *connlist; sigar_net_connection_list_t *connlist;