Changeset 9636216


Ignore:
Timestamp:
02/23/16 16:03:14 (5 years ago)
Author:
Perry Lorier <git@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, master, ndag_format, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
Children:
7d1ada1
Parents:
3fe009c
Message:

Trivial whitespace fixes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/trace.c

    r6fc1ae7 r9636216  
    22 * This file is part of libtrace
    33 *
    4  * Copyright (c) 2007,2008,2009,2010 The University of Waikato, Hamilton, 
     4 * Copyright (c) 2007,2008,2009,2010 The University of Waikato, Hamilton,
    55 * New Zealand.
    66 *
    7  * Authors: Daniel Lawson 
     7 * Authors: Daniel Lawson
    88 *          Perry Lorier
    9  *          Shane Alcock 
    10  *         
     9 *          Shane Alcock
     10 *
    1111 * All rights reserved.
    1212 *
    13  * This code has been developed by the University of Waikato WAND 
     13 * This code has been developed by the University of Waikato WAND
    1414 * research group. For further information please see http://www.wand.net.nz/
    1515 *
     
    115115        dest[n]='\0';
    116116}
    117  
     117
    118118static char *xstrndup(const char *src,size_t n)
    119 {       
     119{
    120120        char *ret=(char*)malloc(n+1);
    121121        if (ret==NULL) {
     
    153153}
    154154
    155 /* Prints help information for libtrace 
     155/* Prints help information for libtrace
    156156 *
    157157 * Function prints out some basic help information regarding libtrace,
     
    176176{
    177177        struct libtrace_format_t *tmp;
    178        
     178
    179179        /* Try and guess based on filename */
    180180        for(tmp = formats_list; tmp; tmp=tmp->next) {
     
    198198                }
    199199        }
    200        
     200
    201201        /* Oh well */
    202202        return;
     
    211211 *  erf:/path/to/erf/file
    212212 *  erf:/path/to/erf/file.gz
    213  *  erf:-                       (stdin)
     213 *  erf:-                       (stdin)
    214214 *  dag:/dev/dagcard
    215  *  pcapint:pcapinterface               (eg: pcapint:eth0)
     215 *  pcapint:pcapinterface               (eg: pcapint:eth0)
    216216 *  pcapfile:/path/to/pcap/file
    217217 *  pcapfile:-
     
    224224 */
    225225DLLEXPORT libtrace_t *trace_create(const char *uri) {
    226         libtrace_t *libtrace = 
     226        libtrace_t *libtrace =
    227227                        (libtrace_t *)malloc(sizeof(libtrace_t));
    228228        char *scan = 0;
    229         const char *uridata = 0;                 
     229        const char *uridata = 0;
    230230
    231231        trace_init();
     
    237237                return NULL;
    238238        }
    239        
     239
    240240        libtrace->err.err_num = TRACE_ERR_NOERROR;
    241241        libtrace->format=NULL;
    242        
     242
    243243        libtrace->event.tdelta = 0.0;
    244244        libtrace->event.packet = NULL;
     
    287287         * libtrace->uridata contains the appropriate data for this
    288288         */
    289        
    290         /* Call the init_input function for the matching capture format */
     289
     290        /* Call the init_input function for the matching capture format */
    291291        if (libtrace->format->init_input) {
    292292                int err=libtrace->format->init_input(libtrace);
    293293                assert (err==-1 || err==0);
    294294                if (err==-1) {
    295                         /* init_input should call trace_set_err to set
    296                          * the error message
     295                        /* init_input should call trace_set_err to set the
     296                         * error message
    297297                         */
    298298                        return libtrace;
     
    303303                return libtrace;
    304304        }
    305        
     305
    306306        if (scan)
    307307                free(scan);
     
    326326
    327327        trace_init();
    328        
     328
    329329        libtrace->err.err_num = TRACE_ERR_NOERROR;
    330330
     
    334334                xstrncpy(scan,uri, (size_t)(uridata - uri));
    335335        }
    336        
     336
    337337        libtrace->err.err_num = TRACE_ERR_NOERROR;
    338338        libtrace->format=NULL;
    339        
     339
    340340        libtrace->event.tdelta = 0.0;
    341341        libtrace->event.packet = NULL;
     
    348348        libtrace->io = NULL;
    349349        libtrace->filtered_packets = 0;
    350        
     350
    351351        for(tmp=formats_list;tmp;tmp=tmp->next) {
    352352                if (strlen(scan) == strlen(tmp->name) &&
     
    369369}
    370370
    371 /* Creates an output trace from a URI. 
     371/* Creates an output trace from a URI.
    372372 *
    373373 * @param uri   the uri string describing the output format and destination
    374  * @returns opaque pointer to a libtrace_output_t 
     374 * @returns opaque pointer to a libtrace_output_t
    375375 *
    376376 *  If an error occured when attempting to open the output trace, NULL is
    377  *  returned and trace_errno is set. 
    378  */
    379        
     377 *  returned and trace_errno is set.
     378 */
     379
    380380DLLEXPORT libtrace_out_t *trace_create_output(const char *uri) {
    381         libtrace_out_t *libtrace = 
     381        libtrace_out_t *libtrace =
    382382                        (libtrace_out_t*)malloc(sizeof(libtrace_out_t));
    383        
     383
    384384        char *scan = 0;
    385385        const char *uridata = 0;
     
    392392        libtrace->format = NULL;
    393393        libtrace->uridata = NULL;
    394        
     394
    395395        /* Parse the URI to determine what capture format we want to write */
    396396
     
    400400                return libtrace;
    401401        }
    402        
     402
    403403        /* Attempt to find the format in the list of supported formats */
    404404        for(tmp=formats_list;tmp;tmp=tmp->next) {
     
    469469
    470470/* Start an output trace */
    471 DLLEXPORT int trace_start_output(libtrace_out_t *libtrace) 
     471DLLEXPORT int trace_start_output(libtrace_out_t *libtrace)
    472472{
    473473        assert(libtrace);
     
    505505                return -1;
    506506        }
    507        
     507
    508508        /* If the capture format supports configuration, try using their
    509509         * native configuration first */
     
    515515
    516516        /* If we get here, either the native configuration failed or the
    517          * format did not support configuration. However, libtrace can 
     517         * format did not support configuration. However, libtrace can
    518518         * deal with some options itself, so give that a go */
    519519        switch(option) {
     
    523523                                trace_get_err(libtrace);
    524524                        }
    525                         if (*(int*)value<0 
     525                        if (*(int*)value<0
    526526                                || *(int*)value>LIBTRACE_PACKET_BUFSIZE) {
    527527                                trace_set_err(libtrace,TRACE_ERR_BAD_STATE,
     
    545545                case TRACE_OPTION_META_FREQ:
    546546                        if (!trace_is_err(libtrace)) {
    547                                 trace_set_err(libtrace, 
     547                                trace_set_err(libtrace,
    548548                                                TRACE_ERR_OPTION_UNAVAIL,
    549549                                                "This format does not support meta-data gathering");
     
    552552                case TRACE_OPTION_EVENT_REALTIME:
    553553                        if (!trace_is_err(libtrace)) {
    554                                 trace_set_err(libtrace, 
     554                                trace_set_err(libtrace,
    555555                                                TRACE_ERR_OPTION_UNAVAIL,
    556556                                                "This format does not support realtime events");
    557557                        }
    558558                        return -1;
    559                        
     559
    560560        }
    561561        if (!trace_is_err(libtrace)) {
     
    566566}
    567567
    568 DLLEXPORT int trace_config_output(libtrace_out_t *libtrace, 
     568DLLEXPORT int trace_config_output(libtrace_out_t *libtrace,
    569569                trace_option_output_t option,
    570570                void *value) {
    571        
     571
    572572        /* Unlike the input options, libtrace does not natively support any of
    573573         * the output options - the format module must be able to deal with
     
    623623 * @param libtrace      the output trace file to be destroyed
    624624 */
    625 DLLEXPORT void trace_destroy_output(libtrace_out_t *libtrace) 
     625DLLEXPORT void trace_destroy_output(libtrace_out_t *libtrace)
    626626{
    627627        assert(libtrace);
     
    633633}
    634634
    635 DLLEXPORT libtrace_packet_t *trace_create_packet(void) 
    636 {
    637         libtrace_packet_t *packet = 
     635DLLEXPORT libtrace_packet_t *trace_create_packet(void)
     636{
     637        libtrace_packet_t *packet =
    638638                (libtrace_packet_t*)calloc((size_t)1,sizeof(libtrace_packet_t));
    639639
     
    644644
    645645DLLEXPORT libtrace_packet_t *trace_copy_packet(const libtrace_packet_t *packet) {
    646         libtrace_packet_t *dest = 
     646        libtrace_packet_t *dest =
    647647                (libtrace_packet_t *)malloc(sizeof(libtrace_packet_t));
    648648        if (!dest) {
     
    663663        /* Reset the cache - better to recalculate than try to convert
    664664         * the values over to the new packet */
    665         trace_clear_cache(dest);       
     665        trace_clear_cache(dest);
    666666        /* Ooooh nasty memcpys! This is why we want to avoid copying packets
    667667         * as much as possible */
     
    678678                free(packet->buffer);
    679679        }
    680         packet->buf_control=(buf_control_t)'\0'; 
     680        packet->buf_control=(buf_control_t)'\0';
    681681                                /* A "bad" value to force an assert
    682682                                 * if this packet is ever reused
    683683                                 */
    684684        free(packet);
    685 }       
     685}
    686686
    687687/* Read one packet from the trace into buffer. Note that this function will
    688688 * block until a packet is read (or EOF is reached).
    689689 *
    690  * @param libtrace      the libtrace opaque pointer
    691  * @param packet        the packet opaque pointer
     690 * @param libtrace      the libtrace opaque pointer
     691 * @param packet        the packet opaque pointer
    692692 * @returns 0 on EOF, negative value on error
    693693 *
     
    702702                return -1;
    703703        }
    704         if (!(packet->buf_control==TRACE_CTRL_PACKET || packet->buf_control==TRACE_CTRL_EXTERNAL)) {
     704        if (!(packet->buf_control==TRACE_CTRL_PACKET
     705                    || packet->buf_control==TRACE_CTRL_EXTERNAL)) {
    705706                trace_set_err(libtrace,TRACE_ERR_BAD_STATE,"Packet passed to trace_read_packet() is invalid\n");
    706707                return -1;
    707708        }
    708709        assert(packet);
    709      
    710         /* Store the trace we are reading from into the packet opaque 
     710
     711        /* Store the trace we are reading from into the packet opaque
    711712         * structure */
    712713        packet->trace = libtrace;
     
    739740                                        return ~0U;
    740741                                }
    741                                
     742
    742743                                if (filtret == 0) {
    743744                                        ++libtrace->filtered_packets;
     
    763764 * appropriate capture format header for the format type that the packet is
    764765 * being converted to. This also allows for a packet to be converted into
    765  * just about capture format that is supported by libtrace, provided the 
     766 * just about capture format that is supported by libtrace, provided the
    766767 * format header is present in the buffer.
    767768 *
    768769 * This function is primarily used to convert packets received via the RT
    769770 * protocol back into their original capture format. The RT header encapsulates
    770  * the original capture format header, so after removing it the packet must 
     771 * the original capture format header, so after removing it the packet must
    771772 * have it's header and payload pointers updated and the packet format and type
    772773 * changed, amongst other things.
    773774 *
    774  * Intended only for internal use at this point - this function is not 
     775 * Intended only for internal use at this point - this function is not
    775776 * available through the external libtrace API.
    776777 */
     
    780781        assert(packet);
    781782        assert(trace);
    782        
     783
    783784        /* XXX Proper error handling?? */
    784785        if (buffer == NULL)
     
    789790                return -1;
    790791        }
    791        
     792
    792793        packet->trace = trace;
    793        
     794
    794795        /* Clear packet cache */
    795796        trace_clear_cache(packet);
     
    799800                                buffer, rt_type, flags);
    800801        }
    801         trace_set_err(trace, TRACE_ERR_UNSUPPORTED, 
     802        trace_set_err(trace, TRACE_ERR_UNSUPPORTED,
    802803                        "This format does not support preparing packets\n");
    803804        return -1;
     
    813814DLLEXPORT int trace_write_packet(libtrace_out_t *libtrace, libtrace_packet_t *packet) {
    814815        assert(libtrace);
    815         assert(packet); 
     816        assert(packet);
    816817        /* Verify the packet is valid */
    817818        if (!libtrace->started) {
     
    841842                 * wire lengths to be the "remaining" value. If the packet has
    842843                 * been padded to increase the capture length, we don't want
    843                  * to allow subsequent protocol decoders to consider the 
     844                 * to allow subsequent protocol decoders to consider the
    844845                 * padding as part of the packet.
    845846                 *
     
    851852                 * better off returning an incomplete TCP header in that case.
    852853                 */
    853                
     854
    854855                cap_len = trace_get_capture_length(packet);
    855856                wire_len = trace_get_wire_length(packet);
     
    860861                 * massively negative wire lens. We could assert fail here on
    861862                 * them, but we could at least try the capture length instead.
    862                  * 
     863                 *
    863864                 * You may still run into problems if you try to write that
    864865                 * packet, but at least reading should work OK.
     
    876877
    877878
    878 /* Get a pointer to the first byte of the packet payload 
     879/* Get a pointer to the first byte of the packet payload
    879880 *
    880881 * DEPRECATED - use trace_get_packet_buffer() instead */
     
    883884}
    884885
    885 /* Get the current time in DAG time format 
    886  * @param packet        a pointer to a libtrace_packet structure
     886/* Get the current time in DAG time format
     887 * @param packet        a pointer to a libtrace_packet structure
    887888 * @returns a 64 bit timestamp in DAG ERF format (upper 32 bits are the seconds
    888889 * past 1970-01-01, the lower 32bits are partial seconds)
    889  */ 
     890 */
    890891DLLEXPORT uint64_t trace_get_erf_timestamp(const libtrace_packet_t *packet) {
    891892        if (packet->trace->format->get_erf_timestamp) {
     
    913914                return (uint64_t)0;
    914915        }
    915                      
    916916}
    917917
     
    922922 * @author Daniel Lawson
    923923 * @author Perry Lorier
    924  */ 
     924 */
    925925DLLEXPORT struct timeval trace_get_timeval(const libtrace_packet_t *packet) {
    926926        struct timeval tv;
     
    934934                tv.tv_sec = ts >> 32;
    935935                tv.tv_usec = ((ts&0xFFFFFFFF)*1000000)>>32;
    936                 if (tv.tv_usec >= 1000000) {
    937                         tv.tv_usec -= 1000000;
    938                         tv.tv_sec += 1;
    939                 }
     936                if (tv.tv_usec >= 1000000) {
     937                        tv.tv_usec -= 1000000;
     938                        tv.tv_sec += 1;
     939                }
    940940        } else if (packet->trace->format->get_timespec) {
    941941                struct timespec ts = packet->trace->format->get_timespec(packet);
     
    966966                ts.tv_sec = erfts >> 32;
    967967                ts.tv_nsec = ((erfts&0xFFFFFFFF)*1000000000)>>32;
    968                 if (ts.tv_nsec >= 1000000000) {
    969                         ts.tv_nsec -= 1000000000;
    970                         ts.tv_sec += 1;
    971                 }
     968                if (ts.tv_nsec >= 1000000000) {
     969                        ts.tv_nsec -= 1000000000;
     970                        ts.tv_sec += 1;
     971                }
    972972                return ts;
    973973        } else if (packet->trace->format->get_timeval) {
     
    993993
    994994/* Get the current time in floating point seconds
    995  * @param packet        a pointer to a libtrace_packet structure
     995 * @param packet        a pointer to a libtrace_packet structure
    996996 * @returns time that this packet was seen in 64bit floating point seconds
    997  */ 
     997 */
    998998DLLEXPORT double trace_get_seconds(const libtrace_packet_t *packet) {
    999999        double seconds = 0.0;
     
    10221022}
    10231023
    1024 DLLEXPORT size_t trace_get_capture_length(const libtrace_packet_t *packet) 
     1024DLLEXPORT size_t trace_get_capture_length(const libtrace_packet_t *packet)
    10251025{
    10261026        /* Cache the capture length */
     
    10291029                        return ~0U;
    10301030                /* Cast away constness because this is "just" a cache */
    1031                 ((libtrace_packet_t*)packet)->capture_length = 
     1031                ((libtrace_packet_t*)packet)->capture_length =
    10321032                        packet->trace->format->get_capture_length(packet);
    10331033        }
     
    10371037        return packet->capture_length;
    10381038}
    1039        
     1039
    10401040/* Get the size of the packet as it was seen on the wire.
    10411041 * @param packet        a pointer to a libtrace_packet structure
     
    10441044 * @note Due to the trace being a header capture, or anonymisation this may
    10451045 * not be the same as the Capture Len.
    1046  */ 
     1046 */
    10471047DLLEXPORT size_t trace_get_wire_length(const libtrace_packet_t *packet){
    1048        
     1048
    10491049        if (packet->wire_length == -1) {
    1050                 if (!packet->trace->format->get_wire_length) 
     1050                if (!packet->trace->format->get_wire_length)
    10511051                        return ~0U;
    1052                 ((libtrace_packet_t *)packet)->wire_length = 
     1052                ((libtrace_packet_t *)packet)->wire_length =
    10531053                        packet->trace->format->get_wire_length(packet);
    10541054        }
     
    10601060
    10611061/* Get the length of the capture framing headers.
    1062  * @param packet        the packet opaque pointer
     1062 * @param packet        the packet opaque pointer
    10631063 * @returns the size of the packet as it was on the wire.
    1064  * @note this length corresponds to the difference between the size of a 
     1064 * @note this length corresponds to the difference between the size of a
    10651065 * captured packet in memory, and the captured length of the packet
    1066  */ 
     1066 */
    10671067DLLEXPORT SIMPLE_FUNCTION
    10681068size_t trace_get_framing_length(const libtrace_packet_t *packet) {
     
    10751075
    10761076/* Get the type of the link layer
    1077  * @param packet        a pointer to a libtrace_packet structure
     1077 * @param packet        a pointer to a libtrace_packet structure
    10781078 * @returns libtrace_linktype_t
    10791079 */
     
    11011101 * which in turn is stored inside the new packet object...
    11021102 */
    1103 DLLEXPORT libtrace_eventobj_t trace_event(libtrace_t *trace, 
     1103DLLEXPORT libtrace_eventobj_t trace_event(libtrace_t *trace,
    11041104                libtrace_packet_t *packet) {
    11051105        libtrace_eventobj_t event = {TRACE_EVENT_IOWAIT,0,0.0,0};
     
    11131113        /* Clear the packet cache */
    11141114        trace_clear_cache(packet);
    1115        
     1115
    11161116        /* Store the trace we are reading from into the packet opaque
    11171117         * structure */
     
    11201120        if (packet->trace->format->trace_event) {
    11211121                /* Note: incrementing accepted, filtered etc. packet
    1122                  * counters is handled by the format-specific 
     1122                 * counters is handled by the format-specific
    11231123                 * function so don't increment them here.
    11241124                 */
     
    11471147        filter->filter.bf_insns = (struct bpf_insn *)
    11481148                malloc(sizeof(struct bpf_insn) * bf_len);
    1149        
     1149
    11501150        memcpy(filter->filter.bf_insns, bf_insns,
    11511151                        bf_len * sizeof(struct bpf_insn));
    1152        
     1152
    11531153        filter->filter.bf_len = bf_len;
    11541154        filter->filterstring = NULL;
    11551155        filter->jitfilter = NULL;
    11561156        /* "flag" indicates that the filter member is valid */
    1157         filter->flag = 1; 
    1158        
     1157        filter->flag = 1;
     1158
    11591159        return filter;
    11601160#endif
     
    11861186                pcap_freecode(&filter->filter);
    11871187#ifdef HAVE_LLVM
    1188         if (filter->jitfilter) 
     1188        if (filter->jitfilter)
    11891189                destroy_program(filter->jitfilter);
    11901190#endif
     
    12041204static int trace_bpf_compile(libtrace_filter_t *filter,
    12051205                const libtrace_packet_t *packet,
    1206                 void *linkptr, 
     1206                void *linkptr,
    12071207                libtrace_linktype_t linktype    ) {
    12081208#ifdef HAVE_BPF_FILTER
     
    12151215                return -1;
    12161216        }
    1217        
     1217
    12181218        if (filter->filterstring && ! filter->flag) {
    12191219                pcap_t *pcap = NULL;
     
    12341234                /* build filter */
    12351235                assert(pcap);
    1236                 if (pcap_compile( pcap, &filter->filter, filter->filterstring, 
     1236                if (pcap_compile( pcap, &filter->filter, filter->filterstring,
    12371237                                        1, 0)) {
    12381238                        trace_set_err(packet->trace,TRACE_ERR_BAD_FILTER,
    1239                                         "Unable to compile the filter \"%s\": %s", 
     1239                                        "Unable to compile the filter \"%s\": %s",
    12401240                                        filter->filterstring,
    12411241                                        pcap_geterr(pcap));
     
    12731273
    12741274        if (linktype == TRACE_TYPE_NONDATA)
    1275                 return 1;       
     1275                return 1;
    12761276
    12771277        if (libtrace_to_pcap_dlt(linktype)==TRACE_DLT_ERROR) {
    1278                
     1278
    12791279                /* If we cannot get a suitable DLT for the packet, it may
    12801280                 * be because the packet is encapsulated in a link type that
     
    12821282                 * popping off headers until we either can find a suitable
    12831283                 * link type or we can't do any more sensible decapsulation. */
    1284                
     1284
    12851285                /* Copy the packet, as we don't want to trash the one we
    12861286                 * were passed in */
     
    12901290                while (libtrace_to_pcap_dlt(linktype) == TRACE_DLT_ERROR) {
    12911291                        if (!demote_packet(packet_copy)) {
    1292                                 trace_set_err(packet->trace, 
     1292                                trace_set_err(packet->trace,
    12931293                                                TRACE_ERR_NO_CONVERSION,
    12941294                                                "pcap does not support this format");
     
    13021302
    13031303        }
    1304        
     1304
    13051305        linkptr = trace_get_packet_buffer(packet_copy,NULL,&clen);
    13061306        if (!linkptr) {
     
    13111311        }
    13121312
    1313         /* We need to compile the filter now, because before we didn't know 
     1313        /* We need to compile the filter now, because before we didn't know
    13141314         * what the link type was
    13151315         */
     
    13521352 * @returns a signed value containing the direction flag, or -1 if this is not supported
    13531353 */
    1354 DLLEXPORT libtrace_direction_t trace_set_direction(libtrace_packet_t *packet, 
    1355                 libtrace_direction_t direction) 
     1354DLLEXPORT libtrace_direction_t trace_set_direction(libtrace_packet_t *packet,
     1355                libtrace_direction_t direction)
    13561356{
    13571357        assert(packet);
     
    13701370 * for a special trace.
    13711371 */
    1372 DLLEXPORT libtrace_direction_t trace_get_direction(const libtrace_packet_t *packet) 
     1372DLLEXPORT libtrace_direction_t trace_get_direction(const libtrace_packet_t *packet)
    13731373{
    13741374        assert(packet);
     
    13851385#define DYNAMIC(x) ((49152 < (x)) && ((x) < 65535))
    13861386#define SERVER(x) ROOT_SERVER(x) || NONROOT_SERVER(x)
    1387 #define CLIENT(x) ROOT_CLIENT(x) || NONROOT_CLIENT(x) 
     1387#define CLIENT(x) ROOT_CLIENT(x) || NONROOT_CLIENT(x)
    13881388
    13891389/* Attempt to deduce the 'server' port
     
    13931393 * @returns a hint as to which port is the server port
    13941394 */
    1395 DLLEXPORT int8_t trace_get_server_port(UNUSED uint8_t protocol, 
    1396                 uint16_t source, uint16_t dest) 
     1395DLLEXPORT int8_t trace_get_server_port(UNUSED uint8_t protocol,
     1396                uint16_t source, uint16_t dest)
    13971397{
    13981398        /*
     
    14071407         * * flip a coin.
    14081408         */
    1409        
     1409
    14101410        /* equal */
    14111411        if (source == dest)
     
    14531453                return USE_SOURCE;
    14541454        }
    1455        
     1455
    14561456        /* nonroot client */
    14571457        if (NONROOT_CLIENT(source) && NONROOT_CLIENT(dest)) {
    1458                 if (source < dest) 
     1458                if (source < dest)
    14591459                        return USE_SOURCE;
    14601460                return USE_DEST;
     
    14761476                return USE_SOURCE;
    14771477        /*
    1478         if (SERVER(source) && CLIENT(dest)) 
     1478        if (SERVER(source) && CLIENT(dest))
    14791479                return USE_SOURCE;
    1480        
    1481         if (SERVER(dest) && CLIENT(source)) 
     1480
     1481        if (SERVER(dest) && CLIENT(source))
    14821482                return USE_DEST;
    1483         if (ROOT_SERVER(source) && !ROOT_SERVER(dest)) 
     1483        if (ROOT_SERVER(source) && !ROOT_SERVER(dest))
    14841484                return USE_SOURCE;
    1485         if (ROOT_SERVER(dest) && !ROOT_SERVER(source)) 
     1485        if (ROOT_SERVER(dest) && !ROOT_SERVER(source))
    14861486                return USE_DEST;
    14871487        */
     
    14891489        if (source < dest) {
    14901490                return USE_SOURCE;
    1491         } 
     1491        }
    14921492        return USE_DEST;
    1493        
     1493
    14941494}
    14951495
     
    15201520 *
    15211521 * Returns a pointer to the URI data, but updates the format parameter to
    1522  * point to a copy of the format component. 
     1522 * point to a copy of the format component.
    15231523 */
    15241524
    15251525DLLEXPORT const char * trace_parse_uri(const char *uri, char **format) {
    15261526        const char *uridata = 0;
    1527        
     1527
    15281528        if((uridata = strchr(uri,':')) == NULL) {
    15291529                /* Badly formed URI - needs a : */
     
    15421542        /* Push uridata past the delimiter */
    15431543        uridata++;
    1544        
     1544
    15451545        return uridata;
    15461546}
    15471547
    1548 enum base_format_t trace_get_format(libtrace_packet_t *packet) 
     1548enum base_format_t trace_get_format(libtrace_packet_t *packet)
    15491549{
    15501550        assert(packet);
     
    15521552        return packet->trace->format->type;
    15531553}
    1554        
     1554
    15551555DLLEXPORT libtrace_err_t trace_get_err(libtrace_t *trace)
    15561556{
     
    16501650                }
    16511651                if (trace->format->seek_seconds) {
    1652                         double seconds = 
     1652                        double seconds =
    16531653                                (ts>>32) + ((ts & UINT_MAX)*1.0 / UINT_MAX);
    16541654                        return trace->format->seek_seconds(trace,seconds);
     
    16741674                }
    16751675                if (trace->format->seek_erf) {
    1676                         uint64_t timestamp = 
     1676                        uint64_t timestamp =
    16771677                                ((uint64_t)((uint32_t)seconds) << 32) + \
    16781678                            (uint64_t)(( seconds - (uint32_t)seconds   ) * UINT_MAX);
     
    17371737
    17381738
    1739 /* Creates a libtrace packet from scratch using the contents of the provided 
     1739/* Creates a libtrace packet from scratch using the contents of the provided
    17401740 * buffer as the packet payload.
    17411741 *
    17421742 * Unlike trace_prepare_packet(), the buffer should not contain any capture
    1743  * format headers; instead this function will add the PCAP header to the 
     1743 * format headers; instead this function will add the PCAP header to the
    17441744 * packet record. This also means only PCAP packets can be constructed using
    17451745 * this function.
     
    17631763        /* We need a trace to attach the constructed packet to (and it needs
    17641764         * to be PCAP) */
    1765         if (NULL == deadtrace) 
     1765        if (NULL == deadtrace)
    17661766                deadtrace=trace_create_dead("pcapfile");
    17671767
     
    18631863
    18641864        /* Now, verify that the format has at least the minimum functionality.
    1865          * 
     1865         *
    18661866         * This #if can be changed to a 1 to output warnings about inconsistent
    18671867         * functions being provided by format modules.  This generally is very
    18681868         * noisy, as almost all modules don't implement one or more functions
    1869          * for various reasons.  This is very useful when checking a new 
     1869         * for various reasons.  This is very useful when checking a new
    18701870         * format module is sane.
    1871          */ 
     1871         */
    18721872#if 0
    18731873        if (f->init_input) {
     
    18831883                REQUIRE(get_framing_length);
    18841884                REQUIRE(trace_event);
    1885                 if (!f->get_erf_timestamp 
     1885                if (!f->get_erf_timestamp
    18861886                        && !f->get_seconds
    18871887                        && !f->get_timeval) {
Note: See TracChangeset for help on using the changeset viewer.