Changeset 925


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

Location:
trunk/lib
Files:
4 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  
  • trunk/lib/libtrace.h.in

    r922 r925  
    738738 * @return the number of bytes written out, if zero or negative then an error has occured. 
    739739 */ 
    740 DLLEXPORT int trace_write_packet(libtrace_out_t *trace, const libtrace_packet_t *packet); 
     740DLLEXPORT int trace_write_packet(libtrace_out_t *trace, libtrace_packet_t *packet); 
    741741/*@}*/ 
    742742 
  • trunk/lib/libtrace_int.h

    r921 r925  
    237237         * (or NULL if output not supported) 
    238238         */ 
    239         int (*write_packet)(libtrace_out_t *libtrace, const libtrace_packet_t *packet); 
     239        int (*write_packet)(libtrace_out_t *libtrace, libtrace_packet_t *packet); 
    240240        /** return the libtrace link type for this packet  
    241241         * @return the libtrace link type, or -1 if this link type is unknown 
  • trunk/lib/trace.c

    r904 r925  
    697697 * @author Shane Alcock 
    698698 * */ 
    699 DLLEXPORT int trace_write_packet(libtrace_out_t *libtrace, const libtrace_packet_t *packet) { 
     699DLLEXPORT int trace_write_packet(libtrace_out_t *libtrace, libtrace_packet_t *packet) { 
    700700        assert(libtrace); 
    701701        assert(packet);  
Note: See TracChangeset for help on using the changeset viewer.