Browse Source

Merge pull request #78 from rvandegrift/master

net/softflowd: import from packages and update to latest version
Hauke Mehrtens 10 years ago
parent
commit
5286c9487f
3 changed files with 142 additions and 0 deletions
  1. 54
    0
      net/softflowd/Makefile
  2. 14
    0
      net/softflowd/files/softflowd.config
  3. 74
    0
      net/softflowd/files/softflowd.init

+ 54
- 0
net/softflowd/Makefile View File

@@ -0,0 +1,54 @@
1
+#
2
+# Copyright (C) 2007-2011 OpenWrt.org
3
+#
4
+# This is free software, licensed under the GNU General Public License v2.
5
+# See /LICENSE for more information.
6
+#
7
+
8
+include $(TOPDIR)/rules.mk
9
+
10
+PKG_NAME:=softflowd
11
+PKG_VERSION:=0.9.9
12
+PKG_RELEASE:=1
13
+
14
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
15
+PKG_SOURCE_URL:=http://softflowd.googlecode.com/files/
16
+PKG_MD5SUM:=ba83e2715e6250e6645ebcaa9ae1009d
17
+PKG_MAINTAINER:=Ross Vandegrift <ross@kallisti.us>
18
+PKG_LICENSE:=BSD-3-Clause
19
+
20
+PKG_FIXUP:=autoreconf
21
+
22
+include $(INCLUDE_DIR)/package.mk
23
+
24
+define Package/softflowd
25
+  SECTION:=net
26
+  CATEGORY:=Network
27
+  DEPENDS:=+libpcap
28
+  TITLE:=softflowd
29
+  URL:=http://code.google.com/p/softflowd/
30
+endef
31
+
32
+define Package/softflowd/description
33
+	Software netflow exporter
34
+endef
35
+
36
+define Build/Compile
37
+	$(MAKE) -C $(PKG_BUILD_DIR) DESTDIR="$(PKG_INSTALL_DIR)" softflowd softflowctl
38
+endef
39
+
40
+define Package/softflowd/install
41
+	$(INSTALL_DIR) $(1)/usr/sbin
42
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/softflowd $(1)/usr/sbin/
43
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/softflowctl $(1)/usr/sbin/
44
+	$(INSTALL_DIR) $(1)/etc/config
45
+	$(INSTALL_DATA) ./files/$(PKG_NAME).config $(1)/etc/config/$(PKG_NAME)
46
+	$(INSTALL_DIR) $(1)/etc/init.d
47
+	$(INSTALL_BIN) ./files/$(PKG_NAME).init $(1)/etc/init.d/$(PKG_NAME)
48
+endef
49
+
50
+define Package/softflowd/conffiles
51
+/etc/config/softflowd
52
+endef
53
+
54
+$(eval $(call BuildPackage,softflowd))

+ 14
- 0
net/softflowd/files/softflowd.config View File

@@ -0,0 +1,14 @@
1
+config softflowd
2
+	option enabled        '0'
3
+	option interface      'br-lan'
4
+	option pcap_file      ''
5
+	option timeout        ''
6
+	option max_flows      '8192'
7
+	option host_port      ''
8
+	option pid_file       '/var/run/softflowd.pid'
9
+	option control_socket '/var/run/softflowd.ctl'
10
+	option export_version '5'
11
+	option hoplimit       ''
12
+	option tracking_level 'full'
13
+	option track_ipv6     '0'
14
+	option sampling_rate  '100'

+ 74
- 0
net/softflowd/files/softflowd.init View File

@@ -0,0 +1,74 @@
1
+#!/bin/sh /etc/rc.common
2
+# Copyright (C) 2007-2011 OpenWrt.org
3
+
4
+START=50
5
+
6
+append_bool() {
7
+	local section="$1"
8
+	local option="$2"
9
+	local value="$3"
10
+	local _val
11
+	config_get_bool _val "$section" "$option" '0'
12
+	[ "$_val" -gt 0 ] && append args "$3"
13
+}
14
+
15
+append_string() {
16
+	local section="$1"
17
+	local option="$2"
18
+	local value="$3"
19
+	local _val
20
+	config_get _val "$section" "$option"
21
+	[ -n "$_val" ] && append args "$3 $_val"
22
+}
23
+
24
+start_instance() {
25
+	local section="$1"
26
+
27
+	config_get_bool enabled "$section" 'enabled' '0'
28
+	[ $enabled -gt 0 ] || return 1
29
+
30
+	config_get pid_file "$section" 'pid_file'
31
+
32
+	args=""
33
+	append_string "$section" 'interface' '-i'
34
+	append_string "$section" 'pcap_file' '-r'
35
+	append_string "$section" 'timeout' '-t'
36
+	append_string "$section" 'max_flows' '-m'
37
+	append_string "$section" 'host_port' '-n'
38
+	append_string "$section" 'pid_file' '-p'
39
+	append_string "$section" 'control_socket' '-c'
40
+	append_string "$section" 'export_version' '-v'
41
+	append_string "$section" 'hoplimit' '-L'
42
+	append_string "$section" 'tracking_level' '-T'
43
+	append_string "$section" 'sampling_rate' '-s'
44
+	append_bool "$section" track_ipv6 '-6'
45
+
46
+	SERVICE_PID_FILE="$pid_file" \
47
+	service_start /usr/sbin/softflowd $args${pid_file:+ -p $pid_file}
48
+}
49
+
50
+stop_instance() {
51
+	local section="$1"
52
+
53
+	config_get_bool enabled "$section" 'enabled' '0'
54
+	[ $enabled -gt 0 ] || return 1
55
+
56
+	config_get control_socket "$section" 'control_socket'
57
+
58
+	[ -n "control_socket" -a -S $control_socket ] && {
59
+		/usr/sbin/softflowctl -c $control_socket exit
60
+	}
61
+}
62
+
63
+start() {
64
+	mkdir -m 0755 -p /var/empty
65
+
66
+	config_load 'softflowd'
67
+	config_foreach start_instance 'softflowd'
68
+}
69
+
70
+stop() {
71
+	config_load 'softflowd'
72
+	config_foreach stop_instance 'softflowd'
73
+	service_stop /usr/sbin/softflowd
74
+}