Changeset faf16af
- Timestamp:
- 07/07/14 14:25:36 (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:
- 262a093, ce7153d, ea602cd
- Parents:
- 1ca603b (diff), 17f954f (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:
-
- 10 added
- 35 edited
Legend:
- Unmodified
- Added
- Removed
-
README
rfbd4ba6 r9ad7a35 1 libtrace 3.0. 191 libtrace 3.0.20 2 2 3 3 --------------------------------------------------------------------------- -
configure.in
rfbd4ba6 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 … … 19 19 AC_CONFIG_MACRO_DIR([m4]) 20 20 AC_CONFIG_SRCDIR(lib/trace.c) 21 AM_INIT_AUTOMAKE 21 AM_INIT_AUTOMAKE([subdir-objects]) 22 22 23 23 # Make sure we use the relatively silent automake output … … 105 105 LIBWANDIO_LIBS="" 106 106 107 # Set our C compiler flags based on the gcc version 108 if test "$GCC" = "yes"; then 107 CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -Wextra -DLT_BUILDING_DLL=1" 108 CXXFLAGS="$CXXFLAGS -Wall -DLT_BUILDING_DLL=1" 109 110 # Check for -fvisibility 111 gl_VISIBILITY 112 113 gcc_PACKED 114 gcc_DEPRECATED 115 gcc_UNUSED 116 gcc_PURE 117 gcc_FORMAT 109 118 110 gcc_version=`gcc -dumpversion`111 112 # This is probably not the most reliable way to test whether our113 # compiler supports visibility, but it's better than nothing114 #115 # According to the gcc wiki - http://gcc.gnu.org/wiki/Visibility -116 # visibility is supported in gcc 4.0 or later, so we just need to117 # check the major version number118 119 major=$(echo $gcc_version | cut -d'.' -f1)120 121 #major=${gcc_version%\.*\.*}122 123 if test "$major" -lt 4; then124 vis=no125 else126 vis=yes127 fi128 129 CFLAGS="$CFLAGS -Wall -Wmissing-prototypes"130 CXXFLAGS="$CXXFLAGS -Wall"131 LIBCFLAGS="$CFLAGS"132 LIBCFLAGS="$LIBCFLAGS -DLT_BUILDING_DLL=1"133 LIBCXXFLAGS="$CXXFLAGS"134 LIBCXXFLAGS="$CXXFLAGS -DLT_BUILDING_DLL=1"135 136 if test "$vis" = "yes"; then137 LIBCFLAGS="$LIBCFLAGS -Wextra -fvisibility=hidden"138 LIBCXXFLAGS="$CXXFLAGS -Wextra -fvisibility=hidden"139 fi140 fi141 142 119 # Check for libtool 143 120 AC_PROG_LIBTOOL … … 603 580 ) 604 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 ) 605 603 606 604 # Define automake conditionals for use in our Makefile.am files … … 617 615 AM_CONDITIONAL([HAVE_ZLIB], [test "x$with_zlib" != "xno"]) 618 616 AM_CONDITIONAL([HAVE_LZO], [ test "x$with_lzo" != "xno"]) 617 AM_CONDITIONAL([HAVE_LZMA], [ test "x$with_lzma" != "xno"]) 619 618 620 619 # Check for miscellaneous programs … … 671 670 reportopt "Compiled with compressed trace (bz2) support" $with_bzip2 672 671 reportopt "Compiled with compressed trace (lzo write only) support" $with_lzo 672 reportopt "Compiled with compressed trace (lzma) support" $with_lzma 673 673 if test x"$libtrace_dag" = xtrue; then 674 674 if test "$libtrace_dag_version" = 24; then -
lib/Makefile.am
r2138553 rbd119b3 2 2 include_HEADERS = libtrace.h dagformat.h lt_inttypes.h daglegacy.h rt_protocol.h erftypes.h 3 3 4 AM_CFLAGS=@LIBCFLAGS@ 5 AM_CXXFLAGS=@LIBCXXFLAGS@ 4 AM_CFLAGS=@LIBCFLAGS@ @CFLAG_VISIBILITY@ 5 AM_CXXFLAGS=@LIBCXXFLAGS@ @CFLAG_VISIBILITY@ 6 6 7 7 extra_DIST = format_template.c … … 58 58 endif 59 59 60 INCLUDES= @ADD_INCLS@ -I../libwandio60 AM_CPPFLAGS= @ADD_INCLS@ -I../libwandio 61 61 libtrace_la_LIBADD = @LIBTRACE_LIBS@ @LTLIBOBJS@ $(DPDKLIBS) 62 62 libtrace_la_LDFLAGS=-version-info @LIBTRACE_MAJOR@:@LIBTRACE_MINOR@:@LIBTRACE_MID@ @ADD_LDFLAGS@ -
lib/format_helper.c
r8b49230 r74ecbc7 263 263 { 264 264 iow_t *io = NULL; 265 assert(level<10); 266 assert(level>=0); 265 266 if (level < 0 || level > 9) { 267 trace_set_err_out(trace, TRACE_ERR_UNSUPPORTED_COMPRESS, 268 "Compression level %d is invalid, must be between 0 and 9 inclusive", 269 level); 270 return NULL; 271 } 272 273 if (compress_type < 0 || 274 compress_type >= TRACE_OPTION_COMPRESSTYPE_LAST) { 275 trace_set_err_out(trace, TRACE_ERR_UNSUPPORTED_COMPRESS, 276 "Invalid compression type %d", compress_type); 277 return NULL; 278 } 267 279 268 280 io = wandio_wcreate(trace->uridata, compress_type, level, fileflag); -
lib/format_linux.c
r7a529a9 rd1af45d 1020 1020 struct pollfd pollset; 1021 1021 int ret; 1022 unsigned int snaplen; 1022 1023 1023 1024 ring_release_frame(libtrace, packet); … … 1048 1049 1049 1050 packet->buffer = header; 1051 1052 /* If a snaplen was configured, automatically truncate the packet to 1053 * the desired length. 1054 */ 1055 snaplen=LIBTRACE_MIN( 1056 (int)LIBTRACE_PACKET_BUFSIZE-(int)sizeof(*header), 1057 (int)FORMAT(libtrace->format_data)->snaplen); 1058 1059 TO_TP_HDR(packet->buffer)->tp_snaplen = LIBTRACE_MIN((unsigned int)snaplen, TO_TP_HDR(packet->buffer)->tp_len); 1050 1060 1051 1061 /* Move to next buffer */ -
lib/libtrace.h.in
rf7bcbfb r17f954f 80 80 #if defined(LITTLE_ENDIAN) && !defined(__LITTLE_ENDIAN) 81 81 #define __LITTLE_ENDIAN LITTLE_ENDIAN 82 #endif83 84 #ifdef _MSC_VER85 /* define the following from MSVC's internal types */86 typedef __int8 int8_t;87 typedef __int16 int16_t;88 typedef __int32 int32_t;89 typedef __int64 int64_t;90 typedef unsigned __int8 uint8_t;91 typedef unsigned __int16 uint16_t;92 typedef unsigned __int32 uint32_t;93 typedef unsigned __int64 uint64_t;94 #ifdef LT_BUILDING_DLL95 #define DLLEXPORT __declspec(dllexport)96 #else97 #define DLLEXPORT __declspec(dllimport)98 #endif99 #define DLLLOCAL100 /* Windows pads bitfields out to to the size of their parent type101 * however gcc warns that this doesn't meet with the iso C specification102 * so produces warnings for this behaviour. sigh.103 */104 #define LT_BITFIELD8 uint8_t105 #define LT_BITFIELD16 uint16_t106 #define LT_BITFIELD32 uint32_t107 #define LT_BITFIELD64 uint64_t108 #else109 #ifdef HAVE_STDINT_H110 # include <stdint.h>111 #endif112 #if __GNUC__ >= 4113 #ifdef LT_BUILDING_DLL114 #define DLLEXPORT __attribute__ ((visibility("default")))115 #define DLLLOCAL __attribute__ ((visibility("hidden")))116 #else117 #define DLLEXPORT118 #define DLLLOCAL119 #endif120 #else121 #define DLLEXPORT122 #define DLLLOCAL123 #endif124 /* GCC warns if the bitfield type is not "unsigned int", however windows125 * generates incorrect code for this (see above), so we define these126 * macros. How Hideous. So much for C's portability.127 */128 #define LT_BITFIELD8 unsigned int129 #define LT_BITFIELD16 unsigned int130 #define LT_BITFIELD32 unsigned int131 #define LT_BITFIELD64 unsigned int132 82 #endif 133 83 … … 170 120 #endif 171 121 172 /* Function does not depend on anything but its 173 * parameters, used to hint gcc's optimisations 174 */ 175 #if __GNUC__ >= 3 122 #ifdef _MSC_VER 123 /* define the following from MSVC's internal types */ 124 typedef __int8 int8_t; 125 typedef __int16 int16_t; 126 typedef __int32 int32_t; 127 typedef __int64 int64_t; 128 typedef unsigned __int8 uint8_t; 129 typedef unsigned __int16 uint16_t; 130 typedef unsigned __int32 uint32_t; 131 typedef unsigned __int64 uint64_t; 132 133 /* Windows pads bitfields out to to the size of their parent type 134 * however gcc warns that this doesn't meet with the iso C specification 135 * so produces warnings for this behaviour. sigh. 136 */ 137 #define LT_BITFIELD8 uint8_t 138 #define LT_BITFIELD16 uint16_t 139 #define LT_BITFIELD32 uint32_t 140 #define LT_BITFIELD64 uint64_t 141 #else 142 #ifdef HAVE_STDINT_H 143 # include <stdint.h> 144 #endif 145 /* GCC warns if the bitfield type is not "unsigned int", however windows 146 * generates incorrect code for this (see above), so we define these 147 * macros. How Hideous. So much for C's portability. 148 */ 149 #define LT_BITFIELD8 unsigned int 150 #define LT_BITFIELD16 unsigned int 151 #define LT_BITFIELD32 unsigned int 152 #define LT_BITFIELD64 unsigned int 153 #endif 154 155 /* Ensure these gcc optimisation attributes are defined consistently, 156 * without requiring users to need to have access to the config.h 157 * generated by running configure. 158 */ 159 160 #define LT_USE_PACKED @HAVE_ATTRIBUTE_PACKED@ 161 #define LT_USE_UNUSED @HAVE_ATTRIBUTE_UNUSED@ 162 #define LT_USE_DEPRECATED @HAVE_ATTRIBUTE_DEPRECATED@ 163 #define LT_USE_PURE @HAVE_ATTRIBUTE_PURE@ 164 #define LT_USE_PRINTF @HAVE_ATTRIBUTE_FORMAT@ 165 #define LT_USE_VISIBILITY @HAVE_VISIBILITY@ 166 167 #if LT_USE_PACKED 168 # define PACKED __attribute__((packed)) 169 #else 170 # define PACKED 171 #endif 172 173 #if LT_USE_UNUSED 174 # define UNUSED __attribute__((unused)) 175 #else 176 # define UNUSED 177 #endif 178 179 #if LT_USE_DEPRECATED 176 180 # define DEPRECATED __attribute__((deprecated)) 177 # define SIMPLE_FUNCTION __attribute__((pure))178 # define UNUSED __attribute__((unused))179 # define PACKED __attribute__((packed))180 # define PRINTF(formatpos,argpos) __attribute__((format(printf,formatpos,argpos)))181 181 #else 182 182 # define DEPRECATED 183 #endif 184 185 #if LT_USE_PURE 186 # define SIMPLE_FUNCTION __attribute__((pure)) 187 #else 183 188 # define SIMPLE_FUNCTION 184 # define UNUSED185 # define PACKED186 # define PRINTF(formatpos,argpos)187 189 #endif 190 191 #if LT_USE_PRINTF 192 # define PRINTF(formatpos, argpos) __attribute__((format(printf,formatpos, argpos))) 193 #else 194 # define PRINTF(formatpos, argpos) 195 #endif 196 197 #ifdef _MSC_VER 198 #ifdef LT_BUILDING_DLL 199 #define DLLEXPORT __declspec(dllexport) 200 #else 201 #define DLLEXPORT __declspec(dllimport) 202 #endif 203 #define DLLLOCAL 204 #else 205 #ifndef DLLEXPORT 206 #if LT_USE_VISIBILITY && LT_BUILDING_DLL 207 #define DLLEXPORT __attribute__ ((visibility("default"))) 208 #define DLLLOCAL __attribute__ ((visibility("hidden"))) 209 #else 210 #define DLLEXPORT 211 #define DLLLOCAL 212 #endif 213 #endif 214 #endif 215 188 216 189 217 /** Opaque structure holding information about an output trace */ … … 839 867 uint8_t ospf_v; /**< OSPF Version, should be 2 */ 840 868 uint8_t type; /**< OSPF Packet Type */ 841 uint16_t len;/**< Packet length, including OSPF header */869 uint16_t ospf_len; /**< Packet length, including OSPF header */ 842 870 struct in_addr router; /**< Router ID of the packet source */ 843 871 struct in_addr area; /**< Area the packet belongs to */ … … 1210 1238 TRACE_OPTION_COMPRESSTYPE_ZLIB = 1, /**< GZip Compression */ 1211 1239 TRACE_OPTION_COMPRESSTYPE_BZ2 = 2, /**< BZip2 Compression */ 1212 TRACE_OPTION_COMPRESSTYPE_LZO = 3 /**< LZO Compression */ 1240 TRACE_OPTION_COMPRESSTYPE_LZO = 3, /**< LZO Compression */ 1241 TRACE_OPTION_COMPRESSTYPE_LZMA = 4, /**< LZO Compression */ 1242 TRACE_OPTION_COMPRESSTYPE_LAST 1213 1243 } trace_option_compresstype_t; 1214 1244 … … 1750 1780 DLLEXPORT uint16_t *trace_checksum_transport(libtrace_packet_t *packet, 1751 1781 uint16_t *csum); 1782 1783 /** Calculates the fragment offset in bytes for an IP packet 1784 * @param packet The libtrace packet to calculate the offset for 1785 * @param[out] more A boolean flag to indicate whether there are more 1786 * fragments after the current packet. 1787 * @return The fragment offset for the packet in bytes. If the packet is not 1788 * an IP packet or the fragment offset is not present in packet, the return 1789 * value will be 0. 1790 * 1791 * @note The value returned is in bytes, not 8-octet units as it is stored 1792 * in the fragment offset field in the headers. In other words, libtrace 1793 * automatically does the multiplication for you. 1794 * 1795 * The value passed in for 'more' does not matter; it will be overwritten 1796 * with the value of the More Fragments flag from the IP header. 1797 * 1798 * New in libtrace 3.0.20 1799 */ 1800 DLLEXPORT uint16_t trace_get_fragment_offset(const libtrace_packet_t *packet, 1801 uint8_t *more); 1752 1802 1753 1803 /** Gets a pointer to the transport layer header (if any) -
lib/libtrace_int.h
r8b49230 r10f924c 147 147 #include "bpf-jit/bpf-jit.h" 148 148 #endif 149 149 150 150 151 //#define RP_BUFSIZE 65536U -
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_ospf.c
r8753bb8 r10f924c 32 32 */ 33 33 34 #include "libtrace_int.h" 34 35 #include "libtrace.h" 35 36 #include "protocols.h" -
lib/protocols_transport.c
rc909fad re0bea4e5 33 33 34 34 35 #include "libtrace_int.h" 35 36 #include "libtrace.h" 36 37 #include "protocols.h" … … 381 382 uint32_t remaining; 382 383 uint8_t proto; 383 const struct ports_t *port = 384 (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, 385 399 &proto, &remaining); 386 400 … … 390 404 391 405 /* ICMP *technically* doesn't have ports */ 392 if (proto == TRACE_IPPROTO_ICMP )406 if (proto == TRACE_IPPROTO_ICMP || proto == TRACE_IPPROTO_ICMPV6) 393 407 return 0; 394 408 … … 404 418 uint32_t remaining; 405 419 uint8_t proto; 406 struct ports_t *port = 407 (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, 408 435 &proto, &remaining); 409 436 /* Snapped too early */ … … 412 439 413 440 /* ICMP *technically* doesn't have ports */ 414 if (proto == TRACE_IPPROTO_ICMP )441 if (proto == TRACE_IPPROTO_ICMP || proto == TRACE_IPPROTO_ICMPV6) 415 442 return 0; 416 443 -
libpacketdump/Makefile.am
r8b49230 rbd119b3 172 172 dist_plugin_DATA = $(TXT_PROTOCOLS) 173 173 174 INCLUDES= @ADD_INCLS@ -I../lib -I../libwandio174 AM_CPPFLAGS= @ADD_INCLS@ -I../lib -I../libwandio 175 175 176 176 # NOTE: You CANNOT add @LEXLIBS@ here, as they are statically compiled … … 182 182 @ADD_LDFLAGS@ 183 183 184 AM_CXXFLAGS=-g -Wall -DDIRNAME=\"$(plugindir)\" $( INCLUDES)184 AM_CXXFLAGS=-g -Wall -DDIRNAME=\"$(plugindir)\" $(AM_CPPFLAGS) 185 185 BUILT_SOURCES=parser.h 186 186 AM_YFLAGS=-d -
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
r60f3c4c r3b6e0cf 3 3 include_HEADERS=wandio.h 4 4 5 AM_CFLAGS=@LIBCFLAGS@ 6 AM_CXXFLAGS=@LIBCXXFLAGS@ 5 AM_CFLAGS=@LIBCFLAGS@ @CFLAG_VISIBILITY@ 6 AM_CXXFLAGS=@LIBCXXFLAGS@ @CFLAG_VISIBILITY@ 7 7 8 8 if HAVE_ZLIB … … 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 iow-stdio.c iow-thread.c wandio.h \ 28 $(LIBTRACEIO_ZLIB) $(LIBTRACEIO_BZLIB) $(LIBTRACEIO_LZO) 33 iow-stdio.c iow-thread.c wandio.h wandio_internal.h \ 34 $(LIBTRACEIO_ZLIB) $(LIBTRACEIO_BZLIB) $(LIBTRACEIO_LZO) \ 35 $(LIBTRACEIO_LZMA) 29 36 30 INCLUDES = @ADD_INCLS@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/ior-stdio.c
r60f3c4c r10f924c 34 34 35 35 #define _GNU_SOURCE 1 36 #include "wandio_internal.h" 36 37 #include "wandio.h" 37 38 #include <sys/types.h> -
libwandio/ior-thread.c
r954577b9 r10f924c 34 34 35 35 #include "config.h" 36 #include "wandio_internal.h" 36 37 #include "wandio.h" 37 38 #include <sys/types.h> -
libwandio/iow-lzo.c
r4a2529b rfa7faf3 41 41 42 42 #include <lzo/lzo1x.h> 43 #include "wandio_internal.h" 43 44 #include "wandio.h" 44 45 #include "config.h" … … 273 274 } 274 275 275 iow_t *lzo_wopen(iow_t *child, int compress_level UNUSED)276 iow_t *lzo_wopen(iow_t *child, int compress_level) 276 277 { 277 278 const int opt_filter = 0; … … 289 290 return NULL; 290 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; 291 299 292 300 iow = malloc(sizeof(iow_t)); -
libwandio/iow-stdio.c
r60f3c4c r10f924c 34 34 35 35 #define _GNU_SOURCE 1 36 #include "wandio_internal.h" 36 37 #include "wandio.h" 37 38 #include <sys/types.h> -
libwandio/iow-thread.c
r954577b9 r10f924c 34 34 #include "config.h" 35 35 #include "wandio.h" 36 #include "wandio_internal.h" 36 37 #include <sys/types.h> 37 38 #include <sys/stat.h> -
libwandio/wandio.c
r808eeef r4b0cd2f 34 34 35 35 #include "config.h" 36 #include "wandio_internal.h" 36 37 #include "wandio.h" 37 38 #include <stdlib.h> … … 45 46 */ 46 47 47 struct compression_type compression_type[] = { 48 { "GZ", "gz", WANDIO_COMPRESS_ZLIB }, 49 { "BZ2", "bz2", WANDIO_COMPRESS_BZ2 }, 50 { "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 }, 51 53 { "NONE", "", WANDIO_COMPRESS_NONE } 52 54 }; … … 140 142 DEBUG_PIPELINE("peek"); 141 143 io_t *io = peek_open(stdio_open(filename)); 142 char buffer[1024];144 unsigned char buffer[1024]; 143 145 int len; 144 146 if (!io) … … 150 152 151 153 if (autodetect) { 152 if (len>=3 && buffer[0] == '\037' && buffer[1] == '\213'&&154 if (len>=3 && buffer[0] == 0x1f && buffer[1] == 0x8b && 153 155 buffer[2] == 0x08) { 154 156 #if HAVE_LIBZ … … 161 163 } 162 164 /* Auto detect compress(1) compressed data (gzip can read this) */ 163 if (len>=2 && buffer[0] == '\037' && buffer[1] == '\235') {165 if (len>=2 && buffer[0] == 0x1f && buffer[1] == 0x9d) { 164 166 #if HAVE_LIBZ 165 167 DEBUG_PIPELINE("zlib"); … … 181 183 #endif 182 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 } 183 197 } 184 198 /* Now open a threaded, peekable reader using the appropriate module … … 192 206 DEBUG_PIPELINE("peek"); 193 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; 194 222 } 195 223 … … 290 318 } 291 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 292 326 /* Open a threaded writer */ 293 327 if (use_threads) -
libwandio/wandio.h
r0acfd1e r4b0cd2f 34 34 #ifndef IO_H 35 35 #define IO_H 1 /**< Guard Define */ 36 #include "config.h"37 36 #include <sys/types.h> 38 37 #include <stdio.h> … … 40 39 #include <stdbool.h> 41 40 42 #if __GNUC__ >= 4 43 #ifdef LT_BUILDING_DLL 44 #define DLLEXPORT __attribute__ ((visibility("default"))) 45 #define DLLLOCAL __attribute__ ((visibility("hidden"))) 46 #else 47 #define DLLEXPORT 48 #define DLLLOCAL 49 #endif 50 #else 51 #define DLLEXPORT 52 #define DLLLOCAL 41 42 #ifndef DLLEXPORT 43 #if HAVE_VISIBILITY && LT_BUILDING_DLL 44 #define DLLEXPORT __attribute__ ((visibility("default"))) 45 #define DLLLOCAL __attribute__ ((visibility("hidden"))) 46 #else 47 #define DLLEXPORT 48 #define DLLLOCAL 49 #endif 53 50 #endif 54 51 55 #if __GNUC__ >= 3 56 # define DEPRECATED __attribute__((deprecated)) 57 # define SIMPLE_FUNCTION __attribute__((pure)) 58 # define UNUSED __attribute__((unused)) 59 # define PACKED __attribute__((packed)) 60 # define PRINTF(formatpos,argpos) __attribute__((format(printf,formatpos,argpos))) 61 #else 62 # define DEPRECATED 63 # define SIMPLE_FUNCTION 64 # define UNUSED 65 # define PACKED 66 # define PRINTF(formatpos,argpos) 67 #endif 68 52 // TODO: Use a proper check for these attribute rather than gcc version check 69 53 70 54 /** @file … … 82 66 83 67 /** Structure defining a supported compression method */ 84 struct compression_type {68 struct wandio_compression_type { 85 69 /** Name of the compression method */ 86 70 const char *name; … … 93 77 94 78 /** The list of supported compression methods */ 95 extern struct compression_type compression_type[];79 extern struct wandio_compression_type compression_type[]; 96 80 97 81 /** Structure defining a libtrace IO reader module */ … … 194 178 /** LZO compression */ 195 179 WANDIO_COMPRESS_LZO = 3, 180 /** LZMA compression */ 181 WANDIO_COMPRESS_LZMA = 4, 196 182 /** All supported methods - used as a bitmask */ 197 183 WANDIO_COMPRESS_MASK = 7 … … 209 195 io_t *zlib_open(io_t *parent); 210 196 io_t *thread_open(io_t *parent); 197 io_t *lzma_open(io_t *parent); 211 198 io_t *peek_open(io_t *parent); 212 199 io_t *stdio_open(const char *filename); … … 215 202 iow_t *bz_wopen(iow_t *child, int compress_level); 216 203 iow_t *lzo_wopen(iow_t *child, int compress_level); 204 iow_t *lzma_wopen(iow_t *child, int compress_level); 217 205 iow_t *thread_wopen(iow_t *child); 218 206 iow_t *stdio_wopen(const char *filename, int fileflags); … … 227 215 * 228 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); 229 230 230 231 /** Creates a new libtrace IO reader and opens the provided file for reading. … … 330 331 /** @} */ 331 332 332 /** @name libtraceio options333 * @{ */334 extern int force_directio_read;335 extern int force_directio_write;336 extern uint64_t write_waits;337 extern uint64_t read_waits;338 extern unsigned int use_threads;339 extern unsigned int max_buffers;340 /* @} */341 342 333 #endif -
test/Makefile
r8782b67 rfb20640 12 12 13 13 BINS = test-pcap-bpf test-event test-time test-dir test-wireless test-errors \ 14 test-plen test-autodetect 14 test-plen test-autodetect test-ports test-fragment 15 15 16 16 .PHONY: all clean distclean install depend test -
test/do-tests.sh
r47e927a r95b6218 73 73 do_test ./test-plen 74 74 75 echo \* Testing port numbers 76 do_test ./test-ports 77 78 echo \* Testing fragment parsing 79 do_test ./test-fragment 80 75 81 echo \* Testing event framework 76 82 do_test ./test-event 77 83 78 84 echo \* Testing time conversions 79 do_test ./test-time 85 echo \* ERF 86 do_test ./test-time erf 87 echo \* pcapfile 88 do_test ./test-time pcapfile 89 echo \* pcapfilens 90 do_test ./test-time pcapfilens 91 echo \* legacyatm 92 do_test ./test-time legacyatm 93 echo \* legacypos 94 do_test ./test-time legacypos 95 echo \* legacyeth 96 do_test ./test-time legacyeth 97 echo \* pcap 98 do_test ./test-time pcap 99 echo \* rawerf 100 do_test ./test-time rawerf 101 echo \* tsh 102 do_test ./test-time tsh 80 103 81 104 echo \* Testing directions … … 204 227 echo " * format autodetection - bzip2" 205 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 206 231 207 232 echo -
test/test-time.c
rd5a27e8 r6a38a7e 51 51 struct libtrace_t *trace; 52 52 53 const char *lookup_uri(const char *type) { 54 if (strchr(type,':')) 55 return type; 56 if (!strcmp(type,"erf")) 57 return "erf:traces/100_packets.erf"; 58 if (!strcmp(type,"rawerf")) 59 return "rawerf:traces/100_packets.erf"; 60 if (!strcmp(type,"pcap")) 61 return "pcap:traces/100_packets.pcap"; 62 if (!strcmp(type,"wtf")) 63 return "wtf:traces/wed.wtf"; 64 if (!strcmp(type,"rtclient")) 65 return "rtclient:chasm"; 66 if (!strcmp(type,"pcapfile")) 67 return "pcapfile:traces/100_packets.pcap"; 68 if (!strcmp(type,"pcapfilens")) 69 return "pcapfile:traces/100_packetsns.pcap"; 70 if (!strcmp(type, "duck")) 71 return "duck:traces/100_packets.duck"; 72 if (!strcmp(type, "legacyatm")) 73 return "legacyatm:traces/legacyatm.gz"; 74 if (!strcmp(type, "legacypos")) 75 return "legacypos:traces/legacypos.gz"; 76 if (!strcmp(type, "legacyeth")) 77 return "legacyeth:traces/legacyeth.gz"; 78 if (!strcmp(type, "tsh")) 79 return "tsh:traces/10_packets.tsh.gz"; 80 return type; 81 } 82 53 83 void iferr(libtrace_t *trace) 54 84 { … … 61 91 62 92 int main(int argc, char *argv[]) { 63 char *uri = "erf:traces/100_packets.erf";93 char *uri = lookup_uri(argv[1]); 64 94 int psize = 0; 65 95 int error = 0; … … 76 106 for (;;) { 77 107 double ts; 108 double tsdiff; 78 109 struct timeval tv; 79 110 if ((psize = trace_read_packet(trace, packet)) <0) { … … 88 119 tv=trace_get_timeval(packet); 89 120 ts=trace_get_seconds(packet); 90 assert((tv.tv_sec+tv.tv_usec/1000000.0)-ts<.000001); 121 tsdiff = (tv.tv_sec+tv.tv_usec/1000000.0)-ts; 122 assert(tsdiff > -0.001 && tsdiff < 0.001); 123 91 124 } 92 125 trace_destroy_packet(packet); -
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.