Changeset 17c5749
- Timestamp:
- 07/22/14 12:57:50 (7 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:
- 41148f2
- Parents:
- 54834a1 (diff), a6c77b0 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Files:
-
- 11 added
- 26 edited
Legend:
- Unmodified
- Added
- Removed
-
README
rf1015ad r17c5749 4 4 Libtrace functions might not function correctly breaking the supplied tools. 5 5 6 libtrace 3.0. 196 libtrace 3.0.20 7 7 8 8 --------------------------------------------------------------------------- -
configure.in
rabf01b6 r457bf45 4 4 # and in the README 5 5 6 AC_INIT([libtrace],[3.0. 19],[contact@wand.net.nz],[libtrace])6 AC_INIT([libtrace],[3.0.20],[contact@wand.net.nz],[libtrace]) 7 7 8 8 LIBTRACE_MAJOR=3 9 9 LIBTRACE_MID=0 10 LIBTRACE_MINOR= 1910 LIBTRACE_MINOR=20 11 11 12 12 # OpenSolaris hides libraries like libncurses in /usr/gnu/lib, which is not … … 580 580 ) 581 581 582 AC_ARG_WITH([lzma], 583 AC_HELP_STRING([--with-lzma], [build with support for lzma compressed files])) 584 585 AS_IF([test "x$with_lzma" != "xno"], 586 [ 587 AC_CHECK_HEADER(lzma.h, have_lzma=yes, have_lzma=no) 588 ], [have_lzma=no]) 589 590 AS_IF([test "x$have_lzma" = "xyes"], [ 591 if test "$ac_cv_lib_lzma_code" != "none required"; then 592 LIBWANDIO_LIBS="$LIBWANDIO_LIBS -llzma" 593 fi 594 AC_DEFINE(HAVE_LIBLZMA, 1, "Compiled with lzma support") 595 with_lzma=yes], 596 597 598 [AS_IF([test "x$with_lzma" = "xyes"], 599 [AC_MSG_ERROR([lzma requested but not found])]) 600 AC_DEFINE(HAVE_LIBLZMA, 0, "Compiled with lzma support") 601 with_lzma=no] 602 ) 582 603 583 604 # Define automake conditionals for use in our Makefile.am files … … 594 615 AM_CONDITIONAL([HAVE_ZLIB], [test "x$with_zlib" != "xno"]) 595 616 AM_CONDITIONAL([HAVE_LZO], [ test "x$with_lzo" != "xno"]) 617 AM_CONDITIONAL([HAVE_LZMA], [ test "x$with_lzma" != "xno"]) 596 618 597 619 # Check for miscellaneous programs … … 648 670 reportopt "Compiled with compressed trace (bz2) support" $with_bzip2 649 671 reportopt "Compiled with compressed trace (lzo write only) support" $with_lzo 672 reportopt "Compiled with compressed trace (lzma) support" $with_lzma 650 673 if test x"$libtrace_dag" = xtrue; then 651 674 if test "$libtrace_dag_version" = 24; then -
lib/format_linux.c
rbcfe4ea r17c5749 1109 1109 if (check_queue) { 1110 1110 // Check for a packet - TODO only Linux has MSG_DONTWAIT should use fctl O_NONBLOCK 1111 hdr->wirelen = recvmsg(fd, &msghdr, MSG_DONTWAIT );1111 hdr->wirelen = recvmsg(fd, &msghdr, MSG_DONTWAIT | MSG_TRUNC); 1112 1112 if ((int) hdr->wirelen == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)) { 1113 1113 // Do message queue check or select … … 1136 1136 } 1137 1137 } else { 1138 hdr->wirelen = recvmsg(fd, &msghdr, 0);1138 hdr->wirelen = recvmsg(fd, &msghdr, MSG_TRUNC); 1139 1139 } 1140 1140 -
lib/format_pcap.c
rb13b939 r17c5749 578 578 static libtrace_direction_t pcap_set_direction(libtrace_packet_t *packet, 579 579 libtrace_direction_t dir) { 580 580 581 /* We only support tagging with IN or OUT return error for any others */ 582 if(!(dir == TRACE_DIR_OUTGOING || dir == TRACE_DIR_INCOMING)) 583 return -1; 584 581 585 /* PCAP doesn't have a direction field in the header, so we need to 582 586 * promote to Linux SLL to tag it properly */ -
lib/libtrace.h.in
r50ce607 r17c5749 883 883 uint8_t ospf_v; /**< OSPF Version, should be 2 */ 884 884 uint8_t type; /**< OSPF Packet Type */ 885 uint16_t len;/**< Packet length, including OSPF header */885 uint16_t ospf_len; /**< Packet length, including OSPF header */ 886 886 struct in_addr router; /**< Router ID of the packet source */ 887 887 struct in_addr area; /**< Area the packet belongs to */ … … 1255 1255 TRACE_OPTION_COMPRESSTYPE_BZ2 = 2, /**< BZip2 Compression */ 1256 1256 TRACE_OPTION_COMPRESSTYPE_LZO = 3, /**< LZO Compression */ 1257 TRACE_OPTION_COMPRESSTYPE_LZMA = 4, /**< LZO Compression */ 1257 1258 TRACE_OPTION_COMPRESSTYPE_LAST 1258 1259 } trace_option_compresstype_t; … … 1795 1796 DLLEXPORT uint16_t *trace_checksum_transport(libtrace_packet_t *packet, 1796 1797 uint16_t *csum); 1798 1799 /** Calculates the fragment offset in bytes for an IP packet 1800 * @param packet The libtrace packet to calculate the offset for 1801 * @param[out] more A boolean flag to indicate whether there are more 1802 * fragments after the current packet. 1803 * @return The fragment offset for the packet in bytes. If the packet is not 1804 * an IP packet or the fragment offset is not present in packet, the return 1805 * value will be 0. 1806 * 1807 * @note The value returned is in bytes, not 8-octet units as it is stored 1808 * in the fragment offset field in the headers. In other words, libtrace 1809 * automatically does the multiplication for you. 1810 * 1811 * The value passed in for 'more' does not matter; it will be overwritten 1812 * with the value of the More Fragments flag from the IP header. 1813 * 1814 * New in libtrace 3.0.20 1815 */ 1816 DLLEXPORT uint16_t trace_get_fragment_offset(const libtrace_packet_t *packet, 1817 uint8_t *more); 1797 1818 1798 1819 /** Gets a pointer to the transport layer header (if any) -
lib/protocols_l3.c
r9ca1fce r7baa948 724 724 } 725 725 726 DLLEXPORT uint16_t trace_get_fragment_offset(const libtrace_packet_t *packet, 727 uint8_t *more) { 728 729 void *l3; 730 uint16_t ethertype; 731 uint32_t remaining; 732 733 *more = 0; 734 735 l3 = trace_get_layer3(packet, ðertype, &remaining); 736 if (l3 == NULL) 737 return 0; 738 739 if (ethertype == TRACE_ETHERTYPE_IP) { 740 libtrace_ip_t *ip = (libtrace_ip_t *)l3; 741 uint16_t offset = 0; 742 743 /* Fragment offset appears in 7th and 8th bytes */ 744 if (remaining < 8) 745 return 0; 746 747 offset = ntohs(ip->ip_off); 748 749 if ((offset & 0x2000) != 0) 750 *more = 1; 751 return (offset & 0x1FFF) * 8; 752 } 753 754 if (ethertype == TRACE_ETHERTYPE_IPV6) { 755 libtrace_ip6_t *ip6 = (libtrace_ip6_t *)l3; 756 void *payload = ip6++; 757 uint8_t nxt = ip6->nxt; 758 uint16_t len; 759 760 /* First task, find a Fragment header if present */ 761 if (remaining < sizeof(libtrace_ip6_t)) 762 return 0; 763 remaining -= sizeof(libtrace_ip6_t); 764 765 /* Adapted from trace_get_payload_from_ip6 */ 766 while (1) { 767 switch (nxt) { 768 case 0: 769 case TRACE_IPPROTO_ROUTING: 770 case TRACE_IPPROTO_AH: 771 case TRACE_IPPROTO_DSTOPTS: 772 { 773 774 /* Length does not include the first 8 bytes */ 775 len=((libtrace_ip6_ext_t*)payload)->len * 8; 776 len += 8; 777 778 if (remaining < len) { 779 /* Snap too short */ 780 return 0; 781 } 782 remaining-=len; 783 784 nxt=((libtrace_ip6_ext_t*)payload)->nxt; 785 continue; 786 } 787 case TRACE_IPPROTO_FRAGMENT: 788 { 789 libtrace_ip6_frag_t *frag = (libtrace_ip6_frag_t *)payload; 790 uint16_t offset; 791 len = sizeof(libtrace_ip6_frag_t); 792 if (remaining < len) { 793 /* Snap too short */ 794 return 0; 795 } 796 remaining-=len; 797 798 offset = ntohs(frag->frag_off); 799 if ((offset & 0x0001) != 0) 800 *more = 1; 801 802 return ((offset & 0xFFF8) >> 3) * 8; 803 } 804 default: 805 return 0; 806 } 807 } 808 809 } 810 return 0; 811 } -
lib/protocols_transport.c
r10f924c re0bea4e5 382 382 uint32_t remaining; 383 383 uint8_t proto; 384 const struct ports_t *port = 385 (const struct ports_t*)trace_get_transport((libtrace_packet_t*)packet, 384 struct ports_t *port; 385 uint16_t fragoff; 386 uint8_t more; 387 388 fragoff = trace_get_fragment_offset(packet, &more); 389 390 /* If we're not the first fragment, we're unlikely to be able 391 * to get any useful port numbers from this packet. 392 */ 393 if (fragoff != 0) 394 return 0; 395 396 397 port = (struct ports_t*)trace_get_transport( 398 (libtrace_packet_t*)packet, 386 399 &proto, &remaining); 387 400 … … 391 404 392 405 /* ICMP *technically* doesn't have ports */ 393 if (proto == TRACE_IPPROTO_ICMP )406 if (proto == TRACE_IPPROTO_ICMP || proto == TRACE_IPPROTO_ICMPV6) 394 407 return 0; 395 408 … … 405 418 uint32_t remaining; 406 419 uint8_t proto; 407 struct ports_t *port = 408 (struct ports_t*)trace_get_transport((libtrace_packet_t*)packet, 420 struct ports_t *port; 421 uint16_t fragoff; 422 uint8_t more; 423 424 fragoff = trace_get_fragment_offset(packet, &more); 425 426 /* If we're not the first fragment, we're unlikely to be able 427 * to get any useful port numbers from this packet. 428 */ 429 if (fragoff != 0) 430 return 0; 431 432 433 port = (struct ports_t*)trace_get_transport( 434 (libtrace_packet_t*)packet, 409 435 &proto, &remaining); 410 436 /* Snapped too early */ … … 413 439 414 440 /* ICMP *technically* doesn't have ports */ 415 if (proto == TRACE_IPPROTO_ICMP )441 if (proto == TRACE_IPPROTO_ICMP || proto == TRACE_IPPROTO_ICMPV6) 416 442 return 0; 417 443 -
libpacketdump/eth_2048.c
r66ad025 r387d299 10 10 #include <netdb.h> 11 11 12 #define DISPLAY_EXP(x,fmt,exp) \13 if ((unsigned int)len>=((char*)&ip->x-(char*)ip+sizeof(ip->x))) \14 printf(fmt,exp); \15 else \16 return;17 18 #define DISPLAY(x,fmt) DISPLAY_EXP(x,fmt,ip->x)19 20 #define DISPLAYS(x,fmt) DISPLAY_EXP(x,fmt,htons(ip->x))21 #define DISPLAYIP(x,fmt) DISPLAY_EXP(x,fmt,inet_ntoa(*(struct in_addr*)&ip->x))22 23 12 DLLEXPORT void decode(int link_type UNUSED,const char *packet,unsigned len) 24 13 { … … 29 18 } 30 19 //DISPLAY(ip_tos," TOS %02x") 31 DISPLAY_EXP(ip _tos," DSCP %02x",ip->ip_tos >> 2)32 DISPLAY_EXP(ip _tos," ECN %x",ip->ip_tos & 0x2)33 DISPLAYS(ip _len," Total Length %i")20 DISPLAY_EXP(ip, ip_tos," DSCP %02x",ip->ip_tos >> 2); 21 DISPLAY_EXP(ip, ip_tos," ECN %x",ip->ip_tos & 0x2); 22 DISPLAYS(ip, ip_len," Total Length %i"); 34 23 printf("\n IP:"); 35 DISPLAYS(ip _id," Id %u");24 DISPLAYS(ip, ip_id," Id %u"); 36 25 37 26 if ((unsigned int)len >= ((char *)&ip->ip_ttl - (char *)ip - 2)) { … … 42 31 } 43 32 //printf("\n IP:"); 44 DISPLAY(ip _ttl,"\n IP: TTL %i");33 DISPLAY(ip, ip_ttl,"\n IP: TTL %i"); 45 34 if ((unsigned int)len>=((char*)&ip->ip_p-(char*)ip+sizeof(ip->ip_p))) { 46 35 struct protoent *ent=getprotobynumber(ip->ip_p); … … 55 44 return; 56 45 } 57 DISPLAYS(ip _sum," Checksum %i\n");58 DISPLAYIP(ip _src," IP: Source %s ");59 DISPLAYIP(ip _dst,"Destination %s\n");46 DISPLAYS(ip, ip_sum," Checksum %i\n"); 47 DISPLAYIP(ip, ip_src," IP: Source %s "); 48 DISPLAYIP(ip, ip_dst,"Destination %s\n"); 60 49 decode_next(packet+ip->ip_hl*4,len-ip->ip_hl*4,"ip",ip->ip_p); 61 50 return; -
libpacketdump/ip_1.c
rec0b927 r387d299 3 3 #include <dlfcn.h> 4 4 #include "libpacketdump.h" 5 6 #define STRUCT icmp7 8 #define SAFE(x) \9 ((unsigned int)len>=((char*)&STRUCT->x-(char*)STRUCT+sizeof(STRUCT->x)))10 #define DISPLAY_EXP(x,fmt,exp) \11 if (SAFE(x)) \12 printf(fmt,exp); \13 else \14 return;15 16 #define DISPLAY(x,fmt) DISPLAY_EXP(x,fmt,STRUCT->x)17 18 #define DISPLAYS(x,fmt) DISPLAY_EXP(x,fmt,htons(STRUCT->x))19 #define DISPLAYL(x,fmt) DISPLAY_EXP(x,fmt,htonl(STRUCT->x))20 #define DISPLAYIP(x,fmt) DISPLAY_EXP(x,fmt,inet_ntoa(*(struct in_addr*)&STRUCT->x))21 5 22 6 static char *unreach_types[]={ -
libpacketdump/ip_17.c
rc7062df r387d299 8 8 #include <netdb.h> 9 9 10 #define STRUCT udp11 12 #define SAFE(x) \13 ((unsigned int)len>=((char*)&STRUCT->x-(char*)STRUCT+sizeof(STRUCT->x)))14 #define DISPLAY_EXP(x,fmt,exp) \15 if (SAFE(x)) \16 printf(fmt,exp); \17 else \18 return;19 20 #define DISPLAY(x,fmt) DISPLAY_EXP(x,fmt,STRUCT->x)21 22 #define DISPLAYS(x,fmt) DISPLAY_EXP(x,fmt,htons(STRUCT->x))23 #define DISPLAYL(x,fmt) DISPLAY_EXP(x,fmt,htonl(STRUCT->x))24 #define DISPLAYIP(x,fmt) DISPLAY_EXP(x,fmt,inet_ntoa(*(struct in_addr*)&STRUCT->x))25 26 10 27 11 DLLEXPORT void decode(int link_type UNUSED,const char *packet,unsigned len) … … 29 13 struct libtrace_udp *udp = (struct libtrace_udp*)packet; 30 14 printf(" UDP:"); 31 if (SAFE( source)) {15 if (SAFE(udp, source)) { 32 16 struct servent *ent=getservbyport(udp->source,"udp"); 33 17 if(ent) { … … 41 25 return; 42 26 } 43 if (SAFE( dest)) {27 if (SAFE(udp, dest)) { 44 28 struct servent *ent=getservbyport(udp->dest,"udp"); 45 29 if(ent) { … … 54 38 } 55 39 printf("\n UDP:"); 56 DISPLAYS( len," Len %u");57 DISPLAYS( check," Checksum %u");40 DISPLAYS(udp, len," Len %u"); 41 DISPLAYS(udp, check," Checksum %u"); 58 42 printf("\n"); 59 43 if (htons(udp->source) < htons(udp->dest)) -
libpacketdump/ip_33.c
rc7062df r387d299 6 6 #include <netinet/tcp.h> 7 7 #include <netinet/in.h> 8 9 #define STRUCT dccp10 11 #define SAFE(x) \12 ((unsigned int)len>=((char*)&STRUCT->x-(char*)STRUCT+sizeof(STRUCT->x)))13 #define DISPLAY_EXP(x,fmt,exp) \14 if (SAFE(x)) \15 printf(fmt,exp); \16 else \17 return;18 19 #define DISPLAY(x,fmt) DISPLAY_EXP(x,fmt,STRUCT->x)20 21 #define DISPLAYS(x,fmt) DISPLAY_EXP(x,fmt,htons(STRUCT->x))22 #define DISPLAYL(x,fmt) DISPLAY_EXP(x,fmt,htonl(STRUCT->x))23 #define DISPLAYIP(x,fmt) DISPLAY_EXP(x,fmt,inet_ntoa(*(struct in_addr*)&STRUCT->x))24 8 25 9 struct dccphdr { … … 50 34 { 51 35 struct dccphdr *dccp = (struct dccphdr*)packet; 52 DISPLAYS( source," DCCP: Source %i");53 DISPLAYS(d est," Dest %i");36 DISPLAYS(dccp, source," DCCP: Source %i"); 37 DISPLAYS(dccp, dest," Dest %i"); 54 38 if (len>4) { 55 39 printf("\n DCCP: Type %i",dccp->type); … … 69 53 else 70 54 return; 71 DISPLAY(d off," DCCP: Dataoff: %i\n");55 DISPLAY(dccp, doff," DCCP: Dataoff: %i\n"); 72 56 if (len>9) 73 57 printf(" DCCP: NDP %i CsLen: %i\n",dccp->ndp,dccp->cslen); … … 75 59 return; 76 60 } 77 DISPLAY(check," DCCP: Checksum: %i\n"); 61 /* Should this be byteswapped??? */ 62 DISPLAY(dccp, check," DCCP: Checksum: %i\n"); 78 63 if (htons(dccp->source) < htons(dccp->dest)) 79 64 decode_next(packet+dccp->doff*4,len-dccp->doff*4,"dccp",htons(dccp->source)); -
libpacketdump/ip_6.c
r9ca0b29 r387d299 5 5 #include <assert.h> 6 6 #include <netdb.h> 7 8 #define SAFE(x) \9 ((unsigned int)len>=((char*)&tcp->x-(char*)tcp+sizeof(tcp->x)))10 #define DISPLAY_EXP(x,fmt,exp) \11 if (SAFE(x)) \12 printf(fmt,exp); \13 else \14 return;15 16 #define DISPLAY(x,fmt) DISPLAY_EXP(x,fmt,tcp->x)17 18 #define DISPLAYS(x,fmt) DISPLAY_EXP(x,fmt,htons(tcp->x))19 #define DISPLAYL(x,fmt) DISPLAY_EXP(x,fmt,htonl(tcp->x))20 #define DISPLAYIP(x,fmt) DISPLAY_EXP(x,fmt,inet_ntoa(*(struct in_addr*)&tcp->x))21 7 22 8 DLLEXPORT void decode(int link_type UNUSED,const char *packet,unsigned len) … … 27 13 libtrace_tcp_t *tcp = (libtrace_tcp_t *)packet; 28 14 printf(" TCP:"); 29 if (SAFE( source)) {15 if (SAFE(tcp, source)) { 30 16 struct servent *ent=getservbyport(tcp->source,"tcp"); 31 17 if(ent) { … … 39 25 return; 40 26 } 41 if (SAFE( dest)) {27 if (SAFE(tcp, dest)) { 42 28 struct servent *ent=getservbyport(tcp->dest,"tcp"); 43 29 if(ent) { … … 52 38 } 53 39 printf("\n TCP:"); 54 DISPLAYL( seq," Seq %u");40 DISPLAYL(tcp, seq," Seq %u"); 55 41 printf("\n TCP:"); 56 DISPLAYL( ack_seq," Ack %u");42 DISPLAYL(tcp, ack_seq," Ack %u"); 57 43 if ((char*)&tcp->window-(char *)tcp>len) { 58 44 printf("\n"); … … 71 57 if (tcp->ack) printf(" ACK"); 72 58 if (tcp->urg) printf(" URG"); 73 DISPLAYS( window," Window %i");59 DISPLAYS(tcp, window," Window %i"); 74 60 printf("\n TCP:"); 75 DISPLAYS( check," Checksum %i");76 DISPLAYS( urg_ptr," Urgent %i");61 DISPLAYS(tcp, check," Checksum %i"); 62 DISPLAYS(tcp, urg_ptr," Urgent %i"); 77 63 pkt = (unsigned char*)packet+sizeof(*tcp); 78 64 plen = (len-sizeof *tcp) < (tcp->doff*4-sizeof(*tcp))?(len-sizeof(*tcp)):(tcp->doff*4-sizeof *tcp); -
libpacketdump/ip_89.c
re224862 r387d299 10 10 static void dump_ospf_v2_header(libtrace_ospf_v2_t *hdr, unsigned len) { 11 11 12 printf(" OSPF Header: Version %u Type %u ",13 hdr->ospf_v, hdr->type);12 DISPLAY(hdr, ospf_v, " OSPF Header: Version %u"); 13 DISPLAY(hdr, type, " Type %u "); 14 14 switch(hdr->type) { 15 15 case TRACE_OSPF_HELLO: … … 29 29 break; 30 30 } 31 printf("\n"); 31 32 32 printf("\n OSPF Header: Length %u \n", ntohs(hdr->len)); 33 printf(" OSPF Header: Router Id %s ", inet_ntoa(hdr->router)); 34 printf("Area Id %s\n", inet_ntoa(hdr->area)); 35 printf(" OSPF Header: Checksum %u Auth Type %u\n", ntohs(hdr->sum), 36 ntohs(hdr->au_type)); 37 38 printf(" OSPF Header: Auth Key ID %u Auth Data Len %u\n", 39 hdr->au_key_id, hdr->au_data_len); 40 printf(" OSPF Header: Auth Crypto Seq %u\n", ntohl(hdr->au_seq_num)); 41 33 DISPLAYS(hdr, ospf_len, "OSPF Header: Length %u \n"); 34 DISPLAYIP(hdr, router, " OSPF Header: Router Id %s "); 35 DISPLAYIP(hdr, area, "Area Id %s\n"); 36 DISPLAYS(hdr, sum, " OSPF Header: Checksum %u "); 37 DISPLAYS(hdr, au_type, "Auth Type %u\n"); 38 DISPLAY(hdr, au_key_id, " OSPF Header: Auth Key ID %u "); 39 DISPLAY(hdr, au_data_len, "Auth Data Len %u\n"); 40 DISPLAYL(hdr, au_seq_num, " OSPF Header: Auth Crypto Seq %u\n"); 42 41 43 42 } -
libpacketdump/libpacketdump.h
r66ad025 r387d299 6 6 extern "C" { 7 7 #endif 8 9 #define SAFE(hdr,x) \ 10 ((unsigned int)len>=((char*)&hdr->x-(char*)hdr+sizeof(hdr->x))) 11 12 #define DISPLAY_EXP(hdr,x,fmt,exp) \ 13 if (SAFE(hdr, x)) \ 14 printf(fmt,exp); \ 15 else {\ 16 printf("(Truncated)\n"); \ 17 return; \ 18 } 19 20 #define DISPLAY(hdr,x,fmt) DISPLAY_EXP(hdr,x,fmt,hdr->x) 21 22 #define DISPLAYS(hdr,x,fmt) DISPLAY_EXP(hdr,x,fmt,htons(hdr->x)) 23 #define DISPLAYL(hdr,x,fmt) DISPLAY_EXP(hdr,x,fmt,htonl(hdr->x)) 24 #define DISPLAYIP(hdr,x,fmt) DISPLAY_EXP(hdr,x,fmt,inet_ntoa(*(struct in_addr*)&hdr->x)) 25 8 26 9 27 void trace_hexdump_packet(libtrace_packet_t *packet); -
libwandio/Makefile.am
rbd119b3 r3b6e0cf 24 24 endif 25 25 26 if HAVE_LZMA 27 LIBTRACEIO_LZMA=ior-lzma.c iow-lzma.c 28 else 29 LIBTRACEIO_LZMA= 30 endif 31 26 32 libwandio_la_SOURCES=wandio.c ior-peek.c ior-stdio.c ior-thread.c \ 27 33 iow-stdio.c iow-thread.c wandio.h wandio_internal.h \ 28 $(LIBTRACEIO_ZLIB) $(LIBTRACEIO_BZLIB) $(LIBTRACEIO_LZO) 34 $(LIBTRACEIO_ZLIB) $(LIBTRACEIO_BZLIB) $(LIBTRACEIO_LZO) \ 35 $(LIBTRACEIO_LZMA) 29 36 30 37 AM_CPPFLAGS = @ADD_INCLS@ 31 38 libwandio_la_LIBADD = @LIBWANDIO_LIBS@ 32 libwandio_la_LDFLAGS=-version-info 1: 0:0 @ADD_LDFLAGS@39 libwandio_la_LDFLAGS=-version-info 1:1:0 @ADD_LDFLAGS@ 33 40 41 bin_PROGRAMS = wandiocat 42 wandiocat_SOURCES = wcat.c 43 wandiocat_CFLAGS = -I"$(top_srcdir)/libwandio" 44 wandiocat_CXXFLAGS = -I"$(top_srcdir)/libwandio" 45 wandiocat_LDFLAGS = -L"$(top_srcdir)/libwandio" -lwandio -
libwandio/iow-lzo.c
r2a7047c rfa7faf3 274 274 } 275 275 276 iow_t *lzo_wopen(iow_t *child, int compress_level UNUSED)276 iow_t *lzo_wopen(iow_t *child, int compress_level) 277 277 { 278 278 const int opt_filter = 0; … … 290 290 return NULL; 291 291 } 292 293 /* Compress level is useless for LZO, but getting UNUSED into here 294 * is more trouble than it is worth so this check will at least 295 * stop us from getting warnings about it. 296 */ 297 if (compress_level < 0) 298 return NULL; 292 299 293 300 iow = malloc(sizeof(iow_t)); -
libwandio/wandio.c
r10f924c r4b0cd2f 46 46 */ 47 47 48 struct compression_type compression_type[] = { 49 { "GZ", "gz", WANDIO_COMPRESS_ZLIB }, 50 { "BZ2", "bz2", WANDIO_COMPRESS_BZ2 }, 51 { "LZO", "lzo", WANDIO_COMPRESS_LZO }, 48 struct wandio_compression_type compression_type[] = { 49 { "gzip", "gz", WANDIO_COMPRESS_ZLIB }, 50 { "bzip2", "bz2", WANDIO_COMPRESS_BZ2 }, 51 { "lzo", "lzo", WANDIO_COMPRESS_LZO }, 52 { "lzma", "xz", WANDIO_COMPRESS_LZMA }, 52 53 { "NONE", "", WANDIO_COMPRESS_NONE } 53 54 }; … … 141 142 DEBUG_PIPELINE("peek"); 142 143 io_t *io = peek_open(stdio_open(filename)); 143 char buffer[1024];144 unsigned char buffer[1024]; 144 145 int len; 145 146 if (!io) … … 151 152 152 153 if (autodetect) { 153 if (len>=3 && buffer[0] == '\037' && buffer[1] == '\213'&&154 if (len>=3 && buffer[0] == 0x1f && buffer[1] == 0x8b && 154 155 buffer[2] == 0x08) { 155 156 #if HAVE_LIBZ … … 162 163 } 163 164 /* Auto detect compress(1) compressed data (gzip can read this) */ 164 if (len>=2 && buffer[0] == '\037' && buffer[1] == '\235') {165 if (len>=2 && buffer[0] == 0x1f && buffer[1] == 0x9d) { 165 166 #if HAVE_LIBZ 166 167 DEBUG_PIPELINE("zlib"); … … 182 183 #endif 183 184 } 185 186 if (len >=5 && buffer[0] == 0xfd && buffer[1] == '7' && 187 buffer[2] == 'z' && buffer[3] == 'X' && 188 buffer[4] == 'Z') { 189 #if HAVE_LIBLZMA 190 DEBUG_PIPELINE("lzma"); 191 io = lzma_open(io); 192 #else 193 fprintf(stderr, "File %s is lzma compressed but libtrace has not been built with lzma support!\n", filename); 194 return NULL; 195 #endif 196 } 184 197 } 185 198 /* Now open a threaded, peekable reader using the appropriate module … … 193 206 DEBUG_PIPELINE("peek"); 194 207 return peek_open(io); 208 } 209 210 DLLEXPORT struct wandio_compression_type *wandio_lookup_compression_type( 211 const char *name) { 212 213 struct wandio_compression_type *wct = compression_type; 214 215 while (strcmp(wct->name, "NONE") != 0) { 216 if (strcmp(wct->name, name) == 0) 217 return wct; 218 wct++; 219 } 220 221 return NULL; 195 222 } 196 223 … … 291 318 } 292 319 #endif 320 #if HAVE_LIBLZMA 321 else if (compression_level != 0 && 322 compress_type == WANDIO_COMPRESS_LZMA) { 323 iow = lzma_wopen(iow,compression_level); 324 } 325 #endif 293 326 /* Open a threaded writer */ 294 327 if (use_threads) -
libwandio/wandio.h
rc7021d9 r4b0cd2f 66 66 67 67 /** Structure defining a supported compression method */ 68 struct compression_type {68 struct wandio_compression_type { 69 69 /** Name of the compression method */ 70 70 const char *name; … … 77 77 78 78 /** The list of supported compression methods */ 79 extern struct compression_type compression_type[];79 extern struct wandio_compression_type compression_type[]; 80 80 81 81 /** Structure defining a libtrace IO reader module */ … … 178 178 /** LZO compression */ 179 179 WANDIO_COMPRESS_LZO = 3, 180 /** LZMA compression */ 181 WANDIO_COMPRESS_LZMA = 4, 180 182 /** All supported methods - used as a bitmask */ 181 183 WANDIO_COMPRESS_MASK = 7 … … 193 195 io_t *zlib_open(io_t *parent); 194 196 io_t *thread_open(io_t *parent); 197 io_t *lzma_open(io_t *parent); 195 198 io_t *peek_open(io_t *parent); 196 199 io_t *stdio_open(const char *filename); … … 199 202 iow_t *bz_wopen(iow_t *child, int compress_level); 200 203 iow_t *lzo_wopen(iow_t *child, int compress_level); 204 iow_t *lzma_wopen(iow_t *child, int compress_level); 201 205 iow_t *thread_wopen(iow_t *child); 202 206 iow_t *stdio_wopen(const char *filename, int fileflags); … … 211 215 * 212 216 * @{ */ 217 218 /** Given a string describing the compression method, finds the internal 219 * data structure representing that method. This is mostly useful for 220 * nicely mapping a method name to the internal libwandio compression 221 * method enum when configuring an output file. 222 * 223 * @param name The compression method name as a string, e.g. "gzip", 224 * "bzip2", "lzo" or "lzma". 225 * @return A pointer to the compression_type structure representing the 226 * compression method or NULL if no match can be found. 227 * 228 */ 229 struct wandio_compression_type *wandio_lookup_compression_type(const char *name); 213 230 214 231 /** Creates a new libtrace IO reader and opens the provided file for reading. -
test/Makefile
r59ef093 r17c5749 18 18 19 19 BINS = test-pcap-bpf test-event test-time test-dir test-wireless test-errors \ 20 test-plen test-autodetect $(BINS_DATASTRUCT) $(BINS_PARALLEL) 20 test-plen test-autodetect test-ports test-fragment test-live test-live-snaplen \ 21 $(BINS_DATASTRUCT) $(BINS_PARALLEL) 21 22 22 23 .PHONY: all clean distclean install depend test -
test/do-tests.sh
r5692bc4 r95b6218 72 72 echo \* Testing payload length 73 73 do_test ./test-plen 74 75 echo \* Testing port numbers 76 do_test ./test-ports 77 78 echo \* Testing fragment parsing 79 do_test ./test-fragment 74 80 75 81 echo \* Testing event framework … … 221 227 echo " * format autodetection - bzip2" 222 228 do_test ./test-autodetect traces/5_packets.erf.bz2 229 echo " * format autodetection - lzma" 230 do_test ./test-autodetect traces/5_packets.erf.xz 223 231 224 232 echo -
tools/traceanon/traceanon.1
rd6dc0f6 r17f954f 86 86 .BI \-\^\-compress-type=method 87 87 compress the output trace using the compression algorithm "method". Possible 88 algorithms are "gzip", "bzip2", "lzo" and "none". Default is "none".88 algorithms are "gzip", "bzip2", "lzo", "xz" and "none". Default is "none". 89 89 90 90 .SH EXAMPLES -
tools/traceanon/traceanon.c
rf5b5cca r17f954f 219 219 } else if (strncmp(compress_type_str, "lzo", 3) == 0) { 220 220 compress_type = TRACE_OPTION_COMPRESSTYPE_LZO; 221 } else if (strncmp(compress_type_str, "xz", 2) == 0) { 222 compress_type = TRACE_OPTION_COMPRESSTYPE_LZMA; 221 223 } else if (strncmp(compress_type_str, "no", 2) == 0) { 222 224 compress_type = TRACE_OPTION_COMPRESSTYPE_NONE; -
tools/tracemerge/tracemerge.1
rd6dc0f6 r17f954f 53 53 .BI \-\^\-compress-type method 54 54 Describes the compression algorithm to be used when writing the output trace. 55 Possible methods are "gzip", "bzip2", "lzo" and "none". Defaults to "none". 55 Possible methods are "gzip", "bzip2", "lzo", "xz" and "none". Defaults to 56 "none". 56 57 57 58 -
tools/tracemerge/tracemerge.c
rc0ccccd r17f954f 120 120 } else if (strncmp(compress_type_str, "lzo", 3) == 0) { 121 121 compress_type = TRACE_OPTION_COMPRESSTYPE_LZO; 122 } else if (strncmp(compress_type_str, "xz", 2) == 0) { 123 compress_type = TRACE_OPTION_COMPRESSTYPE_LZMA; 122 124 } else if (strncmp(compress_type_str, "no", 2) == 0) { 123 125 compress_type = TRACE_OPTION_COMPRESSTYPE_NONE; -
tools/tracesplit/tracesplit.1
rd6dc0f6 r17f954f 61 61 \fB-Z\fR compression-method 62 62 Compress the data using the specified compression algorithm. Accepted methods 63 are "gzip", "bzip2", "lzo" or "none". Default value is none unless a63 are "gzip", "bzip2", "lzo", "xz" or "none". Default value is none unless a 64 64 compression level is specified, in which case gzip will be used. 65 65 -
tools/tracesplit/tracesplit.c
r755855a r17f954f 316 316 } else if (strncmp(compress_type_str, "lzo", 3) == 0) { 317 317 compress_type = TRACE_OPTION_COMPRESSTYPE_LZO; 318 } else if (strncmp(compress_type_str, "xz", 2) == 0) { 319 compress_type = TRACE_OPTION_COMPRESSTYPE_LZMA; 318 320 } else if (strncmp(compress_type_str, "no", 2) == 0) { 319 321 compress_type = TRACE_OPTION_COMPRESSTYPE_NONE;
Note: See TracChangeset
for help on using the changeset viewer.