Changeset ca87bcd


Ignore:
Timestamp:
08/23/05 16:04:06 (15 years ago)
Author:
Daniel Lawson <dlawson@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, getfragoff, help, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
Children:
e01bfa8
Parents:
06b2bcf
Message:

fixed API_VERSION define
added missing timestamp format conversions

Location:
lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • lib/libtrace.h

    r4d5a9a7 rca87bcd  
    3535#include <netinet/in.h>
    3636
    37 /** API version as 3 byte hex digits */
    38 #define LIBTRACE_API_VERSION 0x010014
     37/** API version as 3 byte hex digits, eg 0xXXYYZZ */
     38#define LIBTRACE_API_VERSION 0x100014
    3939
    4040#ifdef __cplusplus
  • lib/trace.c

    r4d5a9a7 rca87bcd  
    780780uint64_t trace_get_erf_timestamp(const struct libtrace_packet_t *packet) {
    781781        uint64_t timestamp = 0;
     782        double seconds = 0.0;
    782783        struct timeval ts;
    783784
    784785        if (packet->trace->format->get_erf_timestamp) {
     786                // timestamp -> timestamp
    785787                timestamp = packet->trace->format->get_erf_timestamp(packet);
    786788        } else if (packet->trace->format->get_timeval) {
     789                // timeval -> timestamp
    787790                ts = packet->trace->format->get_timeval(packet);
    788791                timestamp = ((((uint64_t)ts.tv_sec) << 32) + \
    789792                                (((uint64_t)ts.tv_usec * UINT_MAX)/1000000));
    790         }
     793        } else if (packet->trace->format->get_seconds) {
     794                // seconds -> timestamp
     795                seconds = packet->trace->format->get_seconds(packet);
     796                timestamp = (((uint32_t)seconds) << 32) + \
     797                            (( seconds - (uint32_t)seconds   ) * UINT_MAX);
     798        }
    791799        return timestamp;
    792800}
     
    802810        struct timeval tv;
    803811        uint64_t ts = 0;
    804 
     812        double seconds = 0.0
    805813        if (packet->trace->format->get_timeval) {
     814                // timeval -> timeval
    806815                tv = packet->trace->format->get_timeval(packet);
    807816        } else if (packet->trace->format->get_erf_timestamp) {
     817                // timestamp -> timeval
    808818                ts = packet->trace->format->get_erf_timestamp(packet);
    809819#if __BYTE_ORDER == __BIG_ENDIAN
     
    821831                        tv.tv_sec += 1;
    822832                }
     833        } else if (packet->trace->format->get_seconds) {
     834                // seconds -> timeval
     835                seconds = packet->trace->format->get_seconds(packet);
     836                tv.tv_sec = (uint32_t)seconds;
     837                tv.tv_usec = (uint32_t)(((seconds - tv.tv_sec) * 1000000)/UINT_MAX);
    823838        }
    824839
     
    834849        double seconds;
    835850        uint64_t ts;
     851        struct timeval tv;
    836852       
    837853        if (packet->trace->format->get_seconds) {
     854                // seconds->seconds
    838855                seconds = packet->trace->format->get_seconds(packet);
    839856        } else if (packet->trace->format->get_erf_timestamp) {
     857                // timestamp -> seconds
    840858                ts = packet->trace->format->get_erf_timestamp(packet);
    841859                seconds =  (ts>>32) + ((ts & UINT_MAX)*1.0 / UINT_MAX);
    842         }
     860        } else if (packet->trace->format->get_timeval) {
     861                // timeval -> seconds
     862                tv = packet->trace->format->get_timeval(packet);
     863                seconds = tv.tv_sec + ((tv.tv_usec * UINT_MAX * 1.0)/1000000);
     864        }
     865
    843866        return seconds;
    844867}
Note: See TracChangeset for help on using the changeset viewer.