Changeset 41ab052


Ignore:
Timestamp:
05/25/06 18:46:51 (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:
701e164
Parents:
49e3fff
Message:

Fix bitordering issues

Location:
libpacketdump/parser
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • libpacketdump/parser/Makefile.am

    rfc3dcfa r41ab052  
    33
    44#libparser_la_SOURCES = libconfig.c libconfig.h config_internal.h config.lexer.c config.parser.h configuration.h config.parser.c
    5 libparser_la_SOURCES = parser.lexer.c parser.tab.c parser.h
     5libparser_la_SOURCES = parser.lexer.c parser.tab.c parser.h bitbuffer.c
    66libparser_la_LIBADD = @ADD_LIBS@ @LEXLIB@
    77libparser_la_LDFLAGS = @ADD_LDFLAGS@ -L../
  • libpacketdump/parser/parser.h

    rf6c2d8d r41ab052  
    5353void decode_protocol_file(uint16_t link_type,char *packet,int len, element_t* el);
    5454
     55typedef uint64_t bitbuffer_t;
    5556#endif
  • libpacketdump/parser/parser.y

    rf6c2d8d r41ab052  
    1212    #define YYERROR_VERBOSE 1
    1313
    14     typedef uint64_t bitbuffer_t;
    1514   
    1615    int yylex(void);
     
    150149%%
    151150
     151#include "bitbuffer.h"
     152
    152153element_t* parse_protocol_file(char *filename)
    153154{
     
    172173
    173174
    174 bitbuffer_t getbit(void **packet, int *packlen, uint64_t numbits)
    175 {
    176     bitbuffer_t ret;
    177     bitbuffer_t one = 1;
    178 
    179     /* While the buffer is not filled up and there is still
    180      * data in the packet to read, read a byte...
    181      *
    182      * The buffer gets filled from right to left
    183      */
    184     while(bits < (sizeof(bitbuffer_t)-1)*8 && *packlen > 0)
    185     {
    186         /* read in one byte from the packet */
    187         buffer |= ((*  ((bitbuffer_t*)*packet)   )&0xff) << bits;
    188         /* update the position within the packet */
    189         *packet = ((char*)*packet) + 1;
    190 
    191         bits += 8;
    192         *packlen -= 1;
    193     }
    194 
    195     /* our return value is the last <numbits> of the buffer */
    196     ret = buffer & (   (one<<numbits)   -1);
    197    
    198     /* remove the bits that are being returned from out buffer */
    199     buffer >>= numbits;
    200 
    201     /* and update our position inside this buffer */
    202     bits -= numbits;
    203 
    204     return ret;
    205 }
    206175
    207176
     
    371340
    372341                decode_next(packet, len, el->data->nextheader->prefix,
    373                         el->data->nextheader->target->value);
     342                        ntohs(el->data->nextheader->target->value));
    374343                break;
    375344        };
Note: See TracChangeset for help on using the changeset viewer.