Loading Makefile +2 −2 Original line number Diff line number Diff line LIBS = -lrt -lpcap -lm LIBS = -lpcap -lm INCLUDES = -I. DEFINES = CC = gcc Loading @@ -13,7 +13,7 @@ SRC = $(wildcard src/*.c) OBJ = $(addprefix tmp/, $(notdir $(addsuffix .o, $(basename $(SRC))))) bin/masscan: $(OBJ) $(CC) $(CFLAGS) -o $@ $(OBJ) -lm $(LIBS) -lstdc++ $(CC) $(CFLAGS) -o $@ $(OBJ) $(LIBS) clean: rm tmp/*.o Loading src/pixie-threads.c +40 −31 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ #include <Windows.h> #include <process.h> #endif #if defined(__linux__) #if defined(__GNUC__) #include <unistd.h> #include <pthread.h> #endif Loading @@ -16,15 +16,24 @@ /**************************************************************************** ****************************************************************************/ size_t pixie_begin_thread(void (*worker_thread)(void*), unsigned flags, void *worker_data) pixie_begin_thread( void (*worker_thread)(void*), unsigned flags, void *worker_data) { #if defined(WIN32) && defined(_MT) UNUSEDPARM(flags); return _beginthread(worker_thread, 0, worker_data); #elif defined(__GNUC__) typedef void *(*PTHREADFUNC)(void*); pthread_t thread_id; return pthread_create(&thread_id, NULL, (PTHREADFUNC)worker_thread, worker_data); return pthread_create( &thread_id, NULL, (PTHREADFUNC)worker_thread, worker_data); #else #error pixie_begin_thread undefined #endif Loading src/pixie-timer.c +24 −4 Original line number Diff line number Diff line Loading @@ -8,6 +8,11 @@ time. In other words, if you put the system to sleep and wake it up a day later, this function should see no change, since time wasn't elapsing while the system was asleep. Reference: http://www.python.org/dev/peps/pep-0418/#monotonic-clocks http://www.brain-dump.org/blog/entry/107 */ #include "pixie-timer.h" Loading @@ -15,9 +20,6 @@ #include <stdio.h> #include <errno.h> #ifndef WIN32 #include <unistd.h> #endif #if defined(WIN32) #include <Windows.h> Loading Loading @@ -125,7 +127,9 @@ port_usleep(uint64_t waitTime) while (port_gettime() - start < waitTime) ; } #else #elif defined(CLOCK_MONOTONIC) #include <unistd.h> void port_usleep(uint64_t microseconds) { usleep(microseconds); Loading @@ -136,14 +140,30 @@ port_gettime() int x; struct timespec tv; #ifdef CLOCK_MONOTONIC_RAW x = clock_gettime(CLOCK_MONOTONIC_RAW, &tv); #else x = clock_gettime(CLOCK_MONOTONIC, &tv); #endif if (x != 0) { printf("clock_gettime() err %d\n", errno); } return tv.tv_sec * 1000000 + tv.tv_nsec/1000; } #elif defined(__MACH__) /* works for Apple */ #include <unistd.h> #include <mach/mach_time.h> void port_usleep(uint64_t microseconds) { usleep(microseconds); } uint64_t port_gettime() { return mach_absolute_time()/1000; } #endif int port_time_selftest() Loading src/rawsock-getif.c +6 −2 Original line number Diff line number Diff line Loading @@ -9,8 +9,12 @@ #include "ranges.h" /*for parsing IPv4 addresses */ #if defined(__linux__) #if defined(__APPLE__) int rawsock_get_default_interface(char *ifname, size_t sizeof_ifname) { return -1; } #elif defined(__linux__) #include <netinet/in.h> #include <net/if.h> #include <stdio.h> Loading src/rawsock-getip.c +7 −1 Original line number Diff line number Diff line Loading @@ -8,7 +8,13 @@ #include "string_s.h" #include "ranges.h" /*for parsing IPv4 addresses */ #if defined(__linux__) #if defined(__APPLE__) unsigned rawsock_get_adapter_ip(const char *ifname) { return 0; } #elif defined(__linux__) #include <unistd.h> #include <sys/types.h> #include <sys/socket.h> Loading Loading
Makefile +2 −2 Original line number Diff line number Diff line LIBS = -lrt -lpcap -lm LIBS = -lpcap -lm INCLUDES = -I. DEFINES = CC = gcc Loading @@ -13,7 +13,7 @@ SRC = $(wildcard src/*.c) OBJ = $(addprefix tmp/, $(notdir $(addsuffix .o, $(basename $(SRC))))) bin/masscan: $(OBJ) $(CC) $(CFLAGS) -o $@ $(OBJ) -lm $(LIBS) -lstdc++ $(CC) $(CFLAGS) -o $@ $(OBJ) $(LIBS) clean: rm tmp/*.o Loading
src/pixie-threads.c +40 −31 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ #include <Windows.h> #include <process.h> #endif #if defined(__linux__) #if defined(__GNUC__) #include <unistd.h> #include <pthread.h> #endif Loading @@ -16,15 +16,24 @@ /**************************************************************************** ****************************************************************************/ size_t pixie_begin_thread(void (*worker_thread)(void*), unsigned flags, void *worker_data) pixie_begin_thread( void (*worker_thread)(void*), unsigned flags, void *worker_data) { #if defined(WIN32) && defined(_MT) UNUSEDPARM(flags); return _beginthread(worker_thread, 0, worker_data); #elif defined(__GNUC__) typedef void *(*PTHREADFUNC)(void*); pthread_t thread_id; return pthread_create(&thread_id, NULL, (PTHREADFUNC)worker_thread, worker_data); return pthread_create( &thread_id, NULL, (PTHREADFUNC)worker_thread, worker_data); #else #error pixie_begin_thread undefined #endif Loading
src/pixie-timer.c +24 −4 Original line number Diff line number Diff line Loading @@ -8,6 +8,11 @@ time. In other words, if you put the system to sleep and wake it up a day later, this function should see no change, since time wasn't elapsing while the system was asleep. Reference: http://www.python.org/dev/peps/pep-0418/#monotonic-clocks http://www.brain-dump.org/blog/entry/107 */ #include "pixie-timer.h" Loading @@ -15,9 +20,6 @@ #include <stdio.h> #include <errno.h> #ifndef WIN32 #include <unistd.h> #endif #if defined(WIN32) #include <Windows.h> Loading Loading @@ -125,7 +127,9 @@ port_usleep(uint64_t waitTime) while (port_gettime() - start < waitTime) ; } #else #elif defined(CLOCK_MONOTONIC) #include <unistd.h> void port_usleep(uint64_t microseconds) { usleep(microseconds); Loading @@ -136,14 +140,30 @@ port_gettime() int x; struct timespec tv; #ifdef CLOCK_MONOTONIC_RAW x = clock_gettime(CLOCK_MONOTONIC_RAW, &tv); #else x = clock_gettime(CLOCK_MONOTONIC, &tv); #endif if (x != 0) { printf("clock_gettime() err %d\n", errno); } return tv.tv_sec * 1000000 + tv.tv_nsec/1000; } #elif defined(__MACH__) /* works for Apple */ #include <unistd.h> #include <mach/mach_time.h> void port_usleep(uint64_t microseconds) { usleep(microseconds); } uint64_t port_gettime() { return mach_absolute_time()/1000; } #endif int port_time_selftest() Loading
src/rawsock-getif.c +6 −2 Original line number Diff line number Diff line Loading @@ -9,8 +9,12 @@ #include "ranges.h" /*for parsing IPv4 addresses */ #if defined(__linux__) #if defined(__APPLE__) int rawsock_get_default_interface(char *ifname, size_t sizeof_ifname) { return -1; } #elif defined(__linux__) #include <netinet/in.h> #include <net/if.h> #include <stdio.h> Loading
src/rawsock-getip.c +7 −1 Original line number Diff line number Diff line Loading @@ -8,7 +8,13 @@ #include "string_s.h" #include "ranges.h" /*for parsing IPv4 addresses */ #if defined(__linux__) #if defined(__APPLE__) unsigned rawsock_get_adapter_ip(const char *ifname) { return 0; } #elif defined(__linux__) #include <unistd.h> #include <sys/types.h> #include <sys/socket.h> Loading