- Timestamp:
- 01/25/10 17:14:13 (12 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:
- 226c08b
- Parents:
- fc710bf
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/format_linux.c
rf68d5b8 r7fa118f 77 77 78 78 79 /* Note that this structure is passed over the wire in rt encapsulation, and thus we need to be 80 * careful with data sizes. timeval's and timespec's change their size on 32/64 machines 81 */ 79 82 struct libtrace_linuxnative_header { 80 struct timeval tv; 81 struct timespec ts; 82 timestamptype_t timestamptype; 83 int wirelen; 84 int caplen; 83 struct { 84 uint32_t tv_sec; 85 uint32_t tv_usec; 86 } tv; 87 struct { 88 uint32_t tv_sec; 89 uint32_t tv_nsec; 90 } ts; 91 uint8_t timestamptype; 92 uint32_t wirelen; 93 uint32_t caplen; 85 94 struct sockaddr_ll hdr; 86 95 }; … … 453 462 && cmsg->cmsg_type == SO_TIMESTAMP 454 463 && cmsg->cmsg_len <= CMSG_LEN(sizeof(struct timeval))) { 455 memcpy(&hdr->tv, CMSG_DATA(cmsg),456 sizeof(struct timeval));464 hdr->tv.tv_sec = ((struct timeval*)CMSG_DATA(cmsg))->tv_sec; 465 hdr->tv.tv_usec = ((struct timeval*)CMSG_DATA(cmsg))->tv_usec; 457 466 hdr->timestamptype = TS_TIMEVAL; 458 467 break; … … 462 471 && cmsg->cmsg_type == SO_TIMESTAMPNS 463 472 && cmsg->cmsg_len <= CMSG_LEN(sizeof(struct timespec))) { 464 memcpy(&hdr->ts, CMSG_DATA(cmsg),465 sizeof(struct timeval));473 hdr->ts.tv_sec = ((struct timespec*)CMSG_DATA(cmsg))->tv_sec; 474 hdr->ts.tv_nsec = ((struct timespec*)CMSG_DATA(cmsg))->tv_nsec; 466 475 hdr->timestamptype = TS_TIMESPEC; 467 476 break; … … 472 481 /* Did we not get given a timestamp? */ 473 482 if (cmsg == NULL) { 483 struct timeval tv; 474 484 if (ioctl(FORMAT(libtrace->format_data)->fd, 475 SIOCGSTAMP,&hdr->tv)==0) { 485 SIOCGSTAMP,&tv)==0) { 486 hdr->tv.tv_sec = tv.tv_sec; 487 hdr->tv.tv_usec = tv.tv_usec; 476 488 hdr->timestamptype = TS_TIMEVAL; 477 489 } … … 567 579 return ts; 568 580 } 569 else 570 return hdr->ts; 581 else { 582 struct timespec ts; 583 ts.tv_sec = hdr->ts.tv_sec; 584 ts.tv_nsec = hdr->ts.tv_nsec; 585 return ts; 586 } 571 587 } 572 588 … … 582 598 return tv; 583 599 } 584 else 585 return hdr->tv; 600 else { 601 struct timeval tv; 602 tv.tv_sec = hdr->tv.tv_sec; 603 tv.tv_usec = hdr->tv.tv_usec; 604 return tv; 605 } 586 606 } 587 607
Note: See TracChangeset
for help on using the changeset viewer.