Changeset fe7b292 for lib


Ignore:
Timestamp:
10/20/05 17:41:02 (16 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:
c95b923
Parents:
5496a87
Message:

Fixed issues in set_capture_length regarding the meaning of the parameters and return value

Location:
lib
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • lib/format_erf.c

    r734dfb1 rfe7b292  
    759759        dag_record_t *erfptr = 0;
    760760        assert(packet);
    761         if(size > packet->size) {
     761        if((size + sizeof(dag_record_t)) > packet->size) {
    762762                // can't make a packet larger
    763                 return packet->size;
     763                return (packet->size - sizeof(dag_record_t));
    764764        }
    765765        erfptr = (dag_record_t *)packet->buffer;
    766         erfptr->rlen = ntohs(size + sizeof(dag_record_t));
     766        erfptr->rlen = htons(size + sizeof(dag_record_t));
    767767        packet->size = size + sizeof(dag_record_t);
    768         return packet->size;
     768        return size;
    769769}
    770770
  • lib/format_pcap.c

    r9c6aa95 rfe7b292  
    369369        struct pcap_pkthdr *pcapptr = 0;
    370370        assert(packet);
    371         if (size > packet->size) {
     371        if ((size + sizeof(struct pcap_pkthdr)) > packet->size) {
    372372                // can't make a packet larger
    373                 return packet->size;
     373                return (packet->size - sizeof(struct pcap_pkthdr));
    374374        }
    375375        pcapptr = (struct pcap_pkthdr *)packet->buffer;
    376376        pcapptr->caplen = size + sizeof(struct pcap_pkthdr);
    377377        packet->size = pcapptr->caplen;
    378         return packet->size;
     378        return size;
    379379}
    380380
  • lib/trace.c

    r5496a87 rfe7b292  
    13461346 * @param packet        the packet opaque pointer
    13471347 * @param size          the new length of the packet
    1348  * @returns the new length of the packet, or the original length of the
    1349  * packet if unchanged
    1350  * NOTE: len refers to the network-level payload of the packet, and not
     1348 * @returns the new size of the packet
     1349 *
     1350 * NOTE: size and the return size refer to the network-level payload of the packet, and not
    13511351 * any capture headers included as well. For example, to truncate a packet
    1352  * after the IP header, set scan to sizeof(ethernet_header) + sizeof(ip_header)
     1352 * after the IP header, set size to sizeof(ethernet_header) + sizeof(ip_header)
     1353 *
     1354 * If the original network-level payload is smaller than size, then
     1355 * the original size is returned and the packet is left unchanged.
     1356 *
    13531357 * @author Daniel Lawson
    13541358 */
     
    13561360        assert(packet);
    13571361
    1358         if (size > packet->size) {
    1359                 // can't make a packet larger
    1360                 return packet->size;
    1361         }
    1362         if (packet->trace->format->set_capture_length) {
    1363                 return packet->trace->format->set_capture_length(packet,size);
    1364         }
     1362        if (packet->trace->format->truncate_packet) {
     1363                return packet->trace->format->truncate_packet(packet,size);
     1364        }
     1365
    13651366        return -1;
    13661367}
Note: See TracChangeset for help on using the changeset viewer.