suricata
source-pcap-file-helper.h
Go to the documentation of this file.
1/* Copyright (C) 2007-2020 Open Information Security Foundation
2 *
3 * You can copy, redistribute or modify this Program under the terms of
4 * the GNU General Public License version 2 as published by the Free
5 * Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * version 2 along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15 * 02110-1301, USA.
16 */
17
18/**
19 * \file
20 *
21 * \author Danny Browning <danny.browning@protectwise.com>
22 */
23
24#include "suricata-common.h"
25#include "tm-threads.h"
26
27#ifndef SURICATA_SOURCE_PCAP_FILE_HELPER_H
28#define SURICATA_SOURCE_PCAP_FILE_HELPER_H
29
37
38/**
39 * Data that is shared amongst File, Directory, and Thread level vars
40 */
41typedef struct PcapFileSharedVars_
42{
44
45 uint32_t tenant_id;
46
47 struct timespec last_processed;
48
50
53
54 /* counters */
55 uint64_t pkts;
56 uint64_t bytes;
57 uint64_t files;
58
59 uint8_t done;
60 uint32_t errs;
61
62 /** callback result -- set if one of the thread module failed. */
65
66/**
67 * Data specific to a single pcap file
68 */
69typedef struct PcapFileFileVars_
70{
71 char *filename;
72 pcap_t *pcap_handle;
73
75 struct bpf_program filter;
76
78
79 /* fields used to get the first packet's timestamp early,
80 * so it can be used to setup the time subsys. */
81 const u_char *first_pkt_data;
82 struct pcap_pkthdr *first_pkt_hdr;
83 struct timeval first_pkt_ts;
84
85 /** flex array member for the libc io read buffer. Size controlled by
86 * PcapFileGlobalVars::read_buffer_size. */
87#if defined(HAVE_SETVBUF) && defined(OS_LINUX)
88 char buffer[];
89#endif
91
92/**
93 * Dispatch a file for processing, where the information necessary to process that
94 * file is as PcapFileFileVars object.
95 * @param ptv PcapFileFileVars object to be processed
96 * @return
97 */
99
100/**
101 * From a PcapFileFileVars, prepare the filename for processing by setting
102 * pcap_handle, datalink, and filter
103 * @param pfv PcapFileFileVars object to populate
104 * @return
105 */
107
108/**
109 * Cleanup resources associated with a PcapFileFileVars object.
110 * @param pfv Object to be cleaned up
111 */
113
114/**
115 * Determine if a datalink type is valid, setting a decoder function if valid.
116 * @param datalink Datalink type to validate
117 * @param decoder Pointer to decoder to set if valid
118 * @return TM_ECODE_OK if valid datalink type and decoder has been set.
119 */
120TmEcode ValidateLinkType(int datalink, DecoderFunc *decoder);
121
122const char *PcapFileGetFilename(void);
123
124#endif /* SURICATA_SOURCE_PCAP_FILE_HELPER_H */
ChecksumValidationMode
Definition decode.h:42
int(* DecoderFunc)(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
Definition decode.h:1180
TmEcode InitPcapFile(PcapFileFileVars *pfv)
struct PcapFileFileVars_ PcapFileFileVars
const char * PcapFileGetFilename(void)
TmEcode PcapFileDispatch(PcapFileFileVars *ptv)
Main PCAP file reading Loop function.
TmEcode ValidateLinkType(int datalink, DecoderFunc *decoder)
void CleanupPcapFileFileVars(PcapFileFileVars *pfv)
struct PcapFileSharedVars_ PcapFileSharedVars
struct PcapFileGlobalVars_ PcapFileGlobalVars
PcapFileSharedVars * shared
struct pcap_pkthdr * first_pkt_hdr
struct bpf_program filter
SC_ATOMIC_DECLARE(unsigned int, invalid_checksums)
ChecksumValidationMode checksum_mode
ChecksumValidationMode conf_checksum_mode
Per thread variable structure.
Definition threadvars.h:58