mirror of https://github.com/OpenIPC/firmware.git
Preparing mini-snmpd-openipc for migration
parent
68e8382169
commit
7aa944eb74
|
@ -0,0 +1,31 @@
|
|||
From 949ae648bf7c654b8fae607a0988bfa672607156 Mon Sep 17 00:00:00 2001
|
||||
From: Patrick Rauscher <prauscher@prauscher.de>
|
||||
Date: Fri, 18 Aug 2017 17:31:23 +0200
|
||||
Subject: [PATCH] Prepend zero-byte before unsigned integers
|
||||
|
||||
fixes #8
|
||||
|
||||
Signed-off-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
|
||||
---
|
||||
mib.c | 5 +++++
|
||||
1 file changed, 5 insertions(+)
|
||||
|
||||
diff --git a/mib.c b/mib.c
|
||||
index 7d2e513..a9ffbe2 100644
|
||||
--- a/mib.c
|
||||
+++ b/mib.c
|
||||
@@ -207,6 +207,11 @@ static int encode_unsigned(data_t *data, int type, unsigned int ticks_value)
|
||||
else
|
||||
length = 1;
|
||||
|
||||
+ /* check if the integer could be interpreted negative during a signed decode and prepend a zero-byte if necessary */
|
||||
+ if ((ticks_value >> (8 * (length - 1))) & 0x80) {
|
||||
+ length++;
|
||||
+ }
|
||||
+
|
||||
*buffer++ = type;
|
||||
*buffer++ = length;
|
||||
while (length--)
|
||||
--
|
||||
2.13.2
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
From 556c8a406c9e08dd9444222e072f7eb9c82a81e8 Mon Sep 17 00:00:00 2001
|
||||
From: Patrick Rauscher <prauscher@prauscher.de>
|
||||
Date: Fri, 18 Aug 2017 17:44:32 +0200
|
||||
Subject: [PATCH] mib.c: allow unsigned integers to have an extra byte
|
||||
|
||||
The extra byte can be needed when encoding huge unsigned numbers (i.e. 0x80000000 or higher). In this case, during encoding we need an extra byte to make sure clients decoding as signed int do not get negative numbers. For further details, see commit 949ae648
|
||||
|
||||
Signed-off-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
|
||||
---
|
||||
mib.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/mib.c b/mib.c
|
||||
index a9ffbe2..83cc20d 100644
|
||||
--- a/mib.c
|
||||
+++ b/mib.c
|
||||
@@ -372,7 +372,7 @@ static int data_alloc(data_t *data, int type)
|
||||
case BER_TYPE_COUNTER:
|
||||
case BER_TYPE_GAUGE:
|
||||
case BER_TYPE_TIME_TICKS:
|
||||
- data->max_length = sizeof(unsigned int) + 2;
|
||||
+ data->max_length = sizeof(unsigned int) + 3;
|
||||
data->encoded_length = 0;
|
||||
data->buffer = allocate(data->max_length);
|
||||
break;
|
||||
--
|
||||
2.13.2
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
config BR2_PACKAGE_MINI_SNMPD_OPENIPC
|
||||
bool "mini-snmpd-openipc"
|
||||
help
|
||||
Mini SNMPd is a minimal implementation targeted at small or
|
||||
embedded UNIX systems with limited resources
|
||||
|
||||
http://troglobit.com/mini-snmpd.html
|
|
@ -0,0 +1,57 @@
|
|||
#!/bin/sh
|
||||
|
||||
DAEMON="mini-snmpd"
|
||||
PIDFILE="/var/run/$DAEMON.pid"
|
||||
|
||||
SNMPD_ARGS="-n -4 -c openipc -i eth0 -D OpenIPC -C https://openipc.org -L Internet -l notice"
|
||||
|
||||
# shellcheck source=/dev/null
|
||||
[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON"
|
||||
|
||||
# The mini-snmpd does not create a pidfile, so pass "-n" in the command line
|
||||
# and use "-m" to instruct start-stop-daemon to create one.
|
||||
start() {
|
||||
printf 'Starting %s: ' "$DAEMON"
|
||||
[ -f /usr/sbin/$DAEMON ] || echo -en "DISABLED, "
|
||||
# shellcheck disable=SC2086 # we need the word splitting
|
||||
start-stop-daemon -b -m -S -q -p "$PIDFILE" -x "/usr/sbin/$DAEMON" \
|
||||
-- $SNMPD_ARGS
|
||||
status=$?
|
||||
if [ "$status" -eq 0 ]; then
|
||||
echo "OK"
|
||||
else
|
||||
echo "FAIL"
|
||||
fi
|
||||
return "$status"
|
||||
}
|
||||
|
||||
stop() {
|
||||
printf 'Stopping %s: ' "$DAEMON"
|
||||
[ -f /usr/sbin/$DAEMON ] || echo -en "DISABLED, "
|
||||
start-stop-daemon -K -q -p "$PIDFILE"
|
||||
status=$?
|
||||
if [ "$status" -eq 0 ]; then
|
||||
rm -f "$PIDFILE"
|
||||
echo "OK"
|
||||
else
|
||||
echo "FAIL"
|
||||
fi
|
||||
return "$status"
|
||||
}
|
||||
|
||||
restart() {
|
||||
stop
|
||||
sleep 1
|
||||
start
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start|stop|restart)
|
||||
"$1";;
|
||||
reload)
|
||||
# Restart, since there is no true "reload" feature.
|
||||
restart;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart|reload}"
|
||||
exit 1
|
||||
esac
|
|
@ -0,0 +1,20 @@
|
|||
################################################################################
|
||||
#
|
||||
# mini-snmpd-openipc
|
||||
#
|
||||
################################################################################
|
||||
|
||||
MINI_SNMPD_OPENIPC_VERSION = 1.4
|
||||
MINI_SNMPD_OPENIPC_SITE = $(call github,troglobit,mini-snmpd,v$(MINI_SNMPD_OPENIPC_VERSION))
|
||||
MINI_SNMPD_OPENIPC_LICENSE = GPL-2.0
|
||||
MINI_SNMPD_OPENIPC_LICENSE_FILES = COPYING
|
||||
MINI_SNMPD_OPENIPC_AUTORECONF = YES
|
||||
|
||||
define MINI_SNMPD_OPENIPC_INSTALL_TARGET_CMDS
|
||||
|
||||
$(INSTALL) -m 755 -d $(TARGET_DIR)/etc/init.d
|
||||
cp ../general/package/mini-snmpd-openipc/files/S50snmpd $(TARGET_DIR)/etc/init.d
|
||||
|
||||
endef
|
||||
|
||||
$(eval $(autotools-package))
|
Loading…
Reference in New Issue