Changeset f6c2d8d


Ignore:
Timestamp:
05/23/06 13:40:23 (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:
1b95fd0
Parents:
440a60f
Message:

Don't try and continue to decode a snapped packet.
Lots of warning cleanups.

Location:
libpacketdump/parser
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libpacketdump/parser/parser.h

    r14b2010 rf6c2d8d  
    1111enum byte_order_t {
    1212    BIGENDIAN,
    13     LITTLEENDIAN,
     13    LITTLEENDIAN
    1414};
    1515
     
    2020    DISPLAY_IPV4,
    2121    DISPLAY_MAC,
    22     DISPLAY_FLAG,
     22    DISPLAY_FLAG
    2323};
    2424
  • libpacketdump/parser/parser.y

    r14b2010 rf6c2d8d  
    5353
    5454element:    byteorder size output identifier {
     55                node_t *n;
     56                element_t *el;
    5557                /* create a new field node... */
    5658                field_t *new_field = (field_t *)malloc(sizeof(field_t));
     
    6163
    6264                /* to go inside a new node... */
    63                 node_t *n = (node_t *)malloc(sizeof(node_t));
     65                n = (node_t *)malloc(sizeof(node_t));
    6466                n->field = new_field;
    6567
    6668                /* to go inside a new element */
    67                 element_t *el = (element_t *)malloc(sizeof(element_t));         
     69                el = (element_t *)malloc(sizeof(element_t));           
    6870                el->type = FIELD;
    6971                el->next = NULL;
     
    98100
    99101                element_t *tmp;
     102                node_t *n;
     103                element_t *el;
    100104                next_t *nextheader = (next_t *)malloc(sizeof(next_t));
    101105                nextheader->prefix = $2;
     
    130134                }
    131135               
    132                 node_t *n = (node_t *)malloc(sizeof(node_t));
     136                n = (node_t *)malloc(sizeof(node_t));
    133137                n->nextheader = nextheader;
    134138
    135                 element_t *el = (element_t *)malloc(sizeof(element_t));         
     139                el = (element_t *)malloc(sizeof(element_t));           
    136140                el->type = NEXTHEADER;
    137141                el->next = NULL;
     
    145149
    146150%%
    147 //#include "parser.lexer.c"
    148151
    149152element_t* parse_protocol_file(char *filename)
    150153{
    151     // hold onto this so we can put it in any error messages
     154    /* hold onto this so we can put it in any error messages */
    152155    file = filename;
    153156
    154     // if the protocol file doesn't exist, we return null and
    155     // it will fall back to using the generic_decode function
     157    /* if the protocol file doesn't exist, we return null and
     158     * it will fall back to using the generic_decode function
     159     */
    156160    yyin = fopen(filename, "r");
    157161    if(!yyin)
     
    180184    while(bits < (sizeof(bitbuffer_t)-1)*8 && *packlen > 0)
    181185    {
    182         // read in one byte from the packet
     186        /* read in one byte from the packet */
    183187        buffer |= ((*  ((bitbuffer_t*)*packet)   )&0xff) << bits;
    184         // update the position within the packet
     188        /* update the position within the packet */
    185189        *packet = ((char*)*packet) + 1;
    186190
     
    189193    }
    190194
    191     // our return value is the last <numbits> of the buffer
     195    /* our return value is the last <numbits> of the buffer */
    192196    ret = buffer & (   (one<<numbits)   -1);
    193197   
    194     // remove the bits that are being returned from out buffer
     198    /* remove the bits that are being returned from out buffer */
    195199    buffer >>= numbits;
    196200
    197     // and update our position inside this buffer
     201    /* and update our position inside this buffer */
    198202    bits -= numbits;
    199203
     
    205209{
    206210    bitbuffer_t one = 1;
     211    bitbuffer_t lhs;
     212    bitbuffer_t rhs;;
    207213
    208214    /*
     
    221227                return ntohl(value);
    222228           
    223             bitbuffer_t lhs = ntohl(value& ((one<<32)-1));
    224             bitbuffer_t rhs = ntohl(value >> 32);
     229            lhs = ntohl(value& ((one<<32)-1));
     230            rhs = ntohl(value >> 32);
    225231            return ((lhs<<32) | rhs);
    226232
     
    230236    };
    231237
    232     // should never get here
     238    /* should never get here */
    233239    assert(0);
    234240    return 0;
     
    246252        {
    247253            case FIELD:
     254                if (len*8+bits<el->data->field->size) {
     255                        printf(" [Truncated]\n");
     256                        return;
     257                }
    248258                result = getbit((void*)&packet, &len, el->data->field->size);
    249259
     
    447457                            break;
    448458    };
    449     //printf("%s\n", list->data->identifier);
     459    /*printf("%s\n", list->data->identifier); */
    450460    print_list(list->next);
    451461}
Note: See TracChangeset for help on using the changeset viewer.