2013-02-26 00:56:44 +08:00
|
|
|
/*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that: (1) source code
|
|
|
|
* distributions retain the above copyright notice and this paragraph
|
|
|
|
* in its entirety, and (2) distributions including binary code include
|
|
|
|
* the above copyright notice and this paragraph in its entirety in
|
|
|
|
* the documentation or other materials provided with the distribution.
|
|
|
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND
|
|
|
|
* WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
|
|
|
|
* LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE.
|
|
|
|
*
|
|
|
|
* Original code by Francesco Fondelli (francesco dot fondelli, gmail dot com)
|
|
|
|
*/
|
|
|
|
|
2016-08-15 21:27:28 +08:00
|
|
|
/* \summary: Virtual eXtensible Local Area Network (VXLAN) printer */
|
|
|
|
|
|
|
|
/* specification: RFC 7348 */
|
|
|
|
|
2018-01-22 04:27:08 +08:00
|
|
|
#include <config.h>
|
2013-02-26 00:56:44 +08:00
|
|
|
|
2018-01-20 22:59:49 +08:00
|
|
|
#include "netdissect-stdinc.h"
|
2013-02-26 00:56:44 +08:00
|
|
|
|
2020-10-11 21:01:40 +08:00
|
|
|
#define ND_LONGJMP_FROM_TCHECK
|
2015-09-06 05:35:58 +08:00
|
|
|
#include "netdissect.h"
|
2013-02-26 00:56:44 +08:00
|
|
|
#include "extract.h"
|
|
|
|
|
2023-06-08 07:59:43 +08:00
|
|
|
#define VXLAN_I 0x08 /* Instance Bit */
|
|
|
|
|
2020-10-03 20:33:23 +08:00
|
|
|
static const struct tok vxlan_flags [] = {
|
2023-06-08 07:59:43 +08:00
|
|
|
{ VXLAN_I, "I" },
|
2020-10-03 20:33:23 +08:00
|
|
|
{ 0, NULL }
|
|
|
|
};
|
2016-02-01 03:27:48 +08:00
|
|
|
#define VXLAN_HDR_LEN 8
|
|
|
|
|
2013-02-26 00:56:44 +08:00
|
|
|
/*
|
2014-11-14 16:20:49 +08:00
|
|
|
* VXLAN header, RFC7348
|
|
|
|
* Virtual eXtensible Local Area Network (VXLAN): A Framework
|
|
|
|
* for Overlaying Virtualized Layer 2 Networks over Layer 3 Networks
|
2013-02-26 00:56:44 +08:00
|
|
|
*
|
|
|
|
* 0 1 2 3
|
|
|
|
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* |R|R|R|R|I|R|R|R| Reserved |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | VXLAN Network Identifier (VNI) | Reserved |
|
2014-01-02 10:27:54 +08:00
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
2013-02-26 00:56:44 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
2014-03-08 19:28:13 +08:00
|
|
|
vxlan_print(netdissect_options *ndo, const u_char *bp, u_int len)
|
2013-02-26 00:56:44 +08:00
|
|
|
{
|
2014-04-23 15:20:40 +08:00
|
|
|
uint8_t flags;
|
2014-01-02 10:27:54 +08:00
|
|
|
|
2018-03-14 23:54:17 +08:00
|
|
|
ndo->ndo_protocol = "vxlan";
|
2020-10-11 21:01:40 +08:00
|
|
|
nd_print_protocol_caps(ndo);
|
2016-02-01 03:27:48 +08:00
|
|
|
if (len < VXLAN_HDR_LEN)
|
2020-10-11 21:01:40 +08:00
|
|
|
goto invalid;
|
2013-02-26 00:56:44 +08:00
|
|
|
|
2018-06-16 23:23:21 +08:00
|
|
|
flags = GET_U_1(bp);
|
2020-10-11 21:01:40 +08:00
|
|
|
bp += 1;
|
2020-10-03 20:33:23 +08:00
|
|
|
ND_PRINT(", flags [%s] (0x%02x), ",
|
|
|
|
bittok2str_nosep(vxlan_flags, "invalid", flags), flags);
|
2020-10-11 21:01:40 +08:00
|
|
|
|
|
|
|
/* 1st Reserved */
|
|
|
|
bp += 3;
|
|
|
|
|
2023-06-08 07:59:43 +08:00
|
|
|
/*
|
|
|
|
* RFC 7348 says that the I flag MUST be set.
|
|
|
|
*/
|
|
|
|
if (flags & VXLAN_I)
|
|
|
|
ND_PRINT("vni %u\n", GET_BE_U_3(bp));
|
|
|
|
else
|
|
|
|
ND_PRINT("ERROR: I flag not set\n");
|
2020-10-11 21:01:40 +08:00
|
|
|
bp += 3;
|
2013-02-26 00:56:44 +08:00
|
|
|
|
2020-10-11 21:01:40 +08:00
|
|
|
/* 2nd Reserved */
|
|
|
|
ND_TCHECK_1(bp);
|
|
|
|
bp += 1;
|
|
|
|
|
2020-08-01 20:05:59 +08:00
|
|
|
ether_print(ndo, bp, len - VXLAN_HDR_LEN, ND_BYTES_AVAILABLE_AFTER(bp), NULL, NULL);
|
2016-02-01 03:27:48 +08:00
|
|
|
|
|
|
|
return;
|
|
|
|
|
2020-10-11 21:01:40 +08:00
|
|
|
invalid:
|
|
|
|
nd_print_invalid(ndo);
|
2013-02-26 00:56:44 +08:00
|
|
|
}
|