-/* Copyright (C) 2007-2013 Open Information Security Foundation
+/* Copyright (C) 2007-2014 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
#include "util-checksum.h"
#include "util-privs.h"
#include "util-device.h"
+#include "util-host-info.h"
#include "runmodes.h"
#ifdef __SC_CUDA_SUPPORT__
ThreadVars *tv;
TmSlot *slot;
+ int vlan_disabled;
+
/* threads count */
int threads;
* so that is what we do here. */
p->datalink = LINKTYPE_ETHERNET;
+ /* get vlan id from header. Check on vlan_id not null even if comment in
+ * header announce NO_VLAN is used when there is no VLAN. But NO_VLAN
+ * is not defined nor used in PF_RING code. And vlan_id is set to 0
+ * in PF_RING kernel code when there is no VLAN. */
+ if ((!ptv->vlan_disabled) && h->extended_hdr.parsed_pkt.vlan_id) {
+ p->vlan_id[0] = h->extended_hdr.parsed_pkt.vlan_id;
+ p->vlan_idx = 1;
+ p->vlanh[0] = NULL;
+ }
+
switch (ptv->checksum_mode) {
case CHECKSUM_VALIDATION_RXONLY:
if (h->extended_hdr.rx_direction == 0) {
opflag = PF_RING_REENTRANT | PF_RING_PROMISC;
+ /* if suri uses VLAN and if we have a recent kernel, we need
+ * to use parsed_pkt to get VLAN info */
+ if ((! ptv->vlan_disabled) && SCKernelVersionIsAtLeast(3, 0)) {
+ opflag |= PF_RING_LONG_HEADER;
+ }
+
if (ptv->checksum_mode == CHECKSUM_VALIDATION_RXONLY) {
if (strncmp(ptv->interface, "dna", 3) == 0) {
SCLogWarning(SC_ERR_INVALID_VALUE,
}
#endif /* HAVE_PFRING_ENABLE */
+ /* A bit strange to have this here but we only have vlan information
+ * during reading so we need to know if we want to keep vlan during
+ * the capture phase */
+ int vlanbool = 0;
+ if ((ConfGetBool("vlan.use-for-tracking", &vlanbool)) == 1 && vlanbool == 0) {
+ ptv->vlan_disabled = 1;
+ }
+
+ /* If kernel is older than 3.8, VLAN is not stripped so we don't
+ * get the info from packt extended header but we will use a standard
+ * parsing */
+ if (! SCKernelVersionIsAtLeast(3, 0)) {
+ ptv->vlan_disabled = 1;
+ }
*data = (void *)ptv;
pfconf->DerefFunc(pfconf);
SCPerfCounterAddUI64(dtv->counter_avg_pkt_size, tv->sc_perf_pca, GET_PKT_LEN(p));
SCPerfCounterSetUI64(dtv->counter_max_pkt_size, tv->sc_perf_pca, GET_PKT_LEN(p));
+ /* If suri has set vlan during reading, we increase vlan counter */
+ if (p->vlan_idx) {
+ SCPerfCounterIncr(dtv->counter_vlan, tv->sc_perf_pca);
+ }
+
DecodeEthernet(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p), pq);
PacketDecodeFinalize(tv, dtv, p);