* ----------------------------------*/
int copy_tcp_connection(
tcp_connection_t * p_dest_connection,
- tcp_connection_t * p_source_connection
+ const tcp_connection_t * p_source_connection
)
{
if ( !p_dest_connection || !p_source_connection )
p_monitor1 = (tcp_port_monitor_t *)p_data1;
p_monitor2 = (tcp_port_monitor_t *)p_data2;
- return (p_monitor1->port_range_begin == p_monitor1->port_range_begin &&
- p_monitor2->port_range_end == p_monitor2->port_range_end);
+ return (p_monitor1->port_range_begin == p_monitor2->port_range_begin &&
+ p_monitor1->port_range_end == p_monitor2->port_range_end);
}
/* ---------------------------------------------------------------------------
#ifdef HASH_DEBUG
fprintf(stderr,"--- num vacated is %d, vacated factor is %.3f\n", p_monitor->hash.vacated, vacated_load );
#endif
- if ( vacated_load <= TCP_CONNECIION_HASH_MAX_VACATED_RATIO )
+ if ( vacated_load <= TCP_CONNECTION_HASH_MAX_VACATED_RATIO )
{
/* hash is fine and needs no rebalancing */
return;
/* it's already in the hash. reset the age of the connection. */
if ( p_connection != NULL )
{
- p_connection->age = TCP_CONNECIION_STARTING_AGE;
+ p_connection->age = TCP_CONNECTION_STARTING_AGE;
}
return;
return;
}
- p_node->connection.age = TCP_CONNECIION_STARTING_AGE;
+ p_node->connection.age = TCP_CONNECTION_STARTING_AGE;
p_node->p_next = NULL;
/* insert it into the monitor's hash table */
The requested monitor value is copied into a client-supplied char buffer.
Returns 0 on success, -1 otherwise. */
int peek_tcp_port_monitor(
- tcp_port_monitor_t * p_monitor,
+ const tcp_port_monitor_t * p_monitor,
int item,
int connection_index,
char * p_buffer,
/* read all tcp connections */
while (fgets (buf, sizeof (buf), fp) != NULL) {
- if ( sscanf (buf, "%*d: %lx:%lx %lx:%lx %lx %*x:%*x %*x:%*x %*x %lu %*d %lu",
- (unsigned long *)&conn.local_addr, (unsigned long *)&conn.local_port,
- (unsigned long *)&conn.remote_addr, (unsigned long *)&conn.remote_port,
+ if ( sscanf (buf, "%*d: %lx:%hx %lx:%hx %lx %*x:%*x %*x:%*x %*x %lu %*d %lu",
+ (unsigned long *)&conn.local_addr, &conn.local_port,
+ (unsigned long *)&conn.remote_addr, &conn.remote_port,
(unsigned long *)&state, (unsigned long *)&uid, (unsigned long *)&inode) != 7 )
fprintf( stderr, "/proc/net/tcp: bad file format\n" );
/* Clients need a way to find monitors */
tcp_port_monitor_t * find_tcp_port_monitor(
- tcp_port_monitor_collection_t * p_collection,
+ const tcp_port_monitor_collection_t * p_collection,
in_port_t port_range_begin,
in_port_t port_range_end
)