]> git.ipfire.org Git - people/ms/suricata.git/commitdiff
pcap-file: set tenant-id if available
authorVictor Julien <victor@inliniac.net>
Fri, 30 Jan 2015 12:20:12 +0000 (13:20 +0100)
committerVictor Julien <victor@inliniac.net>
Thu, 23 Jul 2015 17:36:14 +0000 (19:36 +0200)
Set the id to each packet's 'pcap_v' structure.

src/source-pcap-file.c
src/source-pcap.h

index 5d60b9871340f40ac7b1a6dffc86550f68c0f360..0b982fd3ab13fd05b21d9c7e149b4581ef3d7d45 100644 (file)
@@ -78,6 +78,8 @@ typedef struct PcapFileGlobalVars_ {
 
 typedef struct PcapFileThreadVars_
 {
+    uint32_t tenant_id;
+
     /* counters */
     uint32_t pkts;
     uint64_t bytes;
@@ -155,6 +157,7 @@ void PcapFileCallbackLoop(char *user, struct pcap_pkthdr *h, u_char *pkt)
     p->datalink = pcap_g.datalink;
     p->pcap_cnt = ++pcap_g.cnt;
 
+    p->pcap_v.tenant_id = ptv->tenant_id;
     ptv->pkts++;
     ptv->bytes += h->caplen;
 
@@ -271,6 +274,16 @@ TmEcode ReceivePcapFileThreadInit(ThreadVars *tv, void *initdata, void **data)
         SCReturnInt(TM_ECODE_FAILED);
     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] = "";
     pcap_g.pcap_handle = pcap_open_offline((char *)initdata, errbuf);
     if (pcap_g.pcap_handle == NULL) {
index 335986954dc5ed5d21038aac19be542abe126473..ac6d331ddbc3dc04eede394c6287d490b2ce966b 100644 (file)
@@ -39,6 +39,7 @@ char *PcapLiveGetDevice(int);
 /* per packet Pcap vars */
 typedef struct PcapPacketVars_
 {
+    uint32_t tenant_id;
 } PcapPacketVars;
 
 /** needs to be able to contain Windows adapter id's, so