-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathoutput_flatfile.c
More file actions
37 lines (32 loc) · 782 Bytes
/
Copy pathoutput_flatfile.c
File metadata and controls
37 lines (32 loc) · 782 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "output_flatfile.h"
#include "util.h"
void output_flatfile_init()
{
if (cfg.data_file) {
cfg.data_fd = fopen(cfg.data_file, "ae");
if (!cfg.data_fd) {
log_msg(LOG_ERR, "Unable to open flat file %s", cfg.data_file);
}
log_msg(LOG_DEBUG, "Saving results to '%s' flat file", cfg.data_file);
}
}
void output_flatfile_reload()
{
output_flatfile_close();
output_flatfile_init();
}
void output_flatfile_save(struct pkt *p, char *mac_str, char *ip_str)
{
if (cfg.data_fd) {
fprintf(cfg.data_fd, "%" PRIu64 " %s %" PRIu16 " %s %s %s\n",
(uint64_t)p->pcap_header->ts.tv_sec, p->ifc->name, p->vlan_tag,
mac_str, ip_str, pkt_origin_str[p->origin]);
fflush(cfg.data_fd);
}
}
void output_flatfile_close()
{
if (cfg.data_fd) {
fclose(cfg.data_fd);
}
}