diff options
| author | Maciej Borowiec <81316152+Mosder@users.noreply.github.com> | 2026-06-14 01:54:07 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-06-14 01:54:07 +0200 |
| commit | 2e3f7fe39791cd671a68330f7ba7a5bb5fc6f9ae (patch) | |
| tree | bf2f679387bff19637e1183400c0b0290d2d1834 /analyzer/capture.c | |
| parent | 35dc15a03ba5cf2dec10d63a1fdc7ab1fb082899 (diff) | |
| parent | c2568d72efca8fae3c610072cb055f9c8de3ca5f (diff) | |
Merge pull request #4 from Mosder/2-simple-capturing-mode
Simple capturing mode
Diffstat (limited to 'analyzer/capture.c')
| -rw-r--r-- | analyzer/capture.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/analyzer/capture.c b/analyzer/capture.c new file mode 100644 index 0000000..0a75e09 --- /dev/null +++ b/analyzer/capture.c @@ -0,0 +1,28 @@ +#include "capture.h" + +#include <stdio.h> +#include <stdlib.h> + +#include "headers/interface.h" +#include "headers/server.h" +#include "utils/fs.h" +#include "utils/time.h" + +void capture_to_file(char *path) { + char command[128]; + sprintf(command, "tshark -i %s -f \"src host %s\" -w %s", INTERFACE, SERVER_IP, path); + system(command); +} + +void capturing_mode(char *path) { + if (path != NULL) { + capture_to_file(path); + return; + } + + char capture_dir[256], new_path[256], date_time[128]; + get_capture_dir(capture_dir); + get_date_time_string(date_time); + sprintf(new_path, "%s/capture-%s.pcap", capture_dir, date_time); + capture_to_file(new_path); +} |
