ASR_BASE
Change-Id: Icf3719cc0afe3eeb3edc7fa80a2eb5199ca9dda1
diff --git a/external/subpack/net/netifyd/Makefile b/external/subpack/net/netifyd/Makefile
new file mode 100644
index 0000000..025bf26
--- /dev/null
+++ b/external/subpack/net/netifyd/Makefile
@@ -0,0 +1,106 @@
+#
+# Copyright (C) 2016-2020 eGloo, Incorporated
+#
+# This is free software, licensed under the GNU General Public License v2.
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=netifyd
+PKG_RELEASE:=2
+PKG_MAINTAINER:=Darryl Sokoloski <darryl@egloo.ca>
+PKG_LICENSE:=GPL-3.0-or-later
+
+PKG_BUILD_PARALLEL:=1
+PKG_FIXUP:=autoreconf
+PKG_INSTALL:=1
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=https://gitlab.com/netify.ai/public/netify-agent.git
+PKG_SOURCE_DATE:=2020-09-15
+PKG_SOURCE_VERSION:=v3.05
+#PKG_SOURCE_VERSION:=09fa5fb202ba95ee2d73a4eb0fefe9265d15c780
+PKG_MIRROR_HASH:=2bcaa54f1660a30070f0c79a79259e96f169a9c7a0fe4a1195bb74f7de184204
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/netifyd
+ SECTION:=net
+ CATEGORY:=Network
+ TITLE:=Netify Agent
+ URL:=http://www.netify.ai/
+ DEPENDS:=+ca-bundle +libcurl +libmnl +libnetfilter-conntrack +libpcap +zlib +libpthread @!USE_UCLIBC
+ # Explicitly depend on libstdcpp rather than $(CXX_DEPENDS). At the moment
+ # std::unordered_map is only available via libstdcpp which is required for
+ # performance reasons.
+ DEPENDS+=+libstdcpp
+endef
+
+define Package/netifyd/description
+The Netify Agent is a deep-packet inspection server which detects network
+protocols and applications. These detections can be saved locally, served over
+a UNIX or TCP socket, and/or "pushed" (via HTTP POSTs) to a remote third-party
+server. Flow metadata, network statistics, and detection classifications are
+JSON encoded for easy consumption by third-party applications.
+endef
+
+define Package/netifyd/conffiles
+/etc/netifyd.conf
+/etc/config/netifyd
+/etc/netify.d/agent.uuid
+/etc/netify.d/serial.uuid
+/etc/netify.d/site.uuid
+endef
+
+TARGET_CFLAGS+=-ffunction-sections -fdata-sections -Wno-psabi
+TARGET_CXXFLAGS+=-ffunction-sections -fdata-sections -Wno-psabi
+TARGET_LDFLAGS+=-Wl,--gc-sections
+
+CONFIGURE_ARGS+= \
+ --sharedstatedir=/var/run \
+ --enable-lean-and-mean \
+ --disable-libtcmalloc \
+ --without-systemdsystemunitdir \
+ --without-tmpfilesdir
+
+# Disable configuration file-watch support (deprecated feature).
+# Not to be confused with kernel/system-level inotify support.
+CONFIGURE_ARGS+= \
+ --disable-inotify
+
+ifneq ($(CONFIG_LIBCURL_ZLIB),y)
+CONFIGURE_ARGS+= \
+ --without-libcurl-zlib
+endif
+
+define Build/Configure
+ (cd $(PKG_BUILD_DIR); ./autogen.sh)
+ $(call Build/Configure/Default,$(CONFIGURE_ARGS))
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include/netifyd
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/netifyd/*.h $(1)/usr/include/netifyd
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libnetifyd.{a,so*} $(1)/usr/lib/
+ $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+ $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libnetifyd.pc $(1)/usr/lib/pkgconfig/
+endef
+
+define Package/netifyd/install
+ $(INSTALL_DIR) $(1)/etc
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/deploy/netifyd.conf $(1)/etc
+ $(INSTALL_DIR) $(1)/etc/config
+ $(INSTALL_CONF) ./files/netifyd.config $(1)/etc/config/netifyd
+ $(INSTALL_DIR) $(1)/etc/init.d
+ $(INSTALL_BIN) ./files/netifyd.init $(1)/etc/init.d/netifyd
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/netifyd $(1)/usr/sbin
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libnetifyd.so.* $(1)/usr/lib/
+ $(INSTALL_DIR) $(1)/etc/netify.d
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/deploy/netify-sink.conf $(1)/etc/netify.d/netify-sink.conf
+ $(INSTALL_DIR) $(1)/usr/share/netifyd
+ $(INSTALL_DATA) $(PKG_BUILD_DIR)/deploy/functions.sh $(1)/usr/share/netifyd
+endef
+
+$(eval $(call BuildPackage,netifyd))
diff --git a/external/subpack/net/netifyd/README.md b/external/subpack/net/netifyd/README.md
new file mode 100644
index 0000000..c1127d5
--- /dev/null
+++ b/external/subpack/net/netifyd/README.md
@@ -0,0 +1,69 @@
+# Netify Agent
+Copyright ©2015-2020 eGloo Incorporated ([www.egloo.ca](https://www.egloo.ca))
+
+## Network Intelligence - Simplified
+The [Netify Agent](https://www.netify.ai/) is a deep-packet inspection server. The Agent is built on top of [nDPI](http://www.ntop.org/products/deep-packet-inspection/ndpi/) (formerly OpenDPI) to detect network protocols and applications. Detections can be saved locally, served over a UNIX or TCP socket, and/or "pushed" (via HTTP POSTs) to a remote third-party server. Flow metadata, network statistics, and detection classifications are stored using JSON encoding.
+
+Optionally, the Netify Agent can be coupled with a [Netify Cloud](https://www.netify.ai/) subscription for further cloud processing, historical storage, machine-learning analysis, event notifications, device detection/identification, along with the option (on supported platforms) to take an active role in policing/bandwidth-shaping specific network protocols and applications.
+
+## Download Packages
+Supported platforms with installation instructions can be found [here](https://www.netify.ai/get-netify).
+
+Alternatively, binary packages are available for the following OS distributions (manual install):
+- [CentOS](http://download.netify.ai/netify/centos/)
+- [ClearOS](http://download.netify.ai/netify/clearos/)
+- [Debian](http://download.netify.ai/netify/debian/)
+- [FreeBSD](http://download.netify.ai/netify/freebsd/)
+- [NethServer](http://download.netify.ai/netify/nethserver/)
+- [OpenWrt/LEDE](https://downloads.openwrt.org/snapshots/packages/)
+- [pfSense](http://download.netify.ai/netify/pfsense/)
+- [Raspbian](https://software.opensuse.org//download.html?project=home%3Aegloo&package=netifyd)
+- [RHEL](http://download.netify.ai/netify/rhel/)
+- [Ubuntu](http://download.netify.ai/netify/ubuntu/)
+
+### Runtime Requirements
+- [Linux] Ensure that the nfnetlink and nf_conntrack_netlink kernel modules are loaded if NAT detection is enabled.
+
+## Download Source
+When cloning the source tree, ensure you use `--recursive` to include all
+sub-modules.
+
+### Build Requirements
+Netify requires the following third-party packages:
+- libcurl
+- libpcap
+- zlib
+- [Linux] libmnl
+- [Linux] libnetfilter-conntrack
+
+Optional:
+- google-perftools/gperftools/libtcmalloc (will use bundled version when not available)
+
+### Configuring/Building From Source
+Read the appropriate documentation in the doc directory, prefixed with: `BUILD-*`
+
+Generally the process is:
+```sh
+./autogen.sh
+./configure
+make
+```
+
+## Online Documentation
+Further user and developer documentation can be found [here](https://www.netify.ai/resources).
+
+## License
+This software is licenced under the [GPLv3](https://www.gnu.org/licenses/gpl-3.0.txt):
+>>>
+Copyright (C) 2015-2020 eGloo Incorporated
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+>>>
diff --git a/external/subpack/net/netifyd/files/netifyd.config b/external/subpack/net/netifyd/files/netifyd.config
new file mode 100644
index 0000000..49e1c23
--- /dev/null
+++ b/external/subpack/net/netifyd/files/netifyd.config
@@ -0,0 +1,5 @@
+config netifyd
+ option enabled 1
+ option autoconfig 1
+# option internal_if 'eth0'
+# option external_if 'eth1'
diff --git a/external/subpack/net/netifyd/files/netifyd.init b/external/subpack/net/netifyd/files/netifyd.init
new file mode 100644
index 0000000..1f7d931
--- /dev/null
+++ b/external/subpack/net/netifyd/files/netifyd.init
@@ -0,0 +1,46 @@
+#!/bin/sh /etc/rc.common
+#
+# Copyright (C) 2016-2019 eGloo, Incorporated
+#
+# This is free software, licensed under the GNU General Public License v2.
+
+START=50
+STOP=50
+
+USE_PROCD=1
+PROG=/usr/sbin/netifyd
+
+start_netifyd() {
+ local instance enabled autoconfig internal_if external_if
+
+ instance="$1"
+
+ config_get_bool enabled "$instance" enabled 0
+ [ "$enabled" -eq 0 ] && return 0
+
+ [ ! -d /var/run/netifyd ] && mkdir -p /var/run/netifyd
+
+ config_get_bool autoconfig "$instance" autoconfig 1
+
+ if [ "$autoconfig" -gt 0 ] ; then
+ source /usr/share/netifyd/functions.sh
+ load_modules
+ NETIFYD_AUTODETECT=yes
+ NETIFYD_OPTS=$(auto_detect_options)
+ else
+ config_get internal_if "$instance" internal_if "eth0"
+ config_get external_if "$instance" external_if "eth1"
+ NETIFYD_OPTS="-E $external_if -I $internal_if"
+ fi
+
+ procd_open_instance
+ procd_set_param command $PROG -R $NETIFYD_OPTS
+ procd_set_param file /etc/netifyd.conf
+ procd_set_param respawn
+ procd_close_instance
+}
+
+start_service() {
+ config_load netifyd
+ config_foreach start_netifyd netifyd
+}
diff --git a/external/subpack/net/netifyd/patches/010-reproducible.patch b/external/subpack/net/netifyd/patches/010-reproducible.patch
new file mode 100644
index 0000000..60486ad
--- /dev/null
+++ b/external/subpack/net/netifyd/patches/010-reproducible.patch
@@ -0,0 +1,11 @@
+--- a/src/netifyd.cpp
++++ b/src/netifyd.cpp
+@@ -144,7 +144,7 @@ static void nd_usage(int rc = 0, bool ve
+ {
+ fprintf(stderr, "%s\n", nd_get_version_and_features().c_str());
+ fprintf(stderr, "Copyright (C) 2015-2020 eGloo Incorporated\n"
+- "[%s %s]\n", GIT_RELEASE, GIT_DATE);
++ "[%s]\n", PACKAGE_VERSION);
+ if (version) {
+ fprintf(stderr, "\nThis application uses nDPI v%s\n"
+ "http://www.ntop.org/products/deep-packet-inspection/ndpi/\n", ndpi_revision());