- Timestamp:
- 03/15/10 16:58:28 (12 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:
- 4811b1e
- Parents:
- 91c38f8
- Location:
- lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/format_legacy.c
r238d50a r7fc0eaa2 349 349 * - Perry Lorier (2008-11-04) 350 350 */ 351 352 /* It can also be CHDLC, which is different again */ 353 354 /* This check matchs PPP over HDLC, a la RFC 1662 */ 351 355 if (((char *)packet->payload)[0] == '\xFF' 352 356 && ((char*)packet->payload)[1] == '\x03') 353 357 return TRACE_TYPE_POS; 358 359 /* This check matches unicast CHDLC */ 360 else if (((char *)packet->payload)[0] == '\x0F' && 361 ((char*)packet->payload)[1] == '\x00') 362 return TRACE_TYPE_HDLC_POS; 363 364 /* This check matches broadcast CHDLC */ 365 else if (((char *)packet->payload)[0] == '\x8F' && 366 ((char*)packet->payload)[1] == '\x00') 367 return TRACE_TYPE_HDLC_POS; 368 369 /* Otherwise just assume raw PPP (?) */ 354 370 else 355 371 return TRACE_TYPE_PPP; -
lib/protocols_l2.c
rf6730d8 r7fc0eaa2 251 251 } 252 252 253 253 /* Header for CHDLC framing */ 254 254 typedef struct libtrace_chdlc_t { 255 255 uint8_t address; /** 0xF0 for unicast, 0xF8 for multicast */ 256 uint8_t control; 256 uint8_t control; /** Always 0x00 */ 257 257 uint16_t ethertype; 258 258 } libtrace_chdlc_t; 259 259 260 static void *trace_get_payload_from_chdlc(void *link, 260 /* Header for PPP in HDLC-like framing */ 261 typedef struct libtrace_ppp_hdlc_t { 262 uint8_t address; /** Always should be 0xff */ 263 uint8_t control; /** Always should be 0x03 */ 264 uint16_t protocol; 265 } libtrace_ppp_hdlc_t; 266 267 static void *trace_get_payload_from_chdlc(void *link, uint16_t *type, 268 uint32_t *remaining) { 269 270 libtrace_chdlc_t *chdlc = (libtrace_chdlc_t *)link; 271 272 if (remaining) { 273 if (*remaining < sizeof(libtrace_chdlc_t)) { 274 *remaining = 0; 275 return NULL; 276 } 277 *remaining -= sizeof(libtrace_chdlc_t); 278 } 279 280 if (type) { 281 *type = ntohs(chdlc->ethertype); 282 } 283 284 return (void *)((char *)chdlc + sizeof(*chdlc)); 285 286 } 287 288 static void *trace_get_payload_from_ppp_hdlc(void *link, 261 289 uint16_t *type, uint32_t *remaining) 262 290 { 263 libtrace_ chdlc_t *chdlc = (libtrace_chdlc_t*)link;264 265 if (remaining) { 266 if (*remaining < sizeof(libtrace_ chdlc_t)) {267 *remaining = 0; 268 return NULL; 269 } 270 *remaining-=sizeof(libtrace_ chdlc_t);291 libtrace_ppp_hdlc_t *ppp_hdlc = (libtrace_ppp_hdlc_t*)link; 292 293 if (remaining) { 294 if (*remaining < sizeof(libtrace_ppp_hdlc_t)) { 295 *remaining = 0; 296 return NULL; 297 } 298 *remaining-=sizeof(libtrace_ppp_hdlc_t); 271 299 } 272 300 273 301 if (type) { 274 switch(ntohs(chdlc->ethertype)) { 302 /* http://www.iana.org/assignments/ppp-numbers */ 303 304 switch(ntohs(ppp_hdlc->protocol)) { 275 305 case 0x0021: /* IP */ 276 306 *type = TRACE_ETHERTYPE_IP; … … 281 311 282 312 default: 283 printf("Unknown chdlc type: %04x\n",ntohs(chdlc->ethertype)); 313 printf("Unknown chdlc type: %04x\n", 314 ntohs(ppp_hdlc->protocol)); 284 315 *type = 0; /* Unknown */ 285 316 } … … 287 318 288 319 289 return (void*)((char *) chdlc+sizeof(*chdlc));320 return (void*)((char *)ppp_hdlc+sizeof(*ppp_hdlc)); 290 321 } 291 322 … … 413 444 remaining); 414 445 case TRACE_TYPE_POS: 415 return trace_get_payload_from_ chdlc(link,ethertype,446 return trace_get_payload_from_ppp_hdlc(link,ethertype, 416 447 remaining); 417 448 /* TODO: Unsupported */
Note: See TracChangeset
for help on using the changeset viewer.