|
|
|
@ -78,6 +78,8 @@ typedef struct PcapFileGlobalVars_ {
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct PcapFileThreadVars_
|
|
|
|
typedef struct PcapFileThreadVars_
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
uint32_t tenant_id;
|
|
|
|
|
|
|
|
|
|
|
|
/* counters */
|
|
|
|
/* counters */
|
|
|
|
uint32_t pkts;
|
|
|
|
uint32_t pkts;
|
|
|
|
uint64_t bytes;
|
|
|
|
uint64_t bytes;
|
|
|
|
@ -155,6 +157,7 @@ void PcapFileCallbackLoop(char *user, struct pcap_pkthdr *h, u_char *pkt)
|
|
|
|
p->datalink = pcap_g.datalink;
|
|
|
|
p->datalink = pcap_g.datalink;
|
|
|
|
p->pcap_cnt = ++pcap_g.cnt;
|
|
|
|
p->pcap_cnt = ++pcap_g.cnt;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
p->pcap_v.tenant_id = ptv->tenant_id;
|
|
|
|
ptv->pkts++;
|
|
|
|
ptv->pkts++;
|
|
|
|
ptv->bytes += h->caplen;
|
|
|
|
ptv->bytes += h->caplen;
|
|
|
|
|
|
|
|
|
|
|
|
@ -271,6 +274,16 @@ TmEcode ReceivePcapFileThreadInit(ThreadVars *tv, void *initdata, void **data)
|
|
|
|
SCReturnInt(TM_ECODE_FAILED);
|
|
|
|
SCReturnInt(TM_ECODE_FAILED);
|
|
|
|
memset(ptv, 0, sizeof(PcapFileThreadVars));
|
|
|
|
memset(ptv, 0, sizeof(PcapFileThreadVars));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
intmax_t tenant = 0;
|
|
|
|
|
|
|
|
if (ConfGetInt("pcap-file.tenant-id", &tenant) == 1) {
|
|
|
|
|
|
|
|
if (tenant > 0 && tenant < UINT_MAX) {
|
|
|
|
|
|
|
|
ptv->tenant_id = (uint32_t)tenant;
|
|
|
|
|
|
|
|
SCLogInfo("tenant %u", ptv->tenant_id);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
SCLogError(SC_ERR_INVALID_ARGUMENT, "tenant out of range");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
char errbuf[PCAP_ERRBUF_SIZE] = "";
|
|
|
|
char errbuf[PCAP_ERRBUF_SIZE] = "";
|
|
|
|
pcap_g.pcap_handle = pcap_open_offline((char *)initdata, errbuf);
|
|
|
|
pcap_g.pcap_handle = pcap_open_offline((char *)initdata, errbuf);
|
|
|
|
if (pcap_g.pcap_handle == NULL) {
|
|
|
|
if (pcap_g.pcap_handle == NULL) {
|
|
|
|
|