Add flow-tools from #1341
authorFlorian Fainelli <florian@openwrt.org>
Tue, 15 May 2007 08:35:25 +0000 (08:35 +0000)
committerFlorian Fainelli <florian@openwrt.org>
Tue, 15 May 2007 08:35:25 +0000 (08:35 +0000)
SVN-Revision: 7248

net/flow-tools/Makefile [new file with mode: 0644]
net/flow-tools/patches/001-cross_compile_configure_fix.patch [new file with mode: 0644]
net/flow-tools/patches/002-flex_lib.patch [new file with mode: 0644]
net/flow-tools/patches/010-python_script_location_fix.patch [new file with mode: 0644]
net/flow-tools/patches/020-invalid_lvalue_in_assignment.patch [new file with mode: 0644]
net/flow-tools/patches/030-avoid_external_debug_var.patch [new file with mode: 0644]
net/flow-tools/patches/050-fix-64bit_temp_time_t.patch [new file with mode: 0644]
net/flow-tools/patches/060-fix_uninitialized_var_in_flow_send.patch [new file with mode: 0644]
net/flow-tools/patches/070-extra_ftpdu_verify_debugging.patch [new file with mode: 0644]
net/flow-tools/patches/080-fix_uninitialized_var_in_flow_export.patch [new file with mode: 0644]

diff --git a/net/flow-tools/Makefile b/net/flow-tools/Makefile
new file mode 100644 (file)
index 0000000..f5d8693
--- /dev/null
@@ -0,0 +1,43 @@
+#
+# Copyright (C) 2007 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+# $Id: $
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=flow-tools
+PKG_VERSION:=0.68
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=ftp://ftp.eng.oar.net/pub/flow-tools/
+PKG_MD5SUM:=c9e0a8b53c79611b6bffcb9d510a5a38
+PKG_CAT:=zcat
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/flow-tools
+  SECTION:=net
+  CATEGORY:=Network
+  TITLE:=flow-tools
+  DESCRIPTION:=\
+       Flow-tools is a software package for collecting and processing \\\
+       NetFlow data from Cisco and Juniper routers.
+  URL:=http://www.splintered.net/sw/flow-tools/
+endef
+
+define Build/Compile
+       $(call Build/Compile/Default)
+endef
+
+define Package/flow-tools/install      
+       $(INSTALL_DIR) $(1)/usr/bin/
+       $(CP) $(PKG_BUILD_DIR)/src/flow-* $(1)/usr/bin/
+endef
+
+$(eval $(call BuildPackage,flow-tools))
diff --git a/net/flow-tools/patches/001-cross_compile_configure_fix.patch b/net/flow-tools/patches/001-cross_compile_configure_fix.patch
new file mode 100644 (file)
index 0000000..01a3724
--- /dev/null
@@ -0,0 +1,11 @@
+-- flow-tools-0.68.orig/configure      2007-02-08 07:21:42.000000000 -0500
++++ flow-tools-0.68/configure   2007-02-08 07:53:42.000000000 -0500
+@@ -6308,7 +6308,7 @@
+ See \`config.log' for more details." >&5
+ echo "$as_me: error: cannot run test program while cross compiling
+ See \`config.log' for more details." >&2;}
+-   { (exit 1); exit 1; }; }
++}
+ else
+   cat >conftest.$ac_ext <<_ACEOF
+ #line $LINENO "configure"
diff --git a/net/flow-tools/patches/002-flex_lib.patch b/net/flow-tools/patches/002-flex_lib.patch
new file mode 100644 (file)
index 0000000..f6b9877
--- /dev/null
@@ -0,0 +1,46 @@
+--- flow-tools-0.68.orig/Makefile.in   2007-02-08 07:21:42.000000000 -0500
++++ flow-tools-0.68/Makefile.in        2007-02-08 08:18:36.000000000 -0500
+@@ -70,7 +70,7 @@
+ DEPDIR = @DEPDIR@
+ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+ LEX = @LEX@
+-LEXLIB = @LEXLIB@
++LEXLIB =
+ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+ MYSQLCFLAGS = @MYSQLCFLAGS@
+ MYSQLINCLUDE = @MYSQLINCLUDE@
+--- flow-tools-0.68.orig/src/Makefile.in       2007-02-08 07:21:42.000000000 -0500
++++ flow-tools-0.68/src/Makefile.in    2007-02-08 08:18:31.000000000 -0500
+@@ -70,7 +70,7 @@
+ DEPDIR = @DEPDIR@
+ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+ LEX = @LEX@
+-LEXLIB = @LEXLIB@
++LEXLIB =
+ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+ MYSQLCFLAGS = @MYSQLCFLAGS@
+ MYSQLINCLUDE = @MYSQLINCLUDE@
+--- flow-tools-0.68.orig/src/acllex.c  2007-02-08 07:21:42.000000000 -0500
++++ flow-tools-0.68/src/acllex.c       2007-02-08 08:25:10.000000000 -0500
+@@ -503,7 +503,9 @@
+ #ifdef __cplusplus
+ extern "C" int yywrap YY_PROTO(( void ));
+ #else
+-extern int yywrap YY_PROTO(( void ));
++int yywrap (void ) {
++    return 1;
++}
+ #endif
+ #endif
+--- flow-tools-0.68.orig/configure     2007-02-08 07:21:42.000000000 -0500
++++ flow-tools-0.68/configure  2007-02-08 08:19:30.000000000 -0500
+@@ -2952,7 +2952,7 @@
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+   ac_check_lib_save_LIBS=$LIBS
+-LIBS="-lfl  $LIBS"
++LIBS="$LIBS"
+ cat >conftest.$ac_ext <<_ACEOF
+ #line $LINENO "configure"
+ /* confdefs.h.  */
diff --git a/net/flow-tools/patches/010-python_script_location_fix.patch b/net/flow-tools/patches/010-python_script_location_fix.patch
new file mode 100644 (file)
index 0000000..5806732
--- /dev/null
@@ -0,0 +1,30 @@
+diff --git a/bin/flow-log2rrd b/bin/flow-log2rrd
+index 0567ba5..db4fdda 100755
+--- a/bin/flow-log2rrd
++++ b/bin/flow-log2rrd
+@@ -1,4 +1,4 @@
+-#!/usr/local/bin/python
++#!/bin/env python
+ import getopt
+ import os
+diff --git a/bin/flow-rpt2rrd b/bin/flow-rpt2rrd
+index 72a74c7..7698f2b 100755
+--- a/bin/flow-rpt2rrd
++++ b/bin/flow-rpt2rrd
+@@ -1,4 +1,4 @@
+-#!/usr/local/bin/python
++#!/bin/env python
+ import getopt
+ import os
+diff --git a/bin/flow-rptfmt b/bin/flow-rptfmt
+index 047d1ba..f663fae 100755
+--- a/bin/flow-rptfmt
++++ b/bin/flow-rptfmt
+@@ -1,4 +1,4 @@
+-#!/usr/local/bin/python
++#!/bin/env python
+ import sys
+ import string
diff --git a/net/flow-tools/patches/020-invalid_lvalue_in_assignment.patch b/net/flow-tools/patches/020-invalid_lvalue_in_assignment.patch
new file mode 100644 (file)
index 0000000..aeda139
--- /dev/null
@@ -0,0 +1,171 @@
+diff --git a/lib/ftchash.c b/lib/ftchash.c
+index 9cc7efa..28bafbf 100644
+--- a/lib/ftchash.c
++++ b/lib/ftchash.c
+@@ -326,7 +326,7 @@ void *ftchash_foreach(struct ftchash *ft
+       (char*)ftch->traverse_chunk->base+ftch->traverse_chunk->next) {
+       ret = ftch->traverse_rec;
+-      (char*)ftch->traverse_rec += ftch->d_size;
++      ftch->traverse_rec = vpadd(ftch->traverse_rec, ftch->d_size);
+       return ret;
+     } else {
+diff --git a/lib/ftio.c b/lib/ftio.c
+index f6c739c..1082416 100644
+--- a/lib/ftio.c
++++ b/lib/ftio.c
+@@ -2267,7 +2267,7 @@ int readn(register int fd, register void
+         break;
+       nleft -= nread;
+-      (char*)ptr += nread;
++      ptr = vpadd(ptr, nread);
+   }
+   return (nbytes - nleft);
+ } /* readn */
+@@ -2292,7 +2292,7 @@ int writen(register int fd, register voi
+       return(nwritten); /* error */
+     nleft -= nwritten;
+-    (char*)ptr += nwritten;
++    ptr =  vpadd(ptr,nwritten);
+   }
+   return(nbytes - nleft);
+ } /* writen */
+diff --git a/lib/ftlib.h b/lib/ftlib.h
+index f91ad0a..66bf2f3 100644
+--- a/lib/ftlib.h
++++ b/lib/ftlib.h
+@@ -152,7 +152,6 @@ #define FT_PDU_V8_11_MAXFLOWS 44  /* max
+ #define FT_PDU_V8_12_MAXFLOWS 44  /* max records in V8 DST_PREFIX_TOS packet */
+ #define FT_PDU_V8_13_MAXFLOWS 35  /* max records in V8 PREFIX_TOS packet */
+ #define FT_PDU_V8_14_MAXFLOWS 35  /* max records in V8 PREFIX_PORT_TOS packet */
+-
+ #define FT_PDU_V8_1_VERSION    2  /* version of AS packet */
+ #define FT_PDU_V8_2_VERSION    2  /* version of PROTO PORT packet */
+ #define FT_PDU_V8_3_VERSION    2  /* version of SRC PREFIX packet */
+@@ -3029,6 +3028,8 @@ #ifndef IN_CLASSD_SSM
+ #define IN_CLASSD_SSM(i) (((u_int32_t)(i) & 0xff000000) == 0xe8000000)
+ #endif /* IN_CLASSD_SSM */
++void *vpadd(const void* v, const int change);
++
+ /* MACHINE DEPENDANT */
+ #define fmt_uint fmt_uint32
+diff --git a/lib/fttlv.c b/lib/fttlv.c
+index 7035813..330a783 100644
+--- a/lib/fttlv.c
++++ b/lib/fttlv.c
+@@ -68,10 +68,10 @@ int fttlv_enc_uint32(void *buf, int buf_
+   }
+   bcopy(&t, buf, 2);
+-  (char*)buf+= 2;
++  buf = vpadd(buf, 2);
+   bcopy(&len, buf, 2);
+-  (char*)buf+= 2;
++  buf = vpadd(buf, 2);
+   bcopy(&v, buf, 4);
+@@ -107,10 +107,10 @@ int fttlv_enc_uint16(void *buf, int buf_
+   }
+   bcopy(&t, buf, 2);
+-  (char*)buf+= 2;
++  buf = vpadd(buf, 2);
+   bcopy(&len, buf, 2);
+-  (char*)buf+= 2;
++  buf = vpadd(buf, 2);
+   bcopy(&v, buf, 2);
+@@ -145,10 +145,10 @@ int fttlv_enc_uint8(void *buf, int buf_s
+   }
+   bcopy(&t, buf, 2);
+-  (char*)buf+= 2;
++  buf = vpadd(buf, 2);
+   bcopy(&len, buf, 2);
+-  (char*)buf+= 2;
++  buf = vpadd(buf, 2);
+   bcopy(&v, buf, 1);
+@@ -183,10 +183,10 @@ int fttlv_enc_str(void *buf, int buf_siz
+   }
+   bcopy(&t, buf, 2);
+-  (char*)buf+= 2;
++  buf = vpadd(buf, 2);
+   bcopy(&len, buf, 2);
+-  (char*)buf+= 2;
++  buf = vpadd(buf, 2);
+   bcopy(v, buf, len);
+@@ -230,16 +230,16 @@ int fttlv_enc_ifname(void *buf, int buf_
+     return -1;
+   bcopy(&t, buf, 2);
+-  (char*)buf+= 2;
++  buf = vpadd(buf, 2);
+   bcopy(&len, buf, 2);
+-  (char*)buf+= 2;
++  buf = vpadd(buf, 2);
+   bcopy(&ip, buf, 4);
+-  (char*)buf += 4;
++  buf = vpadd(buf, 4);
+   bcopy(&ifIndex, buf, 2);
+-  (char*)buf += 2;
++  buf = vpadd(buf, 2);
+   bcopy(name, buf, n);
+@@ -287,19 +287,19 @@ int fttlv_enc_ifalias(void *buf, int buf
+   }
+   bcopy(&t, buf, 2);
+-  (char*)buf+= 2;
++  buf = vpadd(buf, 2);
+   bcopy(&len, buf, 2);
+-  (char*)buf+= 2;
++  buf = vpadd(buf, 2);
+   bcopy(&ip, buf, 4);
+-  (char*)buf += 4;
++  buf = vpadd(buf, 4);
+   bcopy(&entries, buf, 2);
+-  (char*)buf += 2;
++  buf = vpadd(buf, 2);
+   bcopy(ifIndex_list, buf, esize);
+-  (char*)buf += esize;
++  buf = vpadd(buf, esize);
+   bcopy(name, buf, n);
+diff --git a/lib/support.c b/lib/support.c
+index a32ffe7..2e1db9f 100644
+--- a/lib/support.c
++++ b/lib/support.c
+@@ -736,3 +736,8 @@ int udp_cksum(struct ip *ip, struct udph
+   return sum;
+ } /* udp_cksum */
++// void pointer add
++
++void * vpadd(const void *v, const int change) {
++  return (void *) (((char*) v) + change);
++}
diff --git a/net/flow-tools/patches/030-avoid_external_debug_var.patch b/net/flow-tools/patches/030-avoid_external_debug_var.patch
new file mode 100644 (file)
index 0000000..6ca5740
--- /dev/null
@@ -0,0 +1,13 @@
+diff --git a/lib/ftfile.c b/lib/ftfile.c
+index 2f3ae76..f25e849 100644
+--- a/lib/ftfile.c
++++ b/lib/ftfile.c
+@@ -53,7 +53,7 @@ #endif
+ int load_dir(char *prefix, struct ftfile_entries *fte, int flags, int *depth);
+-extern int debug;
++#define debug 0
+ /*
+  * function: ftfile_entry_new
diff --git a/net/flow-tools/patches/050-fix-64bit_temp_time_t.patch b/net/flow-tools/patches/050-fix-64bit_temp_time_t.patch
new file mode 100644 (file)
index 0000000..99a06f7
--- /dev/null
@@ -0,0 +1,41 @@
+diff --git a/lib/ftfile.c b/lib/ftfile.c
+index f25e849..ec17771 100644
+--- a/lib/ftfile.c
++++ b/lib/ftfile.c
+@@ -413,16 +413,17 @@ void ftfile_pathname(char *buf, int bsiz
+  int done, u_int32 ftime)
+ {
+   struct tm *tm;
++  time_t _t = (time_t) ftime;
+   char *prefix, dbuf[64];
+   long gmt_val;
+   char gmt_sign;
+   int tm_gmtoff;
+   
+-  if (!(tm = localtime ((time_t*)&ftime))) {
++  if (!(tm = localtime (&_t))) {
+     snprintf(buf, bsize, ".");
+   }
+-  tm_gmtoff = get_gmtoff(ftime);
++  tm_gmtoff = get_gmtoff(_t);
+   /* compute GMT offset */
+   if (tm_gmtoff >= 0) {
+@@ -502,6 +503,7 @@ void ftfile_pathname(char *buf, int bsiz
+ int ftfile_mkpath(u_int32 ftime, int nest)
+ {
+   struct tm *tm;
++  time_t _t = (time_t) ftime;
+   char buf[32];
+   /* no directories */
+@@ -512,7 +514,7 @@ int ftfile_mkpath(u_int32 ftime, int nes
+   if ((nest > 3) || (nest < -3))
+     return -1;
+-  if (!(tm = localtime ((time_t*)&ftime)))
++  if (!(tm = localtime (&_t)))
+     return -1;
+   if (nest == -1)
diff --git a/net/flow-tools/patches/060-fix_uninitialized_var_in_flow_send.patch b/net/flow-tools/patches/060-fix_uninitialized_var_in_flow_send.patch
new file mode 100644 (file)
index 0000000..2240537
--- /dev/null
@@ -0,0 +1,13 @@
+diff --git a/src/flow-send.c b/src/flow-send.c
+index 83ca926..ad87024 100644
+--- a/src/flow-send.c
++++ b/src/flow-send.c
+@@ -76,7 +76,7 @@ int main(int argc, char **argv)
+   u_int32 privacy_mask;
+   unsigned int v1, v2, one;
+   int i, n, ret, tx_delay, udp_sock;
+-  int src_ip_spoof, hdr_len;
++  int src_ip_spoof, hdr_len = 0;
+   void *rec;
+   /* init fterr */
diff --git a/net/flow-tools/patches/070-extra_ftpdu_verify_debugging.patch b/net/flow-tools/patches/070-extra_ftpdu_verify_debugging.patch
new file mode 100644 (file)
index 0000000..911d369
--- /dev/null
@@ -0,0 +1,49 @@
+diff --git a/lib/ftdecode.c b/lib/ftdecode.c
+index ff6b0cf..8884db9 100644
+--- a/lib/ftdecode.c
++++ b/lib/ftdecode.c
+@@ -122,8 +122,10 @@ int ftpdu_verify(struct ftpdu *ftpdu)
+   ret = -1;
+   /* enough bytes to decode the count and version? */
+-  if (ftpdu->bused < 4)
++  if (ftpdu->bused < 4) {
++    fterr_warnx("not enough bytes to decode the count and version.");
+     goto ftpdu_verify_out_quick;
++  }
+   ph = (struct ftpdu_header*)&ftpdu->buf;
+@@ -158,15 +160,22 @@ #endif /* LITTLE_ENDIAN */
+     case 5:
+       /* max PDU's in record */
+-      if (ph->count > FT_PDU_V5_MAXFLOWS)
++      if (ph->count > FT_PDU_V5_MAXFLOWS) {
++      fterr_warnx("too many pdus (%d) in record, max %d", ph->count,
++              FT_PDU_V5_MAXFLOWS);
+         goto ftpdu_verify_out;
++      }
++
+       size = offsetof(struct ftpdu_v5, records) +
+              ph->count * sizeof (struct ftrec_v5);
+       /* PDU received size == PDU expected size? */
+-      if (size != ftpdu->bused)
++      if (size != ftpdu->bused) {
++        fterr_warnx("pdu received size was wrong.  expected %d got %d",
++                ftpdu->bused, size);
+         goto ftpdu_verify_out;
++      }
+       ftpdu->ftv.d_version = 5;
+       ftpdu->decodef = fts3rec_pdu_v5_decode;
+@@ -516,6 +525,7 @@ #endif /* LITTLE_ENDIAN */
+       break; /* 8 */
+       default:
++        fterr_warnx("ftpdu version not set.");
+           goto ftpdu_verify_out;
+   } /* switch ph->version */
diff --git a/net/flow-tools/patches/080-fix_uninitialized_var_in_flow_export.patch b/net/flow-tools/patches/080-fix_uninitialized_var_in_flow_export.patch
new file mode 100644 (file)
index 0000000..bd88403
--- /dev/null
@@ -0,0 +1,13 @@
+diff --git a/src/flow-export.c b/src/flow-export.c
+index 52ae4d2..22b0330 100644
+--- a/src/flow-export.c
++++ b/src/flow-export.c
+@@ -961,7 +961,7 @@ #endif /* PGSQL */
+ int fmt_xfields_type(char *buf, u_int64 xfield)
+ {
+-  int comma;
++  int comma = 0;
+   buf[0] = 0;