@@ -422,6 +422,9 @@ typedef struct _SFSample {
422422 /* counter blocks */
423423 uint32_t statsSamplingInterval ;
424424 uint32_t counterBlockVersion ;
425+
426+ /* timetamp */
427+ uint64_t timestamp_nS ;
425428 } s ;
426429
427430 /* exception handler context */
@@ -1103,6 +1106,17 @@ static char *printTimestamp(time_t ts, SFStr *sb) {
11031106 return SFStr_str (sb );
11041107}
11051108
1109+ static char * printTimestamp_nS (uint64_t nS , SFStr * sb ) {
1110+ SFStr_init (sb );
1111+ uint64_t gig = (uint64_t )1e9 ;
1112+ time_t ts = nS / gig ;
1113+ uint64_t fract = nS % gig ;
1114+ SFStr_append_timestamp (sb , ts );
1115+ SFStr_append (sb , "." );
1116+ SFStr_append_U64 (sb , "%" PRIu64 , fract );
1117+ return SFStr_str (sb );
1118+ }
1119+
11061120static char * printOUI (uint8_t * oui , SFStr * sb ) {
11071121 SFStr_init (sb );
11081122 SFStr_append_hex (sb , oui , 3 , NO , YES , '-' );
@@ -3896,6 +3910,20 @@ static void readExtendedLinuxReason(SFSample *sample)
38963910 }
38973911}
38983912
3913+ /*_________________----------------------------__________________
3914+ _________________ readExtendedTimestamp __________________
3915+ -----------------____________________________------------------
3916+ */
3917+
3918+ static void readExtendedTimestamp (SFSample * sample )
3919+ {
3920+ SFStr buf ;
3921+ sf_logf (sample , "extendedType" , "timestamp" );
3922+ sample -> s .timestamp_nS = getData64 (sample );
3923+ sf_logf_U64 (sample , "timestamp_nS" , sample -> s .timestamp_nS );
3924+ // sf_logf(sample, "timestamp_fmt", printTimestamp_nS(sample->s.timestamp_nS, &buf));
3925+ }
3926+
38993927/*_________________---------------------------__________________
39003928 _________________ readFlowSample_v2v4 __________________
39013929 -----------------___________________________------------------
@@ -4091,6 +4119,7 @@ static void readFlowSampleElements(SFSample *sample)
40914119 case SFLFLOW_EX_EGRESS_Q : readExtendedEgressQueue (sample ); break ;
40924120 case SFLFLOW_EX_TRANSIT : readExtendedTransitDelay (sample ); break ;
40934121 case SFLFLOW_EX_Q_DEPTH : readExtendedQueueDepth (sample ); break ;
4122+ case SFLFLOW_EX_TIMESTAMP : readExtendedTimestamp (sample ); break ;
40944123 /* In discard samples, any of the above may appear along with the following. */
40954124 case SFLFLOW_EX_FUNCTION : readExtendedFunction (sample ); break ;
40964125 case SFLFLOW_EX_HW_TRAP : readExtendedHardwareTrap (sample ); break ;
0 commit comments