Changeset 238d50a for lib/format_legacy.c
- Timestamp:
- 02/08/10 16:43:43 (11 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:
- d026488
- Parents:
- 5511c14
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/format_legacy.c
r1aa4bf7 r238d50a 2 2 * This file is part of libtrace 3 3 * 4 * Copyright (c) 2007,2008 The University of Waikato, Hamilton, New Zealand. 4 * Copyright (c) 2007,2008,2009,2010 The University of Waikato, Hamilton, 5 * New Zealand. 6 * 5 7 * Authors: Daniel Lawson 6 * Perry Lorier 8 * Perry Lorier 9 * Shane Alcock 7 10 * 8 11 * All rights reserved. … … 28 31 * 29 32 */ 33 30 34 #define _GNU_SOURCE 31 35 … … 51 55 #endif 52 56 57 /* The format module deals with legacy DAG formats from older revisions of the 58 * DAG hardware and software. Aside from a few minor differences, the legacy 59 * formats are very similar so we can deal with them using the same callback 60 * functions for the most part. 61 * 62 * These formats are intended for reading old ERF traces such as the earlier 63 * Auckland traces. 64 * 65 * We definitely do not support writing using these formats - one should 66 * convert packets to regular ERF instead before writing. 67 */ 68 69 /* Several formats are covered in this source file: 70 * 71 * Legacy Ethernet: as seen in Auckland VI 72 * Legacy ATM: as seen in Auckland II and IV 73 * Legacy PoS: as seen in Leipzig I and II 74 * Legacy NZIX: as seen in NZIX I 75 */ 53 76 54 77 /* Catch undefined O_LARGEFILE on *BSD etc */ … … 63 86 #define DATA(x) ((struct legacy_format_data_t *)x->format_data) 64 87 88 /* Legacy NZIX timestamps are all relative to the start of the trace, so we 89 * have to remember all sorts of stuff so that we can convert them into a 90 * useful timestamp */ 91 65 92 struct legacy_format_data_t { 66 time_t starttime; /* Used for legacy_nzix */ 67 uint64_t ts_high; /* Used for legacy_nzix */ 68 uint32_t ts_old; /* Used for legacy_nzix */ 93 time_t starttime; /* Time that the trace file was started */ 94 uint64_t ts_high; /* The timestamp of the last packet */ 95 uint32_t ts_old; /* The timestamp of the last packet as 96 reported in the NZIX header */ 69 97 }; 70 98 … … 104 132 } 105 133 134 /* Takes a trace file name and determines the time that the capture began. 135 * 136 * NZIX only features relative timestamps so the trace file name is the only 137 * indication we have of where the relative timestamping begins from 138 */ 106 139 static time_t trtime(char *s) { 107 140 /* XXX: this function may not be particularly portable to … … 143 176 144 177 legacy_init_format_data(libtrace); 178 179 /* Check that the filename appears to contain a suitable timestamp. 180 * Without it, we have no way of determining the actual timestamps 181 * for each packet */ 145 182 if((retval = regcomp(®, "[0-9]{8}-[0-9]{6}", REG_EXTENDED)) != 0) { 146 183 trace_set_err(libtrace, errno, "Failed to compile regex"); … … 155 192 } 156 193 194 /* All of the formats can be started in exactly the same way */ 157 195 static int erf_start_input(libtrace_t *libtrace) 158 196 { … … 291 329 } 292 330 293 /* lets move the padding so that it's in the framing header */331 /* Lets move the padding so that it's in the framing header */ 294 332 data_ptr = ((char *)buffer) + 12; 295 333 memmove(data_ptr + 2, data_ptr, 26); … … 392 430 hdr_ts = legacy->ts; 393 431 394 /* seems we only need 30 bits to represent our timestamp */432 /* Seems we only need 30 bits to represent our timestamp */ 395 433 hdr_ts >>=2; 396 /* try a sequence number wrap-around comparison */ 434 435 /* Try a sequence number wrap-around comparison */ 397 436 if (ts_cmp(hdr_ts, old_ts) > (UINT32_MAX / 2) ) 398 new_ts += (1LL << 30); /* wraparound */399 new_ts &= ~((1LL << 30) -1); /* mask lower 30 bits */400 new_ts += hdr_ts; /* packet ts is the new 30 bits */437 new_ts += (1LL << 30); /* Wraparound */ 438 new_ts &= ~((1LL << 30) -1); /* Mask lower 30 bits */ 439 new_ts += hdr_ts; /* Packet ts is the new 30 bits */ 401 440 DATA(packet->trace)->ts_old = hdr_ts; 402 441
Note: See TracChangeset
for help on using the changeset viewer.