Changeset 925 for trunk/lib/format_erf.c


Ignore:
Timestamp:
08/21/06 22:10:42 (7 years ago)
Author:
perry
Message:

trace_write_packet isn't const -- it can promote/demote packets

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/format_erf.c

    r924 r925  
    900900        return 0; 
    901901} 
     902 
     903static bool find_compatible_linktype(libtrace_packet_t *packet) 
     904{ 
     905        /* Keep trying to simplify the packet until we can find  
     906         * something we can do with it */ 
     907        do { 
     908                char type=libtrace_to_erf_type(trace_get_link_type(packet)); 
     909 
     910                /* Success */ 
     911                if (type != (char)-1) 
     912                        return true; 
     913 
     914                if (!demote_packet(packet)) { 
     915                        trace_set_err_out(packet->trace, 
     916                                        TRACE_ERR_NO_CONVERSION, 
     917                                        "No erf type for packet (%i)", 
     918                                        trace_get_link_type(packet)); 
     919                        return false; 
     920                } 
     921 
     922        } while(1); 
     923 
     924        return true; 
     925} 
    902926                 
    903927static int erf_write_packet(libtrace_out_t *libtrace,  
     
    940964        } else { 
    941965                dag_record_t erfhdr; 
    942                 int type; 
    943966                /* convert format - build up a new erf header */ 
    944967                /* Timestamp */ 
     
    950973                        erfhdr.flags.iface = trace_get_direction(packet); 
    951974 
    952                 /* Keep trying to simplify the packet until we can find  
    953                  * something we can do with it */ 
    954                 do { 
    955                         type=libtrace_to_erf_type(trace_get_link_type(packet)); 
    956                 } while(type==(char)-1 && demote_packet((libtrace_packet_t *)packet)); 
    957                 /* We just don't support this link type sorry */ 
    958                 if (type==(char)-1) { 
    959                         trace_set_err_out(libtrace, 
    960                                         TRACE_ERR_NO_CONVERSION, 
    961                                         "No erf type for packet"); 
     975                if (!find_compatible_linktype(packet)) 
    962976                        return -1; 
    963                 } 
    964                 erfhdr.type = type; 
     977 
     978                erfhdr.type = libtrace_to_erf_type(trace_get_link_type(packet)); 
     979 
    965980                /* Packet length (rlen includes format overhead) */ 
    966981                assert(trace_get_capture_length(packet)>0  
Note: See TracChangeset for help on using the changeset viewer.