[packages/tcpflow] - rel 3; two patches from debian; fix unordered_map detection

arekm arekm at pld-linux.org
Tue May 10 12:04:48 CEST 2016


commit 9428874278e85debaa68519a19a2c6851b405515
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Tue May 10 12:04:43 2016 +0200

    - rel 3; two patches from debian; fix unordered_map detection

 0001-tcpflow-b-0-now-works.patch                   | 87 ++++++++++++++++++++++
 packing-struct-tcphdr-to-improve-portability.patch | 23 ++++++
 tcpflow.spec                                       |  7 +-
 3 files changed, 116 insertions(+), 1 deletion(-)
---
diff --git a/tcpflow.spec b/tcpflow.spec
index a6a1a48..e3673bb 100644
--- a/tcpflow.spec
+++ b/tcpflow.spec
@@ -6,12 +6,14 @@ Summary:	TCP Flow Recorder
 Summary(pl.UTF-8):	Program zapisujący ruch TCP
 Name:		tcpflow
 Version:	1.4.5
-Release:	2
+Release:	3
 License:	GPL v3
 Group:		Applications/Networking
 Source0:	http://www.digitalcorpora.org/downloads/tcpflow/%{name}-%{version}.tar.gz
 # Source0-md5:	5978b112a899f2099e98cef6d9a0ece9
 Patch0:		0001-using-the-debian-package-of-libhttp-parser-instead-o.patch
+Patch1:		0001-tcpflow-b-0-now-works.patch
+Patch2:		packing-struct-tcphdr-to-improve-portability.patch
 URL:		https://github.com/simsong/tcpflow
 BuildRequires:	autoconf
 BuildRequires:	automake
@@ -49,6 +51,8 @@ połączenie.
 %prep
 %setup -q
 %patch0 -p1
+%patch1 -p1
+%patch2 -p1
 
 %build
 %{__aclocal} -I m4
@@ -56,6 +60,7 @@ połączenie.
 %{__autoheader}
 %{__automake}
 %configure \
+	CPPFLAGS="%{rpmcppflags} -std=c++11" \
 	%{!?with_cairo:--enable-cairo=false}
 %{__make}
 
diff --git a/0001-tcpflow-b-0-now-works.patch b/0001-tcpflow-b-0-now-works.patch
new file mode 100644
index 0000000..c50c42a
--- /dev/null
+++ b/0001-tcpflow-b-0-now-works.patch
@@ -0,0 +1,87 @@
+From 7c32381b6548e407fc3d0f3a63ccf1b6b12dadfd Mon Sep 17 00:00:00 2001
+From: Dima Kogan <dima at secretsauce.net>
+Date: Thu, 5 Mar 2015 15:01:07 -0800
+Subject: [PATCH] 'tcpflow -b 0' now works
+Forwarded: https://github.com/simsong/tcpflow/issues/95
+
+This creates length-0 flow files that act as binary success/failure indicators
+---
+ src/tcpdemux.h |  4 ++--
+ src/tcpip.cpp  | 22 +++++++++++++---------
+ 2 files changed, 15 insertions(+), 11 deletions(-)
+
+diff --git a/src/tcpdemux.h b/src/tcpdemux.h
+index 858c50b..09c5970 100644
+--- a/src/tcpdemux.h
++++ b/src/tcpdemux.h
+@@ -91,7 +91,7 @@ public:
+         options():console_output(false),console_output_nonewline(false),
+                   store_output(true),opt_md5(false),
+                   post_processing(false),gzip_decompress(true),
+-                  max_bytes_per_flow(),
++                  max_bytes_per_flow(-1),
+                   max_flows(0),suppress_header(0),
+                   output_strip_nonprint(true),output_hex(false),use_color(0),
+                   output_packet_index(false),max_seek(MAX_SEEK) {
+@@ -102,7 +102,7 @@ public:
+         bool    opt_md5;                // do we calculate MD5 on DFXML output?
+         bool    post_processing;        // decode headers after tcp connection closes
+         bool    gzip_decompress;
+-        uint64_t max_bytes_per_flow;
++        int64_t  max_bytes_per_flow;
+         uint32_t max_flows;
+         bool    suppress_header;
+         bool    output_strip_nonprint;
+diff --git a/src/tcpip.cpp b/src/tcpip.cpp
+index 70d9ef5..754230b 100644
+--- a/src/tcpip.cpp
++++ b/src/tcpip.cpp
+@@ -236,10 +236,12 @@ void tcpip::print_packet(const u_char *data, uint32_t length)
+     /* green, blue, read */
+     const char *color[3] = { "\033[0;32m", "\033[0;34m", "\033[0;31m" };
+ 
+-    if(demux.opt.max_bytes_per_flow>0){
+-	if(last_byte > demux.opt.max_bytes_per_flow) return; /* too much has been printed */
+-	if(length > demux.opt.max_bytes_per_flow - last_byte){
+-	    length = demux.opt.max_bytes_per_flow - last_byte; /* can only output this much */
++    if(demux.opt.max_bytes_per_flow>=0){
++        uint64_t max_bytes_per_flow = (uint64_t)demux.opt.max_bytes_per_flow;
++
++	if(last_byte > max_bytes_per_flow) return; /* too much has been printed */
++	if(length > max_bytes_per_flow - last_byte){
++	    length = max_bytes_per_flow - last_byte; /* can only output this much */
+ 	    if(length==0) return;
+ 	}
+     }
+@@ -419,13 +421,15 @@ void tcpip::store_packet(const u_char *data, uint32_t length, int32_t delta,stru
+      * but remember to seek out to the actual position after the truncated write...
+      */
+     uint32_t wlength = length;		// length to write
+-    if (demux.opt.max_bytes_per_flow){
+-	if(offset >= demux.opt.max_bytes_per_flow){
++    if (demux.opt.max_bytes_per_flow >= 0){
++        uint64_t max_bytes_per_flow = (uint64_t)demux.opt.max_bytes_per_flow;
++
++	if(offset >= max_bytes_per_flow){
+ 	    wlength = 0;
+ 	} 
+-	if(offset < demux.opt.max_bytes_per_flow &&  offset+length > demux.opt.max_bytes_per_flow){
++	if(offset < max_bytes_per_flow &&  offset+length > max_bytes_per_flow){
+ 	    DEBUG(2) ("packet truncated by max_bytes_per_flow on %s", flow_pathname.c_str());
+-	    wlength = demux.opt.max_bytes_per_flow - offset;
++	    wlength = max_bytes_per_flow - offset;
+ 	}
+     }
+ 
+@@ -434,7 +438,7 @@ void tcpip::store_packet(const u_char *data, uint32_t length, int32_t delta,stru
+      * save the return value because open_tcpfile() puts the file pointer
+      * into the structure for us.
+      */
+-    if (fd < 0 && wlength>0) {
++    if (fd < 0) {
+ 	if (open_file()) {
+ 	    DEBUG(1)("unable to open TCP file %s  fd=%d  wlength=%d",
+                      flow_pathname.c_str(),fd,(int)wlength);
+-- 
+2.1.4
+
diff --git a/packing-struct-tcphdr-to-improve-portability.patch b/packing-struct-tcphdr-to-improve-portability.patch
new file mode 100644
index 0000000..c1af8b3
--- /dev/null
+++ b/packing-struct-tcphdr-to-improve-portability.patch
@@ -0,0 +1,23 @@
+From: Dima Kogan <dima at secretsauce.net>
+Date: Sun, 12 Jan 2014 23:58:39 -0800
+Subject: packing struct tcphdr to improve portability
+Forwarded: https://github.com/simsong/tcpflow/issues/67
+
+I was seeing build failures on arm and sparc. These were happening because of
+unaligned loads of struct tcphdr. I now declare this structure as packed, so
+this does not happen
+
+
+Index: tcpflow/src/be13_api/bulk_extractor_i.h
+===================================================================
+--- tcpflow.orig/src/be13_api/bulk_extractor_i.h
++++ tcpflow/src/be13_api/bulk_extractor_i.h
+@@ -278,7 +278,7 @@ namespace be13 {
+     uint16_t th_win;            /* window */
+     uint16_t th_sum;            /* checksum */
+     uint16_t th_urp;            /* urgent pointer */
+-};
++} __attribute__((packed));
+ /*
+  * The packet_info structure records packets after they are read from the pcap library.
+  * It preserves the original pcap information and information decoded from the MAC and
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/tcpflow.git/commitdiff/9428874278e85debaa68519a19a2c6851b405515



More information about the pld-cvs-commit mailing list