diff options
author | 2023-07-23 10:30:50 -0400 | |
---|---|---|
committer | 2023-07-23 10:30:50 -0400 | |
commit | b093b66047241896330e09ef7faa981a77cf9e1c (patch) | |
tree | 7ef4981c748ac07eb7dbfeff107ee62378ba076e /src/fnettrace/main.c | |
parent | contrib/syntax: run make syntax (diff) | |
download | firejail-b093b66047241896330e09ef7faa981a77cf9e1c.tar.gz firejail-b093b66047241896330e09ef7faa981a77cf9e1c.tar.zst firejail-b093b66047241896330e09ef7faa981a77cf9e1c.zip |
fnettrace: trace ICPM ECHO (ping) traffic
Diffstat (limited to 'src/fnettrace/main.c')
-rw-r--r-- | src/fnettrace/main.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/fnettrace/main.c b/src/fnettrace/main.c index 932afff61..c996adb19 100644 --- a/src/fnettrace/main.c +++ b/src/fnettrace/main.c | |||
@@ -30,7 +30,7 @@ static int arg_tail = 0; | |||
30 | static char *arg_log = NULL; | 30 | static char *arg_log = NULL; |
31 | 31 | ||
32 | uint32_t stats_pkts = 0; | 32 | uint32_t stats_pkts = 0; |
33 | uint32_t stats_icmp = 0; | 33 | uint32_t stats_icmp_echo = 0; |
34 | uint32_t stats_dns = 0; | 34 | uint32_t stats_dns = 0; |
35 | 35 | ||
36 | 36 | ||
@@ -291,7 +291,7 @@ static inline const char *common_port(uint16_t port) { | |||
291 | } | 291 | } |
292 | 292 | ||
293 | if (port <= 194) { | 293 | if (port <= 194) { |
294 | PortType *ptr =&ports[0]; | 294 | PortType *ptr = &ports[0]; |
295 | while(ptr->service != NULL) { | 295 | while(ptr->service != NULL) { |
296 | if (ptr->port == port) | 296 | if (ptr->port == port) |
297 | return ptr->service; | 297 | return ptr->service; |
@@ -440,10 +440,9 @@ static void hnode_print(unsigned bw) { | |||
440 | 440 | ||
441 | 441 | ||
442 | void print_stats(void) { | 442 | void print_stats(void) { |
443 | printf("\nIP table: %d entries, %d unknown\n", radix_nodes, geoip_calls); | 443 | printf("\nIP table: %d entries - address network (packets)\n", radix_nodes); |
444 | printf(" address network (packets)\n"); | ||
445 | radix_print(1); | 444 | radix_print(1); |
446 | printf("Packets: %u total, ICMP %u, DNS %u\n", stats_pkts, stats_icmp, stats_dns); | 445 | printf("Packets: %u total, PING %u, DNS %u\n", stats_pkts, stats_icmp_echo, stats_dns); |
447 | } | 446 | } |
448 | 447 | ||
449 | // trace rx traffic coming in | 448 | // trace rx traffic coming in |
@@ -557,9 +556,11 @@ static void run_trace(void) { | |||
557 | 556 | ||
558 | // stats | 557 | // stats |
559 | stats_pkts++; | 558 | stats_pkts++; |
560 | if (icmp) | 559 | if (icmp) { |
561 | stats_icmp++; | 560 | if (*(buf + hlen) == 0 || *(buf + hlen) == 8) |
562 | if (port_src == 53) | 561 | stats_icmp_echo++; |
562 | } | ||
563 | else if (port_src == 53) | ||
563 | stats_dns++; | 564 | stats_dns++; |
564 | 565 | ||
565 | } | 566 | } |
@@ -775,7 +776,7 @@ int main(int argc, char **argv) { | |||
775 | return 0; | 776 | return 0; |
776 | } | 777 | } |
777 | else if (strncmp(argv[i], "--squash-map=", 13) == 0) { | 778 | else if (strncmp(argv[i], "--squash-map=", 13) == 0) { |
778 | if (i !=(argc - 1)) { | 779 | if (i != (argc - 1)) { |
779 | fprintf(stderr, "Error: please provide a map file\n"); | 780 | fprintf(stderr, "Error: please provide a map file\n"); |
780 | return 1; | 781 | return 1; |
781 | } | 782 | } |