Ignore:
Timestamp:
01/05/09 11:29:11 (13 years ago)
Author:
Perry Lorier <perry@…>
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:
ad36006
Parents:
9d0049cf
Message:

Try to autoguess the tracetype if the format uri specify is not present

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/format_atmhdr.c

    rc66068d r91b72d3  
    1616#include <stdlib.h>
    1717
    18 
    19 
    20 #define DATA(x) ((struct atmhdr_format_data_t *)x->format_data)
    21 
    22 #define INPUT DATA(libtrace)->input
    23 
    24 struct atmhdr_format_data_t {
    25         union {
    26                 int fd;
    27                 io_t *file;
    28         } input;
    29 };
    30 
    3118static int atmhdr_get_framing_length(const libtrace_packet_t *packet UNUSED)
    3219{
     
    3522
    3623static int atmhdr_init_input(libtrace_t *libtrace) {
    37         libtrace->format_data = malloc(sizeof(struct atmhdr_format_data_t));
    38         DATA(libtrace)->input.file = NULL;
     24        libtrace->format_data = NULL; /* No format data needed */
    3925        return 0;
    4026}
     
    4228static int atmhdr_start_input(libtrace_t *libtrace)
    4329{
    44         if (DATA(libtrace)->input.file)
     30        if (libtrace->io) /* Already open? */
    4531                return 0;
    46         DATA(libtrace)->input.file = trace_open_file(libtrace);
    47         if (DATA(libtrace)->input.file)
     32        libtrace->io = trace_open_file(libtrace);
     33        if (libtrace->io)
    4834                return 0;
    4935        return -1;
     
    5238static int atmhdr_fin_input(libtrace_t *libtrace)
    5339{
    54         wandio_destroy(INPUT.file);
    55         free(libtrace->format_data);
     40        wandio_destroy(libtrace->io);
    5641        return 0;
    5742}
     
    9782        packet->type = TRACE_RT_DATA_ATMHDR;
    9883
    99         if ((numbytes=wandio_read(INPUT.file, buffer, (size_t)12)) != 12)
     84        if ((numbytes=wandio_read(libtrace->io, buffer, (size_t)12)) != 12)
    10085        {
    10186                if (numbytes != 0) {
     
    138123        "$Id$",
    139124        TRACE_FORMAT_ATMHDR,
     125        NULL,                           /* probe filename */
     126        NULL,                           /* probe magic */
    140127        atmhdr_init_input,              /* init_input */
    141128        NULL,                           /* config_input */
Note: See TracChangeset for help on using the changeset viewer.