-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SIGUSR1 support and some code improvement
- Loading branch information
root
committed
Oct 20, 2021
1 parent
5b8e0fb
commit acbd12a
Showing
11 changed files
with
295 additions
and
212 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
Binary file not shown.
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 |
---|---|---|
@@ -1,26 +1,29 @@ | ||
CFLAGS = -Wall -O2 | ||
|
||
all: tuninetd | ||
tuninetd: main.o nflog.o pcap.o thread.o tun.o utils.o | ||
|
||
tuninetd: main.o xnflog.o xpcap.o thread.o xtun.o utils.o | ||
[ -d ./bin ] || mkdir -p ./bin | ||
gcc main.o nflog.o pcap.o thread.o tun.o utils.o -o ./bin/tuninetd -lpthread -lpcap -lnetfilter_log | ||
gcc main.o xnflog.o xpcap.o thread.o xtun.o utils.o -o ./bin/tuninetd -lpthread -lpcap -lnetfilter_log | ||
|
||
main.o: main.c main.h | ||
gcc -c main.c | ||
main.o: main.c main.h common.h | ||
gcc $(CFLAGS) -c main.c | ||
|
||
nflog.o: nflog.c main.h | ||
gcc -c nflog.c | ||
xnflog.o: xnflog.c common.h | ||
gcc $(CFLAGS) -c xnflog.c | ||
|
||
pcap.o: pcap.c main.h | ||
gcc -c pcap.c | ||
xpcap.o: xpcap.c common.h | ||
gcc $(CFLAGS) -c xpcap.c | ||
|
||
thread.o: thread.c main.h | ||
gcc -c thread.c | ||
thread.o: thread.c common.h | ||
gcc $(CFLAGS) -c thread.c | ||
|
||
tun.o: tun.c main.h | ||
gcc -c tun.c | ||
xtun.o: xtun.c common.h | ||
gcc $(CFLAGS) -c xtun.c | ||
|
||
utils.o: utils.c main.h | ||
gcc -c utils.c | ||
utils.o: utils.c common.h | ||
gcc $(CFLAGS) -c utils.c | ||
|
||
clean: | ||
rm -f *.o tuninetd | ||
rm -rf ./bin | ||
rm -f *.o | ||
rm -rf ./bin |
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,61 @@ | ||
#ifndef H_TUNINETD_COMMON | ||
#define H_TUNINETD_COMMON | ||
|
||
#include <fcntl.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <sys/ioctl.h> | ||
#include <net/if.h> | ||
#include <linux/if_tun.h> | ||
#include <unistd.h> | ||
#include <time.h> | ||
|
||
#define BUFSIZE 2000 | ||
#define ON 1 | ||
#define OFF 0 | ||
|
||
#define ERROR 0 | ||
#define WARNING 1 | ||
#define INFO 2 | ||
|
||
#define VERSION "\ntuninetd 1.3.0\n" | ||
|
||
//global vars. | ||
short int debug; | ||
short int status; | ||
unsigned long ts; | ||
unsigned long curts; | ||
|
||
struct globcfg_t { | ||
short int isdaemon; | ||
pid_t pid; | ||
char *cmd_path; | ||
char *cmd_path_start; | ||
char *cmd_path_stop; | ||
char *pcap_filter; | ||
char *dev_name; | ||
long nf_group; | ||
int dev_mode; | ||
long ttl; | ||
} globcfg; | ||
|
||
|
||
//from utils.c | ||
void do_debug(const char *msg, ...); | ||
void message(int, const char *msg, ...); | ||
|
||
void sighup_handler(int signo); | ||
void sigusr_handler(int signo); | ||
void usage(); | ||
void version(); | ||
|
||
//from thread.c | ||
void switch_guard(short action); | ||
void thread_init(); | ||
|
||
void *tun_x(void *x_void_ptr); | ||
void *nflog_x(void *x_void_ptr); | ||
void *pcap_x(void *x_void_ptr); | ||
|
||
#endif |
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
Oops, something went wrong.