Ignore:
Timestamp:
02/08/10 16:43:43 (11 years ago)
Author:
Shane Alcock <salcock@…>
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
Message:
  • Updated licensing and documentation for several format modules and the format_helper code
File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/format_legacy.c

    r1aa4bf7 r238d50a  
    22 * This file is part of libtrace
    33 *
    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 *
    57 * Authors: Daniel Lawson
    6  *          Perry Lorier
     8 *          Perry Lorier
     9 *          Shane Alcock
    710 *         
    811 * All rights reserved.
     
    2831 *
    2932 */
     33
    3034#define _GNU_SOURCE
    3135
     
    5155#endif
    5256
     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 */
    5376
    5477/* Catch undefined O_LARGEFILE on *BSD etc */
     
    6386#define DATA(x) ((struct legacy_format_data_t *)x->format_data)
    6487
     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
    6592struct 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 */
    6997};
    7098
     
    104132}
    105133
     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 */
    106139static time_t trtime(char *s) {
    107140        /* XXX: this function may not be particularly portable to
     
    143176
    144177        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 */
    145182        if((retval = regcomp(&reg, "[0-9]{8}-[0-9]{6}", REG_EXTENDED)) != 0) {
    146183                trace_set_err(libtrace, errno, "Failed to compile regex");
     
    155192}
    156193
     194/* All of the formats can be started in exactly the same way */
    157195static int erf_start_input(libtrace_t *libtrace)
    158196{
     
    291329        }
    292330
    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 */
    294332        data_ptr = ((char *)buffer) + 12;
    295333        memmove(data_ptr + 2, data_ptr, 26);
     
    392430        hdr_ts = legacy->ts;
    393431
    394         /* seems we only need 30 bits to represent our timestamp */
     432        /* Seems we only need 30 bits to represent our timestamp */
    395433        hdr_ts >>=2;
    396         /* try a sequence number wrap-around comparison */
     434       
     435        /* Try a sequence number wrap-around comparison */
    397436        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 */
    401440        DATA(packet->trace)->ts_old = hdr_ts;
    402441
Note: See TracChangeset for help on using the changeset viewer.