Changeset ca87bcd
- Timestamp:
- 08/23/05 16:04:06 (17 years ago)
- 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
- Location:
- lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/libtrace.h
r4d5a9a7 rca87bcd 35 35 #include <netinet/in.h> 36 36 37 /** API version as 3 byte hex digits */38 #define LIBTRACE_API_VERSION 0x 01001437 /** API version as 3 byte hex digits, eg 0xXXYYZZ */ 38 #define LIBTRACE_API_VERSION 0x100014 39 39 40 40 #ifdef __cplusplus -
lib/trace.c
r4d5a9a7 rca87bcd 780 780 uint64_t trace_get_erf_timestamp(const struct libtrace_packet_t *packet) { 781 781 uint64_t timestamp = 0; 782 double seconds = 0.0; 782 783 struct timeval ts; 783 784 784 785 if (packet->trace->format->get_erf_timestamp) { 786 // timestamp -> timestamp 785 787 timestamp = packet->trace->format->get_erf_timestamp(packet); 786 788 } else if (packet->trace->format->get_timeval) { 789 // timeval -> timestamp 787 790 ts = packet->trace->format->get_timeval(packet); 788 791 timestamp = ((((uint64_t)ts.tv_sec) << 32) + \ 789 792 (((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 } 791 799 return timestamp; 792 800 } … … 802 810 struct timeval tv; 803 811 uint64_t ts = 0; 804 812 double seconds = 0.0 805 813 if (packet->trace->format->get_timeval) { 814 // timeval -> timeval 806 815 tv = packet->trace->format->get_timeval(packet); 807 816 } else if (packet->trace->format->get_erf_timestamp) { 817 // timestamp -> timeval 808 818 ts = packet->trace->format->get_erf_timestamp(packet); 809 819 #if __BYTE_ORDER == __BIG_ENDIAN … … 821 831 tv.tv_sec += 1; 822 832 } 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); 823 838 } 824 839 … … 834 849 double seconds; 835 850 uint64_t ts; 851 struct timeval tv; 836 852 837 853 if (packet->trace->format->get_seconds) { 854 // seconds->seconds 838 855 seconds = packet->trace->format->get_seconds(packet); 839 856 } else if (packet->trace->format->get_erf_timestamp) { 857 // timestamp -> seconds 840 858 ts = packet->trace->format->get_erf_timestamp(packet); 841 859 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 843 866 return seconds; 844 867 }
Note: See TracChangeset
for help on using the changeset viewer.