summaryrefslogtreecommitdiff
path: root/print-arista.c
diff options
context:
space:
mode:
authorniks3089 <niks3089@gmail.com>2019-05-18 06:18:30 -0700
committerfxlb <devel.fx.lebail@orange.fr>2019-05-23 11:06:14 +0200
commite2f14ebc87586ecad6901c09a1cb7e371baf2ea1 (patch)
tree6a5ed3aec7769a042f69bd298ca8ab2616ca4b04 /print-arista.c
parent05544c8eb2d3b6c9f0ccd25d9ea0f28515976adf (diff)
downloadtcpdump-e2f14ebc87586ecad6901c09a1cb7e371baf2ea1.tar.gz
New ethertype protocol for Arista Networks
Diffstat (limited to 'print-arista.c')
-rw-r--r--print-arista.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/print-arista.c b/print-arista.c
new file mode 100644
index 00000000..38dd724a
--- /dev/null
+++ b/print-arista.c
@@ -0,0 +1,64 @@
+// Copyright (c) 2018 Arista Networks, Inc. All rights reserved.
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <netdissect-stdinc.h>
+
+#include <string.h>
+
+#include "netdissect.h"
+#include "interface.h"
+#include "extract.h"
+#include "addrtoname.h"
+
+#define ARISTA_SUBTYPE_TIMESTAMP 0x01
+
+#define ARISTA_TIMESTAMP_V1 0x10
+#define ARISTA_TIMESTAMP_V2 0x20
+
+int
+arista_print_ethertype(netdissect_options *ndo, const u_char *bp, u_int len _U_)
+{
+ uint16_t subTypeId;
+ uint16_t version;
+ u_short bytesConsumed = 0;
+ u_short size = 0;
+
+ ndo->ndo_protocol = "arista";
+
+ subTypeId = GET_BE_U_2(bp);
+ bp += 2;
+ version = GET_BE_U_2(bp);
+ bp += 2;
+ bytesConsumed += 4;
+
+ ND_PRINT("SubType: 0x%1X, Version: 0x%02x, ", subTypeId, version);
+
+ // TapAgg Header Timestamping
+ if (subTypeId == ARISTA_SUBTYPE_TIMESTAMP) {
+ // Timestamp has 32-bit lsb in nanosec and remaining msb in sec
+
+ switch (version) {
+ case ARISTA_TIMESTAMP_V1:
+ ND_PRINT("Timestamp TAI(64-bit)");
+ ND_PRINT(": Seconds: %u,", GET_BE_U_4(bp));
+ ND_PRINT(" Nanoseconds: %u, ", GET_BE_U_4(bp + 4));
+ bytesConsumed += size + 8;
+ break;
+ case ARISTA_TIMESTAMP_V2:
+ ND_PRINT("Timestamp (48-bit)");
+ ND_PRINT(": Seconds %u,", GET_BE_U_2(bp));
+ ND_PRINT(" Nanoseconds %u, ", GET_BE_U_4(bp + 2));
+ bytesConsumed += size + 6;
+ break;
+ default:
+ ND_PRINT("Unknown timestamp Version 0x%02X ", version);
+ return -1;
+ }
+ } else {
+ return -1;
+ }
+ return bytesConsumed;
+}