Loading Makefile +4 −4 Original line number Diff line number Diff line Loading @@ -8,8 +8,8 @@ SYS := $(shell gcc -dumpmachine) # works on the bajillion of different Linux environments ifneq (, $(findstring linux, $(SYS))) LIBS = -lpcap -lm -lrt -ldl -lpthread INCLUDES = -I. FLAGS2 = -fno-omit-frame-pointer -rdynamic INCLUDES = FLAGS2 = -rdynamic endif # MAC OS X Loading @@ -29,7 +29,7 @@ endif # to then fix all the errors, so this kinda works now. It's not the # intended environment, so it make break in the future. ifneq (, $(findstring mingw, $(SYS))) INCLUDES = -I. -Ivs10/include INCLUDES = -Ivs10/include LIBS = -L vs10/lib -lwpcap -lIPHLPAPI -lWs2_32 FLAGS2 = -march=i686 endif Loading Loading @@ -62,7 +62,7 @@ endif CC = gcc DEFINES = CFLAGS = -g -ggdb $(FLAGS2) $(INCLUDES) $(DEFINES) -Wall -O3 -Wno-format CFLAGS = -g -ggdb $(FLAGS2) $(INCLUDES) $(DEFINES) -Wall -O3 .SUFFIXES: .c .cpp all: bin/masscan Loading src/crypto-base64.c +1 −1 Original line number Diff line number Diff line Loading @@ -186,7 +186,7 @@ base64_selftest(void) size_t buf2_len; size_t buf3_len; unsigned i; unsigned seed = time(0); unsigned seed = (unsigned)time(0); buf_len = base64_encode(buf, sizeof(buf), "hello", 5); buf2_len = base64_decode(buf2, sizeof(buf2), buf, buf_len); Loading src/event-timeout.c +27 −1 Original line number Diff line number Diff line Loading @@ -33,6 +33,12 @@ /*************************************************************************** * The timeout system is a circular ring. We move an index around the * ring. At each slot in the ring is a linked-list of all entries at * that time index. Because the ring can wrap, not everything at a given * entry will be the same timestamp. Therefore, when doing the timeout * logic at a slot, we have to doublecheck the actual timestamp, and skip * those things that are further in the future. ***************************************************************************/ struct Timeouts { /** Loading Loading @@ -60,19 +66,38 @@ timeouts_create(uint64_t timestamp) { struct Timeouts *timeouts; /* * Allocate memory and initialize it to zero */ timeouts = (struct Timeouts *)malloc(sizeof(*timeouts)); if (timeouts == NULL) exit(1); memset(timeouts, 0, sizeof(*timeouts)); /* * We just mask off the low order bits to determine wrap. I'm using * a variable here because one of these days I'm going to make * the size of the ring dynamically adjustable depending upon * the speed of the scan. */ timeouts->mask = sizeof(timeouts->slots)/sizeof(timeouts->slots[0]) - 1; /* * Set the index to the current time. Note that this timestamp is * the 'time_t' value multiplied by the number of ticks-per-second, * where 'ticks' is something I've defined for scanning. Right now * I hard-code in the size of the ticks, but eventually they'll be * dynamically resized depending upon the speed of the scan. */ timeouts->current_index = timestamp; return timeouts; } /*************************************************************************** * This inserts the timeout entry into the appropriate place in the * timeout ring. ***************************************************************************/ void timeouts_add(struct Timeouts *timeouts, struct TimeoutEntry *entry, Loading @@ -84,7 +109,8 @@ timeouts_add(struct Timeouts *timeouts, struct TimeoutEntry *entry, timeout_unlink(entry); if (entry->prev) { LOG(1, "***CHANGE %d-seconds\n", (int)((timestamp-entry->timestamp)/16384ULL)); LOG(1, "***CHANGE %d-seconds\n", (int)((timestamp-entry->timestamp)/TICKS_PER_SECOND)); } /* Initialize the new entry */ Loading src/event-timeout.h +50 −5 Original line number Diff line number Diff line Loading @@ -9,6 +9,9 @@ #endif struct Timeouts; /*************************************************************************** ***************************************************************************/ struct TimeoutEntry { Loading Loading @@ -55,13 +58,55 @@ timeout_init(struct TimeoutEntry *entry) entry->prev = 0; } /** * Create a timeout subsystem. * @param timestamp_now * The current timestamp indicating "now" when the thing starts. * This should be 'time(0) * TICKS_PER_SECOND'. */ struct Timeouts * timeouts_create(uint64_t timestamp_now); struct Timeouts *timeouts_create(uint64_t timestamp); void timeouts_add(struct Timeouts *timeouts, struct TimeoutEntry *entry, size_t offset, uint64_t timestamp); /** * Insert the timeout 'entry' into the future location in the timeout * ring, as determined by the timestamp. * @param timeouts * A ring of timeouts, with each slot corresponding to a specific * time in the future. * @param entry * The entry that we are going to insert into the ring. If it's * already in the ring, it'll be removed from the old location * first before inserting into the new location. * @param offset * The 'entry' field above is part of an existing structure. This * tells the offset_of() from the begining of that structure. * In other words, this tells us the pointer to the object that * that is the subject of the timeout. * @param timestamp_expires * When this timeout will expire. This is in terms of internal * ticks, which in units of TICKS_PER_SECOND. */ void timeouts_add(struct Timeouts *timeouts, struct TimeoutEntry *entry, size_t offset, uint64_t timestamp_expires); void *timeouts_remove(struct Timeouts *timeouts, uint64_t timestamp); /** * Remove an object from the timestamp system that is older than than * the specified timestamp. This function must be called repeatedly * until it returns NULL to remove all the objects that are older * than the given timestamp. * @param timeouts * A ring of timeouts. We'll walk the ring until we've caught * up with the current time. * @param timestamp_now * Usually, this timestmap will be "now", the current time, * and anything older than this will be aged out. * @return * an object older than the specified timestamp, or NULL * if there are no more objects to be found */ void * timeouts_remove(struct Timeouts *timeouts, uint64_t timestamp_now); /* * This macros convert a normal "timeval" structure into the timestamp Loading src/in-binary.c +1 −1 Original line number Diff line number Diff line Loading @@ -239,7 +239,7 @@ parse_file(struct Output *out, const char *filename) } total_records++; if ((total_records & 0xFFFF) == 0) fprintf(stderr, "%s: %8llu\r", filename, total_records); fprintf(stderr, "%s: %8" PRIu64 "\r", filename, total_records); } end: Loading Loading
Makefile +4 −4 Original line number Diff line number Diff line Loading @@ -8,8 +8,8 @@ SYS := $(shell gcc -dumpmachine) # works on the bajillion of different Linux environments ifneq (, $(findstring linux, $(SYS))) LIBS = -lpcap -lm -lrt -ldl -lpthread INCLUDES = -I. FLAGS2 = -fno-omit-frame-pointer -rdynamic INCLUDES = FLAGS2 = -rdynamic endif # MAC OS X Loading @@ -29,7 +29,7 @@ endif # to then fix all the errors, so this kinda works now. It's not the # intended environment, so it make break in the future. ifneq (, $(findstring mingw, $(SYS))) INCLUDES = -I. -Ivs10/include INCLUDES = -Ivs10/include LIBS = -L vs10/lib -lwpcap -lIPHLPAPI -lWs2_32 FLAGS2 = -march=i686 endif Loading Loading @@ -62,7 +62,7 @@ endif CC = gcc DEFINES = CFLAGS = -g -ggdb $(FLAGS2) $(INCLUDES) $(DEFINES) -Wall -O3 -Wno-format CFLAGS = -g -ggdb $(FLAGS2) $(INCLUDES) $(DEFINES) -Wall -O3 .SUFFIXES: .c .cpp all: bin/masscan Loading
src/crypto-base64.c +1 −1 Original line number Diff line number Diff line Loading @@ -186,7 +186,7 @@ base64_selftest(void) size_t buf2_len; size_t buf3_len; unsigned i; unsigned seed = time(0); unsigned seed = (unsigned)time(0); buf_len = base64_encode(buf, sizeof(buf), "hello", 5); buf2_len = base64_decode(buf2, sizeof(buf2), buf, buf_len); Loading
src/event-timeout.c +27 −1 Original line number Diff line number Diff line Loading @@ -33,6 +33,12 @@ /*************************************************************************** * The timeout system is a circular ring. We move an index around the * ring. At each slot in the ring is a linked-list of all entries at * that time index. Because the ring can wrap, not everything at a given * entry will be the same timestamp. Therefore, when doing the timeout * logic at a slot, we have to doublecheck the actual timestamp, and skip * those things that are further in the future. ***************************************************************************/ struct Timeouts { /** Loading Loading @@ -60,19 +66,38 @@ timeouts_create(uint64_t timestamp) { struct Timeouts *timeouts; /* * Allocate memory and initialize it to zero */ timeouts = (struct Timeouts *)malloc(sizeof(*timeouts)); if (timeouts == NULL) exit(1); memset(timeouts, 0, sizeof(*timeouts)); /* * We just mask off the low order bits to determine wrap. I'm using * a variable here because one of these days I'm going to make * the size of the ring dynamically adjustable depending upon * the speed of the scan. */ timeouts->mask = sizeof(timeouts->slots)/sizeof(timeouts->slots[0]) - 1; /* * Set the index to the current time. Note that this timestamp is * the 'time_t' value multiplied by the number of ticks-per-second, * where 'ticks' is something I've defined for scanning. Right now * I hard-code in the size of the ticks, but eventually they'll be * dynamically resized depending upon the speed of the scan. */ timeouts->current_index = timestamp; return timeouts; } /*************************************************************************** * This inserts the timeout entry into the appropriate place in the * timeout ring. ***************************************************************************/ void timeouts_add(struct Timeouts *timeouts, struct TimeoutEntry *entry, Loading @@ -84,7 +109,8 @@ timeouts_add(struct Timeouts *timeouts, struct TimeoutEntry *entry, timeout_unlink(entry); if (entry->prev) { LOG(1, "***CHANGE %d-seconds\n", (int)((timestamp-entry->timestamp)/16384ULL)); LOG(1, "***CHANGE %d-seconds\n", (int)((timestamp-entry->timestamp)/TICKS_PER_SECOND)); } /* Initialize the new entry */ Loading
src/event-timeout.h +50 −5 Original line number Diff line number Diff line Loading @@ -9,6 +9,9 @@ #endif struct Timeouts; /*************************************************************************** ***************************************************************************/ struct TimeoutEntry { Loading Loading @@ -55,13 +58,55 @@ timeout_init(struct TimeoutEntry *entry) entry->prev = 0; } /** * Create a timeout subsystem. * @param timestamp_now * The current timestamp indicating "now" when the thing starts. * This should be 'time(0) * TICKS_PER_SECOND'. */ struct Timeouts * timeouts_create(uint64_t timestamp_now); struct Timeouts *timeouts_create(uint64_t timestamp); void timeouts_add(struct Timeouts *timeouts, struct TimeoutEntry *entry, size_t offset, uint64_t timestamp); /** * Insert the timeout 'entry' into the future location in the timeout * ring, as determined by the timestamp. * @param timeouts * A ring of timeouts, with each slot corresponding to a specific * time in the future. * @param entry * The entry that we are going to insert into the ring. If it's * already in the ring, it'll be removed from the old location * first before inserting into the new location. * @param offset * The 'entry' field above is part of an existing structure. This * tells the offset_of() from the begining of that structure. * In other words, this tells us the pointer to the object that * that is the subject of the timeout. * @param timestamp_expires * When this timeout will expire. This is in terms of internal * ticks, which in units of TICKS_PER_SECOND. */ void timeouts_add(struct Timeouts *timeouts, struct TimeoutEntry *entry, size_t offset, uint64_t timestamp_expires); void *timeouts_remove(struct Timeouts *timeouts, uint64_t timestamp); /** * Remove an object from the timestamp system that is older than than * the specified timestamp. This function must be called repeatedly * until it returns NULL to remove all the objects that are older * than the given timestamp. * @param timeouts * A ring of timeouts. We'll walk the ring until we've caught * up with the current time. * @param timestamp_now * Usually, this timestmap will be "now", the current time, * and anything older than this will be aged out. * @return * an object older than the specified timestamp, or NULL * if there are no more objects to be found */ void * timeouts_remove(struct Timeouts *timeouts, uint64_t timestamp_now); /* * This macros convert a normal "timeval" structure into the timestamp Loading
src/in-binary.c +1 −1 Original line number Diff line number Diff line Loading @@ -239,7 +239,7 @@ parse_file(struct Output *out, const char *filename) } total_records++; if ((total_records & 0xFFFF) == 0) fprintf(stderr, "%s: %8llu\r", filename, total_records); fprintf(stderr, "%s: %8" PRIu64 "\r", filename, total_records); } end: Loading