Commit c8127a29 authored by Robert David Graham's avatar Robert David Graham
Browse files

low traffic timeouts

parent 8746c788
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
    code and causing the bug to come back again.
*/
#include "event-timeout.h"
#include "logger.h"
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
@@ -78,13 +79,14 @@ timeouts_add(struct Timeouts *timeouts, struct TimeoutEntry *entry,
             size_t offset, uint64_t timestamp)
{
    unsigned index;
    //time_t now = time(0);
    //time_t time_future = (unsigned)(timestamp/16384ULL);

    /* Unlink from wherever the entry came from */
    timeout_unlink(entry);

//printf("++ADD %d.%03u\n", time_future-now, (unsigned)(((timestamp%16384ULL)/16384.0)*1000.0));
    if (entry->prev) {
        LOG(1, "***CHANGE %d-seconds\n", (int)((timestamp-entry->timestamp)/16384ULL));
    }

    /* Initialize the new entry */    
    entry->timestamp = timestamp;
    entry->offset = (unsigned)offset;
@@ -96,10 +98,10 @@ timeouts_add(struct Timeouts *timeouts, struct TimeoutEntry *entry,
    entry->prev = &timeouts->slots[index];
    if (entry->next)
        entry->next->prev = &entry->next;
//printf("++PREV=0x%llx\n", entry->prev);
}

/***************************************************************************
 * Remove the next event that it older than the specified timestamp
 ***************************************************************************/
void *
timeouts_remove(struct Timeouts *timeouts, uint64_t timestamp)
@@ -112,7 +114,7 @@ timeouts_remove(struct Timeouts *timeouts, uint64_t timestamp)
        /* Start at the current slot */
        entry = timeouts->slots[timeouts->current_index & timeouts->mask];

        /* enumerate throug the linked list until we find one */
        /* enumerate through the linked list until we find a used slot */
        while (entry && entry->timestamp > timestamp)
            entry = entry->next;
        if (entry)
+1 −1
Original line number Diff line number Diff line
@@ -44,7 +44,6 @@ timeout_unlink(struct TimeoutEntry *entry)
    entry->next = 0;
    entry->prev = 0;
    entry->timestamp = 0;
//printf("--PREV=0x%llx\n", entry->prev);
}

/***************************************************************************
@@ -69,6 +68,7 @@ void *timeouts_remove(struct Timeouts *timeouts, uint64_t timestamp);
 * that we use for timeouts. The timeval structure probably will come
 * from the packets that we are capturing.
 */
#define TICKS_PER_SECOND (16384ULL)
#define TICKS_FROM_SECS(secs) ((secs)*16384ULL)
#define TICKS_FROM_USECS(usecs) ((usecs)/16384ULL)
#define TICKS_FROM_TV(secs,usecs) (TICKS_FROM_SECS(secs)+TICKS_FROM_USECS(usecs))
+2 −1
Original line number Diff line number Diff line
@@ -123,6 +123,7 @@ status_print(
        syn_rate = (1.0*current_syns)/elapsed_time;
    }


    /*
     * Print the message to <stderr> so that <stdout> can be redirected
     * to a file (<stdout> reports what systems were found).
@@ -136,7 +137,7 @@ status_print(
                        tcb_rate,
                        global_tcb_count
                        );
    } else {
    } else if (rate > 0) {
        fprintf(stderr, 
                "rate:%6.2f-kpps, %5.2f%% done,%4u:%02u:%02u remaining, %llu-tcbs, rr=%.0f       \r",
                        x/1000.0,
+7 −2
Original line number Diff line number Diff line
@@ -603,7 +603,7 @@ receive_thread(void *v)
        unsigned cookie;

        /*
         * RECIEVE
         * RECEIVE
         *
         * This is the boring part of actually receiving a packet
         */
@@ -614,8 +614,11 @@ receive_thread(void *v)
                    &usecs,
                    &px);
        
        if (err != 0)
        if (err != 0) {
            if (tcpcon)
                tcpcon_timeouts(tcpcon, (unsigned)time(0), 0);
            continue;
        }
        

        /*
@@ -928,6 +931,8 @@ main_scan(struct Masscan *masscan)
    struct Status status;
    uint64_t min_index = UINT64_MAX;

    memset(parms_array, 0, sizeof(parms_array));

    /*
     * Initialize the task size
     */
+1 −2
Original line number Diff line number Diff line
@@ -618,8 +618,7 @@ output_report_status(struct Output *out, time_t timestamp, int status,
    if (out->is_interactive) {
        unsigned count;
        
        count = fprintf(stdout, "Discovered %s port %u/%s on %u.%u.%u.%u"
                    "                               \n",
        count = fprintf(stdout, "Discovered %s port %u/%s on %u.%u.%u.%u",
                    status_string(status),
                    port,
                    proto_from_status(status),
Loading