]>
The Tcpdump Group git mirrors - tcpdump/blob - print-arista.c
1 // Copyright (c) 2018 Arista Networks, Inc. All rights reserved.
3 /* \summary: EtherType protocol for Arista Networks printer */
9 #include "netdissect-stdinc.h"
13 #include "netdissect.h"
15 #include "addrtoname.h"
17 #define ARISTA_SUBTYPE_TIMESTAMP 0x01
19 #define ARISTA_TIMESTAMP_64_TAI 0x0010
20 #define ARISTA_TIMESTAMP_64_UTC 0x0110
21 #define ARISTA_TIMESTAMP_48_TAI 0x0020
22 #define ARISTA_TIMESTAMP_48_UTC 0x0120
24 static const struct tok ts_version_name
[] = {
25 { ARISTA_TIMESTAMP_64_TAI
, "TAI(64-bit)" },
26 { ARISTA_TIMESTAMP_64_UTC
, "UTC(64-bit)" },
27 { ARISTA_TIMESTAMP_48_TAI
, "TAI(48-bit)" },
28 { ARISTA_TIMESTAMP_48_UTC
, "UTC(48-bit)" },
33 arista_print_date_hms_time(netdissect_options
*ndo
, uint32_t seconds
,
40 ts
= seconds
+ (nanoseconds
/ 1000000000);
41 if (NULL
== (tm
= gmtime(&ts
)))
42 ND_PRINT(": gmtime() error");
43 else if (0 == strftime(buf
, sizeof(buf
), "%Y-%m-%d %H:%M:%S", tm
))
44 ND_PRINT(": strftime() error");
46 ND_PRINT(": %s, %09u ns, ", buf
, nanoseconds
);
50 arista_ethertype_print(netdissect_options
*ndo
, const u_char
*bp
, u_int len _U_
)
54 u_short bytesConsumed
= 0;
56 uint32_t seconds
, nanoseconds
;
58 ndo
->ndo_protocol
= "arista";
60 subTypeId
= GET_BE_U_2(bp
);
62 version
= GET_BE_U_2(bp
);
66 ND_PRINT("SubType: 0x%1x, Version: 0x%04x, ", subTypeId
, version
);
68 // TapAgg Header Timestamping
69 if (subTypeId
== ARISTA_SUBTYPE_TIMESTAMP
) {
70 // Timestamp has 32-bit lsb in nanosec and remaining msb in sec
71 ND_PRINT("Timestamp %s", tok2str(ts_version_name
,
72 "Unknown timestamp Version 0x%04x ", version
));
74 case ARISTA_TIMESTAMP_64_TAI
:
75 case ARISTA_TIMESTAMP_64_UTC
:
76 seconds
= GET_BE_U_4(bp
);
77 nanoseconds
= GET_BE_U_4(bp
+ 4);
78 arista_print_date_hms_time(ndo
, seconds
, nanoseconds
);
79 bytesConsumed
+= size
+ 8;
81 case ARISTA_TIMESTAMP_48_TAI
:
82 case ARISTA_TIMESTAMP_48_UTC
:
83 ND_PRINT(": Seconds %u,", GET_BE_U_2(bp
));
84 ND_PRINT(" Nanoseconds %u, ", GET_BE_U_4(bp
+ 2));
85 bytesConsumed
+= size
+ 6;