Add net_listen_address function to lookup bind address of a listen socket
This commit is contained in:
		
							parent
							
								
									fbaa233617
								
							
						
					
					
						commit
						f6f395d68e
					
				@ -1,5 +1,7 @@
 | 
			
		||||
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
 | 
			
		||||
 | 
			
		||||
        * [SIGAR-46] Fix cpu_info.{mhz,cache_size} fields in UML vms
 | 
			
		||||
 | 
			
		||||
@ -686,6 +686,10 @@ sigar_net_stat_port_get(sigar_t *sigar,
 | 
			
		||||
                        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_state_get(int state);
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										27
									
								
								src/sigar.c
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								src/sigar.c
									
									
									
									
									
								
							@ -859,6 +859,33 @@ static void sigar_net_listen_address_add(sigar_t *sigar,
 | 
			
		||||
           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 {
 | 
			
		||||
    sigar_net_stat_t *netstat;
 | 
			
		||||
    sigar_net_connection_list_t *connlist;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user