From 0318938558d13bfaa0e333fbd95ed1974b40d44d Mon Sep 17 00:00:00 2001 From: acoul Date: Thu, 15 Apr 2010 21:11:06 +0000 Subject: [PATCH] fix mini_snmpd on ipv4. Create a separate mini_snmpd_ipv6 package (closes #6578 & #7094) git-svn-id: svn://svn.openwrt.org/openwrt/packages@20889 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- net/mini_snmpd_ipv6/Makefile | 48 ++++++++++++++++++++++ net/mini_snmpd_ipv6/files/mini_snmpd.config | 7 ++++ net/mini_snmpd_ipv6/files/mini_snmpd.init | 38 +++++++++++++++++ net/mini_snmpd_ipv6/patches/101-opt_flags.patch | 13 ++++++ net/mini_snmpd_ipv6/patches/102-compile_fix.patch | 31 ++++++++++++++ .../103-mib_encode_snmp_element_oid_fix.patch | 21 ++++++++++ .../patches/104-ipv6-support.patch | 0 7 files changed, 158 insertions(+) create mode 100644 net/mini_snmpd_ipv6/Makefile create mode 100644 net/mini_snmpd_ipv6/files/mini_snmpd.config create mode 100644 net/mini_snmpd_ipv6/files/mini_snmpd.init create mode 100644 net/mini_snmpd_ipv6/patches/101-opt_flags.patch create mode 100644 net/mini_snmpd_ipv6/patches/102-compile_fix.patch create mode 100644 net/mini_snmpd_ipv6/patches/103-mib_encode_snmp_element_oid_fix.patch rename net/{mini_snmpd => mini_snmpd_ipv6}/patches/104-ipv6-support.patch (100%) diff --git a/net/mini_snmpd_ipv6/Makefile b/net/mini_snmpd_ipv6/Makefile new file mode 100644 index 000000000..972433af4 --- /dev/null +++ b/net/mini_snmpd_ipv6/Makefile @@ -0,0 +1,48 @@ +# +# Copyright (C) 2009 OpenWrt.orgv +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=mini_snmpd +PKG_VERSION:=1.0 +PKG_RELEASE:=5 + +PKG_SOURCE:=mini_snmpd.tar.gz +PKG_SOURCE_URL:=http://members.aon.at/linuxfreak/linux/ +PKG_MD5SUM:=13f2202ff01ff6b6463989f34f453063 + +PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) + +include $(INCLUDE_DIR)/package.mk + +define Package/mini-snmpd + SECTION:=net + CATEGORY:=Network + TITLE:=SNMP server for embedded systems + URL:=http://members.aon.at/linuxfreak/linux/mini_snmpd.html +endef + + +define Build/Compile + $(MAKE) -C $(PKG_BUILD_DIR) \ + CC="$(TARGET_CC)" \ + OFLAGS="$(TARGET_CFLAGS) -DSYSLOG" \ + STRIP="/bin/true" \ + INSTALL_ROOT="$(PKG_INSTALL_DIR)" \ + mini_snmpd install +endef + +define Package/mini-snmpd/install + $(INSTALL_DIR) $(1)/usr/bin + $(CP) $(PKG_INSTALL_DIR)/sbin/mini_snmpd $(1)/usr/bin/ + $(INSTALL_DIR) $(1)/etc/config + $(INSTALL_CONF) ./files/mini_snmpd.config $(1)/etc/config/mini_snmpd + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/mini_snmpd.init $(1)/etc/init.d/mini_snmpd +endef + +$(eval $(call BuildPackage,mini-snmpd)) diff --git a/net/mini_snmpd_ipv6/files/mini_snmpd.config b/net/mini_snmpd_ipv6/files/mini_snmpd.config new file mode 100644 index 000000000..352ac283b --- /dev/null +++ b/net/mini_snmpd_ipv6/files/mini_snmpd.config @@ -0,0 +1,7 @@ +config mini_snmpd + option enabled 1 + option community public + option location '' + option contact '' + option disks '/tmp,/jffs' + option interfaces 'lo,br-lan,eth0.1,eth1' # Max 4 diff --git a/net/mini_snmpd_ipv6/files/mini_snmpd.init b/net/mini_snmpd_ipv6/files/mini_snmpd.init new file mode 100644 index 000000000..5d7cb7685 --- /dev/null +++ b/net/mini_snmpd_ipv6/files/mini_snmpd.init @@ -0,0 +1,38 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2009 OpenWrt.org + +NAME=mini_snmpd +PROG=/usr/bin/$NAME +START=50 + +append_string() { + local section="$1" + local option="$2" + local value="$3" + local _val + config_get _val "$section" "$option" + [ -n "$_val" ] && append args "$3 $_val" +} + +mini_snmpd_config() { + local cfg="$1" + args="" + + append_string "$cfg" community "-c" + append_string "$cfg" location "-L" + append_string "$cfg" contact "-C" + append_string "$cfg" disks "-d" + append_string "$cfg" interfaces "-i" + + config_get_bool enabled "$cfg" "enabled" '1'c + [ "$enabled" -gt 0 ] && $PROG $args & +} + +start() { + config_load mini_snmpd + config_foreach mini_snmpd_config mini_snmpd +} + +stop() { + killall mini_snmpd +} diff --git a/net/mini_snmpd_ipv6/patches/101-opt_flags.patch b/net/mini_snmpd_ipv6/patches/101-opt_flags.patch new file mode 100644 index 000000000..b34852f16 --- /dev/null +++ b/net/mini_snmpd_ipv6/patches/101-opt_flags.patch @@ -0,0 +1,13 @@ +--- a/Makefile ++++ b/Makefile +@@ -30,8 +30,9 @@ HEADERS = mini_snmpd.h + SOURCES = mini_snmpd.c protocol.c mib.c globals.c utils.c linux.c freebsd.c + VERSION = 1.0 + VENDOR = .1.3.6.1.4.1 ++OFLAGS = -O2 -DDEBUG + CFLAGS = -Wall -Werror -DVERSION="\"$(VERSION)\"" -DVENDOR="\"$(VENDOR)\"" \ +- -O2 -DDEBUG -D__LINUX__ -D__DEMO__ ++ $(OFLAGS) -D__LINUX__ -D__DEMO__ + TARGET = mini_snmpd + MAN = mini_snmpd.8 + DOC = CHANGELOG COPYING README TODO diff --git a/net/mini_snmpd_ipv6/patches/102-compile_fix.patch b/net/mini_snmpd_ipv6/patches/102-compile_fix.patch new file mode 100644 index 000000000..f6ece3e9c --- /dev/null +++ b/net/mini_snmpd_ipv6/patches/102-compile_fix.patch @@ -0,0 +1,31 @@ +--- a/mini_snmpd.c ++++ b/mini_snmpd.c +@@ -134,7 +134,7 @@ + } else if (rv != g_udp_client.size) { + lprintf(LOG_WARNING, "could not send packet to UDP client %s:%d: " + "only %d of %d bytes written\n", inet_ntoa(sockaddr.sin_addr), +- sockaddr.sin_port, rv, g_udp_client.size); ++ sockaddr.sin_port, rv, (int) g_udp_client.size); + } + #ifdef DEBUG + dump_packet(&g_udp_client); +@@ -211,7 +211,7 @@ + } else if (rv != client->size) { + lprintf(LOG_WARNING, "could not send packet to TCP client %s:%d: " + "only %d of %d bytes written\n", inet_ntoa(sockaddr.sin_addr), +- sockaddr.sin_port, rv, client->size); ++ sockaddr.sin_port, rv, (int) client->size); + close(client->sockfd); + client->sockfd = -1; + return; +--- a/utils.c ++++ b/utils.c +@@ -106,7 +106,7 @@ + } + } + lprintf(LOG_DEBUG, "%s %u bytes %s %s:%d (%s)\n", +- client->outgoing ? "transmitted" : "received", client->size, ++ client->outgoing ? "transmitted" : "received", (int) client->size, + client->outgoing ? "to" : "from", inet_ntoa(client_addr), + ntohs(client->port), buffer); + } diff --git a/net/mini_snmpd_ipv6/patches/103-mib_encode_snmp_element_oid_fix.patch b/net/mini_snmpd_ipv6/patches/103-mib_encode_snmp_element_oid_fix.patch new file mode 100644 index 000000000..a46ace24e --- /dev/null +++ b/net/mini_snmpd_ipv6/patches/103-mib_encode_snmp_element_oid_fix.patch @@ -0,0 +1,21 @@ +--- a/mib.c ++++ b/mib.c +@@ -120,6 +120,9 @@ static int encode_snmp_element_oid(value + int length; + int i; + ++ if (oid_value == NULL) { ++ return -1; ++ } + buffer = value->data.buffer; + length = 1; + for (i = 2; i < oid_value->subid_list_length; i++) { +@@ -293,6 +296,8 @@ static int mib_build_entry(const oid_t * + value->data.encoded_length = 0; + value->data.buffer = malloc(value->data.max_length); + if (encode_snmp_element_oid(value, oid_aton((const char *)default_value)) == -1) { ++ lprintf(LOG_ERR, "could not create MIB entry '%s.%d.%d': invalid oid '%s'\n", ++ oid_ntoa(prefix), column, row, (char *)default_value); + return -1; + } + break; diff --git a/net/mini_snmpd/patches/104-ipv6-support.patch b/net/mini_snmpd_ipv6/patches/104-ipv6-support.patch similarity index 100% rename from net/mini_snmpd/patches/104-ipv6-support.patch rename to net/mini_snmpd_ipv6/patches/104-ipv6-support.patch -- 2.11.0