Skip to content

Commit

Permalink
Merge pull request appneta#281 from appneta/Release_4.2
Browse files Browse the repository at this point in the history
Release 4.2
  • Loading branch information
fklassen authored Mar 21, 2017
2 parents 4eb7a09 + 01dfc15 commit f143cb0
Show file tree
Hide file tree
Showing 104 changed files with 1,501 additions and 427 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ docs/web/
*.7z
*.dmg
*.gz
*.xz
*.iso
*.jar
*.rar
Expand Down
25 changes: 15 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
sudo: required
dist: trusty

os: linux

language: c

compiler:
- gcc
- clang

addons:
apt:
packages:
- libpcap-dev

cache:
apt: true
matrix:
include:
- os: osx
osx_image: xcode8.2
compiler: clang
before_install:
- brew update
- brew install autogen
- os: linux
dist: trusty
compiler: gcc
- os: linux
dist: trusty
compiler: clang

script:
- autoreconf -iv > build.log 2>&1 || (cat build.log && exit 1)
- ./configure > build.log 2>&1 || (cat build.log && exit 1)
- ./configure --disable-local-libopts > build.log 2>&1 || (cat build.log && exit 1)
- make > build.log 2>&1 || (cat build.log && exit 1)
- make dist > build.log 2>&1 || (cat build.log && exit 1)
- sudo make test
2 changes: 0 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# $Id$
AUTOMAKE_OPTIONS = foreign

ACLOCAL_AMFLAGS = -I m4 -I libopts/m4

if NEED_LIBOPTS
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#Tcpreplay
Tcpreplay
=========
[![Build Status](https://travis-ci.org/appneta/tcpreplay.svg?branch=master)](https://travis-ci.org/appneta/tcpreplay)
[![Coverity Scan Build Status](https://scan.coverity.com/projects/12017/badge.svg)](https://scan.coverity.com/projects/12017)
[![Code Climate](https://codeclimate.com/github/appneta/tcpreplay.png)](https://codeclimate.com/github/appneta/tcpreplay)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/0e49d208c69e440182ba21109ecaf31d)](https://www.codacy.com/app/fklassen/tcpreplay?utm_source=github.com&utm_medium=referral&utm_content=appneta/tcpreplay&utm_campaign=badger)

Expand Down
2 changes: 1 addition & 1 deletion autogen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
rm -f config/config.guess config/config.sub config/ltmain.sh 2>/dev/null
rm -f aclocal.m4 2>/dev/null
aclocal -I libopts/m4/
if test -x "`which glibtoolize`" ; then
if test -x "$(which glibtoolize)" ; then
# Necessary under OS X
glibtoolize --copy --automake --force
else
Expand Down
62 changes: 30 additions & 32 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@
dnl $Id$

AC_PREREQ([2.69])
AC_INIT([tcpreplay],[4.1.2],[https://github.com/appneta/tcpreplay/issues],[tcpreplay],[http://tcpreplay.sourceforge.net/])

dnl Set version info here!
AC_INIT([tcpreplay],[4.2.0],
[https://github.com/appneta/tcpreplay/issues],
[tcpreplay],
[http://tcpreplay.sourceforge.net/])
AC_CONFIG_SRCDIR([src/tcpreplay.c])
AM_CONFIG_HEADER([src/config.h])
AC_CONFIG_HEADERS([src/config.h])
AC_CONFIG_AUX_DIR(config)
AM_MAINTAINER_MODE
AM_WITH_DMALLOC
Expand All @@ -15,23 +20,16 @@ MAINTAINER_AUTOGEN_VERSION=5.18.4

AC_CONFIG_MACRO_DIR([m4])

dnl Set version info here!
MAJOR_VERSION=4
MINOR_VERSION=1
MICRO_VERSION=2
TCPREPLAY_VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION
PACKAGE_URL=http://tcpreplay.appneta.com/
TCPREPLAY_VERSION=$PACKAGE_VERSION

dnl Release is only used for the RPM spec file
TCPREPLAY_RELEASE=1

AC_DEFINE(PACKAGE, [tcpreplay], [This is our package name])
AC_DEFINE_UNQUOTED(VERSION, "$TCPREPLAY_VERSION", [What is our version?])
AC_SUBST(TCPREPLAY_VERSION)
AC_SUBST(TCPREPLAY_RELEASE)

USER_CFLAGS=$CFLAGS
CFLAGS="-Wall -O3 -std=gnu99 ${CFLAGS}"
CFLAGS="-Wall -std=gnu99 ${CFLAGS}"

dnl Determine OS
AC_CANONICAL_BUILD
Expand Down Expand Up @@ -84,26 +82,26 @@ case "$host_os" in
AC_MSG_CHECKING([what macOS compiler to use])

for _macosx_sdk in $with_macosx_sdk 10.8 10.9 10.10 10.11 10.12 10.13 10.14 10.15 10.16.10.17 10.18 10.19 10.20 11.0 11.1 11.2 11.3 11.4 11.5; do
MACOSX_SDK_PATH=`xcrun --sdk macosx${_macosx_sdk} --show-sdk-path 2> /dev/null`
MACOSX_SDK_PATH=$(xcrun --sdk macosx${_macosx_sdk} --show-sdk-path 2> /dev/null)
if test -d "$MACOSX_SDK_PATH"; then
with_macosx_sdk="${_macosx_sdk}"
break
else
MACOSX_SDK_PATH="`xcode-select -print-path`/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${_macosx_sdk}.sdk"
MACOSX_SDK_PATH="$(xcode-select -print-path)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${_macosx_sdk}.sdk"
if test -d "$MACOSX_SDK_PATH"; then
with_macosx_sdk="${_macosx_sdk}"
break
fi
fi
done
if test -d "$MACOSX_SDK_PATH"; then
CC="`xcrun -find clang` -m64 -isysroot $MACOSX_SDK_PATH"
INSTALL_NAME_TOOL=`xcrun -find install_name_tool`
AR=`xcrun -find ar`
NM=`xcrun -find nm`
STRIP=`xcrun -find strip`
LIBTOOL=`xcrun -find libtool`
RANLIB=`xcrun -find ranlib`
CC="$(xcrun -find clang) -m64 -isysroot $MACOSX_SDK_PATH"
INSTALL_NAME_TOOL=$(xcrun -find install_name_tool)
AR=$(xcrun -find ar)
NM=$(xcrun -find nm)
STRIP=$(xcrun -find strip)
LIBTOOL=$(xcrun -find libtool)
RANLIB=$(xcrun -find ranlib)
AC_MSG_RESULT([$CC])
else
AC_MSG_RESULT([legacy])
Expand Down Expand Up @@ -132,7 +130,7 @@ AC_ARG_WITH(pfring-lib,

have_cygwin=no
AC_MSG_CHECKING([for cygwin development environment])
if test `echo $target | grep -c cygwin` -gt 0 ; then
if test $(echo $target | grep -c cygwin) -gt 0 ; then
AC_DEFINE([HAVE_WIN32], [1], [Windows/Cygwin])
AC_MSG_RESULT(yes)
have_cygwin=yes
Expand All @@ -141,7 +139,7 @@ else
fi


AM_INIT_AUTOMAKE(tcpreplay, $TCPREPLAY_VERSION, nodefine)
AM_INIT_AUTOMAKE([foreign])
AM_SILENT_RULES([yes])

dnl Checks for programs.
Expand Down Expand Up @@ -171,9 +169,9 @@ AUTOGEN_VERSION="unknown - man pages will not be built"
if test -n "${AUTOGEN}" ; then
AC_MSG_CHECKING(for autogen version >= 5.18.x)
${AUTOGEN} -v >autogen.version
AUTOGEN_VERSION=`cat autogen.version | ${SED} 's|.* \([[0-9\.]]\{5,\}\).*|\1|'`
AUTOGEN_MAJOR=`echo ${AUTOGEN_VERSION} | ${CUT} -d '.' -f 1`
AUTOGEN_MINOR=`echo ${AUTOGEN_VERSION} | ${CUT} -d '.' -f 2`
AUTOGEN_VERSION=$(cat autogen.version | ${SED} 's|.* \([[0-9\.]]\{5,\}\).*|\1|')
AUTOGEN_MAJOR=$(echo ${AUTOGEN_VERSION} | ${CUT} -d '.' -f 1)
AUTOGEN_MINOR=$(echo ${AUTOGEN_VERSION} | ${CUT} -d '.' -f 2)
if ( test ${AUTOGEN_MAJOR} -eq 5 && test ${AUTOGEN_MINOR} -lt 18 ) || test ${AUTOGEN_MAJOR} -lt 5 ; then
AC_MSG_RESULT(no)
AC_MSG_WARN([${AUTOGEN} is too old (${AUTOGEN_VERSION}) for building from source code. Please upgrade to 5.18.4)])
Expand Down Expand Up @@ -1420,7 +1418,7 @@ if test x${disable_quick_tx} != xyes; then
dnl * Set destination directory for kernel modules

if test x${kerneluname} = x ; then
kerneluname=`uname -r`
kerneluname=$(uname -r)
fi
default_moduledir=/lib/modules/${kerneluname}/misc
AC_ARG_WITH(moduledir,
Expand Down Expand Up @@ -1466,9 +1464,9 @@ if test $have_cygwin = no ; then

for testdir in $trydnetdir /usr/local /opt/local $MACOSX_SDK_PATH/usr /usr ; do
if test -x ${testdir}/bin/dnet-config -a $founddnet = no ; then
LDNETINC="`$testdir/bin/dnet-config --cflags`"
LDNETLIB="`$testdir/bin/dnet-config --libs`"
libdnet_version="`$testdir/bin/dnet-config --version`"
LDNETINC="$($testdir/bin/dnet-config --cflags)"
LDNETLIB="$($testdir/bin/dnet-config --libs)"
libdnet_version="$($testdir/bin/dnet-config --version)"
founddnet=$testdir
fi
done
Expand Down Expand Up @@ -1612,9 +1610,9 @@ AC_ARG_WITH(pcapnav-config,
)

if test $pcncfg != no ; then
LNAVLIB=`$pcncfg --libs`
LNAV_CFLAGS=`$pcncfg --cflags`
PCAPNAV_VERSION=`$pcncfg --version`
LNAVLIB=$($pcncfg --libs)
LNAV_CFLAGS=$($pcncfg --cflags)
PCAPNAV_VERSION=$($pcncfg --version)
AC_SUBST(LNAVLIB)
AC_SUBST(LNAV_CFLAGS)
AC_DEFINE_UNQUOTED(PCAPNAV_VERSION, "$PCAPNAV_VERSION",
Expand Down
19 changes: 18 additions & 1 deletion docs/CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
02/26/2017 Version 4.2.0
- MAC rewriting capabilities (#313)
- Fix several issues identified by Coverity (#305)
- Packet destortion --fuzz-seed option by Gabriel Ganne (#302)
- Add --unique-ip-loops option to modify IPs every few loops (#296)
- Netmap startup delay increase (#290)
- tcpcapinfo buffer overflow vulnerablily (#278)
- Update git-clone instructions by Kyle McDonald (#277)
- Allow fractions for --pps option (#270)
- Print per-loop stats with --stats=0 (#269)
- Add protection against packet drift by Guillaume Scott (#268)
- Print flow stats periodically with --stats output (#262)
- Include Travis-CI build support by Ilya Shipitsin (#264) (#285)
- tcpreplay won't replay all packets in a pcap file with --netmap (#255)
- First and last packet times in --stats output (#239)
- Switch to wire speed after 30 minutes at 6 Gbps (#210)
- tcprewrite fix checksum properly for fragmented packets (#190)

11/19/2016 Version 4.1.2
- Fix compilation with musl C library (#260)
- Support parallel builds (#259)
Expand All @@ -13,7 +31,6 @@
- Option --duration performance optimizations (#223)
- Correct company name in license (#217)
- Compile and mult-arch cross-compile on ARM (#211)
- Switch to wire speed after 30 minutes at 6 Gbps (#210)
- Tap device support for Linux and FreeBSD from Murat Demirten (#207)
- Handle loopback for linux cooked capture files from corentin-p1(Linux SLL) (#204)
- Master doesn't compile on OS X 10.11 (#203)
Expand Down
8 changes: 6 additions & 2 deletions docs/CREDIT
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Nick Mathewson <[email protected]>
- Kindly giving me his BSD licensed implimentation of poll()
using select() so I don't have to worry about cross platform
issues.

Denis McLaughlin <[email protected]>
- Patch to allow TCP/UDP port translation

Expand Down Expand Up @@ -73,4 +73,8 @@ Luigi Rizzo <[email protected]>
Alexey Indeev <[email protected]> - AppNeta
- Quick TX module for Linux


Pedro Arthur Duarte [aka JEdi] <GitHub @pedroarthur>
- MAC rewrite feature

Gabriel Ganne <GitHub @GabrielGanne>
- Data fuzz rewrite feature
1 change: 1 addition & 0 deletions kernel/linux/example/pcapsend.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ bool read_pcap_file(char* filename, void** buffer, long *length) {
/* memory error */
if(*buffer == NULL) {
printf("Could not allocate %ld bytes of memory!\n", *length);
fclose(infile);
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions libopts/parse-duration.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ scale_n_add (time_t base, time_t val, int scale)
return BAD_TIME;
}

if (val > MAX_DURATION / scale)
if (val >= MAX_DURATION / scale)
{
errno = ERANGE;
return BAD_TIME;
}

val *= scale;
if (base > MAX_DURATION - val)
if ((base + val) >= MAX_DURATION)
{
errno = ERANGE;
return BAD_TIME;
Expand Down
2 changes: 1 addition & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ tcpreplay_LDADD = ./common/libcommon.a $(LIBSTRL) @LPCAPLIB@ @LDNETLIB@ $(LIBOPT
tcpreplay_OBJECTS: tcpreplay_opts.h
tcpreplay_opts.h: tcpreplay_opts.c

BUILT_SOURCES += tcpreplay_opts.def
BUILT_SOURCES += tcpreplay_opts.h
tcpreplay_opts.c: tcpreplay_opts.def
@AUTOGEN@ $(opts_list) @NETMAPFLAGS@ tcpreplay_opts.def

Expand Down
19 changes: 12 additions & 7 deletions src/common/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ read_cache(char **cachedata, const char *cachefile, char **comment)
ssize_t read_size = 0;
COUNTER cache_size = 0;

assert(cachedata);
assert(comment);

/* open the file or abort */
if ((cachefd = open(cachefile, O_RDONLY)) == -1)
errx(-1, "unable to open %s:%s", cachefile, strerror(errno));
Expand All @@ -99,11 +102,12 @@ read_cache(char **cachedata, const char *cachefile, char **comment)

dbgx(1, "Comment length: %d", header.comment_len);

if ((read_size = read(cachefd, *comment, header.comment_len))
!= header.comment_len)
errx(-1, "Unable to read %d bytes of data for the comment (%zu) %s",
header.comment_len, read_size,
read_size == -1 ? strerror(read_size) : "");
if ((read_size = read(cachefd, *comment, header.comment_len)) < 0)
errx(-1, "Error reading comment: %s", strerror(errno));

if (read_size != (ssize_t)header.comment_len)
errx(-1, "Invalid comment read: expected=%u actual=%zd bytes",
header.comment_len, read_size);

dbgx(1, "Cache file comment: %s", *comment);

Expand Down Expand Up @@ -156,8 +160,8 @@ write_cache(tcpr_cache_t * cachedata, const int out_file, COUNTER numpackets,
/* write a header to our file */
cache_header = (tcpr_cache_file_hdr_t *)
safe_malloc(sizeof(tcpr_cache_file_hdr_t));
strncpy(cache_header->magic, CACHEMAGIC, strlen(CACHEMAGIC));
strncpy(cache_header->version, CACHEVERSION, strlen(CACHEVERSION));
strncpy(cache_header->magic, CACHEMAGIC, strlen(CACHEMAGIC)+1);
strncpy(cache_header->version, CACHEVERSION, strlen(CACHEVERSION)+1);
cache_header->packets_per_byte = htons(CACHE_PACKETS_PER_BYTE);
cache_header->num_packets = htonll((u_int64_t)numpackets);

Expand Down Expand Up @@ -220,6 +224,7 @@ write_cache(tcpr_cache_t * cachedata, const int out_file, COUNTER numpackets,
}
}
}
safe_free(cache_header);
/* return number of packets written */
return (packets);
}
Expand Down
Loading

0 comments on commit f143cb0

Please sign in to comment.