Changeset 9d89626
- Timestamp:
- 03/26/15 11:44:45 (6 years ago)
- Branches:
- 4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, 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:
- f50515e
- Parents:
- e99c493
- Location:
- lib
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/format_linux_common.c
r6b98325 r9d89626 681 681 #endif /* HAVE_NETPACKET_PACKET_H */ 682 682 683 684 inline libtrace_direction_t linuxcommon_get_direction(uint8_t pkttype)685 {686 switch (pkttype) {687 case PACKET_OUTGOING:688 case PACKET_LOOPBACK:689 return TRACE_DIR_OUTGOING;690 case PACKET_OTHERHOST:691 return TRACE_DIR_OTHER;692 default:693 return TRACE_DIR_INCOMING;694 }695 }696 697 inline libtrace_direction_t698 linuxcommon_set_direction(struct sockaddr_ll * skadr,699 libtrace_direction_t direction)700 {701 switch (direction) {702 case TRACE_DIR_OUTGOING:703 skadr->sll_pkttype = PACKET_OUTGOING;704 return TRACE_DIR_OUTGOING;705 case TRACE_DIR_INCOMING:706 skadr->sll_pkttype = PACKET_HOST;707 return TRACE_DIR_INCOMING;708 case TRACE_DIR_OTHER:709 skadr->sll_pkttype = PACKET_OTHERHOST;710 return TRACE_DIR_OTHER;711 default:712 return -1;713 }714 }715 716 inline libtrace_linktype_t linuxcommon_get_link_type(uint16_t linktype)717 {718 /* Convert the ARPHRD type into an appropriate libtrace link type */719 switch (linktype) {720 case LIBTRACE_ARPHRD_ETHER:721 case LIBTRACE_ARPHRD_LOOPBACK:722 return TRACE_TYPE_ETH;723 case LIBTRACE_ARPHRD_PPP:724 return TRACE_TYPE_NONE;725 case LIBTRACE_ARPHRD_IEEE80211_RADIOTAP:726 return TRACE_TYPE_80211_RADIO;727 case LIBTRACE_ARPHRD_IEEE80211:728 return TRACE_TYPE_80211;729 case LIBTRACE_ARPHRD_SIT:730 case LIBTRACE_ARPHRD_NONE:731 return TRACE_TYPE_NONE;732 default: /* shrug, beyond me! */733 printf("unknown Linux ARPHRD type 0x%04x\n",linktype);734 return (libtrace_linktype_t)~0U;735 }736 } -
lib/format_linux_common.h
r0a52945 r9d89626 326 326 327 327 void linuxcommon_get_statistics(libtrace_t *libtrace, libtrace_stat_t *stat); 328 inline libtrace_direction_t linuxcommon_get_direction(uint8_t pkttype); 329 inline libtrace_direction_t linuxcommon_set_direction(struct sockaddr_ll * skadr, 330 libtrace_direction_t direction); 331 inline libtrace_linktype_t linuxcommon_get_link_type(uint16_t linktype); 332 328 329 static inline libtrace_direction_t linuxcommon_get_direction(uint8_t pkttype) 330 { 331 switch (pkttype) { 332 case PACKET_OUTGOING: 333 case PACKET_LOOPBACK: 334 return TRACE_DIR_OUTGOING; 335 case PACKET_OTHERHOST: 336 return TRACE_DIR_OTHER; 337 default: 338 return TRACE_DIR_INCOMING; 339 } 340 } 341 342 static inline libtrace_direction_t 343 linuxcommon_set_direction(struct sockaddr_ll * skadr, 344 libtrace_direction_t direction) 345 { 346 switch (direction) { 347 case TRACE_DIR_OUTGOING: 348 skadr->sll_pkttype = PACKET_OUTGOING; 349 return TRACE_DIR_OUTGOING; 350 case TRACE_DIR_INCOMING: 351 skadr->sll_pkttype = PACKET_HOST; 352 return TRACE_DIR_INCOMING; 353 case TRACE_DIR_OTHER: 354 skadr->sll_pkttype = PACKET_OTHERHOST; 355 return TRACE_DIR_OTHER; 356 default: 357 return -1; 358 } 359 } 360 361 static inline libtrace_linktype_t linuxcommon_get_link_type(uint16_t linktype) 362 { 363 /* Convert the ARPHRD type into an appropriate libtrace link type */ 364 switch (linktype) { 365 case LIBTRACE_ARPHRD_ETHER: 366 case LIBTRACE_ARPHRD_LOOPBACK: 367 return TRACE_TYPE_ETH; 368 case LIBTRACE_ARPHRD_PPP: 369 return TRACE_TYPE_NONE; 370 case LIBTRACE_ARPHRD_IEEE80211_RADIOTAP: 371 return TRACE_TYPE_80211_RADIO; 372 case LIBTRACE_ARPHRD_IEEE80211: 373 return TRACE_TYPE_80211; 374 case LIBTRACE_ARPHRD_SIT: 375 case LIBTRACE_ARPHRD_NONE: 376 return TRACE_TYPE_NONE; 377 default: /* shrug, beyond me! */ 378 printf("unknown Linux ARPHRD type 0x%04x\n",linktype); 379 return (libtrace_linktype_t)~0U; 380 } 381 } 333 382 334 383 #endif /* FORMAT_LINUX_COMMON_H */ -
lib/format_linux_ring.c
r6b98325 r9d89626 63 63 #include "format_linux_common.h" 64 64 65 /* Get the start of the captured data. I'm not sure if tp_mac (link layer) is 66 * always guaranteed. If it's not there then just use tp_net. 67 */ 68 #define TP_TRACE_START(mac, net, hdrend) \ 69 ((mac) > (hdrend) && (mac) < (net) ? (mac) : (net)) 70 65 71 #ifdef HAVE_NETPACKET_PACKET_H 66 72 /* Get current frame in the ring buffer*/ … … 69 75 (stream->rxring_offset * \ 70 76 stream->req.tp_frame_size)) 71 #endif 72 73 /* Get the start of the captured data. I'm not sure if tp_mac (link layer) is 74 * always guaranteed. If it's not there then just use tp_net. 75 */ 76 #define TP_TRACE_START(mac, net, hdrend) \ 77 ((mac) > (hdrend) && (mac) < (net) ? (mac) : (net)) 77 78 78 /* Cached page size, the page size shouldn't be changing */ 79 79 static int pagesize = 0; … … 351 351 return 0; 352 352 } 353 #endif /* HAVE_NETPACKET_PACKET_H */ 353 354 354 355 static libtrace_linktype_t … … 454 455 return 0; 455 456 } 457 458 #ifdef HAVE_NETPACKET_PACKET_H 456 459 #define LIBTRACE_MIN(a,b) ((a)<(b) ? (a) : (b)) 457 460 inline static int linuxring_read_stream(libtrace_t *libtrace, … … 700 703 701 704 } 702 703 #ifdef HAVE_NETPACKET_PACKET_H704 705 705 706 static void linuxring_help(void) … … 765 766 NULL /* get thread stats */ 766 767 }; 767 #else 768 #else /* HAVE_NETPACKET_PACKET_H */ 768 769 769 770 static void linuxring_help(void) … … 816 817 NON_PARALLEL(true) 817 818 }; 818 #endif 819 #endif /* HAVE_NETPACKET_PACKET_H */ 819 820 820 821 /* TODO: Figure out how to give this format preference over the linux native
Note: See TracChangeset
for help on using the changeset viewer.