Changeset 0ff6ddf for lib/format_erf.c


Ignore:
Timestamp:
06/06/06 17:32:24 (15 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:
b0acff7
Parents:
41f22e4
Message:

Add demotion of packets from LINUX_SLL to ethernet when writing ERF packets.
We don't need the extra header to store the direction information, and erf
doesn't have a type for linux-sll /anyway/.

This also adds a test which takes a packet, promotes it and demotes it again
which should catch direction related bugs

Closes: #21

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/format_erf.c

    r3e66b30 r0ff6ddf  
    861861
    862862static int erf_dump_packet(libtrace_out_t *libtrace,
    863                 dag_record_t *erfptr, int pad, void *buffer, size_t size) {
     863                dag_record_t *erfptr, int pad, void *buffer) {
    864864        int numbytes = 0;
    865         assert(size<=65536);
     865        int size;
    866866
    867867        if ((numbytes = libtrace_io_write(OUTPUT.file, erfptr, dag_record_size + pad)) != dag_record_size+pad) {
     
    871871        }
    872872
    873         if ((numbytes=libtrace_io_write(OUTPUT.file, buffer, size)) != (int)size) {
     873        size=ntohs(erfptr->rlen)-(dag_record_size+pad);
     874
     875        numbytes=libtrace_io_write(OUTPUT.file, buffer, size);
     876        if (numbytes != size) {
    874877                trace_set_err_out(libtrace,errno,
    875878                                "write(%s)",libtrace->uridata);
     
    926929                                (dag_record_t *)packet->header,
    927930                                pad,
    928                                 payload,
    929                                 trace_get_capture_length(packet)
     931                                payload
    930932                                );
    931933        } else {
     
    935937                /* Timestamp */
    936938                erfhdr.ts = trace_get_erf_timestamp(packet);
    937                 type=libtrace_to_erf_type(trace_get_link_type(packet));
     939                /* Keep trying to simplify the packet until we can find
     940                 * something we can do with it */
     941                do {
     942                        type=libtrace_to_erf_type(trace_get_link_type(packet));
     943                } while(type==(char)-1 && demote_packet(packet));
     944                /* We just don't support this link type sorry */
    938945                if (type==(char)-1) {
    939                         trace_set_err_out(libtrace,TRACE_ERR_NO_CONVERSION,
     946                        trace_set_err_out(libtrace,
     947                                        TRACE_ERR_NO_CONVERSION,
    940948                                        "No erf type for packet");
    941949                        return -1;
     
    946954                if (trace_get_direction(packet)!=-1)
    947955                        erfhdr.flags.iface = trace_get_direction(packet);
     956
    948957                /* Packet length (rlen includes format overhead) */
     958                assert(trace_get_capture_length(packet)>0
     959                                && trace_get_capture_length(packet)<=65536);
     960                assert(erf_get_framing_length(packet)>0
     961                                && trace_get_framing_length(packet)<=65536);
     962                assert(
     963                        trace_get_capture_length(packet)+erf_get_framing_length(packet)>0
     964                      &&trace_get_capture_length(packet)+erf_get_framing_length(packet)<=65536);
    949965                erfhdr.rlen = htons(trace_get_capture_length(packet)
    950966                        + erf_get_framing_length(packet));
     
    958974                                &erfhdr,
    959975                                pad,
    960                                 payload,
    961                                 trace_get_capture_length(packet));
     976                                payload);
    962977        }
    963978        return numbytes;
Note: See TracChangeset for help on using the changeset viewer.