Changeset 91ea76c


Ignore:
Timestamp:
05/28/12 14:07:07 (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:
16c598d
Parents:
b3edbe9
Message:
  • Detect if a user is attempting to read a compressed format that their libtrace build does not support and provide an appropriate error. Previously, we'd just try to read the trace with a stdout reader, resulting in some very confusing results.
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • lib/format_helper.c

    r3787331 r91ea76c  
    266266        io_t *io=wandio_create(trace->uridata);
    267267        if (!io) {
    268                 trace_set_err(trace,errno,"Unable to open %s",trace->uridata);
     268                if (errno != 0) {
     269                        trace_set_err(trace,errno,"Unable to open %s",trace->uridata);
     270                } else {
     271                        trace_set_err(trace,TRACE_ERR_UNSUPPORTED_COMPRESS,"Unsupported compression error: %s", trace->uridata);
     272                }
    269273        }
    270274        return io;
  • lib/libtrace.h.in

    rf440dc0 r91ea76c  
    226226        TRACE_ERR_BAD_FILTER    = -9,
    227227        /** RT communication breakdown */
    228         TRACE_ERR_RT_FAILURE    = -10
     228        TRACE_ERR_RT_FAILURE    = -10,
     229        /** Compression format unsupported */
     230        TRACE_ERR_UNSUPPORTED_COMPRESS  = -11
    229231};
    230232
     
    744746        LT_BITFIELD32      to_ds:1;     /**< Packet to Distribution Service */
    745747#endif
     748       
    746749        uint16_t     duration;  /**< Duration value for NAV calculation */
    747750        uint8_t      mac1[6];   /**< MAC Address 1 */
  • libwandio/wandio.c

    r60f3c4c r91ea76c  
    141141                return NULL;
    142142        len = wandio_peek(io, buffer, sizeof(buffer));
    143 #if HAVE_LIBZ
    144143        /* Auto detect gzip compressed data */
    145144        if (len>=2 && buffer[0] == '\037' && buffer[1] == '\213') {
     145#if HAVE_LIBZ
    146146                DEBUG_PIPELINE("zlib");
    147147                io = zlib_open(io);
     148#else
     149                fprintf(stderr, "File %s is gzip compressed but libtrace has not been built with zlib support!\n", filename);
     150                return NULL;
     151#endif
    148152        }
    149153        /* Auto detect compress(1) compressed data (gzip can read this) */
    150154        if (len>=2 && buffer[0] == '\037' && buffer[1] == '\235') {
     155#if HAVE_LIBZ
    151156                DEBUG_PIPELINE("zlib");
    152157                io = zlib_open(io);
    153         }
    154 #endif
    155 #if HAVE_LIBBZ2
     158#else
     159                fprintf(stderr, "File %s is compress(1) compressed but libtrace has not been built with zlib support!\n", filename);
     160                return NULL;
     161#endif
     162        }
     163
    156164        /* Auto detect bzip compressed data */
    157165        if (len>=3 && buffer[0] == 'B' && buffer[1] == 'Z' && buffer[2] == 'h') {
     166#if HAVE_LIBBZ2
    158167                DEBUG_PIPELINE("bzip");
    159168                io = bz_open(io);
    160         }
    161 #endif
     169#else
     170                fprintf(stderr, "File %s is bzip compressed but libtrace has not been built with bzip2 support!\n", filename);
     171                return NULL;
     172#endif
     173        }
    162174       
    163175        /* Now open a threaded, peekable reader using the appropriate module
     
    218230DLLEXPORT void wandio_destroy(io_t *io)
    219231{
     232        if (!io)
     233                return;
     234       
    220235        if (keep_stats)
    221236                fprintf(stderr,"LIBTRACEIO STATS: %"PRIu64" blocks on read\n", read_waits);
Note: See TracChangeset for help on using the changeset viewer.