aboutsummaryrefslogtreecommitdiffstats
path: root/src/fnettrace/fnettrace.h
diff options
context:
space:
mode:
authorLibravatar netblue30 <netblue30@protonmail.com>2021-12-28 11:04:59 -0500
committerLibravatar netblue30 <netblue30@protonmail.com>2021-12-28 11:04:59 -0500
commit54b28a0b6392f9921fad98ba9e22470c900efb03 (patch)
treeb84db698ff24816e8c67b9002de860a2fccaeb0f /src/fnettrace/fnettrace.h
parentMerge pull request #4802 from jose1711/clipgrab_fix (diff)
downloadfirejail-54b28a0b6392f9921fad98ba9e22470c900efb03.tar.gz
firejail-54b28a0b6392f9921fad98ba9e22470c900efb03.tar.zst
firejail-54b28a0b6392f9921fad98ba9e22470c900efb03.zip
nettrace/netlock
Diffstat (limited to 'src/fnettrace/fnettrace.h')
-rw-r--r--src/fnettrace/fnettrace.h64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/fnettrace/fnettrace.h b/src/fnettrace/fnettrace.h
new file mode 100644
index 000000000..9c34e17ca
--- /dev/null
+++ b/src/fnettrace/fnettrace.h
@@ -0,0 +1,64 @@
1#ifndef FNETTRACE_H
2#define FNETTRACE_H
3
4#include "../include/common.h"
5#include <unistd.h>
6#include <sys/stat.h>
7#include <sys/socket.h>
8#include <netinet/in.h>
9#include <time.h>
10#include <stdarg.h>
11
12//#define NETLOCK_INTERVAL 60
13#define NETLOCK_INTERVAL 60
14#define DISPLAY_INTERVAL 3
15
16void logprintf(char* fmt, ...);
17
18static inline void ansi_topleft(int tolog) {
19 char str[] = {0x1b, '[', '1', ';', '1', 'H', '\0'};
20 if (tolog)
21 logprintf("%s", str);
22 else
23 printf("%s", str);
24 fflush(0);
25}
26
27static inline void ansi_clrscr(int tolog) {
28 ansi_topleft(tolog);
29 char str[] = {0x1b, '[', '0', 'J', '\0'};
30 if (tolog)
31 logprintf("%s", str);
32 else
33 printf("%s", str);
34 fflush(0);
35}
36
37static inline void ansi_linestart(int tolog) {
38 char str[] = {0x1b, '[', '0', 'G', '\0'};
39 if (tolog)
40 logprintf("%s", str);
41 else
42 printf("%s", str);
43 fflush(0);
44}
45
46static inline void ansi_clrline(int tolog) {
47 ansi_linestart(tolog);
48 char str[] = {0x1b, '[', '0', 'K', '\0'};
49 if (tolog)
50 logprintf("%s", str);
51 else
52 printf("%s", str);
53 fflush(0);
54}
55
56static inline uint8_t hash(uint32_t ip) {
57 uint8_t *ptr = (uint8_t *) &ip;
58 // simple byte xor
59 return *ptr ^ *(ptr + 1) ^ *(ptr + 2) ^ *(ptr + 3);
60}
61
62
63
64#endif \ No newline at end of file