- Timestamp:
- 04/11/06 14:52:58 (16 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:
- d8fc342
- Parents:
- dd4b39b
- Location:
- lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/protocols.c
r67a14d4 r9e46ee7 54 54 } 55 55 56 return NULL;56 return ethernet; 57 57 } 58 58 … … 193 193 { 194 194 uint16_t type; 195 void *ret=trace_get_payload_from_link( 196 trace_get_link(packet), 195 void *link = trace_get_link(packet); 196 void *ret; 197 198 if (!link) 199 return NULL; 200 201 ret=trace_get_payload_from_link( 202 link, 197 203 trace_get_link_type(packet), 198 204 &type, NULL); … … 212 218 { 213 219 uint16_t type; 214 void *ret=trace_get_payload_from_link( 215 trace_get_link(packet), 220 void *link=trace_get_link(packet); 221 void *ret; 222 223 if (!link) 224 return NULL; 225 226 ret=trace_get_payload_from_link( 227 link, 216 228 trace_get_link_type(packet), 217 229 &type,NULL); … … 303 315 uint8_t dummy; 304 316 uint16_t ethertype; 317 void *link; 305 318 306 319 if (!proto) proto=&dummy; … … 309 322 *remaining = trace_get_capture_length(packet); 310 323 324 link=trace_get_link(packet); 325 326 if (!link) 327 return NULL; 328 311 329 transport = trace_get_payload_from_link( 312 trace_get_link(packet),330 link, 313 331 trace_get_link_type(packet), 314 332 ðertype, … … 325 343 return NULL; 326 344 327 switch ( *proto) {345 switch (ethertype) { 328 346 case 0x0800: /* IPv4 */ 329 347 transport=trace_get_payload_from_ip( … … 351 369 tcp=(libtrace_tcp_t*)trace_get_transport(packet,&proto,NULL); 352 370 353 if ( proto != 6)371 if (!tcp && proto != 6) 354 372 return NULL; 355 373 … … 646 664 } 647 665 666 /* parse an ip or tcp option 667 * @param[in,out] ptr the pointer to the current option 668 * @param[in,out] len the length of the remaining buffer 669 * @param[out] type the type of the option 670 * @param[out] optlen the length of the option 671 * @param[out] data the data of the option 672 * 673 * @returns bool true if there is another option (and the fields are filled in) 674 * or false if this was the last option. 675 * 676 * This updates ptr to point to the next option after this one, and updates 677 * len to be the number of bytes remaining in the options area. Type is updated 678 * to be the code of this option, and data points to the data of this option, 679 * with optlen saying how many bytes there are. 680 * 681 * @note Beware of fragmented packets. 682 * @author Perry Lorier 683 */ 684 int trace_get_next_option(unsigned char **ptr,int *len, 685 unsigned char *type, 686 unsigned char *optlen, 687 unsigned char **data) 688 { 689 if (*len<=0) 690 return 0; 691 *type=**ptr; 692 switch(*type) { 693 case 0: /* End of options */ 694 return 0; 695 case 1: /* Pad */ 696 (*ptr)++; 697 (*len)--; 698 return 1; 699 default: 700 *optlen = *(*ptr+1); 701 if (*optlen<2) 702 return 0; /* I have no idea wtf is going on 703 * with these packets 704 */ 705 (*len)-=*optlen; 706 (*data)=(*ptr+2); 707 (*ptr)+=*optlen; 708 if (*len<0) 709 return 0; 710 return 1; 711 } 712 assert(0); 713 } 714 715 -
lib/trace.c
r3be9a2b r9e46ee7 678 678 } legacy_framing_t; 679 679 */ 680 681 682 683 684 /* parse an ip or tcp option685 * @param[in,out] ptr the pointer to the current option686 * @param[in,out] len the length of the remaining buffer687 * @param[out] type the type of the option688 * @param[out] optlen the length of the option689 * @param[out] data the data of the option690 *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 updates695 * len to be the number of bytes remaining in the options area. Type is updated696 * 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 Lorier701 */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 on721 * with these packets722 */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 }732 680 733 681
Note: See TracChangeset
for help on using the changeset viewer.