2019-05-27 15:32:00 +00:00
|
|
|
#include "capture_traffic.h"
|
2019-05-27 16:14:21 +00:00
|
|
|
void traffic_capture_init(struct capture_ctx* ctx, char* filename) {
|
|
|
|
ctx->activated = filename == NULL ? 0 : 1;
|
|
|
|
if (!ctx->activated) return;
|
2019-05-27 15:32:00 +00:00
|
|
|
|
2019-05-27 16:14:21 +00:00
|
|
|
ctx->filename = strdup(filename);
|
|
|
|
ctx->capture_in = g_queue_new ();
|
|
|
|
ctx->capture_out = g_queue_new ();
|
2019-05-27 15:32:00 +00:00
|
|
|
}
|
|
|
|
|
2019-05-27 16:14:21 +00:00
|
|
|
void traffic_capture_stop(struct capture_ctx* ctx) {
|
|
|
|
if (!ctx->activated) return;
|
2019-05-27 15:32:00 +00:00
|
|
|
|
2019-05-27 16:14:21 +00:00
|
|
|
FILE* fd = NULL;
|
|
|
|
|
|
|
|
if ((fd = fopen(ctx->filename, "w")) == NULL) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
free(ctx->filename);
|
2019-05-27 15:32:00 +00:00
|
|
|
}
|