Skip to content

Commit

Permalink
Proper indent file
Browse files Browse the repository at this point in the history
  • Loading branch information
clementperon committed Sep 21, 2024
1 parent 6fc1cf5 commit 926aceb
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 138 deletions.
94 changes: 47 additions & 47 deletions Pcap++/src/KniDevice.cpp
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
// GCOVR_EXCL_START

# define LOG_MODULE PcapLogModuleKniDevice

# include "KniDevice.h"
# include "Logger.h"
# include "SystemUtils.h"

# include <unistd.h>
# include <time.h>
# include <thread>
# include <sys/ioctl.h>
# include <net/if.h>
# include <net/if_arp.h>

# include <rte_version.h>
# include <rte_mempool.h>
# include <rte_mbuf.h>
# include <rte_lcore.h>
# include <rte_kni.h>
# include <rte_memory.h>
# include <rte_branch_prediction.h>

# include <cerrno>
# include <cstdio>
# include <cstring>
# include <algorithm>

# ifndef KNI_MEMPOOL_NAME_PREFIX
# define KNI_MEMPOOL_NAME_PREFIX "kniMempool"
# endif
# ifndef MEMPOOL_CACHE_SIZE
# define MEMPOOL_CACHE_SIZE 256
# endif
# ifndef MAX_BURST_SIZE
# define MAX_BURST_SIZE 64
# endif

# define CPP_VLA(TYPE, SIZE) (TYPE*)__builtin_alloca(sizeof(TYPE) * SIZE)
#define LOG_MODULE PcapLogModuleKniDevice

#include "KniDevice.h"
#include "Logger.h"
#include "SystemUtils.h"

#include <unistd.h>
#include <time.h>
#include <thread>
#include <sys/ioctl.h>
#include <net/if.h>
#include <net/if_arp.h>

#include <rte_version.h>
#include <rte_mempool.h>
#include <rte_mbuf.h>
#include <rte_lcore.h>
#include <rte_kni.h>
#include <rte_memory.h>
#include <rte_branch_prediction.h>

#include <cerrno>
#include <cstdio>
#include <cstring>
#include <algorithm>

#ifndef KNI_MEMPOOL_NAME_PREFIX
# define KNI_MEMPOOL_NAME_PREFIX "kniMempool"
#endif
#ifndef MEMPOOL_CACHE_SIZE
# define MEMPOOL_CACHE_SIZE 256
#endif
#ifndef MAX_BURST_SIZE
# define MAX_BURST_SIZE 64
#endif

#define CPP_VLA(TYPE, SIZE) (TYPE*)__builtin_alloca(sizeof(TYPE) * SIZE)

namespace pcpp
{
Expand Down Expand Up @@ -117,17 +117,17 @@ namespace pcpp
{
return oldState = KniDevice::LINK_ERROR;
}
# if RTE_VERSION >= RTE_VERSION_NUM(18, 11, 0, 0)
#if RTE_VERSION >= RTE_VERSION_NUM(18, 11, 0, 0)
oldState = (KniDevice::KniLinkState)rte_kni_update_link(kni, state);
if (oldState == KniDevice::LINK_ERROR)
{ //? NOTE(echo-Mike): Not LOG_ERROR because will generate a lot of junk messages on some DPDK versions
PCPP_LOG_DEBUG("DPDK KNI Failed to update links state for device '" << deviceName << "'");
}
# else
#else
// To avoid compiler warnings
(void)kni;
(void)deviceName;
# endif
#endif
return oldState;
}

Expand Down Expand Up @@ -173,30 +173,30 @@ namespace pcpp
kniConf.core_id = conf.kthreadCoreId;
kniConf.mbuf_size = RTE_MBUF_DEFAULT_BUF_SIZE;
kniConf.force_bind = conf.bindKthread ? 1 : 0;
# if RTE_VERSION >= RTE_VERSION_NUM(18, 2, 0, 0)
#if RTE_VERSION >= RTE_VERSION_NUM(18, 2, 0, 0)
if (conf.mac != MacAddress::Zero)
conf.mac.copyTo((uint8_t*)kniConf.mac_addr);
kniConf.mtu = conf.mtu;
# endif
#endif

kniOps.port_id = conf.portId;
# if RTE_VERSION >= RTE_VERSION_NUM(17, 11, 0, 0)
#if RTE_VERSION >= RTE_VERSION_NUM(17, 11, 0, 0)
if (conf.callbacks != nullptr)
{
kniOps.change_mtu = conf.callbacks->change_mtu;
kniOps.config_network_if = conf.callbacks->config_network_if;
# if RTE_VERSION >= RTE_VERSION_NUM(18, 2, 0, 0)
# if RTE_VERSION >= RTE_VERSION_NUM(18, 2, 0, 0)
kniOps.config_mac_address = conf.callbacks->config_mac_address;
kniOps.config_promiscusity = conf.callbacks->config_promiscusity;
# endif
# endif
}
# else
#else
if (conf.oldCallbacks != nullptr)
{
kniOps.change_mtu = conf.oldCallbacks->change_mtu;
kniOps.config_network_if = conf.oldCallbacks->config_network_if;
}
# endif
#endif

m_Device = rte_kni_alloc(m_MBufMempool, &kniConf, &kniOps);
if (m_Device == nullptr)
Expand Down
40 changes: 20 additions & 20 deletions Pcap++/src/KniDeviceList.cpp
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
// GCOVR_EXCL_START

# define LOG_MODULE PcapLogModuleKniDevice
#define LOG_MODULE PcapLogModuleKniDevice

# include <inttypes.h>
# include <algorithm>
#include <inttypes.h>
#include <algorithm>

# include "KniDeviceList.h"
# include "Logger.h"
# include "SystemUtils.h"
#include "KniDeviceList.h"
#include "Logger.h"
#include "SystemUtils.h"

# include <rte_version.h>
# include <rte_kni.h>
#include <rte_version.h>
#include <rte_kni.h>

# ifndef MAX_KNI_DEVICES
#ifndef MAX_KNI_DEVICES
// This value have no meaning in current DPDK implementation (ver >= 18.11)
// In older versions have literal meaning
# define MAX_KNI_DEVICES 4
# endif
# define MAX_KNI_DEVICES 4
#endif

namespace pcpp
{
Expand Down Expand Up @@ -52,15 +52,15 @@ namespace pcpp
m_Initialized = false;
return;
}
# if RTE_VERSION >= RTE_VERSION_NUM(18, 11, 0, 0)
#if RTE_VERSION >= RTE_VERSION_NUM(18, 11, 0, 0)
if (rte_kni_init(MAX_KNI_DEVICES) < 0)
{
PCPP_LOG_ERROR("Failed to initialize DPDK KNI module");
m_Initialized = false;
}
# else
#else
rte_kni_init(MAX_KNI_DEVICES);
# endif
#endif
}

KniDeviceList::~KniDeviceList()
Expand Down Expand Up @@ -141,11 +141,11 @@ namespace pcpp

KniDeviceList::KniCallbackVersion KniDeviceList::callbackVersion()
{
# if RTE_VERSION >= RTE_VERSION_NUM(17, 11, 0, 0)
#if RTE_VERSION >= RTE_VERSION_NUM(17, 11, 0, 0)
return KniDeviceList::CALLBACKS_NEW;
# else
#else
return KniDeviceList::CALLBACKS_OLD;
# endif
#endif
}

bool KniDeviceList::isCallbackSupported(const KniCallbackType cbType)
Expand All @@ -159,11 +159,11 @@ namespace pcpp
case KniDeviceList::CALLBACK_MAC:
/* fall through */
case KniDeviceList::CALLBACK_PROMISC:
# if RTE_VERSION >= RTE_VERSION_NUM(18, 2, 0, 0)
#if RTE_VERSION >= RTE_VERSION_NUM(18, 2, 0, 0)
return true;
# else
#else
return false;
# endif
#endif
}
return false;
}
Expand Down
24 changes: 12 additions & 12 deletions Pcap++/src/LinuxNicInformationSocket.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# define LOG_MODULE UndefinedLogModule
#define LOG_MODULE UndefinedLogModule

# include "Logger.h"
# include "LinuxNicInformationSocket.h"
#include "Logger.h"
#include "LinuxNicInformationSocket.h"

# include <sys/types.h>
# include <unistd.h>
# include <sys/socket.h>
# include <sys/ioctl.h>
# include <net/if.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <net/if.h>

# include <cerrno>
# include <cstdio>
# include <cstring>
#include <cerrno>
#include <cstdio>
#include <cstring>

# define INVALID_SOCKET_VALUE (-1)
#define INVALID_SOCKET_VALUE (-1)

namespace pcpp
{
Expand Down
38 changes: 19 additions & 19 deletions Pcap++/src/MBufRawPacket.cpp
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
// GCOVR_EXCL_START

# define LOG_MODULE PcapLogModuleMBufRawPacket
#define LOG_MODULE PcapLogModuleMBufRawPacket

# define __STDC_LIMIT_MACROS
# define __STDC_FORMAT_MACROS
#define __STDC_LIMIT_MACROS
#define __STDC_FORMAT_MACROS

# include "rte_mbuf.h"
# include "rte_mempool.h"
# include "rte_errno.h"
#include "rte_mbuf.h"
#include "rte_mempool.h"
#include "rte_errno.h"

# include "MBufRawPacket.h"
# include "Logger.h"
# include "DpdkDevice.h"
# ifdef USE_DPDK_KNI
# include "KniDevice.h"
# endif
#include "MBufRawPacket.h"
#include "Logger.h"
#include "DpdkDevice.h"
#ifdef USE_DPDK_KNI
# include "KniDevice.h"
#endif

# include <string>
# include <stdint.h>
# include <unistd.h>
#include <string>
#include <stdint.h>
#include <unistd.h>

namespace pcpp
{
Expand Down Expand Up @@ -68,12 +68,12 @@ namespace pcpp
return init(device->m_MBufMempool);
}

# ifdef USE_DPDK_KNI
#ifdef USE_DPDK_KNI
bool MBufRawPacket::init(KniDevice* device)
{
return init(device->m_MBufMempool);
}
# endif
#endif

bool MBufRawPacket::initFromRawPacket(const RawPacket* rawPacket, struct rte_mempool* mempool)
{
Expand Down Expand Up @@ -102,12 +102,12 @@ namespace pcpp
return initFromRawPacket(rawPacket, device->m_MBufMempool);
}

# ifdef USE_DPDK_KNI
#ifdef USE_DPDK_KNI
bool MBufRawPacket::initFromRawPacket(const RawPacket* rawPacket, KniDevice* device)
{
return initFromRawPacket(rawPacket, device->m_MBufMempool);
}
# endif
#endif

MBufRawPacket::MBufRawPacket(const MBufRawPacket& other)
{
Expand Down
8 changes: 4 additions & 4 deletions Pcap++/src/PcapRemoteDevice.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# define LOG_MODULE PcapLogModuleRemoteDevice
#define LOG_MODULE PcapLogModuleRemoteDevice

# include "PcapRemoteDevice.h"
# include "Logger.h"
# include "pcap.h"
#include "PcapRemoteDevice.h"
#include "Logger.h"
#include "pcap.h"

namespace pcpp
{
Expand Down
20 changes: 10 additions & 10 deletions Pcap++/src/PcapRemoteDeviceList.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# define LOG_MODULE PcapLogModuleRemoteDevice

# include "PcapRemoteDeviceList.h"
# include "Logger.h"
# include "IpUtils.h"
# include "PcapUtils.h"
# include "IpAddressUtils.h"
# include "pcap.h"
# include <array>
# include <ws2tcpip.h>
#define LOG_MODULE PcapLogModuleRemoteDevice

#include "PcapRemoteDeviceList.h"
#include "Logger.h"
#include "IpUtils.h"
#include "PcapUtils.h"
#include "IpAddressUtils.h"
#include "pcap.h"
#include <array>
#include <ws2tcpip.h>

namespace pcpp
{
Expand Down
22 changes: 11 additions & 11 deletions Pcap++/src/PfRingDevice.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// GCOVR_EXCL_START

# define LOG_MODULE PcapLogModulePfRingDevice
#define LOG_MODULE PcapLogModulePfRingDevice

# include "PfRingDevice.h"
# include "EthLayer.h"
# include "VlanLayer.h"
# include "Logger.h"
# include <errno.h>
# include <pfring.h>
# include <pthread.h>
# include <chrono>
#include "PfRingDevice.h"
#include "EthLayer.h"
#include "VlanLayer.h"
#include "Logger.h"
#include <errno.h>
#include <pfring.h>
#include <pthread.h>
#include <chrono>

# define DEFAULT_PF_RING_SNAPLEN 1600
#define DEFAULT_PF_RING_SNAPLEN 1600

namespace pcpp
{
Expand Down Expand Up @@ -758,7 +758,7 @@ namespace pcpp

uint8_t flushTxAsUint = (flushTxQueues ? 1 : 0);

# define MAX_TRIES 5
#define MAX_TRIES 5

int tries = 0;
int res = 0;
Expand Down
Loading

0 comments on commit 926aceb

Please sign in to comment.