1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-12-03 01:23:49 +00:00
This is a mini-SNMP daemon. The basic daemon implements the system group
and a number of private extensions to manage the UDP transport mapping,
communities, trap destinations and loadable modules. In this form it can
be used to provide remote access to arbitrary data that can be described in
the form as required by the SMI. The daemon speaks both SNMPv1 and SNMPv2c.

PR:		86400
Submitted by:	Andrey V. Elsukov <bu7cher@yandex.ru>
Approved by:	pav (mentor)
This commit is contained in:
Marcus Alves Grando 2005-09-27 17:32:27 +00:00
parent 0960e2f2f5
commit ebb76bfcdb
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=143637
21 changed files with 448 additions and 0 deletions

View File

@ -25,6 +25,7 @@
SUBDIR += bpft
SUBDIR += braa
SUBDIR += bsd-airtools
SUBDIR += bsnmpd
SUBDIR += cdpd
SUBDIR += cdpr
SUBDIR += cfgstoragemk

49
net-mgmt/bsnmpd/Makefile Normal file
View File

@ -0,0 +1,49 @@
# New ports collection makefile for: bsnmpd
# Date created: Sep 22 2005
# Whom: Andrey V. Elsukov <bu7cher@yandex.ru>
#
# $FreeBSD$
#
PORTNAME= bsnmpd
PORTVERSION= 1.10
CATEGORIES= net-mgmt
MASTER_SITES= http://people.freebsd.org/~harti/bsnmp/
DISTNAME= bsnmp-${PORTVERSION}
MAINTAINER= bu7cher@yandex.ru
COMMENT= A mini-SNMP daemon
LIB_DEPENDS= begemot.1:${PORTSDIR}/devel/libbegemot \
smi.2:${PORTSDIR}/net-mgmt/libsmi
USE_GMAKE= yes
GNU_CONFIGURE= yes
CONFIGURE_ARGS= --with-libbegemot=${LOCALBASE}
USE_AUTOCONF_VER= 259
USE_AUTOMAKE_VER= 19
INSTALLS_SHLIB= yes
USE_GCC= 3.2+
USE_RC_SUBR= bsnmpd.sh
MAN1= bsnmpd.1 gensnmpdef.1 gensnmptree.1
MAN3= asn1.3 bsnmplib.3 bsnmpclient.3 bsnmpagent.3 snmpmod.3 \
snmp_mibII.3
.include <bsd.port.pre.mk>
.if ${OSVERSION} > 600000
IGNORE= bsnmpd already in base system
.endif
#run-autotools:
# @(cd ${CONFIGURE_WRKSRC} && ${LOCALBASE}/bin/aclocal19 )
# @(cd ${CONFIGURE_WRKSRC} && ${LOCALBASE}/bin/autoconf259 )
post-install:
@${MKDIR} ${PREFIX}/etc
@${INSTALL_DATA} ${BUILD_WRKSRC}/snmpd/snmpd.config ${PREFIX}/etc/snmpd.config.example
.include <bsd.port.post.mk>

2
net-mgmt/bsnmpd/distinfo Normal file
View File

@ -0,0 +1,2 @@
MD5 (bsnmp-1.10.tar.gz) = d0d8d538639c899eb3e8602876bd28be
SIZE (bsnmp-1.10.tar.gz) = 451797

View File

@ -0,0 +1,20 @@
#!/bin/sh
# $FreeBSD$
#
# PROVIDE: bsnmpd
# REQUIRE: NETWORKING syslogd
# KEYWORD: nojail
bsnmpd_enable="NO"
. %%RC_SUBR%%
name="bsnmpd"
rcvar=`set_rcvar`
required_files="%%PREFIX%%/etc/snmpd.config"
pidfile="/var/run/bsnmpd.pid"
command_args="-c ${required_files} -p ${pidfile}"
command="%%PREFIX%%/sbin/${name}"
load_rc_config $name
run_rc_command "$1"

View File

@ -0,0 +1,67 @@
--- config/Makefile.post.orig Thu Sep 22 08:33:16 2005
+++ config/Makefile.post Thu Sep 22 08:37:05 2005
@@ -31,7 +31,7 @@
install-man1:
@$(srcdir)/../config/mkinstalldirs $(mandir)/man1
for f in $(MAN1) ; do \
- $(INSTALL_DATA) $${f}out $(mandir)/man1/$${f} ; \
+ $(BSD_INSTALL_MAN) $${f}out $(mandir)/man1/$${f} ; \
done
%.1out: %.1
@@ -48,7 +48,7 @@
install-man3:
@$(srcdir)/../config/mkinstalldirs $(mandir)/man3
for f in $(MAN3) ; do \
- $(INSTALL_DATA) $${f}out $(mandir)/man3/$${f} ; \
+ $(BSD_INSTALL_MAN) $${f}out $(mandir)/man3/$${f} ; \
done
%.3out: %.3
@@ -61,7 +61,7 @@
ifneq "$(DEFS)" ""
install-defs:
@$(srcdir)/../config/mkinstalldirs $(DEFSDIR)
- $(INSTALL_DATA) $(DEFS:%=$(srcdir)/%) $(DEFSDIR)
+ $(BSD_INSTALL_DATA) $(DEFS:%=$(srcdir)/%) $(DEFSDIR)
DEFSDIR= ${datadir}/snmp/defs
@@ -76,7 +76,7 @@
install-incs:
@$(srcdir)/../config/mkinstalldirs $(INCDIR)
for f in $(INCS) ; do \
- $(INSTALL_DATA) $(srcdir)/$$f $(INCDIR) ; \
+ $(BSD_INSTALL_DATA) $(srcdir)/$$f $(INCDIR) ; \
done
else
@@ -90,7 +90,7 @@
install-mibs:
@$(srcdir)/../config/mkinstalldirs $(BMIBSDIR)
for f in $(BMIBS) ; do \
- $(INSTALL_DATA) $(srcdir)/$$f $(BMIBSDIR) ; \
+ $(BSD_INSTALL_DATA) $(srcdir)/$$f $(BMIBSDIR) ; \
done
else
@@ -101,8 +101,8 @@
build-prog: $(PROG)
install-prog:
- @$(srcdir)/../config/mkinstalldirs $(bindir)
- $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $(builddir)/$(PROG) $(bindir)/$(PROG)
+ @$(srcdir)/../config/mkinstalldirs $(sbindir)
+ $(LIBTOOL) --mode=install $(BSD_INSTALL_PROGRAM) $(builddir)/$(PROG) $(sbindir)/$(PROG)
else
build-prog:
@@ -114,7 +114,7 @@
install-lib:
@$(srcdir)/../config/mkinstalldirs $(libdir)
- $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $(LIB) $(libdir)
+ $(LIBTOOL) --mode=install $(BSD_INSTALL_DATA) $(LIB) $(libdir)
else
build-lib:

View File

@ -0,0 +1,19 @@
--- config/Makefile.pre.orig Mon Sep 19 22:07:05 2005
+++ config/Makefile.pre Mon Sep 19 22:09:02 2005
@@ -17,6 +17,7 @@
prefix= @prefix@
exec_prefix= @exec_prefix@
bindir= @bindir@
+sbindir= @sbindir@
libdir= @libdir@
includedir= @includedir@
mandir= @mandir@
@@ -34,7 +35,7 @@
LIBEV= @LIBEV@
-SUBMAKE= $(MAKE) -$(MAKEFLAGS) --no-print-directory
+SUBMAKE= $(MAKE) $(MAKEFLAGS) --no-print-directory
WARNS= -Wsystem-headers -Werror -Wall -Wno-format-y2k -W \
-Wstrict-prototypes -Wmissing-prototypes \

View File

@ -0,0 +1,53 @@
--- configure.ac.orig Mon Apr 25 15:49:28 2005
+++ configure.ac Thu Sep 22 08:53:11 2005
@@ -75,6 +75,50 @@
# check for getaddrinfo
AC_CHECK_FUNCS(getaddrinfo)
+AC_CHECK_HEADER(stdint.h,
+ AC_DEFINE(HAVE_STDINT_H))
+AC_CHECK_HEADER(inttypes.h,
+ [AC_DEFINE(HAVE_INTTYPES_H)
+ ac_have_inttypes_h=yes])
+AC_CACHE_CHECK([how to print quads],
+ ac_cv_quad_fmt,
+ [if test "$ac_have_inttypes_h" = "yes" ; then
+ AC_EGREP_CPP(yes,
+[
+# include <inttypes.h>
+# ifdef PRIu64
+yes
+# endif
+],
+ ac_cv_quad_fmt=PRIu64,
+ AC_TRY_RUN(
+[[
+# include <stdio.h>
+# include <stdlib.h>
+# include <string.h>
+int
+main()
+{
+ char buf[100];
+
+ sprintf(buf, "%llx", 0x1234567887654321LLU);
+ exit((strcmp(buf, "1234567887654321") == 0) ? 0 : 1);
+}
+]],
+ ac_cv_quad_fmt='"ll"',
+ ac_cv_quad_fmt='"q"',
+ ac_cv_quad_fmt='"q"')
+ fi ]))
+
+if test "$ac_cv_quad_fmt" = "PRIu64" ; then
+ AC_DEFINE(QUADFMT, PRIu64)
+ AC_DEFINE(QUADXFMT, PRIx64)
+else
+ AC_DEFINE_UNQUOTED(QUADFMT, ${ac_cv_quad_fmt}"u")
+ AC_DEFINE_UNQUOTED(QUADXFMT, ${ac_cv_quad_fmt}"x")
+fi
+
+
AC_CONFIG_FILES([
Makefile:config/Makefile.pre:Makefile.in
lib/Makefile:config/Makefile.pre:config/Makefile.build:lib/Makefile.in:config/Makefile.post

View File

@ -0,0 +1,12 @@
--- gensnmptree/gensnmptree.c.orig Thu Sep 22 08:58:15 2005
+++ gensnmptree/gensnmptree.c Thu Sep 22 08:59:03 2005
@@ -595,7 +595,9 @@
fprintf(fp, "#include <sys/types.h>\n");
fprintf(fp, "#include <stdio.h>\n");
+#ifdef HAVE_STDINT_H
fprintf(fp, "#include <stdint.h>\n");
+#endif
if (localincs) {
fprintf(fp, "#include \"asn1.h\"\n");
fprintf(fp, "#include \"snmp.h\"\n");

View File

@ -0,0 +1,14 @@
--- lib/asn1.c.orig Thu Sep 22 09:02:07 2005
+++ lib/asn1.c Thu Sep 22 09:03:46 2005
@@ -35,7 +35,11 @@
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
+#ifdef HAVE_STDINT_H
#include <stdint.h>
+#elif defined(HAVE_INTTYPES_H)
+#include <inttypes.h>
+#endif
#include <assert.h>
#include "asn1.h"

View File

@ -0,0 +1,13 @@
--- lib/asn1.h.orig Tue Dec 2 18:52:37 2003
+++ lib/asn1.h Wed Sep 21 09:53:04 2005
@@ -183,4 +183,10 @@
ASN_EXCEPT_ENDOFMIBVIEW = 0x02,
};
+#if !defined(__STDC_LIMIT_MACROS)
+#define INT32_MIN (-0x7fffffff-1)
+#define INT32_MAX 0x7fffffff
+#define UINT32_MAX 0xffffffffU
+#endif
+
#endif

View File

@ -0,0 +1,14 @@
--- lib/snmp.c.orig Fri Sep 23 08:48:16 2005
+++ lib/snmp.c Fri Sep 23 08:47:34 2005
@@ -36,7 +36,11 @@
#include <stdlib.h>
#include <stddef.h>
#include <stdarg.h>
+#ifdef HAVE_STDINT_H
#include <stdint.h>
+#elif defined(HAVE_INTTYPES_H)
+#include <inttypes.h>
+#endif
#include <string.h>
#include <ctype.h>
#include <netdb.h>

View File

@ -0,0 +1,14 @@
--- lib/snmpagent.c.orig Thu Sep 22 09:06:25 2005
+++ lib/snmpagent.c Thu Sep 22 09:07:19 2005
@@ -36,7 +36,11 @@
#include <stdlib.h>
#include <stddef.h>
#include <stdarg.h>
+#ifdef HAVE_STDINT_H
#include <stdint.h>
+#elif defined(HAVE_INTTYPES_H)
+#include <inttypes.h>
+#endif
#include <string.h>
#include "asn1.h"

View File

@ -0,0 +1,14 @@
--- lib/snmpclient.c.orig Thu Sep 22 09:07:57 2005
+++ lib/snmpclient.c Thu Sep 22 09:08:38 2005
@@ -48,7 +48,11 @@
#include <unistd.h>
#include <fcntl.h>
#include <netdb.h>
+#ifdef HAVE_STDINT_H
#include <stdint.h>
+#elif defined(HAVE_INTTYPES_H)
+#include <inttypes.h>
+#endif
#include <limits.h>
#ifdef HAVE_ERR_H
#include <err.h>

View File

@ -0,0 +1,15 @@
--- snmp_mibII/mibII_ipaddr.c.orig Wed Sep 21 12:21:53 2005
+++ snmp_mibII/mibII_ipaddr.c Wed Sep 21 12:18:56 2005
@@ -88,8 +88,10 @@
}
bcast.s_addr = upd->addr.s_addr & upd->mask.s_addr;
- if (!(upd->set & UPD_BCAST) || upd->bcast)
- bcast.s_addr |= htonl(0xffffffff & ~ntohl(upd->mask.s_addr));
+ if (!(upd->set & UPD_BCAST) || upd->bcast) {
+ uint32_t tmp = ~ntohl(upd->mask.s_addr);
+ bcast.s_addr |= htonl(0xffffffff & tmp);
+ }
if ((ifa = mib_create_ifa(upd->ifindex, upd->addr, upd->mask, bcast)) == NULL)
return (SNMP_ERR_GENERR);

View File

@ -0,0 +1,48 @@
--- snmp_ntp/snmp_ntp.c.orig Mon May 23 06:03:48 2005
+++ snmp_ntp/snmp_ntp.c Mon Sep 26 12:50:42 2005
@@ -40,7 +40,11 @@
#include <ctype.h>
#include <errno.h>
#include <netdb.h>
+#ifdef HAVE_STDINT_H
#include <stdint.h>
+#elif defined(HAVE_INTTYPES_H)
+#include <inttypes.h>
+#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -360,6 +364,7 @@
free(rpkt);
return (-1);
}
+ return 0;
}
/*
@@ -720,7 +725,7 @@
{
int r, n, error;
struct addrinfo hints, *res0;
- struct sockaddr_in *sin;
+ struct sockaddr_in *sin_local;
r = sscanf(val, "%hhd.%hhd.%hhd.%hhd%n",
&ip[0], &ip[1], &ip[2], &ip[3], &n);
@@ -743,11 +748,11 @@
return (-1);
}
- sin = (struct sockaddr_in *)(void *)res0->ai_addr;
- ip[3] = sin->sin_addr.s_addr >> 24;
- ip[2] = sin->sin_addr.s_addr >> 16;
- ip[1] = sin->sin_addr.s_addr >> 8;
- ip[0] = sin->sin_addr.s_addr >> 0;
+ sin_local = (struct sockaddr_in *)(void *)res0->ai_addr;
+ ip[3] = sin_local->sin_addr.s_addr >> 24;
+ ip[2] = sin_local->sin_addr.s_addr >> 16;
+ ip[1] = sin_local->sin_addr.s_addr >> 8;
+ ip[0] = sin_local->sin_addr.s_addr >> 0;
freeaddrinfo(res0);
return (0);

View File

@ -0,0 +1,20 @@
--- snmpd/config.c.orig Thu Sep 22 08:43:58 2005
+++ snmpd/config.c Thu Sep 22 08:44:54 2005
@@ -820,7 +820,7 @@
while (token == '.') {
if (gettoken() == TOK_NUM) {
if (numval > ASN_MAXID)
- report("subid too large %#"PRIx64, numval);
+ report("subid too large %#"QUADXFMT, numval);
if (oid->len == ASN_MAXOIDLEN)
report("index too long");
oid->subs[oid->len++] = numval;
@@ -863,7 +863,7 @@
if (token != TOK_NUM)
report("bad INTEGER syntax");
if (numval > 0x7fffffff)
- report("INTEGER too large %"PRIu64, numval);
+ report("INTEGER too large %"QUADFMT, numval);
value->v.integer = numval;
gettoken();

View File

@ -0,0 +1,10 @@
--- snmpd/main.c.orig Thu Sep 22 09:14:31 2005
+++ snmpd/main.c Thu Sep 22 09:15:49 2005
@@ -33,6 +33,7 @@
#include <sys/param.h>
#include <sys/un.h>
#include <sys/ucred.h>
+#include <sys/uio.h>
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>

View File

@ -0,0 +1,14 @@
--- snmpd/snmpd.config.orig Tue Sep 20 20:43:27 2005
+++ snmpd/snmpd.config Tue Sep 20 20:43:38 2005
@@ -82,11 +82,3 @@
# Load MIB-2 module
#
begemotSnmpdModulePath."mibII" = "/usr/local/lib/snmp_mibII.so"
-
-#
-# Netgraph module
-#
-begemotSnmpdModulePath."netgraph" = "/usr/local/lib/snmp_netgraph.so"
-
-%netgraph
-begemotNgControlNodeName = "snmpd"

View File

@ -0,0 +1,11 @@
--- snmpd/trap.c.orig Wed Sep 21 11:42:50 2005
+++ snmpd/trap.c Wed Sep 21 11:42:06 2005
@@ -111,7 +111,7 @@
if (connect(t->socket, (struct sockaddr *)&sa, sa.sin_len) == -1) {
syslog(LOG_ERR, "connect(%s,%u): %m",
- inet_ntoa(sa.sin_addr), ntohl(sa.sin_port));
+ inet_ntoa(sa.sin_addr), ntohs(sa.sin_port));
(void)close(t->socket);
free(t);
return (SNMP_ERR_GENERR);

View File

@ -0,0 +1,8 @@
This is a mini-SNMP daemon. The basic daemon implements the system group
and a number of private extensions to manage the UDP transport mapping,
communities, trap destinations and loadable modules. In this form it can
be used to provide remote access to arbitrary data that can be described in
the form as required by the SMI. The daemon speaks both SNMPv1 and SNMPv2c.
WWW: http://people.freebsd.org/~harti/bsnmp/
Author: Andrey V. Elsukov <bu7cher@yandex.ru>

30
net-mgmt/bsnmpd/pkg-plist Normal file
View File

@ -0,0 +1,30 @@
etc/snmpd.config.example
lib/libbsnmp.a
lib/libbsnmp.so
lib/libbsnmp.so.2
lib/snmp_mibII.so
lib/snmp_mibII.so.3
lib/snmp_ntp.so
lib/snmp_ntp.so.3
include/bsnmp/asn1.h
include/bsnmp/snmp.h
include/bsnmp/snmpagent.h
include/bsnmp/snmpclient.h
include/bsnmp/snmpmod.h
include/bsnmp/snmp_mibII.h
sbin/bsnmpd
sbin/gensnmpdef
sbin/gensnmptree
share/snmp/defs/mibII_tree.def
share/snmp/defs/ntp_tree.def
share/snmp/defs/tree.def
share/snmp/mibs/BEGEMOT-MIB.txt
share/snmp/mibs/BEGEMOT-NTP-MIB.txt
share/snmp/mibs/BEGEMOT-SNMPD.txt
share/snmp/mibs/FOKUS-MIB.txt
share/snmp/mibs/NTP-MIB.txt
share/snmp/mibs/NTP-PROXY-MIB.txt
@dirrm include/bsnmp
@dirrm share/snmp/defs
@dirrm share/snmp/mibs
@dirrm share/snmp