Changeset f6c2d8d
- Timestamp:
- 05/23/06 13:40:23 (15 years ago)
- 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
- Location:
- libpacketdump/parser
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libpacketdump/parser/parser.h
r14b2010 rf6c2d8d 11 11 enum byte_order_t { 12 12 BIGENDIAN, 13 LITTLEENDIAN ,13 LITTLEENDIAN 14 14 }; 15 15 … … 20 20 DISPLAY_IPV4, 21 21 DISPLAY_MAC, 22 DISPLAY_FLAG ,22 DISPLAY_FLAG 23 23 }; 24 24 -
libpacketdump/parser/parser.y
r14b2010 rf6c2d8d 53 53 54 54 element: byteorder size output identifier { 55 node_t *n; 56 element_t *el; 55 57 /* create a new field node... */ 56 58 field_t *new_field = (field_t *)malloc(sizeof(field_t)); … … 61 63 62 64 /* to go inside a new node... */ 63 n ode_t *n= (node_t *)malloc(sizeof(node_t));65 n = (node_t *)malloc(sizeof(node_t)); 64 66 n->field = new_field; 65 67 66 68 /* to go inside a new element */ 67 el ement_t *el= (element_t *)malloc(sizeof(element_t));69 el = (element_t *)malloc(sizeof(element_t)); 68 70 el->type = FIELD; 69 71 el->next = NULL; … … 98 100 99 101 element_t *tmp; 102 node_t *n; 103 element_t *el; 100 104 next_t *nextheader = (next_t *)malloc(sizeof(next_t)); 101 105 nextheader->prefix = $2; … … 130 134 } 131 135 132 n ode_t *n= (node_t *)malloc(sizeof(node_t));136 n = (node_t *)malloc(sizeof(node_t)); 133 137 n->nextheader = nextheader; 134 138 135 el ement_t *el= (element_t *)malloc(sizeof(element_t));139 el = (element_t *)malloc(sizeof(element_t)); 136 140 el->type = NEXTHEADER; 137 141 el->next = NULL; … … 145 149 146 150 %% 147 //#include "parser.lexer.c"148 151 149 152 element_t* parse_protocol_file(char *filename) 150 153 { 151 / / hold onto this so we can put it in any error messages154 /* hold onto this so we can put it in any error messages */ 152 155 file = filename; 153 156 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 */ 156 160 yyin = fopen(filename, "r"); 157 161 if(!yyin) … … 180 184 while(bits < (sizeof(bitbuffer_t)-1)*8 && *packlen > 0) 181 185 { 182 / / read in one byte from the packet186 /* read in one byte from the packet */ 183 187 buffer |= ((* ((bitbuffer_t*)*packet) )&0xff) << bits; 184 / / update the position within the packet188 /* update the position within the packet */ 185 189 *packet = ((char*)*packet) + 1; 186 190 … … 189 193 } 190 194 191 / / our return value is the last <numbits> of the buffer195 /* our return value is the last <numbits> of the buffer */ 192 196 ret = buffer & ( (one<<numbits) -1); 193 197 194 / / remove the bits that are being returned from out buffer198 /* remove the bits that are being returned from out buffer */ 195 199 buffer >>= numbits; 196 200 197 / / and update our position inside this buffer201 /* and update our position inside this buffer */ 198 202 bits -= numbits; 199 203 … … 205 209 { 206 210 bitbuffer_t one = 1; 211 bitbuffer_t lhs; 212 bitbuffer_t rhs;; 207 213 208 214 /* … … 221 227 return ntohl(value); 222 228 223 bitbuffer_tlhs = ntohl(value& ((one<<32)-1));224 bitbuffer_trhs = ntohl(value >> 32);229 lhs = ntohl(value& ((one<<32)-1)); 230 rhs = ntohl(value >> 32); 225 231 return ((lhs<<32) | rhs); 226 232 … … 230 236 }; 231 237 232 / / should never get here238 /* should never get here */ 233 239 assert(0); 234 240 return 0; … … 246 252 { 247 253 case FIELD: 254 if (len*8+bits<el->data->field->size) { 255 printf(" [Truncated]\n"); 256 return; 257 } 248 258 result = getbit((void*)&packet, &len, el->data->field->size); 249 259 … … 447 457 break; 448 458 }; 449 / /printf("%s\n", list->data->identifier);459 /*printf("%s\n", list->data->identifier); */ 450 460 print_list(list->next); 451 461 }
Note: See TracChangeset
for help on using the changeset viewer.