43#define VXLAN_HEADER_LEN sizeof(VXLANHeader)
45#define VXLAN_MAX_PORTS 4
46#define VXLAN_UNSET_PORT -1
47#define VXLAN_DEFAULT_PORT 4789
48#define VXLAN_DEFAULT_PORT_S "4789"
50static bool g_vxlan_enabled =
true;
51static int g_vxlan_ports_idx = 0;
64 SCLogDebug(
"ports %u->%u ports %d %d %d %d", sp, dp, g_vxlan_ports[0], g_vxlan_ports[1],
65 g_vxlan_ports[2], g_vxlan_ports[3]);
67 if (g_vxlan_enabled) {
68 for (
int i = 0; i < g_vxlan_ports_idx; i++) {
71 const int port = g_vxlan_ports[i];
72 if (port == (
const int)sp || port == (
const int)dp)
79static void DecodeVXLANConfigPorts(
const char *pstr)
86 g_vxlan_ports_idx = 0;
92 g_vxlan_ports[g_vxlan_ports_idx++] = (int)p->port;
103 g_vxlan_enabled =
true;
105 g_vxlan_enabled =
false;
109 if (g_vxlan_enabled) {
111 if (node && node->
val) {
112 DecodeVXLANConfigPorts(node->
val);
123 const uint8_t *pkt, uint32_t
len)
133 if (!PacketIncreaseCheckLayers(p)) {
138 if ((vxlanh->
flags[0] & 0x08) == 0 || vxlanh->
res != 0)
142 uint32_t vni = (vxlanh->
vni[0] << 16) + (vxlanh->
vni[1] << 8) + (vxlanh->
vni[2]);
175 SCLogDebug(
"VXLAN found unsupported Ethertype - expected IPv4, IPv6, VLAN, or ARP");
198static int DecodeVXLANtest01 (
void)
200 uint8_t raw_vxlan[] = {
201 0x12, 0xb5, 0x12, 0xb5, 0x00, 0x3a, 0x87, 0x51,
202 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x25, 0x00,
203 0x10, 0x00, 0x00, 0x0c, 0x01, 0x00,
204 0x00, 0x51, 0x52, 0xb3, 0x54, 0xe5,
206 0x45, 0x00, 0x00, 0x1c, 0x00, 0x01, 0x00, 0x00, 0x40, 0x11,
207 0x44, 0x45, 0x0a, 0x60, 0x00, 0x0a, 0xb9, 0x1b, 0x73, 0x06,
208 0x00, 0x35, 0x30, 0x39, 0x00, 0x08, 0x98, 0xe4
237static int DecodeVXLANtest02 (
void)
239 uint8_t raw_vxlan[] = {
240 0x12, 0xb5, 0x12, 0xb5, 0x00, 0x3a, 0x87, 0x51,
241 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x25, 0x00,
242 0x10, 0x00, 0x00, 0x0c, 0x01, 0x00,
243 0x00, 0x51, 0x52, 0xb3, 0x54, 0xe5,
245 0x45, 0x00, 0x00, 0x1c, 0x00, 0x01, 0x00, 0x00, 0x40, 0x11,
246 0x44, 0x45, 0x0a, 0x60, 0x00, 0x0a, 0xb9, 0x1b, 0x73, 0x06,
247 0x00, 0x35, 0x30, 0x39, 0x00, 0x08, 0x98, 0xe4
256 DecodeVXLANConfigPorts(
"1");
SCConfNode * SCConfGetNode(const char *name)
Get a SCConfNode by name.
int SCConfGetBool(const char *name, int *val)
Retrieve a configuration value as a boolean.
void StatsIncr(ThreadVars *tv, uint16_t id)
Increments the local counter.
#define ETHERNET_TYPE_ARP
#define ETHERNET_TYPE_8021QINQ
#define ETHERNET_HEADER_LEN
#define ETHERNET_TYPE_IPV6
#define ETHERNET_TYPE_8021AD
@ VXLAN_UNKNOWN_PAYLOAD_TYPE
int DecodeUDP(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint16_t len)
#define ETHERNET_TYPE_VLAN
int DecodeVXLAN(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
struct VXLANHeader_ VXLANHeader
void DecodeVXLANConfig(void)
void DecodeVXLANRegisterTests(void)
bool DecodeVXLANEnabledForPort(const uint16_t sp, const uint16_t dp)
#define VXLAN_DEFAULT_PORT_S
#define VXLAN_DEFAULT_PORT
#define PKT_SET_SRC(p, src_val)
#define ENGINE_SET_INVALID_EVENT(p, e)
int DetectPortParse(const DetectEngineCtx *de_ctx, DetectPort **head, const char *str)
Function for parsing port strings.
void DetectPortCleanupList(const DetectEngineCtx *de_ctx, DetectPort *head)
Free a DetectPort list and each of its members.
void FlowInitConfig(bool quiet)
initialize the configuration
void FlowShutdown(void)
shutdown the flow engine
#define FAIL_IF_NULL(expr)
Fail a test if expression evaluates to NULL.
void UtRegisterTest(const char *name, int(*TestFn)(void))
Register unit test.
#define FAIL_IF_NOT(expr)
Fail a test if expression evaluates to false.
#define PASS
Pass the test.
#define FAIL_IF(expr)
Fail a test if expression evaluates to true.
Packet * PacketGetFromAlloc(void)
Get a malloced packet.
Packet * PacketTunnelPktSetup(ThreadVars *tv, DecodeThreadVars *dtv, Packet *parent, const uint8_t *pkt, uint32_t len, enum DecodeTunnelProto proto)
Setup a pseudo packet (tunnel)
void PacketFreeOrRelease(Packet *p)
Return a packet to where it was allocated.
void PacketFree(Packet *p)
Return a malloced packet.
void PacketEnqueueNoLock(PacketQueueNoLock *qnl, Packet *p)
Packet * PacketDequeueNoLock(PacketQueueNoLock *qnl)
Structure to hold thread specific data for all decode modules.
Port structure for detection engine.
Per thread variable structure.
PacketQueueNoLock decode_pq
#define SCLogWarning(...)
Macro used to log WARNING messages.
#define DEBUG_VALIDATE_BUG_ON(exp)