Changeset bad6a93 for lib/format_rt.c


Ignore:
Timestamp:
09/20/06 16:42:52 (15 years ago)
Author:
Shane Alcock <salcock@…>
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:
e86124e
Parents:
d0aa87c
Message:

trace_get_vlan_payload_from_ethernet is now available to libtrace users.
Fixed error where erf wire length was having padding subtracted from it - wire length doesn't include padding.
erf can also attach padding to the end of packets - get_capture_length now returns the minimum of the record length - padding and the wire length.
Added support for RT_LOSTCONN - also other zero sized rt packets shouldn't cause TRACE_EVENT_TERMINATE anymore
rt header information is no longer stored statically when doing a non-blocking read
The packet->buffer for rt packets is now regarded as external, so now trace_destroy_packet shouldn't cause a segfault

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/format_rt.c

    re502f76 rbad6a93  
    8383        char *buf_current;
    8484        int buf_filled;
    85 
     85        rt_header_t rt_hdr;
     86       
    8687        libtrace_t *dummy_duck;
    8788        libtrace_t *dummy_erf;
     
    485486static int rt_read_packet_versatile(libtrace_t *libtrace,
    486487                libtrace_packet_t *packet,int blocking) {
    487         static rt_header_t rt_hdr;
    488488        static rt_header_t *pkt_hdr = 0;
    489489       
     
    491491                /* first time through */
    492492                pkt_hdr = malloc(sizeof(rt_header_t));
    493                 rt_hdr.type = RT_LAST;
    494         }
    495        
     493                RT_INFO->rt_hdr.type = RT_LAST;
     494        }
     495
     496        /*
    496497        if (packet->buf_control == TRACE_CTRL_EXTERNAL || !packet->buffer) {
    497498                packet->buf_control = TRACE_CTRL_PACKET;
    498499                packet->buffer = malloc(LIBTRACE_PACKET_BUFSIZE);
    499500        }
     501        */
     502        if (packet->buf_control == TRACE_CTRL_PACKET) {
     503                packet->buf_control = TRACE_CTRL_EXTERNAL;
     504                free(packet->buffer);
     505                packet->buffer = NULL;
     506        }
    500507
    501508        /* RT_LAST means that the next bytes received should be a
    502509         * rt header - I know it's hax and maybe I'll fix it later on */
    503         if (rt_hdr.type == RT_LAST) {
     510        if (RT_INFO->rt_hdr.type == RT_LAST) {
    504511       
    505512                /* FIXME: Better error handling required */
     
    512519                /* Need to salvage these in case the next rt_read overwrites
    513520                 * the buffer they came from! */
    514                 rt_hdr.type = pkt_hdr->type;
    515                 rt_hdr.length = pkt_hdr->length;
    516                 rt_hdr.sequence = pkt_hdr->sequence;
    517         }
    518         packet->type = rt_hdr.type;
    519         packet->size = rt_hdr.length;
     521                RT_INFO->rt_hdr.type = pkt_hdr->type;
     522                RT_INFO->rt_hdr.length = pkt_hdr->length;
     523                RT_INFO->rt_hdr.sequence = pkt_hdr->sequence;
     524        }
     525        packet->type = RT_INFO->rt_hdr.type;
     526        packet->size = RT_INFO->rt_hdr.length;
    520527
    521528        if (packet->type >= RT_DATA_SIMPLE) {
    522                 if (rt_read(libtrace, &packet->buffer, rt_hdr.length,blocking) != rt_hdr.length) {
     529                if (rt_read(libtrace, &packet->buffer, RT_INFO->rt_hdr.length,blocking) != RT_INFO->rt_hdr.length) {
    523530                        return -1;
    524531                }
     
    526533               
    527534                if (RT_INFO->reliable > 0) {
    528                         if (rt_send_ack(libtrace, rt_hdr.sequence)
     535                        if (rt_send_ack(libtrace, RT_INFO->rt_hdr.sequence)
    529536                                        == -1)
    530537                        {
     
    535542                       
    536543                if (rt_set_format(libtrace, packet) < 0) {
    537                         return -1;
     544                        return -1;
    538545                }
    539546                rt_set_payload(packet);
     
    542549                        case RT_STATUS:
    543550                                if (rt_read(libtrace, &packet->buffer,
    544                                         rt_hdr.length, blocking) !=
    545                                                 rt_hdr.length) {
     551                                        RT_INFO->rt_hdr.length, blocking) !=
     552                                                RT_INFO->rt_hdr.length) {
    546553                                        return -1;
    547554                                }
     
    552559                        case RT_DUCK_2_5:
    553560                                if (rt_read(libtrace, &packet->buffer,
    554                                         rt_hdr.length, blocking) !=
    555                                                 rt_hdr.length) {
     561                                        RT_INFO->rt_hdr.length, blocking) !=
     562                                                RT_INFO->rt_hdr.length) {
    556563                                        return -1;
    557564                                }
     
    563570                                break;
    564571                        case RT_END_DATA:
    565                                 return 0;
     572                                break;
    566573                        case RT_PAUSE_ACK:
    567574                                /* FIXME: Do something useful */
     
    581588        }
    582589        /* Return the number of bytes read from the stream */
    583         rt_hdr.type = RT_LAST;
     590        RT_INFO->rt_hdr.type = RT_LAST;
    584591        return packet->size;
    585592}
     
    615622                case RT_KEYCHANGE:
    616623                        return 0;
     624                case RT_LOSTCONN:
     625                        return 0;
    617626        }
    618627        printf("Unknown type: %d\n", packet->type);
     
    656665                }
    657666        } else if (event.size == 0) {
    658                 event.type = TRACE_EVENT_TERMINATE;
     667                if (packet->type == RT_END_DATA)
     668                        event.type = TRACE_EVENT_TERMINATE;
     669                else
     670                        event.type = TRACE_EVENT_PACKET;
    659671               
    660672        }       
Note: See TracChangeset for help on using the changeset viewer.