new package: net-snmp

This commit is contained in:
Tee KOBAYASHI 2022-01-31 07:25:19 +09:00 committed by xtkoba
parent 7a8fb1b2b0
commit 1c0e8ce18d
13 changed files with 201 additions and 0 deletions

View File

@ -0,0 +1,11 @@
--- a/agent/mibgroup/host/data_access/swinst_apt.c
+++ b/agent/mibgroup/host/data_access/swinst_apt.c
@@ -42,7 +42,7 @@
void
netsnmp_swinst_arch_init(void)
{
- strlcpy(pkg_directory, "/var/lib/dpkg/info", sizeof(pkg_directory));
+ strlcpy(pkg_directory, "@TERMUX_PREFIX@/var/lib/dpkg/info", sizeof(pkg_directory));
snprintf(apt_fmt, SNMP_MAXBUF, "%%%d[^#]#%%%d[^#]#%%%d[^#]#%%%d[^#]#%%%d[^#]#%%%d[^#]#%%%ds",
SNMP_MAXBUF-1, SNMP_MAXBUF-1, SNMP_MAXBUF-1, SNMP_MAXBUF-1,
SNMP_MAXBUF-1, SNMP_MAXBUF-1, SNMP_MAXBUF-1);

View File

@ -0,0 +1,11 @@
--- a/agent/mibgroup/host/data_access/swinst_pkginfo.c
+++ b/agent/mibgroup/host/data_access/swinst_pkginfo.c
@@ -68,7 +68,7 @@
#elif defined(freebsd2) || defined(openbsd)
snprintf( pkg_directory, SNMP_MAXPATH, "/var/db/pkg" );
#elif defined(linux)
- snprintf( pkg_directory, SNMP_MAXPATH, "/var/cache/hrmib" );
+ snprintf( pkg_directory, SNMP_MAXPATH, "@TERMUX_PREFIX@/var/cache/hrmib" );
#else
pkg_directory[0] = '\0';
snmp_log( LOG_ERR, "SWInst: No package directory\n" );

View File

@ -0,0 +1,11 @@
--- a/agent/mibgroup/host/hr_filesys.c
+++ b/agent/mibgroup/host/hr_filesys.c
@@ -892,7 +892,7 @@
if (cp1 == NULL)
cp1 = filesys;
- if ((dump_fp = fopen("/etc/dumpdates", "r")) == NULL)
+ if ((dump_fp = fopen("@TERMUX_PREFIX@/etc/dumpdates", "r")) == NULL)
return date_n_time(NULL, length);
while (fgets(line, sizeof(line), dump_fp) != NULL) {

View File

@ -0,0 +1,11 @@
--- a/agent/mibgroup/host/hr_swinst.c
+++ b/agent/mibgroup/host/hr_swinst.c
@@ -193,7 +193,7 @@
#define _PATH_HRSW_directory "/var/db/pkg"
#endif
#if defined(linux) && !defined(HAVE_LIBRPM)
-#define _PATH_HRSW_directory "/var/cache/hrmib"
+#define _PATH_HRSW_directory "@TERMUX_PREFIX@/var/cache/hrmib"
#endif
void

View File

@ -0,0 +1,11 @@
--- a/agent/mibgroup/host/hrh_filesys.c
+++ b/agent/mibgroup/host/hrh_filesys.c
@@ -338,7 +338,7 @@
if (cp1 == NULL)
cp1 = filesys;
- if ((dump_fp = fopen("/etc/dumpdates", "r")) == NULL)
+ if ((dump_fp = fopen("@TERMUX_PREFIX@/etc/dumpdates", "r")) == NULL)
return date_n_time(NULL, length);
while (fgets(line, sizeof(line), dump_fp) != NULL) {

View File

@ -0,0 +1,13 @@
--- a/agent/mibgroup/if-mib/data_access/interface_linux.c
+++ b/agent/mibgroup/if-mib/data_access/interface_linux.c
@@ -10,6 +10,10 @@
#include <net-snmp/agent/snmp_vars.h>
#include "interface_private.h"
+#ifdef __ANDROID__
+typedef unsigned short ushort;
+#endif
+
netsnmp_feature_require(fd_event_manager);
netsnmp_feature_require(delete_prefix_info);
netsnmp_feature_require(create_prefix_info);

View File

@ -0,0 +1,13 @@
--- a/agent/mibgroup/ip-mib/data_access/ipaddress_linux.c
+++ b/agent/mibgroup/ip-mib/data_access/ipaddress_linux.c
@@ -21,6 +21,10 @@
#include <sys/ioctl.h>
#include <sys/stat.h>
+#ifdef __ANDROID__
+typedef unsigned long ulong;
+#endif
+
netsnmp_feature_require(prefix_info);
netsnmp_feature_require(find_prefix_info);

View File

@ -0,0 +1,10 @@
--- a/apps/encode_keychange.c
+++ b/apps/encode_keychange.c
@@ -95,6 +95,7 @@
int snmp_ttyecho(const int fd, const int echo);
char *snmp_getpassphrase(const char *prompt, int fvisible);
+#undef HAVE_GETPASS
#if defined(HAVE__CPUTS) && defined(HAVE__GETCH)
#include <conio.h>
#include <io.h>

View File

@ -0,0 +1,17 @@
--- a/apps/snmpnetstat/main.c
+++ b/apps/snmpnetstat/main.c
@@ -57,6 +57,14 @@
#include "winstub.h"
#endif
+#if defined __ANDROID__ && __ANDROID_API__ < 28
+#define getprotoent() (NULL)
+#define sethostent(s) ((void)0)
+#define setnetent(s) ((void)0)
+#define setprotoent(s) ((void)0)
+#define endprotoent() ((void)0)
+#endif
+
int aflag; /* show all sockets (including servers) */
int bflag; /* show bytes instead of packets */
int dflag; /* show i/f dropped packets */

View File

@ -0,0 +1,26 @@
TERMUX_PKG_HOMEPAGE=http://www.net-snmp.org/
TERMUX_PKG_DESCRIPTION="Various tools relating to the Simple Network Management Protocol"
# Licenses: HPND, BSD 3-Clause, MIT
TERMUX_PKG_LICENSE="custom"
TERMUX_PKG_LICENSE_FILE="COPYING"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=5.9.1
TERMUX_PKG_SRCURL=https://github.com/net-snmp/net-snmp/archive/refs/tags/v${TERMUX_PKG_VERSION}.tar.gz
TERMUX_PKG_SHA256=bdff5fe0915369971e4c7f8e43283fa5fdd08785c7d3b61431465562112d86e7
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
--with-agentx-socket=$TERMUX_PREFIX/var/agentx/master
--with-default-snmp-version=3
--with-logfile=$TERMUX_PREFIX/var/log/net-snmpd.log
--with-mnttab=$TERMUX_PREFIX/etc/mtab
--with-persistent-directory=$TERMUX_PREFIX/var/lib/net-snmp
--with-sys-contact=root@localhost
--with-sys-location=Unknown
--with-temp-file-pattern=$TERMUX_PREFIX/tmp/snmpdXXXXXX
ac_cv_path_LPSTAT_PATH=$TERMUX_PREFIX/bin/lpstat
"
termux_step_pre_configure() {
if [ $TERMUX_ARCH = "x86_64" ]; then
CPPFLAGS+=" -DOPENSSL_NO_INLINE_ASM"
fi
}

View File

@ -0,0 +1,41 @@
--- a/config.sub
+++ b/config.sub
@@ -247,10 +247,11 @@
# Some are omitted here because they have special meanings below.
1750a | 580 \
| a29k \
+ | aarch64 \
| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
| am33_2.0 \
- | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
+ | arc | arm | arm[bl]e | arme[lb] | armv* | avr | avr32 \
| bfin \
| c4x | clipper \
| d10v | d30v | dlx | dsp16xx \
@@ -301,7 +302,7 @@
| ubicom32 \
| v850 | v850e \
| we32k \
- | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
+ | x86 | x86_64 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
| z8k | z80)
basic_machine=$basic_machine-unknown
;;
@@ -339,6 +340,7 @@
# Recognize the basic CPU types with company name.
580-* \
| a29k-* \
+ | aarch64-* \
| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
@@ -1300,7 +1302,7 @@
# The portable systems comes first.
# Each alternative MUST END IN A *, to match a version number.
# -sysv* is not here because it comes later, after sysvr4.
- -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
+ -gnu* | -android* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
| -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
| -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
| -sym* | -kopensolaris* \

View File

@ -0,0 +1,13 @@
--- a/include/net-snmp/library/types.h
+++ b/include/net-snmp/library/types.h
@@ -6,6 +6,10 @@
#endif
+#ifdef __ANDROID__
+#include <sys/select.h>
+#endif
+
#include <net-snmp/types.h>

View File

@ -0,0 +1,13 @@
--- a/include/net-snmp/session_api.h
+++ b/include/net-snmp/session_api.h
@@ -17,6 +17,10 @@
* including sending and receiving requests.
*/
+#ifdef __ANDROID__
+#include <sys/select.h>
+#endif
+
#include <net-snmp/types.h>
#ifdef __cplusplus