Changeset 9e46ee7 for lib/trace.c


Ignore:
Timestamp:
04/11/06 14:52:58 (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:
d8fc342
Parents:
dd4b39b
Message:

Fix various bugs in protocols.c
Move trace_get_next_option from trace.c to protocols.c

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/trace.c

    r3be9a2b r9e46ee7  
    678678} legacy_framing_t;
    679679*/
    680 
    681 
    682 
    683 
    684 /* parse an ip or tcp option
    685  * @param[in,out] ptr   the pointer to the current option
    686  * @param[in,out] len   the length of the remaining buffer
    687  * @param[out] type     the type of the option
    688  * @param[out] optlen   the length of the option
    689  * @param[out] data     the data of the option
    690  *
    691  * @returns bool true if there is another option (and the fields are filled in)
    692  *               or false if this was the last option.
    693  *
    694  * This updates ptr to point to the next option after this one, and updates
    695  * len to be the number of bytes remaining in the options area.  Type is updated
    696  * to be the code of this option, and data points to the data of this option,
    697  * with optlen saying how many bytes there are.
    698  *
    699  * @note Beware of fragmented packets.
    700  * @author Perry Lorier
    701  */
    702 int trace_get_next_option(unsigned char **ptr,int *len,
    703                         unsigned char *type,
    704                         unsigned char *optlen,
    705                         unsigned char **data)
    706 {
    707         if (*len<=0)
    708                 return 0;
    709         *type=**ptr;
    710         switch(*type) {
    711                 case 0: /* End of options */
    712                         return 0;
    713                 case 1: /* Pad */
    714                         (*ptr)++;
    715                         (*len)--;
    716                         return 1;
    717                 default:
    718                         *optlen = *(*ptr+1);
    719                         if (*optlen<2)
    720                                 return 0; /* I have no idea wtf is going on
    721                                            * with these packets
    722                                            */
    723                         (*len)-=*optlen;
    724                         (*data)=(*ptr+2);
    725                         (*ptr)+=*optlen;
    726                         if (*len<0)
    727                                 return 0;
    728                         return 1;
    729         }
    730         assert(0);
    731 }
    732680
    733681
Note: See TracChangeset for help on using the changeset viewer.