Loading src/event-timeout.c +5 −5 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ struct Timeouts { unsigned mask; struct TimeoutEntry *freed_list; struct TimeoutEntry *entries[1024*8*16]; struct TimeoutEntry *slots[1024*1024]; }; /*************************************************************************** Loading @@ -47,7 +47,7 @@ timeouts_create(uint64_t timestamp) timeouts = (struct Timeouts *)malloc(sizeof(*timeouts)); memset(timeouts, 0, sizeof(*timeouts)); timeouts->mask = sizeof(timeouts->entries)/sizeof(timeouts->entries[0]) - 1; timeouts->mask = sizeof(timeouts->slots)/sizeof(timeouts->slots[0]) - 1; timeouts->current_index = timestamp; Loading @@ -72,8 +72,8 @@ timeouts_add(struct Timeouts *timeouts, void *p, uint64_t timestamp, unsigned co entry->timestamp = timestamp; entry->pointer = p; entry->counter = counter; entry->next = timeouts->entries[index]; timeouts->entries[index] = entry; entry->next = timeouts->slots[index]; timeouts->slots[index] = entry; return &entry->counter; } Loading @@ -85,7 +85,7 @@ timeouts_remove(struct Timeouts *timeouts, uint64_t timestamp) struct TimeoutEvent result; while (timeouts->current_index <= timestamp) { struct TimeoutEntry **r_entry = &timeouts->entries[timeouts->current_index & timeouts->mask]; struct TimeoutEntry **r_entry = &timeouts->slots[timeouts->current_index & timeouts->mask]; while (*r_entry && (*r_entry)->timestamp > timestamp) r_entry = &(*r_entry)->next; Loading src/event-timeout.h +2 −2 Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ struct Timeouts *timeouts_create(uint64_t timestamp); unsigned *timeouts_add(struct Timeouts *timeouts, void *p, uint64_t timestamp, unsigned counter); struct TimeoutEvent timeouts_remove(struct Timeouts *timeouts, uint64_t timestamp); #define TICKS_FROM_SECS(secs) ((secs)*1000ULL) #define TICKS_FROM_USECS(usecs) ((usecs)/1000ULL) #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)) #endif src/main-status.c +12 −1 Original line number Diff line number Diff line Loading @@ -80,6 +80,17 @@ status_print(struct Status *status, uint64_t count, uint64_t max_count) double rate = ((double)(count - status->last.count)*1.0/elapsed); double percent_done = (double)(count*100.0/max_count); double finished = 0; status->last_rates[status->last_count++ & 0x7] = rate; rate = status->last_rates[0] + status->last_rates[1] + status->last_rates[2] + status->last_rates[3] + status->last_rates[4] + status->last_rates[5] + status->last_rates[6] + status->last_rates[7] ; rate /= 8; if (rate) finished = (1.0 - percent_done/100.0) * (max_count / rate); /* (%u-days %02u:%02u:%02u remaining) */ Loading src/main-status.h +3 −0 Original line number Diff line number Diff line Loading @@ -12,6 +12,9 @@ struct Status } last; uint64_t timer; unsigned charcount; double last_rates[8]; unsigned last_count; }; Loading src/main.c +11 −10 Original line number Diff line number Diff line Loading @@ -515,33 +515,34 @@ receive_thread(struct Masscan *masscan, seqno_me, seqno_them+1); } tcpcon_handle(tcpcon, tcb, TCP_WHAT_SYNACK, 0, 0, secs, usecs); tcpcon_handle(tcpcon, tcb, TCP_WHAT_SYNACK, 0, 0, secs, usecs, seqno_them+1); } else if (tcb) { /* If this is an ACK, then handle that first */ if (TCP_IS_ACK(px, parsed.transport_offset)) { tcpcon_handle(tcpcon, tcb, TCP_WHAT_ACK, 0, seqno_me, secs, usecs); tcpcon_handle(tcpcon, tcb, TCP_WHAT_ACK, 0, seqno_me, secs, usecs, seqno_them); } /* If this contains payload, handle that */ if (parsed.app_length) { tcpcon_handle(tcpcon, tcb, TCP_WHAT_DATA, px + parsed.app_offset, parsed.app_length, secs, usecs); secs, usecs, seqno_them); } /* If this is a FIN, handle that. Note that ACK + payload + FIN * can come together */ /* If this is a FIN, handle that. Note that ACK + * payload + FIN can come together */ if (TCP_IS_FIN(px, parsed.transport_offset)) { tcpcon_handle(tcpcon, tcb, TCP_WHAT_FIN, 0, seqno_them, secs, usecs); tcpcon_handle(tcpcon, tcb, TCP_WHAT_FIN, 0, 0, secs, usecs, seqno_them); } /* If this is a RST, then we'll be closing the connection */ if (TCP_IS_RST(px, parsed.transport_offset)) { tcpcon_handle(tcpcon, tcb, TCP_WHAT_RST, 0, 0, secs, usecs); tcpcon_handle(tcpcon, tcb, TCP_WHAT_RST, 0, 0, secs, usecs, seqno_them); } } else if (TCP_IS_FIN(px, parsed.transport_offset)) { /* Loading Loading
src/event-timeout.c +5 −5 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ struct Timeouts { unsigned mask; struct TimeoutEntry *freed_list; struct TimeoutEntry *entries[1024*8*16]; struct TimeoutEntry *slots[1024*1024]; }; /*************************************************************************** Loading @@ -47,7 +47,7 @@ timeouts_create(uint64_t timestamp) timeouts = (struct Timeouts *)malloc(sizeof(*timeouts)); memset(timeouts, 0, sizeof(*timeouts)); timeouts->mask = sizeof(timeouts->entries)/sizeof(timeouts->entries[0]) - 1; timeouts->mask = sizeof(timeouts->slots)/sizeof(timeouts->slots[0]) - 1; timeouts->current_index = timestamp; Loading @@ -72,8 +72,8 @@ timeouts_add(struct Timeouts *timeouts, void *p, uint64_t timestamp, unsigned co entry->timestamp = timestamp; entry->pointer = p; entry->counter = counter; entry->next = timeouts->entries[index]; timeouts->entries[index] = entry; entry->next = timeouts->slots[index]; timeouts->slots[index] = entry; return &entry->counter; } Loading @@ -85,7 +85,7 @@ timeouts_remove(struct Timeouts *timeouts, uint64_t timestamp) struct TimeoutEvent result; while (timeouts->current_index <= timestamp) { struct TimeoutEntry **r_entry = &timeouts->entries[timeouts->current_index & timeouts->mask]; struct TimeoutEntry **r_entry = &timeouts->slots[timeouts->current_index & timeouts->mask]; while (*r_entry && (*r_entry)->timestamp > timestamp) r_entry = &(*r_entry)->next; Loading
src/event-timeout.h +2 −2 Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ struct Timeouts *timeouts_create(uint64_t timestamp); unsigned *timeouts_add(struct Timeouts *timeouts, void *p, uint64_t timestamp, unsigned counter); struct TimeoutEvent timeouts_remove(struct Timeouts *timeouts, uint64_t timestamp); #define TICKS_FROM_SECS(secs) ((secs)*1000ULL) #define TICKS_FROM_USECS(usecs) ((usecs)/1000ULL) #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)) #endif
src/main-status.c +12 −1 Original line number Diff line number Diff line Loading @@ -80,6 +80,17 @@ status_print(struct Status *status, uint64_t count, uint64_t max_count) double rate = ((double)(count - status->last.count)*1.0/elapsed); double percent_done = (double)(count*100.0/max_count); double finished = 0; status->last_rates[status->last_count++ & 0x7] = rate; rate = status->last_rates[0] + status->last_rates[1] + status->last_rates[2] + status->last_rates[3] + status->last_rates[4] + status->last_rates[5] + status->last_rates[6] + status->last_rates[7] ; rate /= 8; if (rate) finished = (1.0 - percent_done/100.0) * (max_count / rate); /* (%u-days %02u:%02u:%02u remaining) */ Loading
src/main-status.h +3 −0 Original line number Diff line number Diff line Loading @@ -12,6 +12,9 @@ struct Status } last; uint64_t timer; unsigned charcount; double last_rates[8]; unsigned last_count; }; Loading
src/main.c +11 −10 Original line number Diff line number Diff line Loading @@ -515,33 +515,34 @@ receive_thread(struct Masscan *masscan, seqno_me, seqno_them+1); } tcpcon_handle(tcpcon, tcb, TCP_WHAT_SYNACK, 0, 0, secs, usecs); tcpcon_handle(tcpcon, tcb, TCP_WHAT_SYNACK, 0, 0, secs, usecs, seqno_them+1); } else if (tcb) { /* If this is an ACK, then handle that first */ if (TCP_IS_ACK(px, parsed.transport_offset)) { tcpcon_handle(tcpcon, tcb, TCP_WHAT_ACK, 0, seqno_me, secs, usecs); tcpcon_handle(tcpcon, tcb, TCP_WHAT_ACK, 0, seqno_me, secs, usecs, seqno_them); } /* If this contains payload, handle that */ if (parsed.app_length) { tcpcon_handle(tcpcon, tcb, TCP_WHAT_DATA, px + parsed.app_offset, parsed.app_length, secs, usecs); secs, usecs, seqno_them); } /* If this is a FIN, handle that. Note that ACK + payload + FIN * can come together */ /* If this is a FIN, handle that. Note that ACK + * payload + FIN can come together */ if (TCP_IS_FIN(px, parsed.transport_offset)) { tcpcon_handle(tcpcon, tcb, TCP_WHAT_FIN, 0, seqno_them, secs, usecs); tcpcon_handle(tcpcon, tcb, TCP_WHAT_FIN, 0, 0, secs, usecs, seqno_them); } /* If this is a RST, then we'll be closing the connection */ if (TCP_IS_RST(px, parsed.transport_offset)) { tcpcon_handle(tcpcon, tcb, TCP_WHAT_RST, 0, 0, secs, usecs); tcpcon_handle(tcpcon, tcb, TCP_WHAT_RST, 0, 0, secs, usecs, seqno_them); } } else if (TCP_IS_FIN(px, parsed.transport_offset)) { /* Loading