scan ports as short. debian bug# 359974
[monky] / src / libtcp-portmon.c
index 33e5ee6..5881cc9 100644 (file)
@@ -37,7 +37,7 @@
  * ----------------------------------*/
 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 )
@@ -231,8 +231,8 @@ int monitor_match_function( const void *p_data1, const void *p_data2 )
    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);
 }
 
 /* ---------------------------------------------------------------------------
@@ -350,7 +350,7 @@ void maintain_tcp_port_monitor_hash(
 #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;
@@ -437,7 +437,7 @@ void show_connection_to_tcp_port_monitor(
                /* 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;
@@ -468,7 +468,7 @@ void show_connection_to_tcp_port_monitor(
                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 */
@@ -621,7 +621,7 @@ tcp_port_monitor_t * create_tcp_port_monitor(
    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,
@@ -816,9 +816,9 @@ void update_tcp_port_monitor_collection(
         /* 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" );
@@ -902,7 +902,7 @@ int insert_tcp_port_monitor_into_collection(
 
 /* 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
        )