diff options
Diffstat (limited to 'src/fnettrace')
-rw-r--r-- | src/fnettrace/main.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/src/fnettrace/main.c b/src/fnettrace/main.c index 9cbdc290d..04aabf514 100644 --- a/src/fnettrace/main.c +++ b/src/fnettrace/main.c | |||
@@ -75,7 +75,7 @@ static void hlist_add(uint32_t ip_src, uint32_t ip_dst, uint8_t protocol, uint16 | |||
75 | } | 75 | } |
76 | 76 | ||
77 | ansi_clrline(1); | 77 | ansi_clrline(1); |
78 | logprintf(" %u.%u.%u.%u\n", PRINT_IP(hnew->ip_src)); | 78 | logprintf(" %d%d.%d.%d\n", PRINT_IP(hnew->ip_src)); |
79 | } | 79 | } |
80 | 80 | ||
81 | // remove entries with a ttl <= 0 | 81 | // remove entries with a ttl <= 0 |
@@ -111,7 +111,6 @@ static void hlist_print() { | |||
111 | return; | 111 | return; |
112 | if (arg_netfilter) | 112 | if (arg_netfilter) |
113 | printf("\n\n"); | 113 | printf("\n\n"); |
114 | static int clear_cnt = 0; | ||
115 | 114 | ||
116 | int i; | 115 | int i; |
117 | int cnt = 0; | 116 | int cnt = 0; |
@@ -122,9 +121,9 @@ static void hlist_print() { | |||
122 | if (ptr->bytes) { | 121 | if (ptr->bytes) { |
123 | cnt_printed++; | 122 | cnt_printed++; |
124 | char ip_src[30]; | 123 | char ip_src[30]; |
125 | sprintf(ip_src, "%u.%u.%u.%u:%u", PRINT_IP(ptr->ip_src), ptr->port_src); | 124 | sprintf(ip_src, "%d.%d.%d.%d:%u", PRINT_IP(ptr->ip_src), ptr->port_src); |
126 | char ip_dst[30]; | 125 | char ip_dst[30]; |
127 | sprintf(ip_dst, "%u.%u.%u.%u", PRINT_IP(ptr->ip_dst)); | 126 | sprintf(ip_dst, "%d.%d.%d.%d", PRINT_IP(ptr->ip_dst)); |
128 | printf("%-25s => %-25s\t%s:", | 127 | printf("%-25s => %-25s\t%s:", |
129 | ip_src, | 128 | ip_src, |
130 | ip_dst, | 129 | ip_dst, |
@@ -168,7 +167,6 @@ static void run_trace(void) { | |||
168 | unsigned last_print_traces = 0; | 167 | unsigned last_print_traces = 0; |
169 | unsigned last_print_remaining = 0; | 168 | unsigned last_print_remaining = 0; |
170 | unsigned char buf[MAX_BUF_SIZE]; | 169 | unsigned char buf[MAX_BUF_SIZE]; |
171 | int progress_cnt = 0; | ||
172 | while (1) { | 170 | while (1) { |
173 | unsigned end = time(NULL); | 171 | unsigned end = time(NULL); |
174 | if (arg_netfilter && end - start >= NETLOCK_INTERVAL) { | 172 | if (arg_netfilter && end - start >= NETLOCK_INTERVAL) { |
@@ -201,11 +199,8 @@ static void run_trace(void) { | |||
201 | else if (rv == 0) | 199 | else if (rv == 0) |
202 | continue; | 200 | continue; |
203 | 201 | ||
204 | |||
205 | |||
206 | int sock = (FD_ISSET(s1, &rfds)) ? s1 : s2; | 202 | int sock = (FD_ISSET(s1, &rfds)) ? s1 : s2; |
207 | 203 | ||
208 | unsigned char buf[MAX_BUF_SIZE]; | ||
209 | unsigned bytes = recvfrom(sock, buf, MAX_BUF_SIZE, 0, NULL, NULL); | 204 | unsigned bytes = recvfrom(sock, buf, MAX_BUF_SIZE, 0, NULL, NULL); |
210 | if (bytes >= 20) { // size of IP header | 205 | if (bytes >= 20) { // size of IP header |
211 | // filter out loopback traffic | 206 | // filter out loopback traffic |
@@ -253,11 +248,11 @@ static int print_filter(FILE *fp) { | |||
253 | while (ptr) { | 248 | while (ptr) { |
254 | if (ptr->instance == 1) { | 249 | if (ptr->instance == 1) { |
255 | char *protocol = (ptr->protocol == 6)? "tcp": "udp"; | 250 | char *protocol = (ptr->protocol == 6)? "tcp": "udp"; |
256 | fprintf(fp, "-A INPUT -s %u.%u.%u.%u -sport %u -p %s -j ACCEPT\n", | 251 | fprintf(fp, "-A INPUT -s %d.%d.%d.%d -sport %u -p %s -j ACCEPT\n", |
257 | PRINT_IP(ptr->ip_src), | 252 | PRINT_IP(ptr->ip_src), |
258 | ptr->port_src, | 253 | ptr->port_src, |
259 | protocol); | 254 | protocol); |
260 | fprintf(fp, "-A OUTPUT -d %u.%u.%u.%u -dport %u -p %s -j ACCEPT\n", | 255 | fprintf(fp, "-A OUTPUT -d %d.%d.%d.%d -dport %u -p %s -j ACCEPT\n", |
261 | PRINT_IP(ptr->ip_src), | 256 | PRINT_IP(ptr->ip_src), |
262 | ptr->port_src, | 257 | ptr->port_src, |
263 | protocol); | 258 | protocol); |