Changeset 52f8fc2


Ignore:
Timestamp:
02/23/06 13:14:32 (16 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:
8ea5b38
Parents:
aa62105
Message:

Cleanup some uses of packet->trace where the trace is already available!

Location:
lib
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • lib/format_erf.c

    raa62105 r52f8fc2  
    408408                                        dag_record_size)) == -1) {
    409409                trace_set_err(errno,"read(%s)",
    410                                 packet->trace->uridata);
     410                                libtrace->uridata);
    411411                return -1;
    412412        }
     
    428428                                        buffer2,
    429429                                        size)) != size) {
    430                 trace_set_err(errno, "read(%s)", packet->trace->uridata);
     430                trace_set_err(errno, "read(%s)", libtrace->uridata);
    431431                return -1;
    432432        }
     
    474474        void *buffer = 0;
    475475
    476         packet->trace = libtrace;
    477 
    478476        if (packet->buf_control == TRACE_CTRL_EXTERNAL || !packet->buffer) {
    479477                packet->buf_control = TRACE_CTRL_PACKET;
     
    591589        }
    592590       
    593         if (packet->trace->format == &erf 
     591        if (libtrace->format == &erf 
    594592#if HAVE_DAG
    595                         || packet->trace->format == &dag
     593                        || libtrace->format == &dag
    596594#endif
    597595                        ) {
     
    678676}
    679677
    680 static int rtclient_get_fd(const struct libtrace_packet_t *packet) {
    681         return packet->trace->format_data->input.fd;
    682 }
    683 
    684 static int erf_get_fd(const struct libtrace_packet_t *packet) {
    685         return packet->trace->format_data->input.fd;
     678static int rtclient_get_fd(const libtrace_t *trace) {
     679        return trace->format_data->input.fd;
     680}
     681
     682static int erf_get_fd(const libtrace_t *trace) {
     683        return trace->format_data->input.fd;
    686684}
    687685
     
    692690        int data;
    693691
    694         if (packet->trace->format->get_fd) {
    695                 dag_fd = packet->trace->format->get_fd(packet);
     692        if (trace->format->get_fd) {
     693                dag_fd = trace->format->get_fd(packet);
    696694        } else {
    697695                dag_fd = 0;
  • lib/format_helper.c

    rfe76c55 r52f8fc2  
    5252        int data;
    5353
    54         if (packet->trace->format->get_fd) {
    55                 event.fd = packet->trace->format->get_fd(packet);
     54        if (trace->format->get_fd) {
     55                event.fd = trace->format->get_fd(packet);
    5656        } else {
    5757                event.fd = 0;
  • lib/format_legacy.c

    rc1db742 r52f8fc2  
    166166        packet->header = packet->buffer;
    167167        packet->payload = (void*)((char*)packet->buffer +
    168                 packet->trace->format->get_framing_length(packet));
     168                libtrace->format->get_framing_length(packet));
    169169       
    170170        return 64;
  • lib/format_pcap.c

    rf0d19d4 r52f8fc2  
    299299                fflush((FILE *)OUTPUT.trace.dump);
    300300        }
    301         if (packet->trace->format == &pcap ||
    302                         packet->trace->format == &pcapint) {
     301        if (libtrace->format == &pcap ||
     302                        libtrace->format == &pcapint) {
    303303               
    304304                pcap_dump((u_char*)OUTPUT.trace.dump,(struct pcap_pkthdr *)packet->header,packet->payload);
     
    428428}
    429429
    430 static int pcap_get_fd(const struct libtrace_packet_t *packet) {
    431         return pcap_fileno(packet->trace->format_data->input.pcap);
     430static int pcap_get_fd(const libtrace_t *trace) {
     431        return pcap_fileno(trace->format_data->input.pcap);
    432432}
    433433
  • lib/format_rt.c

    rc2d5f23 r52f8fc2  
    389389        rt_data_t data_hdr;
    390390        void *buffer = 0;
    391 
    392         packet->trace = libtrace;
    393391
    394392        if (packet->buf_control == TRACE_CTRL_EXTERNAL || !packet->buffer) {
     
    507505}
    508506
    509 static int rt_get_fd(const struct libtrace_packet_t *packet) {
    510         return packet->trace->format_data->input_fd;
     507static int rt_get_fd(const struct libtrace_t *trace) {
     508        return trace->format_data->input_fd;
    511509}
    512510
     
    554552        NULL,                           /* get_framing_length */
    555553        NULL,                           /* set_capture_length */
    556         rt_get_fd,                /* get_fd */
     554        rt_get_fd,                      /* get_fd */
    557555        trace_event_device,             /* trace_event */
    558556        rt_help                   /* help */
  • lib/format_wag.c

    rf0d19d4 r52f8fc2  
    407407}
    408408
    409 static int wag_get_fd(const struct libtrace_packet_t *packet) {
    410         return packet->trace->format_data->input.fd;
     409static int wag_get_fd(const libtrace_t *trace) {
     410        return trace->format_data->input.fd;
    411411}
    412412
  • lib/libtrace.h

    r91c9552 r52f8fc2  
    718718 * @author Perry Lorier
    719719 * @note Due to this being a header capture, or anonymisation, this may not
    720  * be the same size as the original packet.  See get_wire_length() for the original
    721  * size of the packet.
     720 * be the same size as the original packet.  See get_wire_length() for the
     721 * original size of the packet.
    722722 * @note This can (and often is) different for different packets in a trace!
    723  * @par
    724  *  This is sometimes called the "snaplen".
     723 * @note This is sometimes called the "snaplen".
     724 * @note The return size refers to the network-level payload of the packet and
     725 * does not include any capture headers. For example, an Ethernet packet with
     726 * an empty TCP packet will return sizeof(ethernet_header) + sizeof(ip_header)
     727 * + sizeof(tcp_header).
    725728 */
    726729SIMPLE_FUNCTION
     
    730733 * @param packet        the packet opaque pointer
    731734 * @return the size of the packet as it was on the wire.
    732  * @author Perry Lorier
    733  * @author Daniel Lawson
    734735 * @note Due to the trace being a header capture, or anonymisation this may
    735736 * not be the same as the Capture Len.
  • lib/libtrace_int.h

    r6dbc47a r52f8fc2  
    175175        int (*get_framing_length)(const libtrace_packet_t *packet);
    176176        size_t (*set_capture_length)(struct libtrace_packet_t *packet,size_t size);
    177         int (*get_fd)(const libtrace_packet_t *packet);
     177        int (*get_fd)(const libtrace_t *trace);
    178178        struct libtrace_eventobj_t (*trace_event)(libtrace_t *trace, libtrace_packet_t *packet);       
    179179        void (*help)();
  • lib/trace.c

    r91c9552 r52f8fc2  
    558558 *
    559559 */
    560 int trace_read_packet(struct libtrace_t *libtrace, struct libtrace_packet_t *packet) {
     560int trace_read_packet(libtrace_t *libtrace, libtrace_packet_t *packet) {
    561561
    562562        assert(libtrace && "You called trace_read_packet() with a NULL libtrace parameter!\n");
     
    10271027 * @author Daniel Lawson
    10281028 */
    1029 uint64_t trace_get_erf_timestamp(const struct libtrace_packet_t *packet) {
     1029uint64_t trace_get_erf_timestamp(const libtrace_packet_t *packet) {
    10301030        uint64_t timestamp = 0;
    10311031        double seconds = 0.0;
     
    10581058 * @author Perry Lorier
    10591059 */
    1060 struct timeval trace_get_timeval(const struct libtrace_packet_t *packet) {
     1060struct timeval trace_get_timeval(const libtrace_packet_t *packet) {
    10611061        struct timeval tv;
    10621062        uint64_t ts = 0;
     
    11211121}
    11221122
    1123 /* Get the size of the packet in the trace
    1124  * @param packet        the packet opaque pointer
    1125  * @returns the size of the packet in the trace
    1126  * @author Perry Lorier
    1127  * @note The return size refers to the network-level payload of the packet and
    1128  * does not include any capture headers. For example, an Ethernet packet with
    1129  * an empty TCP packet will return sizeof(ethernet_header) + sizeof(ip_header)
    1130  * + sizeof(tcp_header).
    1131  * @note Due to this being a header capture, or anonymisation, this may not
    1132  * be the same size as the original packet.  See trace_get_wire_length() for the
    1133  * original size of the packet.
    1134  * @note This can (and often is) different for different packets in a trace!
    1135  * @note This is sometimes called the "snaplen".
    1136  */
    11371123int trace_get_capture_length(const struct libtrace_packet_t *packet) {
    11381124
     
    11731159 */
    11741160SIMPLE_FUNCTION
    1175 int trace_get_framing_length(const struct libtrace_packet_t *packet) {
     1161int trace_get_framing_length(const libtrace_packet_t *packet) {
    11761162        if (packet->trace->format->get_framing_length) {
    11771163                return packet->trace->format->get_framing_length(packet);
     
    11871173 * @author Daniel Lawson
    11881174 */
    1189 libtrace_linktype_t trace_get_link_type(const struct libtrace_packet_t *packet ) {
     1175libtrace_linktype_t trace_get_link_type(const libtrace_packet_t *packet ) {
    11901176        if (packet->trace->format->get_link_type) {
    11911177                return packet->trace->format->get_link_type(packet);
Note: See TracChangeset for help on using the changeset viewer.