Virgin import of bsnmpd 1.11
This commit is contained in:
parent
9ed6112d51
commit
165c5d31cb
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/vendor/bsnmp/dist/; revision=150920 svn path=/vendor/bsnmp/1.11/; revision=150922; tag=vendor/bsnmp/1.11
38
contrib/bsnmp/Makefile.in
Normal file
38
contrib/bsnmp/Makefile.in
Normal file
@ -0,0 +1,38 @@
|
||||
# Copyright (c) 2001-2003
|
||||
# Fraunhofer Institute for Open Communication Systems (FhG Fokus).
|
||||
# All rights reserved.
|
||||
#
|
||||
# Author: Harti Brandt <harti@freebsd.org>
|
||||
#
|
||||
# $Begemot: bsnmp/Makefile.in,v 1.4 2005/10/04 11:21:22 brandt_h Exp $
|
||||
#
|
||||
|
||||
SUBDIR= lib gensnmptree snmpd snmp_mibII snmp_ntp
|
||||
|
||||
ifeq "$(HAVE_LIBSMI)" "yes"
|
||||
SUBDIR += gensnmpdef
|
||||
endif
|
||||
|
||||
all:
|
||||
+@for f in $(SUBDIR) ; do \
|
||||
echo "==> $$f" ; \
|
||||
if ! $(SUBMAKE) -C $$f all ; then \
|
||||
break ; \
|
||||
fi ; \
|
||||
done
|
||||
|
||||
install:
|
||||
+@for f in $(SUBDIR) ; do \
|
||||
echo "==> $$f" ; \
|
||||
if ! $(SUBMAKE) -C $$f install ; then \
|
||||
break ; \
|
||||
fi ; \
|
||||
done
|
||||
|
||||
clean:
|
||||
+@for f in $(SUBDIR) ; do \
|
||||
echo "==> $$f" ; \
|
||||
if ! $(SUBMAKE) -C $$f clean ; then \
|
||||
break ; \
|
||||
fi ; \
|
||||
done
|
@ -1,3 +1,25 @@
|
||||
1.11 Make the Mib2 routing table use red-black tree. This vastly
|
||||
reduces loading and access time. Load the table only every 10
|
||||
minutes. In the meantime process message from the routing socket
|
||||
to update the table.
|
||||
|
||||
Lot of man-page fixes from ru@freebsd.org.
|
||||
|
||||
Fixes to command line macros and macro redefinition.
|
||||
|
||||
Trap variables for ntp (still need trap definition and code).
|
||||
|
||||
Periodic timers from Victor Cruceru.
|
||||
|
||||
Man-page fixes from Christian Brueffer.
|
||||
|
||||
Lots of spelling fixes from Giorgios Keramidas.
|
||||
|
||||
A number of changes to facilitate building on FreeBSD-4 from
|
||||
Andrey Elsukov.
|
||||
|
||||
Add repeatable timers.
|
||||
|
||||
1.10
|
||||
Change all the tick handling in the daemon from 32-bit to 64-bit.
|
||||
Bump the modules' major version number to 3.
|
||||
@ -34,7 +56,7 @@
|
||||
Maxim Konovalov)
|
||||
|
||||
1.7
|
||||
snmpd: Move event library initialisation before reading of
|
||||
snmpd: Move event library initialization before reading of
|
||||
config file (thanks to phk).
|
||||
|
||||
gensnmptree: can now read more than one tree and merge them.
|
||||
|
@ -1 +1 @@
|
||||
1.10
|
||||
1.11
|
||||
|
5867
contrib/bsnmp/acinclude.m4
Normal file
5867
contrib/bsnmp/acinclude.m4
Normal file
File diff suppressed because it is too large
Load Diff
14
contrib/bsnmp/aclocal.m4
vendored
Normal file
14
contrib/bsnmp/aclocal.m4
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
# generated automatically by aclocal 1.9.2 -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
|
||||
# Free Software Foundation, Inc.
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
m4_include([acinclude.m4])
|
11
contrib/bsnmp/config/Makefile.build
Normal file
11
contrib/bsnmp/config/Makefile.build
Normal file
@ -0,0 +1,11 @@
|
||||
# Copyright (c) 2004
|
||||
# Hartmut Brandt
|
||||
# All rights reserved.
|
||||
#
|
||||
# Author: Harti Brandt <harti@freebsd.org>
|
||||
#
|
||||
# $Begemot: bsnmp/config/Makefile.build,v 1.1 2004/04/13 17:01:31 novo Exp $
|
||||
#
|
||||
|
||||
all: build-prog build-lib build-man1 build-man3
|
||||
|
126
contrib/bsnmp/config/Makefile.post
Normal file
126
contrib/bsnmp/config/Makefile.post
Normal file
@ -0,0 +1,126 @@
|
||||
# Copyright (c) 2001-2003
|
||||
# Fraunhofer Institute for Open Communication Systems (FhG Fokus).
|
||||
# All rights reserved.
|
||||
#
|
||||
# Author: Harti Brandt <harti@freebsd.org>
|
||||
#
|
||||
# $Begemot: bsnmp/config/Makefile.post,v 1.4 2005/10/04 11:21:28 brandt_h Exp $
|
||||
#
|
||||
|
||||
.SUFFIXES: .lo
|
||||
.c.lo:
|
||||
@test -d .deps || mkdir .deps >/dev/null 2>&1
|
||||
$(LIBTOOL) --mode=compile $(CC) -c $(CFLAGS) -o $@ $<
|
||||
|
||||
LIBTOOL_DEPS= @LIBTOOL_DEPS@
|
||||
$(LIBTOOL): $(LIBTOOL_DEPS)
|
||||
$(SHELL) ../config.status --recheck
|
||||
|
||||
clean:
|
||||
rm -rf *.o .libs .deps *.a *.la *.lo $(PROG) $(LIB) core $(PROG).core $(CLEANFILES)
|
||||
|
||||
DEPENDS=$(patsubst %.c,.deps/%.d, $(patsubst %.h,, $(SRCS)))
|
||||
|
||||
ifndef MANFILTER
|
||||
MANFILTER=cat
|
||||
endif
|
||||
|
||||
ifneq "$(MAN1)" ""
|
||||
build-man1: $(MAN1:%.1=%.1out)
|
||||
|
||||
install-man1:
|
||||
@$(srcdir)/../config/mkinstalldirs $(mandir)/man1
|
||||
for f in $(MAN1) ; do \
|
||||
$(BSD_INSTALL_MAN) $${f}out $(mandir)/man1/$${f} ; \
|
||||
done
|
||||
|
||||
%.1out: %.1
|
||||
cat $< | $(MANFILTER) >$@
|
||||
|
||||
else
|
||||
build-man1:
|
||||
install-man1:
|
||||
endif
|
||||
|
||||
ifneq "$(MAN3)" ""
|
||||
build-man3: $(MAN3:%.3=%.3out)
|
||||
|
||||
install-man3:
|
||||
@$(srcdir)/../config/mkinstalldirs $(mandir)/man3
|
||||
for f in $(MAN3) ; do \
|
||||
$(BSD_INSTALL_MAN) $${f}out $(mandir)/man3/$${f} ; \
|
||||
done
|
||||
|
||||
%.3out: %.3
|
||||
cat $< | $(MANFILTER) >$@
|
||||
else
|
||||
build-man3:
|
||||
install-man3:
|
||||
endif
|
||||
|
||||
ifneq "$(DEFS)" ""
|
||||
install-defs:
|
||||
@$(srcdir)/../config/mkinstalldirs $(DEFSDIR)
|
||||
$(BSD_INSTALL_DATA) $(DEFS:%=$(srcdir)/%) $(DEFSDIR)
|
||||
|
||||
DEFSDIR= ${datadir}/snmp/defs
|
||||
|
||||
else
|
||||
install-defs:
|
||||
endif
|
||||
|
||||
ifneq "$(INCS)" ""
|
||||
|
||||
INCDIR= $(includedir)/bsnmp
|
||||
|
||||
install-incs:
|
||||
@$(srcdir)/../config/mkinstalldirs $(INCDIR)
|
||||
for f in $(INCS) ; do \
|
||||
$(BSD_INSTALL_DATA) $(srcdir)/$$f $(INCDIR) ; \
|
||||
done
|
||||
|
||||
else
|
||||
install-incs:
|
||||
endif
|
||||
|
||||
ifneq "$(BMIBS)" ""
|
||||
|
||||
BMIBSDIR= ${datadir}/snmp/mibs
|
||||
|
||||
install-mibs:
|
||||
@$(srcdir)/../config/mkinstalldirs $(BMIBSDIR)
|
||||
for f in $(BMIBS) ; do \
|
||||
$(BSD_INSTALL_DATA) $(srcdir)/$$f $(BMIBSDIR) ; \
|
||||
done
|
||||
|
||||
else
|
||||
install-mibs:
|
||||
endif
|
||||
|
||||
ifneq "$(PROG)" ""
|
||||
build-prog: $(PROG)
|
||||
|
||||
install-prog:
|
||||
@$(srcdir)/../config/mkinstalldirs $(bindir)
|
||||
$(LIBTOOL) --mode=install $(BSD_INSTALL_PROGRAM) $(builddir)/$(PROG) $(bindir)/$(PROG)
|
||||
|
||||
else
|
||||
build-prog:
|
||||
install-prog:
|
||||
endif
|
||||
|
||||
ifneq "$(LIB)" ""
|
||||
build-lib: $(LIB)
|
||||
|
||||
install-lib:
|
||||
@$(srcdir)/../config/mkinstalldirs $(libdir)
|
||||
$(LIBTOOL) --mode=install $(BSD_INSTALL_DATA) $(LIB) $(libdir)
|
||||
|
||||
else
|
||||
build-lib:
|
||||
install-lib:
|
||||
endif
|
||||
|
||||
install: install-prog install-lib install-incs install-man1 install-man3 install-defs install-mibs
|
||||
|
||||
-include /dev/null $(DEPENDS)
|
66
contrib/bsnmp/config/Makefile.pre
Normal file
66
contrib/bsnmp/config/Makefile.pre
Normal file
@ -0,0 +1,66 @@
|
||||
# Copyright (c) 2004-2005
|
||||
# Hartmut Brandt.
|
||||
# All rights reserved.
|
||||
# Copyright (c) 2001-2003
|
||||
# Fraunhofer Institute for Open Communication Systems (FhG Fokus).
|
||||
# All rights reserved.
|
||||
#
|
||||
# Author: Harti Brandt <harti@freebsd.org>
|
||||
#
|
||||
# $Begemot: bsnmp/config/Makefile.pre,v 1.5 2005/10/04 11:21:28 brandt_h Exp $
|
||||
#
|
||||
|
||||
@SET_MAKE@
|
||||
|
||||
VPATH+= @srcdir@
|
||||
|
||||
srcdir= @srcdir@
|
||||
top_builddir= @top_builddir@
|
||||
builddir= @builddir@
|
||||
prefix= @prefix@
|
||||
exec_prefix= @exec_prefix@
|
||||
bindir= @bindir@
|
||||
sbindir= @sbindir@
|
||||
libdir= @libdir@
|
||||
includedir= @includedir@
|
||||
mandir= @mandir@
|
||||
datadir= @datadir@
|
||||
|
||||
INSTALL= @INSTALL@
|
||||
INSTALL_PROGRAM= @INSTALL_PROGRAM@
|
||||
INSTALL_DATA= @INSTALL_DATA@
|
||||
INSTALL_SCRIPT= @INSTALL_SCRIPT@
|
||||
|
||||
ifndef BSD_INSTALL_MAN
|
||||
BSD_INSTALL_MAN = ${INSTALL_DATA}
|
||||
endif
|
||||
ifndef BSD_INSTALL_DATA
|
||||
BSD_INSTALL_DATA = ${INSTALL_DATA}
|
||||
endif
|
||||
ifndef BSD_INSTALL_PROGRAM
|
||||
BSD_INSTALL_PROGRAM = ${INSTALL_PROGRAM}
|
||||
endif
|
||||
|
||||
LIBTOOL= @LIBTOOL@
|
||||
CC= @CC@
|
||||
DEFINES=@DEFS@
|
||||
CFLAGS= @CFLAGS@
|
||||
LDFLAGS= @LDFLAGS@
|
||||
|
||||
LIBEV= @LIBEV@
|
||||
LIBWRAP= @LIBWRAP@
|
||||
|
||||
# Assume a Posix-ish make that passes MAKEFLAGS in the environment.
|
||||
SUBMAKE= $(MAKE) --no-print-directory
|
||||
|
||||
WARNS= -Wsystem-headers -Werror -Wall -Wno-format-y2k -W \
|
||||
-Wstrict-prototypes -Wmissing-prototypes \
|
||||
-Wpointer-arith -Wreturn-type -Wcast-qual \
|
||||
-Wwrite-strings -Wswitch -Wshadow -Wcast-align \
|
||||
-Wbad-function-cast -Wchar-subscripts -Winline \
|
||||
-Wnested-externs -Wredundant-decls -std=c99
|
||||
|
||||
CFLAGS+= $(WARNS) -Wp,-MD,.deps/$(*F).d
|
||||
CFLAGS+= $(DEFINES)
|
||||
|
||||
HAVE_LIBSMI=@HAVE_LIBSMI@
|
1388
contrib/bsnmp/config/config.guess
vendored
Executable file
1388
contrib/bsnmp/config/config.guess
vendored
Executable file
File diff suppressed because it is too large
Load Diff
1489
contrib/bsnmp/config/config.sub
vendored
Executable file
1489
contrib/bsnmp/config/config.sub
vendored
Executable file
File diff suppressed because it is too large
Load Diff
236
contrib/bsnmp/config/install.sh
Executable file
236
contrib/bsnmp/config/install.sh
Executable file
@ -0,0 +1,236 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# install - install a program, script, or datafile
|
||||
# This comes from X11R5.
|
||||
#
|
||||
# $XConsortium: install.sh,v 1.2 89/12/18 14:47:22 jim Exp $
|
||||
#
|
||||
# This script is compatible with the BSD install script, but was written
|
||||
# from scratch.
|
||||
#
|
||||
|
||||
|
||||
# set DOITPROG to echo to test this script
|
||||
|
||||
# Don't use :- since 4.3BSD and earlier shells don't like it.
|
||||
doit="${DOITPROG-}"
|
||||
|
||||
|
||||
# put in absolute paths if you don't have them in your path; or use env. vars.
|
||||
|
||||
mvprog="${MVPROG-mv}"
|
||||
cpprog="${CPPROG-cp}"
|
||||
chmodprog="${CHMODPROG-chmod}"
|
||||
chownprog="${CHOWNPROG-chown}"
|
||||
chgrpprog="${CHGRPPROG-chgrp}"
|
||||
stripprog="${STRIPPROG-strip}"
|
||||
rmprog="${RMPROG-rm}"
|
||||
mkdirprog="${MKDIRPROG-mkdir}"
|
||||
|
||||
tranformbasename=""
|
||||
transform_arg=""
|
||||
instcmd="$mvprog"
|
||||
chmodcmd="$chmodprog 0755"
|
||||
chowncmd=""
|
||||
chgrpcmd=""
|
||||
stripcmd=""
|
||||
rmcmd="$rmprog -f"
|
||||
mvcmd="$mvprog"
|
||||
src=""
|
||||
dst=""
|
||||
dir_arg=""
|
||||
|
||||
while [ x"$1" != x ]; do
|
||||
case $1 in
|
||||
-c) instcmd="$cpprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-d) dir_arg=true
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-m) chmodcmd="$chmodprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-o) chowncmd="$chownprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-g) chgrpcmd="$chgrpprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-s) stripcmd="$stripprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
|
||||
shift
|
||||
continue;;
|
||||
|
||||
*) if [ x"$src" = x ]
|
||||
then
|
||||
src=$1
|
||||
else
|
||||
# this colon is to work around a 386BSD /bin/sh bug
|
||||
:
|
||||
dst=$1
|
||||
fi
|
||||
shift
|
||||
continue;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ x"$src" = x ]
|
||||
then
|
||||
echo "install: no input file specified"
|
||||
exit 1
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
if [ x"$dir_arg" != x ]; then
|
||||
dst=$src
|
||||
src=""
|
||||
|
||||
if [ -d $dst ]; then
|
||||
instcmd=:
|
||||
else
|
||||
instcmd=mkdir
|
||||
fi
|
||||
else
|
||||
|
||||
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
|
||||
# might cause directories to be created, which would be especially bad
|
||||
# if $src (and thus $dsttmp) contains '*'.
|
||||
|
||||
if [ -f $src -o -d $src ]
|
||||
then
|
||||
true
|
||||
else
|
||||
echo "install: $src does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ x"$dst" = x ]
|
||||
then
|
||||
echo "install: no destination specified"
|
||||
exit 1
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
# If destination is a directory, append the input filename; if your system
|
||||
# does not like double slashes in filenames, you may need to add some logic
|
||||
|
||||
if [ -d $dst ]
|
||||
then
|
||||
dst="$dst"/`basename $src`
|
||||
else
|
||||
true
|
||||
fi
|
||||
fi
|
||||
|
||||
## this sed command emulates the dirname command
|
||||
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
|
||||
|
||||
# Make sure that the destination directory exists.
|
||||
# this part is taken from Noah Friedman's mkinstalldirs script
|
||||
|
||||
# Skip lots of stat calls in the usual case.
|
||||
if [ ! -d "$dstdir" ]; then
|
||||
defaultIFS='
|
||||
'
|
||||
IFS="${IFS-${defaultIFS}}"
|
||||
|
||||
oIFS="${IFS}"
|
||||
# Some sh's can't handle IFS=/ for some reason.
|
||||
IFS='%'
|
||||
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
|
||||
IFS="${oIFS}"
|
||||
|
||||
pathcomp=''
|
||||
|
||||
while [ $# -ne 0 ] ; do
|
||||
pathcomp="${pathcomp}${1}"
|
||||
shift
|
||||
|
||||
if [ ! -d "${pathcomp}" ] ;
|
||||
then
|
||||
$mkdirprog "${pathcomp}"
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
pathcomp="${pathcomp}/"
|
||||
done
|
||||
fi
|
||||
|
||||
if [ x"$dir_arg" != x ]
|
||||
then
|
||||
$doit $instcmd $dst &&
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
|
||||
else
|
||||
|
||||
# If we're going to rename the final executable, determine the name now.
|
||||
|
||||
if [ x"$transformarg" = x ]
|
||||
then
|
||||
dstfile=`basename $dst`
|
||||
else
|
||||
dstfile=`basename $dst $transformbasename |
|
||||
sed $transformarg`$transformbasename
|
||||
fi
|
||||
|
||||
# don't allow the sed command to completely eliminate the filename
|
||||
|
||||
if [ x"$dstfile" = x ]
|
||||
then
|
||||
dstfile=`basename $dst`
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
# Make a temp file name in the proper directory.
|
||||
|
||||
dsttmp=$dstdir/#inst.$$#
|
||||
|
||||
# Move or copy the file name to the temp name
|
||||
|
||||
$doit $instcmd $src $dsttmp &&
|
||||
|
||||
trap "rm -f ${dsttmp}" 0 &&
|
||||
|
||||
# and set any options; do chmod last to preserve setuid bits
|
||||
|
||||
# If any of these fail, we abort the whole thing. If we want to
|
||||
# ignore errors from any of these, just make sure not to ignore
|
||||
# errors from the above "$doit $instcmd $src $dsttmp" command.
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
|
||||
$doit $rmcmd -f $dstdir/$dstfile &&
|
||||
$doit $mvcmd $dsttmp $dstdir/$dstfile
|
||||
|
||||
fi &&
|
||||
|
||||
|
||||
exit 0
|
6306
contrib/bsnmp/config/ltmain.sh
Normal file
6306
contrib/bsnmp/config/ltmain.sh
Normal file
File diff suppressed because it is too large
Load Diff
40
contrib/bsnmp/config/mkinstalldirs
Executable file
40
contrib/bsnmp/config/mkinstalldirs
Executable file
@ -0,0 +1,40 @@
|
||||
#! /bin/sh
|
||||
# mkinstalldirs --- make directory hierarchy
|
||||
# Author: Noah Friedman <friedman@prep.ai.mit.edu>
|
||||
# Created: 1993-05-16
|
||||
# Public domain
|
||||
|
||||
# $Id: mkinstalldirs,v 1.1 1999/06/17 13:26:38 maw Exp $
|
||||
|
||||
errstatus=0
|
||||
|
||||
for file
|
||||
do
|
||||
set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
|
||||
shift
|
||||
|
||||
pathcomp=
|
||||
for d
|
||||
do
|
||||
pathcomp="$pathcomp$d"
|
||||
case "$pathcomp" in
|
||||
-* ) pathcomp=./$pathcomp ;;
|
||||
esac
|
||||
|
||||
if test ! -d "$pathcomp"; then
|
||||
echo "mkdir $pathcomp" 1>&2
|
||||
|
||||
mkdir "$pathcomp" || lasterr=$?
|
||||
|
||||
if test ! -d "$pathcomp"; then
|
||||
errstatus=$lasterr
|
||||
fi
|
||||
fi
|
||||
|
||||
pathcomp="$pathcomp/"
|
||||
done
|
||||
done
|
||||
|
||||
exit $errstatus
|
||||
|
||||
# mkinstalldirs ends here
|
20188
contrib/bsnmp/configure
vendored
Executable file
20188
contrib/bsnmp/configure
vendored
Executable file
File diff suppressed because it is too large
Load Diff
134
contrib/bsnmp/configure.ac
Normal file
134
contrib/bsnmp/configure.ac
Normal file
@ -0,0 +1,134 @@
|
||||
#
|
||||
# Copyright (c) 2004-2005
|
||||
# Hartmut Brandt.
|
||||
# All rights reserved.
|
||||
# Copyright (c) 2003-2003
|
||||
# Fraunhofer Institute for Open Communication Systems (FhG Fokus).
|
||||
# All rights reserved.
|
||||
#
|
||||
# Author: Harti Brandt <harti@freebsd.org>
|
||||
#
|
||||
# $Begemot: bsnmp/configure.ac,v 1.8 2005/10/04 11:21:26 brandt_h Exp $
|
||||
#
|
||||
AC_INIT([BSNMP], [1.0], [harti@freebsd.org], bsnmp)
|
||||
AC_PREREQ(2.53)
|
||||
AC_COPYRIGHT([Copyright (c)1996-2003 Fraunhofer Fokus. All rights reserved.])
|
||||
AC_REVISION($Revision$)
|
||||
|
||||
AC_CONFIG_SRCDIR(config/install.sh)
|
||||
AC_CONFIG_AUX_DIR(config)
|
||||
AC_CANONICAL_BUILD
|
||||
AC_CANONICAL_HOST
|
||||
AC_CANONICAL_TARGET
|
||||
|
||||
AC_PROG_CC
|
||||
AC_PROG_CPP
|
||||
AC_PROG_MAKE_SET
|
||||
AC_PROG_INSTALL
|
||||
|
||||
AC_PROG_LIBTOOL
|
||||
AC_SUBST(LIBTOOL_DEPS)
|
||||
|
||||
AC_ARG_WITH(libbegemot,
|
||||
AC_HELP_STRING([--with-libbegemot],
|
||||
[use libbegemot instead of libisc and set path to where the
|
||||
includes and lib are found(default is NO, if no path specified default=/usr/local)]),
|
||||
ac_cv_use_libbegemot=$withval, ac_cv_use_libbegemot=no)
|
||||
AC_CACHE_CHECK(whether to use libbegemot,
|
||||
ac_cv_use_libbegemot, ac_cv_use_libbegemot=no)
|
||||
|
||||
if test $ac_cv_use_libbegemot == "yes" ; then
|
||||
ac_cv_use_libbegemot="/usr/local"
|
||||
fi
|
||||
|
||||
if test $ac_cv_use_libbegemot != "no" ; then
|
||||
AC_DEFINE(USE_LIBBEGEMOT)
|
||||
AC_SUBST(LIBEV, -lbegemot)
|
||||
|
||||
CFLAGS="${CFLAGS} -I$ac_cv_use_libbegemot/include"
|
||||
LDFLAGS="${LDFLAGS} -L$ac_cv_use_libbegemot/lib"
|
||||
|
||||
AC_CHECK_LIB(begemot, poll_register, ,
|
||||
[AC_ERROR([libbegemot not found])])
|
||||
else
|
||||
AC_SUBST(LIBEV, -lisc)
|
||||
fi
|
||||
|
||||
AC_ARG_WITH(tcpwrappers,
|
||||
AC_HELP_STRING([--with-tcpwrappers],
|
||||
[use libwrap to control access]),
|
||||
ac_cv_use_tcpwrappers=$withval, ac_cv_use_tcpwrappers=no)
|
||||
|
||||
if test $ac_cv_use_tcpwrappers != "no" ; then
|
||||
AC_DEFINE(USE_TCPWRAPPERS)
|
||||
AC_SUBST(LIBWRAP, -lwrap)
|
||||
fi
|
||||
|
||||
LDFLAGS="${LDFLAGS} -L/usr/local/lib"
|
||||
|
||||
AC_CHECK_LIB(smi, smiGetNode, HAVE_LIBSMI=yes, HAVE_LIBSMI=no)
|
||||
AC_SUBST(HAVE_LIBSMI)
|
||||
|
||||
# check for BSD's err.h
|
||||
AC_CHECK_HEADERS([err.h])
|
||||
|
||||
# check for strlcpy
|
||||
AC_CHECK_FUNCS(strlcpy)
|
||||
|
||||
# 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
|
||||
gensnmptree/Makefile:config/Makefile.pre:config/Makefile.build:gensnmptree/Makefile.in:config/Makefile.post
|
||||
gensnmpdef/Makefile:config/Makefile.pre:config/Makefile.build:gensnmpdef/Makefile.in:config/Makefile.post
|
||||
snmpd/Makefile:config/Makefile.pre:config/Makefile.build:snmpd/Makefile.in:config/Makefile.post
|
||||
snmp_mibII/Makefile:config/Makefile.pre:config/Makefile.build:snmp_mibII/Makefile.in:config/Makefile.post
|
||||
snmp_ntp/Makefile:config/Makefile.pre:config/Makefile.build:snmp_ntp/Makefile.in:config/Makefile.post
|
||||
])
|
||||
AC_OUTPUT
|
17
contrib/bsnmp/gensnmpdef/Makefile.in
Normal file
17
contrib/bsnmp/gensnmpdef/Makefile.in
Normal file
@ -0,0 +1,17 @@
|
||||
# Copyright (c) 2004
|
||||
# Hartmut Brandt
|
||||
# All rights reserved.
|
||||
#
|
||||
# Author: Harti Brandt <harti@freebsd.org>
|
||||
#
|
||||
# $Begemot: bsnmp/gensnmpdef/Makefile.in,v 1.2 2004/04/14 09:54:51 novo Exp $
|
||||
#
|
||||
|
||||
PROG= gensnmpdef
|
||||
SRCS= gensnmpdef.c
|
||||
MAN1= gensnmpdef.1
|
||||
|
||||
CFLAGS+= -I/usr/local/include
|
||||
|
||||
$(PROG): $(SRCS:.c=.lo)
|
||||
$(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ $(SRCS:.c=.lo) -lsmi
|
@ -1,5 +1,5 @@
|
||||
.\"
|
||||
.\" Copyright (C) 2004
|
||||
.\" Copyright (C) 2004-2005
|
||||
.\" Hartmut Brandt.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
@ -26,9 +26,9 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Begemot: bsnmp/gensnmpdef/gensnmpdef.1,v 1.3 2005/02/25 11:55:54 brandt_h Exp $
|
||||
.\" $Begemot: bsnmp/gensnmpdef/gensnmpdef.1,v 1.5 2005/10/04 08:46:46 brandt_h Exp $
|
||||
.\"
|
||||
.Dd April 14, 2004
|
||||
.Dd June 14, 2005
|
||||
.Dt GENSNMPDEF 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -43,7 +43,8 @@
|
||||
The
|
||||
.Nm
|
||||
utility is used to create an initial MIB description file from
|
||||
one or more MIBs. The description file must be edited to be actually useful
|
||||
one or more MIBs.
|
||||
The description file must be edited to be actually useful
|
||||
for feeding it into
|
||||
.Xr gensnmptree 1 .
|
||||
.Pp
|
||||
@ -57,13 +58,13 @@ of 3 is just correct in most cases.
|
||||
.Pp
|
||||
.Nm
|
||||
does no attempt on sorting the OID tree so in case of complex and
|
||||
non-standard MIBs it is necessay to sort the tree in the resulting definition
|
||||
non-standard MIBs it is necessary to sort the tree in the resulting definition
|
||||
file by hand.
|
||||
.Sh SEE ALSO
|
||||
.Xr snmpd 1
|
||||
.Sh AUTHORS
|
||||
.An Hartmut Brandt Aq harti@freebsd.org
|
||||
.Sh BUGS
|
||||
The utility is by no means bullet-proof and may fail for complex
|
||||
or non-standard MIBs.
|
||||
Its output is expected to be edited by hand.
|
||||
.Sh AUTHORS
|
||||
.An Hartmut Brandt Aq harti@freebsd.org
|
||||
|
17
contrib/bsnmp/gensnmptree/Makefile.in
Normal file
17
contrib/bsnmp/gensnmptree/Makefile.in
Normal file
@ -0,0 +1,17 @@
|
||||
# Copyright (c) 2001-2003
|
||||
# Fraunhofer Institute for Open Communication Systems (FhG Fokus).
|
||||
# All rights reserved.
|
||||
#
|
||||
# Author: Harti Brandt <harti@freebsd.org>
|
||||
#
|
||||
# $Begemot: bsnmp/gensnmptree/Makefile.in,v 1.3 2004/04/13 17:01:31 novo Exp $
|
||||
#
|
||||
|
||||
PROG= gensnmptree
|
||||
SRCS= gensnmptree.c
|
||||
MAN1= gensnmptree.1
|
||||
|
||||
CFLAGS+= -I$(srcdir)/../lib
|
||||
|
||||
$(PROG): $(SRCS:.c=.lo)
|
||||
$(LIBTOOL) --mode=link $(CC) $(LDLAGS) -o $@ $(SRCS:.c=.lo)
|
@ -1,5 +1,5 @@
|
||||
.\"
|
||||
.\" Copyright (c) 2001-2003
|
||||
.\" Copyright (c) 2001-2005
|
||||
.\" Fraunhofer Institute for Open Communication Systems (FhG Fokus).
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
@ -26,9 +26,9 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Begemot: bsnmp/gensnmptree/gensnmptree.1,v 1.4 2005/02/25 11:55:56 brandt_h Exp $
|
||||
.\" $Begemot: bsnmp/gensnmptree/gensnmptree.1,v 1.5 2005/06/15 11:31:25 brandt_h Exp $
|
||||
.\"
|
||||
.Dd October 7, 2003
|
||||
.Dd June 14, 2005
|
||||
.Dt GENSNMPTREE 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -43,8 +43,8 @@
|
||||
The
|
||||
.Nm
|
||||
utility is used to either generate C language tables and header files from
|
||||
a MIB description or to numeric OIDs from MIB descriptions. The first form
|
||||
is used only for maintaining the
|
||||
a MIB description or to numeric OIDs from MIB descriptions.
|
||||
The first form is used only for maintaining the
|
||||
.Xr snmpd 1
|
||||
daemon or for module writers.
|
||||
The second form may be used by SNMP client program writers.
|
||||
@ -70,7 +70,8 @@ option is specified
|
||||
.Nm
|
||||
expects MIB variable names (only the last component) on its command line.
|
||||
It reads a MIB specification from standard input and for each MIB variable
|
||||
name emits two C preprocessor defines on its standard output. One define
|
||||
name emits two C preprocessor defines on its standard output.
|
||||
One define
|
||||
.Va OID_ Ns Ar name
|
||||
can be used as an array initialized to initialize a
|
||||
.Va struct asn_oid .
|
||||
@ -85,7 +86,8 @@ Print a short help page.
|
||||
.It Fl e
|
||||
Enter extract mode.
|
||||
.It Fl l
|
||||
Generate local preprocessor includes. This is used for bootstrapping
|
||||
Generate local preprocessor includes.
|
||||
This is used for bootstrapping
|
||||
.Xr snmpd 1 .
|
||||
.It Fl t
|
||||
Instead of normal output print the resulting tree.
|
||||
|
@ -30,7 +30,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Begemot: bsnmp/gensnmptree/gensnmptree.c,v 1.42 2005/04/26 16:26:19 brandt_h Exp $
|
||||
* $Begemot: bsnmp/gensnmptree/gensnmptree.c,v 1.43 2005/10/04 11:21:29 brandt_h Exp $
|
||||
*
|
||||
* Generate OID table from table description.
|
||||
*
|
||||
@ -595,7 +595,9 @@ gen_table(struct node *node)
|
||||
|
||||
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");
|
||||
|
20
contrib/bsnmp/lib/Makefile.in
Normal file
20
contrib/bsnmp/lib/Makefile.in
Normal file
@ -0,0 +1,20 @@
|
||||
# Copyright (c) 2003-2003
|
||||
# Fraunhofer Institute for Open Communication Systems (FhG Fokus).
|
||||
# All rights reserved.
|
||||
#
|
||||
# Author: Harti Brandt <harti@freebsd.org>
|
||||
#
|
||||
# $Begemot: bsnmp/lib/Makefile.in,v 1.4 2004/08/06 08:46:47 brandt Exp $
|
||||
#
|
||||
SRCS= asn1.c snmp.c snmpagent.c snmpclient.c support.c
|
||||
INCS= asn1.h snmp.h snmpagent.h snmpclient.h
|
||||
MAN3= asn1.3 bsnmplib.3 bsnmpclient.3 bsnmpagent.3
|
||||
|
||||
LIB= libbsnmp.la
|
||||
SHLIB_MAJOR= 2
|
||||
SHLIB_MINOR= 0
|
||||
|
||||
CFLAGS+= -I$(srcdir)
|
||||
|
||||
$(LIB): $(SRCS:.c=.lo)
|
||||
$(LIBTOOL) --mode=link $(CC) $(LDLAGS) -o $@ $(SRCS:.c=.lo) -rpath $(libdir) -version-info $(SHLIB_MAJOR):$(SHLIB_MINOR)
|
@ -1,4 +1,7 @@
|
||||
.\"
|
||||
.\" Copyright (c) 2004-2005
|
||||
.\" Hartmut Brandt.
|
||||
.\" All rights reserved.
|
||||
.\" Copyright (c) 2001-2003
|
||||
.\" Fraunhofer Institute for Open Communication Systems (FhG Fokus).
|
||||
.\" All rights reserved.
|
||||
@ -26,9 +29,9 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Begemot: bsnmp/lib/asn1.3,v 1.6 2005/02/25 11:55:57 brandt_h Exp $
|
||||
.\" $Begemot: bsnmp/lib/asn1.3,v 1.9 2005/10/04 08:46:49 brandt_h Exp $
|
||||
.\"
|
||||
.Dd August 15, 2002
|
||||
.Dd October 4, 2005
|
||||
.Dt ASN1 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -142,8 +145,8 @@ Begemot SNMP library
|
||||
.Fn asn_oid2str "const struct asn_oid *oid"
|
||||
.Sh DESCRIPTION
|
||||
The ASN.1 library contains routines to handle ASN.1 encoding for SNMP.
|
||||
It supports only the restricted form of ASN.1 as required by SNMP. There
|
||||
are two basic structures used throughout the library:
|
||||
It supports only the restricted form of ASN.1 as required by SNMP.
|
||||
There are two basic structures used throughout the library:
|
||||
.Bd -literal -offset indent
|
||||
/* these restrictions are in the SMI */
|
||||
#define ASN_MAXID 0xffffffff
|
||||
@ -176,17 +179,18 @@ struct asn_buf {
|
||||
#define asn_ptr asn_u.ptr
|
||||
.Ed
|
||||
.Pp
|
||||
This structure is used to encode and decode ASN.1. It describes the output
|
||||
This structure is used to encode and decode ASN.1.
|
||||
It describes the output
|
||||
buffer for encoding routines and the input buffer for decoding routines.
|
||||
For encoding
|
||||
.Fa asn_len
|
||||
holds the number of remaining free octets in the buffer. The first free byte
|
||||
is pointed to by
|
||||
holds the number of remaining free octets in the buffer.
|
||||
The first free byte is pointed to by
|
||||
.Fa asn_ptr .
|
||||
For decoding
|
||||
.Fa asn_len
|
||||
holds the number of remaining bytes to decode. The next byte to decode is pointed
|
||||
to by
|
||||
holds the number of remaining bytes to decode.
|
||||
The next byte to decode is pointed to by
|
||||
.Fa asn_cptr .
|
||||
.Pp
|
||||
Most of the functions return an error code
|
||||
@ -216,20 +220,20 @@ of error.
|
||||
.Pp
|
||||
The function
|
||||
.Fn asn_get_header
|
||||
reads the next header from the input octet stream. It returns the tag
|
||||
in the variable pointed to by
|
||||
reads the next header from the input octet stream.
|
||||
It returns the tag in the variable pointed to by
|
||||
.Fa type
|
||||
(note that only single byte tags are supported) and the decoded length field
|
||||
in the value pointed to by
|
||||
.Fa lenp
|
||||
(this is restricted to a unsigned 32-bit value). All errors in this function
|
||||
are fatal and stop processing.
|
||||
(this is restricted to a unsigned 32-bit value).
|
||||
All errors in this function are fatal and stop processing.
|
||||
.Pp
|
||||
The function
|
||||
.Fn asn_put_header
|
||||
writes an ASN.1 header.
|
||||
.Fa type
|
||||
is the tag to write and is restricted to one byte tags (i.e. tags
|
||||
is the tag to write and is restricted to one byte tags (i.e., tags
|
||||
lesser or equal than 0x30).
|
||||
.Fa len
|
||||
is the length of the value and is restricted to 16-bit.
|
||||
@ -246,15 +250,18 @@ writes a header with the given tag
|
||||
and space for the maximum supported length field and sets the pointer pointed
|
||||
to by
|
||||
.Fa ptr
|
||||
to the begin of this length field. This pointer must then be fed into
|
||||
to the begin of this length field.
|
||||
This pointer must then be fed into
|
||||
.Fn asn_commit_header
|
||||
directly after writing the value to the buffer. The function will compute the
|
||||
directly after writing the value to the buffer.
|
||||
The function will compute the
|
||||
length, insert it into the right place and shift the value if the resulting
|
||||
length field is shorter than the estimated one.
|
||||
.Pp
|
||||
The function
|
||||
.Fn asn_get_integer_raw
|
||||
is used to decode a signed integer value (32-bit). It assumes, that the
|
||||
is used to decode a signed integer value (32-bit).
|
||||
It assumes, that the
|
||||
header of the integer has been decoded already.
|
||||
.Fa len
|
||||
is the length obtained from the ASN.1 header and the integer will be returned
|
||||
@ -263,8 +270,8 @@ in the value pointed to by
|
||||
.Pp
|
||||
The function
|
||||
.Fn asn_get_integer
|
||||
decodes a complete 32-bit signed integer including the header. If the
|
||||
tag is wrong
|
||||
decodes a complete 32-bit signed integer including the header.
|
||||
If the tag is wrong
|
||||
.Li ASN_ERR_TAG
|
||||
is returned.
|
||||
The function
|
||||
@ -273,14 +280,16 @@ encodes a 32-bit signed integer.
|
||||
.Pp
|
||||
The function
|
||||
.Fn asn_get_octetstring_raw
|
||||
decodes the value field of an ASN.1 octet string. The length obtained from the
|
||||
header must be fed into the
|
||||
decodes the value field of an ASN.1 octet string.
|
||||
The length obtained from the header must be fed into the
|
||||
.Fa len
|
||||
argument and
|
||||
.Fa out
|
||||
must point to a buffer to receive the octet string. On entry to the function
|
||||
must point to a buffer to receive the octet string.
|
||||
On entry to the function
|
||||
.Fa outsize
|
||||
must point to the size of the buffer. On exit
|
||||
must point to the size of the buffer.
|
||||
On exit
|
||||
.Fa outsize
|
||||
will point to the number of octets decoded (if no error occurs this will be
|
||||
equal to
|
||||
@ -291,7 +300,8 @@ decodes an octetstring including the header.
|
||||
.Fa out
|
||||
must point to a buffer to receive the string,
|
||||
.Fa outsize
|
||||
must point to the size of the buffer. On exit of the function
|
||||
must point to the size of the buffer.
|
||||
On exit of the function
|
||||
.Fa outsize
|
||||
will point to the number of octets decoded.
|
||||
The function
|
||||
@ -316,7 +326,8 @@ encodes a null.
|
||||
.Pp
|
||||
The function
|
||||
.Fn asn_put_exception
|
||||
is used to encode an SNMPv2 exception. The exception type is
|
||||
is used to encode an SNMPv2 exception.
|
||||
The exception type is
|
||||
.Fa type .
|
||||
.Pp
|
||||
The function
|
||||
@ -369,8 +380,8 @@ The function
|
||||
.Fn asn_get_counter64_raw
|
||||
decodes an unsigned 64-bit integer value.
|
||||
.Fa len
|
||||
must be the value length from the header. The resulting value is
|
||||
stored into the variable pointed to by
|
||||
must be the value length from the header.
|
||||
The resulting value is stored into the variable pointed to by
|
||||
.Fa res .
|
||||
The function
|
||||
.Fn asn_put_counter64
|
||||
@ -392,12 +403,12 @@ bytes in the input buffer.
|
||||
.Pp
|
||||
The function
|
||||
.Fn asn_slice_oid
|
||||
splits a part out from an OID. It takes all the subids from the OID
|
||||
pointed to by
|
||||
splits a part out from an OID.
|
||||
It takes all the subids from the OID pointed to by
|
||||
.Fa src
|
||||
starting with the subid at position
|
||||
.Fa from
|
||||
(the first subid beeing subid 0) up to, but not including, subid
|
||||
(the first subid being subid 0) up to, but not including, subid
|
||||
.Fa to
|
||||
and generates a new OID in
|
||||
.Fa dest .
|
||||
@ -413,8 +424,8 @@ appends the OID
|
||||
.Fa from
|
||||
to the OID
|
||||
.Fa to
|
||||
given that the resulting OID is not too long. If the maximum length is exceeded
|
||||
the result is undefined.
|
||||
given that the resulting OID is not too long.
|
||||
If the maximum length is exceeded the result is undefined.
|
||||
.Pp
|
||||
The function
|
||||
.Fn asn_compare_oid
|
||||
@ -442,7 +453,8 @@ makes a printable string from
|
||||
.Fa oid .
|
||||
The buffer pointed to by
|
||||
.Fa str
|
||||
must be large enough to hold the result. The constant
|
||||
must be large enough to hold the result.
|
||||
The constant
|
||||
.Li ASN_OIDSTRLEN
|
||||
is defined to be the length of the maximum string generated by this function
|
||||
(including the trailing NUL).
|
||||
@ -452,7 +464,7 @@ makes a printable string from
|
||||
.Fa oid
|
||||
into a private buffer that is overwritten by each call.
|
||||
.Sh DIAGNOSTICS
|
||||
When an error occures in any of the function the function pointed to
|
||||
When an error occurs in any of the function the function pointed to
|
||||
by the global pointer
|
||||
.Bd -literal -offset indent
|
||||
extern void (*asn_error)(const struct asn_buf *, const char *, ...);
|
||||
@ -469,7 +481,7 @@ starting with
|
||||
followed by the error message and an optional dump of the buffer.
|
||||
.Sh SEE ALSO
|
||||
.Xr gensnmptree 1 ,
|
||||
.Xr snmpd 1 ,
|
||||
.Xr bsnmpd 1 ,
|
||||
.Xr bsnmpagent 3 ,
|
||||
.Xr bsnmpclient 3 ,
|
||||
.Xr bsnmplib 3
|
||||
|
@ -26,7 +26,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Begemot: bsnmp/lib/asn1.c,v 1.28 2004/08/06 08:46:49 brandt Exp $
|
||||
* $Begemot: bsnmp/lib/asn1.c,v 1.29 2005/10/04 11:21:31 brandt_h Exp $
|
||||
*
|
||||
* ASN.1 for SNMP.
|
||||
*/
|
||||
@ -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"
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Begemot: bsnmp/lib/asn1.h,v 1.18 2004/08/06 08:46:50 brandt Exp $
|
||||
* $Begemot: bsnmp/lib/asn1.h,v 1.19 2005/10/04 11:21:31 brandt_h Exp $
|
||||
*
|
||||
* ASN.1 for SNMP
|
||||
*/
|
||||
@ -179,4 +179,14 @@ enum {
|
||||
ASN_EXCEPT_ENDOFMIBVIEW = 0x02,
|
||||
};
|
||||
|
||||
#if !defined(INT32_MIN)
|
||||
#define INT32_MIN (-0x7fffffff-1)
|
||||
#endif
|
||||
#if !defined(INT32_MAX)
|
||||
#define INT32_MAX (0x7fffffff)
|
||||
#endif
|
||||
#if !defined(UINT32_MAX)
|
||||
#define UINT32_MAX (0xffffffff)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -1,4 +1,7 @@
|
||||
.\"
|
||||
.\" Copyright (c) 2004-2005
|
||||
.\" Hartmut Brandt.
|
||||
.\" All rights reserved.
|
||||
.\" Copyright (c) 2001-2003
|
||||
.\" Fraunhofer Institute for Open Communication Systems (FhG Fokus).
|
||||
.\" All rights reserved.
|
||||
@ -26,9 +29,9 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Begemot: bsnmp/lib/bsnmpagent.3,v 1.7 2005/02/25 11:55:58 brandt_h Exp $
|
||||
.\" $Begemot: bsnmp/lib/bsnmpagent.3,v 1.10 2005/10/04 08:46:49 brandt_h Exp $
|
||||
.\"
|
||||
.Dd August 16, 2002
|
||||
.Dd October 4, 2005
|
||||
.Dt BSNMPAGENT 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -87,14 +90,15 @@ Begemot SNMP library
|
||||
.Fn snmp_dep_finish "struct snmp_context *ctx"
|
||||
.Sh DESCRIPTION
|
||||
The SNMP library contains routines to easily build SNMP agent applications
|
||||
that use SNMP versions 1 or 2. Note, however, that it may be even easier to
|
||||
build an
|
||||
.Xr snmpd 1
|
||||
that use SNMP versions 1 or 2.
|
||||
Note, however, that it may be even easier to build an
|
||||
.Xr bsnmpd 1
|
||||
loadable module, that handles the new MIB (see
|
||||
.Xr snmpmod 3 ) .
|
||||
.Pp
|
||||
Most of the agent routines operate on a global array that the describes the
|
||||
complete MIB served by the agent. This array is held in the two variables:
|
||||
complete MIB served by the agent.
|
||||
This array is held in the two variables:
|
||||
.Bd -literal -offset indent
|
||||
extern struct snmp_node *tree;
|
||||
extern u_int tree_size;
|
||||
@ -126,7 +130,8 @@ Base OID of the scalar or table column.
|
||||
.It Va name
|
||||
Name of this variable.
|
||||
.It Va type
|
||||
Type of this variable. One of:
|
||||
Type of this variable.
|
||||
One of:
|
||||
.Bd -literal -offset indent
|
||||
enum snmp_node_type {
|
||||
SNMP_NODE_LEAF = 1,
|
||||
@ -136,17 +141,20 @@ enum snmp_node_type {
|
||||
.It Va syntax
|
||||
The SNMP syntax of this variable.
|
||||
.It Va op
|
||||
The user supplied handler for this variable. The handler is called with
|
||||
the following arguments:
|
||||
The user supplied handler for this variable.
|
||||
The handler is called with the following arguments:
|
||||
.Bl -tag -width "ctx"
|
||||
.It Fa ctx
|
||||
A pointer to the context (see below).
|
||||
.Li NULL .
|
||||
.It Fa val
|
||||
The value to be set or retrieved. For GETNEXT and GETBULK operations the oid in
|
||||
this value is the current OID. The function (called in this case only for
|
||||
The value to be set or retrieved.
|
||||
For GETNEXT and GETBULK operations the oid in
|
||||
this value is the current OID.
|
||||
The function (called in this case only for
|
||||
table rows) must find the lexically next existing OID within the same column and
|
||||
set the oid and value subfields accordingly. If the table column is exhausted the
|
||||
set the oid and value subfields accordingly.
|
||||
If the table column is exhausted the
|
||||
function must return
|
||||
.Li SNMP_ERR_NOSUCHNAME .
|
||||
For all other operations the oid in
|
||||
@ -169,18 +177,20 @@ enum snmp_op {
|
||||
.Ed
|
||||
.El
|
||||
.Pp
|
||||
The user handler must return an appropiate SNMP v2 error code. If the original
|
||||
The user handler must return an appropriate SNMP v2 error code.
|
||||
If the original
|
||||
PDU was a version 1 PDU, the error code is mapped automatically.
|
||||
.It Va flags
|
||||
Currently only the flag
|
||||
.Li SNMP_NODE_CANSET is defined and set for nodes, that can be written or
|
||||
created.
|
||||
.It Va index
|
||||
This word describes the index for table columns. Each part of the index
|
||||
takes 4 bits starting at bit 4. Bits 0 to 3 hold the number of index parts.
|
||||
This arrangment allows for tables with up to seven indexes. Each bit group
|
||||
contains the syntax for the index part. There are a number of macros to
|
||||
help in parsing this field:
|
||||
This word describes the index for table columns.
|
||||
Each part of the index takes 4 bits starting at bit 4.
|
||||
Bits 0 to 3 hold the number of index parts.
|
||||
This arrangement allows for tables with up to seven indexes.
|
||||
Each bit group contains the syntax for the index part.
|
||||
There are a number of macros to help in parsing this field:
|
||||
.Bd -literal -offset indent
|
||||
#define SNMP_INDEXES_MAX 7
|
||||
#define SNMP_INDEX_SHIFT 4
|
||||
@ -197,8 +207,9 @@ This field may contain arbitrary data and is not used by the library.
|
||||
The easiest way to construct the node table is
|
||||
.Xr gensnmptree 1 .
|
||||
Note, that one must be careful when changing the tree while executing a SET
|
||||
operation. Consult the sources for
|
||||
.Xr snmpd 1 .
|
||||
operation.
|
||||
Consult the sources for
|
||||
.Xr bsnmpd 1 .
|
||||
.Pp
|
||||
The global variable
|
||||
.Va snmp_trace
|
||||
@ -218,7 +229,8 @@ enum {
|
||||
.Pp
|
||||
Setting a bit to true causes the library to call
|
||||
.Fn snmp_debug
|
||||
in strategic places with a debug string. The library contains a default
|
||||
in strategic places with a debug string.
|
||||
The library contains a default
|
||||
implementation for the debug function that prints a message to standard error.
|
||||
.Pp
|
||||
Many of the functions use a so called context:
|
||||
@ -234,8 +246,8 @@ struct snmp_context {
|
||||
struct snmp_scratch {
|
||||
void *ptr1;
|
||||
void *ptr2;
|
||||
u_int32_t int1;
|
||||
u_int32_t int2;
|
||||
uint32_t int1;
|
||||
uint32_t int2;
|
||||
};
|
||||
.Ed
|
||||
.Pp
|
||||
@ -243,15 +255,17 @@ The fields are used as follows:
|
||||
.Bl -tag -width ".It Va var_index"
|
||||
.It Va va_index
|
||||
For the node operation callback this is the
|
||||
index of the variable binding that should be returned if an error occures.
|
||||
Set by the library. In all other functions this is undefined.
|
||||
index of the variable binding that should be returned if an error occurs.
|
||||
Set by the library.
|
||||
In all other functions this is undefined.
|
||||
.It Va scratch
|
||||
For the node operation callback this is a pointer to a per variable binding
|
||||
scratch area that can be used to implement the commit and rollback. Set
|
||||
by the library.
|
||||
scratch area that can be used to implement the commit and rollback.
|
||||
Set by the library.
|
||||
.It Va dep
|
||||
In the dependency callback function (see below) this is a pointer to the
|
||||
current dependency. Set by the library.
|
||||
current dependency.
|
||||
Set by the library.
|
||||
.It Va data
|
||||
This is the
|
||||
.Fa data
|
||||
@ -267,21 +281,24 @@ executes an SNMP GETNEXT operation and the function
|
||||
.Fn snmp_getbulk
|
||||
executes an SNMP GETBULK operation.
|
||||
For all three functions the response PDU is constructed and encoded
|
||||
on the fly. If everything is ok, the response PDU is returned in
|
||||
on the fly.
|
||||
If everything is ok, the response PDU is returned in
|
||||
.Fa resp
|
||||
and
|
||||
.Fa resp_b .
|
||||
The caller must call
|
||||
.Fn snmp_pdu_free
|
||||
to free the response PDU in this case. One of the following values may be
|
||||
returned:
|
||||
to free the response PDU in this case.
|
||||
One of the following values may be returned:
|
||||
.Bl -tag -width ".It Li SNMP_RET_ERR"
|
||||
.It Li SNMP_RET_OK
|
||||
Operation successful, response PDU may be sent.
|
||||
.It Li SNMP_RET_IGN
|
||||
Operation failed, no response PDU constructed. Request is ignored.
|
||||
Operation failed, no response PDU constructed.
|
||||
Request is ignored.
|
||||
.It Li SNMP_RET_ERR
|
||||
Error in operation. The error code and index have been set in
|
||||
Error in operation.
|
||||
The error code and index have been set in
|
||||
.Fa pdu .
|
||||
No response PDU has been constructed.
|
||||
The caller may construct an error response PDU via
|
||||
@ -290,47 +307,56 @@ The caller may construct an error response PDU via
|
||||
.Pp
|
||||
The function
|
||||
.Fn snmp_set
|
||||
executes an SNMP SET operation. The arguments are the same as for the previous
|
||||
three functions. The operation of this functions is, however, much more complex.
|
||||
executes an SNMP SET operation.
|
||||
The arguments are the same as for the previous
|
||||
three functions.
|
||||
The operation of this functions is, however, much more complex.
|
||||
.Pp
|
||||
The SET operation occures in several stages:
|
||||
The SET operation occurs in several stages:
|
||||
.Bl -enum -offset indent
|
||||
.It
|
||||
For each binding search the corresponding nodes, check that the
|
||||
variable is writeable and the syntax is ok. The writeable check can be done
|
||||
only for scalars. For columns it must be done in the node's operation callback
|
||||
function.
|
||||
variable is writeable and the syntax is ok.
|
||||
The writeable check can be done only for scalars.
|
||||
For columns it must be done in the node's operation callback function.
|
||||
.It
|
||||
For each binding call the node's operation callback with function SNMP_OP_SET.
|
||||
The callback may create dependencies or finalizers (see below). For simple
|
||||
The callback may create dependencies or finalizers (see below).
|
||||
For simple
|
||||
scalars the scratch area may be enough to handle commit and rollback, for
|
||||
interdependend table columns dependencies may be necessary.
|
||||
interdependent table columns dependencies may be necessary.
|
||||
.It
|
||||
If the previous step fails at any point, the node's operation callback
|
||||
functions are called for all bindings for which SNMP_OP_SET was executed
|
||||
with SNMP_OP_ROLLBACK, in the opposite order. This allows all variables to
|
||||
undo the effect of the SET operation. After this all the dependencies
|
||||
are freed
|
||||
and the finalizers are executed with a fail flag of 1. Then the function
|
||||
with SNMP_OP_ROLLBACK, in the opposite order.
|
||||
This allows all variables to undo the effect of the SET operation.
|
||||
After this all the dependencies are freed
|
||||
and the finalizers are executed with a fail flag of 1.
|
||||
Then the function
|
||||
returns to the caller with an appropriate error indication.
|
||||
.It
|
||||
If the SET step was successful for all bindings, the dependency callbacks
|
||||
are executed in the order in which the dependencies were created with an
|
||||
operation of SNMP_DEPOP_COMMIT. If any of the dependencies fails, all the
|
||||
operation of SNMP_DEPOP_COMMIT.
|
||||
If any of the dependencies fails, all the
|
||||
committed dependencies are called again in the opposite order
|
||||
with SNMP_DEPOP_ROLLBACK. Than for all bindings from the last to the first
|
||||
with SNMP_DEPOP_ROLLBACK.
|
||||
Than for all bindings from the last to the first
|
||||
the node's operation callback is called with SNMP_OP_ROLLBACK to undo
|
||||
the effect of SNMP_OP_SET. At the end the dependencies are freed
|
||||
and the finalizers are called with a fail flag
|
||||
of 1 and the function returns to the caller with an appropriate error indication.
|
||||
the effect of SNMP_OP_SET.
|
||||
At the end the dependencies are freed and the finalizers are called with
|
||||
a fail flag of 1 and the function returns to the caller with an appropriate
|
||||
error indication.
|
||||
.It
|
||||
If the dependency commits were successful, for each binding the node's
|
||||
operation callback is called with SNMP_OP_COMMIT. Any error returned from
|
||||
operation callback is called with SNMP_OP_COMMIT.
|
||||
Any error returned from
|
||||
the callbacks is ignored (an error message is generated via
|
||||
.Fn snmp_error ).
|
||||
.It
|
||||
Now the dependencies are freed and the finalizers are called
|
||||
with a fail flag of 0. For each dependency just before freeing it
|
||||
with a fail flag of 0.
|
||||
For each dependency just before freeing it
|
||||
its callback is called with
|
||||
.Li SNMP_DEPOP_FINISH.
|
||||
Then the function returns
|
||||
@ -338,20 +364,26 @@ Then the function returns
|
||||
.El
|
||||
.Pp
|
||||
There are to mechanisms to help in complex SET operations: dependencies and
|
||||
finalizers. A dependency is used if several bindings depend on each other.
|
||||
finalizers.
|
||||
A dependency is used if several bindings depend on each other.
|
||||
A typical example is the creation of a conceptual row, which requires
|
||||
the setting of several columns to succeed. A dependency is identified by
|
||||
two OIDs. In the table case, the first oid is typically the table's base OID
|
||||
and the second one the index. Both of these can easily be generated from the
|
||||
the setting of several columns to succeed.
|
||||
A dependency is identified by
|
||||
two OIDs.
|
||||
In the table case, the first oid is typically the table's base OID
|
||||
and the second one the index.
|
||||
Both of these can easily be generated from the
|
||||
variables OID with
|
||||
.Fn asn_slice_oid .
|
||||
The function
|
||||
.Fn snmp_dep_lookup
|
||||
tries to find a dependency based on these two OIDs and, if it cannot find one
|
||||
creates a new one. This means for the table example, that the function
|
||||
creates a new one.
|
||||
This means for the table example, that the function
|
||||
returns the same dependency for each of the columns of the same table row.
|
||||
This allows during the SNMP_OP_SET processing to collect all information
|
||||
about the row into the dependency. The arguments to
|
||||
about the row into the dependency.
|
||||
The arguments to
|
||||
.Fn snmp_dep_lookup
|
||||
are: the two OIDs to identify the dependency (they are copied into newly
|
||||
created dependencies), the size of the structure to allocate and
|
||||
@ -369,16 +401,17 @@ freed correctly.
|
||||
.Pp
|
||||
The function
|
||||
.Fn snmp_make_errresp
|
||||
makes an error response if an operation has failed. It takes the original
|
||||
request PDU (it will look only on the error code and index fields), the
|
||||
buffer containing the original PDU and a buffer for the error PDU. It copies
|
||||
the bindings field from the original PDUs buffer directly to the response
|
||||
PDU and thus does not depend on the decodability of this field. It may return
|
||||
the same values as the operation functions.
|
||||
makes an error response if an operation has failed.
|
||||
It takes the original request PDU (it will look only on the error code and
|
||||
index fields), the buffer containing the original PDU and a buffer for the
|
||||
error PDU.
|
||||
It copies the bindings field from the original PDUs buffer directly to
|
||||
the response PDU and thus does not depend on the decodability of this field.
|
||||
It may return the same values as the operation functions.
|
||||
.Pp
|
||||
The next four functions allow some parts of the SET operation to be executed.
|
||||
This is only used in
|
||||
.Xr snmpd 1
|
||||
.Xr bsnmpd 1
|
||||
to implement the configuration as a single transaction.
|
||||
The function
|
||||
.Fn snmp_init_context
|
||||
@ -395,12 +428,12 @@ The function
|
||||
.Fn snmp_dep_finish
|
||||
executes SNMP_DEPOP_FINISH for all dependencies.
|
||||
.Sh DIAGNOSTICS
|
||||
If an error occures in any of the function an error indication as described
|
||||
above is returned. Additionally the functions may call snmp_error on unexected
|
||||
errors.
|
||||
If an error occurs in any of the function an error indication as described
|
||||
above is returned.
|
||||
Additionally the functions may call snmp_error on unexpected errors.
|
||||
.Sh SEE ALSO
|
||||
.Xr gensnmptree 1 ,
|
||||
.Xr snmpd 1 ,
|
||||
.Xr bsnmpd 1 ,
|
||||
.Xr bsnmpclient 3 ,
|
||||
.Xr bsnmplib 3 ,
|
||||
.Xr snmpmod 3
|
||||
|
@ -29,9 +29,9 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Begemot: bsnmp/lib/bsnmpclient.3,v 1.9 2005/05/23 11:10:12 brandt_h Exp $
|
||||
.\" $Begemot: bsnmp/lib/bsnmpclient.3,v 1.12 2005/10/04 08:46:50 brandt_h Exp $
|
||||
.\"
|
||||
.Dd May 23, 2005
|
||||
.Dd October 4, 2005
|
||||
.Dt BSNMPCLIENT 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -104,7 +104,8 @@ Begemot SNMP library
|
||||
.Fn snmp_dialog "struct snmp_pdu *req" "struct snmp_pdu *resp"
|
||||
.Sh DESCRIPTION
|
||||
The SNMP library contains routines to easily build SNMP client applications
|
||||
that use SNMP versions 1 or 2. Most of the routines use a
|
||||
that use SNMP versions 1 or 2.
|
||||
Most of the routines use a
|
||||
.Vt struct snmp_client :
|
||||
.Bd -literal -offset indent
|
||||
struct snmp_client {
|
||||
@ -145,9 +146,11 @@ struct snmp_client {
|
||||
The fields of this structure are described below.
|
||||
.Bl -tag -width "timeout_start"
|
||||
.It Va version
|
||||
This is the version of SNMP to use. See
|
||||
This is the version of SNMP to use.
|
||||
See
|
||||
.Xr bsnmplib 3
|
||||
for applicable values. The default version is
|
||||
for applicable values.
|
||||
The default version is
|
||||
.Li SNMP_V2c .
|
||||
.It Va trans
|
||||
If this is
|
||||
@ -163,12 +166,14 @@ It uses the
|
||||
.Va chost
|
||||
field as the path to the server's socket for local sockets.
|
||||
.It Va cport
|
||||
The SNMP agent's UDP port number. This may be a symbolic port number (from
|
||||
.Pa /etc/services
|
||||
or a numeric port number. If this field is
|
||||
The SNMP agent's UDP port number.
|
||||
This may be a symbolic port number (from
|
||||
.Pa /etc/services )
|
||||
or a numeric port number.
|
||||
If this field is
|
||||
.Li NULL
|
||||
(the default) the standard SNMP port is used. This field should not be changed
|
||||
directly but rather by calling
|
||||
(the default) the standard SNMP port is used.
|
||||
This field should not be changed directly but rather by calling
|
||||
.Fn snmp_client_set_port .
|
||||
.It Va chost
|
||||
The SNMP agent's host name, IP address or
|
||||
@ -178,46 +183,52 @@ If this is
|
||||
.Li NULL
|
||||
(the default)
|
||||
.Li localhost
|
||||
is assumed. This field should not be changed directly but rather through
|
||||
calling
|
||||
is assumed.
|
||||
This field should not be changed directly but rather through calling
|
||||
.Fn snmp_client_set_host .
|
||||
.It Va read_community
|
||||
This is the community name to be used for all requests except SET requests.
|
||||
The default is
|
||||
.Sq public .
|
||||
.It Va write_community
|
||||
The community name to be used for SET requests. The default is
|
||||
The community name to be used for SET requests.
|
||||
The default is
|
||||
.Sq private .
|
||||
.It Va timeout
|
||||
The maximum time to wait for responses to requests. If the time elapses, the
|
||||
request is resent up to
|
||||
The maximum time to wait for responses to requests.
|
||||
If the time elapses, the request is resent up to
|
||||
.Va retries
|
||||
times. The default is 3 seconds.
|
||||
times.
|
||||
The default is 3 seconds.
|
||||
.It Va retries
|
||||
Number of times a request PDU is to be resent. If set to 0, the request is
|
||||
sent only once. The default is 3 retransmissions.
|
||||
Number of times a request PDU is to be resent.
|
||||
If set to 0, the request is sent only once.
|
||||
The default is 3 retransmissions.
|
||||
.It Va dump_pdus
|
||||
If set to a non-zero value all received and sent PDUs are dumped via
|
||||
.Xr snmp_pdu_dump 3 .
|
||||
The default is not to dump PDUs.
|
||||
.It Va txbuflen
|
||||
The encoding buffer size to be allocated for transmitted PDUs. The default is
|
||||
10000 octets.
|
||||
The encoding buffer size to be allocated for transmitted PDUs.
|
||||
The default is 10000 octets.
|
||||
.It Va rxbuflen
|
||||
The decoding buffer size to be allocated for received PDUs. This is the size
|
||||
of the maximum PDU that can be received. The default is 10000 octets.
|
||||
The decoding buffer size to be allocated for received PDUs.
|
||||
This is the size of the maximum PDU that can be received.
|
||||
The default is 10000 octets.
|
||||
.It Va fd
|
||||
After calling
|
||||
.Fn snmp_open
|
||||
this is the file socket file descriptor used for sending and receiving PDUs.
|
||||
.It Va next_reqid
|
||||
The request id of the next PDU to send. Used internal by the library.
|
||||
The request id of the next PDU to send.
|
||||
Used internal by the library.
|
||||
.It Va max_reqid
|
||||
The maximum request id to use for outging PDUs. The default is
|
||||
The maximum request id to use for outgoing PDUs.
|
||||
The default is
|
||||
.Li INT32_MAX .
|
||||
.It Va min_reqid
|
||||
The minimum request id to use for outgoing PDUs. Request ids are allocated
|
||||
linerily starting at
|
||||
The minimum request id to use for outgoing PDUs.
|
||||
Request ids are allocated linearily starting at
|
||||
.Va min_reqid
|
||||
up to
|
||||
.Va max_reqid .
|
||||
@ -225,29 +236,30 @@ up to
|
||||
If an error happens, this field is set to a printable string describing the
|
||||
error.
|
||||
.It Va timeout_start
|
||||
This field must point to a function setting up a one shot timeout. After the
|
||||
timeout has elapsed, the given callback function must be called with the
|
||||
user argument. The
|
||||
This field must point to a function setting up a one shot timeout.
|
||||
After the timeout has elapsed, the given callback function must be called
|
||||
with the user argument.
|
||||
The
|
||||
.Fn timeout_start
|
||||
function must return a
|
||||
.Vt void *
|
||||
identifying the timeout.
|
||||
.It Va timeout_stop
|
||||
This field must be set to a function that stops a running timeout. The function
|
||||
will be called with the return value of the corresponding
|
||||
This field must be set to a function that stops a running timeout.
|
||||
The function will be called with the return value of the corresponding
|
||||
.Fn timeout_start
|
||||
function.
|
||||
.It Va local_path
|
||||
If in local socket mode, the name of the clients socket. Not needed by the
|
||||
application.
|
||||
If in local socket mode, the name of the clients socket.
|
||||
Not needed by the application.
|
||||
.El
|
||||
.Pp
|
||||
In the current implementation there is a global variable
|
||||
.Pp
|
||||
.D1 Vt extern struct snmp_client snmp_client ;
|
||||
.Pp
|
||||
that is used by all the library functions. The first call into the library must
|
||||
be a call to
|
||||
that is used by all the library functions.
|
||||
The first call into the library must be a call to
|
||||
.Fn snmp_client_init
|
||||
to initialize this global variable to the default values.
|
||||
After this call and before calling
|
||||
@ -271,23 +283,26 @@ If any of the arguments of the call is not
|
||||
.Li NULL
|
||||
the corresponding field in the global
|
||||
.Va snmp_client
|
||||
is set from the argument. Otherwise the values that are already in that variable
|
||||
are used.
|
||||
is set from the argument.
|
||||
Otherwise the values that are already in that variable are used.
|
||||
The function
|
||||
.Fn snmp_close
|
||||
closes the socket, stops all timeouts and frees all dynamically allocated
|
||||
resources.
|
||||
.Pp
|
||||
The next three functions are used to create request PDUs. The function
|
||||
The next three functions are used to create request PDUs.
|
||||
The function
|
||||
.Fn snmp_pdu_create
|
||||
initializes a PDU of type
|
||||
.Va op .
|
||||
It does not allocate space for the PDU itself. This is the responsibility of
|
||||
the caller.
|
||||
It does not allocate space for the PDU itself.
|
||||
This is the responsibility of the caller.
|
||||
.Fn snmp_add_binding
|
||||
adds bindings to the PDU and returns the (zero based) index of the first new
|
||||
binding. The arguments are pairs of pointer to the OIDs and syntax constants,
|
||||
terminated by a NULL. The call
|
||||
binding.
|
||||
The arguments are pairs of pointer to the OIDs and syntax constants,
|
||||
terminated by a NULL.
|
||||
The call
|
||||
.Bd -literal -offset indent
|
||||
snmp_add_binding(&pdu,
|
||||
&oid1, SNMP_SYNTAX_INTEGER,
|
||||
@ -297,15 +312,16 @@ snmp_add_binding(&pdu,
|
||||
.Pp
|
||||
adds two new bindings to the PDU and returns the index of the first one.
|
||||
It is the responsibility of the caller to set the value part of the binding
|
||||
if neccesary. The functions returns -1 if the maximum number of bindings
|
||||
is exhausted.
|
||||
if necessary.
|
||||
The functions returns -1 if the maximum number of bindings is exhausted.
|
||||
The function
|
||||
.Fn snmp_oid_append
|
||||
can be used to construct variable OIDs for requests. It takes a pointer
|
||||
to an
|
||||
can be used to construct variable OIDs for requests.
|
||||
It takes a pointer to an
|
||||
.Vt struct asn_oid
|
||||
that is to be constructed, a format string, and a number of arguments
|
||||
the type of which depends on the format string. The format string is interpreted
|
||||
the type of which depends on the format string.
|
||||
The format string is interpreted
|
||||
character by character in the following way:
|
||||
.Bl -tag -width ".It Li ( Va N Ns Li )"
|
||||
.It Li i
|
||||
@ -332,7 +348,8 @@ This format expects an argument of type
|
||||
.Vt const char *
|
||||
and appends
|
||||
.Va size
|
||||
characters from the string to the OID. The string may contain
|
||||
characters from the string to the OID.
|
||||
The string may contain
|
||||
.Li NUL
|
||||
characters.
|
||||
.It Li c
|
||||
@ -346,7 +363,8 @@ pointed to by the second argument.
|
||||
.Pp
|
||||
The function
|
||||
.Fn snmp_pdu_check
|
||||
may be used to check a response PDU. A number of checks are performed
|
||||
may be used to check a response PDU.
|
||||
A number of checks are performed
|
||||
(error code, equal number of bindings, syntaxes and values for SET PDUs).
|
||||
The function returns +1 if everything is ok, 0 if a NOSUCHNAME or similar
|
||||
error was detected, -1 if the response PDU had fatal errors
|
||||
@ -354,38 +372,43 @@ and -2 if
|
||||
.Fa resp
|
||||
is
|
||||
.Li NULL
|
||||
(a timeout occured).
|
||||
(a timeout occurred).
|
||||
.Pp
|
||||
The function
|
||||
.Fn snmp_pdu_send
|
||||
encodes and sends the given PDU. It records the PDU together with the callback
|
||||
encodes and sends the given PDU.
|
||||
It records the PDU together with the callback
|
||||
and user pointers in an internal list and arranges for retransmission if no
|
||||
response is received. When a response is received or the retransmission count
|
||||
response is received.
|
||||
When a response is received or the retransmission count
|
||||
is exceeded the callback
|
||||
.Fa func
|
||||
is called with the orignal request PDU, the response PDU and the user argument
|
||||
.Fa uarg .
|
||||
If the retransmit count is exceeded,
|
||||
.Fa func
|
||||
is called with the original request PDU, the reponse pointer set to
|
||||
is called with the original request PDU, the response pointer set to
|
||||
.Li NULL
|
||||
and the user argument
|
||||
.Fa uarg .
|
||||
The caller should not free the request PDU until the callback function is
|
||||
called. The callback function must free the request PDU and the response
|
||||
PDU (if not
|
||||
called.
|
||||
The callback function must free the request PDU and the response PDU (if not
|
||||
.Li NULL ).
|
||||
.Pp
|
||||
The function
|
||||
.Fn snmp_receive
|
||||
tries to receive a PDU. If the argument is zero, the function polls to see
|
||||
tries to receive a PDU.
|
||||
If the argument is zero, the function polls to see
|
||||
whether a packet is available, if the argument is non-zero, the function blocks
|
||||
until the next packet is received. The packet is delivered via the usual callback
|
||||
until the next packet is received.
|
||||
The packet is delivered via the usual callback
|
||||
mechanism (non-response packets are silently dropped).
|
||||
The function returns 0, if a packet was received and successfully dispatched,
|
||||
-1 if an error occured or no packet was available (in polling mode).
|
||||
-1 if an error occurred or no packet was available (in polling mode).
|
||||
.Pp
|
||||
The next two functions are used to retrieve tables from SNMP agents. The use
|
||||
The next two functions are used to retrieve tables from SNMP agents.
|
||||
They use
|
||||
the following input structure, that describes the table:
|
||||
.Bd -literal -offset indent
|
||||
struct snmp_table {
|
||||
@ -394,7 +417,7 @@ struct snmp_table {
|
||||
u_int max_iter;
|
||||
size_t entry_size;
|
||||
u_int index_size;
|
||||
u_int64_t req_mask;
|
||||
uint64_t req_mask;
|
||||
|
||||
struct snmp_table_entry {
|
||||
asn_subid_t subid;
|
||||
@ -410,15 +433,17 @@ The fields of this structure have the following meaning:
|
||||
This is the base OID of the table.
|
||||
.It Va last_change
|
||||
Some tables have a scalar variable of type TIMETICKS attached to them,
|
||||
that holds the time when the table was last changed. This OID should be
|
||||
the OID of this variable (without the \&.0 index). When the table is retrieved
|
||||
that holds the time when the table was last changed.
|
||||
This OID should be the OID of this variable (without the \&.0 index).
|
||||
When the table is retrieved
|
||||
with multiple GET requests, and the variable changes between two request,
|
||||
the table fetch is restarted.
|
||||
.It Va max_iter
|
||||
Maximum number of tries to fetch the table.
|
||||
.It Va entry_size
|
||||
The table fetching routines return a list of structure one for each table
|
||||
row. This variable is the size of one structure and used to
|
||||
The table fetching routines return a list of structures one for each table
|
||||
row.
|
||||
This variable is the size of one structure and used to
|
||||
.Xr malloc 3
|
||||
the structure.
|
||||
.It Va index_size
|
||||
@ -427,19 +452,22 @@ This is the number of index columns in the table.
|
||||
This is a bit mask with a 1 for each table column that is required.
|
||||
Bit 0 corresponds to the first element (index 0) in the array
|
||||
.Va entries ,
|
||||
bit 1 to the second (index 1) and so on. SNMP tables may be sparse. For sparse
|
||||
columns the bit should not be set. If the bit for a given column is set and
|
||||
bit 1 to the second (index 1) and so on.
|
||||
SNMP tables may be sparse.
|
||||
For sparse columns the bit should not be set.
|
||||
If the bit for a given column is set and
|
||||
the column value cannot be retrieved for a given row, the table fetch is
|
||||
restarted assuming that the table is currently beeing modified by the agent.
|
||||
restarted assuming that the table is currently being modified by the agent.
|
||||
The bits for the index columns are ignored.
|
||||
.It Va entries
|
||||
This is a variable sized array of column descriptors. This array is terminated
|
||||
by an element with syntax
|
||||
This is a variable sized array of column descriptors.
|
||||
This array is terminated by an element with syntax
|
||||
.Li SNMP_SYNTAX_NULL .
|
||||
The first
|
||||
.Va index_size
|
||||
elements describe all the index columns of the table, the rest are normal
|
||||
columns. If for a the column at
|
||||
columns.
|
||||
If for the column at
|
||||
.Ql entries[N]
|
||||
the expression
|
||||
.Ql req_mask & (1 << N)
|
||||
@ -447,12 +475,14 @@ yields true, the column is considered a required column.
|
||||
The fields of this the array elements have the following meaning:
|
||||
.Bl -tag -width "syntax"
|
||||
.It Va subid
|
||||
This is the OID subid of the column. This is ignored for index entries. Index
|
||||
entries are decoded according to the
|
||||
This is the OID subid of the column.
|
||||
This is ignored for index entries.
|
||||
Index entries are decoded according to the
|
||||
.Va syntax
|
||||
field.
|
||||
.It Va syntax
|
||||
This is the syntax of the column or index. A syntax of
|
||||
This is the syntax of the column or index.
|
||||
A syntax of
|
||||
.Li SNMP_SYNTAX_NULL
|
||||
terminates the array.
|
||||
.It Va offset
|
||||
@ -465,10 +495,11 @@ macro.
|
||||
.Pp
|
||||
Both table fetching functions return TAILQ (see
|
||||
.Xr queue 3 )
|
||||
of structures--one for each table row. These structures must start with a
|
||||
of structures--one for each table row.
|
||||
These structures must start with a
|
||||
.Fn TAILQ_ENTRY
|
||||
and a
|
||||
.Vt u_int64_t
|
||||
.Vt uint64_t
|
||||
and are allocated via
|
||||
.Xr malloc 3 .
|
||||
The
|
||||
@ -476,29 +507,33 @@ The
|
||||
argument of the table functions must point to a
|
||||
.Fn TAILQ_HEAD .
|
||||
The
|
||||
.Vt u_int64_t
|
||||
.Vt uint64_t
|
||||
fields, usually called
|
||||
.Va found
|
||||
is used to indicate which of the columns have been found for the given
|
||||
row. It is encoded like the
|
||||
row.
|
||||
It is encoded like the
|
||||
.Fa req_mask
|
||||
field.
|
||||
.Pp
|
||||
The function
|
||||
.Fn snmp_table_fetch
|
||||
synchronuosly fetches the given table. If everything is ok 0 is returned.
|
||||
synchronously fetches the given table.
|
||||
If everything is ok 0 is returned.
|
||||
Otherwise the function returns -1 and sets an appropriate error string.
|
||||
The function
|
||||
.Fn snmp_table_fetch_async
|
||||
fetches the tables asynchronuosly. If either the entire table is fetch, or
|
||||
an error occures the callback function
|
||||
fetches the tables asynchronously.
|
||||
If either the entire table is fetch, or
|
||||
an error occurs the callback function
|
||||
.Fa callback
|
||||
is called with the callers arguments
|
||||
.Fa list
|
||||
and
|
||||
.Fa uarg
|
||||
and a parameter that is either 0 if the table was fetched, or
|
||||
-1 if there was an error. The function itself returns -1 if it could not
|
||||
-1 if there was an error.
|
||||
The function itself returns -1 if it could not
|
||||
initialize fetching of the table.
|
||||
.Pp
|
||||
The following table description is used to fetch the ATM interface table:
|
||||
@ -508,17 +543,17 @@ The following table description is used to fetch the ATM interface table:
|
||||
*/
|
||||
struct atmif {
|
||||
TAILQ_ENTRY(atmif) link;
|
||||
u_int64_t found;
|
||||
uint64_t found;
|
||||
int32_t index;
|
||||
u_char *ifname;
|
||||
size_t ifnamelen;
|
||||
u_int32_t node_id;
|
||||
u_int32_t pcr;
|
||||
uint32_t node_id;
|
||||
uint32_t pcr;
|
||||
int32_t media;
|
||||
u_int32_t vpi_bits;
|
||||
u_int32_t vci_bits;
|
||||
u_int32_t max_vpcs;
|
||||
u_int32_t max_vccs;
|
||||
uint32_t vpi_bits;
|
||||
uint32_t vci_bits;
|
||||
uint32_t max_vpcs;
|
||||
uint32_t max_vccs;
|
||||
u_char *esi;
|
||||
size_t esilen;
|
||||
int32_t carrier;
|
||||
@ -568,15 +603,18 @@ static const struct snmp_table atmif_table = {
|
||||
.Pp
|
||||
The function
|
||||
.Fn snmp_dialog
|
||||
is used to execute a synchonuous dialog with the agent. The request PDU
|
||||
is used to execute a synchonuous dialog with the agent.
|
||||
The request PDU
|
||||
.Fa req
|
||||
is sent and the function blocks until the response PDU is received. Note,
|
||||
is sent and the function blocks until the response PDU is received.
|
||||
Note,
|
||||
that asynchonuous receives are handled (i.e. callback functions of other send
|
||||
calls or table fetches may be called while in the function). The response
|
||||
PDU is returned in
|
||||
calls or table fetches may be called while in the function).
|
||||
The response PDU is returned in
|
||||
.Fa resp .
|
||||
If no reponse could be received after all timeouts and retries, the function
|
||||
returns -1. If a response was received 0 is returned.
|
||||
If no response could be received after all timeouts and retries, the function
|
||||
returns -1.
|
||||
If a response was received 0 is returned.
|
||||
.Pp
|
||||
The function
|
||||
.Fn snmp_parse_server
|
||||
@ -600,15 +638,16 @@ is the port in case of UDP transport.
|
||||
The function returns 0 in the case of success and return -1 and sets
|
||||
the error string in case of an error.
|
||||
.Sh DIAGNOSTICS
|
||||
If an error occures in any of the function an error indication as described
|
||||
above is returned. Additionally the function sets a printable error string
|
||||
If an error occurs in any of the function an error indication as described
|
||||
above is returned.
|
||||
Additionally the function sets a printable error string
|
||||
in the
|
||||
.Va error
|
||||
filed of
|
||||
.Va snmp_client .
|
||||
.Sh SEE ALSO
|
||||
.Xr gensnmptree 1 ,
|
||||
.Xr snmpd 1 ,
|
||||
.Xr bsnmpd 1 ,
|
||||
.Xr bsnmpagent 3 ,
|
||||
.Xr bsnmplib 3
|
||||
.Sh STANDARDS
|
||||
|
@ -1,4 +1,7 @@
|
||||
.\"
|
||||
.\" Copyright (c) 2004-2005
|
||||
.\" Hartmut Brandt.
|
||||
.\" All rights reserved.
|
||||
.\" Copyright (c) 2001-2003
|
||||
.\" Fraunhofer Institute for Open Communication Systems (FhG Fokus).
|
||||
.\" All rights reserved.
|
||||
@ -26,9 +29,9 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Begemot: bsnmp/lib/bsnmplib.3,v 1.6 2005/02/25 11:55:59 brandt_h Exp $
|
||||
.\" $Begemot: bsnmp/lib/bsnmplib.3,v 1.9 2005/10/04 08:46:51 brandt_h Exp $
|
||||
.\"
|
||||
.Dd August 15, 2002
|
||||
.Dd October 4, 2005
|
||||
.Dt BSNMPLIB 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -84,15 +87,15 @@ struct snmp_value {
|
||||
} octetstring;
|
||||
struct asn_oid oid;
|
||||
u_char ipaddress[4];
|
||||
u_int32_t uint32; /* also gauge32, counter32,
|
||||
uint32_t uint32; /* also gauge32, counter32,
|
||||
unsigned32, timeticks */
|
||||
u_int64_t counter64;
|
||||
uint64_t counter64;
|
||||
} v;
|
||||
};
|
||||
.Ed
|
||||
.Pp
|
||||
This structure represents one variable binding from an SNMP PDU. The
|
||||
field
|
||||
This structure represents one variable binding from an SNMP PDU.
|
||||
The field
|
||||
.Fa var
|
||||
is the ASN.1 of the variable that is bound.
|
||||
.Fa syntax
|
||||
@ -178,8 +181,8 @@ is the type of the PDU.
|
||||
.Pp
|
||||
The function
|
||||
.Fn snmp_value_free
|
||||
is used to free all the dynamic allocated contents of an SNMP value. It does
|
||||
not free the structure pointed to by
|
||||
is used to free all the dynamic allocated contents of an SNMP value.
|
||||
It does not free the structure pointed to by
|
||||
.Fa value
|
||||
itself.
|
||||
.Pp
|
||||
@ -187,7 +190,7 @@ The function
|
||||
.Fn snmp_value_parse
|
||||
parses the ASCII representation of an SNMP value into its binary form.
|
||||
This function is mainly used by the configuration file reader of
|
||||
.Xr snmpd 1 .
|
||||
.Xr bsnmpd 1 .
|
||||
.Pp
|
||||
The function
|
||||
.Fn snmp_value_copy
|
||||
@ -197,14 +200,14 @@ to the structure pointed to by
|
||||
.Fa to .
|
||||
It assumes that
|
||||
.Fa to
|
||||
is uninitialized and will overwrite its previous contents. It does not itself
|
||||
allocate the structure pointed to by
|
||||
is uninitialized and will overwrite its previous contents.
|
||||
It does not itself allocate the structure pointed to by
|
||||
.Fa to .
|
||||
.Pp
|
||||
The function
|
||||
.Fn snmp_pdu_free
|
||||
frees all the dynamically allocated components of the PDU. It does not itself
|
||||
free the structure pointed to by
|
||||
frees all the dynamically allocated components of the PDU.
|
||||
It does not itself free the structure pointed to by
|
||||
.Fa pdu .
|
||||
.Pp
|
||||
The function
|
||||
@ -239,7 +242,7 @@ The function
|
||||
.Fn TRUTH_OK
|
||||
checks, whether its argument is a legal SNMP truth value.
|
||||
.Sh DIAGNOSTICS
|
||||
When an error occures in any of the function the function pointed to
|
||||
When an error occurs in any of the function the function pointed to
|
||||
by the global pointer
|
||||
.Bd -literal -offset indent
|
||||
extern void (*snmp_error)(const char *, ...);
|
||||
@ -291,7 +294,7 @@ Encoding failed.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr gensnmptree 1 ,
|
||||
.Xr snmpd 1 ,
|
||||
.Xr bsnmpd 1 ,
|
||||
.Xr bsnmpagent 3 ,
|
||||
.Xr bsnmpclient 3 ,
|
||||
.Xr bsnmplib 3
|
||||
|
@ -26,7 +26,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Begemot: bsnmp/lib/snmp.c,v 1.38 2004/08/06 08:46:53 brandt Exp $
|
||||
* $Begemot: bsnmp/lib/snmp.c,v 1.40 2005/10/04 14:32:42 brandt_h Exp $
|
||||
*
|
||||
* SNMP
|
||||
*/
|
||||
@ -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>
|
||||
|
@ -26,7 +26,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Begemot: bsnmp/lib/snmpagent.c,v 1.19 2004/08/19 17:09:09 brandt Exp $
|
||||
* $Begemot: bsnmp/lib/snmpagent.c,v 1.20 2005/10/04 11:21:33 brandt_h Exp $
|
||||
*
|
||||
* SNMP Agent functions
|
||||
*/
|
||||
@ -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"
|
||||
|
@ -30,7 +30,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Begemot: bsnmp/lib/snmpclient.c,v 1.31 2005/05/23 11:10:13 brandt_h Exp $
|
||||
* $Begemot: bsnmp/lib/snmpclient.c,v 1.34 2005/10/04 14:32:42 brandt_h Exp $
|
||||
*
|
||||
* Support functions for SNMP clients.
|
||||
*/
|
||||
@ -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>
|
||||
@ -549,7 +553,7 @@ table_check_cons(struct tabwork *work)
|
||||
|
||||
/*
|
||||
* Fetch a table. Returns 0 if ok, -1 on errors.
|
||||
* This is the synchronuous variant.
|
||||
* This is the synchronous variant.
|
||||
*/
|
||||
int
|
||||
snmp_table_fetch(const struct snmp_table *descr, void *list)
|
||||
@ -1561,7 +1565,7 @@ ok_get(const struct snmp_pdu * req, const struct snmp_pdu * resp)
|
||||
}
|
||||
|
||||
/*
|
||||
* Check the reponse to a SET PDU. We check: - the error status must be 0 -
|
||||
* Check the response to a SET PDU. We check: - the error status must be 0 -
|
||||
* the number of bindings must be equal in response and request - the
|
||||
* syntaxes must be the same in response and request - the OIDs must be the
|
||||
* same in response and request
|
||||
|
@ -26,7 +26,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Begemot: bsnmp/snmp_mibII/mibII.c,v 1.22 2005/05/23 09:03:37 brandt_h Exp $
|
||||
* $Begemot: bsnmp/snmp_mibII/mibII.c,v 1.23 2005/06/09 12:36:52 brandt_h Exp $
|
||||
*
|
||||
* Implementation of the standard interfaces and ip MIB.
|
||||
*/
|
||||
@ -941,6 +941,10 @@ handle_rtmsg(struct rt_msghdr *rtm)
|
||||
process_arp(rtm,
|
||||
(struct sockaddr_dl *)(void *)addrs[RTAX_GATEWAY],
|
||||
(struct sockaddr_in *)(void *)addrs[RTAX_DST]);
|
||||
} else {
|
||||
if (rtm->rtm_errno == 0 && (rtm->rtm_flags & RTF_UP))
|
||||
mib_sroute_process(rtm, addrs[RTAX_GATEWAY],
|
||||
addrs[RTAX_DST], addrs[RTAX_NETMASK]);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -955,11 +959,70 @@ handle_rtmsg(struct rt_msghdr *rtm)
|
||||
process_arp(rtm,
|
||||
(struct sockaddr_dl *)(void *)addrs[RTAX_GATEWAY],
|
||||
(struct sockaddr_in *)(void *)addrs[RTAX_DST]);
|
||||
} else {
|
||||
if (rtm->rtm_errno == 0 && (rtm->rtm_flags & RTF_UP))
|
||||
mib_sroute_process(rtm, addrs[RTAX_GATEWAY],
|
||||
addrs[RTAX_DST], addrs[RTAX_NETMASK]);
|
||||
}
|
||||
break;
|
||||
|
||||
case RTM_DELETE:
|
||||
mib_extract_addrs(rtm->rtm_addrs, (u_char *)(rtm + 1), addrs);
|
||||
if (rtm->rtm_errno == 0 && !(rtm->rtm_flags & RTF_LLINFO))
|
||||
mib_sroute_process(rtm, addrs[RTAX_GATEWAY],
|
||||
addrs[RTAX_DST], addrs[RTAX_NETMASK]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* send a routing message
|
||||
*/
|
||||
void
|
||||
mib_send_rtmsg(struct rt_msghdr *rtm, struct sockaddr *gw,
|
||||
struct sockaddr *dst, struct sockaddr *mask)
|
||||
{
|
||||
size_t len;
|
||||
struct rt_msghdr *msg;
|
||||
char *cp;
|
||||
ssize_t sent;
|
||||
|
||||
len = sizeof(*rtm) + SA_SIZE(gw) + SA_SIZE(dst) + SA_SIZE(mask);
|
||||
if ((msg = malloc(len)) == NULL) {
|
||||
syslog(LOG_ERR, "%s: %m", __func__);
|
||||
return;
|
||||
}
|
||||
cp = (char *)(msg + 1);
|
||||
|
||||
memset(msg, 0, sizeof(*msg));
|
||||
msg->rtm_flags = 0;
|
||||
msg->rtm_version = RTM_VERSION;
|
||||
msg->rtm_addrs = RTA_DST | RTA_GATEWAY;
|
||||
|
||||
memcpy(cp, dst, SA_SIZE(dst));
|
||||
cp += SA_SIZE(dst);
|
||||
memcpy(cp, gw, SA_SIZE(gw));
|
||||
cp += SA_SIZE(gw);
|
||||
if (mask != NULL) {
|
||||
memcpy(cp, mask, SA_SIZE(mask));
|
||||
cp += SA_SIZE(mask);
|
||||
msg->rtm_addrs |= RTA_NETMASK;
|
||||
}
|
||||
msg->rtm_msglen = cp - (char *)msg;
|
||||
msg->rtm_type = RTM_GET;
|
||||
if ((sent = write(route, msg, msg->rtm_msglen)) == -1) {
|
||||
syslog(LOG_ERR, "%s: write: %m", __func__);
|
||||
free(msg);
|
||||
return;
|
||||
}
|
||||
if (sent != msg->rtm_msglen) {
|
||||
syslog(LOG_ERR, "%s: short write", __func__);
|
||||
free(msg);
|
||||
return;
|
||||
}
|
||||
free(msg);
|
||||
}
|
||||
|
||||
/*
|
||||
* Fetch the routing table via sysctl
|
||||
*/
|
||||
@ -1428,6 +1491,7 @@ mibII_start(void)
|
||||
mib_refresh_iflist();
|
||||
update_ifa_info();
|
||||
mib_arp_update();
|
||||
(void)mib_fetch_route();
|
||||
mib_iftable_last_change = 0;
|
||||
mib_ifstack_last_change = 0;
|
||||
|
||||
@ -1474,7 +1538,6 @@ mibII_init(struct lmodule *mod, int argc __unused, char *argv[] __unused)
|
||||
syslog(LOG_ERR, "PF_ROUTE: %m");
|
||||
return (-1);
|
||||
}
|
||||
(void)shutdown(route, SHUT_WR);
|
||||
|
||||
if ((mib_netsock = socket(PF_INET, SOCK_DGRAM, 0)) == -1) {
|
||||
syslog(LOG_ERR, "PF_INET: %m");
|
||||
|
@ -26,7 +26,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Begemot: bsnmp/snmp_mibII/mibII.h,v 1.14 2005/05/23 09:03:38 brandt_h Exp $
|
||||
* $Begemot: bsnmp/snmp_mibII/mibII.h,v 1.15 2005/06/09 12:36:53 brandt_h Exp $
|
||||
*
|
||||
* Implementation of the interfaces and IP groups of MIB-II.
|
||||
*/
|
||||
@ -230,5 +230,16 @@ void mib_arp_update(void);
|
||||
/* fetch routing table */
|
||||
u_char *mib_fetch_rtab(int af, int info, int arg, size_t *lenp);
|
||||
|
||||
/* process routing message */
|
||||
void mib_sroute_process(struct rt_msghdr *, struct sockaddr *,
|
||||
struct sockaddr *, struct sockaddr *);
|
||||
|
||||
/* send a routing message */
|
||||
void mib_send_rtmsg(struct rt_msghdr *, struct sockaddr *,
|
||||
struct sockaddr *, struct sockaddr *);
|
||||
|
||||
/* extract addresses from routing message */
|
||||
void mib_extract_addrs(int, u_char *, struct sockaddr **);
|
||||
|
||||
/* fetch routing table */
|
||||
int mib_fetch_route(void);
|
||||
|
@ -26,7 +26,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Begemot: bsnmp/snmp_mibII/mibII_ipaddr.c,v 1.9 2004/08/06 08:47:02 brandt Exp $
|
||||
* $Begemot: bsnmp/snmp_mibII/mibII_ipaddr.c,v 1.10 2005/10/04 11:21:35 brandt_h Exp $
|
||||
*
|
||||
* IP address table. This table is writeable!
|
||||
*
|
||||
@ -84,10 +84,13 @@ create(struct update *upd)
|
||||
}
|
||||
|
||||
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)
|
||||
if ((ifa = mib_create_ifa(upd->ifindex, upd->addr, upd->mask, bcast))
|
||||
== NULL)
|
||||
return (SNMP_ERR_GENERR);
|
||||
|
||||
upd->rb |= RB_CREATE;
|
||||
|
@ -26,41 +26,218 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Begemot: bsnmp/snmp_mibII/mibII_route.c,v 1.6 2005/05/23 09:03:41 brandt_h Exp $
|
||||
* $Begemot: bsnmp/snmp_mibII/mibII_route.c,v 1.7 2005/06/09 12:36:53 brandt_h Exp $
|
||||
*
|
||||
* Routing table
|
||||
*/
|
||||
#include <sys/tree.h>
|
||||
#include "mibII.h"
|
||||
#include "mibII_oid.h"
|
||||
|
||||
struct sroute {
|
||||
TAILQ_ENTRY(sroute) link;
|
||||
struct asn_oid index;
|
||||
u_int ifindex;
|
||||
u_int type;
|
||||
u_int proto;
|
||||
RB_ENTRY(sroute) link;
|
||||
uint32_t ifindex;
|
||||
uint8_t index[13];
|
||||
uint8_t type;
|
||||
uint8_t proto;
|
||||
};
|
||||
static TAILQ_HEAD(, sroute) sroute_list = TAILQ_HEAD_INITIALIZER(sroute_list);
|
||||
RB_HEAD(sroutes, sroute) sroutes = RB_INITIALIZER(&sroutes);
|
||||
|
||||
RB_PROTOTYPE(sroutes, sroute, link, sroute_compare);
|
||||
|
||||
#define ROUTE_UPDATE_INTERVAL (100 * 60 * 10) /* 10 min */
|
||||
static uint64_t route_tick;
|
||||
static u_int route_total;
|
||||
|
||||
/*
|
||||
* Compare two routes
|
||||
*/
|
||||
static int
|
||||
fetch_route(void)
|
||||
sroute_compare(struct sroute *s1, struct sroute *s2)
|
||||
{
|
||||
|
||||
return (memcmp(s1->index, s2->index, 13));
|
||||
}
|
||||
|
||||
static void
|
||||
sroute_index_append(struct asn_oid *oid, u_int sub, const struct sroute *s)
|
||||
{
|
||||
int i;
|
||||
|
||||
oid->len = sub + 13;
|
||||
for (i = 0; i < 13; i++)
|
||||
oid->subs[sub + i] = s->index[i];
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void
|
||||
sroute_print(const struct sroute *r)
|
||||
{
|
||||
u_int i;
|
||||
|
||||
for (i = 0; i < 13 - 1; i++)
|
||||
printf("%u.", r->index[i]);
|
||||
printf("%u proto=%u type=%u", r->index[i], r->proto, r->type);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* process routing message
|
||||
*/
|
||||
void
|
||||
mib_sroute_process(struct rt_msghdr *rtm, struct sockaddr *gw,
|
||||
struct sockaddr *dst, struct sockaddr *mask)
|
||||
{
|
||||
struct sockaddr_in *in_dst, *in_gw;
|
||||
struct in_addr in_mask;
|
||||
struct mibif *ifp;
|
||||
struct sroute key;
|
||||
struct sroute *r, *r1;
|
||||
in_addr_t ha;
|
||||
|
||||
if (dst == NULL || gw == NULL || dst->sa_family != AF_INET ||
|
||||
gw->sa_family != AF_INET)
|
||||
return;
|
||||
|
||||
in_dst = (struct sockaddr_in *)(void *)dst;
|
||||
in_gw = (struct sockaddr_in *)(void *)gw;
|
||||
|
||||
if (rtm->rtm_flags & RTF_HOST)
|
||||
in_mask.s_addr = 0xffffffff;
|
||||
else if (mask == NULL || mask->sa_len == 0)
|
||||
in_mask.s_addr = 0;
|
||||
else
|
||||
in_mask = ((struct sockaddr_in *)(void *)mask)->sin_addr;
|
||||
|
||||
/* build the index */
|
||||
ha = ntohl(in_dst->sin_addr.s_addr);
|
||||
key.index[0] = (ha >> 24) & 0xff;
|
||||
key.index[1] = (ha >> 16) & 0xff;
|
||||
key.index[2] = (ha >> 8) & 0xff;
|
||||
key.index[3] = (ha >> 0) & 0xff;
|
||||
|
||||
ha = ntohl(in_mask.s_addr);
|
||||
key.index[4] = (ha >> 24) & 0xff;
|
||||
key.index[5] = (ha >> 16) & 0xff;
|
||||
key.index[6] = (ha >> 8) & 0xff;
|
||||
key.index[7] = (ha >> 0) & 0xff;
|
||||
|
||||
/* ToS */
|
||||
key.index[8] = 0;
|
||||
|
||||
ha = ntohl(in_gw->sin_addr.s_addr);
|
||||
key.index[9] = (ha >> 24) & 0xff;
|
||||
key.index[10] = (ha >> 16) & 0xff;
|
||||
key.index[11] = (ha >> 8) & 0xff;
|
||||
key.index[12] = (ha >> 0) & 0xff;
|
||||
|
||||
if (rtm->rtm_type == RTM_DELETE) {
|
||||
r = RB_FIND(sroutes, &sroutes, &key);
|
||||
if (r == 0) {
|
||||
#ifdef DEBUG_ROUTE
|
||||
syslog(LOG_WARNING, "%s: DELETE: %u.%u.%u.%u "
|
||||
"%u.%u.%u.%u %u %u.%u.%u.%u not found", __func__,
|
||||
key.index[0], key.index[1], key.index[2],
|
||||
key.index[3], key.index[4], key.index[5],
|
||||
key.index[6], key.index[7], key.index[8],
|
||||
key.index[9], key.index[10], key.index[11],
|
||||
key.index[12]);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
RB_REMOVE(sroutes, &sroutes, r);
|
||||
free(r);
|
||||
route_total--;
|
||||
#ifdef DEBUG_ROUTE
|
||||
printf("%s: DELETE: %u.%u.%u.%u "
|
||||
"%u.%u.%u.%u %u %u.%u.%u.%u\n", __func__,
|
||||
key.index[0], key.index[1], key.index[2],
|
||||
key.index[3], key.index[4], key.index[5],
|
||||
key.index[6], key.index[7], key.index[8],
|
||||
key.index[9], key.index[10], key.index[11],
|
||||
key.index[12]);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
/* GET or ADD */
|
||||
ifp = NULL;
|
||||
if ((ifp = mib_find_if_sys(rtm->rtm_index)) == NULL) {
|
||||
if (rtm->rtm_type == RTM_ADD) {
|
||||
/* make it a get so the kernel fills the index */
|
||||
mib_send_rtmsg(rtm, gw, dst, mask);
|
||||
return;
|
||||
}
|
||||
mib_iflist_bad = 1;
|
||||
}
|
||||
|
||||
if ((r = malloc(sizeof(*r))) == NULL) {
|
||||
syslog(LOG_ERR, "%m");
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(r->index, key.index, sizeof(r->index));
|
||||
r->ifindex = (ifp == NULL) ? 0 : ifp->index;
|
||||
|
||||
r->type = (rtm->rtm_flags & RTF_LLINFO) ? 3 :
|
||||
(rtm->rtm_flags & RTF_REJECT) ? 2 : 4;
|
||||
|
||||
/* cannot really know, what protocol it runs */
|
||||
r->proto = (rtm->rtm_flags & RTF_LOCAL) ? 2 :
|
||||
(rtm->rtm_flags & RTF_STATIC) ? 3 :
|
||||
(rtm->rtm_flags & RTF_DYNAMIC) ? 4 : 10;
|
||||
|
||||
r1 = RB_INSERT(sroutes, &sroutes, r);
|
||||
if (r1 != NULL) {
|
||||
#ifdef DEBUG_ROUTE
|
||||
syslog(LOG_WARNING, "%s: %u.%u.%u.%u "
|
||||
"%u.%u.%u.%u %u %u.%u.%u.%u duplicate route", __func__,
|
||||
key.index[0], key.index[1], key.index[2],
|
||||
key.index[3], key.index[4], key.index[5],
|
||||
key.index[6], key.index[7], key.index[8],
|
||||
key.index[9], key.index[10], key.index[11],
|
||||
key.index[12]);
|
||||
#endif
|
||||
r1->ifindex = r->ifindex;
|
||||
r1->type = r->type;
|
||||
r1->proto = r->proto;
|
||||
free(r);
|
||||
return;
|
||||
}
|
||||
|
||||
route_total++;
|
||||
#ifdef DEBUG_ROUTE
|
||||
printf("%s: ADD/GET: %u.%u.%u.%u "
|
||||
"%u.%u.%u.%u %u %u.%u.%u.%u\n", __func__,
|
||||
key.index[0], key.index[1], key.index[2],
|
||||
key.index[3], key.index[4], key.index[5],
|
||||
key.index[6], key.index[7], key.index[8],
|
||||
key.index[9], key.index[10], key.index[11],
|
||||
key.index[12]);
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
mib_fetch_route(void)
|
||||
{
|
||||
u_char *rtab, *next;
|
||||
size_t len;
|
||||
struct sroute *r;
|
||||
struct sroute *r, *r1;
|
||||
struct rt_msghdr *rtm;
|
||||
struct sockaddr *addrs[RTAX_MAX];
|
||||
struct sockaddr_in *sa, *gw;
|
||||
struct in_addr mask, nhop;
|
||||
in_addr_t ha;
|
||||
struct mibif *ifp;
|
||||
|
||||
while ((r = TAILQ_FIRST(&sroute_list)) != NULL) {
|
||||
TAILQ_REMOVE(&sroute_list, r, link);
|
||||
if (route_tick != 0 && route_tick + ROUTE_UPDATE_INTERVAL > this_tick)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Remove all routes
|
||||
*/
|
||||
r = RB_MIN(sroutes, &sroutes);
|
||||
while (r != NULL) {
|
||||
r1 = RB_NEXT(sroutes, &sroutes, r);
|
||||
RB_REMOVE(sroutes, &sroutes, r);
|
||||
free(r);
|
||||
r = r1;
|
||||
}
|
||||
route_total = 0;
|
||||
|
||||
@ -75,83 +252,120 @@ fetch_route(void)
|
||||
continue;
|
||||
mib_extract_addrs(rtm->rtm_addrs, (u_char *)(rtm + 1), addrs);
|
||||
|
||||
if (addrs[RTAX_DST] == NULL || addrs[RTAX_GATEWAY] == NULL ||
|
||||
addrs[RTAX_DST]->sa_family != AF_INET)
|
||||
continue;
|
||||
|
||||
sa = (struct sockaddr_in *)(void *)addrs[RTAX_DST];
|
||||
|
||||
if (rtm->rtm_flags & RTF_HOST) {
|
||||
mask.s_addr = 0xffffffff;
|
||||
} else {
|
||||
if (addrs[RTAX_NETMASK] == NULL ||
|
||||
addrs[RTAX_NETMASK]->sa_len == 0)
|
||||
mask.s_addr = 0;
|
||||
else
|
||||
mask = ((struct sockaddr_in *)(void *)
|
||||
addrs[RTAX_NETMASK])->sin_addr;
|
||||
}
|
||||
if (addrs[RTAX_GATEWAY] == NULL) {
|
||||
nhop.s_addr = 0;
|
||||
} else if (rtm->rtm_flags & RTF_LLINFO) {
|
||||
nhop = sa->sin_addr;
|
||||
} else {
|
||||
gw = (struct sockaddr_in *)(void *)addrs[RTAX_GATEWAY];
|
||||
if (gw->sin_family != AF_INET)
|
||||
continue;
|
||||
nhop = gw->sin_addr;
|
||||
}
|
||||
if ((ifp = mib_find_if_sys(rtm->rtm_index)) == NULL) {
|
||||
mib_iflist_bad = 1;
|
||||
continue;
|
||||
mib_sroute_process(rtm, addrs[RTAX_GATEWAY], addrs[RTAX_DST],
|
||||
addrs[RTAX_NETMASK]);
|
||||
}
|
||||
|
||||
if ((r = malloc(sizeof(*r))) == NULL) {
|
||||
syslog(LOG_ERR, "%m");
|
||||
continue;
|
||||
#if 0
|
||||
u_int n = 0;
|
||||
r = RB_MIN(sroutes, &sroutes);
|
||||
while (r != NULL) {
|
||||
printf("%u: ", n++);
|
||||
sroute_print(r);
|
||||
printf("\n");
|
||||
r = RB_NEXT(sroutes, &sroutes, r);
|
||||
}
|
||||
|
||||
route_total++;
|
||||
|
||||
r->index.len = 13;
|
||||
ha = ntohl(sa->sin_addr.s_addr);
|
||||
r->index.subs[0] = (ha >> 24) & 0xff;
|
||||
r->index.subs[1] = (ha >> 16) & 0xff;
|
||||
r->index.subs[2] = (ha >> 8) & 0xff;
|
||||
r->index.subs[3] = (ha >> 0) & 0xff;
|
||||
ha = ntohl(mask.s_addr);
|
||||
r->index.subs[4] = (ha >> 24) & 0xff;
|
||||
r->index.subs[5] = (ha >> 16) & 0xff;
|
||||
r->index.subs[6] = (ha >> 8) & 0xff;
|
||||
r->index.subs[7] = (ha >> 0) & 0xff;
|
||||
|
||||
r->index.subs[8] = 0;
|
||||
|
||||
ha = ntohl(nhop.s_addr);
|
||||
r->index.subs[9] = (ha >> 24) & 0xff;
|
||||
r->index.subs[10] = (ha >> 16) & 0xff;
|
||||
r->index.subs[11] = (ha >> 8) & 0xff;
|
||||
r->index.subs[12] = (ha >> 0) & 0xff;
|
||||
|
||||
r->ifindex = ifp->index;
|
||||
|
||||
r->type = (rtm->rtm_flags & RTF_LLINFO) ? 3 :
|
||||
(rtm->rtm_flags & RTF_REJECT) ? 2 : 4;
|
||||
|
||||
/* cannot really know, what protocol it runs */
|
||||
r->proto = (rtm->rtm_flags & RTF_LOCAL) ? 2 :
|
||||
(rtm->rtm_flags & RTF_STATIC) ? 3 :
|
||||
(rtm->rtm_flags & RTF_DYNAMIC) ? 4 : 10;
|
||||
|
||||
INSERT_OBJECT_OID(r, &sroute_list);
|
||||
}
|
||||
|
||||
#endif
|
||||
free(rtab);
|
||||
route_tick = get_ticks();
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a route in the table.
|
||||
*/
|
||||
static struct sroute *
|
||||
sroute_get(const struct asn_oid *oid, u_int sub)
|
||||
{
|
||||
struct sroute key;
|
||||
int i;
|
||||
|
||||
if (oid->len - sub != 13)
|
||||
return (NULL);
|
||||
for (i = 0; i < 13; i++)
|
||||
key.index[i] = oid->subs[sub + i];
|
||||
return (RB_FIND(sroutes, &sroutes, &key));
|
||||
}
|
||||
|
||||
/**
|
||||
* Find next route in the table. There is no such RB_ macro, so must
|
||||
* dig into the innards of the RB stuff.
|
||||
*/
|
||||
static struct sroute *
|
||||
sroute_getnext(struct asn_oid *oid, u_int sub)
|
||||
{
|
||||
u_int i;
|
||||
int comp;
|
||||
struct sroute key;
|
||||
struct sroute *best;
|
||||
struct sroute *s;
|
||||
|
||||
/*
|
||||
* We now, that the OID is at least the tableEntry OID. If it is,
|
||||
* the user wants the first route.
|
||||
*/
|
||||
if (oid->len == sub)
|
||||
return (RB_MIN(sroutes, &sroutes));
|
||||
|
||||
/*
|
||||
* This is also true for any index that consists of zeros and is
|
||||
* shorter than the full index.
|
||||
*/
|
||||
if (oid->len < sub + 13) {
|
||||
for (i = sub; i < oid->len; i++)
|
||||
if (oid->subs[i] != 0)
|
||||
break;
|
||||
if (i == oid->len)
|
||||
return (RB_MIN(sroutes, &sroutes));
|
||||
|
||||
/*
|
||||
* Now if the index is too short, we fill it with zeros and then
|
||||
* subtract one from the index. We can do this, because we now,
|
||||
* that there is at least one index element that is not zero.
|
||||
*/
|
||||
for (i = oid->len; i < sub + 13; i++)
|
||||
oid->subs[i] = 0;
|
||||
|
||||
for (i = sub + 13 - 1; i >= sub; i--) {
|
||||
if (oid->subs[i] != 0) {
|
||||
oid->subs[i]--;
|
||||
break;
|
||||
}
|
||||
oid->subs[i] = ASN_MAXID;
|
||||
}
|
||||
oid->len = sub + 13;
|
||||
}
|
||||
|
||||
/* build the index */
|
||||
for (i = sub; i < sub + 13; i++)
|
||||
key.index[i - sub] = oid->subs[i];
|
||||
|
||||
/* now find the element */
|
||||
best = NULL;
|
||||
s = RB_ROOT(&sroutes);
|
||||
|
||||
while (s != NULL) {
|
||||
comp = sroute_compare(&key, s);
|
||||
if (comp >= 0) {
|
||||
/* The current element is smaller than what we search.
|
||||
* Forget about it and move to the right subtree. */
|
||||
s = RB_RIGHT(s, link);
|
||||
continue;
|
||||
}
|
||||
/* the current element is larger than what we search.
|
||||
* forget about the right subtree (its even larger), but
|
||||
* the current element may be what we need. */
|
||||
if (best == NULL || sroute_compare(s, best) < 0)
|
||||
/* this one's better */
|
||||
best = s;
|
||||
|
||||
s = RB_LEFT(s, link);
|
||||
}
|
||||
return (best);
|
||||
}
|
||||
|
||||
/*
|
||||
* Table
|
||||
*/
|
||||
@ -159,28 +373,27 @@ int
|
||||
op_route_table(struct snmp_context *ctx __unused, struct snmp_value *value,
|
||||
u_int sub, u_int iidx __unused, enum snmp_op op)
|
||||
{
|
||||
static struct sroute *r;
|
||||
struct sroute *r;
|
||||
|
||||
if (route_tick < this_tick)
|
||||
if (fetch_route() == -1)
|
||||
if (mib_fetch_route() == -1)
|
||||
return (SNMP_ERR_GENERR);
|
||||
|
||||
switch (op) {
|
||||
|
||||
case SNMP_OP_GETNEXT:
|
||||
if ((r = NEXT_OBJECT_OID(&sroute_list, &value->var, sub)) == NULL)
|
||||
if ((r = sroute_getnext(&value->var, sub)) == NULL)
|
||||
return (SNMP_ERR_NOSUCHNAME);
|
||||
index_append(&value->var, sub, &r->index);
|
||||
sroute_index_append(&value->var, sub, r);
|
||||
break;
|
||||
|
||||
case SNMP_OP_GET:
|
||||
if ((r = FIND_OBJECT_OID(&sroute_list, &value->var, sub)) == NULL)
|
||||
if ((r = sroute_get(&value->var, sub)) == NULL)
|
||||
return (SNMP_ERR_NOSUCHNAME);
|
||||
break;
|
||||
|
||||
case SNMP_OP_SET:
|
||||
if ((r = FIND_OBJECT_OID(&sroute_list, &value->var, sub)) == NULL)
|
||||
return (SNMP_ERR_NO_CREATION);
|
||||
if ((r = sroute_get(&value->var, sub)) == NULL)
|
||||
return (SNMP_ERR_NOSUCHNAME);
|
||||
return (SNMP_ERR_NOT_WRITEABLE);
|
||||
|
||||
case SNMP_OP_ROLLBACK:
|
||||
@ -194,28 +407,28 @@ op_route_table(struct snmp_context *ctx __unused, struct snmp_value *value,
|
||||
switch (value->var.subs[sub - 1]) {
|
||||
|
||||
case LEAF_ipCidrRouteDest:
|
||||
value->v.ipaddress[0] = r->index.subs[0];
|
||||
value->v.ipaddress[1] = r->index.subs[1];
|
||||
value->v.ipaddress[2] = r->index.subs[2];
|
||||
value->v.ipaddress[3] = r->index.subs[3];
|
||||
value->v.ipaddress[0] = r->index[0];
|
||||
value->v.ipaddress[1] = r->index[1];
|
||||
value->v.ipaddress[2] = r->index[2];
|
||||
value->v.ipaddress[3] = r->index[3];
|
||||
break;
|
||||
|
||||
case LEAF_ipCidrRouteMask:
|
||||
value->v.ipaddress[0] = r->index.subs[4];
|
||||
value->v.ipaddress[1] = r->index.subs[5];
|
||||
value->v.ipaddress[2] = r->index.subs[6];
|
||||
value->v.ipaddress[3] = r->index.subs[7];
|
||||
value->v.ipaddress[0] = r->index[4];
|
||||
value->v.ipaddress[1] = r->index[5];
|
||||
value->v.ipaddress[2] = r->index[6];
|
||||
value->v.ipaddress[3] = r->index[7];
|
||||
break;
|
||||
|
||||
case LEAF_ipCidrRouteTos:
|
||||
value->v.integer = r->index.subs[8];
|
||||
value->v.integer = r->index[8];
|
||||
break;
|
||||
|
||||
case LEAF_ipCidrRouteNextHop:
|
||||
value->v.ipaddress[0] = r->index.subs[9];
|
||||
value->v.ipaddress[1] = r->index.subs[10];
|
||||
value->v.ipaddress[2] = r->index.subs[11];
|
||||
value->v.ipaddress[3] = r->index.subs[12];
|
||||
value->v.ipaddress[0] = r->index[9];
|
||||
value->v.ipaddress[1] = r->index[10];
|
||||
value->v.ipaddress[2] = r->index[11];
|
||||
value->v.ipaddress[3] = r->index[12];
|
||||
break;
|
||||
|
||||
case LEAF_ipCidrRouteIfIndex:
|
||||
@ -280,8 +493,7 @@ op_route(struct snmp_context *ctx __unused, struct snmp_value *value,
|
||||
abort();
|
||||
}
|
||||
|
||||
if (route_tick < this_tick)
|
||||
if (fetch_route() == -1)
|
||||
if (mib_fetch_route() == -1)
|
||||
return (SNMP_ERR_GENERR);
|
||||
|
||||
switch (value->var.subs[sub - 1]) {
|
||||
@ -293,3 +505,5 @@ op_route(struct snmp_context *ctx __unused, struct snmp_value *value,
|
||||
}
|
||||
return (SNMP_ERR_NOERROR);
|
||||
}
|
||||
|
||||
RB_GENERATE(sroutes, sroute, link, sroute_compare);
|
||||
|
@ -1,4 +1,7 @@
|
||||
.\"
|
||||
.\" Copyright (c) 2004-2005
|
||||
.\" Hartmut Brandt
|
||||
.\" All rights reserved.
|
||||
.\" Copyright (c) 2001-2003
|
||||
.\" Fraunhofer Institute for Open Communication Systems (FhG Fokus).
|
||||
.\" All rights reserved.
|
||||
@ -26,9 +29,9 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Begemot: bsnmp/snmp_mibII/snmp_mibII.3,v 1.7 2005/05/23 09:11:21 brandt_h Exp $
|
||||
.\" $Begemot: bsnmp/snmp_mibII/snmp_mibII.3,v 1.10 2005/10/04 08:46:52 brandt_h Exp $
|
||||
.\"
|
||||
.Dd May 23, 2005
|
||||
.Dd October 4, 2005
|
||||
.Dt SNMP_MIBII 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -56,7 +59,7 @@
|
||||
.Nm mib_rcvaddr_delete ,
|
||||
.Nm mibif_notify ,
|
||||
.Nm mibif_unnotify
|
||||
.Nd "mib-2 module for snmpd.
|
||||
.Nd "mib-2 module for bsnmpd."
|
||||
.Sh LIBRARY
|
||||
.Pq begemotSnmpdModulePath."mibII" = "@MODPATH@snmp_mibII.so"
|
||||
.Sh SYNOPSIS
|
||||
@ -110,27 +113,31 @@
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm snmp_mibII
|
||||
module implements parts of the internet standard MIB-2. Most of the relevant
|
||||
MIBs are implemented. Some of the tables are restricted to be read-only
|
||||
instead of read-write. The exact current implementation can be found in
|
||||
module implements parts of the internet standard MIB-2.
|
||||
Most of the relevant MIBs are implemented.
|
||||
Some of the tables are restricted to be read-only instead of read-write.
|
||||
The exact current implementation can be found in
|
||||
.Pa @DEFPATH@mibII_tree.def .
|
||||
The module also exports a number of functions and global variables for use
|
||||
by other modules, that need to handle network interfaces. This man page describes
|
||||
these functions.
|
||||
by other modules, that need to handle network interfaces.
|
||||
This man page describes these functions.
|
||||
.Ss DIRECT NETWORK ACCESS
|
||||
The
|
||||
.Nm
|
||||
module opens a socket that is used to execute all network related
|
||||
.Xr ioctl 2
|
||||
functions. This socket is globally available under the name
|
||||
functions.
|
||||
This socket is globally available under the name
|
||||
.Va mib_netsock .
|
||||
.Ss NETWORK INTERFACES
|
||||
The
|
||||
.Nm
|
||||
module handles a list of all currently existing network interfaces. It allows
|
||||
module handles a list of all currently existing network interfaces.
|
||||
It allows
|
||||
other modules to handle their own interface lists with special information
|
||||
by providing a mechanism to register to events that change the interface list
|
||||
(see below). The basic data structure is the interface structure:
|
||||
(see below).
|
||||
The basic data structure is the interface structure:
|
||||
.Bd -literal -offset indent
|
||||
struct mibif {
|
||||
TAILQ_ENTRY(mibif) link;
|
||||
@ -159,35 +166,39 @@ The
|
||||
.Nm
|
||||
module tries to implement the semantic if
|
||||
.Va ifIndex
|
||||
as described in RFC-2863. This RFC states, that an interface indexes may not
|
||||
be reused. That means, for example, if
|
||||
as described in RFC-2863.
|
||||
This RFC states, that an interface indexes may not be reused.
|
||||
That means, for example, if
|
||||
.Pa tun
|
||||
is a synthetic interface type and the system creates the interface
|
||||
.Pa tun0 ,
|
||||
destroys this interfaces and again creates a
|
||||
.Pa tun 0 ,
|
||||
then these interfaces must have different interface indexes, because in fact
|
||||
they are different interfaces. If, on the other hand, there is a hardware
|
||||
interface
|
||||
they are different interfaces.
|
||||
If, on the other hand, there is a hardware interface
|
||||
.Pa xl0
|
||||
and this interface disappears, because its driver is unloaded and appears
|
||||
again, because the driver is loaded again, the interface index must stay
|
||||
the same.
|
||||
.Nm
|
||||
implements this by differentiating between real and synthetic (dynamic)
|
||||
interfaces. An interface type can be declared dynamic by calling the function
|
||||
interfaces.
|
||||
An interface type can be declared dynamic by calling the function
|
||||
.Fn mib_if_set_dyn
|
||||
with the name if the interface type (for example
|
||||
.Qq tun ).
|
||||
For real interfaces, the module keeps the mapping between the interface name
|
||||
and its
|
||||
.Va ifIndex
|
||||
in a special list, if the interface is unloaded. For dynamic interfaces
|
||||
in a special list, if the interface is unloaded.
|
||||
For dynamic interfaces
|
||||
a new
|
||||
.Va ifIndex
|
||||
is generated each time the interface comes into existance. This
|
||||
means, that the interface index as seen by SNMP is not the same index
|
||||
as used by the system. The SNMP
|
||||
is generated each time the interface comes into existence.
|
||||
This means, that the interface index as seen by SNMP is not the same index
|
||||
as used by the system.
|
||||
The SNMP
|
||||
.Va ifIndex
|
||||
is held in field
|
||||
.Va index ,
|
||||
@ -212,8 +223,8 @@ finds an interface by searching for an SNMP
|
||||
.Fn mib_find_if_sys
|
||||
finds an interface by searching for a system interface index and
|
||||
.Fn mib_find_if_name
|
||||
finds an interface by looking for an interface name. Each of the
|
||||
function returns
|
||||
finds an interface by looking for an interface name.
|
||||
Each of the function returns
|
||||
.Li NULL
|
||||
if the interface cannot be found.
|
||||
.Pp
|
||||
@ -227,17 +238,18 @@ can be used to change the interface administrative state to up
|
||||
(argument is 1) or down (argument is 0).
|
||||
.Ss INTERFACE EVENTS
|
||||
A module can register itself to receive a notification when a new entry is
|
||||
created in the interface list. This is done by calling
|
||||
created in the interface list.
|
||||
This is done by calling
|
||||
.Fn mib_register_newif .
|
||||
A module can register only one function, a second call to
|
||||
.Fn mib_register_newif
|
||||
causes the registration to be overwritten. The registration can be removed
|
||||
with a call to
|
||||
causes the registration to be overwritten.
|
||||
The registration can be removed with a call to
|
||||
.Fn mib_unregister_newif .
|
||||
If is unregistered automatically, when the registering module is unloaded.
|
||||
It is unregistered automatically, when the registering module is unloaded.
|
||||
.Pp
|
||||
A module can also register to events on a specific interface. This is done
|
||||
by calling
|
||||
A module can also register to events on a specific interface.
|
||||
This is done by calling
|
||||
.Fn mibif_notify .
|
||||
This causes the given callback
|
||||
.Fa func
|
||||
@ -251,7 +263,8 @@ The interface is destroyed.
|
||||
.El
|
||||
.Pp
|
||||
This mechanism can be used to implement interface type specific MIB parts
|
||||
in other modules. The registration can be removed with
|
||||
in other modules.
|
||||
The registration can be removed with
|
||||
.Fn mib_unnotify
|
||||
which the return value from
|
||||
.Fa mib_notify .
|
||||
@ -261,8 +274,8 @@ is destroyed or the registering module is unloaded.
|
||||
.Ss INTERFACE ADDRESSES
|
||||
The
|
||||
.Nm
|
||||
module handles a table of interface IP-addresses. These addresses are held
|
||||
in a
|
||||
module handles a table of interface IP-addresses.
|
||||
These addresses are held in a
|
||||
.Bd -literal -offset indent
|
||||
struct mibifa {
|
||||
TAILQ_ENTRY(mibifa) link;
|
||||
@ -282,8 +295,8 @@ and
|
||||
.Fn mib_next_ififa .
|
||||
The list should not be considered read-only.
|
||||
.Ss INTERFACE RECEIVE ADDRESSES
|
||||
The internet MIB-2 contains a table of interface receive addresses. These
|
||||
addresses are handled in:
|
||||
The internet MIB-2 contains a table of interface receive addresses.
|
||||
These addresses are handled in:
|
||||
.Bd -literal -offset indent
|
||||
struct mibrcvaddr {
|
||||
TAILQ_ENTRY(mibrcvaddr) link;
|
||||
@ -302,8 +315,9 @@ enum {
|
||||
.Pp
|
||||
Note, that the assignment of
|
||||
.Li MIBRCVADDR_BCAST
|
||||
is based on a list of known interface types. The flags should be handled
|
||||
by modules inplementing interface type specific MIBs.
|
||||
is based on a list of known interface types.
|
||||
The flags should be handled
|
||||
by modules implementing interface type specific MIBs.
|
||||
.Pp
|
||||
A receive address can be created with
|
||||
.Fn mib_rcvaddr_create
|
||||
@ -317,9 +331,11 @@ A receive address can be found with
|
||||
.Ss INTERFACE STACK TABLE
|
||||
The
|
||||
.Nm
|
||||
module maintains also the interface stack table. Because for complex stacks,
|
||||
module maintains also the interface stack table.
|
||||
Because for complex stacks,
|
||||
there is no system supported generic way of getting this information, interface
|
||||
type specific modules need to help setting up stack entries. The
|
||||
type specific modules need to help setting up stack entries.
|
||||
The
|
||||
.Nm
|
||||
module handles only the top and bottom entries.
|
||||
.Pp
|
||||
@ -327,8 +343,10 @@ A table entry is created with
|
||||
.Fn mib_ifstack_create
|
||||
and deleted with
|
||||
.Fn mib_ifstack_delete .
|
||||
Both functions need the pointers to the interfaces. Entries are automatically
|
||||
deleted if any of the interfaces of the entry is destroyed. The functions handle
|
||||
Both functions need the pointers to the interfaces.
|
||||
Entries are automatically
|
||||
deleted if any of the interfaces of the entry is destroyed.
|
||||
The functions handle
|
||||
both the stack table and the reverse stack table.
|
||||
.Sh FILES
|
||||
.Bl -tag -width ".It Pa @DEFPATH@mibII_tree.def" -compact
|
||||
|
@ -26,7 +26,7 @@
|
||||
-- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
-- SUCH DAMAGE.
|
||||
--
|
||||
-- $Begemot: bsnmp/snmp_ntp/BEGEMOT-NTP-MIB.txt,v 1.2 2005/04/26 13:38:01 brandt_h Exp $
|
||||
-- $Begemot: bsnmp/snmp_ntp/BEGEMOT-NTP-MIB.txt,v 1.3 2005/10/04 08:13:41 brandt_h Exp $
|
||||
--
|
||||
-- Private MIB for NTP module.
|
||||
--
|
||||
@ -35,11 +35,13 @@ BEGEMOT-NTP-MIB DEFINITIONS ::= BEGIN
|
||||
IMPORTS
|
||||
MODULE-IDENTITY, OBJECT-TYPE, TimeTicks, Unsigned32, Counter64
|
||||
FROM SNMPv2-SMI
|
||||
TruthValue
|
||||
FROM SNMPv2-TC
|
||||
begemot
|
||||
FROM BEGEMOT-MIB;
|
||||
|
||||
begemotNtp MODULE-IDENTITY
|
||||
LAST-UPDATED "200503210000Z"
|
||||
LAST-UPDATED "200509300000Z"
|
||||
ORGANIZATION "German Aerospace Center"
|
||||
CONTACT-INFO
|
||||
" Hartmut Brandt
|
||||
@ -114,4 +116,29 @@ begemotNtpStability OBJECT-TYPE
|
||||
"Current stability in ppm multiplied by 2^32."
|
||||
::= { begemotNtpObjects 6 }
|
||||
|
||||
begemotNtpJitterThresh OBJECT-TYPE
|
||||
SYNTAX Counter64
|
||||
MAX-ACCESS read-only
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"Jitter trap threshold in seconds multiplied by 2^32."
|
||||
::= { begemotNtpObjects 7 }
|
||||
|
||||
begemotNtpStabilityThresh OBJECT-TYPE
|
||||
SYNTAX Counter64
|
||||
MAX-ACCESS read-only
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"Stability trap threshold in ppm multiplied by 2^32."
|
||||
::= { begemotNtpObjects 8 }
|
||||
|
||||
begemotNtpTrapEnable OBJECT-TYPE
|
||||
SYNTAX TruthValue
|
||||
MAX-ACCESS read-only
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"Enables the sending of traps when either the peer is lost/
|
||||
found or one of the above thresholds is crossed."
|
||||
::= { begemotNtpObjects 9 }
|
||||
|
||||
END
|
||||
|
38
contrib/bsnmp/snmp_ntp/Makefile.in
Normal file
38
contrib/bsnmp/snmp_ntp/Makefile.in
Normal file
@ -0,0 +1,38 @@
|
||||
# Copyright (c) 2005
|
||||
# Hartmut Brandt.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Author: Harti Brandt <harti@freebsd.org>
|
||||
#
|
||||
# $Begemot: bsnmp/snmp_ntp/Makefile.in,v 1.2 2005/05/23 09:03:47 brandt_h Exp $
|
||||
#
|
||||
MOD= ntp
|
||||
SRCS= ${MOD}_tree.c snmp_ntp.c
|
||||
DEFS= ntp_tree.def
|
||||
BMIBS= BEGEMOT-NTP-MIB.txt NTP-MIB.txt NTP-PROXY-MIB.txt
|
||||
# MAN3= snmp_ntp.3
|
||||
MANFILTER= sed -e 's%@MODPATH@%${LIBDIR}/%g' \
|
||||
-e 's%@DEFPATH@%${DEFSDIR}/%g' \
|
||||
-e 's%@MIBSPATH@%${MIBSDIR}/%g'
|
||||
|
||||
XSYM= ntpMIB
|
||||
|
||||
LIB= snmp_${MOD}.la
|
||||
SHLIB_MAJOR= 3
|
||||
SHLIB_MINOR= 0
|
||||
|
||||
CFLAGS+= -I$(srcdir) -I$(srcdir)/../lib -I$(builddir) -I$(srcdir)/../snmpd
|
||||
|
||||
CLEANFILES += ${MOD}_oid.h ${MOD}_tree.c ${MOD}_tree.h
|
||||
|
||||
# for bootstrapping
|
||||
GENSNMPTREE= ${builddir}/../gensnmptree/gensnmptree
|
||||
|
||||
$(LIB): ${MOD}_oid.h ${MOD}_tree.h $(SRCS:.c=.lo)
|
||||
$(LIBTOOL) --mode=link $(CC) $(LDLAGS) -module -o $@ $(SRCS:.c=.lo) -rpath $(libdir) -version-info $(SHLIB_MAJOR):$(SHLIB_MINOR)
|
||||
|
||||
${MOD}_oid.h: ${MOD}_tree.def
|
||||
${GENSNMPTREE} <${srcdir}/${MOD}_tree.def -e ${XSYM} >$@
|
||||
|
||||
${MOD}_tree.h ${MOD}_tree.c : ${MOD}_tree.def
|
||||
${GENSNMPTREE} <${srcdir}/${MOD}_tree.def -l -p ${MOD}_
|
@ -27,7 +27,7 @@
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Begemot: bsnmp/snmp_ntp/snmp_ntp.c,v 1.4 2005/05/23 09:03:48 brandt_h Exp $
|
||||
* $Begemot: bsnmp/snmp_ntp/snmp_ntp.c,v 1.7 2005/10/04 11:21:36 brandt_h Exp $
|
||||
*
|
||||
* NTP interface for SNMPd.
|
||||
*/
|
||||
@ -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>
|
||||
@ -173,7 +177,7 @@ static uint32_t ntp_timeout;
|
||||
static void ntpd_input(int, void *);
|
||||
static int open_socket(void);
|
||||
|
||||
/* the initialisation function */
|
||||
/* the initialization function */
|
||||
static int
|
||||
ntp_init(struct lmodule *mod, int argc, char *argv[] __unused)
|
||||
{
|
||||
@ -360,6 +364,7 @@ ntpd_request(u_int op, u_int associd, const char *vars)
|
||||
free(rpkt);
|
||||
return (-1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -431,7 +436,7 @@ ntpd_read(uint16_t *op, uint16_t *associd, u_char **data, size_t *datalen)
|
||||
}
|
||||
|
||||
ptr = pkt;
|
||||
if (*ptr != ((NTPC_VERSION << 3) | NTPC_MODE)) {
|
||||
if ((*ptr & 0x3f) != ((NTPC_VERSION << 3) | NTPC_MODE)) {
|
||||
syslog(LOG_ERR, "unexpected packet version 0x%x", *ptr);
|
||||
free(*data);
|
||||
return (-1);
|
||||
@ -720,7 +725,7 @@ val_parse_ip(const char *val, u_char ip[4])
|
||||
{
|
||||
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 @@ val_parse_ip(const char *val, u_char ip[4])
|
||||
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);
|
||||
@ -1517,7 +1522,7 @@ op_begemot_ntp(struct snmp_context *ctx __unused, struct snmp_value *value,
|
||||
switch (which) {
|
||||
|
||||
case LEAF_begemotNtpHost:
|
||||
/* only at initialisation */
|
||||
/* only at initialization */
|
||||
if (community != COMM_INITIALIZE)
|
||||
return (SNMP_ERR_NOT_WRITEABLE);
|
||||
|
||||
@ -1527,7 +1532,7 @@ op_begemot_ntp(struct snmp_context *ctx __unused, struct snmp_value *value,
|
||||
return (SNMP_ERR_NOERROR);
|
||||
|
||||
case LEAF_begemotNtpPort:
|
||||
/* only at initialisation */
|
||||
/* only at initialization */
|
||||
if (community != COMM_INITIALIZE)
|
||||
return (SNMP_ERR_NOT_WRITEABLE);
|
||||
|
||||
|
42
contrib/bsnmp/snmpd/Makefile.in
Normal file
42
contrib/bsnmp/snmpd/Makefile.in
Normal file
@ -0,0 +1,42 @@
|
||||
# Copyright (c) 2001-2003
|
||||
# Fraunhofer Institute for Open Communication Systems (FhG Fokus).
|
||||
# All rights reserved.
|
||||
#
|
||||
# Author: Harti Brandt <harti@freebsd.org>
|
||||
#
|
||||
# $Begemot: bsnmp/snmpd/Makefile.in,v 1.8 2005/04/22 12:18:14 brandt_h Exp $
|
||||
#
|
||||
|
||||
PROG= bsnmpd
|
||||
SRCS= tree.c main.c action.c config.c export.c trap.c
|
||||
SRCS+= trans_udp.c trans_lsock.c
|
||||
MAN1= bsnmpd.1
|
||||
MAN3= snmpmod.3
|
||||
MANFILTER= sed -e 's%@MODPATH@%${LIBDIR}/%g' \
|
||||
-e 's%@DEFPATH@%${DEFSDIR}/%g' \
|
||||
-e 's%@MIBSPATH@%${MIBSDIR}/%g'
|
||||
|
||||
XSYM= snmpMIB begemotSnmpdModuleTable begemotSnmpd begemotTrapSinkTable \
|
||||
sysUpTime snmpTrapOID coldStart authenticationFailure \
|
||||
begemotSnmpdLocalPortTable begemotSnmpdTransUdp begemotSnmpdTransLsock
|
||||
|
||||
BMIBS= FOKUS-MIB.txt BEGEMOT-MIB.txt BEGEMOT-SNMPD.txt
|
||||
DEFS= tree.def
|
||||
INCS= snmpmod.h
|
||||
|
||||
CFLAGS+= -I$(builddir)/. -I${srcdir} -I${srcdir}/../lib
|
||||
LDFLAGS+= -export-dynamic
|
||||
|
||||
$(PROG): $(SRCS:.c=.lo) oid.h tree.h
|
||||
$(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ $(SRCS:.c=.lo) \
|
||||
$(builddir)/../lib/libbsnmp.la $(LIBEV) $(LIBWRAP)
|
||||
|
||||
CLEANFILES += tree.c tree.h oid.h
|
||||
|
||||
tree.c tree.h: tree.def ../gensnmptree/gensnmptree
|
||||
$(builddir)/../gensnmptree/gensnmptree -l <${srcdir}/tree.def
|
||||
|
||||
oid.h: tree.def ../gensnmptree/gensnmptree
|
||||
$(builddir)/../gensnmptree/gensnmptree <${srcdir}/tree.def -e ${XSYM} >$@
|
||||
|
||||
$(SRCS:.c=.lo): oid.h
|
@ -1,4 +1,7 @@
|
||||
.\"
|
||||
.\" Copyright (c) 2004-2005
|
||||
.\" Hartmut Brandt.
|
||||
.\" All rights reserved.
|
||||
.\" Copyright (c) 2001-2003
|
||||
.\" Fraunhofer Institute for Open Communication Systems (FhG Fokus).
|
||||
.\" All rights reserved.
|
||||
@ -26,14 +29,14 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Begemot: bsnmp/snmpd/bsnmpd.1,v 1.6 2005/02/25 11:56:01 brandt_h Exp $
|
||||
.\" $Begemot: bsnmp/snmpd/bsnmpd.1,v 1.9 2005/10/04 08:46:54 brandt_h Exp $
|
||||
.\"
|
||||
.Dd August 15, 2002
|
||||
.Dd October 4, 2005
|
||||
.Dt SNMPD 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm snmpd
|
||||
.Nd "simple and extendable SNMP daemon"
|
||||
.Nm bsnmpd
|
||||
.Nd "simple and extensible SNMP daemon"
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl dh
|
||||
@ -46,9 +49,10 @@
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
daemon servers the internet SNMP (Simple Network Managment Protocol).
|
||||
daemon servers the internet SNMP (Simple Network Management Protocol).
|
||||
It is intended to serve only the absolute basic MIBs and implement all other
|
||||
MIBs through loadable modules. In this way the
|
||||
MIBs through loadable modules.
|
||||
In this way the
|
||||
.Nm
|
||||
can be used in unexpected ways.
|
||||
.Pp
|
||||
@ -78,11 +82,13 @@ This causes the debugging level of the event library (see
|
||||
to be set to 10.
|
||||
.It Cm trace Ns Cm = Ns Cm level
|
||||
This option causes the snmp library trace flag to be set to the specified
|
||||
value. The value can be specified in the usual C-syntax for numbers.
|
||||
value.
|
||||
The value can be specified in the usual C-syntax for numbers.
|
||||
.El
|
||||
.It Fl I Ar paths
|
||||
This option specifies a colon separated list of directories to search for
|
||||
configuration include files. The default is
|
||||
configuration include files.
|
||||
The default is
|
||||
.Pa /etc:/usr/etc/:/usr/local/etc .
|
||||
These paths are only searched for include specified within <> parentheses.
|
||||
.It Fl l Ar prefix
|
||||
@ -98,8 +104,8 @@ Specify an alternate pid file instead of the default one.
|
||||
The
|
||||
.Nm
|
||||
reads its configuration from either the default or the user specified
|
||||
configuration file. The configuration file consists of the following types of
|
||||
lines:
|
||||
configuration file.
|
||||
The configuration file consists of the following types of lines:
|
||||
.Bl -bullet -offset indent
|
||||
.It
|
||||
variable assignments
|
||||
@ -112,18 +118,21 @@ MIB variable assignments
|
||||
.El
|
||||
.Pp
|
||||
If a line is too long it can be continued on the next line by ending it with
|
||||
a backslash. Empty lines and lines in which the first non-blank character is a
|
||||
a backslash.
|
||||
Empty lines and lines in which the first non-blank character is a
|
||||
.Dq #
|
||||
sign are ignored.
|
||||
.Pp
|
||||
All MIB variable assignments of the entire configuration (including nested
|
||||
configuration files) are handled as one transaction, i.e. as if they arrived
|
||||
in a single SET PDU. Any failure during the initial configuration read causes
|
||||
configuration files) are handled as one transaction, i.e., as if they arrived
|
||||
in a single SET PDU.
|
||||
Any failure during the initial configuration read causes
|
||||
.Nm
|
||||
to exit. A failure during the configuration read caused by a module load
|
||||
to exit.
|
||||
A failure during the configuration read caused by a module load
|
||||
causes the loading of the module to fail.
|
||||
.Pp
|
||||
The configuration is read during initialisation of
|
||||
The configuration is read during initialization of
|
||||
.Nm ,
|
||||
when a module is loaded and when
|
||||
.Nm
|
||||
@ -138,23 +147,25 @@ variable ?= string
|
||||
The string reaches from the first non-blank character after the
|
||||
equal sign until the first new line or
|
||||
.Dq #
|
||||
character. In the first case
|
||||
character.
|
||||
In the first case
|
||||
the string is assigned to the variable unconditionally, in the second case the
|
||||
variable is only assigned if it does not exist yet.
|
||||
.Pp
|
||||
Variable names must begin with a letter or underscore and contain only letters,
|
||||
digits or underscores.
|
||||
.Ss SECTION SEPARATORS
|
||||
The configuration consists of named sections. The MIB variable assignments in
|
||||
the section named
|
||||
The configuration consists of named sections.
|
||||
The MIB variable assignments in the section named
|
||||
.Dq snmpd
|
||||
are executed only during initial setup or when
|
||||
.Nm
|
||||
receives a SIGHUP. All other sections are executed when either a module
|
||||
receives a SIGHUP.
|
||||
All other sections are executed when either a module
|
||||
with the same name as the section is loaded or
|
||||
.Nm
|
||||
receives a SIGHUP and that module is already loaded. The default section
|
||||
at the start of the configuration is
|
||||
receives a SIGHUP and that module is already loaded.
|
||||
The default section at the start of the configuration is
|
||||
.Dq snmpd .
|
||||
One can switch to another section with the syntax
|
||||
.Bd -unfilled -offset indent
|
||||
@ -163,10 +174,11 @@ One can switch to another section with the syntax
|
||||
.Pp
|
||||
Where
|
||||
.Ar secname
|
||||
is the name of the section. The same
|
||||
is the name of the section.
|
||||
The same
|
||||
.Ar secname
|
||||
can be used in more than one place in the configuration. All of these parts are
|
||||
collected into one section.
|
||||
can be used in more than one place in the configuration.
|
||||
All of these parts are collected into one section.
|
||||
.Ss INCLUDE DIRECTIVES
|
||||
Another configuration file can be included into the current one with the
|
||||
include directive that takes one of two forms:
|
||||
@ -177,8 +189,8 @@ include directive that takes one of two forms:
|
||||
.Pp
|
||||
The first form causes the file to be searched in the current directory, the
|
||||
second form causes the file to be searched in the directories specified in
|
||||
the system include path. Nesting depth is only restricted by available
|
||||
memory.
|
||||
the system include path.
|
||||
Nesting depth is only restricted by available memory.
|
||||
.Ss MIB VARIABLE ASSIGNMENTS
|
||||
A MIB variable is assigned with the syntax
|
||||
.Bd -unfilled -offset indent
|
||||
@ -186,17 +198,23 @@ oid [ suboids ] = value
|
||||
.Ed
|
||||
.Pp
|
||||
.Va oid
|
||||
is the name of the variable to be set. Only the last component of the entire
|
||||
name is used here. If the variable is a scalar, the index (.0) is automatically
|
||||
appended and need not to be specified. If the variable is a table column,
|
||||
the index
|
||||
is the name of the variable to be set.
|
||||
Only the last component of the entire name is used here.
|
||||
If the variable is a scalar, the index (.0) is automatically
|
||||
appended and need not to be specified.
|
||||
If the variable is a table column, the index
|
||||
.Pq Va suboids
|
||||
must be specified. The index consist of elements each seperated from the
|
||||
previous one by a dot. Elements may be either numbers, strings or hostnames
|
||||
enclosed in [] brackets. If the element is a number it is appended
|
||||
to the current oid. If the element is a string, its length and the
|
||||
must be specified.
|
||||
The index consist of elements each separated from the
|
||||
previous one by a dot.
|
||||
Elements may be either numbers, strings or hostnames
|
||||
enclosed in [] brackets.
|
||||
If the element is a number it is appended
|
||||
to the current oid.
|
||||
If the element is a string, its length and the
|
||||
.Tn ASCII
|
||||
code of each of its characters are appended to the current oid. If the
|
||||
code of each of its characters are appended to the current oid.
|
||||
If the
|
||||
element is a hostname, the IP address of the host is looked up and the four
|
||||
elements of the IP address are appended to the oid.
|
||||
.Pp
|
||||
@ -213,7 +231,8 @@ myvariable.27.6.102.111.111.111.108.108.127.0.0.1.38.94.33
|
||||
The value of the assignment may be either empty, a string or a number.
|
||||
If a string starts with a letter or an underscore and consists only of
|
||||
letters, digits, underscores and minus signs, it can be written without
|
||||
quotes. In all other cases the string must be enclosed in double quotes.
|
||||
quotes.
|
||||
In all other cases the string must be enclosed in double quotes.
|
||||
.Sh SUBSTITUTIONS
|
||||
A variable substitution is written as
|
||||
.Bd -unfilled -offset indent
|
||||
@ -222,8 +241,8 @@ $(variable)
|
||||
.Pp
|
||||
where
|
||||
.Ar variable
|
||||
is the name of the variable to substitute. Using an undefined variable is
|
||||
considered an error.
|
||||
is the name of the variable to substitute.
|
||||
Using an undefined variable is considered an error.
|
||||
.Sh FILES
|
||||
.Bl -tag -width ".It Pa /var/run/ Ns Ao Ar prefix Ac Ns \&.pid" -compact
|
||||
.It Pa /etc/ Ns Ao Ar prefix Ac Ns \&.config
|
||||
|
@ -26,7 +26,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Begemot: bsnmp/snmpd/config.c,v 1.22 2004/08/12 17:09:49 brandt Exp $
|
||||
* $Begemot: bsnmp/snmpd/config.c,v 1.24 2005/10/04 11:21:37 brandt_h Exp $
|
||||
*
|
||||
* Parse configuration file.
|
||||
*/
|
||||
@ -820,7 +820,7 @@ parse_oid(const char *varname, struct asn_oid *oid)
|
||||
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 @@ parse_syntax_integer(struct snmp_value *value)
|
||||
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();
|
||||
@ -1131,7 +1131,7 @@ parse_define(const char *varname)
|
||||
m->value = string;
|
||||
m->length = length;
|
||||
} else {
|
||||
if (t != TOK_ASSIGN) {
|
||||
if (t == TOK_ASSIGN) {
|
||||
free(m->value);
|
||||
m->value = string;
|
||||
m->length = length;
|
||||
@ -1360,5 +1360,7 @@ define_macro(const char *name, const char *value)
|
||||
}
|
||||
strcpy(m->value, value);
|
||||
m->length = strlen(value);
|
||||
m->perm = 1;
|
||||
LIST_INSERT_HEAD(¯os, m, link);
|
||||
return (0);
|
||||
}
|
||||
|
@ -26,13 +26,14 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Begemot: bsnmp/snmpd/main.c,v 1.93 2005/05/23 11:10:16 brandt_h Exp $
|
||||
* $Begemot: bsnmp/snmpd/main.c,v 1.97 2005/10/04 14:32:45 brandt_h Exp $
|
||||
*
|
||||
* SNMPd main stuff.
|
||||
*/
|
||||
#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>
|
||||
@ -734,7 +735,7 @@ check_priv(struct port_input *pi, struct msghdr *msg)
|
||||
pi->priv = 0;
|
||||
|
||||
if (msg->msg_controllen == sizeof(*cmsg)) {
|
||||
/* process explicitely sends credentials */
|
||||
/* process explicitly sends credentials */
|
||||
|
||||
cmsg = (struct credmsg *)msg->msg_control;
|
||||
pi->priv = (cmsg->cred.cmcred_euid == 0);
|
||||
@ -1611,6 +1612,10 @@ get_ticks()
|
||||
/*
|
||||
* Timer support
|
||||
*/
|
||||
|
||||
/*
|
||||
* Trampoline for the non-repeatable timers.
|
||||
*/
|
||||
#ifdef USE_LIBBEGEMOT
|
||||
static void
|
||||
tfunc(int tid __unused, void *uap)
|
||||
@ -1628,7 +1633,24 @@ tfunc(evContext ctx __unused, void *uap, struct timespec due __unused,
|
||||
}
|
||||
|
||||
/*
|
||||
* Start a timer
|
||||
* Trampoline for the repeatable timers.
|
||||
*/
|
||||
#ifdef USE_LIBBEGEMOT
|
||||
static void
|
||||
trfunc(int tid __unused, void *uap)
|
||||
#else
|
||||
static void
|
||||
trfunc(evContext ctx __unused, void *uap, struct timespec due __unused,
|
||||
struct timespec inter __unused)
|
||||
#endif
|
||||
{
|
||||
struct timer *tp = uap;
|
||||
|
||||
tp->func(tp->udata);
|
||||
}
|
||||
|
||||
/*
|
||||
* Start a one-shot timer
|
||||
*/
|
||||
void *
|
||||
timer_start(u_int ticks, void (*func)(void *), void *udata, struct lmodule *mod)
|
||||
@ -1669,6 +1691,55 @@ timer_start(u_int ticks, void (*func)(void *), void *udata, struct lmodule *mod)
|
||||
return (tp);
|
||||
}
|
||||
|
||||
/*
|
||||
* Start a repeatable timer. When used with USE_LIBBEGEMOT the first argument
|
||||
* is currently ignored and the initial number of ticks is set to the
|
||||
* repeat number of ticks.
|
||||
*/
|
||||
void *
|
||||
timer_start_repeat(u_int ticks __unused, u_int repeat_ticks,
|
||||
void (*func)(void *), void *udata, struct lmodule *mod)
|
||||
{
|
||||
struct timer *tp;
|
||||
#ifndef USE_LIBBEGEMOT
|
||||
struct timespec due;
|
||||
struct timespec inter;
|
||||
#endif
|
||||
|
||||
if ((tp = malloc(sizeof(struct timer))) == NULL) {
|
||||
syslog(LOG_CRIT, "out of memory for timer");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
#ifndef USE_LIBBEGEMOT
|
||||
due = evAddTime(evNowTime(),
|
||||
evConsTime(ticks / 100, (ticks % 100) * 10000));
|
||||
inter = evConsTime(repeat_ticks / 100, (repeat_ticks % 100) * 10000);
|
||||
#endif
|
||||
|
||||
tp->udata = udata;
|
||||
tp->owner = mod;
|
||||
tp->func = func;
|
||||
|
||||
LIST_INSERT_HEAD(&timer_list, tp, link);
|
||||
|
||||
#ifdef USE_LIBBEGEMOT
|
||||
if ((tp->id = poll_start_timer(repeat_ticks * 10, 1, trfunc, tp)) < 0) {
|
||||
syslog(LOG_ERR, "cannot set timer: %m");
|
||||
exit(1);
|
||||
}
|
||||
#else
|
||||
if (evSetTimer(evctx, trfunc, tp, due, inter, &tp->id) == -1) {
|
||||
syslog(LOG_ERR, "cannot set timer: %m");
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
return (tp);
|
||||
}
|
||||
|
||||
/*
|
||||
* Stop a timer.
|
||||
*/
|
||||
void
|
||||
timer_stop(void *p)
|
||||
{
|
||||
@ -2157,7 +2228,7 @@ lm_load(const char *path, const char *section)
|
||||
av[ac] = NULL;
|
||||
|
||||
/*
|
||||
* Run the initialisation function
|
||||
* Run the initialization function
|
||||
*/
|
||||
if ((err = (*m->config->init)(m, ac, av)) != 0) {
|
||||
syslog(LOG_ERR, "lm_load: init failed: %d", err);
|
||||
|
@ -1,4 +1,7 @@
|
||||
.\"
|
||||
.\" Copyright (c) 2004-2005
|
||||
.\" Hartmut Brandt.
|
||||
.\" All rights reserved.
|
||||
.\" Copyright (c) 2001-2003
|
||||
.\" Fraunhofer Institute for Open Communication Systems (FhG Fokus).
|
||||
.\" All rights reserved.
|
||||
@ -26,9 +29,9 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Begemot: bsnmp/snmpd/snmpmod.3,v 1.10 2005/05/23 09:10:11 brandt_h Exp $
|
||||
.\" $Begemot: bsnmp/snmpd/snmpmod.3,v 1.14 2005/10/04 13:30:35 brandt_h Exp $
|
||||
.\"
|
||||
.Dd May 23, 2005
|
||||
.Dd October 4, 2005
|
||||
.Dt SNMPMOD 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -63,6 +66,7 @@
|
||||
.Nm reqid_istype ,
|
||||
.Nm reqid_type ,
|
||||
.Nm timer_start ,
|
||||
.Nm timer_start_repeat ,
|
||||
.Nm timer_stop ,
|
||||
.Nm fd_select ,
|
||||
.Nm fd_deselect ,
|
||||
@ -142,6 +146,8 @@ Begemot SNMP library
|
||||
.Fn reqid_type "int32_t reqid"
|
||||
.Ft void *
|
||||
.Fn timer_start "u_int ticks" "void (*func)(void *)" "void *uarg" "struct lmodule *mod"
|
||||
.Ft void *
|
||||
.Fn timer_start_repeat "u_int ticks" "u_int repeat_ticks" "void (*func)(void *)" "void *uarg" "struct lmodule *mod"
|
||||
.Ft void
|
||||
.Fn timer_stop "void *timer_id"
|
||||
.Ft void *
|
||||
@ -221,22 +227,26 @@ Begemot SNMP library
|
||||
.Fn index_append_off "struct asn_oid *dst" "u_int sub" "const struct asn_oid *src" "u_int off"
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Xr snmpd 1
|
||||
.Xr bsnmpd 1
|
||||
SNMP daemon implements a minimal MIB which consists of the system group, part
|
||||
of the SNMP MIB, a private configuration MIB, a trap destination table, a
|
||||
UDP port table, a community table, a module table, a statistics group and
|
||||
a debugging group. All other MIBs are support through loadable modules.
|
||||
a debugging group.
|
||||
All other MIBs are support through loadable modules.
|
||||
This allows
|
||||
.Xr snmpd 1
|
||||
.Xr bsnmpd 1
|
||||
to use for task, that are not the classical SNMP task.
|
||||
.Ss MODULE LOADING AND UNLOADING
|
||||
Modules are loaded by writing to the module table. This table is indexed by
|
||||
a string, that identfies the module to the daemon. This identifier is used
|
||||
Modules are loaded by writing to the module table.
|
||||
This table is indexed by a string, that identifies the module to the daemon.
|
||||
This identifier is used
|
||||
to select the correct configuration section from the configuration files and
|
||||
to identify resources allocated to this module. A row in the module table is
|
||||
to identify resources allocated to this module.
|
||||
A row in the module table is
|
||||
created by writing a string of non-zero length to the
|
||||
.Va begemotSnmpdModulePath
|
||||
column. This string must be the complete path to the file containing the module.
|
||||
column.
|
||||
This string must be the complete path to the file containing the module.
|
||||
A module can be unloaded by writing a zero length string to the path column
|
||||
of an existing row.
|
||||
.Pp
|
||||
@ -273,29 +283,33 @@ This structure must be statically initialized and its fields have the
|
||||
following functions:
|
||||
.Bl -tag -width ".It Va tree_size"
|
||||
.It Va comment
|
||||
This is a string that will be visible in the module table. It should give
|
||||
some hint about the function of this module.
|
||||
This is a string that will be visible in the module table.
|
||||
It should give some hint about the function of this module.
|
||||
.It Va init
|
||||
This function is called upon loading the module. The module pointer should
|
||||
This function is called upon loading the module.
|
||||
The module pointer should
|
||||
be stored by the module because it is needed in other calls and the
|
||||
argument vector will contain the arguments to this module from the daemons
|
||||
command line. This function should return 0 if everything is ok or an
|
||||
UNIX error code (see
|
||||
command line.
|
||||
This function should return 0 if everything is ok or an UNIX error code (see
|
||||
.Xr errno 3 ) .
|
||||
Once the function returns 0, the
|
||||
.Va fini
|
||||
function is called when the module is unloaded.
|
||||
.It Va fini
|
||||
The module is unloaded. This gives the module a chance to free resources that
|
||||
are not automatically freed. Be sure to free all memory, because daemons tend
|
||||
to run very long. This function pointer may be
|
||||
The module is unloaded.
|
||||
This gives the module a chance to free resources that
|
||||
are not automatically freed.
|
||||
Be sure to free all memory, because daemons tend to run very long.
|
||||
This function pointer may be
|
||||
.Li NULL
|
||||
if it is not needed.
|
||||
.It Va idle
|
||||
If this function pointer is not
|
||||
.Li NULL ,
|
||||
the function pointed to by it is called whenever the daemon is going
|
||||
to wait for an event. Try to avoid using this feature.
|
||||
to wait for an event.
|
||||
Try to avoid using this feature.
|
||||
.It Va dump
|
||||
Whenever the daemon receives a
|
||||
.Li SIGUSR1
|
||||
@ -322,7 +336,7 @@ If not
|
||||
this function is called after successful loading and initializing the module
|
||||
to start its actual operation.
|
||||
.It Va proxy
|
||||
If the daemon receives a PDU and that PDU has a community string who's
|
||||
If the daemon receives a PDU and that PDU has a community string whose
|
||||
community was registered by this module and
|
||||
.Va proxy
|
||||
is not
|
||||
@ -336,16 +350,18 @@ This is the number of nodes in
|
||||
.It Va loading
|
||||
If this pointer is not
|
||||
.Li NULL
|
||||
it is called whenever another module was loaded or unloaded. It gets a
|
||||
it is called whenever another module was loaded or unloaded.
|
||||
It gets a
|
||||
pointer to that module and a flag that is 0 for unloading and 1 for loading.
|
||||
.El
|
||||
.Pp
|
||||
When everything is ok, the daemon merges the module's MIB tree into its current
|
||||
global tree, calls the modules
|
||||
.Fn init
|
||||
function. If this function returns an error, the modules MIB tree is removed from
|
||||
the global one and the module is unloaded. If initialisation is successful,
|
||||
the modules
|
||||
function.
|
||||
If this function returns an error, the modules MIB tree is removed from
|
||||
the global one and the module is unloaded.
|
||||
If initialization is successful, the modules
|
||||
.Fn start
|
||||
function is called.
|
||||
After it returns the
|
||||
@ -363,10 +379,11 @@ functions of all other modules are called.
|
||||
There are a number of macros designed to help implementing SNMP tables.
|
||||
A problem while implementing a table is the support for the GETNEXT operator.
|
||||
The GETNEXT operation has to find out whether, given an arbitrary OID, the
|
||||
lessest table row, that has an OID higher than the given OID. The easiest way
|
||||
lessest table row, that has an OID higher than the given OID.
|
||||
The easiest way
|
||||
to do this is to keep the table as an ordered list of structures each one
|
||||
of which contains an OID that is the index of the table row. This allows easy
|
||||
removal, insertion and search.
|
||||
of which contains an OID that is the index of the table row.
|
||||
This allows easy removal, insertion and search.
|
||||
.Pp
|
||||
The helper macros assume, that the table is organized as a TAILQ (see
|
||||
.Xr queue 3
|
||||
@ -400,7 +417,7 @@ assume the existence of a
|
||||
.Vt struct asn_oid
|
||||
that is used as index, the macros
|
||||
.Fn *_OBJECT_INT_*
|
||||
assume the existance of an unsigned integer field that is used as index.
|
||||
assume the existence of an unsigned integer field that is used as index.
|
||||
.Pp
|
||||
The macros
|
||||
.Fn *_INDEX
|
||||
@ -413,7 +430,7 @@ The macros
|
||||
allow the explicit naming of the link field of the tail queues, the others
|
||||
assume that the link field is named
|
||||
.Va link .
|
||||
Explicitely naming the link field may be necessary if the same structures
|
||||
Explicitly naming the link field may be necessary if the same structures
|
||||
are held in two or more different tables.
|
||||
.Pp
|
||||
The arguments to the macros are as follows:
|
||||
@ -431,7 +448,8 @@ Must point to the
|
||||
.Va var
|
||||
field of the
|
||||
.Fa value
|
||||
argument to the node operation callback. This is the OID to search for.
|
||||
argument to the node operation callback.
|
||||
This is the OID to search for.
|
||||
.It Fa SUB
|
||||
This is the index of the start of the table index in the OID pointed to
|
||||
by
|
||||
@ -466,18 +484,19 @@ struct systemg {
|
||||
u_char *contact;
|
||||
u_char *name;
|
||||
u_char *location;
|
||||
u_int32_t services;
|
||||
u_int32_t or_last_change;
|
||||
uint32_t services;
|
||||
uint32_t or_last_change;
|
||||
};
|
||||
.Ed
|
||||
.Ss COMMUNITIES
|
||||
The SNMP daemon implements a community table. On recipte of a request message
|
||||
The SNMP daemon implements a community table.
|
||||
On recipte of a request message
|
||||
the community string in that message is compared to each of the community
|
||||
strings in that table, if a match is found, the global variable
|
||||
.Va community
|
||||
is set to the community identifier for that community. Community identifiers
|
||||
are unsigned integers. For the three standard communities there are three
|
||||
constants defined:
|
||||
is set to the community identifier for that community.
|
||||
Community identifiers are unsigned integers.
|
||||
For the three standard communities there are three constants defined:
|
||||
.Bd -literal -offset indent
|
||||
#define COMM_INITIALIZE 0
|
||||
#define COMM_READ 1
|
||||
@ -487,24 +506,26 @@ constants defined:
|
||||
.Va community
|
||||
is set to
|
||||
.Li COMM_INITIALIZE
|
||||
while the assignments in the configuration file are processed. To
|
||||
while the assignments in the configuration file are processed.
|
||||
To
|
||||
.Li COMM_READ
|
||||
or
|
||||
.Li COMM_WRITE
|
||||
when the community strings for the read-write or read-only community are found
|
||||
in the incoming PDU.
|
||||
.Pp
|
||||
Modules can define additional communities. This may be necessary to provide
|
||||
Modules can define additional communities.
|
||||
This may be necessary to provide
|
||||
transport proxying (a PDU received on one communication link is proxied to
|
||||
another link) or to implement non-UDP access points to SNMP. A new
|
||||
community is defined with the function
|
||||
another link) or to implement non-UDP access points to SNMP.
|
||||
A new community is defined with the function
|
||||
.Fn comm_define .
|
||||
It takes the following parameters:
|
||||
.Bl -tag -width ".It Fa descr"
|
||||
.It Fa priv
|
||||
This is an integer identifying the community to the module. Each module has
|
||||
its own namespace with regard to this parameter. The community table is
|
||||
indexed with the module name and this identifier.
|
||||
This is an integer identifying the community to the module.
|
||||
Each module has its own namespace with regard to this parameter.
|
||||
The community table is indexed with the module name and this identifier.
|
||||
.It Fa descr
|
||||
This is a string providing a human readable description of the community.
|
||||
It is visible in the community table.
|
||||
@ -514,7 +535,8 @@ This is the module defining the community.
|
||||
This is the initial community string.
|
||||
.El
|
||||
.Pp
|
||||
The function returns a globally unique community identifier. If a PDU is
|
||||
The function returns a globally unique community identifier.
|
||||
If a PDU is
|
||||
received who's community string matches, this identifier is set into the global
|
||||
.Va community .
|
||||
.Pp
|
||||
@ -531,7 +553,8 @@ contains the OID 0.0.
|
||||
.Ss REQUEST ID RANGES
|
||||
For modules that implement SNMP client functions besides SNMP agent functions
|
||||
it may be necessary to identify SNMP requests by their identifier to allow
|
||||
easier routing of responses to the correct sub-system. Request id ranges
|
||||
easier routing of responses to the correct sub-system.
|
||||
Request id ranges
|
||||
provide a way to aquire globally non-overlapping sub-ranges of the entire
|
||||
31-bit id range.
|
||||
.Pp
|
||||
@ -543,7 +566,8 @@ For example, the call
|
||||
id = reqid_allocate(1000, module);
|
||||
.Ed
|
||||
.Pp
|
||||
allocates a range of 1000 request ids. The function returns the request
|
||||
allocates a range of 1000 request ids.
|
||||
The function returns the request
|
||||
id range identifier or 0 if there is not enough identifier space.
|
||||
The function
|
||||
.Fn reqid_base
|
||||
@ -578,9 +602,20 @@ after
|
||||
.Fa ticks
|
||||
SNMP ticks have expired.
|
||||
.Fa mod
|
||||
is the module that starts the timer. Timers are one-shot, they are not
|
||||
restarted. The function returns a timer identifier that can be used to
|
||||
stop the timer via
|
||||
is the module that starts the timer.
|
||||
These timers are one-shot, they are not restarted.
|
||||
Repeatable timers are started with
|
||||
.Fn timer_start_repeat
|
||||
which takes an additional argument
|
||||
.Fa repeat_ticks .
|
||||
The argument
|
||||
.Fa ticks
|
||||
gives the number of ticks until the first execution of the callback, while
|
||||
.Fa repeat_ticks
|
||||
is the number of ticks between invocations of the callback.
|
||||
Note, that currently the number of initial ticks silently may be set identical
|
||||
to the number of ticks between callback invocations.
|
||||
The function returns a timer identifier that can be used to stop the timer via
|
||||
.Fn timer_stop .
|
||||
If a module is unloaded all timers started by the module that have not expired
|
||||
yet are stopped.
|
||||
@ -598,9 +633,10 @@ and the user argument
|
||||
.Fa uarg
|
||||
whenever the file descriptor
|
||||
.Fa fd
|
||||
can be red or has a close condition. If the file descriptor is not in
|
||||
non-blocking mode, it is set to non-blocking mode. If the callback is not
|
||||
needed anymore,
|
||||
can be read or has a close condition.
|
||||
If the file descriptor is not in
|
||||
non-blocking mode, it is set to non-blocking mode.
|
||||
If the callback is not needed anymore,
|
||||
.Fn fd_deselect
|
||||
may be called with the value returned from
|
||||
.Fn fd_select .
|
||||
@ -609,17 +645,18 @@ the module is unloaded.
|
||||
.Pp
|
||||
To temporarily suspend the file descriptor registration
|
||||
.Fn fd_suspend
|
||||
can be called. This also causes the file descriptor to be switched back to
|
||||
can be called.
|
||||
This also causes the file descriptor to be switched back to
|
||||
blocking mode if it was blocking prior the call to
|
||||
.Fn fd_select .
|
||||
This is necessary to do synchronuous input on a selected socket.
|
||||
This is necessary to do synchronous input on a selected socket.
|
||||
The effect of
|
||||
.Fn fd_suspend
|
||||
can be undone with
|
||||
.Fn fd_resume .
|
||||
.Ss OBJECT RESOURCES
|
||||
The system group contains an object resource table. A module may create
|
||||
an entry in this table by calling
|
||||
The system group contains an object resource table.
|
||||
A module may create an entry in this table by calling
|
||||
.Fn or_register
|
||||
with the
|
||||
.Fa oid
|
||||
@ -634,10 +671,11 @@ unloaded.
|
||||
.Ss TRANSMIT AND RECEIVE BUFFERS
|
||||
A buffer is allocated via
|
||||
.Fn buf_alloc .
|
||||
The argument must be 1 for transmit and 0 for receive buffers. The function
|
||||
may return
|
||||
The argument must be 1 for transmit and 0 for receive buffers.
|
||||
The function may return
|
||||
.Li NULL
|
||||
if there is no memory available. The current buffersize can be obtained with
|
||||
if there is no memory available.
|
||||
The current buffersize can be obtained with
|
||||
.Fn buf_size .
|
||||
.Sh PROCESSING PDUS
|
||||
For modules that need to do their own PDU processing (for example for proxying)
|
||||
@ -666,7 +704,8 @@ A SET PDU had a value field in a binding with wrong ASN.1 encoding.
|
||||
The buffer appears to contain a valid begin of a PDU, but is too short.
|
||||
For streaming transports this means that the caller must save what he
|
||||
already has and trying to obtain more input and reissue this input to
|
||||
the function. For datagram transports this means that part of the
|
||||
the function.
|
||||
For datagram transports this means that part of the
|
||||
datagram was lost and the input should be ignored.
|
||||
.El
|
||||
.Pp
|
||||
@ -674,11 +713,12 @@ The function
|
||||
.Fn snmp_input_finish
|
||||
does the other half of processing: if
|
||||
.Fn snmp_input_start
|
||||
did not return OK, tries to construct an error response. If the start was OK,
|
||||
it calls the correct function from
|
||||
.Xr bsnmpagent
|
||||
did not return OK, tries to construct an error response.
|
||||
If the start was OK, it calls the correct function from
|
||||
.Xr bsnmpagent 3
|
||||
to execute the request and depending on the outcome constructs a response or
|
||||
error response PDU or ignores the request PDU. It returns either
|
||||
error response PDU or ignores the request PDU.
|
||||
It returns either
|
||||
.Er SNMPD_INPUT_OK
|
||||
or
|
||||
.Er SNMPD_INPUT_FAILED .
|
||||
@ -695,7 +735,8 @@ the transport and the index in the port table) to the given address.
|
||||
.Pp
|
||||
The function
|
||||
.Fn snmp_send_trap
|
||||
sends a trap to all trap destinations. The arguments are the
|
||||
sends a trap to all trap destinations.
|
||||
The arguments are the
|
||||
.Fa oid
|
||||
identifying the trap and a NULL-terminated list of
|
||||
.Vt struct snmp_value
|
||||
@ -712,12 +753,13 @@ should be called for SNMP_OP_SET.
|
||||
.Fa value
|
||||
and
|
||||
.Fa ctx
|
||||
are the resp\&. arguments to the node callback.
|
||||
are the resp\&.\& arguments to the node callback.
|
||||
.Fa valp
|
||||
is a pointer to the pointer that holds the current value and
|
||||
.Fa req_size
|
||||
should be -1 if any size of the string is acceptable or a number larger or
|
||||
equal zero if the string must have a specific size. The function saves
|
||||
equal zero if the string must have a specific size.
|
||||
The function saves
|
||||
the old value in the scratch area (note, that any initial value must have
|
||||
been allocated by
|
||||
.Xr malloc 3 ) ,
|
||||
@ -728,11 +770,13 @@ simply frees the saved old value in the scratch area.
|
||||
.It Fn string_rollback
|
||||
frees the new value, and puts back the old one.
|
||||
.It Fn string_get
|
||||
is used for GET or GETNEXT. If
|
||||
is used for GET or GETNEXT.
|
||||
If
|
||||
.Fa len
|
||||
is -1, the length is computed via
|
||||
.Xr strlen 3
|
||||
from the current string value. If the current value is NULL,
|
||||
from the current string value.
|
||||
If the current value is NULL,
|
||||
a OCTET STRING of zero length is returned.
|
||||
.It Fn string_free
|
||||
must be called if either rollback or commit fails to free the saved old value.
|
||||
@ -771,13 +815,15 @@ Retrieves the OID
|
||||
The following functions help in handling table indexes:
|
||||
.Bl -tag -width "XXXXXXXXX"
|
||||
.It Fn index_decode
|
||||
Decodes the index part of the OID. The parameter
|
||||
Decodes the index part of the OID.
|
||||
The parameter
|
||||
.Fa oid
|
||||
must be a pointer to the
|
||||
.Va var
|
||||
field of the
|
||||
.Fa value
|
||||
argument of the node callback. The
|
||||
argument of the node callback.
|
||||
The
|
||||
.Fa sub
|
||||
argument must be the index of the start of the index in the OID (this is
|
||||
the
|
||||
@ -794,14 +840,16 @@ elements as follows:
|
||||
.Vt int32_t *
|
||||
expected as argument.
|
||||
.It Li COUNTER64
|
||||
.Vt u_int64_t *
|
||||
expected as argument. Note, that this syntax is illegal for indexes.
|
||||
.Vt uint64_t *
|
||||
expected as argument.
|
||||
Note, that this syntax is illegal for indexes.
|
||||
.It Li OCTET STRING
|
||||
A
|
||||
.Vt u_char **
|
||||
and a
|
||||
.Vt size_t *
|
||||
expected as arguments. A buffer is allocated to hold the decoded string.
|
||||
expected as arguments.
|
||||
A buffer is allocated to hold the decoded string.
|
||||
.It Li OID
|
||||
A
|
||||
.Vt struct asn_oid *
|
||||
@ -828,7 +876,8 @@ and
|
||||
.Fa sub
|
||||
resp.
|
||||
.Fa oid2
|
||||
is the OID to compare to. The function returns -1, 0, +1 when the
|
||||
is the OID to compare to.
|
||||
The function returns -1, 0, +1 when the
|
||||
variable is lesser, equal, higher to the given OID.
|
||||
.Fa oid2
|
||||
must contain only the index part of the table column.
|
||||
@ -861,7 +910,7 @@ beginning at position
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr gensnmptree 1 ,
|
||||
.Xr snmpd 1 ,
|
||||
.Xr bsnmpd 1 ,
|
||||
.Xr bsnmpagent 3 ,
|
||||
.Xr bsnmpclient 3 ,
|
||||
.Xr bsnmplib 3
|
||||
|
@ -26,7 +26,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Begemot: bsnmp/snmpd/snmpmod.h,v 1.28 2005/05/23 09:03:59 brandt_h Exp $
|
||||
* $Begemot: bsnmp/snmpd/snmpmod.h,v 1.31 2005/10/04 13:30:36 brandt_h Exp $
|
||||
*
|
||||
* SNMP daemon data and functions exported to modules.
|
||||
*/
|
||||
@ -46,7 +46,8 @@
|
||||
/*
|
||||
* These macros help to handle object lists for SNMP tables. They use
|
||||
* tail queues to hold the objects in ascending order in the list.
|
||||
* ordering can be done either on an integer/unsigned field or and asn_oid.
|
||||
* ordering can be done either on an integer/unsigned field, an asn_oid
|
||||
* or an ordering function.
|
||||
*/
|
||||
#define INSERT_OBJECT_OID_LINK_INDEX(PTR, LIST, LINK, INDEX) do { \
|
||||
__typeof (PTR) _lelem; \
|
||||
@ -72,6 +73,30 @@
|
||||
TAILQ_INSERT_BEFORE(_lelem, (PTR), LINK); \
|
||||
} while (0)
|
||||
|
||||
#define INSERT_OBJECT_FUNC_LINK(PTR, LIST, LINK, FUNC) do { \
|
||||
__typeof (PTR) _lelem; \
|
||||
\
|
||||
TAILQ_FOREACH(_lelem, (LIST), LINK) \
|
||||
if ((FUNC)(_lelem, (PTR)) > 0) \
|
||||
break; \
|
||||
if (_lelem == NULL) \
|
||||
TAILQ_INSERT_TAIL((LIST), (PTR), LINK); \
|
||||
else \
|
||||
TAILQ_INSERT_BEFORE(_lelem, (PTR), LINK); \
|
||||
} while (0)
|
||||
|
||||
#define INSERT_OBJECT_FUNC_LINK_REV(PTR, LIST, HEAD, LINK, FUNC) do { \
|
||||
__typeof (PTR) _lelem; \
|
||||
\
|
||||
TAILQ_FOREACH_REVERSE(_lelem, (LIST), HEAD, LINK) \
|
||||
if ((FUNC)(_lelem, (PTR)) < 0) \
|
||||
break; \
|
||||
if (_lelem == NULL) \
|
||||
TAILQ_INSERT_HEAD((LIST), (PTR), LINK); \
|
||||
else \
|
||||
TAILQ_INSERT_AFTER((LIST), _lelem, (PTR), LINK); \
|
||||
} while (0)
|
||||
|
||||
#define FIND_OBJECT_OID_LINK_INDEX(LIST, OID, SUB, LINK, INDEX) ({ \
|
||||
__typeof (TAILQ_FIRST(LIST)) _lelem; \
|
||||
\
|
||||
@ -114,6 +139,24 @@
|
||||
(_lelem); \
|
||||
})
|
||||
|
||||
#define FIND_OBJECT_FUNC_LINK(LIST, OID, SUB, LINK, FUNC) ({ \
|
||||
__typeof (TAILQ_FIRST(LIST)) _lelem; \
|
||||
\
|
||||
TAILQ_FOREACH(_lelem, (LIST), LINK) \
|
||||
if ((FUNC)(OID, SUB, _lelem) == 0) \
|
||||
break; \
|
||||
(_lelem); \
|
||||
})
|
||||
|
||||
#define NEXT_OBJECT_FUNC_LINK(LIST, OID, SUB, LINK, FUNC) ({ \
|
||||
__typeof (TAILQ_FIRST(LIST)) _lelem; \
|
||||
\
|
||||
TAILQ_FOREACH(_lelem, (LIST), LINK) \
|
||||
if ((FUNC)(OID, SUB, _lelem) < 0) \
|
||||
break; \
|
||||
(_lelem); \
|
||||
})
|
||||
|
||||
/*
|
||||
* Macros for the case where the index field is called 'index'
|
||||
*/
|
||||
@ -145,18 +188,27 @@
|
||||
#define INSERT_OBJECT_INT(PTR, LIST) \
|
||||
INSERT_OBJECT_INT_LINK_INDEX(PTR, LIST, link, index)
|
||||
|
||||
#define INSERT_OBJECT_FUNC_REV(PTR, LIST, HEAD, FUNC) \
|
||||
INSERT_OBJECT_FUNC_LINK_REV(PTR, LIST, HEAD, link, FUNC)
|
||||
|
||||
#define FIND_OBJECT_OID(LIST, OID, SUB) \
|
||||
FIND_OBJECT_OID_LINK_INDEX(LIST, OID, SUB, link, index)
|
||||
|
||||
#define FIND_OBJECT_INT(LIST, OID, SUB) \
|
||||
FIND_OBJECT_INT_LINK_INDEX(LIST, OID, SUB, link, index)
|
||||
|
||||
#define FIND_OBJECT_FUNC(LIST, OID, SUB, FUNC) \
|
||||
FIND_OBJECT_FUNC_LINK(LIST, OID, SUB, link, FUNC)
|
||||
|
||||
#define NEXT_OBJECT_OID(LIST, OID, SUB) \
|
||||
NEXT_OBJECT_OID_LINK_INDEX(LIST, OID, SUB, link, index)
|
||||
|
||||
#define NEXT_OBJECT_INT(LIST, OID, SUB) \
|
||||
NEXT_OBJECT_INT_LINK_INDEX(LIST, OID, SUB, link, index)
|
||||
|
||||
#define NEXT_OBJECT_FUNC(LIST, OID, SUB, FUNC) \
|
||||
NEXT_OBJECT_FUNC_LINK(LIST, OID, SUB, link, FUNC)
|
||||
|
||||
struct lmodule;
|
||||
|
||||
/* The tick when the program was started. This is the absolute time of
|
||||
@ -214,7 +266,7 @@ struct snmp_module {
|
||||
/* a comment describing what this module implements */
|
||||
const char *comment;
|
||||
|
||||
/* the initialisation function */
|
||||
/* the initialization function */
|
||||
int (*init)(struct lmodule *, int argc, char *argv[]);
|
||||
|
||||
/* the finalisation function */
|
||||
@ -301,6 +353,8 @@ u_int reqid_type(int32_t reqid);
|
||||
* Timers.
|
||||
*/
|
||||
void *timer_start(u_int, void (*)(void *), void *, struct lmodule *);
|
||||
void *timer_start_repeat(u_int, u_int, void (*)(void *), void *,
|
||||
struct lmodule *);
|
||||
void timer_stop(void *);
|
||||
|
||||
/*
|
||||
|
@ -26,7 +26,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Begemot: bsnmp/snmpd/trans_udp.c,v 1.4 2004/08/06 08:47:16 brandt Exp $
|
||||
* $Begemot: bsnmp/snmpd/trans_udp.c,v 1.5 2005/10/04 08:46:56 brandt_h Exp $
|
||||
*
|
||||
* UDP transport
|
||||
*/
|
||||
@ -137,7 +137,7 @@ udp_init_port(struct tport *tp)
|
||||
|
||||
/*
|
||||
* Create a new SNMP Port object and start it, if we are not
|
||||
* in initialisation mode. The arguments are in host byte order.
|
||||
* in initialization mode. The arguments are in host byte order.
|
||||
*/
|
||||
static int
|
||||
udp_open_port(u_int8_t *addr, u_int32_t udp_port, struct udp_port **pp)
|
||||
|
@ -26,7 +26,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Begemot: bsnmp/snmpd/trap.c,v 1.8 2004/08/06 08:47:17 brandt Exp $
|
||||
* $Begemot: bsnmp/snmpd/trap.c,v 1.9 2005/10/04 11:21:39 brandt_h Exp $
|
||||
*
|
||||
* TrapSinkTable
|
||||
*/
|
||||
@ -107,7 +107,7 @@ trapsink_create(struct trapsink_dep *tdep)
|
||||
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user