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"
50 static bool g_vxlan_enabled =
true;
51 static 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)
79 static void DecodeVXLANConfigPorts(
const char *pstr)
86 g_vxlan_ports_idx = 0;
92 g_vxlan_ports[g_vxlan_ports_idx++] = (int)p->port;
101 if (
ConfGetBool(
"decoder.vxlan.enabled", &enabled) == 1) {
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");
198 static 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
237 static 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");