@@ -157,10 +157,10 @@ packet_stats(const tcpreplay_stats_t *stats)
157157 }
158158
159159 if (diff_us >= 1000000 )
160- printf ("Actual: " COUNTER_SPEC " packets (" COUNTER_SPEC " bytes) sent in %zd.%02zd seconds. \n" ,
161- stats -> pkts_sent , stats -> bytes_sent , (ssize_t )diff .tv_sec , (ssize_t )(diff .tv_usec / (100 * 1000 )));
160+ printf ("Actual: " COUNTER_SPEC " packets (" COUNTER_SPEC " bytes) sent in %zd.%02zd seconds\n" ,
161+ stats -> pkts_sent , stats -> bytes_sent , (ssize_t )diff .tv_sec , (ssize_t )(diff .tv_usec / (10 * 1000 )));
162162 else
163- printf ("Actual: " COUNTER_SPEC " packets (" COUNTER_SPEC " bytes) sent in %zd.%06zd seconds. \n" ,
163+ printf ("Actual: " COUNTER_SPEC " packets (" COUNTER_SPEC " bytes) sent in %zd.%06zd seconds\n" ,
164164 stats -> pkts_sent , stats -> bytes_sent , (ssize_t )diff .tv_sec , (ssize_t )diff .tv_usec );
165165
166166
@@ -177,6 +177,29 @@ packet_stats(const tcpreplay_stats_t *stats)
177177 stats -> failed );
178178}
179179
180+ /**
181+ * fills a buffer with a string representing the given time
182+ *
183+ * @param when: the time that should be formatted
184+ * @param buf: a buffer to write to
185+ * @param len: length of the buffer
186+ * @return: string containing date, or -1 on error
187+ */
188+ int format_date_time (struct timeval * when , char * buf , size_t len )
189+ {
190+ struct tm * tm ;
191+ char tmp [64 ];
192+
193+ assert (len );
194+
195+ tm = localtime (& when -> tv_sec );
196+ if (!tm )
197+ return -1 ;
198+
199+ strftime (tmp , sizeof tmp , "%Y-%m-%d %H:%M:%S.%%06u" , tm );
200+ return snprintf (buf , len , tmp , when -> tv_usec );
201+ }
202+
180203/**
181204 * reads a hexstring in the format of xx,xx,xx,xx spits it back into *hex
182205 * up to hexlen bytes. Returns actual number of bytes returned. On error
0 commit comments