From 67f9b018cfdbe09c9f093cb0acc6c92e033badbf Mon Sep 17 00:00:00 2001 From: Ycarus Date: Mon, 6 Aug 2018 14:09:39 +0200 Subject: [PATCH] Add tracebox --- openmptcprouter-full/Makefile | 1 + tracebox/Makefile | 51 +++++++++++++++++++ tracebox/patches/101-build-fixes.patch | 33 ++++++++++++ tracebox/patches/102-configure.patch | 19 +++++++ tracebox/patches/103-configure.patch | 24 +++++++++ tracebox/patches/104-ns_name_compress.patch | 31 +++++++++++ .../patches/202-fix-lua-include-hpp.patch | 32 ++++++++++++ .../204-fix-lua-namespace-crafter.patch | 10 ++++ 8 files changed, 201 insertions(+) create mode 100644 tracebox/Makefile create mode 100644 tracebox/patches/101-build-fixes.patch create mode 100644 tracebox/patches/102-configure.patch create mode 100644 tracebox/patches/103-configure.patch create mode 100644 tracebox/patches/104-ns_name_compress.patch create mode 100644 tracebox/patches/202-fix-lua-include-hpp.patch create mode 100644 tracebox/patches/204-fix-lua-namespace-crafter.patch diff --git a/openmptcprouter-full/Makefile b/openmptcprouter-full/Makefile index 162c615a6..ec8043bf6 100644 --- a/openmptcprouter-full/Makefile +++ b/openmptcprouter-full/Makefile @@ -41,6 +41,7 @@ MY_DEPENDS := \ iftop \ tcpdump \ ethtool \ + tracebox \ luci-proto-3g \ comgt-ncm luci-proto-ncm \ luci-app-mlvpn mlvpn \ diff --git a/tracebox/Makefile b/tracebox/Makefile new file mode 100644 index 000000000..042ab2b29 --- /dev/null +++ b/tracebox/Makefile @@ -0,0 +1,51 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=tracebox +PKG_VERSION:=0.4.4 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) +PKG_SOURCE_URL:=git@github.com:tracebox/tracebox.git +PKG_MAINTAINER:=Gregory Detal + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_VERSION:=v0.4.4 + +PKG_FIXUP:=autoreconf + +#include $(INCLUDE_DIR)/uclibc++.mk +include $(INCLUDE_DIR)/package.mk +#include $(INCLUDE_DIR)/autotools.mk + +define Package/tracebox + SECTION:=net + CATEGORY:=Network + TITLE:=tracebox + DEPENDS:=+liblua +libpcap +libpthread +librt +curl +libjson-c +libnetfilter-queue +libstdcpp +endef + +define Package/tracebox/description + Tracebox is a tool that allows to detect middleboxes on any paths, i.e., +between a source and any destination. Tracebox can be viewed as a tool similar +to traceroute as it uses ICMP replies to identify changes in the packets. +endef + +CONFIGURE_VARS += \ + ac_cv_header_lua_h=no \ + ax_header_version_match=yes + +CONFIGURE_ARGS += --enable-sniffer --enable-curl --with-libpcap="$(STAGING_DIR)/usr/include/" +#CONFIGURE_ARGS += --enable-sniffer --enable-curl +#CONFIGURE_ARGS += --disable-shared --enable-static + +EXTRA_CPPFLAGS += -fpermissive -Wno-variadic-macros + +TARGET_CFLAGS += -D_GNU_SOURCE + +define Package/tracebox/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/tracebox/tracebox $(1)/usr/sbin/tracebox +endef + +$(eval $(call BuildPackage,tracebox)) diff --git a/tracebox/patches/101-build-fixes.patch b/tracebox/patches/101-build-fixes.patch new file mode 100644 index 000000000..c10739153 --- /dev/null +++ b/tracebox/patches/101-build-fixes.patch @@ -0,0 +1,33 @@ +diff --git a/noinst/libcrafter/libcrafter/crafter/Fields/NumericFields.cpp b/noinst/libcrafter/libcrafter/crafter/Fields/NumericFields.cpp +index 86b77e6..7de1eb7 100644 +--- a/noinst/libcrafter/libcrafter/crafter/Fields/NumericFields.cpp ++++ b/noinst/libcrafter/libcrafter/crafter/Fields/NumericFields.cpp +@@ -270,8 +270,15 @@ Int64Field::Int64Field(const std::string& name, size_t nword, size_t nbyte) : + offset = nword * 4 + nbyte; + } + ++static string genString(uint64_t val) ++{ ++ char temp[21]; ++ sprintf(temp, "%llu", val); ++ return temp; ++} ++ + void Int64Field::PrintValue(std::ostream& str) const { +- str << GetName() << " = " << dec << (uint64_t)human; ++ str << GetName() << " = " << dec << genString(human); + } + + FieldInfo* Int64Field::Clone() const { +diff --git a/noinst/libcrafter/libcrafter/crafter/Packet.h b/noinst/libcrafter/libcrafter/crafter/Packet.h +index 2fa813d..25c0fa1 100644 +--- a/noinst/libcrafter/libcrafter/crafter/Packet.h ++++ b/noinst/libcrafter/libcrafter/crafter/Packet.h +@@ -33,6 +33,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + #include + #include + #include ++#include + + #include "Crafter.h" + #include "Utils/RawSocket.h" diff --git a/tracebox/patches/102-configure.patch b/tracebox/patches/102-configure.patch new file mode 100644 index 000000000..9aeb84973 --- /dev/null +++ b/tracebox/patches/102-configure.patch @@ -0,0 +1,19 @@ +--- a/configure.ac 2018-07-20 16:15:42.284633906 +0200 ++++ b/configure.ac 2018-07-20 16:16:09.812296939 +0200 +@@ -162,16 +162,8 @@ + ;; + *) + AC_MSG_RESULT($withval) +- if test -f $withval/pcap.h -a \ +- -f $withval/libpcap.a -a \ +- -d $withval/pcap; then +- owd=`pwd` +- if cd $withval; then withval=`pwd`; cd $owd; fi + PCAPINC="-I$withval -I$withval/bpf" + PCAPLIB="-L$withval -lpcap" +- else +- AC_ERROR(pcap.h, net/bpf.h, or libpcap.a not found in $withval) +- fi + ;; + esac ], + [ if test -f ${prefix}/include/pcap.h; then diff --git a/tracebox/patches/103-configure.patch b/tracebox/patches/103-configure.patch new file mode 100644 index 000000000..120fcfa71 --- /dev/null +++ b/tracebox/patches/103-configure.patch @@ -0,0 +1,24 @@ +--- a/noinst/libcrafter/libcrafter/configure.ac.anc 2018-07-20 16:45:10.760534965 +0200 ++++ b/noinst/libcrafter/libcrafter/configure.ac 2018-07-20 16:46:03.339973975 +0200 +@@ -29,21 +29,8 @@ + ;; + *) + AC_MSG_RESULT($withval) +- if test -f $withval/pcap.h -a -f $withval/libpcap.a; then +- owd=`pwd` +- if cd $withval; then withval=`pwd`; cd $owd; fi + PCAPINC="-I$withval -I$withval/bpf" + PCAPLIB="-L$withval -lpcap" +- elif test -f $withval/include/pcap.h -a \ +- -f $withval/include/net/bpf.h -a \ +- -f $withval/lib/libpcap.a; then +- owd=`pwd` +- if cd $withval; then withval=`pwd`; cd $owd; fi +- PCAPINC="-I$withval/include" +- PCAPLIB="-L$withval/lib -lpcap" +- else +- AC_ERROR(pcap.h, net/bpf.h, or libpcap.a not found in $withval) +- fi + ;; + esac ], + [ if test -f ${prefix}/include/pcap.h; then diff --git a/tracebox/patches/104-ns_name_compress.patch b/tracebox/patches/104-ns_name_compress.patch new file mode 100644 index 000000000..76cd520a3 --- /dev/null +++ b/tracebox/patches/104-ns_name_compress.patch @@ -0,0 +1,31 @@ +--- a/noinst/libcrafter/libcrafter/crafter/Protocols/DNSQuery.cpp 2018-07-20 17:28:21.252256760 +0200 ++++ b/noinst/libcrafter/libcrafter/crafter/Protocols/DNSQuery.cpp 2018-07-20 17:28:35.092103432 +0200 +@@ -85,7 +85,7 @@ + + size_t DNS::DNSQuery::Compress() { + /* Put data into the buffer */ +- int nbytes = ns_name_compress(qname.c_str(), cqname, sizeof(cqname) , NULL, ++ int nbytes = dn_comp(qname.c_str(), cqname, sizeof(cqname) , NULL, + NULL); + if(nbytes == -1) + throw std::runtime_error("DNS::DNSQuery::Compress() : Error compressing the domain name provided"); +--- a/noinst/libcrafter/libcrafter/crafter/Protocols/DNSAnswer.cpp 2018-07-20 17:37:46.614513337 +0200 ++++ b/noinst/libcrafter/libcrafter/crafter/Protocols/DNSAnswer.cpp 2018-07-20 17:38:24.298131516 +0200 +@@ -209,7 +209,7 @@ + + size_t DNS::DNSAnswer::CompressName() { + /* Put data into the buffer */ +- int nbytes = ns_name_compress(qname.c_str(), cqname, sizeof(cqname), NULL, ++ int nbytes = dn_comp(qname.c_str(), cqname, sizeof(cqname), NULL, + NULL); + if(nbytes == -1) + throw std::runtime_error("DNSAnswer::CompressName() : Error compressing the domain name provided"); +@@ -224,7 +224,7 @@ + size_t DNS::DNSAnswer::CompressRData() { + if (rdata.find_first_of("abcdefghijklmnopqrstuvwxyzABCDEFGHIKKLMNOPQRSTUVWXYZ") != std::string::npos) { + /* Put data into the buffer */ +- int nbytes = ns_name_compress(rdata.c_str(), crdata, sizeof(crdata), ++ int nbytes = dn_comp(rdata.c_str(), crdata, sizeof(crdata), + NULL, NULL); + if(nbytes == -1) + throw std::runtime_error("DNSAnswer::CompressRData() : Error compressing the domain name provided"); diff --git a/tracebox/patches/202-fix-lua-include-hpp.patch b/tracebox/patches/202-fix-lua-include-hpp.patch new file mode 100644 index 000000000..939c23a70 --- /dev/null +++ b/tracebox/patches/202-fix-lua-include-hpp.patch @@ -0,0 +1,32 @@ +--- a/src/tracebox/lua.cc 2018-07-20 18:03:00.439624791 +0200 ++++ b/src/tracebox/lua.cc 2018-07-20 18:03:38.035263456 +0200 +@@ -6,7 +6,12 @@ + */ + + ++extern "C" { ++#include "lua.h" ++#include "lualib.h" ++#include "lauxlib.h" ++} + #include "lua/lua_packet.hpp" + #include "config.h" + + extern lua_State* l_init(); +--- a/src/tracebox/lua/lua_base.hpp 2018-08-06 09:43:49.589813406 +0200 ++++ b/src/tracebox/lua/lua_base.hpp 2018-08-06 09:44:27.773454118 +0200 +@@ -13,8 +13,12 @@ + #include + + #define LUA_COMPAT_ALL +-#include +-#include ++extern "C" { ++#include "lua.h" ++#include "lualib.h" ++#include "lauxlib.h" ++} ++ + + #include "config.h" + diff --git a/tracebox/patches/204-fix-lua-namespace-crafter.patch b/tracebox/patches/204-fix-lua-namespace-crafter.patch new file mode 100644 index 000000000..d58614406 --- /dev/null +++ b/tracebox/patches/204-fix-lua-namespace-crafter.patch @@ -0,0 +1,10 @@ +--- a/src/tracebox/lua.cc 2018-07-20 20:04:08.984285796 +0200 ++++ b/src/tracebox/lua.cc 2018-07-20 20:04:22.336156705 +0200 +@@ -12,6 +12,7 @@ + #include "lauxlib.h" + } + #include "config.h" ++#include "PartialHeader.h" + + extern lua_State* l_init(); +