]> The Tcpdump Group git mirrors - tcpdump/blob - print-arista.c
New ethertype protocol for Arista Networks
[tcpdump] / print-arista.c
1 // Copyright (c) 2018 Arista Networks, Inc. All rights reserved.
2
3 #ifdef HAVE_CONFIG_H
4 #include "config.h"
5 #endif
6
7 #include <netdissect-stdinc.h>
8
9 #include <string.h>
10
11 #include "netdissect.h"
12 #include "interface.h"
13 #include "extract.h"
14 #include "addrtoname.h"
15
16 #define ARISTA_SUBTYPE_TIMESTAMP 0x01
17
18 #define ARISTA_TIMESTAMP_V1 0x10
19 #define ARISTA_TIMESTAMP_V2 0x20
20
21 int
22 arista_print_ethertype(netdissect_options *ndo, const u_char *bp, u_int len _U_)
23 {
24 uint16_t subTypeId;
25 uint16_t version;
26 u_short bytesConsumed = 0;
27 u_short size = 0;
28
29 ndo->ndo_protocol = "arista";
30
31 subTypeId = GET_BE_U_2(bp);
32 bp += 2;
33 version = GET_BE_U_2(bp);
34 bp += 2;
35 bytesConsumed += 4;
36
37 ND_PRINT("SubType: 0x%1X, Version: 0x%02x, ", subTypeId, version);
38
39 // TapAgg Header Timestamping
40 if (subTypeId == ARISTA_SUBTYPE_TIMESTAMP) {
41 // Timestamp has 32-bit lsb in nanosec and remaining msb in sec
42
43 switch (version) {
44 case ARISTA_TIMESTAMP_V1:
45 ND_PRINT("Timestamp TAI(64-bit)");
46 ND_PRINT(": Seconds: %u,", GET_BE_U_4(bp));
47 ND_PRINT(" Nanoseconds: %u, ", GET_BE_U_4(bp + 4));
48 bytesConsumed += size + 8;
49 break;
50 case ARISTA_TIMESTAMP_V2:
51 ND_PRINT("Timestamp (48-bit)");
52 ND_PRINT(": Seconds %u,", GET_BE_U_2(bp));
53 ND_PRINT(" Nanoseconds %u, ", GET_BE_U_4(bp + 2));
54 bytesConsumed += size + 6;
55 break;
56 default:
57 ND_PRINT("Unknown timestamp Version 0x%02X ", version);
58 return -1;
59 }
60 } else {
61 return -1;
62 }
63 return bytesConsumed;
64 }