head 1.2; access; symbols; locks; strict; comment @ * @; 1.2 date 2008.04.28.17.49.30; author wessels; state Exp; branches; next 1.1; 1.1 date 2008.04.21.23.39.06; author wessels; state Exp; branches; next ; desc @@ 1.2 log @fix time_t problems @ text @#include #include #include #include #include #include #include #include int main(int argc, char *argv[]) { pcap_t *in = NULL; pcap_dumper_t *out = NULL; char errbuf[PCAP_ERRBUF_SIZE + 1]; struct pcap_pkthdr hdr; const u_char *data; char ttime[32]; struct timeval adjust; long long int L1; long long int L2; if (argc < 2) { fprintf(stderr, "usage: tcpdump-adjust-timestamp adjust\n"); exit(1); } snprintf(ttime, 32, "%8.6f", atof(argv[1])); if (2 != sscanf(ttime, "%lld.%lld", &L1, &L2)) { fprintf(stderr, "bad adjust time: %s\n", argv[1]); exit(1); } adjust.tv_sec = (time_t) L1; adjust.tv_usec = (time_t) L2; fprintf(stderr, "adjusting timestamps by %lld.%06lld sec\n", (long long int) adjust.tv_sec, (long long int) adjust.tv_usec); in = pcap_open_offline("-", errbuf); if (NULL == in) { fprintf(stderr, "stdin: %s", errbuf); exit(1); } out = pcap_dump_open(in, "-"); if (NULL == out) { perror("stdout"); exit(1); } while ((data = pcap_next(in, &hdr))) { struct timeval result; timersub(&hdr.ts, &adjust, &result); hdr.ts = result; pcap_dump((void *)out, &hdr, data); } pcap_close(in); if (out) pcap_dump_close(out); exit(0); } @ 1.1 log @Initial revision @ text @d20 2 d30 1 a30 1 if (2 != sscanf(ttime, "%d.%d", &adjust.tv_sec, &adjust.tv_usec)) { d34 4 a37 2 fprintf(stderr, "adjusting timestamps by %d.%06d sec\n", adjust.tv_sec, adjust.tv_usec); @