]>
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"
14 #include "interface.h"
16 #include "addrtoname.h"
18 #define ARISTA_SUBTYPE_TIMESTAMP 0x01
20 #define ARISTA_TIMESTAMP_64_TAI 0x0010
21 #define ARISTA_TIMESTAMP_64_UTC 0x0110
22 #define ARISTA_TIMESTAMP_48_TAI 0x0020
23 #define ARISTA_TIMESTAMP_48_UTC 0x0120
25 static const struct tok ts_version_name
[] = {
26 { ARISTA_TIMESTAMP_64_TAI
, "TAI(64-bit)" },
27 { ARISTA_TIMESTAMP_64_UTC
, "UTC(64-bit)" },
28 { ARISTA_TIMESTAMP_48_TAI
, "TAI(48-bit)" },
29 { ARISTA_TIMESTAMP_48_UTC
, "UTC(48-bit)" },
34 arista_print_date_hms_time(netdissect_options
*ndo
, uint32_t seconds
,
41 ts
= seconds
+ (nanoseconds
/ 1000000000);
42 if (NULL
== (tm
= gmtime(&ts
)))
43 ND_PRINT(": gmtime() error");
44 else if (0 == strftime(buf
, sizeof(buf
), "%Y-%m-%d %H:%M:%S", tm
))
45 ND_PRINT(": strftime() error");
47 ND_PRINT(": %s, %09u ns, ", buf
, nanoseconds
);
51 arista_ethertype_print(netdissect_options
*ndo
, const u_char
*bp
, u_int len _U_
)
55 u_short bytesConsumed
= 0;
57 uint32_t seconds
, nanoseconds
;
59 ndo
->ndo_protocol
= "arista";
61 subTypeId
= GET_BE_U_2(bp
);
63 version
= GET_BE_U_2(bp
);
67 ND_PRINT("SubType: 0x%1x, Version: 0x%04x, ", subTypeId
, version
);
69 // TapAgg Header Timestamping
70 if (subTypeId
== ARISTA_SUBTYPE_TIMESTAMP
) {
71 // Timestamp has 32-bit lsb in nanosec and remaining msb in sec
72 ND_PRINT("Timestamp %s", tok2str(ts_version_name
,
73 "Unknown timestamp Version 0x%04x ", version
));
75 case ARISTA_TIMESTAMP_64_TAI
:
76 case ARISTA_TIMESTAMP_64_UTC
:
77 seconds
= GET_BE_U_4(bp
);
78 nanoseconds
= GET_BE_U_4(bp
+ 4);
79 arista_print_date_hms_time(ndo
, seconds
, nanoseconds
);
80 bytesConsumed
+= size
+ 8;
82 case ARISTA_TIMESTAMP_48_TAI
:
83 case ARISTA_TIMESTAMP_48_UTC
:
84 ND_PRINT(": Seconds %u,", GET_BE_U_2(bp
));
85 ND_PRINT(" Nanoseconds %u, ", GET_BE_U_4(bp
+ 2));
86 bytesConsumed
+= size
+ 6;