-
Notifications
You must be signed in to change notification settings - Fork 554
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
629 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
.PHONY: all | ||
all: fnettrace | ||
|
||
include ../common.mk | ||
|
||
%.o : %.c $(H_FILE_LIST) | ||
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(INCLUDE) -c $< -o $@ | ||
|
||
fnettrace: $(OBJS) | ||
$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) $(EXTRA_LDFLAGS) | ||
|
||
.PHONY: clean | ||
clean:; rm -fr *.o fnettrace *.gcov *.gcda *.gcno *.plist | ||
|
||
.PHONY: distclean | ||
distclean: clean | ||
rm -fr Makefile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#ifndef FNETTRACE_H | ||
#define FNETTRACE_H | ||
|
||
#include "../include/common.h" | ||
#include <unistd.h> | ||
#include <sys/stat.h> | ||
#include <sys/socket.h> | ||
#include <netinet/in.h> | ||
#include <time.h> | ||
#include <stdarg.h> | ||
|
||
//#define NETLOCK_INTERVAL 60 | ||
#define NETLOCK_INTERVAL 60 | ||
#define DISPLAY_INTERVAL 3 | ||
|
||
void logprintf(char* fmt, ...); | ||
|
||
static inline void ansi_topleft(int tolog) { | ||
char str[] = {0x1b, '[', '1', ';', '1', 'H', '\0'}; | ||
if (tolog) | ||
logprintf("%s", str); | ||
else | ||
printf("%s", str); | ||
fflush(0); | ||
} | ||
|
||
static inline void ansi_clrscr(int tolog) { | ||
ansi_topleft(tolog); | ||
char str[] = {0x1b, '[', '0', 'J', '\0'}; | ||
if (tolog) | ||
logprintf("%s", str); | ||
else | ||
printf("%s", str); | ||
fflush(0); | ||
} | ||
|
||
static inline void ansi_linestart(int tolog) { | ||
char str[] = {0x1b, '[', '0', 'G', '\0'}; | ||
if (tolog) | ||
logprintf("%s", str); | ||
else | ||
printf("%s", str); | ||
fflush(0); | ||
} | ||
|
||
static inline void ansi_clrline(int tolog) { | ||
ansi_linestart(tolog); | ||
char str[] = {0x1b, '[', '0', 'K', '\0'}; | ||
if (tolog) | ||
logprintf("%s", str); | ||
else | ||
printf("%s", str); | ||
fflush(0); | ||
} | ||
|
||
static inline uint8_t hash(uint32_t ip) { | ||
uint8_t *ptr = (uint8_t *) &ip; | ||
// simple byte xor | ||
return *ptr ^ *(ptr + 1) ^ *(ptr + 2) ^ *(ptr + 3); | ||
} | ||
|
||
|
||
|
||
#endif |
Oops, something went wrong.