util-coredump-config.h \
util-cpu.h \
util-daemon.h \
+ util-datalink.h \
util-debug-filters.h \
util-debug.h \
util-decode-mime.h \
util-coredump-config.c \
util-cpu.c \
util-daemon.c \
+ util-datalink.c \
util-debug.c \
util-debug-filters.c \
util-decode-mime.c \
#include "tm-threads-common.h"
#include "conf.h"
#include "util-cpu.h"
+#include "util-datalink.h"
#include "util-debug.h"
#include "util-device.h"
#include "util-ebpf.h"
ltype = AFPGetDevLinktype(fd, ifname);
close(fd);
+ DatalinkSetGlobalType(ltype);
+
return ltype;
}
#include "tm-threads.h"
#include "util-privs.h"
+#include "util-datalink.h"
#include "util-device.h"
#include "tmqh-packetpool.h"
#include "source-erf-dag.h"
ewtn->tv = tv;
*data = (void *)ewtn;
+ DatalinkSetGlobalType(LINKTYPE_ETHERNET);
+
SCLogInfo("Starting processing packets from stream: %d on DAG: %s",
ewtn->dagstream, ewtn->dagname);
#include "suricata.h"
#include "tm-threads.h"
#include "source-erf-file.h"
+#include "util-datalink.h"
#define DAG_TYPE_ETH 2
SCLogInfo("Processing ERF file %s", (char *)initdata);
+ DatalinkSetGlobalType(LINKTYPE_ETHERNET);
+
SCReturnInt(TM_ECODE_OK);
}
#include "conf.h"
#include "util-byte.h"
#include "util-privs.h"
+#include "util-datalink.h"
#include "util-device.h"
#include "runmodes.h"
}
ntv->datalink = DLT_RAW;
+ DatalinkSetGlobalType(DLT_RAW);
*data = (void *)ntv;
#include "suricata-common.h"
#include "suricata.h"
#include "threadvars.h"
+#include "util-datalink.h"
#include "util-optimize.h"
#include "tm-queuehandlers.h"
#include "tm-threads.h"
ntv->stream_id = stream_id;
ntv->tv = tv;
ntv->hba = conf->hba;
+
+ DatalinkSetGlobalType(LINKTYPE_ETHERNET);
+
SCLogDebug("Started processing packets from NAPATECH Stream: %lu", ntv->stream_id);
*data = (void *) ntv;
#include "util-bpf.h"
#include "util-privs.h"
#include "util-validate.h"
+#include "util-datalink.h"
#include "source-netmap.h"
SCLogDebug("thread: %s polling on fd: %d", tv->name, ntv->ifsrc->nmd->fd);
+ DatalinkSetGlobalType(LINKTYPE_ETHERNET);
+
*data = (void *)ntv;
aconf->DerefFunc(aconf);
SCReturnInt(TM_ECODE_OK);
ntv->datalen = T_DATA_SIZE;
#undef T_DATA_SIZE
+ DatalinkSetGlobalType(DLT_RAW);
+
*data = (void *)ntv;
nflconfig->DerefFunc(nflconfig);
#include "source-nfq-prototypes.h"
#include "action-globals.h"
+#include "util-datalink.h"
#include "util-debug.h"
#include "util-error.h"
#include "util-byte.h"
ntv->datalen = T_DATA_SIZE;
#undef T_DATA_SIZE
+ DatalinkSetGlobalType(DLT_RAW);
+
*data = (void *)ntv;
SCMutexUnlock(&nfq_init_lock);
*/
#include "source-pcap-file-helper.h"
+#include "util-datalink.h"
#include "util-checksum.h"
#include "util-profiling.h"
#include "source-pcap-file.h"
pfv->datalink = pcap_datalink(pfv->pcap_handle);
SCLogDebug("datalink %" PRId32 "", pfv->datalink);
+ DatalinkSetGlobalType(pfv->datalink);
if (!PeekFirstPacketTimestamp(pfv))
SCReturnInt(TM_ECODE_FAILED);
#include "util-debug.h"
#include "util-error.h"
#include "util-privs.h"
+#include "util-datalink.h"
#include "util-device.h"
#include "util-optimize.h"
#include "util-checksum.h"
(void)GetIfaceOffloading(pcapconfig->iface, 1, 1);
ptv->datalink = pcap_datalink(ptv->pcap_handle);
+ DatalinkSetGlobalType(ptv->datalink);
pcapconfig->DerefFunc(pcapconfig);
#include "util-debug.h"
#include "util-checksum.h"
#include "util-privs.h"
+#include "util-datalink.h"
#include "util-device.h"
#include "util-host-info.h"
#include "runmodes.h"
}
}
+ DatalinkSetGlobalType(LINKTYPE_ETHERNET);
+
*data = (void *)ptv;
pfconf->DerefFunc(pfconf);
--- /dev/null
+/* Copyright (C) 2021 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
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * version 2 along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#include "suricata-common.h"
+#include "conf.h"
+#include "util-datalink.h"
+
+int g_datalink_value = LINKTYPE_NULL;
+int g_datalink_is_multiple = 0;
+
+void DatalinkSetGlobalType(int datalink)
+{
+ if (g_datalink_value != LINKTYPE_NULL) {
+ if (datalink != g_datalink_value) {
+ g_datalink_is_multiple = 1;
+ }
+ } else {
+ g_datalink_value = datalink;
+ }
+}
+
+inline int DatalinkGetGlobalType(void)
+{
+ return g_datalink_value;
+}
+
+bool DatalinkHasMultipleValues(void)
+{
+ return g_datalink_is_multiple == 1;
+}
--- /dev/null
+/* Copyright (C) 2021 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
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * version 2 along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#ifndef __UTIL_DATALINK_H__
+#define __UTIL_DATALINK_H__
+
+void DatalinkSetGlobalType(int datalink);
+int DatalinkGetGlobalType(void);
+bool DatalinkHasMultipleValues(void);
+
+#endif /* __UTIL_DATALINK_H__ */