ASR_BASE
Change-Id: Icf3719cc0afe3eeb3edc7fa80a2eb5199ca9dda1
diff --git a/external/subpack/net/softflowd/Makefile b/external/subpack/net/softflowd/Makefile
new file mode 100644
index 0000000..3e966e4
--- /dev/null
+++ b/external/subpack/net/softflowd/Makefile
@@ -0,0 +1,55 @@
+#
+# Copyright (C) 2007-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=softflowd
+PKG_VERSION:=1.0.0
+PKG_RELEASE:=2
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=https://codeload.github.com/irino/softflowd/tar.gz/softflowd-$(PKG_VERSION)?
+PKG_HASH:=98aa66026d730211b45fe89670cd6ce50959846d536880b82f5afbca6281e108
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-softflowd-$(PKG_VERSION)
+
+PKG_MAINTAINER:=Ross Vandegrift <ross@kallisti.us>
+PKG_LICENSE:=BSD-3-Clause
+PKG_LICENSE_FILES:=LICENSE
+
+PKG_FIXUP:=autoreconf
+PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/softflowd
+ SECTION:=net
+ CATEGORY:=Network
+ DEPENDS:=+libpcap
+ TITLE:=softflowd
+ URL:=https://github.com/irino/softflowd
+endef
+
+define Package/softflowd/description
+ Software netflow exporter
+endef
+
+define Package/softflowd/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/softflowd $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/softflowctl $(1)/usr/sbin/
+ $(INSTALL_DIR) $(1)/etc/config
+ $(INSTALL_DATA) ./files/$(PKG_NAME).config $(1)/etc/config/$(PKG_NAME)
+ $(INSTALL_DIR) $(1)/etc/init.d
+ $(INSTALL_BIN) ./files/$(PKG_NAME).init $(1)/etc/init.d/$(PKG_NAME)
+endef
+
+define Package/softflowd/conffiles
+/etc/config/softflowd
+endef
+
+$(eval $(call BuildPackage,softflowd))
diff --git a/external/subpack/net/softflowd/files/softflowd.config b/external/subpack/net/softflowd/files/softflowd.config
new file mode 100644
index 0000000..61a2ee4
--- /dev/null
+++ b/external/subpack/net/softflowd/files/softflowd.config
@@ -0,0 +1,14 @@
+config softflowd
+ option enabled '0'
+ option interface 'br-lan'
+ option pcap_file ''
+ option timeout ''
+ option max_flows '8192'
+ option host_port ''
+ option pid_file '/var/run/softflowd.pid'
+ option control_socket '/var/run/softflowd.ctl'
+ option export_version '5'
+ option hoplimit ''
+ option tracking_level 'full'
+ option track_ipv6 '0'
+ option sampling_rate '100'
diff --git a/external/subpack/net/softflowd/files/softflowd.init b/external/subpack/net/softflowd/files/softflowd.init
new file mode 100755
index 0000000..3f1c5f8
--- /dev/null
+++ b/external/subpack/net/softflowd/files/softflowd.init
@@ -0,0 +1,59 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2007-2011 OpenWrt.org
+
+USE_PROCD=1
+START=50
+
+append_bool() {
+ local section="$1"
+ local option="$2"
+ local value="$3"
+ local _val
+ config_get_bool _val "$section" "$option" '0'
+ [ "$_val" -gt 0 ] && append args "$3"
+}
+
+append_string() {
+ local section="$1"
+ local option="$2"
+ local value="$3"
+ local _val
+ config_get _val "$section" "$option"
+ [ -n "$_val" ] && append args "$3 $_val"
+}
+
+start_instance() {
+ local section="$1"
+
+ config_get_bool enabled "$section" 'enabled' '0'
+ [ "$enabled" -gt 0 ] || return 1
+
+ config_get pid_file "$section" 'pid_file'
+
+ args=""
+ append_string "$section" 'interface' '-i'
+ append_string "$section" 'pcap_file' '-r'
+ append_string "$section" 'timeout' '-t'
+ append_string "$section" 'max_flows' '-m'
+ append_string "$section" 'host_port' '-n'
+ append_string "$section" 'pid_file' '-p'
+ append_string "$section" 'control_socket' '-c'
+ append_string "$section" 'export_version' '-v'
+ append_string "$section" 'hoplimit' '-L'
+ append_string "$section" 'tracking_level' '-T'
+ append_string "$section" 'sampling_rate' '-s'
+ append_bool "$section" track_ipv6 '-6'
+
+ procd_open_instance
+ procd_set_param command /usr/sbin/softflowd -d $args${pid_file:+ -p $pid_file}
+ procd_set_param respawn
+ procd_close_instance
+}
+
+start_service() {
+ mkdir -p /var/empty
+ chmod 0755 /var/empty
+
+ config_load 'softflowd'
+ config_foreach start_instance 'softflowd'
+}
diff --git a/external/subpack/net/softflowd/patches/010-bzero.patch b/external/subpack/net/softflowd/patches/010-bzero.patch
new file mode 100644
index 0000000..a67f6f3
--- /dev/null
+++ b/external/subpack/net/softflowd/patches/010-bzero.patch
@@ -0,0 +1,134 @@
+--- a/freelist.c
++++ b/freelist.c
+@@ -46,7 +46,7 @@ freelist_init(struct freelist *fl, size_
+ {
+ size_t sizeof_fl = sizeof(fl);
+ FLOGIT((LOG_DEBUG, "%s: %s(%p, %zu)", __func__, __func__, fl, allocsz));
+- bzero(fl, sizeof_fl);
++ memset(fl, 0, sizeof_fl);
+ fl->allocsz = roundup(allocsz, FREELIST_ALLOC_ALIGN);
+ fl->free_entries = NULL;
+ }
+--- a/ipfix.c
++++ b/ipfix.c
+@@ -388,7 +388,7 @@ ipfix_init_template_unity (struct FLOWTR
+ u_int8_t icmp_flag, u_int8_t bi_flag,
+ u_int16_t version) {
+ u_int index = 0, bi_index = 0, length = 0;
+- bzero (template, sizeof (*template));
++ memset (template, 0, sizeof (*template));
+ template->h.c.set_id = htons (version == 10 ?
+ IPFIX_TEMPLATE_SET_ID :
+ NFLOW9_TEMPLATE_SET_ID);
+@@ -510,7 +510,7 @@ nflow9_init_option (u_int16_t ifidx, str
+ NFLOW9_SOFTFLOWD_OPTION_TEMPLATE_NRECORDS *
+ sizeof (struct IPFIX_FIELD_SPECIFIER);
+
+- bzero (&option_template, sizeof (option_template));
++ memset (&option_template, 0, sizeof (option_template));
+ option_template.h.c.set_id = htons (NFLOW9_OPTION_TEMPLATE_SET_ID);
+ option_template.h.c.length =
+ htons (sizeof (option_template.h) + scope_len + opt_len);
+@@ -524,7 +524,7 @@ nflow9_init_option (u_int16_t ifidx, str
+ ipfix_init_fields (option_template.r, &option_index,
+ field_nf9option,
+ NFLOW9_SOFTFLOWD_OPTION_TEMPLATE_NRECORDS);
+- bzero (&nf9opt_data, sizeof (nf9opt_data));
++ memset (&nf9opt_data, 0, sizeof (nf9opt_data));
+ nf9opt_data.c.set_id = htons (IPFIX_SOFTFLOWD_OPTION_TEMPLATE_ID);
+ nf9opt_data.c.length = htons (sizeof (nf9opt_data));
+ nf9opt_data.scope_ifidx = htonl (ifidx);
+@@ -536,7 +536,7 @@ nflow9_init_option (u_int16_t ifidx, str
+ static void
+ ipfix_init_option (struct timeval *system_boot_time, struct OPTION *option) {
+ u_int scope_index = 0, option_index = 0;
+- bzero (&option_template, sizeof (option_template));
++ memset (&option_template, 0, sizeof (option_template));
+ option_template.h.c.set_id = htons (IPFIX_OPTION_TEMPLATE_SET_ID);
+ option_template.h.c.length = htons (sizeof (option_template));
+ option_template.h.u.i.r.template_id =
+@@ -553,7 +553,7 @@ ipfix_init_option (struct timeval *syste
+ ipfix_init_fields (option_template.r, &option_index, field_option,
+ IPFIX_SOFTFLOWD_OPTION_TEMPLATE_NRECORDS);
+
+- bzero (&option_data, sizeof (option_data));
++ memset (&option_data, 0, sizeof (option_data));
+ option_data.c.set_id = htons (IPFIX_SOFTFLOWD_OPTION_TEMPLATE_ID);
+ option_data.c.length = htons (sizeof (option_data));
+ option_data.scope_pid = htonl ((u_int32_t) option->meteringProcessId);
+@@ -809,7 +809,7 @@ send_ipfix_common (struct FLOW **flows,
+
+ last_valid = num_packets = 0;
+ for (j = 0; j < num_flows;) {
+- bzero (packet, sizeof (packet));
++ memset (packet, 0, sizeof (packet));
+ if (version == 10) {
+ ipfix = (struct IPFIX_HEADER *) packet;
+ ipfix->version = htons (version);
+--- a/netflow9.c
++++ b/netflow9.c
+@@ -145,7 +145,7 @@ static int nf9_pkts_until_template = -1;
+
+ static void
+ nf9_init_template (void) {
+- bzero (&v4_template, sizeof (v4_template));
++ memset (&v4_template, 0, sizeof (v4_template));
+ v4_template.h.c.flowset_id = htons (NFLOW9_TEMPLATE_SET_ID);
+ v4_template.h.c.length = htons (sizeof (v4_template));
+ v4_template.h.template_id = htons (NF9_SOFTFLOWD_V4_TEMPLATE_ID);
+@@ -182,7 +182,7 @@ nf9_init_template (void) {
+ v4_template.r[14].length = htons (2);
+ v4_template.r[15].type = htons (NF9_SRC_VLAN);
+ v4_template.r[15].length = htons (2);
+- bzero (&v6_template, sizeof (v6_template));
++ memset (&v6_template, 0, sizeof (v6_template));
+ v6_template.h.c.flowset_id = htons (NFLOW9_TEMPLATE_SET_ID);
+ v6_template.h.c.length = htons (sizeof (v6_template));
+ v6_template.h.template_id = htons (NF9_SOFTFLOWD_V6_TEMPLATE_ID);
+@@ -223,7 +223,7 @@ nf9_init_template (void) {
+
+ static void
+ nf9_init_option (u_int16_t ifidx, struct OPTION *option) {
+- bzero (&option_template, sizeof (option_template));
++ memset (&option_template, 0, sizeof (option_template));
+ option_template.h.c.flowset_id = htons (NFLOW9_OPTION_TEMPLATE_SET_ID);
+ option_template.h.c.length = htons (sizeof (option_template));
+ option_template.h.template_id = htons (NF9_SOFTFLOWD_OPTION_TEMPLATE_ID);
+@@ -238,7 +238,7 @@ nf9_init_option (u_int16_t ifidx, struct
+ option_template.r[1].length =
+ htons (sizeof (option_data.sampling_algorithm));
+
+- bzero (&option_data, sizeof (option_data));
++ memset (&option_data, 0, sizeof (option_data));
+ option_data.c.flowset_id = htons (NF9_SOFTFLOWD_OPTION_TEMPLATE_ID);
+ option_data.c.length = htons (sizeof (option_data));
+ option_data.scope_ifidx = htonl (ifidx);
+@@ -257,7 +257,7 @@ nf_flow_to_flowset (const struct FLOW *f
+ struct NF9_SOFTFLOWD_DATA_COMMON *dc[2];
+ u_int freclen, ret_len, nflows;
+
+- bzero (d, sizeof (d));
++ memset (d, 0, sizeof (d));
+ *len_used = nflows = ret_len = 0;
+ switch (flow->af) {
+ case AF_INET:
+@@ -363,7 +363,7 @@ send_netflow_v9 (struct SENDPARAMETER sp
+
+ last_valid = num_packets = 0;
+ for (j = 0; j < num_flows;) {
+- bzero (packet, sizeof (packet));
++ memset (packet, 0, sizeof (packet));
+ nf9 = (struct NFLOW9_HEADER *) packet;
+
+ nf9->version = htons (9);
+--- a/psamp.c
++++ b/psamp.c
+@@ -51,7 +51,7 @@ static int psamp_pkts_until_template = -
+ static void
+ psamp_init_template (struct PSAMP_SOFTFLOWD_TEMPLATE *template_p) {
+ u_int index = 0;
+- bzero (template_p, sizeof (*template_p));
++ memset (template_p, 0, sizeof (*template_p));
+ template_p->h.c.set_id = htons (IPFIX_TEMPLATE_SET_ID);
+ template_p->h.c.length = htons (sizeof (struct PSAMP_SOFTFLOWD_TEMPLATE));
+ template_p->h.r.template_id = htons (PSAMP_SOFTFLOWD_TEMPLATE_ID);
diff --git a/external/subpack/net/softflowd/patches/020-uid.patch b/external/subpack/net/softflowd/patches/020-uid.patch
new file mode 100644
index 0000000..fe2ea7c
--- /dev/null
+++ b/external/subpack/net/softflowd/patches/020-uid.patch
@@ -0,0 +1,11 @@
+--- a/common.h
++++ b/common.h
+@@ -179,7 +179,7 @@ struct ip6_ext {
+
+ /* following lines are copy from unistd.h in Linux for avoidance warnings in compilation */
+ #if defined(HAVE_SETRESGID) && !defined(_GNU_SOURCE)
+-extern int setresgid (__uid_t __ruid, __uid_t __euid, __uid_t __suid);
++extern int setresgid (uid_t __ruid, uid_t __euid, uid_t __suid);
+ #endif
+ #if defined(HAVE_SETRESUID) && !defined(_GNU_SOURCE)
+ extern int setresuid (__uid_t __ruid, __uid_t __euid, __uid_t __suid);