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