Changeset d57ae6f for lib


Ignore:
Timestamp:
05/14/13 17:17:57 (9 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:
808eeef
Parents:
0acfd1e
Message:

Added a new format: rawerf. This is a special format that will force ERF files to be opened and read without going through the compression autodetection. It will only work for uncompressed ERF files.

This should be a handy option for people who are working with lots of uncompressed ERF files -- running the compression autodetection against uncompressed ERF traces can very occasionally produce a false positive, i.e. decide the file is compressed. By skipping the autodetection and forcing the traces to be read as uncompressed ERF, the threat of this bug will go away.

Location:
lib
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • lib/format_erf.c

    rc909fad rd57ae6f  
    226226}
    227227
    228 static int erf_start_input(libtrace_t *libtrace)
     228static int erf_start_input(libtrace_t *libtrace)
     229{
     230        if (libtrace->io)
     231                return 0; /* Success -- already done. */
     232
     233        libtrace->io = trace_open_file(libtrace);
     234
     235        if (!libtrace->io)
     236                return -1;
     237
     238        DATA(libtrace)->drops = 0;
     239        printf("Calling erf_start_input\n");
     240
     241        return 0; /* success */
     242}
     243
     244/* Raw ERF is a special case -- we want to force libwandio to treat the file
     245 * as uncompressed so we can't just use trace_open_file() */
     246static int rawerf_start_input(libtrace_t *libtrace)
    229247{
    230248        if (libtrace->io)
    231                 return 0; /* Success -- already done. */
    232 
    233         libtrace->io = trace_open_file(libtrace);
    234 
    235         if (!libtrace->io)
    236                 return -1;
     249                wandio_destroy(libtrace->io);
     250
     251        libtrace->io = wandio_create_uncompressed(libtrace->uridata);
     252
     253        if (!libtrace->io) {
     254                if (errno != 0) {
     255                        trace_set_err(libtrace, errno, "Unable to open raw ERF file %s", libtrace->uridata);
     256                }
     257                return -1;
     258        }
    237259
    238260        DATA(libtrace)->drops = 0;
     
    811833};
    812834
     835static struct libtrace_format_t rawerfformat = {
     836        "rawerf",
     837        "$Id$",
     838        TRACE_FORMAT_RAWERF,
     839        NULL,                           /* probe filename */
     840        NULL,           /* probe magic */
     841        erf_init_input,                 /* init_input */       
     842        erf_config_input,               /* config_input */
     843        rawerf_start_input,             /* start_input */
     844        NULL,                           /* pause_input */
     845        erf_init_output,                /* init_output */
     846        erf_config_output,              /* config_output */
     847        erf_start_output,               /* start_output */
     848        erf_fin_input,                  /* fin_input */
     849        erf_fin_output,                 /* fin_output */
     850        erf_read_packet,                /* read_packet */
     851        erf_prepare_packet,             /* prepare_packet */
     852        NULL,                           /* fin_packet */
     853        erf_write_packet,               /* write_packet */
     854        erf_get_link_type,              /* get_link_type */
     855        erf_get_direction,              /* get_direction */
     856        erf_set_direction,              /* set_direction */
     857        erf_get_erf_timestamp,          /* get_erf_timestamp */
     858        NULL,                           /* get_timeval */
     859        NULL,                           /* get_timespec */
     860        NULL,                           /* get_seconds */
     861        erf_seek_erf,                   /* seek_erf */
     862        NULL,                           /* seek_timeval */
     863        NULL,                           /* seek_seconds */
     864        erf_get_capture_length,         /* get_capture_length */
     865        erf_get_wire_length,            /* get_wire_length */
     866        erf_get_framing_length,         /* get_framing_length */
     867        erf_set_capture_length,         /* set_capture_length */
     868        NULL,                           /* get_received_packets */
     869        NULL,                           /* get_filtered_packets */
     870        erf_get_dropped_packets,        /* get_dropped_packets */
     871        NULL,                           /* get_captured_packets */
     872        NULL,                           /* get_fd */
     873        erf_event,                      /* trace_event */
     874        erf_help,                       /* help */
     875        NULL                            /* next pointer */
     876};
     877
     878
    813879
    814880void erf_constructor(void) {
    815881        register_format(&erfformat);
    816 }
     882        register_format(&rawerfformat);
     883}
  • lib/format_helper.c

    r0acfd1e rd57ae6f  
    247247io_t *trace_open_file(libtrace_t *trace)
    248248{
    249         int ad = (trace->format->type != TRACE_FORMAT_ERF);
    250249        io_t *io=wandio_create(trace->uridata);
    251250
  • lib/libtrace.h.in

    r94dbe30 rd57ae6f  
    306306        TRACE_FORMAT_ATMHDR       =13,  /**< Legacy ATM header capture */
    307307        TRACE_FORMAT_LEGACY_NZIX  =14,  /**< Legacy format used for NZIX traces */
    308         TRACE_FORMAT_LINUX_RING   =15   /**< Linux native interface capture PACKET_MMAP */
     308        TRACE_FORMAT_LINUX_RING   =15,  /**< Linux native interface capture PACKET_MMAP */
     309        TRACE_FORMAT_RAWERF       =16,  /**< Special format for reading uncompressed ERF traces without checking for compression */
    309310};
    310311
Note: See TracChangeset for help on using the changeset viewer.