]>
The Tcpdump Group git mirrors - tcpdump/blob - print-arista.c
63bf9dd80d0d8b73321a7fab6ad46c7fe00f69e3
1 // Copyright (c) 2018 Arista Networks, Inc. All rights reserved.
3 /* \summary: EtherType protocol for Arista Networks printer */
9 #include "netdissect-stdinc.h"
11 #include "netdissect.h"
18 The Arista timestamp header consists of the following fields:
19 1. The Arista ethertype (0xd28b)
20 2. A 2-byte subtype field; 0x01 indicates the timestamp header
21 3. A 2-byte version field, described below.
22 4. A 48-bit or 64-bit timestamp field, depending on the contents of the version field
24 This header is then followed by the original ethertype and the remainder of the original packet.
27 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
28 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
30 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
32 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +
34 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
35 | ethertype 0xd28b | subtype 0x1 |
36 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
38 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +
40 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
42 The two-byte version value is split into 3 fields:
43 1. The timescale in use. Currently assigned values include:
46 2. The timestamp format and length. Currently assigned values include:
54 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
55 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
56 | timescale | format|hw info|
57 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
60 See also: https://www.arista.com/assets/data/pdf/Whitepapers/Overview_Arista_Timestamps.pdf
64 #define ARISTA_SUBTYPE_TIMESTAMP 0x0001
65 static const struct tok subtype_str
[] = {
66 { ARISTA_SUBTYPE_TIMESTAMP
, "Timestamp" },
70 static const struct tok ts_timescale_str
[] = {
76 #define FORMAT_64BIT 0x1
77 #define FORMAT_48BIT 0x2
78 static const struct tok ts_format_str
[] = {
79 { FORMAT_64BIT
, "64-bit" },
80 { FORMAT_48BIT
, "48-bit" },
84 static const struct tok hw_info_str
[] = {
90 #define MAX_VALID_NS 999999999U
91 #define BOGUS_NS_STR "(bogus ns!)"
94 arista_print_date_hms_time(netdissect_options
*ndo
, const uint32_t seconds
,
95 const uint32_t nanoseconds
)
97 const time_t ts
= seconds
;
98 char buf
[sizeof("-yyyyyyyyyy-mm-dd hh:mm:ss")];
101 nd_format_time(buf
, sizeof(buf
), "%Y-%m-%d %H:%M:%S",
102 gmtime(&ts
)), nanoseconds
);
103 if (nanoseconds
> MAX_VALID_NS
)
104 ND_PRINT(" " BOGUS_NS_STR
);
108 arista_ethertype_print(netdissect_options
*ndo
, const u_char
*bp
, u_int len _U_
)
111 u_short bytesConsumed
= 0;
113 ndo
->ndo_protocol
= "arista";
115 subTypeId
= GET_BE_U_2(bp
);
119 ND_PRINT("SubType %s (0x%04x), ",
120 tok2str(subtype_str
, "Unknown", subTypeId
),
123 // TapAgg Header Timestamping
124 if (subTypeId
== ARISTA_SUBTYPE_TIMESTAMP
) {
126 uint32_t nanoseconds
;
127 uint8_t ts_timescale
= GET_U_1(bp
);
130 ND_PRINT("Timescale %s (%u), ",
131 tok2str(ts_timescale_str
, "Unknown", ts_timescale
),
134 uint8_t ts_format
= GET_U_1(bp
) >> 4;
135 uint8_t hw_info
= GET_U_1(bp
) & 0x0f;
139 // Timestamp has 32-bit lsb in nanosec and remaining msb in sec
140 ND_PRINT("Format %s (%u), HwInfo %s (%u), Timestamp ",
141 tok2str(ts_format_str
, "Unknown", ts_format
),
143 tok2str(hw_info_str
, "Unknown", hw_info
),
147 seconds
= GET_BE_U_4(bp
);
148 nanoseconds
= GET_BE_U_4(bp
+ 4);
149 arista_print_date_hms_time(ndo
, seconds
, nanoseconds
);
153 seconds
= GET_BE_U_2(bp
);
154 nanoseconds
= GET_BE_U_4(bp
+ 2);
155 ND_PRINT("%u.%09u", seconds
, nanoseconds
);
156 if (nanoseconds
> MAX_VALID_NS
)
157 ND_PRINT(" " BOGUS_NS_STR
);
167 return bytesConsumed
;