You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-12-24 14:20:59 +03:00
Remove net-snmp and use the OS version
Also remove a few old binaries from build/
This commit is contained in:
@@ -47,6 +47,7 @@ SET (ENGINE_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
SET (INSTALL_ENGINE "/usr/local/mariadb/columnstore")
|
||||
|
||||
INCLUDE (configureEngine.cmake)
|
||||
INCLUDE (FindNetSNMP.cmake)
|
||||
|
||||
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
||||
|
||||
@@ -66,6 +67,10 @@ if (NOT LIBXML2_FOUND)
|
||||
MESSAGE(FATAL_ERROR "Could not find a usable libxml2 development environment!")
|
||||
endif()
|
||||
|
||||
if (NOT NETSNMP_FOUND)
|
||||
MESSAGE(FATAL_ERROR "Could not find net-snmp!")
|
||||
endif()
|
||||
|
||||
FIND_PROGRAM(AWK_EXECUTABLE awk DOC "path to the awk executable")
|
||||
if(NOT AWK_EXECUTABLE)
|
||||
message(FATAL_ERROR "awk not found!")
|
||||
@@ -98,9 +103,8 @@ SET (ENGINE_MYSQLDIR "${INSTALL_ENGINE}/mysql")
|
||||
SET (ENGINE_MIBDIR "${INSTALL_ENGINE}/share/snmp/mibs")
|
||||
SET (ENGINE_TOOLSDIR "${INSTALL_ENGINE}/tools")
|
||||
|
||||
SET (ENGINE_NETSNMP_LIBS "-L${CMAKE_CURRENT_SOURCE_DIR}/net-snmp/net-snmp/snmplib/.libs -L${CMAKE_CURRENT_SOURCE_DIR}/net-snmp/net-snmp/agent/helpers/.libs -L${CMAKE_CURRENT_SOURCE_DIR}/net-snmp/net-snmp/agent/.libs/ -L${CMAKE_CURRENT_SOURCE_DIR}/net-snmp/net-snmp/apps/.libs/ -lnetsnmpmibs -lnetsnmpagent -lnetsnmp -lnetsnmpmibs -lnetsnmphelpers")
|
||||
SET (ENGINE_COMMON_LIBS messageqcpp loggingcpp configcpp idbboot ${Boost_LIBRARIES} xml2 pthread rt)
|
||||
SET (ENGINE_OAM_LIBS oamcpp snmpmanager ${ENGINE_NETSNMP_LIBS})
|
||||
SET (ENGINE_OAM_LIBS oamcpp snmpmanager)
|
||||
SET (ENGINE_BRM_LIBS brm idbdatafile cacheutils rwlock ${ENGINE_OAM_LIBS} ${ENGINE_COMMON_LIBS})
|
||||
SET (ENGINE_EXEC_LIBS joblist execplan windowfunction joiner rowgroup funcexp udfsdk dataconvert common compress mysqlcl_idb querystats querytele thrift threadpool ${ENGINE_BRM_LIBS})
|
||||
SET (ENGINE_WRITE_LIBS ddlpackageproc ddlpackage dmlpackageproc dmlpackage writeengine writeengineclient idbdatafile cacheutils ${ENGINE_EXEC_LIBS})
|
||||
@@ -151,25 +155,12 @@ SET (ENGINE_SERVER_INCLUDE_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/../../../incl
|
||||
SET (ENGINE_SERVER_INCLUDE_INCLUDE2 "${CMAKE_CURRENT_SOURCE_DIR}/../include")
|
||||
SET (ENGINE_SERVER_PCRE_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/../../../pcre")
|
||||
SET (ENGINE_SERVER_PCRE_INCLUDE2 "${CMAKE_CURRENT_SOURCE_DIR}/../pcre")
|
||||
SET (ENGINE_NETSNMP_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/net-snmp/net-snmp")
|
||||
SET (ENGINE_NETSNMP_INCLUDE2 "${CMAKE_CURRENT_SOURCE_DIR}/net-snmp/net-snmp/include")
|
||||
|
||||
SET (ENGINE_DEFAULT_INCLUDES "." "../" "../..")
|
||||
|
||||
SET (ENGINE_COMMON_INCLUDES ${ENGINE_DEFAULT_INCLUDES} ${Boost_INCLUDE_DIR} ${ENGINE_UTILS_XML_INCLUDE} ${ENGINE_UTILS_MESSAGEQCPP_INCLUDE} ${ENGINE_WE_SHARED_INCLUDE} ${ENGINE_UTILS_IDBDATAFILE_INCLUDE} ${ENGINE_UTILS_LOGGINGCPP_INCLUDE} ${ENGINE_UTILS_CONFIGCPP_INCLUDE} ${ENGINE_UTILS_COMPRESS_INCLUDE} ${ENGINE_VERSIONING_BRM_INCLUDE} ${ENGINE_UTILS_ROWGROUP_INCLUDE} ${ENGINE_UTILS_COMMON_INCLUDE} ${ENGINE_UTILS_DATACONVERT_INCLUDE} ${ENGINE_UTILS_RWLOCK_INCLUDE} ${ENGINE_UTILS_FUNCEXP_INCLUDE} ${ENGINE_SNMPD_SNMPMANAGER_INCLUDE} ${ENGINE_UTILS_INCLUDE} ${ENGINE_OAM_OAMCPP_INCLUDE} ${ENGINE_DBCON_DDLPKGPROC_INCLUDE} ${ENGINE_DBCON_DDLPKG_INCLUDE} ${ENGINE_DBCON_EXECPLAN_INCLUDE} ${ENGINE_UTILS_STARTUP_INCLUDE} ${ENGINE_DBCON_JOBLIST_INCLUDE} ${ENGINE_WE_WRAPPER_INCLUDE} ${ENGINE_WE_SERVER_INCLUDE} ${ENGINE_DBCON_DMLPKG_INCLUDE} ${ENGINE_WE_CLIENT_INCLUDE} ${ENGINE_DBCON_DMLPKGPROC_INCLUDE} ${ENGINE_UTILS_CACHEUTILS_INCLUDE} ${ENGINE_UTILS_MYSQLCL_INCLUDE} ${ENGINE_UTILS_QUERYTELE_INCLUDE} ${ENGINE_UTILS_THRIFT_INCLUDE} ${ENGINE_UTILS_JOINER_INCLUDE} ${ENGINE_UTILS_THREADPOOL_INCLUDE} ${ENGINE_UTILS_BATCHLDR_INCLUDE} ${ENGINE_UTILS_DDLCLEANUP_INCLUDE} ${ENGINE_UTILS_QUERYSTATS_INCLUDE} ${ENGINE_WE_CONFIGCPP_INCLUDE} ${ENGINE_SERVER_SQL_INCLUDE} ${ENGINE_SERVER_INCLUDE_INCLUDE} ${ENGINE_SERVER_PCRE_INCLUDE} ${ENGINE_SERVER_SQL2_INCLUDE} ${ENGINE_SERVER_INCLUDE_INCLUDE2} ${ENGINE_SERVER_PCRE_INCLUDE2} ${ENGINE_NETSNMP_INCLUDE} ${ENGINE_NETSNMP_INCLUDE2})
|
||||
SET (ENGINE_COMMON_INCLUDES ${ENGINE_DEFAULT_INCLUDES} ${Boost_INCLUDE_DIR} ${ENGINE_UTILS_XML_INCLUDE} ${ENGINE_UTILS_MESSAGEQCPP_INCLUDE} ${ENGINE_WE_SHARED_INCLUDE} ${ENGINE_UTILS_IDBDATAFILE_INCLUDE} ${ENGINE_UTILS_LOGGINGCPP_INCLUDE} ${ENGINE_UTILS_CONFIGCPP_INCLUDE} ${ENGINE_UTILS_COMPRESS_INCLUDE} ${ENGINE_VERSIONING_BRM_INCLUDE} ${ENGINE_UTILS_ROWGROUP_INCLUDE} ${ENGINE_UTILS_COMMON_INCLUDE} ${ENGINE_UTILS_DATACONVERT_INCLUDE} ${ENGINE_UTILS_RWLOCK_INCLUDE} ${ENGINE_UTILS_FUNCEXP_INCLUDE} ${ENGINE_SNMPD_SNMPMANAGER_INCLUDE} ${ENGINE_UTILS_INCLUDE} ${ENGINE_OAM_OAMCPP_INCLUDE} ${ENGINE_DBCON_DDLPKGPROC_INCLUDE} ${ENGINE_DBCON_DDLPKG_INCLUDE} ${ENGINE_DBCON_EXECPLAN_INCLUDE} ${ENGINE_UTILS_STARTUP_INCLUDE} ${ENGINE_DBCON_JOBLIST_INCLUDE} ${ENGINE_WE_WRAPPER_INCLUDE} ${ENGINE_WE_SERVER_INCLUDE} ${ENGINE_DBCON_DMLPKG_INCLUDE} ${ENGINE_WE_CLIENT_INCLUDE} ${ENGINE_DBCON_DMLPKGPROC_INCLUDE} ${ENGINE_UTILS_CACHEUTILS_INCLUDE} ${ENGINE_UTILS_MYSQLCL_INCLUDE} ${ENGINE_UTILS_QUERYTELE_INCLUDE} ${ENGINE_UTILS_THRIFT_INCLUDE} ${ENGINE_UTILS_JOINER_INCLUDE} ${ENGINE_UTILS_THREADPOOL_INCLUDE} ${ENGINE_UTILS_BATCHLDR_INCLUDE} ${ENGINE_UTILS_DDLCLEANUP_INCLUDE} ${ENGINE_UTILS_QUERYSTATS_INCLUDE} ${ENGINE_WE_CONFIGCPP_INCLUDE} ${ENGINE_SERVER_SQL_INCLUDE} ${ENGINE_SERVER_INCLUDE_INCLUDE} ${ENGINE_SERVER_PCRE_INCLUDE} ${ENGINE_SERVER_SQL2_INCLUDE} ${ENGINE_SERVER_INCLUDE_INCLUDE2} ${ENGINE_SERVER_PCRE_INCLUDE2})
|
||||
|
||||
|
||||
INCLUDE (ExternalProject)
|
||||
ExternalProject_Add(
|
||||
libnetsnmpmibs
|
||||
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/net-snmp/net-snmp
|
||||
CONFIGURE_COMMAND ./configure --prefix=${INSTALL_ENGINE} --with-mib-modules=disman/event-mib --with-cc=gcc --with-logfile=${INSTALL_ENGINE}/log/snmpd.log --with-sys-location=Unknown --with-sys-contact=root@localhost.localdomain --with-default-snmp-version=3 --with-persistent-directory=${INSTALL_ENGINE}/var/net-snmp --without-openssl --with-ldflags=-Wl,-rpath\ -Wl,${INSTALL_ENGINE}/lib
|
||||
BUILD_COMMAND make
|
||||
INSTALL_COMMAND ""
|
||||
BUILD_IN_SOURCE 1
|
||||
)
|
||||
INSTALL ( CODE "EXECUTE_PROCESS(COMMAND make install WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/net-snmp/net-snmp)")
|
||||
|
||||
ADD_SUBDIRECTORY(utils)
|
||||
ADD_SUBDIRECTORY(oam/oamcpp)
|
||||
ADD_SUBDIRECTORY(snmpd)
|
||||
|
||||
74
FindNetSNMP.cmake
Normal file
74
FindNetSNMP.cmake
Normal file
@@ -0,0 +1,74 @@
|
||||
# - Find Net-SNMP
|
||||
#
|
||||
# -*- cmake -*-
|
||||
#
|
||||
# Find the Net-SNMP module
|
||||
#
|
||||
# NETSNMP_INCLUDE_DIR - where to find Net-SNMP.h, etc.
|
||||
# NETSNMP_LIBRARIES - List of libraries when using Net-SNMP.
|
||||
# NETSNMP_FOUND - True if Net-SNMP found.
|
||||
|
||||
IF (NETSNMP_INCLUDE_DIR)
|
||||
# Already in cache, be silent
|
||||
SET(NETSNMP_FIND_QUIETLY TRUE)
|
||||
ENDIF (NETSNMP_INCLUDE_DIR)
|
||||
|
||||
FIND_PATH(NETSNMP_INCLUDE_DIR snmp.h
|
||||
/usr/include/net-snmp/library
|
||||
)
|
||||
|
||||
SET(NETSNMP_NAMES netsnmp)
|
||||
FIND_LIBRARY(NETSNMP_LIBRARY
|
||||
NAMES ${NETSNMP_NAMES}
|
||||
PATHS /usr/lib /usr/local/lib
|
||||
)
|
||||
|
||||
SET(NETSNMPAGENT_NAMES netsnmpagent)
|
||||
FIND_LIBRARY(NETSNMPAGENT_LIBRARY
|
||||
NAMES ${NETSNMPAGENT_NAMES}
|
||||
PATHS /usr/lib /usr/local/lib
|
||||
)
|
||||
|
||||
SET(NETSNMPHELPERS_NAMES netsnmphelpers)
|
||||
FIND_LIBRARY(NETSNMPHELPERS_LIBRARY
|
||||
NAMES ${NETSNMPHELPERS_NAMES}
|
||||
PATHS /usr/lib /usr/local/lib
|
||||
)
|
||||
|
||||
SET(NETSNMPMIBS_NAMES netsnmpmibs)
|
||||
FIND_LIBRARY(NETSNMPMIBS_LIBRARY
|
||||
NAMES ${NETSNMPMIBS_NAMES}
|
||||
PATHS /usr/lib /usr/local/lib
|
||||
)
|
||||
|
||||
SET(NETSNMPTRAPD_NAMES netsnmptrapd)
|
||||
FIND_LIBRARY(NETSNMPTRAPD_LIBRARY
|
||||
NAMES ${NETSNMPTRAPD_NAMES}
|
||||
PATHS /usr/lib /usr/local/lib
|
||||
)
|
||||
|
||||
SET(NETSNMP_LIBRARIES
|
||||
${NETSNMP_LIBRARY}
|
||||
${NETSNMPAGENT_LIBRARY}
|
||||
${NETSNMPHELPERS_LIBRARY}
|
||||
${NETSNMPMIBS_LIBRARY}
|
||||
# ${NETSNMPTRAPD_LIBRARY}
|
||||
)
|
||||
|
||||
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(NETSNMP
|
||||
DEFAULT_MSG
|
||||
NETSNMP_INCLUDE_DIR
|
||||
NETSNMP_LIBRARIES
|
||||
)
|
||||
|
||||
MARK_AS_ADVANCED(
|
||||
NETSNMP_LIBRARY
|
||||
NETSNMPAGENT_LIBRARY
|
||||
NETSNMPHELPERS_LIBRARY
|
||||
NETSNMPMIBS_LIBRARY
|
||||
NETSNMPTRAPD_LIBRARY
|
||||
NETSNMP_INCLUDE_DIR
|
||||
)
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -14,7 +14,7 @@ set(ddlpackageproc_LIB_SRCS
|
||||
|
||||
add_library(ddlpackageproc SHARED ${ddlpackageproc_LIB_SRCS})
|
||||
|
||||
add_dependencies(ddlpackageproc libnetsnmpmibs)
|
||||
target_link_libraries(ddlpackageproc ${NETSNMP_LIBRARIES})
|
||||
|
||||
set_target_properties(ddlpackageproc PROPERTIES VERSION 1.0.0 SOVERSION 1)
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ set(dmlpackageproc_LIB_SRCS
|
||||
|
||||
add_library(dmlpackageproc SHARED ${dmlpackageproc_LIB_SRCS})
|
||||
|
||||
add_dependencies(dmlpackageproc libnetsnmpmibs)
|
||||
target_link_libraries(dmlpackageproc ${NETSNMP_LIBRARIES})
|
||||
|
||||
set_target_properties(dmlpackageproc PROPERTIES VERSION 1.0.0 SOVERSION 1)
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ set(execplan_LIB_SRCS
|
||||
|
||||
add_library(execplan SHARED ${execplan_LIB_SRCS})
|
||||
|
||||
add_dependencies(execplan libnetsnmpmibs)
|
||||
target_link_libraries(execplan ${NETSNMP_LIBRARIES})
|
||||
|
||||
set_target_properties(execplan PROPERTIES VERSION 1.0.0 SOVERSION 1)
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ set(joblist_LIB_SRCS
|
||||
|
||||
add_library(joblist SHARED ${joblist_LIB_SRCS})
|
||||
|
||||
add_dependencies(joblist libnetsnmpmibs)
|
||||
target_link_libraries(joblist ${NETSNMP_LIBRARIES})
|
||||
|
||||
set_target_properties(joblist PROPERTIES VERSION 1.0.0 SOVERSION 1)
|
||||
|
||||
|
||||
@@ -28,9 +28,7 @@ set_source_files_properties(ha_calpont.cpp PROPERTIES COMPILE_FLAGS "-fno-rtti -
|
||||
|
||||
add_library(calmysql SHARED ${libcalmysql_SRCS})
|
||||
|
||||
add_dependencies(calmysql libnetsnmpmibs)
|
||||
|
||||
target_link_libraries(calmysql ${ENGINE_LDFLAGS} ${ENGINE_WRITE_LIBS} threadpool)
|
||||
target_link_libraries(calmysql ${ENGINE_LDFLAGS} ${ENGINE_WRITE_LIBS} ${NETSNMP_LIBRARIES} threadpool)
|
||||
|
||||
set_target_properties(calmysql PROPERTIES VERSION 1.0.0 SOVERSION 1)
|
||||
|
||||
|
||||
@@ -8,9 +8,7 @@ set(DDLProc_SRCS ddlproc.cpp ddlprocessor.cpp)
|
||||
|
||||
add_executable(DDLProc ${DDLProc_SRCS})
|
||||
|
||||
add_dependencies(DDLProc libnetsnmpmibs)
|
||||
|
||||
target_link_libraries(DDLProc ${ENGINE_LDFLAGS} ${ENGINE_WRITE_LIBS} threadpool)
|
||||
target_link_libraries(DDLProc ${ENGINE_LDFLAGS} ${ENGINE_WRITE_LIBS} ${NETSNMP_LIBRARIES} threadpool)
|
||||
|
||||
install(TARGETS DDLProc DESTINATION ${ENGINE_BINDIR})
|
||||
|
||||
|
||||
@@ -12,9 +12,7 @@ set(DMLProc_SRCS
|
||||
|
||||
add_executable(DMLProc ${DMLProc_SRCS})
|
||||
|
||||
add_dependencies(DMLProc libnetsnmpmibs)
|
||||
|
||||
target_link_libraries(DMLProc ${ENGINE_LDFLAGS} ${ENGINE_WRITE_LIBS} threadpool ddlcleanuputil batchloader)
|
||||
target_link_libraries(DMLProc ${ENGINE_LDFLAGS} ${ENGINE_WRITE_LIBS} ${NETSNMP_LIBRARIES} threadpool ddlcleanuputil batchloader)
|
||||
|
||||
install(TARGETS DMLProc DESTINATION ${ENGINE_BINDIR})
|
||||
|
||||
|
||||
@@ -8,9 +8,7 @@ set(ExeMgr_SRCS main.cpp activestatementcounter.cpp femsghandler.cpp)
|
||||
|
||||
add_executable(ExeMgr ${ExeMgr_SRCS})
|
||||
|
||||
add_dependencies(ExeMgr libnetsnmpmibs)
|
||||
|
||||
target_link_libraries(ExeMgr ${ENGINE_LDFLAGS} ${ENGINE_EXEC_LIBS} cacheutils threadpool)
|
||||
target_link_libraries(ExeMgr ${ENGINE_LDFLAGS} ${ENGINE_EXEC_LIBS} ${NETSNMP_LIBRARIES} cacheutils threadpool)
|
||||
|
||||
install(TARGETS ExeMgr DESTINATION ${ENGINE_BINDIR})
|
||||
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
# $Id$
|
||||
|
||||
.PHONY: test coverage leakcheck docs bootstrap install clean
|
||||
test:
|
||||
|
||||
coverage:
|
||||
|
||||
leakcheck:
|
||||
|
||||
docs:
|
||||
|
||||
all:
|
||||
$(MAKE) -C net-snmp
|
||||
|
||||
install:
|
||||
$(MAKE) -C net-snmp install
|
||||
|
||||
clean:
|
||||
$(MAKE) -C net-snmp clean
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
net-snmp-5.7.3/
|
||||
116
net-snmp/net-snmp-5.7.3/.gitignore
vendored
116
net-snmp/net-snmp-5.7.3/.gitignore
vendored
@@ -1,116 +0,0 @@
|
||||
*~
|
||||
*.bak
|
||||
*.bs
|
||||
*.ft
|
||||
*.ft.1
|
||||
*.la
|
||||
*.lo
|
||||
*.made
|
||||
*.o
|
||||
*.obj
|
||||
*.old
|
||||
*.orig
|
||||
*.out
|
||||
*.pdb
|
||||
*.rej
|
||||
.libs/
|
||||
agent/*.exe
|
||||
agent/mibgroup/agent_module_dot_conf.h
|
||||
agent/mibgroup/agent_module_includes.h
|
||||
agent/mibgroup/agent_module_inits.h
|
||||
agent/mibgroup/agent_module_shutdown.h
|
||||
agent/mibgroup/mib_module_dot_conf.h
|
||||
agent/mibgroup/mib_module_includes.h
|
||||
agent/mibgroup/mib_module_inits.h
|
||||
agent/mibgroup/mib_module_shutdown.h
|
||||
agent/snmpd
|
||||
apps/*.exe
|
||||
apps/agentxtrap
|
||||
apps/encode_keychange
|
||||
apps/snmpbulkget
|
||||
apps/snmpbulkwalk
|
||||
apps/snmpdelta
|
||||
apps/snmpdf
|
||||
apps/snmpget
|
||||
apps/snmpgetnext
|
||||
apps/snmpnetstat/*.exe
|
||||
apps/snmpnetstat/snmpnetstat
|
||||
apps/snmpset
|
||||
apps/snmpstatus
|
||||
apps/snmptable
|
||||
apps/snmptest
|
||||
apps/snmptls
|
||||
apps/snmptranslate
|
||||
apps/snmptrap
|
||||
apps/snmptrapd
|
||||
apps/snmpusm
|
||||
apps/snmpvacm
|
||||
apps/snmpwalk
|
||||
apps/sshtosnmp
|
||||
autom4te.cache/
|
||||
ChangeLog.add*
|
||||
ChangeLog.reallyadd
|
||||
CHANGES.new*
|
||||
confdefs.h
|
||||
config.cache
|
||||
config.log
|
||||
config.status
|
||||
configure-summary
|
||||
dist/generation-scripts/gen-variables
|
||||
docs/html
|
||||
docs/latex
|
||||
EXAMPLE.conf
|
||||
include/net-snmp/agent/agent_module_config.h
|
||||
include/net-snmp/agent/mib_module_config.h
|
||||
include/net-snmp/library/snmpv3-security-includes.h
|
||||
include/net-snmp/net-snmp-config.h
|
||||
libtool
|
||||
local/snmpcheck
|
||||
local/snmpconf
|
||||
Makefile
|
||||
man/*.[1358]
|
||||
man/default_store.3.h
|
||||
man/manaliases
|
||||
mibs/.index
|
||||
mk/
|
||||
module_tmp_header.h
|
||||
net-snmp-5*
|
||||
net-snmp-6*
|
||||
net-snmp-config
|
||||
net-snmp-config-x
|
||||
net-snmp-create-v3-user
|
||||
NEWS.new*
|
||||
perl/*.yml
|
||||
perl/*/*.def
|
||||
perl/*/*.yml
|
||||
perl/*/*/*.yml
|
||||
perl/agent/agent.c
|
||||
perl/agent/default_store/default_store.c
|
||||
perl/agent/default_store/default_store.def
|
||||
perl/ASN/ASN.c
|
||||
perl/blib/
|
||||
perl/default_store/default_store.c
|
||||
perl/NetSNMP.c
|
||||
perl/OID/OID.c
|
||||
perl/SNMP/SNMP.c
|
||||
perl/SNMP/t/*.log
|
||||
perl/SNMP/t/*.pid
|
||||
perl/SNMP/t/*.stderr
|
||||
perl/SNMP/t/snmptest.cmd
|
||||
perl/TrapReceiver/const-c.inc
|
||||
perl/TrapReceiver/const-xs.inc
|
||||
perl/TrapReceiver/TrapReceiver.c
|
||||
pm_to_blib
|
||||
python/build
|
||||
sedscript
|
||||
snmplib/snmpsm_init.h
|
||||
snmplib/snmpsm_shutdown.h
|
||||
snmplib/transports/snmp_transport_inits.h
|
||||
stamp-h
|
||||
TAGS
|
||||
testing/failed_tests
|
||||
testing/testing/
|
||||
win32/*/debug
|
||||
win32/*/release
|
||||
win32/bin
|
||||
win32/lib
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,327 +0,0 @@
|
||||
Various copyrights apply to this package, listed in various separate
|
||||
parts below. Please make sure that you read all the parts.
|
||||
|
||||
---- Part 1: CMU/UCD copyright notice: (BSD like) -----
|
||||
|
||||
|
||||
Copyright 1989, 1991, 1992 by Carnegie Mellon University
|
||||
|
||||
Derivative Work - 1996, 1998-2000
|
||||
Copyright 1996, 1998-2000 The Regents of the University of California
|
||||
|
||||
All Rights Reserved
|
||||
|
||||
Permission to use, copy, modify and distribute this software and its
|
||||
documentation for any purpose and without fee is hereby granted,
|
||||
provided that the above copyright notice appears in all copies and
|
||||
that both that copyright notice and this permission notice appear in
|
||||
supporting documentation, and that the name of CMU and The Regents of
|
||||
the University of California not be used in advertising or publicity
|
||||
pertaining to distribution of the software without specific written
|
||||
permission.
|
||||
|
||||
CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
|
||||
WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
|
||||
THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
|
||||
INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
|
||||
FROM THE LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
|
||||
CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
|
||||
---- Part 2: Networks Associates Technology, Inc copyright notice (BSD) -----
|
||||
|
||||
Copyright (c) 2001-2003, Networks Associates Technology, Inc
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of the Networks Associates Technology, Inc nor the
|
||||
names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
|
||||
IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
---- Part 3: Cambridge Broadband Ltd. copyright notice (BSD) -----
|
||||
|
||||
Portions of this code are copyright (c) 2001-2003, Cambridge Broadband Ltd.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* The name of Cambridge Broadband Ltd. may not be used to endorse or
|
||||
promote products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``AS IS'' AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
---- Part 4: Sun Microsystems, Inc. copyright notice (BSD) -----
|
||||
|
||||
Copyright <20> 2003 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
California 95054, U.S.A. All rights reserved.
|
||||
|
||||
Use is subject to license terms below.
|
||||
|
||||
This distribution may include materials developed by third parties.
|
||||
|
||||
Sun, Sun Microsystems, the Sun logo and Solaris are trademarks or registered
|
||||
trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of the Sun Microsystems, Inc. nor the
|
||||
names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
|
||||
IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
---- Part 5: Sparta, Inc copyright notice (BSD) -----
|
||||
|
||||
Copyright (c) 2003-2013, Sparta, Inc
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of Sparta, Inc nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
|
||||
IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
---- Part 6: Cisco/BUPTNIC copyright notice (BSD) -----
|
||||
|
||||
Copyright (c) 2004, Cisco, Inc and Information Network
|
||||
Center of Beijing University of Posts and Telecommunications.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of Cisco, Inc, Beijing University of Posts and
|
||||
Telecommunications, nor the names of their contributors may
|
||||
be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
|
||||
IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
---- Part 7: Fabasoft R&D Software GmbH & Co KG copyright notice (BSD) -----
|
||||
|
||||
Copyright (c) Fabasoft R&D Software GmbH & Co KG, 2003
|
||||
oss@fabasoft.com
|
||||
Author: Bernhard Penz <bernhard.penz@fabasoft.com>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* The name of Fabasoft R&D Software GmbH & Co KG or any of its subsidiaries,
|
||||
brand or product names may not be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``AS IS'' AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
---- Part 8: Apple Inc. copyright notice (BSD) -----
|
||||
|
||||
Copyright (c) 2007 Apple Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
3. Neither the name of Apple Inc. ("Apple") nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
|
||||
---- Part 9: ScienceLogic, LLC copyright notice (BSD) -----
|
||||
|
||||
Copyright (c) 2009, ScienceLogic, LLC
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of ScienceLogic, LLC nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGE.
|
||||
|
||||
---- Part 10: IETF copyright notice (BSD) -----
|
||||
|
||||
Copyright (c) 2013 IETF Trust and the persons identified as authors of
|
||||
the code. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
· Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
· Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
· Neither the name of Internet Society, IETF or IETF Trust, nor the
|
||||
names of specific contributors, may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS
|
||||
IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,69 +0,0 @@
|
||||
The discussion about coding style on the net-snmp-coders mailing list
|
||||
can be found at the following web address:
|
||||
|
||||
http://sourceforge.net/mailarchive/message.php?msg_id=1009885
|
||||
(Thread "design proposal - coding style" started on 2001-02-08)
|
||||
|
||||
----------------------------------------------------------------------
|
||||
Indentation:
|
||||
|
||||
We've adopted the following indent style:
|
||||
|
||||
indent -orig -nbc -bap -nut -nfca -T netsnmp_mib_handler -T netsnmp_handler_registration -T netsnmp_handler_args -T netsnmp_delegated_cache -T netsnmp_baby_steps_modes -T netsnmp_baby_steps_access_methods -T netsnmp_mode_handler_list -T netsnmp_mib_handler_methods -T netsnmp_monitor_callback_header -T netsnmp_monitor_set_request_data -T netsnmp_monitor_callback_cooperative -T netsnmp_old_api_info -T netsnmp_old_api_cache -T netsnmp_row_merge_status -T netsnmp_scalar_group -T netsnmp_set_info -T netsnmp_request_info -T netsnmp_set_info -T netsnmp_tree_cache -T netsnmp_agent_request_info -T netsnmp_cachemap -T netsnmp_agent_session -T netsnmp_stash_cache_info -T netsnmp_stash_cache_data -T netsnmp_request_group_item -T netsnmp_request_group -T netsnmp_table_array_callbacks -T netsnmp_table_row -T netsnmp_table_data -T netsnmp_table_data_set_storage -T netsnmp_table_data_set -T netsnmp_column_info -T netsnmp_table_registration_info -T netsnmp_table_request_info -T netsnmp_iterator_info -T netsnmp_tdata_row -T netsnmp_tdata -T netsnmp_subtree -T netsnmp_watcher_info -T netsnmp_arp_entry -T netsnmp_interface_stats -T netsnmp_interface_entry -T netsnmp_conf_if_list -T netsnmp_ipaddress_entry -T netsnmp_ipstats -T netsnmp_route_entry -T netsnmp_systemstats_entry -T netsnmp_tcpconn_entry -T netsnmp_udp_endpoint_entry -T netsnmp_container -T netsnmp_iterator -T netsnmp_data_list -T netsnmp_data_list_saveinfo -T netsnmp_factory -T netsnmp_file -T netsnmp_oid_stash_node -T netsnmp_oid_stash_save_info -T netsnmp_pdu -T netsnmp_request_list -T netsnmp_vardata -T netsnmp_callback_pass -T netsnmp_callback_info -T netsnmp_token_descr -T netsnmp_std_data -T netsnmp_transport -T netsnmp_transport_list -T netsnmp_tdomain -T netsnmp_line_info -T netsnmp_line_process_info -T netsnmp_token_value_index
|
||||
|
||||
[wow, what an annoying list! The above -T list can be (re)generated by
|
||||
running:
|
||||
perl -n -e 'print "-T $1 " if (/}\s*(netsnmp_\w+)\s*;/);' */*.h
|
||||
in the include/net-snmp directory]
|
||||
|
||||
If possible, please run all new code submitted to the project through
|
||||
the above command. However, if sending a patch, please do *not* send
|
||||
a patch that reformats the entire file. Just the new sections of code
|
||||
should be in the above style to make it easier for us to dissect what
|
||||
you did in your patch.
|
||||
|
||||
Briefly, here's a description of the style:
|
||||
|
||||
Blank lines:
|
||||
after procedures
|
||||
not (forced) after blocks of declarations or block comments
|
||||
multiple declarations not split onto separate lines
|
||||
|
||||
Comments:
|
||||
Block comments indented 4 spaces from surrounding code
|
||||
Start/End on separate lines
|
||||
Solid '*' on the left of block comments
|
||||
"One-line" comments start in column 33
|
||||
|
||||
Bracing/Indent/etc:
|
||||
K&R-style bracing (including "cuddle-else")
|
||||
'case' statements in line with 'switch'
|
||||
No space between procedure name and opening parenthesis
|
||||
variable declarations lined up, and start in column 16
|
||||
Procedure return type on a separate line to the procedure name
|
||||
Four character basic and continuation line indent
|
||||
No tabs used in the file, always use 8 spaces instead.
|
||||
Continuation parameters lined up with opening parenthesis
|
||||
|
||||
----------------------------------------------------------------------
|
||||
Function names and Variable names:
|
||||
|
||||
should_be_like_this and notLikeThis
|
||||
|
||||
New public functions and defines should ideally start with a netsnmp_
|
||||
or NETSNMP_ prefix, respectively.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
Structures:
|
||||
|
||||
We have decided to typedef all structures into names using the
|
||||
following convention:
|
||||
|
||||
typedef struct netsnmp_wombat_s {
|
||||
int something_cool;
|
||||
} netsnmp_wombat;
|
||||
|
||||
The important things to note here are that the struct name ends in a
|
||||
"_s", the typedef name doesn't end in "_t", and the typedef is not to a
|
||||
pointer and everything begins with "netsnmp_".
|
||||
|
||||
@@ -1,193 +0,0 @@
|
||||
###############################################################################
|
||||
#
|
||||
# EXAMPLE.conf:
|
||||
# An example configuration file for configuring the Net-SNMP agent ('snmpd')
|
||||
# See the 'snmpd.conf(5)' man page for details
|
||||
#
|
||||
# Some entries are deliberately commented out, and will need to be explicitly activated
|
||||
#
|
||||
###############################################################################
|
||||
#
|
||||
# AGENT BEHAVIOUR
|
||||
#
|
||||
|
||||
# Listen for connections from the local system only
|
||||
agentAddress udp:127.0.0.1:161
|
||||
# Listen for connections on all interfaces (both IPv4 *and* IPv6)
|
||||
#agentAddress udp:161,udp6:[::1]:161
|
||||
|
||||
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# SNMPv3 AUTHENTICATION
|
||||
#
|
||||
# Note that these particular settings don't actually belong here.
|
||||
# They should be copied to the file /var/net-snmp/snmpd.conf
|
||||
# and the passwords changed, before being uncommented in that file *only*.
|
||||
# Then restart the agent
|
||||
|
||||
# createUser authOnlyUser MD5 "remember to change this password"
|
||||
# createUser authPrivUser SHA "remember to change this one too" DES
|
||||
# createUser internalUser MD5 "this is only ever used internally, but still change the password"
|
||||
|
||||
# If you also change the usernames (which might be sensible),
|
||||
# then remember to update the other occurances in this example config file to match.
|
||||
|
||||
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# ACCESS CONTROL
|
||||
#
|
||||
|
||||
# system + hrSystem groups only
|
||||
view systemonly included .1.3.6.1.2.1.1
|
||||
view systemonly included .1.3.6.1.2.1.25.1
|
||||
|
||||
# Full access from the local host
|
||||
#rocommunity public localhost
|
||||
# Default access to basic system info
|
||||
rocommunity public default -V systemonly
|
||||
|
||||
# Full access from an example network
|
||||
# Adjust this network address to match your local
|
||||
# settings, change the community string,
|
||||
# and check the 'agentAddress' setting above
|
||||
#rocommunity secret 10.0.0.0/16
|
||||
|
||||
# Full read-only access for SNMPv3
|
||||
rouser authOnlyUser
|
||||
# Full write access for encrypted requests
|
||||
# Remember to activate the 'createUser' lines above
|
||||
#rwuser authPrivUser priv
|
||||
|
||||
# It's no longer typically necessary to use the full 'com2sec/group/access' configuration
|
||||
# r[ou]user and r[ow]community, together with suitable views, should cover most requirements
|
||||
|
||||
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# SYSTEM INFORMATION
|
||||
#
|
||||
|
||||
# Note that setting these values here, results in the corresponding MIB objects being 'read-only'
|
||||
# See snmpd.conf(5) for more details
|
||||
sysLocation Sitting on the Dock of the Bay
|
||||
sysContact Me <me@example.org>
|
||||
# Application + End-to-End layers
|
||||
sysServices 72
|
||||
|
||||
|
||||
#
|
||||
# Process Monitoring
|
||||
#
|
||||
# At least one 'mountd' process
|
||||
proc mountd
|
||||
# No more than 4 'ntalkd' processes - 0 is OK
|
||||
proc ntalkd 4
|
||||
# At least one 'sendmail' process, but no more than 10
|
||||
proc sendmail 10 1
|
||||
|
||||
# Walk the UCD-SNMP-MIB::prTable to see the resulting output
|
||||
# Note that this table will be empty if there are no "proc" entries in the snmpd.conf file
|
||||
|
||||
|
||||
#
|
||||
# Disk Monitoring
|
||||
#
|
||||
# 10MBs required on root disk, 5% free on /var, 10% free on all other disks
|
||||
disk / 10000
|
||||
disk /var 5%
|
||||
includeAllDisks 10%
|
||||
|
||||
# Walk the UCD-SNMP-MIB::dskTable to see the resulting output
|
||||
# Note that this table will be empty if there are no "disk" entries in the snmpd.conf file
|
||||
|
||||
|
||||
#
|
||||
# System Load
|
||||
#
|
||||
# Unacceptable 1-, 5-, and 15-minute load averages
|
||||
load 12 10 5
|
||||
|
||||
# Walk the UCD-SNMP-MIB::laTable to see the resulting output
|
||||
# Note that this table *will* be populated, even without a "load" entry in the snmpd.conf file
|
||||
|
||||
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# ACTIVE MONITORING
|
||||
#
|
||||
|
||||
# send SNMPv1 traps
|
||||
trapsink localhost public
|
||||
# send SNMPv2c traps
|
||||
#trap2sink localhost public
|
||||
# send SNMPv2c INFORMs
|
||||
#informsink localhost public
|
||||
|
||||
# Note that you typically only want *one* of these three lines
|
||||
# Uncommenting two (or all three) will result in multiple copies of each notification.
|
||||
|
||||
|
||||
#
|
||||
# Event MIB - automatically generate alerts
|
||||
#
|
||||
# Remember to activate the 'createUser' lines above
|
||||
iquerySecName internalUser
|
||||
rouser internalUser
|
||||
# generate traps on UCD error conditions
|
||||
defaultMonitors yes
|
||||
# generate traps on linkUp/Down
|
||||
linkUpDownNotifications yes
|
||||
|
||||
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# EXTENDING THE AGENT
|
||||
#
|
||||
|
||||
#
|
||||
# Arbitrary extension commands
|
||||
#
|
||||
extend test1 /bin/echo Hello, world!
|
||||
extend-sh test2 echo Hello, world! ; echo Hi there ; exit 35
|
||||
#extend-sh test3 /bin/sh /tmp/shtest
|
||||
|
||||
# Note that this last entry requires the script '/tmp/shtest' to be created first,
|
||||
# containing the same three shell commands, before the line is uncommented
|
||||
|
||||
# Walk the NET-SNMP-EXTEND-MIB tables (nsExtendConfigTable, nsExtendOutput1Table
|
||||
# and nsExtendOutput2Table) to see the resulting output
|
||||
|
||||
# Note that the "extend" directive supercedes the previous "exec" and "sh" directives
|
||||
# However, walking the UCD-SNMP-MIB::extTable should still returns the same output,
|
||||
# as well as the fuller results in the above tables.
|
||||
|
||||
|
||||
#
|
||||
# "Pass-through" MIB extension command
|
||||
#
|
||||
#pass .1.3.6.1.4.1.8072.2.255 /bin/sh PREFIX/local/passtest
|
||||
#pass .1.3.6.1.4.1.8072.2.255 /usr/bin/perl PREFIX/local/passtest.pl
|
||||
|
||||
# Note that this requires one of the two 'passtest' scripts to be installed first,
|
||||
# before the appropriate line is uncommented.
|
||||
# These scripts can be found in the 'local' directory of the source distribution,
|
||||
# and are not installed automatically.
|
||||
|
||||
# Walk the NET-SNMP-PASS-MIB::netSnmpPassExamples subtree to see the resulting output
|
||||
|
||||
|
||||
#
|
||||
# AgentX Sub-agents
|
||||
#
|
||||
# Run as an AgentX master agent
|
||||
master agentx
|
||||
# Listen for network connections (from localhost)
|
||||
# rather than the default named socket /var/agentx/master
|
||||
#agentXSocket tcp:localhost:705
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,278 +0,0 @@
|
||||
TABLE OF CONTENTS
|
||||
=================
|
||||
|
||||
Table Of Contents
|
||||
Quick Instructions
|
||||
* Net-SNMP Specific Information
|
||||
Long (but you should read these) Instructions
|
||||
Installing the Perl/SNMP Module
|
||||
* Compilers and Options
|
||||
Compiling For Multiple Architectures
|
||||
Installation Names
|
||||
Optional Features
|
||||
Sharing Defaults
|
||||
Operation Controls
|
||||
|
||||
* = required reading
|
||||
|
||||
QUICK INSTRUCTIONS
|
||||
==================
|
||||
|
||||
1) Run ./configure
|
||||
(type "./configure --help" for a quick usage summary.)
|
||||
(--prefix=PATH will change the default /usr/local installation path.)
|
||||
(see "Compilers and Options" on changing the compiler to use)
|
||||
|
||||
2) Optionally edit include/net-snmp/net-snmp-config.h
|
||||
(due to prompting done by the configure script, this is very rarely
|
||||
necessary.)
|
||||
|
||||
3) make
|
||||
|
||||
4) Run the next command as root:
|
||||
5) make install
|
||||
|
||||
6) configure the agent
|
||||
(either using 'snmpconf' or by crafting an snmpd.conf file manually.
|
||||
The file 'EXAMPLE.conf' may be a suitable starting point)
|
||||
|
||||
Note: By default, everything will be installed in /usr/local.
|
||||
(see below for more instructions)
|
||||
|
||||
Net-SNMP Specific Information
|
||||
=============================
|
||||
|
||||
As of UCD-SNMP V3.3.1 the configuration files are now looked for in
|
||||
$(prefix)/share/snmp, where ($prefix) is defined as the value passed
|
||||
to the --prefix argument of the configure script, or /usr/local if
|
||||
undefined. In version 3.0.3 till 3.3, the files were kept in
|
||||
$(prefix)/lib/snmp
|
||||
|
||||
Optional features to pass to configure for Net-SNMP can be obtained by
|
||||
running configure --help.
|
||||
|
||||
LONG (but you should read these) INSTRUCTIONS
|
||||
=============================================
|
||||
|
||||
The `configure' shell script attempts to guess correct values for
|
||||
various system-dependent variables used during compilation. It uses
|
||||
those values to create a `Makefile' in each directory of the package.
|
||||
It may also create one or more `.h' files containing system-dependent
|
||||
definitions. Finally, it creates a shell script `config.status' that
|
||||
you can run in the future to recreate the current configuration, a file
|
||||
`config.cache' that saves the results of its tests to speed up
|
||||
reconfiguring, a file `config.log' containing compiler output
|
||||
(useful mainly for debugging `configure') and a file `configure-summary'
|
||||
containing the summary displayed at the end of the `configure' run.
|
||||
|
||||
The file `include/net-snmp/net-snmp-config.h' is also generated
|
||||
at this time. It contains IMPORTANT information such as the location
|
||||
of log and configuration files. In some special cases you may need to
|
||||
modify this file but it is prefererable to work out a way of getting
|
||||
`configure' to set things up for your particular environment.
|
||||
|
||||
As the `configure' invocation often gets lengthy and difficult to
|
||||
type or if you have several different ways you want to configure a
|
||||
system, you may want to create a shell script containing your invocation.
|
||||
|
||||
If you need to do unusual things to compile the package, please try
|
||||
to figure out how `configure' could check whether to do them, and mail
|
||||
diffs or instructions to the address given in the `README' so they can
|
||||
be considered for the next release. If at some point `config.cache'
|
||||
contains results you don't want to keep, you may remove or edit it.
|
||||
|
||||
The file `configure.in' is used to create `configure' by a program
|
||||
called `autoconf'. You only need `configure.in' if you want to change
|
||||
it or regenerate `configure' using a newer version of `autoconf'.
|
||||
|
||||
The simplest way to compile this package is:
|
||||
|
||||
1. `cd' to the directory containing the package's source code and type
|
||||
`./configure' to configure the package for your system. If you're
|
||||
using `csh' on an old version of System V, you might need to type
|
||||
`sh ./configure' instead to prevent `csh' from trying to execute
|
||||
`configure' itself.
|
||||
|
||||
Running `configure' takes awhile. While running, it prints some
|
||||
messages telling which features it is checking for. When it
|
||||
completes it prints a short message (also available in configure-summary)
|
||||
indicating what functionality will be available when compiled.
|
||||
|
||||
2. If necessary, edit include/net-snmp/net-snmp-config.h (see above).
|
||||
|
||||
3. Type `make' to compile the package.
|
||||
|
||||
4. Type `make test' which runs a variety of tests to see what functionality
|
||||
has been incorporated and if it works.
|
||||
|
||||
5. Type `make install' to install the programs and any data files and
|
||||
documentation.
|
||||
|
||||
6. You can remove the program binaries and object files from the
|
||||
source code directory by typing `make clean'. To also remove the
|
||||
files that `configure' created (so you can compile the package for
|
||||
a different kind of computer), type `make distclean'.
|
||||
|
||||
7. You can remove the application by typing `make uninstall'.
|
||||
|
||||
There may be additional installation issues discussed in the
|
||||
README's for various platforms such as README.solaris.
|
||||
|
||||
|
||||
Installing the Perl/SNMP Module
|
||||
===============================
|
||||
|
||||
The Perl/SNMP Module is now bundled with the net-snmp package
|
||||
(which includes other Net-SNMP specific modules as well), all of which
|
||||
are located in the net-snmp/perl directory. The Perl package provides
|
||||
a high level abstract interface to the functionality found in the
|
||||
Net-SNMP libraries and demon applications.
|
||||
|
||||
It is recommended you install the perl modules as you build the
|
||||
Net-SNMP package. The configure script can be run as follows to
|
||||
automatically find perl and use it to install the perl modules:
|
||||
|
||||
./configure --with-perl-modules
|
||||
|
||||
If you wish to use the embedded perl support available in the
|
||||
Net-SNMP agent (and starting in Net-SNMP 5.2, the trap receiver),
|
||||
then use the following option instead:
|
||||
|
||||
./configure --enable-embedded-perl --enable-shared
|
||||
|
||||
Starting with Net-SNMP 5.4, configure enables embedded Perl and the
|
||||
Perl modules by default when possible unless explicitly disabled.
|
||||
|
||||
If you wish to build the perl modules by hand, *install Net-SNMP
|
||||
first* and then change directories to the perl subdirectory and:
|
||||
|
||||
Run:
|
||||
cd perl
|
||||
perl Makefile.PL
|
||||
make
|
||||
make test
|
||||
make install (as root)
|
||||
|
||||
|
||||
Compilers and Options
|
||||
=====================
|
||||
|
||||
Some systems require unusual options for compilation or linking that
|
||||
the `configure' script does not know about. You can give `configure'
|
||||
initial values for variables by setting them in the environment. Using
|
||||
a Bourne-compatible shell, you can do that on the command line like
|
||||
this:
|
||||
CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
|
||||
|
||||
Or on systems that have the `env' program, you can do it like this:
|
||||
env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
|
||||
|
||||
Compiling For Multiple Architectures
|
||||
====================================
|
||||
|
||||
You can compile the package for more than one kind of computer at the
|
||||
same time, by placing the object files for each architecture in their
|
||||
own directory. To do this, you must use a version of `make' that
|
||||
supports the `VPATH' variable, such as GNU `make'. `cd' to the
|
||||
directory where you want the object files and executables to go and run
|
||||
the `configure' script. `configure' automatically checks for the
|
||||
source code in the directory that `configure' is in and in `..'.
|
||||
|
||||
If you have to use a `make' that does not supports the `VPATH'
|
||||
variable, there is a `maketarget' script that will generate a symlink'ed
|
||||
shadow-directory for the object files. Do a `sh maketarget', then `cd' into
|
||||
targets/`config.guess` and do the configuration and installation.
|
||||
|
||||
Installation Names
|
||||
==================
|
||||
|
||||
By default, `make install' will install the package's files in
|
||||
`/usr/local/bin', `/usr/local/man', etc. You can specify an
|
||||
installation prefix other than `/usr/local' by giving `configure' the
|
||||
option `--prefix=PATH'.
|
||||
|
||||
You can specify separate installation prefixes for
|
||||
architecture-specific files and architecture-independent files. If you
|
||||
give `configure' the option `--exec-prefix=PATH', the package will use
|
||||
PATH as the prefix for installing programs and libraries.
|
||||
Documentation and other data files will still use the regular prefix.
|
||||
|
||||
If the package supports it, you can cause programs to be installed
|
||||
with an extra prefix or suffix on their names by giving `configure' the
|
||||
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
|
||||
|
||||
Optional Features
|
||||
=================
|
||||
|
||||
Some packages pay attention to `--enable-FEATURE' options to
|
||||
`configure', where FEATURE indicates an optional part of the package.
|
||||
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
|
||||
is something like `gnu-as' or `x' (for the X Window System). The
|
||||
`README' should mention any `--enable-' and `--with-' options that the
|
||||
package recognizes.
|
||||
|
||||
For packages that use the X Window System, `configure' can usually
|
||||
find the X include and library files automatically, but if it doesn't,
|
||||
you can use the `configure' options `--x-includes=DIR' and
|
||||
`--x-libraries=DIR' to specify their locations.
|
||||
|
||||
Specifying the System Type
|
||||
==========================
|
||||
|
||||
There may be some features `configure' can not figure out
|
||||
automatically, but needs to determine by the type of host the package
|
||||
will run on. Usually `configure' can figure that out, but if it prints
|
||||
a message saying it can not guess the host type, give it the
|
||||
`--host=TYPE' option. TYPE can either be a short name for the system
|
||||
type, such as `sun4', or a canonical name with three fields:
|
||||
CPU-COMPANY-SYSTEM
|
||||
|
||||
See the file `config.sub' for the possible values of each field. If
|
||||
`config.sub' isn't included in this package, then this package doesn't
|
||||
need to know the host type.
|
||||
|
||||
If you are building compiler tools for cross-compiling, you can also
|
||||
use the `--target=TYPE' option to select the type of system they will
|
||||
produce code for and the `--build=TYPE' option to select the type of
|
||||
system on which you are compiling the package.
|
||||
|
||||
Sharing Defaults
|
||||
================
|
||||
|
||||
If you want to set default values for `configure' scripts to share,
|
||||
you can create a site shell script called `config.site' that gives
|
||||
default values for variables like `CC', `cache_file', and `prefix'.
|
||||
`configure' looks for `PREFIX/share/config.site' if it exists, then
|
||||
`PREFIX/etc/config.site' if it exists. Or, you can set the
|
||||
`CONFIG_SITE' environment variable to the location of the site script.
|
||||
A warning: not all `configure' scripts look for a site script.
|
||||
|
||||
Operation Controls
|
||||
==================
|
||||
|
||||
`configure' recognizes the following options to control how it
|
||||
operates.
|
||||
|
||||
`--cache-file=FILE'
|
||||
Use and save the results of the tests in FILE instead of
|
||||
`./config.cache'. Set FILE to `/dev/null' to disable caching, for
|
||||
debugging `configure'.
|
||||
|
||||
`--help'
|
||||
Print a summary of the options to `configure', and exit.
|
||||
|
||||
`--quiet'
|
||||
`--silent'
|
||||
`-q'
|
||||
Do not print messages saying which checks are being made.
|
||||
|
||||
`--srcdir=DIR'
|
||||
Look for the package's source code in directory DIR. Usually
|
||||
`configure' can determine that directory automatically.
|
||||
|
||||
`--version'
|
||||
Print the version of Autoconf used to generate the `configure'
|
||||
script, and exit.
|
||||
|
||||
`configure' also accepts some other, not widely useful, options.
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
@@ -1,461 +0,0 @@
|
||||
|
||||
#
|
||||
# Makefile.in (at the root of net-snmp)
|
||||
#
|
||||
|
||||
top_builddir = .
|
||||
VPATH = @srcdir@
|
||||
|
||||
SUBDIRS = snmplib @MAINSUBS@
|
||||
FTSUBDIRS = @FTMAINSUBS@ snmplib
|
||||
TESTDIRS = testing
|
||||
|
||||
CPP = @CPP@ \
|
||||
-Iinclude -I$(srcdir)/include -I$(srcdir)/agent/mibgroup -I. -I$(srcdir) \
|
||||
-DDONT_INC_STRUCTS -DBINDIR=$(bindir) \
|
||||
$(EXTRACPPFLAGS)
|
||||
|
||||
INSTALLHEADERS=version.h net-snmp-features.h
|
||||
INCLUDESUBDIR=system
|
||||
INCLUDESUBDIRHEADERS= aix.h bsd.h bsdi3.h bsdi4.h bsdi.h cygwin.h \
|
||||
darwin.h darwin7.h darwin8.h darwin9.h darwin10.h dragonfly.h dynix.h \
|
||||
freebsd2.h freebsd3.h freebsd4.h freebsd5.h freebsd6.h \
|
||||
freebsd7.h freebsd8.h freebsd9.h freebsd10.h freebsd11.h \
|
||||
freebsd12.h freebsd.h \
|
||||
generic.h \
|
||||
hpux.h irix.h linux.h mingw32.h mips.h netbsd.h osf5.h \
|
||||
openbsd.h openbsd5.h openbsd4.h \
|
||||
solaris2.3.h solaris2.4.h solaris2.5.h solaris2.6.h \
|
||||
solaris.h sunos.h svr5.h sysv.h ultrix4.h
|
||||
INCLUDESUBDIR2=machine
|
||||
INCLUDESUBDIRHEADERS2=generic.h
|
||||
INSTALLBUILTHEADERS=include/net-snmp/net-snmp-config.h
|
||||
INSTALLBUILTINCLUDEHEADERS=@FEATUREHEADERS@
|
||||
INSTALLBINSCRIPTS=net-snmp-config net-snmp-create-v3-user
|
||||
INSTALLUCDHEADERS=ucd-snmp-config.h version.h mib_module_config.h
|
||||
|
||||
#
|
||||
# other install rules.
|
||||
#
|
||||
OTHERINSTALL=copypersistentfiles @PERLINSTALLTARGS@ @PYTHONINSTALLTARGS@
|
||||
OTHERUNINSTALL=@PERLUNINSTALLTARGS@ @PYTHONUNINSTALLTARGS@
|
||||
COPY_PERSISTENT_FILES=@COPY_PERSISTENT_FILES@
|
||||
PERSISTENT_DIRECTORY=@PERSISTENT_DIRECTORY@
|
||||
UCDPERSISTENT_DIRECTORY=@UCDPERSISTENT_DIRECTORY@
|
||||
|
||||
#
|
||||
# perl specific
|
||||
#
|
||||
# yes, order matters here. default_store must occur before anything else
|
||||
PERLMODULES=default_store SNMP ASN OID agent TrapReceiver
|
||||
PERLMODULEFTS=perl/default_store/netsnmp-feature-definitions.ft \
|
||||
perl/SNMP/netsnmp-feature-definitions.ft \
|
||||
perl/ASN/netsnmp-feature-definitions.ft \
|
||||
perl/OID/netsnmp-feature-definitions.ft \
|
||||
perl/agent/netsnmp-feature-definitions.ft \
|
||||
perl/TrapReceiver/netsnmp-feature-definitions.ft
|
||||
PERLARGS=@PERLARGS@
|
||||
|
||||
#
|
||||
# python specific
|
||||
#
|
||||
PYTHONARGS=@PYTHONARGS@
|
||||
PYTHONMODULEFTS=python/netsnmp/netsnmp-feature-definitions.ft
|
||||
|
||||
#
|
||||
# libtool
|
||||
#
|
||||
LIBTOOL_DEPS = @LIBTOOL_DEPS@
|
||||
|
||||
#
|
||||
# feature checks for optional components
|
||||
#
|
||||
FTOTHERTARGS=@PERLFEATURES@ @PYTHONFEATURES@
|
||||
|
||||
#
|
||||
# targets
|
||||
#
|
||||
all: sedscript EXAMPLE.conf @FEATURETARGS@ standardall net-snmp-config-x net-snmp-create-v3-user @PERLTARGS@ @PYTHONTARGS@
|
||||
|
||||
start-flag:
|
||||
@touch build-in-progress-flag
|
||||
|
||||
end-flag:
|
||||
@rm -f build-in-progress-flag > /dev/null 2>&1
|
||||
|
||||
libtool: $(LIBTOOL_DEPS)
|
||||
$(SHELL) ./config.status --recheck
|
||||
|
||||
|
||||
snmplib: @FEATURETARGS@
|
||||
@(cd snmplib; $(MAKE) )
|
||||
|
||||
agent: @FEATURETARGS@
|
||||
@(cd snmplib; $(MAKE) )
|
||||
@(cd agent; $(MAKE) )
|
||||
|
||||
apps: @FEATURETARGS@
|
||||
@(cd snmplib; $(MAKE) )
|
||||
@(cd agent; $(MAKE) libs)
|
||||
@(cd apps; $(MAKE) )
|
||||
|
||||
snmpget snmpbulkget snmpwalk snmpbulkwalk snmptranslate snmpstatus snmpdelta snmptable snmptest snmpset snmpusm snmpvacm snmpgetnext encode_keychange snmpdf snmptrap snmptls: @FEATURETARGS@
|
||||
@(cd snmplib; $(MAKE) )
|
||||
@(cd apps; $(MAKE) $@ )
|
||||
|
||||
agentxtrap snmptrapd: @FEATURETARGS@
|
||||
@(cd snmplib; $(MAKE) )
|
||||
@(cd agent; $(MAKE) libs)
|
||||
@(cd apps; $(MAKE) $@ )
|
||||
|
||||
#
|
||||
# local build rules
|
||||
#
|
||||
sedscript: sedscript.in include/net-snmp/net-snmp-config.h $(srcdir)/agent/mibgroup/mibdefs.h
|
||||
$(CPP) $(srcdir)/sedscript.in | egrep '^s[/#]' | sed 's/REMOVEME//g;s# */#/#g;s/ *#/#/g;s#/ *#/#g;s/# g/#g/;' > sedscript
|
||||
echo 's/VERSIONINFO/$(VERSION)/g' >> sedscript
|
||||
echo 's#DATADIR#$(datadir)#g' >> sedscript
|
||||
echo 's#LIBDIR#$(libdir)#g' >> sedscript
|
||||
echo 's#BINDIR#$(bindir)#g' >> sedscript
|
||||
echo 's#PERSISTENT_DIRECTORY#$(PERSISTENT_DIRECTORY)#g' >> sedscript
|
||||
echo 's#SYSCONFDIR#@sysconfdir@#g' >> sedscript
|
||||
|
||||
EXAMPLE.conf: sedscript EXAMPLE.conf.def
|
||||
$(SED) -f sedscript $(srcdir)/EXAMPLE.conf.def > EXAMPLE.conf
|
||||
|
||||
docs: docsdir
|
||||
|
||||
docsdir: docsdox
|
||||
|
||||
docsdox: doxygen.conf
|
||||
srcdir=$(srcdir) VERSION=$(VERSION) doxygen $(srcdir)/doxygen.conf
|
||||
|
||||
net-snmp-config-x: net-snmp-config
|
||||
chmod a+x net-snmp-config
|
||||
touch net-snmp-config-x
|
||||
|
||||
net-snmp-create-v3-user-x: net-snmp-create-v3-user
|
||||
chmod a+x net-snmp-create-v3-user
|
||||
touch net-snmp-create-v3-user-x
|
||||
|
||||
#
|
||||
# extra install rules
|
||||
#
|
||||
|
||||
copypersistentfiles:
|
||||
@if test "$(COPY_PERSISTENT_FILES)" = "yes" -a -d $(UCDPERSISTENT_DIRECTORY) -a ! -d $(PERSISTENT_DIRECTORY) ; then \
|
||||
cp -pr $(UCDPERSISTENT_DIRECTORY) $(PERSISTENT_DIRECTORY) ; \
|
||||
echo "copying $(UCDPERSISTENT_DIRECTORY) to $(PERSISTENT_DIRECTORY)" ; \
|
||||
fi
|
||||
#
|
||||
# test targets
|
||||
#
|
||||
test test-mibs testall testfailed testsimple: all testdirs
|
||||
( cd testing; $(MAKE) $@ )
|
||||
|
||||
testdirs:
|
||||
for i in $(TESTDIRS) ; do \
|
||||
( cd $$i ; $(MAKE) ) ; \
|
||||
if test $$? != 0 ; then \
|
||||
exit 1 ; \
|
||||
fi \
|
||||
done
|
||||
|
||||
distall: ${srcdir}/configure ${srcdir}/include/net-snmp/net-snmp-config.h
|
||||
|
||||
OTHERCLEANTARGETS=EXAMPLE.conf sedscript
|
||||
OTHERCLEANTODOS=perlclean @PYTHONCLEANTARGS@ cleanfeatures perlcleanfeatures pythoncleanfeatures
|
||||
|
||||
#
|
||||
# perl specific build rules
|
||||
#
|
||||
# override LD_RUN_PATH to avoid dependencies on the build directory
|
||||
perlmodules: perlmakefiles subdirs
|
||||
@(cd perl ; $(MAKE) LD_RUN_PATH="$(libdir):`$(PERL) -e 'use Config; print qq($$Config{archlibexp}/CORE);'`") ; \
|
||||
if test $$? != 0 ; then \
|
||||
exit 1 ; \
|
||||
fi
|
||||
|
||||
perlmakefiles: net-snmp-config-x
|
||||
@if test ! -f perl/Makefile; then \
|
||||
(dir=`pwd`; \
|
||||
cd perl ; \
|
||||
$(PERL) Makefile.PL -NET-SNMP-IN-SOURCE=true -NET-SNMP-CONFIG="sh $$dir/net-snmp-config" $(PERLARGS) ) ; \
|
||||
fi
|
||||
|
||||
perlinstall:
|
||||
@(cd perl ; $(MAKE) install) ; \
|
||||
if test $$? != 0 ; then \
|
||||
exit 1 ; \
|
||||
fi
|
||||
|
||||
perluninstall:
|
||||
@(cd perl ; $(MAKE) uninstall) ; \
|
||||
if test $$? != 0 ; then \
|
||||
exit 1 ; \
|
||||
fi
|
||||
|
||||
perltest:
|
||||
@(cd perl ; $(MAKE) test) ; \
|
||||
if test $$? != 0 ; then \
|
||||
exit 1 ; \
|
||||
fi
|
||||
|
||||
perlclean:
|
||||
@if test -f perl/Makefile; then \
|
||||
( cd perl ; $(MAKE) clean ) ; \
|
||||
fi
|
||||
|
||||
perlrealclean:
|
||||
@if test -f perl/Makefile; then \
|
||||
( cd perl ; $(MAKE) realclean ) ; \
|
||||
fi
|
||||
|
||||
.h.ft:
|
||||
$(FEATURECHECK) --feature-global $(top_builddir)/include/net-snmp/feature-details.h `dirname $<` $< $@ $(CC) -I $(top_builddir)/include -I $(top_srcdir)/include -E $(CPPFLAGS) $(CFLAGS) -c
|
||||
|
||||
perlfeatures: $(PERLMODULEFTS)
|
||||
|
||||
perlcleanfeatures:
|
||||
$(RM) $(PERLMODULEFTS)
|
||||
|
||||
|
||||
# python specific build rules
|
||||
#
|
||||
PYMAKE=$(PYTHON) setup.py $(PYTHONARGS)
|
||||
pythonmodules: subdirs
|
||||
@(dir=`pwd`; cd python; $(PYMAKE) build --basedir=$$dir) ; \
|
||||
if test $$? != 0 ; then \
|
||||
exit 1 ; \
|
||||
fi
|
||||
|
||||
pythoninstall:
|
||||
@(dir=`pwd`; cd python; $(PYMAKE) install --basedir=$$dir) ; \
|
||||
if test $$? != 0 ; then \
|
||||
exit 1 ; \
|
||||
fi
|
||||
|
||||
pythonuninstall:
|
||||
echo "WARNING: python doesn't support uninstall"
|
||||
|
||||
pythontest:
|
||||
@(dir=`pwd`; cd python; $(PYMAKE) test --basedir=$$dir) ; \
|
||||
if test $$? != 0 ; then \
|
||||
exit 1 ; \
|
||||
fi
|
||||
|
||||
pythonclean:
|
||||
@(dir=`pwd`; cd python; $(PYMAKE) clean --basedir=$$dir)
|
||||
|
||||
pythonfeatures: $(PYTHONMODULEFTS)
|
||||
|
||||
pythoncleanfeatures:
|
||||
$(RM) $(PYTHONMODULEFTS)
|
||||
|
||||
#
|
||||
# make distclean completely removes all traces of building including
|
||||
# any files generated by configure itself.
|
||||
#
|
||||
distclean: perlrealclean clean configclean tarclean
|
||||
|
||||
makefileclean:
|
||||
rm -f Makefile snmplib/Makefile \
|
||||
agent/Makefile agent/mibgroup/Makefile \
|
||||
agent/helpers/Makefile \
|
||||
apps/Makefile apps/snmpnetstat/Makefile \
|
||||
man/Makefile mibs/Makefile ov/Makefile \
|
||||
local/Makefile testing/Makefile
|
||||
|
||||
configclean: makefileclean
|
||||
rm -f config.cache config.status config.log \
|
||||
libtool include/net-snmp/net-snmp-config.h \
|
||||
net-snmp-config net-snmp-config-x configure-summary \
|
||||
net-snmp-create-v3-user net-snmp-create-v3-user-x
|
||||
rm -f mibs/.index
|
||||
rm -f include/net-snmp/agent/mib_module_config.h \
|
||||
include/net-snmp/agent/agent_module_config.h \
|
||||
include/net-snmp/library/snmpv3-security-includes.h \
|
||||
include/net-snmp/feature-details.h \
|
||||
snmplib/snmpsm_init.h snmplib/snmpsm_shutdown.h \
|
||||
snmplib/transports/snmp_transport_inits.h \
|
||||
agent/mibgroup/agent_module_includes.h \
|
||||
agent/mibgroup/agent_module_inits.h \
|
||||
agent/mibgroup/agent_module_shutdown.h \
|
||||
agent/mibgroup/agent_module_dot_conf.h \
|
||||
agent/mibgroup/mib_module_includes.h \
|
||||
agent/mibgroup/mib_module_inits.h \
|
||||
agent/mibgroup/mib_module_shutdown.h \
|
||||
agent/mibgroup/mib_module_dot_conf.h \
|
||||
local/snmpconf
|
||||
rm -rf mk
|
||||
rm -f *.core
|
||||
|
||||
#
|
||||
# Configure script related targets
|
||||
#
|
||||
touchit:
|
||||
touch configure include/net-snmp/net-snmp-config.h.in
|
||||
touch config.status
|
||||
touch stamp-h stamp-h.in
|
||||
|
||||
Makefile: Makefile.in config.status Makefile.rules Makefile.top
|
||||
@if test "x$(NOAUTODEPS)" = "x"; then \
|
||||
echo "running config.status because the following file(s) changed:"; \
|
||||
echo " $?"; \
|
||||
./config.status; \
|
||||
else \
|
||||
echo "WARNING: not running config.status"; \
|
||||
fi
|
||||
|
||||
configure_ac = configure.ac \
|
||||
configure.d/config_modules_agent \
|
||||
configure.d/config_modules_lib \
|
||||
configure.d/config_os_functions \
|
||||
configure.d/config_os_headers \
|
||||
configure.d/config_os_libs1 \
|
||||
configure.d/config_os_libs2 \
|
||||
configure.d/config_os_misc1 \
|
||||
configure.d/config_os_misc2 \
|
||||
configure.d/config_os_misc3 \
|
||||
configure.d/config_os_misc4 \
|
||||
configure.d/config_os_progs \
|
||||
configure.d/config_os_struct_members \
|
||||
configure.d/config_project_ipv6_types \
|
||||
configure.d/config_project_manual \
|
||||
configure.d/config_project_paths \
|
||||
configure.d/config_project_perl_python \
|
||||
configure.d/config_project_types \
|
||||
configure.d/config_project_with_enable
|
||||
|
||||
$(srcdir)/include/net-snmp/net-snmp-config.h.in: stamp-h.in
|
||||
$(srcdir)/stamp-h.in: $(configure_ac) acconfig.h
|
||||
@if test "x$(NOAUTODEPS)" = "x" -a "x$(AUTOHEADER)" != "x:"; then \
|
||||
cd ${srcdir} && LC_COLLATE=C $(AUTOHEADER); \
|
||||
echo timestamp > ${srcdir}/stamp-h.in; \
|
||||
else \
|
||||
echo "WARNING: not running autoheader"; \
|
||||
fi
|
||||
|
||||
include/net-snmp/net-snmp-config.h: stamp-h
|
||||
stamp-h: include/net-snmp/net-snmp-config.h.in config.status
|
||||
@if test "x$(NOAUTODEPS)" = "x"; then \
|
||||
echo "running config.status because the following file(s) changed:"; \
|
||||
echo " $?"; \
|
||||
./config.status; \
|
||||
echo timestamp > stamp-h; \
|
||||
else \
|
||||
echo "WARNING: not running config.status"; \
|
||||
fi
|
||||
|
||||
$(srcdir)/configure: $(configure_ac) aclocal.m4
|
||||
@if test "x$(NOAUTODEPS)" = "x" -a "x$(AUTOCONF)" != "x:"; then \
|
||||
cd ${srcdir} && $(AUTOCONF); \
|
||||
echo "Please run configure now."; \
|
||||
sh -c exit 2; \
|
||||
else \
|
||||
echo "WARNING: not running autoconf"; \
|
||||
fi
|
||||
|
||||
gendir=dist/generation-scripts
|
||||
generation-scripts: generation-scripts-dirs $(gendir)/gen-transport-headers $(gendir)/gen-security-headers
|
||||
|
||||
$(gendir)/gen-variables: $(gendir)/gen-variables.in
|
||||
./config.status
|
||||
|
||||
generation-scripts-dirs:
|
||||
@if [ ! -d dist ] ; then \
|
||||
mkdir dist ; \
|
||||
fi
|
||||
@if [ ! -d dist/generation-scripts ] ; then \
|
||||
mkdir dist/generation-scripts ; \
|
||||
fi
|
||||
|
||||
$(gendir)/gen-transport-headers: $(gendir)/gen-transport-headers.in $(gendir)/gen-variables
|
||||
rm -f $@
|
||||
autoconf -o $@ $<
|
||||
chmod a+x $@
|
||||
|
||||
$(gendir)/gen-security-headers: $(gendir)/gen-security-headers.in $(gendir)/gen-variables
|
||||
rm -f $@
|
||||
autoconf -o $@ $<
|
||||
chmod a+x $@
|
||||
|
||||
config.status: configure
|
||||
@if test "x$(NOAUTODEPS)" = "x"; then \
|
||||
echo "running config.status because $? changed"; \
|
||||
./config.status --recheck; \
|
||||
else \
|
||||
echo "WARNING: not running config.status --recheck"; \
|
||||
fi
|
||||
|
||||
#
|
||||
# Emacs TAGS file
|
||||
#
|
||||
TAGS:
|
||||
$(FIND) $(srcdir) -path $(srcdir)/dist/rpm -prune -o -name '*.[ch]' -print | etags -
|
||||
|
||||
#
|
||||
# Internal distribution packaging, etc.
|
||||
#
|
||||
#tag:
|
||||
# @if test "x$(VERSION)" = "x"; then \
|
||||
# echo "you need to supply a VERSION string."; \
|
||||
# exit 2; \
|
||||
# fi
|
||||
# ${srcdir}/agent/mibgroup/versiontag $(VERSION) tag
|
||||
|
||||
tar:
|
||||
@if test "x$(VERSION)" = "x"; then \
|
||||
echo "you need to supply a VERSION string."; \
|
||||
exit 2; \
|
||||
fi
|
||||
${srcdir}/agent/mibgroup/versiontag $(VERSION) tar
|
||||
|
||||
tarclean:
|
||||
@if test -x ${srcdir}/agent/mibgroup/versiontag ; then \
|
||||
${srcdir}/agent/mibgroup/versiontag Ext clean ; \
|
||||
fi
|
||||
|
||||
checks:
|
||||
$(MAKE) -k makefilecheck commentcheck warningcheck dependcheck \
|
||||
assertcheck perlcalloccheck
|
||||
|
||||
dependcheck:
|
||||
@echo "Checking for full paths in dependency files..."
|
||||
@if grep -n -E "^/" `$(FIND) $(top_srcdir) -name Makefile.depend`; then false; fi
|
||||
|
||||
warningcheck:
|
||||
@echo "Checking for cpp warnings..."
|
||||
@if grep -n "#warning" `$(FIND) $(top_srcdir) -name \*.\[ch\]`; then false; fi
|
||||
|
||||
assertcheck:
|
||||
@echo "Checking for non-snmp asserts..."
|
||||
@if grep -n -w "assert" `$(FIND) $(top_srcdir) -name \*.\[ch\] | grep -v snmp_assert.h | egrep -v 'perl/.*c' | grep -v openssl`; then false; fi
|
||||
|
||||
commentcheck:
|
||||
@echo "Checking for C++ style comments..."
|
||||
@if grep -n -E "([^:)n]|^)//" `$(FIND) $(top_srcdir) -path './win32' -prune -o -name \*.\[ch\] | grep -v agent/mibgroup/winExtDLL.c`; then false; fi
|
||||
|
||||
makefilecheck:
|
||||
@echo "Checking for non-portable Makefile constructs..."
|
||||
@if grep -n "\.c=" `$(FIND) $(top_srcdir) -name .svn -prune -o -path ./Makefile.in -prune -o -name "Makefile.*" -print`; then false; fi
|
||||
|
||||
# Invoking calloc() directly or indirectly from a Perl XSUB and freeing that
|
||||
# memory by calling free() from the XSUB is a sure way to trigger "Free to
|
||||
# wrong pool" errors on Windows.
|
||||
perlcalloccheck:
|
||||
@echo "Checking for calloc() in Perl's external subroutines ..."
|
||||
@if grep -nwE 'calloc|SNMP_MALLOC_STRUCT|SNMP_MALLOC_TYPEDEF' `$(FIND) $(top_srcdir) -name '*.xs'`; then false; fi
|
||||
|
||||
dist: tar
|
||||
|
||||
FAQ.html:
|
||||
local/FAQ2HTML FAQ
|
||||
|
||||
.PHONY: docs docsdir mancp testdirs test TAGS
|
||||
# note: tags and docs are phony to force rebulding
|
||||
.PHONY: snmplib agent apps \
|
||||
snmpget snmpbulkget snmpwalk snmpbulkwalk snmptranslate snmpstatus \
|
||||
snmpdelta snmptable snmptest snmpset snmpusm snmpvacm snmpgetnext \
|
||||
encode_keychange snmpdf snmptrap snmptrapd
|
||||
.PHONY: perlfeatures pythonfeatures
|
||||
@@ -1,475 +0,0 @@
|
||||
|
||||
#
|
||||
# standard target definitions. Set appropriate variables to make use of them.
|
||||
#
|
||||
# note: the strange use of the "it" variable is for shell parsing when
|
||||
# there is no targets to install for that rule.
|
||||
#
|
||||
|
||||
# the standard items to build: libraries, bins, and sbins
|
||||
STANDARDTARGETS =$(INSTALLLIBS) $(INSTALLBINPROGS) $(INSTALLSBINPROGS)
|
||||
STANDARDCLEANTARGETS=$(INSTALLLIBS) $(INSTALLPOSTLIBS) $(INSTALLBINPROGS) $(INSTALLSBINPROGS) $(INSTALLUCDLIBS)
|
||||
|
||||
standardall: subdirs $(STANDARDTARGETS)
|
||||
|
||||
objs: ${OBJS} ${LOBJS}
|
||||
|
||||
# features require that subdirs be made *first* to get dependency
|
||||
# collection processed in the right order
|
||||
.PHONY: features ftobjs ftsubdirs
|
||||
features: $(FTOTHERTARGS) ftsubdirs ftobjs $(FEATUREFILE)
|
||||
ftobjs: $(FTOBJS)
|
||||
$(FEATUREFILE): $(FTOBJS) $(top_builddir)/include/net-snmp/feature-details.h
|
||||
cat $(FTOBJS) > $(FEATUREFILE).in
|
||||
$(FEATUREPROCESS) $(FEATUREFILE) $(top_builddir)/include/net-snmp/feature-details.h @FEATURE_REMOVE_FLAGS@ @FEATURE_ADD_FLAGS@
|
||||
ftsubdirs:
|
||||
@if test "$(FTSUBDIRS)" != ""; then \
|
||||
SUBDIRS="$(FTSUBDIRS)" ; \
|
||||
else \
|
||||
SUBDIRS="$(SUBDIRS)" ; \
|
||||
fi ; \
|
||||
if test "$$SUBDIRS" != ""; then \
|
||||
it="$$SUBDIRS" ; \
|
||||
for i in $$it ; do \
|
||||
echo "making features in `pwd`/$$i"; \
|
||||
( cd $$i ; $(MAKE) features ) ; \
|
||||
if test $$? != 0 ; then \
|
||||
exit 1 ; \
|
||||
fi \
|
||||
done \
|
||||
fi
|
||||
|
||||
.PHONY: cleanfeatures cleanfeaturessubdirs
|
||||
cleanfeatures: cleanfeaturessubdirs
|
||||
rm -f $(FTOBJS)
|
||||
rm -f $(FEATUREFILE)
|
||||
rm -f $(top_builddir)/include/net-snmp/feature-details.h
|
||||
|
||||
cleanfeaturessubdirs:
|
||||
@if test "$(FTSUBDIRS)" != ""; then \
|
||||
SUBDIRS="$(FTSUBDIRS)" ; \
|
||||
else \
|
||||
SUBDIRS="$(SUBDIRS)" ; \
|
||||
fi ; \
|
||||
if test "$$SUBDIRS" != ""; then \
|
||||
it="$$SUBDIRS" ; \
|
||||
for i in $$it ; do \
|
||||
echo "making cleanfeatures in `pwd`/$$i"; \
|
||||
( cd $$i ; $(MAKE) cleanfeatures ) ; \
|
||||
if test $$? != 0 ; then \
|
||||
exit 1 ; \
|
||||
fi \
|
||||
done \
|
||||
fi
|
||||
|
||||
# feature-check definitions
|
||||
.SUFFIXES: .ft
|
||||
.c.ft:
|
||||
@test -f $(top_builddir)/include/net-snmp/feature-details.h || \
|
||||
echo "/* Generated by make. Do not modify directly */" \
|
||||
> $(top_builddir)/include/net-snmp/feature-details.h
|
||||
$(FEATURECHECK) --feature-global $(top_builddir)/include/net-snmp/feature-details.h $(mysubdir) $< $@ $(CC) -E $(CPPFLAGS) $(CFLAGS) -c
|
||||
|
||||
subdirs:
|
||||
@if test "$(SUBDIRS)" != ""; then \
|
||||
it="$(SUBDIRS)" ; \
|
||||
for i in $$it ; do \
|
||||
echo "making all in `pwd`/$$i"; \
|
||||
( cd $$i ; $(MAKE) ) ; \
|
||||
if test $$? != 0 ; then \
|
||||
exit 1 ; \
|
||||
fi \
|
||||
done \
|
||||
fi
|
||||
|
||||
# installlibs handles local, ucd and subdir libs. need to do subdir libs
|
||||
# before bins, sinze those libs may be needed for successful linking
|
||||
install: installlocalheaders @installucdheaders@ \
|
||||
installlibs \
|
||||
installlocalbin installlocalsbin \
|
||||
installsubdirs $(OTHERINSTALL)
|
||||
|
||||
uninstall: uninstalllibs uninstallbin uninstallsbin uninstallheaders \
|
||||
uninstallsubdirs $(OTHERUNINSTALL)
|
||||
|
||||
installprogs: installbin installsbin
|
||||
|
||||
#
|
||||
# headers
|
||||
#
|
||||
# set INSTALLHEADERS to a list of things to install in each makefile.
|
||||
# set INSTALLBUILTINCLUDEHEADERS a list built and placed into include/net-snmp/
|
||||
# set INSTALLBUILTHEADERS to a list of things to install from builddir
|
||||
# set INSTALLSUBDIRHEADERS and INSTALLSUBDIR to subdirectory headers
|
||||
# set INSTALLSUBDIRHEADERS2 and INSTALLSUBDIR2 to more subdirectory headers
|
||||
# set INSTALLBUILTSUBDIRHEADERS and INSTALLBUILTSUBDIR to a list from builddir
|
||||
#
|
||||
installheaders: installlocalheaders @installucdheaders@ installsubdirheaders
|
||||
|
||||
installlocalheaders:
|
||||
@if test "$(INSTALLBUILTINCLUDEHEADERS)" != "" ; then \
|
||||
echo creating directory $(INSTALL_PREFIX)$(includedir) ; \
|
||||
it="$(INSTALLBUILTINCLUDEHEADERS)" ; \
|
||||
$(SHELL) $(top_srcdir)/mkinstalldirs $(INSTALL_PREFIX)$(includedir)/library ; \
|
||||
$(SHELL) $(top_srcdir)/mkinstalldirs $(INSTALL_PREFIX)$(includedir)/agent ; \
|
||||
for i in $$it ; do \
|
||||
$(INSTALL_DATA) include/net-snmp/$$i $(INSTALL_PREFIX)$(includedir)/$$i ; \
|
||||
echo "installing $$i in $(INSTALL_PREFIX)$(includedir)/$$i" ; \
|
||||
done \
|
||||
fi
|
||||
@if test "$(INSTALLHEADERS)" != "" ; then \
|
||||
echo creating directory $(INSTALL_PREFIX)$(includedir) ; \
|
||||
it="$(INSTALLHEADERS)" ; \
|
||||
$(SHELL) $(top_srcdir)/mkinstalldirs $(INSTALL_PREFIX)$(includedir) ; \
|
||||
for i in $$it ; do \
|
||||
$(INSTALL_DATA) $(top_srcdir)/include/net-snmp/$$i $(INSTALL_PREFIX)$(includedir) ; \
|
||||
echo "installing $$i in $(INSTALL_PREFIX)$(includedir)" ; \
|
||||
done \
|
||||
fi
|
||||
@if test "$(INSTALLBUILTHEADERS)" != "" ; then \
|
||||
echo creating directory $(INSTALL_PREFIX)$(includedir) ; \
|
||||
it="$(INSTALLBUILTHEADERS)" ; \
|
||||
$(SHELL) $(top_srcdir)/mkinstalldirs $(INSTALL_PREFIX)$(includedir) ; \
|
||||
for i in $$it ; do \
|
||||
$(INSTALL_DATA) $$i $(INSTALL_PREFIX)$(includedir) ; \
|
||||
echo "installing $$i in $(INSTALL_PREFIX)$(includedir)" ; \
|
||||
done \
|
||||
fi
|
||||
@if test "$(INCLUDESUBDIRHEADERS)" != "" ; then \
|
||||
echo creating directory $(INSTALL_PREFIX)$(includedir)/$(INCLUDESUBDIR) ; \
|
||||
it="$(INCLUDESUBDIRHEADERS)" ; \
|
||||
$(SHELL) $(top_srcdir)/mkinstalldirs $(INSTALL_PREFIX)$(includedir)/$(INCLUDESUBDIR) ; \
|
||||
for i in $$it ; do \
|
||||
$(INSTALL_DATA) $(top_srcdir)/include/net-snmp/$(INCLUDESUBDIR)/$$i $(INSTALL_PREFIX)$(includedir)/$(INCLUDESUBDIR) ; \
|
||||
echo "installing $$i in $(INSTALL_PREFIX)$(includedir)/$(INCLUDESUBDIR)" ; \
|
||||
done \
|
||||
fi
|
||||
@if test "$(INCLUDESUBDIRHEADERS2)" != "" ; then \
|
||||
echo creating directory $(INSTALL_PREFIX)$(includedir)/$(INCLUDESUBDIR2) ; \
|
||||
it="$(INCLUDESUBDIRHEADERS2)" ; \
|
||||
$(SHELL) $(top_srcdir)/mkinstalldirs $(INSTALL_PREFIX)$(includedir)/$(INCLUDESUBDIR2) ; \
|
||||
for i in $$it ; do \
|
||||
$(INSTALL_DATA) $(top_srcdir)/include/net-snmp/$(INCLUDESUBDIR2)/$$i $(INSTALL_PREFIX)$(includedir)/$(INCLUDESUBDIR2) ; \
|
||||
echo "installing $$i in $(INSTALL_PREFIX)$(includedir)/$(INCLUDESUBDIR2)" ; \
|
||||
done \
|
||||
fi
|
||||
@if test "$(INSTALLBUILTSUBDIRHEADERS)" != "" ; then \
|
||||
echo creating directory $(INSTALL_PREFIX)$(includedir)/$(INSTALLBUILTSUBDIR) ; \
|
||||
it="$(INSTALLBUILTSUBDIRHEADERS)" ; \
|
||||
$(SHELL) $(top_srcdir)/mkinstalldirs $(INSTALL_PREFIX)$(includedir)/$(INSTALLBUILTSUBDIR) ; \
|
||||
for i in $$it ; do \
|
||||
$(INSTALL_DATA) $$i $(INSTALL_PREFIX)$(includedir)/$(INSTALLBUILTSUBDIR) ; \
|
||||
echo "installing $$i in $(INSTALL_PREFIX)$(includedir)/$(INSTALLBUILTSUBDIR)" ; \
|
||||
done \
|
||||
fi
|
||||
|
||||
installucdheaders:
|
||||
@if test "$(INSTALLUCDHEADERS)" != "" ; then \
|
||||
echo creating directory $(INSTALL_PREFIX)$(ucdincludedir) ; \
|
||||
it="$(INSTALLUCDHEADERS)" ; \
|
||||
$(SHELL) $(top_srcdir)/mkinstalldirs $(INSTALL_PREFIX)$(ucdincludedir) ; \
|
||||
for i in $$it ; do \
|
||||
$(INSTALL_DATA) $(top_srcdir)/include/ucd-snmp/$$i $(INSTALL_PREFIX)$(ucdincludedir) ; \
|
||||
echo "installing $$i in $(INSTALL_PREFIX)$(ucdincludedir)" ; \
|
||||
done \
|
||||
fi
|
||||
|
||||
installsubdirheaders:
|
||||
@if test "$(SUBDIRS)" != ""; then \
|
||||
it="$(SUBDIRS)" ; \
|
||||
for i in $$it ; do \
|
||||
echo "making installheaders in `pwd`/$$i"; \
|
||||
( cd $$i ; $(MAKE) installheaders) ; \
|
||||
if test $$? != 0 ; then \
|
||||
exit 1 ; \
|
||||
fi \
|
||||
done \
|
||||
fi
|
||||
|
||||
uninstallheaders:
|
||||
@if test "$(INSTALLHEADERS)" != "" ; then \
|
||||
it="$(INSTALLHEADERS)" ; \
|
||||
for i in $$it ; do \
|
||||
rm -f $(INSTALL_PREFIX)$(includedir)/$$i ; \
|
||||
echo "removing $$i from $(INSTALL_PREFIX)$(includedir)" ; \
|
||||
done \
|
||||
fi
|
||||
@if test "$(INSTALLBUILTHEADERS)" != "" ; then \
|
||||
it="$(INSTALLBUILTHEADERS)" ; \
|
||||
for i in $$it ; do \
|
||||
rm -f $(INSTALL_PREFIX)$(includedir)/`basename $$i` ; \
|
||||
echo "removing $$i from $(INSTALL_PREFIX)$(includedir)" ; \
|
||||
done \
|
||||
fi
|
||||
@if test "$(INCLUDESUBDIRHEADERS)" != "" ; then \
|
||||
it="$(INCLUDESUBDIRHEADERS)" ; \
|
||||
for i in $$it ; do \
|
||||
rm -f $(INSTALL_PREFIX)$(includedir)/$(INCLUDESUBDIR)/$$i ; \
|
||||
echo "removing $$i from $(INSTALL_PREFIX)$(includedir)/$(INCLUDESUBDIR)" ; \
|
||||
done \
|
||||
fi
|
||||
@if test "$(INCLUDESUBDIRHEADERS2)" != "" ; then \
|
||||
it="$(INCLUDESUBDIRHEADERS2)" ; \
|
||||
for i in $$it ; do \
|
||||
rm -f $(INSTALL_PREFIX)$(includedir)/$(INCLUDESUBDIR2)/$$i ; \
|
||||
echo "removing $$i from $(INSTALL_PREFIX)$(includedir)/$(INCLUDESUBDIR2)" ; \
|
||||
done \
|
||||
fi
|
||||
@if test "$(INSTALLBUILTSUBDIRHEADERS)" != "" ; then \
|
||||
it="$(INSTALLBUILTSUBDIRHEADERS)" ; \
|
||||
for i in $$it ; do \
|
||||
rm -f $(INSTALL_PREFIX)$(includedir)/$(INSTALLBUILTSUBDIR)/`basename $$i` ; \
|
||||
echo "removing $$i from $(INSTALL_PREFIX)$(includedir)/$(INSTALLBUILTSUBDIR)" ; \
|
||||
done \
|
||||
fi
|
||||
|
||||
#
|
||||
# libraries
|
||||
#
|
||||
# set INSTALLLIBS to a list of things to install in each makefile.
|
||||
#
|
||||
installlibs: installlocallibs @installucdlibs@ installsubdirlibs installpostlibs
|
||||
|
||||
installlocallibs: $(INSTALLLIBS)
|
||||
@if test "$(INSTALLLIBS)" != ""; then \
|
||||
it="$(INSTALLLIBS)" ; \
|
||||
$(SHELL) $(top_srcdir)/mkinstalldirs $(INSTALL_PREFIX)$(libdir) ; \
|
||||
$(INSTALL) $(INSTALLLIBS) $(INSTALL_PREFIX)$(libdir) ; \
|
||||
for i in $$it ; do \
|
||||
echo "installing $$i in $(INSTALL_PREFIX)$(libdir)"; \
|
||||
$(RANLIB) $(INSTALL_PREFIX)$(libdir)/$$i ; \
|
||||
done ; \
|
||||
$(LIB_LDCONFIG_CMD) ; \
|
||||
fi
|
||||
|
||||
installpostlibs: $(INSTALLPOSTLIBS)
|
||||
@if test "$(INSTALLPOSTLIBS)" != ""; then \
|
||||
it="$(INSTALLPOSTLIBS)" ; \
|
||||
$(SHELL) $(top_srcdir)/mkinstalldirs $(INSTALL_PREFIX)$(libdir) ; \
|
||||
$(INSTALL) $(INSTALLPOSTLIBS) $(INSTALL_PREFIX)$(libdir) ; \
|
||||
for i in $$it ; do \
|
||||
echo "installing $$i in $(INSTALL_PREFIX)$(libdir)"; \
|
||||
$(RANLIB) $(INSTALL_PREFIX)$(libdir)/$$i ; \
|
||||
done ; \
|
||||
$(LIB_LDCONFIG_CMD) ; \
|
||||
fi
|
||||
|
||||
installucdlibs: $(INSTALLUCDLIBS)
|
||||
@if test "$(INSTALLUCDLIBS)" != ""; then \
|
||||
it="$(INSTALLUCDLIBS)" ; \
|
||||
$(SHELL) $(top_srcdir)/mkinstalldirs $(INSTALL_PREFIX)$(libdir) ; \
|
||||
$(INSTALL) $(INSTALLUCDLIBS) $(INSTALL_PREFIX)$(libdir) ; \
|
||||
for i in $$it ; do \
|
||||
echo "installing $$i in $(INSTALL_PREFIX)$(libdir)"; \
|
||||
$(RANLIB) $(INSTALL_PREFIX)$(libdir)/$$i ; \
|
||||
done ; \
|
||||
$(LIB_LDCONFIG_CMD) ; \
|
||||
fi
|
||||
|
||||
installsubdirlibs:
|
||||
@if test "$(SUBDIRS)" != ""; then \
|
||||
it="$(SUBDIRS)" ; \
|
||||
for i in $$it ; do \
|
||||
echo "making installlibs in `pwd`/$$i"; \
|
||||
( cd $$i ; $(MAKE) installlibs) ; \
|
||||
if test $$? != 0 ; then \
|
||||
exit 1 ; \
|
||||
fi \
|
||||
done \
|
||||
fi
|
||||
|
||||
uninstalllibs:
|
||||
@if test "$(INSTALLLIBS)" != ""; then \
|
||||
it="$(INSTALLLIBS)" ; \
|
||||
for i in $$it ; do \
|
||||
$(UNINSTALL) $(INSTALL_PREFIX)$(libdir)/$$i ; \
|
||||
echo "removing $$i from $(INSTALL_PREFIX)$(libdir)"; \
|
||||
done \
|
||||
fi
|
||||
|
||||
#
|
||||
# normal bin binaries
|
||||
#
|
||||
# set INSTALLBINPROGS to a list of things to install in each makefile.
|
||||
#
|
||||
installbin: installlocalbin installsubdirbin
|
||||
|
||||
installlocalbin: $(INSTALLBINPROGS)
|
||||
@if test "$(INSTALLBINPROGS) $(INSTALLBINSCRIPTS)" != " "; then \
|
||||
$(SHELL) $(top_srcdir)/mkinstalldirs $(INSTALL_PREFIX)$(bindir) ; \
|
||||
it="$(INSTALLBINPROGS) $(INSTALLBINSCRIPTS)" ; \
|
||||
$(INSTALL) $(INSTALLBINPROGS) $(INSTALLBINSCRIPTS) $(INSTALL_PREFIX)$(bindir) ; \
|
||||
for i in $$it ; do \
|
||||
echo "installing $$i in $(INSTALL_PREFIX)$(bindir)"; \
|
||||
done \
|
||||
fi
|
||||
|
||||
installsubdirbin:
|
||||
@if test "$(SUBDIRS)" != ""; then \
|
||||
it="$(SUBDIRS)" ; \
|
||||
for i in $$it ; do \
|
||||
echo "making installbin in `pwd`/$$i"; \
|
||||
( cd $$i ; $(MAKE) installbin) ; \
|
||||
if test $$? != 0 ; then \
|
||||
exit 1 ; \
|
||||
fi \
|
||||
done \
|
||||
fi
|
||||
|
||||
uninstallbin:
|
||||
@if test "$(INSTALLBINPROGS) $(INSTALLBINSCRIPTS)" != " "; then \
|
||||
it="$(INSTALLBINPROGS) $(INSTALLBINSCRIPTS)" ; \
|
||||
for i in $$it ; do \
|
||||
$(UNINSTALL) $(INSTALL_PREFIX)$(bindir)/$$i ; \
|
||||
echo "removing $$i from $(INSTALL_PREFIX)$(bindir)"; \
|
||||
done \
|
||||
fi
|
||||
|
||||
#
|
||||
# sbin binaries
|
||||
#
|
||||
# set INSTALLSBINPROGS to a list of things to install in each makefile.
|
||||
#
|
||||
installsbin: installlocalsbin installsubdirsbin
|
||||
|
||||
installlocalsbin: $(INSTALLSBINPROGS)
|
||||
@if test "$(INSTALLSBINPROGS)" != ""; then \
|
||||
it="$(INSTALLSBINPROGS)" ; \
|
||||
$(SHELL) $(top_srcdir)/mkinstalldirs $(INSTALL_PREFIX)$(sbindir) ; \
|
||||
$(INSTALL) $(INSTALLSBINPROGS) $(INSTALL_PREFIX)$(sbindir) ; \
|
||||
for i in $$it ; do \
|
||||
echo "installing $$i in $(INSTALL_PREFIX)$(sbindir)"; \
|
||||
done \
|
||||
fi
|
||||
|
||||
installsubdirsbin:
|
||||
@if test "$(SUBDIRS)" != ""; then \
|
||||
it="$(SUBDIRS)" ; \
|
||||
for i in $$it ; do \
|
||||
echo "making installsbin in `pwd`/$$i"; \
|
||||
( cd $$i ; $(MAKE) installsbin) ; \
|
||||
if test $$? != 0 ; then \
|
||||
exit 1 ; \
|
||||
fi \
|
||||
done \
|
||||
fi
|
||||
|
||||
uninstallsbin:
|
||||
@if test "$(INSTALLSBINPROGS)" != ""; then \
|
||||
it="$(INSTALLSBINPROGS)" ; \
|
||||
for i in $$it ; do \
|
||||
$(UNINSTALL) $(INSTALL_PREFIX)$(sbindir)/$$i ; \
|
||||
echo "removing $$i from $(INSTALL_PREFIX)$(sbindir)"; \
|
||||
done \
|
||||
fi
|
||||
|
||||
#
|
||||
# general make install target for subdirs
|
||||
#
|
||||
installsubdirs:
|
||||
@if test "$(SUBDIRS)" != ""; then \
|
||||
it="$(SUBDIRS)" ; \
|
||||
for i in $$it ; do \
|
||||
echo "making install in `pwd`/$$i"; \
|
||||
( cd $$i ; $(MAKE) install) ; \
|
||||
if test $$? != 0 ; then \
|
||||
exit 1 ; \
|
||||
fi \
|
||||
done \
|
||||
fi
|
||||
|
||||
uninstallsubdirs:
|
||||
@if test "$(SUBDIRS)" != ""; then \
|
||||
it="$(SUBDIRS)" ; \
|
||||
for i in $$it ; do \
|
||||
echo "making uninstall in `pwd`/$$i"; \
|
||||
( cd $$i ; $(MAKE) uninstall) ; \
|
||||
if test $$? != 0 ; then \
|
||||
exit 1 ; \
|
||||
fi \
|
||||
done \
|
||||
fi
|
||||
|
||||
#
|
||||
# cleaning targets
|
||||
#
|
||||
clean: cleansubdirs $(OTHERCLEANTODOS)
|
||||
$(LIBTOOLCLEAN) ${OBJS} ${LOBJS} ${FTOBJS} core $(STANDARDCLEANTARGETS) $(OTHERCLEANTARGETS)
|
||||
|
||||
cleansubdirs:
|
||||
@if test "$(SUBDIRS)" != ""; then \
|
||||
it="$(SUBDIRS)" ; \
|
||||
for i in $$it ; do \
|
||||
echo "making clean in `pwd`/$$i"; \
|
||||
( cd $$i ; $(MAKE) clean) ; \
|
||||
if test $$? != 0 ; then \
|
||||
exit 1 ; \
|
||||
fi \
|
||||
done \
|
||||
fi
|
||||
|
||||
lint:
|
||||
lint -nhx $(CSRCS)
|
||||
|
||||
#
|
||||
# wacky dependency building.
|
||||
#
|
||||
depend: dependdirs
|
||||
@if test -f Makefile.depend ; then \
|
||||
makedepend `echo $(CPPFLAGS) | sed 's/-f[-a-z]*//g'` -o .lo $(srcdir)/*.c $(srcdir)/*/*.c ; \
|
||||
fi
|
||||
|
||||
|
||||
nosysdepend: nosysdependdirs
|
||||
@if test -f Makefile.depend ; then \
|
||||
makedepend `echo $(CPPFLAGS) | sed 's/-f[-a-z]*//g'` -o .lo $(srcdir)/*.c $(srcdir)/*/*.c ; \
|
||||
$(PERL) -n -i.bak $(top_srcdir)/makenosysdepend.pl Makefile ; \
|
||||
fi
|
||||
|
||||
distdepend: nosysdepend distdependdirs
|
||||
@if test -f Makefile.depend ; then \
|
||||
$(PERL) $(top_srcdir)/makefileindepend.pl ; \
|
||||
fi
|
||||
|
||||
dependdirs:
|
||||
@if test "$(SUBDIRS)" != ""; then \
|
||||
it="$(SUBDIRS)" ; \
|
||||
for i in $$it ; do \
|
||||
echo "making depend in `pwd`/$$i"; \
|
||||
( cd $$i ; $(MAKE) depend) ; \
|
||||
if test $$? != 0 ; then \
|
||||
exit 1 ; \
|
||||
fi \
|
||||
done \
|
||||
fi
|
||||
|
||||
nosysdependdirs:
|
||||
@if test "$(SUBDIRS)" != ""; then \
|
||||
it="$(SUBDIRS)" ; \
|
||||
for i in $$it ; do \
|
||||
echo "making nosysdepend in `pwd`/$$i"; \
|
||||
( cd $$i ; $(MAKE) nosysdepend) ; \
|
||||
if test $$? != 0 ; then \
|
||||
exit 1 ; \
|
||||
fi \
|
||||
done \
|
||||
fi
|
||||
|
||||
distdependdirs:
|
||||
@if test "$(SUBDIRS)" != ""; then \
|
||||
it="$(SUBDIRS)" ; \
|
||||
for i in $$it ; do \
|
||||
echo "making distdepend in `pwd`/$$i"; \
|
||||
( cd $$i ; $(MAKE) distdepend) ; \
|
||||
if test $$? != 0 ; then \
|
||||
exit 1 ; \
|
||||
fi \
|
||||
done \
|
||||
fi
|
||||
|
||||
# These aren't real targets, let gnu's make know that.
|
||||
.PHONY: clean cleansubdirs lint \
|
||||
install installprogs installheaders installlibs \
|
||||
installbin installsbin installsubdirs \
|
||||
all subdirs standardall objs features \
|
||||
depend nosysdepend distdepend dependdirs nosysdependdirs distdependdirs
|
||||
@@ -1,121 +0,0 @@
|
||||
#
|
||||
# Minimum environment and virtual path setup
|
||||
#
|
||||
SHELL = @SHELL@
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
VERSION = @VERSION@
|
||||
@SET_MAKE@
|
||||
|
||||
#
|
||||
# Paths
|
||||
#
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
bindir = @bindir@
|
||||
sbindir = @sbindir@
|
||||
libdir = @libdir@
|
||||
datarootdir = @datarootdir@
|
||||
datadir = @datadir@
|
||||
includedir = @includedir@/net-snmp
|
||||
ucdincludedir = @includedir@/ucd-snmp
|
||||
mandir = @mandir@
|
||||
man1dir = $(mandir)/man1
|
||||
man3dir = $(mandir)/man3
|
||||
man5dir = $(mandir)/man5
|
||||
man8dir = $(mandir)/man8
|
||||
snmplibdir = $(datadir)/snmp
|
||||
mibdir = $(snmplibdir)/mibs
|
||||
persistentdir = @PERSISTENT_DIRECTORY@
|
||||
DESTDIR = @INSTALL_PREFIX@
|
||||
INSTALL_PREFIX = $(DESTDIR)
|
||||
|
||||
#
|
||||
# Programs
|
||||
#
|
||||
INSTALL = $(LIBTOOL) --mode=install @INSTALL@
|
||||
UNINSTALL = $(LIBTOOL) --mode=uninstall rm -f
|
||||
LIBTOOLCLEAN = $(LIBTOOL) --mode=clean rm -f
|
||||
FEATURECHECK = $(top_srcdir)/local/minimalist/feature-check
|
||||
FEATUREPROCESS = $(top_srcdir)/local/minimalist/feature-remove
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
SED = @SED@
|
||||
LN_S = @LN_S@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
PERL = @PERLPROG@
|
||||
PYTHON = @PYTHONPROG@
|
||||
FIND = @FIND@
|
||||
EGREP = @EGREP@
|
||||
|
||||
#
|
||||
# Compiler arguments
|
||||
#
|
||||
CFLAGS = @CFLAGS@ @DEVFLAGS@
|
||||
EXTRACPPFLAGS = @EXTRACPPFLAGS@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBTOOL = @LIBTOOL@ @LIBTOOLFLAGS@
|
||||
EXEEXT = @EXEEXT@
|
||||
|
||||
# Misc Compiling Stuff
|
||||
CC = @CC@
|
||||
LINKCC = @LINKCC@
|
||||
|
||||
# use libtool versioning the way they recommend.
|
||||
# The (slightly clarified) rules:
|
||||
#
|
||||
# - If any interfaces/structures have been removed or changed since the
|
||||
# last update, increment current (+5), and set age and revision to 0. Stop.
|
||||
#
|
||||
# - If any interfaces have been added since the last public release, then
|
||||
# increment current and age, and set revision to 0. Stop.
|
||||
#
|
||||
# - If the source code has changed at all since the last update,
|
||||
# then increment revision (c:r:a becomes c:r+1:a).
|
||||
#
|
||||
# Note: maintenance releases (eg 5.2.x) should never have changes
|
||||
# that would require a current to be incremented.
|
||||
#
|
||||
# policy: we increment major releases of LIBCURRENT by 5 starting at
|
||||
# 5.3 was at 10, 5.4 is at 15, ... This leaves some room for needed
|
||||
# changes for past releases if absolutely necessary.
|
||||
#
|
||||
LIBCURRENT = 30
|
||||
LIBAGE = 0
|
||||
LIBREVISION = 3
|
||||
|
||||
LIB_LD_CMD = $(LIBTOOL) --mode=link $(LINKCC) $(CFLAGS) -rpath $(libdir) -version-info $(LIBCURRENT):$(LIBREVISION):$(LIBAGE) -o
|
||||
LIB_EXTENSION = la
|
||||
LIB_VERSION =
|
||||
LIB_LDCONFIG_CMD = $(LIBTOOL) --mode=finish $(INSTALL_PREFIX)$(libdir)
|
||||
LINK = $(LIBTOOL) --mode=link $(LINKCC)
|
||||
# RANLIB = @RANLIB@
|
||||
RANLIB = :
|
||||
|
||||
# libtool definitions
|
||||
.SUFFIXES: .c .o .lo .rc
|
||||
.c.lo:
|
||||
$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
|
||||
.rc.lo:
|
||||
$(LIBTOOL) --mode=compile --tag=CC windres -o $@ -i $<
|
||||
|
||||
# include paths
|
||||
#
|
||||
SRC_TOP_INCLUDES = -I$(top_srcdir)/include
|
||||
SRC_SNMPLIB_INCLUDES = -I$(top_srcdir)/snmplib
|
||||
SRC_AGENT_INCLUDES = -I$(top_srcdir)/agent
|
||||
SRC_HELPER_INCLUDES = -I$(top_srcdir)/agent/helpers
|
||||
SRC_MIBGROUP_INCLUDES = -I$(top_srcdir)/agent/mibgroup
|
||||
|
||||
BLD_TOP_INCLUDES = -I$(top_builddir)/include $(SRC_TOP_INCLUDES)
|
||||
BLD_SNMPLIB_INCLUDES = -I$(top_builddir)/snmplib $(SRC_SNMPLIB_INCLUDES)
|
||||
BLD_AGENT_INCLUDES = -I$(top_builddir)/agent $(SRC_AGENT_INCLUDES)
|
||||
BLD_HELPER_INCLUDES = -I$(top_builddir)/agent/helpers $(SRC_HELPER_INCLUDES)
|
||||
BLD_MIBGROUP_INCLUDES = -I$(top_builddir)/agent/mibgroup $(SRC_MIBGROUP_INCLUDES)
|
||||
|
||||
TOP_INCLUDES = $(@TOP_INCLUDES@)
|
||||
SNMPLIB_INCLUDES = $(@SNMPLIB_INCLUDES@)
|
||||
AGENT_INCLUDES = $(@AGENT_INCLUDES@)
|
||||
HELPER_INCLUDES = $(@HELPER_INCLUDES@)
|
||||
MIBGROUP_INCLUDES = $(@MIBGROUP_INCLUDES@) @EXTERNAL_MIBGROUP_INCLUDES@
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,104 +0,0 @@
|
||||
--- INTRODUCTION
|
||||
|
||||
Just a quick note on porting and sending me patches:
|
||||
|
||||
First off, you probably should subscribe to
|
||||
net-snmp-coders@lists.sourceforge.net by sending a message to
|
||||
net-snmp-coders-request@lists.sourceforge.net with a subject line of
|
||||
subscribe. This is a mailing list to discuss all oft the coding
|
||||
aspects of the project.
|
||||
|
||||
Additionally, you should probably be developing against the latest
|
||||
snapshot of the source code, which can be obtained through the
|
||||
net-snmp cvs server. Details can be found at
|
||||
http://www.net-snmp.org/cvs/.
|
||||
|
||||
If you send patches to us, it would greatly help us if you sent them
|
||||
to us based on the current checked out copy from CVS. To do this,
|
||||
send us the output of "cvs diff -u" run in the top level net-snmp
|
||||
source tree after you have modified the files that will fix the
|
||||
problem or add the feature you're submitting the patch for.
|
||||
|
||||
Quite a while back I started using the GNU autoconf testing suite to
|
||||
greatly enhance portability. Because of this porting to new
|
||||
architectures is much easier than before. However, new people porting
|
||||
the package to new architectures rarely take advantage of this setup
|
||||
and send me patches with lots of '#ifdef ARCH' type C code in it. Let
|
||||
me say up front, I *hate* this type of coding now (even though I used
|
||||
to use it a lot). What is better is to check for the necessary
|
||||
functionality using the configure script and then use the results of
|
||||
those tests.
|
||||
|
||||
To do this, you need to install the GNU 'autoconf' package which also
|
||||
requires the GNU 'm4' (gm4) package as well. This double installation
|
||||
is extremely easy and shouldn't take you more than 15 minutes max.
|
||||
After that, modify the configure.in and acconfig.h files as needed
|
||||
instead of modifying the config.h or configure files directly. The
|
||||
Makefile will re-produce these files from the first two.
|
||||
|
||||
Worst case: Don't put in #ifdef architecture style statements.
|
||||
Rather, create a new define in the s/ and m/ system specific header
|
||||
files and use those defines to test against in the C code. This
|
||||
should only be done for things that can't be checked using configure
|
||||
though.
|
||||
|
||||
Some autoconf examples:
|
||||
|
||||
--- HEADER FILES
|
||||
|
||||
In configure.in:
|
||||
AC_CHECK_HEADERS(headdir/header.h)
|
||||
|
||||
Then in your source code:
|
||||
#ifdef HAVE_HEADDIR_HEADER_H
|
||||
#include <headdir/header.h>
|
||||
#ENDIF
|
||||
|
||||
--- LIBRARY ROUTIENS
|
||||
|
||||
In configure.in:
|
||||
AC_CHECK_LIB(libexample, example_function)
|
||||
|
||||
Thats it. The Makefiles will automatically link against -llibexample
|
||||
if example_function is found in the library.
|
||||
|
||||
--- FUNCTION CHECKS
|
||||
|
||||
In configure.in:
|
||||
AC_CHECK_FUNCS(example_function)
|
||||
|
||||
In source code:
|
||||
#ifdef HAVE_EXAMPLE_FUNCTION
|
||||
/* use it */
|
||||
#endif
|
||||
|
||||
--- STRUCTURE MEMBER CHECKS
|
||||
|
||||
In configure.in:
|
||||
AC_CHECK_MEMBERS([struct STRUCTURE.MEMBER],,,[[
|
||||
#include lines
|
||||
]])
|
||||
^^^^^^^^^ ^^^^^^ (change)
|
||||
|
||||
In source code:
|
||||
#ifdef HAVE_STRUCT_STRUCTURE_MEMBER
|
||||
/* use it */
|
||||
#endif
|
||||
|
||||
--- READ THE MANUAL
|
||||
|
||||
The GNU autoconf info files are extremely well written and easy to
|
||||
follow. Please check them out.
|
||||
|
||||
I'd be happy to help you through anything you don't understand or
|
||||
through more complex examples (eg, checking for structure parts or
|
||||
existance). I'd be far less happy to get patches ignoring the above
|
||||
request. If you simple can't abide by this, please send the patches
|
||||
anyway, but it'll just take me longer to get them applied.
|
||||
|
||||
Submit the patch to http://www.net-snmp.org/patches/.
|
||||
Please include what version of the net-snmp package it was applied to
|
||||
and state the arcitectures you have tested it on.
|
||||
|
||||
Thanks a lot for the consideration,
|
||||
Wes
|
||||
@@ -1,360 +0,0 @@
|
||||
README file for net-snmp Version: 5.7.3
|
||||
|
||||
DISCLAIMER
|
||||
|
||||
The Authors assume no responsibility for damage or loss of system
|
||||
performance as a direct or indirect result of the use of this
|
||||
software. This software is provided "as is" without express or
|
||||
implied warranty.
|
||||
|
||||
TABLE OF CONTENTS
|
||||
|
||||
Disclaimer
|
||||
Table Of Contents
|
||||
Introduction
|
||||
* Supported Architectures
|
||||
Availability
|
||||
Web Page
|
||||
* Installation
|
||||
Copying And Copyrights
|
||||
* Frequently Asked Questions
|
||||
Helping Out
|
||||
* Code Update Announcements
|
||||
* Mailing Lists
|
||||
Agent Extensibility
|
||||
Example Agent Configuration and Usage
|
||||
Configuration
|
||||
Submitting Bug Reports
|
||||
Closing
|
||||
Thanks
|
||||
|
||||
* = Required Reading.
|
||||
|
||||
INTRODUCTION
|
||||
|
||||
This package was originally based on the CMU 2.1.2.1 snmp code. It
|
||||
has been greatly modified, restructured, enhanced and fixed. It
|
||||
hardly looks the same as anything that CMU has ever released. It
|
||||
was renamed from cmu-snmp to ucd-snmp in 1995 and later renamed from
|
||||
ucd-snmp to net-snmp in November 2000.
|
||||
|
||||
This README file serves as a starting place to learn about the
|
||||
package, but very little of the documentation is contained within
|
||||
this file. The FAQ is an excellent place to start as well.
|
||||
Additionally, there are a bunch of README files for specific
|
||||
architectures and specific features. You might wish to look at some
|
||||
of these other files as well.
|
||||
|
||||
SUPPORTED ARCHITECTURES
|
||||
|
||||
Please see the FAQ for this information.
|
||||
|
||||
Please let us know if you compile it on other OS versions and it
|
||||
works for you so we can add them to the above list.
|
||||
|
||||
Porting: Please! read the PORTING file.
|
||||
|
||||
Also note that many architecture have architecture specific README
|
||||
files, so you should check to see if there is one appropriate to
|
||||
your platform.
|
||||
|
||||
AVAILABILITY
|
||||
|
||||
Download:
|
||||
- http://www.net-snmp.org/download/
|
||||
- ftp://ftp.net-snmp.org/pub/sourceforge/net-snmp/
|
||||
Web page:
|
||||
- http://www.net-snmp.org/
|
||||
Project Wiki:
|
||||
- http://www.net-snmp.org/wiki/
|
||||
Sourceforge Project page:
|
||||
- http://sourceforge.net/projects/net-snmp
|
||||
Mirrors:
|
||||
- US: ftp://ftp.freesnmp.com/mirrors/net-snmp/
|
||||
|
||||
The old ucd-snmp.ucdavis.edu web site and ftp server is now
|
||||
offline and should not be accessed any longer.
|
||||
|
||||
WEB PAGES
|
||||
|
||||
http://www.net-snmp.org/
|
||||
http://sourceforge.net/projects/net-snmp
|
||||
http://www.net-snmp.org/wiki/
|
||||
|
||||
INSTALLATION
|
||||
|
||||
See the INSTALL file distributed with this package.
|
||||
|
||||
COPYING AND COPYRIGHTS
|
||||
|
||||
See the COPYING file distributed with this package.
|
||||
|
||||
FREQUENTLY ASKED QUESTIONS
|
||||
|
||||
See the FAQ file distributed with this package.
|
||||
This is also available on the project Wiki at
|
||||
|
||||
http://www.net-snmp.org/wiki/index.php/FAQ
|
||||
|
||||
so that the wider Net-SNMP community can help maintain it!
|
||||
|
||||
HELPING OUT
|
||||
|
||||
This is a project worked on by people around the net. We'd love
|
||||
your help, but please read the PORTING file first. Also, subscribe
|
||||
to the net-snmp-coders list described below and mention what you're
|
||||
going to work on to make sure no one else is already doing so!
|
||||
You'll also need to keep up to date with the latest code snap shot,
|
||||
which can be obtained from CVS using the information found at
|
||||
http://www.net-snmp.org/cvs/.
|
||||
|
||||
Contributions to the Net-SNMP source code in any form are greatly
|
||||
appreciated. We expect the parties providing such contributions to
|
||||
have the right to contribute them to the Net-SNMP project or that
|
||||
the parties that do have the right have directed the person
|
||||
submitting the contribution to do so. In addition, all contributors
|
||||
need to be aware that if the contribution is accepted and
|
||||
incorporated into the Net-SNMP project, it will be redistributed
|
||||
under the terms of the license agreement used for the entire body of
|
||||
work that comprises the Net-SNMP project (see the COPYING file for
|
||||
details). If this license agreement ever changes the contribution
|
||||
will continue to be released under any new licenses as well. Thank
|
||||
you, in advance, for your gracious contributions.
|
||||
|
||||
CODE UPDATE ANNOUNCEMENTS
|
||||
|
||||
See the NEWS file and the ChangeLog file for details on what has
|
||||
changed between releases.
|
||||
|
||||
We hate broadcasting announce messages to other mailing lists and
|
||||
newsgroups, so there is a mailing list set up to handle release
|
||||
announcements. Any time we put new software out for ftp, we'll mail
|
||||
this fact to net-snmp-announce@lists.sourceforge.net. See the
|
||||
MAILING LISTS section described below to sign up for these
|
||||
announcements.
|
||||
|
||||
We will post new announcements on a very infrequent basis to the
|
||||
other channels (the other snmp mailing lists and newsgroups like
|
||||
comp.protocols.snmp), but only for major code revisions and not for
|
||||
bug-fix patches or small feature upgrades.
|
||||
|
||||
MAILING LISTS
|
||||
|
||||
The lists:
|
||||
|
||||
A number of mailing lists have been created for support of the project:
|
||||
The main ones are:
|
||||
|
||||
net-snmp-announce@lists.sourceforge.net -- For official announcements
|
||||
net-snmp-users@lists.sourceforge.net -- For usage discussions
|
||||
net-snmp-coders@lists.sourceforge.net -- For development discussions
|
||||
|
||||
The -coders list is intended for discussion on development of code
|
||||
that will be shipped as part of the package. The -users list is
|
||||
for general discussion on configuring and using the package,
|
||||
including issues with coding user-developed applications (clients,
|
||||
managers, MIB modules, etc).
|
||||
|
||||
Please do *NOT* send messages to both -users and -coders lists.
|
||||
This is completely unnecessary, and simply serves to further
|
||||
overload (and annoy) the core development team. If in doubt,
|
||||
just use the -users list.
|
||||
|
||||
|
||||
The other lists of possible interest are:
|
||||
|
||||
net-snmp-cvs@lists.sourceforge.net -- For cvs update announcements
|
||||
net-snmp-bugs@lists.sourceforge.net -- For Bug database update announcements
|
||||
net-snmp-patches@lists.sourceforge.net -- For Patch database update announcements
|
||||
|
||||
Please do NOT post messages to these lists (or to the announce list above).
|
||||
Bug reports and Patches should be submitted via the Source Forge tracker
|
||||
system. See the main project web pages for details.
|
||||
|
||||
To subscribe to any of these lists, please see:
|
||||
|
||||
http://www.net-snmp.org/lists/
|
||||
|
||||
|
||||
Archives:
|
||||
The archives for these mailing lists can be found by following links at
|
||||
|
||||
http://www.net-snmp.org/lists/
|
||||
|
||||
AGENT EXTENSIBILITY
|
||||
|
||||
The agent that comes with this package is extensible through use of
|
||||
shell scripts and other methods. See the configuration manual pages
|
||||
(like snmpd.conf) and run the snmpconf perl script for further details.
|
||||
|
||||
You can also extend the agent by writing C code directly. The agent
|
||||
is extremely modular in nature and you need only create new files,
|
||||
re-run configure and re-compile (or link against its libraries). No
|
||||
modification of the distributed source files are necessary. See the
|
||||
following files for details on how to go about this:
|
||||
http://www.net-snmp.org/tutorial-5/toolkit/,
|
||||
agent/mibgroup/examples/*.c
|
||||
|
||||
Also, see the local/mib2c program and its README file for help in
|
||||
turning a textual mib description into a C code template.
|
||||
|
||||
We now support AgentX for subagent extensibility. The net-snmp
|
||||
agent can run as both a master agent and a subagent. Additionally,
|
||||
a toolkit is provided that enables users of it to easily embed a
|
||||
agentx client into external applications. See the tutorial at
|
||||
http://www.net-snmp.org/tutorial-5/toolkit/ for an example of how
|
||||
go about doing this.
|
||||
|
||||
CONFIGURATION
|
||||
|
||||
See the man/snmp.conf.5 manual page.
|
||||
|
||||
For the agent, additionally see the man/snmpd.conf.5 manual page.
|
||||
|
||||
For the snmptrapd, see the man/snmptrapd.conf.5 manual page.
|
||||
|
||||
You can also run the snmpconf perl script to help you create some of
|
||||
these files.
|
||||
|
||||
SUBMITTING BUG REPORTS
|
||||
|
||||
Important: *Please* include what version of the net-snmp (or
|
||||
ucd-snmp) package you are using and what architecture(s) you're
|
||||
using, as well as detailed information about exactly what is wrong.
|
||||
|
||||
To submit a bug report, please use the web interface at
|
||||
http://www.net-snmp.org/bugs/. It is a full-fledged
|
||||
bug-tracking system that will allow you to search for already
|
||||
existing bug reports as well as track the status of your report as
|
||||
it is processed by the core developers.
|
||||
|
||||
If you intend to submit a patch as well, please read the PORTING
|
||||
file before you do so and then submit it to
|
||||
http://www.net-snmp.org/patches/.
|
||||
|
||||
CLOSING
|
||||
|
||||
We love patches. Send some to us! But before you do, please see
|
||||
the 'PORTING' file for information on helping us out with the
|
||||
process of integrating your patches (regardless of whether its a new
|
||||
feature implementation or a new port).
|
||||
|
||||
Also, We're interested if anyone actually uses/likes/hates/whatever
|
||||
this package... Mail us a note and let us know what you think of it!
|
||||
|
||||
Have fun and may it make your life easier,
|
||||
|
||||
The net-snmp developers
|
||||
|
||||
THANKS
|
||||
|
||||
The following people have contributed various patches and
|
||||
improvements. To them we owe our deepest thanks (and you do too!):
|
||||
|
||||
Wes Hardaker <hardaker@users.sourceforge.net>
|
||||
Steve Waldbusser <waldbusser@nextbeacon.com>
|
||||
Dan A. Dickey <ddickey@transition.com>
|
||||
Dave Shield <D.T.Shield@csc.liv.ac.uk>
|
||||
Giovanni S. Marzot <gmarzot@nortelnetworks.com>
|
||||
Niels Baggesen <nba@users.sourceforge.net>
|
||||
Simon Leinen <simon@limmat.switch.ch>
|
||||
David T. Perkins <dperkins@dsperkins.com>
|
||||
Mike Perik <mikep@crt.com>
|
||||
Sanjai Narain <narain@thumper.bellcore.com>
|
||||
francus@metsny.delphi.com
|
||||
Gary Palmer <gpalmer@freebsd.org>
|
||||
Marc G. Fournier <scrappy@ki.net>
|
||||
Gary A. Hayward <gah@bellcore.com>
|
||||
Jennifer Bray <jbray@origin-at.co.uk>
|
||||
Philip Guenther <guenther@gac.edu>
|
||||
Elwyn B Davies <edavies@origin-at.co.uk>
|
||||
Simon Burge <simonb@telstra.com.au>
|
||||
David Paul Zimmerman <dpz@apple.com>
|
||||
Alan Batie <batie@aahz.jf.intel.com>
|
||||
Michael Douglass <mikedoug@texas.net>
|
||||
Ted Rule <Ted_Rule@FLEXTECH.CO.UK>
|
||||
Craig Bevins <craigb@bitcom.net.au>
|
||||
Arther Hyun <arthur@psi.com>
|
||||
Cristian Estan <Cristian.Estan@net.utcluj.ro>
|
||||
Eugene Polovnikov <eugen@rd.zgik.zaporizhzhe.ua>
|
||||
Jakob Ellerstedt <jakob@dynarc.se>
|
||||
Michael J. Slifcak <slif@bellsouth.net>
|
||||
Jonas Olsson <jolsson@erv.ericsson.se>
|
||||
James H. Young <sysjhy@gsu.edu>
|
||||
Jeff Johnson <jbj@redhat.com>
|
||||
Markku Laukkanen <marlaukk@stybba.ntc.nokia.com>
|
||||
Derek Simkowiak <dereks@kd-dev.com>
|
||||
David F. Newman <dnewman@epnet.com>
|
||||
Nick Amato <naamato@merit.edu>
|
||||
Mike Baer <baerm@calweb.com>
|
||||
Patrick Lawrence <pjlawrence@ucdavis.edu>
|
||||
Russ Mundy <mundy@tislabs.com>
|
||||
Olafur Gudmundsson <ogud@tislabs.com>
|
||||
David Reeder <dreeder@tislabs.com>
|
||||
Ed Lewis <lewis@tislabs.com>
|
||||
Bill Babson <wbabson@tislabs.com>
|
||||
Chris Smith <csmith@platform.com>
|
||||
Mike Michaud <mikemichaud@earthlink.net>
|
||||
Andy Hood <ahood@westpac.com.au>
|
||||
Robert Story <rstory@freesnmp.com>
|
||||
Bert Driehuis <driehuis@playbeing.org>
|
||||
Juergen Schoenwaelder <schoenw@ibr.cs.tu-bs.de>
|
||||
Frank Strauss <strauss@ibr.cs.tu-bs.de>
|
||||
Ragnar Kj<4B>rstad <ucd@ragnark.vestdata.no>
|
||||
Jochen Kmietsch <jochen.kmietsch@tu-clausthal.de>
|
||||
Jun-ichiro itojun Hagino <itojun@iijlab.net>
|
||||
John L Villalovos <john.l.villalovos@intel.com>
|
||||
Christoph Mammitzsch <Christoph.Mammitzsch@tu-clausthal.de>
|
||||
Arne Oesleboe <Arne.Oesleboe@item.ntnu.no>
|
||||
Jeff Cours <jeff@ultradns.com>
|
||||
Karl Schilke <karl_schilke@eli.net>
|
||||
John Naylon <jbpn@cambridgebroadband.com>
|
||||
Ken Hornstein <kenh@cmf.nrl.navy.mil>
|
||||
Martin Oldfield <m@mail.tc>
|
||||
Harrie Hazewinkel <harrie@users.sourceforge.net>
|
||||
Mark Ferlatte <ferlatte@users.sourceforge.net>
|
||||
Marus Meissner <marcusmeissner@users.sourceforge.net>
|
||||
Stephan Wenzer <stephanwenzel@users.sourceforge.net>
|
||||
Ron Mevissen <ron.mevissen@eed.ericsson.se>
|
||||
T.J. Mather <tjmather@tjmather.com>
|
||||
Craig Setera <seterajunk@charter.net>
|
||||
Katsuhisa ABE <abekatsu@cysols.com>
|
||||
Axel Kittenberger <Axel.Kittenberger@maxxio.com>
|
||||
Johannes Schmidt-Fischer <jsf@InterFace-AG.com>
|
||||
Jeffrey Watson <nostaw@users.sourceforge.net>
|
||||
Bruce Shaw <Bruce.Shaw@gov.ab.ca>
|
||||
Stefan Radman <sradman@users.sourceforge.net>
|
||||
Stephen J. Friedl <sjfriedl@users.sourceforge.net>
|
||||
Alex Burger <alex_b@users.sourceforge.net>
|
||||
Christophe Varoqui <ext.devoteam.varoqui@sncf.fr>
|
||||
Srikanth Pindiproli <sripindip@users.sourceforge.net>
|
||||
Kevin Graham <kevgraham7@users.sourceforge.net>
|
||||
Xiaofeng Ling <xfling@users.sourceforge.net>
|
||||
Brandon Knitter <knitterb@bl...>
|
||||
Andrew Findlay <andrew.findlay@skills-1st.co.uk>
|
||||
Ron Tabor <rtabor@users.sourceforge.net>
|
||||
Peter Warasin <drg-r3@users.sourceforge.net>
|
||||
Bob Rowlands <robert.rowlands@sun.com>
|
||||
Peter Hicks <Peter.Hicks@POGGS.CO.UK>
|
||||
Andy Smith <wasmith32@earthlink.net>
|
||||
Nick Barkas <nbarkas@users.sourceforge.net>
|
||||
Noah Friedman <friedman@prep.ai.mit.edu>
|
||||
Geert De Peuter <geert@depeuter.org>
|
||||
Magnus Fromreide <magfr@lysator.liu.se>
|
||||
Marcus Meissner <marcusmeissner@users.sourceforge.net>
|
||||
Andrew Rucker Jones <arjones@users.sourceforge.net>
|
||||
Dai.H. <dg-f@users.sourceforge.net>
|
||||
Thomas Anders <tanders@users.sourceforge.net>
|
||||
Vladislav Bogdanov <slava_reg@nsys.by>
|
||||
Peter Martin <pnmartin@users.sourceforge.net>
|
||||
Thomas Lackey <telackey@users.sourceforge.net>
|
||||
Joe Buehler <jbuehler@spirentcom.com>
|
||||
Anders Persson <apersson@users.sourceforge.net>
|
||||
Rojer <rojer@users.sourceforge.net>
|
||||
Bart Van Assche <bart.vanassche@gmail.com>
|
||||
Pablo Carboni <pcarboni@users.sourceforge.net>
|
||||
Bill Fenner <fenner@gmail.com>
|
||||
Brian Sipos <bsiposrkf@users.sourceforge.net>
|
||||
|
||||
We've probably forgotten people on this list. Let us know if you've
|
||||
contributed code and we've left you out.
|
||||
@@ -1,118 +0,0 @@
|
||||
1. INTRODUCTION
|
||||
|
||||
Last revision 05/30/2003
|
||||
|
||||
This document describes the process to build net-snmp-5.0.8 stack for embedded linux
|
||||
platforms based on the following Matsushita(Panasonic) processors family.
|
||||
|
||||
AM33,AM34
|
||||
MN10300,MN103E0HRA
|
||||
|
||||
The same procedure can be followed to build the net-snmp stack for other Matsushita
|
||||
family of processors also.
|
||||
|
||||
2. ENVIRONMENT
|
||||
|
||||
Host Machine : Linux 7.1 or later ( with nfs server or samba server installed ).
|
||||
Target Machine : Am33 Based Embedded platform.
|
||||
Cross-compiler : GNU compiler version 3.1 for AM33/AM34/MN10300/MN103E010HRA
|
||||
am33_2.0-linux-gnu-gcc
|
||||
Host-Target Setup : Samba mount or NFS mount
|
||||
|
||||
|
||||
2. CONFIGURATION
|
||||
|
||||
The following configuration flags can be used to create Makefile.You can reaplce
|
||||
some of the configuration flags according to your platform and compiler.
|
||||
|
||||
Perl support was NOT compiled in due to unavailability of perl support for
|
||||
AM3X platform at this time.
|
||||
|
||||
The parameters passed to configure are as follows...
|
||||
( you can down load the script configure.am33 script )
|
||||
|
||||
--with-cc=am33_2.0-linux-gnu-gcc
|
||||
--host=i686-pc-linux-gnu
|
||||
--target=am33-linux ( Can be removed, if it stops building process )
|
||||
--disable-dlopen
|
||||
--disable-dlclose
|
||||
--disable-dlerror
|
||||
--with-endianness=little
|
||||
--with-openssl=no
|
||||
--with-cflags="-g -mam33 -O2 -static"
|
||||
--oldincludedir=./usr/local
|
||||
--prefix=./usr/local
|
||||
--exec-prefix=./usr/local
|
||||
--with-persistent-directory=./usr/local
|
||||
|
||||
These parameters passed are depending on the capabilities available for the
|
||||
AM33/AM34 development environment at the time of build. These parameter can be
|
||||
changed depending on the avialable capabilities and desired preferences.
|
||||
|
||||
You can use the below shell script directly to create Makefiles and other files.
|
||||
This script also insttals all binaries ,libraries in usr directory in the directory
|
||||
in which this scrip executed.
|
||||
|
||||
# configure.am33
|
||||
#--------------------------------------------------------------------------
|
||||
./configure --with-cc=am33_2.0-linux-gnu-gcc --host=i686-pc-linux-gnu \
|
||||
--disable-dlopen --target=am33-linux --disable-dlclose --disable-dlerror \
|
||||
--with-endianness=little --with-openssl=no --with-cflags="-g -mam33 -O2 -static" \
|
||||
--oldincludedir=./usr/local --prefix=./usr/local --exec-prefix=./usr/local \
|
||||
--with-persistent-directory=./usr/local
|
||||
|
||||
make
|
||||
make install
|
||||
#--------------------------------------------------------------------------
|
||||
|
||||
2. INSTALLATION
|
||||
|
||||
Find a partition with 60 Mb available space which will be mounted on to target machine.
|
||||
Copy or ftp the binary to this location ( copy entire usr directory tree ).
|
||||
Copy net-snmp configuration files from host machine (.snmp directory) on to target / directory.
|
||||
snmp configuration files can be created on host machine by running sbmpconf command. Make sure
|
||||
that host is using snmpconf from net-snmp-5.0.8 version.
|
||||
|
||||
-:ON AM3X target Shell :-
|
||||
Mount the above directory on AM3X platform either using NFS or sambs clients on target machine.
|
||||
|
||||
If you are running a previous version, stop the daemon
|
||||
|
||||
ps -ef | grep snmp
|
||||
|
||||
will return something like:
|
||||
|
||||
root 17736 1 - Jan 26 ? 0:00 /usr/local/sbin/snmpd
|
||||
|
||||
the PID is 17736, so you need to type
|
||||
|
||||
kill {PID}
|
||||
|
||||
in our example this would be
|
||||
|
||||
kill 17736.
|
||||
|
||||
cd /usr/local/sbin
|
||||
./snmpd
|
||||
|
||||
2. TESTING
|
||||
|
||||
You will need to know your SNMP community. For this example, we will use "public".
|
||||
|
||||
snmpwalk -v 2c -m ALL -c public -t 100 localhost .1.3 > snmpwalk.txt
|
||||
more snmpwalk.txt
|
||||
|
||||
This should return a considerable amount of output.
|
||||
|
||||
3. ISSUES
|
||||
|
||||
You may not see correct target name in the build summary. Just ignore it.
|
||||
|
||||
|
||||
Please refer net-snmp documentation for more information...
|
||||
|
||||
|
||||
Srinivasa Rao Gurusu
|
||||
Engineer
|
||||
Panasonic Semiconductor Development Center ( PSDC )
|
||||
gurusus@research.panasonic.com
|
||||
@@ -1,462 +0,0 @@
|
||||
The following is a list of SNMP MIB tables and object, and their
|
||||
implementation status for Net-SNMP.
|
||||
|
||||
Note that simply adding a MIB file does not allow the agent to return values
|
||||
for the MIB. See the FAQ question here for details:
|
||||
|
||||
http://www.net-snmp.org/FAQ.html#How_do_I_add_a_MIB_to_the_agent_
|
||||
|
||||
|
||||
This table was generated by inspecting the source, so it may be incorrect,
|
||||
especially with regards to OS platform support. If an object/table is listed
|
||||
for your OS but doesn't work (or vice-cersa), let us know.
|
||||
|
||||
The Rel column indicates the first release that an object/table was
|
||||
available. That does not imply that all platforms indicated in the OS
|
||||
column were supported for that release. There is no breakdown of feature
|
||||
introduction by platform. Note that the earliest CVS information I could
|
||||
find was for sometime around ucd-snmp 3.2.
|
||||
|
||||
The OS platform is probably the least reliable of the columns, as most are
|
||||
marked as 'unix?', indicating that most unix-based platforms should
|
||||
support the table.
|
||||
|
||||
An '=' in a file path indicates that the table/object name should be
|
||||
substituted in place of the '=' in the path. All paths are relative to
|
||||
the agent/mibgroup directory.
|
||||
|
||||
X.*.0 indicates all scalars under node X.
|
||||
X.?.0 indicates all scalars execept as noted.
|
||||
.Y.0 indicates that Y is an exception to the previous scalar group.
|
||||
|
||||
|
||||
Table Style
|
||||
----------------------------
|
||||
O old (ucd) style helper
|
||||
D table data helper
|
||||
I table iterator
|
||||
A iterate_access
|
||||
S scalar helper
|
||||
G scalar group helper
|
||||
W watched scalar
|
||||
M mfd
|
||||
C container table
|
||||
|
||||
Platform Keys
|
||||
------------------
|
||||
A All systems
|
||||
U unix based
|
||||
L Linux
|
||||
S Solaris
|
||||
H HP-UX
|
||||
B BSD Based
|
||||
F FreeBSD
|
||||
O OpenBSD
|
||||
N NetBSD
|
||||
X MacOSX
|
||||
W Win32 based
|
||||
$ Microsoft
|
||||
C cygwi---
|
||||
M MingW
|
||||
|
||||
A number after a platform indicates notes at the bottom of the file.
|
||||
|
||||
table/object group OS Rel Styl File
|
||||
==============================================================================
|
||||
SNMPv2-MIB
|
||||
system.?.0 A 5.5 W mibII/system_mib.c
|
||||
.sysORLastChange.0 A 5.5 W mibII/sysORTable.c
|
||||
sysORTable A 5.5 C mibII/sysORTable.c
|
||||
snmp.*.0 A 5.5 G mibII/snmp_mib_5_5.c
|
||||
setSerialNo.0 A 5.0 W mibII/setSerialNo.c
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
SNMP-FRAMEWORK-MIB
|
||||
snmpEngine.*.0 A ~4.0? O snmpv3/snmpEngine.c
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
SNMP-MPD-MIB
|
||||
snmpMPDStats.*.0 A ~4.0? G snmpv3/snmpMPDStats_5_5.c
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
SNMP-TARGET-MIB
|
||||
snmpTargetSpinLock.0 A 3.6 O target/snmpTargetAddrEntry.c
|
||||
snmpTargetAddrTable A 3.6 O target/snmpTargetAddrEntry.c
|
||||
snmpTargetParamsTable A 3.6 O target/snmpTargetParamsEntry.c
|
||||
snmpUnavailableContexts.0 A 5.5 G target/target_counters_5_5.c
|
||||
snmpUnknownContexts.0 A 5.5 G target/target_counters_5_5.c
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
SNMP-NOTIFICATION-MIB
|
||||
snmpNotifyTable A 4.2 O notification/=
|
||||
snmpNotifyFilterProfileTable A 4.2 O notification/=
|
||||
snmpNotifyFilterTable A 4.2 O notification/=
|
||||
nlmConfig.*.0 ---
|
||||
nlmStats.*.0 ---
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
NOTIFICATION-LOG-MIB
|
||||
* ---
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
SNMP-PROXY-MIB
|
||||
snmpProxyTable ---
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
SNMP-USER-BASED-SM-MIB
|
||||
usmStats.*.0 A ~4.0 O snmpv3/usmStats.c
|
||||
usmStats.*.0 A 5.5 G snmpv3/usmStats_5_5.c
|
||||
usmUserTable A ~4.0? O snmpv3/usmUser.c
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
SNMP-VIEW-BASED-ACM-MIB
|
||||
vacmContextTable A ~3.5 I mibII/vacm_context.c
|
||||
vacmSecurityToGroupTable A ~3.5 O
|
||||
vacmAccessContextTable A ~3.5 O mibII/vacm_vars.c
|
||||
vacmViewSpinLock.0 A ~3.5 O
|
||||
vacmViewTreeFamilyTable A ~3.5 O
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
SNMP-USM-DH-OBJECTS-MIB
|
||||
usmDHPublicObjects.*.0 A 5.2 S snmp-usm-dh-objects-mib/=/*
|
||||
usmDHUserKeyTable A 5.2 M snmp-usm-dh-objects-mib/=/*
|
||||
usmDHKickstartTable ---
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
SNMP-COMMUNITY-MIB
|
||||
snmpCommunityMIBObjects.*.0 ---
|
||||
snmpCommunityTable ---
|
||||
snmpTargetAddrExtTable ---
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
IF-MIB
|
||||
ifNumber.0 U $2 ~3.2 O mibII/interfaces.c
|
||||
ifTableLastChange.0 ---
|
||||
ifTable (old) U $2 ~3.5 O mibII/interfaces.c
|
||||
ifTable (new) L 5.2 M if-mib/ifTable/*
|
||||
ifTable (new) FOS 5.4 M if-mib/ifTable/*
|
||||
ifXTable L 5.2 M if-mib/ifXTable/*
|
||||
ifXTable FOS 5.4 M if-mib/ifXTable/*
|
||||
ifStackLastChange.0 ---
|
||||
ifStackTable ---
|
||||
ifTestTable ---
|
||||
ifRcvAddressTable ---
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
RFC1213-MIB
|
||||
atTable (D) U $2 ~3.5 O mibII/at.c
|
||||
egp.*.0 ---
|
||||
egpNeighTable ---
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
IP-MIB
|
||||
ip.*.0 U $2 ~3.2 G mibII/ip.c
|
||||
icmp.*.0 U $2 ~3.2 G mibII/icmp.c
|
||||
|
||||
ipSystemStatsTable L 5.2 M ip-mib/=/*
|
||||
ipSystemStatsTable S 5.5 M ip-mib/=/*
|
||||
ipIfStatsTableLastChange.0 ---
|
||||
ipIfStatsTable L-- 5.5 M ip-mib/=/*
|
||||
|
||||
ipAddrTable (D) U $2 4.2 O mibII/ipAddr.c
|
||||
ipAddressSpinLock.0 A 5.5 O mibII/ipAddr.c
|
||||
ipAddressTable L 5.2 M ip-mib/=/*
|
||||
ipAddressTable S 5.5 M ip-mib/=/*
|
||||
ipAddressPrefixTable L 5.3 M ip-mib/=/*
|
||||
|
||||
ipRouteTable (D) U $2 ~3.5 O mibII/*route*.c
|
||||
ipNetToMediaTable (D) U $2 ~3.5 O mibII/at.c
|
||||
ipNetToPhysicalTable (implemented as inetNetToMediaTable)
|
||||
inetNetToMediaTable L 5.2 M ip-mib/=/*
|
||||
ipDefaultRouterTable L 5.5 M ip-mib/=/*
|
||||
|
||||
icmpStatsTable ---
|
||||
icmpMsgStatsTable ---
|
||||
|
||||
ipv4InterfaceTableLastChange ---
|
||||
ipv4InterfaceTable L 5.3 M ip-mib/=/*
|
||||
|
||||
ipv6InterfaceTableLastChange ---
|
||||
ipv6InterfaceTable L 5.3 M ip-mib/=/*
|
||||
ipv6RouterAdvertTable ---
|
||||
ipv6IpForwarding.0 L 5.3 S ip-mib/ip_scalars.c
|
||||
ipv6IpDefaultHopLimit.0 L 5.3 S ip-mib/ip_scalars.c
|
||||
ipv6RouterAdvertSpinLock.0 ---
|
||||
ipv6ScopeZoneIndexTable ---
|
||||
|
||||
ipForwarding.0 L 5.4 S ip-mib/ip_scalars.c
|
||||
ipDefaultTTL.0 L 5.4 S ip-mib/ip_scalars.c
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
IPV6-MIB
|
||||
ipv6MIBObjects.?.0 U 4.1 O mibII/ipv6.c
|
||||
.ipv6IfTableLastChange.0 ---
|
||||
.ipv6RouteNumber.0 ---
|
||||
.ipv6DiscardedRoutes.0 ---
|
||||
ipv6Interfaces U1 4.1 O mibII/ipv6.c
|
||||
ipv6IfTable U1 4.1 O mibII/ipv6.c
|
||||
ipv6IfStatsTable U1 4.1 O mibII/ipv6.c
|
||||
ipv6AddrPrefixTable ---
|
||||
ipv6AddrTable ---
|
||||
ipv6RouteTable ---
|
||||
ipv6NetToMediaTable ---
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
IPV6-TCP-MIB
|
||||
ipv6TcpConnTable U1 4.1 O mibII/ipv6.c
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
IPV6-UDP-MIB
|
||||
ipv6UdpTable U1 4.1 O mibII/ipv6.c
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
IPV6-ICMP-MIB
|
||||
ipv6IfIcmpTable U1 4.1 O mibII/ipv6.c
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
IP-FORWARD-MIB
|
||||
ipForward.*.0 ---
|
||||
ipForwardTable (D) ---
|
||||
ipCidrRouteTable (D)(new) L 5.2 A mibII/=
|
||||
ipCidrRouteTable (D)(newer) L 5.2 M ip-forward-mib/=/*
|
||||
inetCidrRouteTable L 5.2 M ip-forward-mib/=/*
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
TCP-MIB
|
||||
tcp.*.0 U $2 ~3.2 G mibII/tcp.c
|
||||
tcpConnTable (D) U $2 4.2 I mibII/tcpTable.c
|
||||
tcpConnectionTable L 5.3 M tcp-mib/=/*
|
||||
tcpConnectionTable S 5.4 M tcp-mib/=/*
|
||||
tcpListenerTable L 5.3 M tcp-mib/=/*
|
||||
tcpListenerTable S 5.4 M tcp-mib/=/*
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
UDP-MIB
|
||||
udpEndpointTable L 5.3 M udp-mib/=/*
|
||||
udpEndpointTable S 5.4 M udp-mib/=/*
|
||||
udp.*.0 U $2 ~3.2 G mibII/udp.c
|
||||
udpTable (D) U $2 4.2 I mibII/udpTable.c
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
IF-INVERTED-STACK-MIB
|
||||
* ---
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
RMON-MIB
|
||||
etherStatsTable U 5.0 O Rmon/statistics.c
|
||||
.etherStatsJabbers L3 5.5 M rmon-mib/=/*
|
||||
etherHistoryControlTable U 5.0 O Rmon/history.c
|
||||
etherHistoryTable U 5.0 O Rmon/history.c
|
||||
alarmTable U 3.2 O Rmon/alarm.c
|
||||
eventTable U 3.2 O Rmon/event.c
|
||||
logTable U 5.0 O Rmon/event.c
|
||||
hostControlTable ---
|
||||
hostTable ---
|
||||
hostTimeTable ---
|
||||
hostTopNControlTable ---
|
||||
hostTopNTable ---
|
||||
matrixControlTable ---
|
||||
matrixSDTable ---
|
||||
matrixDSTable ---
|
||||
filterTable ---
|
||||
channelTable ---
|
||||
bufferControlTable ---
|
||||
captureBufferTable ---
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
HOST-RESOURCES-MIB
|
||||
hrSystem.*.0 U ~3.3 O host/hr_system.c
|
||||
hrMemorySize U ~3.3 O host/hr_storage.c
|
||||
hrStorageTable U ~3.3 O host/hr_storage.c
|
||||
hrDeviceTable U ~3.3 O host/hr_device.c
|
||||
hrProcessorTable U ~3.3 O host/hr_proc.c
|
||||
hrNetworkTable U ~3.3 O host/hr_network.c
|
||||
hrPrinterTable U ~3.3 O host/hr_print.c
|
||||
hrDiskStorageTable U ~3.3 O host/hr_disk.c
|
||||
hrPartitionTable U ~3.3 O host/hr_partition.c
|
||||
hrFSTable U ~3.3 O host/hr_filesys.c
|
||||
hrSWOSIndex.0 --- ~3.3 O host/hr_swrun.c
|
||||
hrSWRunTable U ~3.3 O host/hr_swrun.c
|
||||
hrSWRunPerfTable U ~3.3 O host/hr_swrun.c
|
||||
hrSWInstalled.*.0 U ~3.3 O host/hr_swinst.c
|
||||
hrSWInstalledTable U ~3.3 O host/hr_swinst.c
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
DISMAN-EVENT-MIB
|
||||
mteTriggerTable A 5.0 O disman/=
|
||||
mteTriggerFailures.0 ---
|
||||
mteTriggerDeltaTable A 5.0 O disman/=
|
||||
mteTriggerExistenceTable A 5.0 O disman/=
|
||||
mteTriggerBooleanTable A 5.0 O disman/=
|
||||
mteTriggerThresholdTable A 5.0 O disman/=
|
||||
mteObjectsTable A 5.0 O disman/=
|
||||
mteEventTable A 5.0.7 D disman/=
|
||||
mteEventFailures.0 ---
|
||||
mteEventNotificationTable A 5.0.7 D disman/=
|
||||
mteResource.*.0 ---
|
||||
mteEventSetTabel ---
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
DISMAN-SCHEDULE-MIB
|
||||
schedLocalTime.0 A 5.3 D disman/schedule/=
|
||||
schedTable A 5.3 D disman/schedule/=
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
DISMAN-EXPRESSION-MIB (expired ID)
|
||||
expErrorTable U 5.2 O disman/expression/=
|
||||
expExpressionTable U 5.2 O disman/expression/=
|
||||
expObjectTable U 5.2 O disman/expression/=
|
||||
expValueTable U 5.2 O disman/expression/=
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
DISMAN-PING-MIB (draft-ietf-disman-remops-mib-v2*)
|
||||
pingCtlTable U 5.2 O disman/ping/=
|
||||
pingProbeHistoryTable U 5.2 O disman/ping/=
|
||||
pingResultsTable U 5.2 O disman/ping/=
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
DISMAN-TRACEROUTE-MIB (draft-ietf-disman-remops-mib-v2*)
|
||||
traceRouteCtlTable U 5.2 O disman/traceroute/=
|
||||
traceRouteHopsTable U 5.2 O disman/traceroute/=
|
||||
traceRouteProbeHistory U 5.2 O disman/traceroute/=
|
||||
traceRouteResultsTable U 5.2 O disman/traceroute/=
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
DISMAN-NSLOOKUP-MIB (draft-ietf-disman-remops-mib-v2*)
|
||||
lookupCtlTable U 5.2 O disman/nslookup/=
|
||||
lookupResultsTable U 5.2 O disman/nslookup/=
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
DISMAN-SCRIPT-MIB
|
||||
* ---
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
EtherLike-MIB
|
||||
dot3StatsTable L 5.5 M etherlike-mib/=
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
AGENTX-MIB
|
||||
* ---
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
LM-SENSORS-MIB
|
||||
lmTempSensorsTable LS 5.0 O ucd-snmp/lmSensors.c
|
||||
lmFanSensorsTable LS 5.0 O ucd-snmp/lmSensors.c
|
||||
lmVoltSensorsTable LS 5.0 O ucd-snmp/lmSensors.c
|
||||
lmMiscSensorsTable LS 5.0 O ucd-snmp/lmSensors.c
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
UCD-SNMP-MIB
|
||||
prTable U $ ~3.2 O ucd-snmp/proc.c
|
||||
memory.*.0 U ~3.2 O ucd-snmp/memory*.c
|
||||
extTable U $ ~3.2 D ucd-snmp/extensible.c
|
||||
dskTable U 3.2 O ucd-snmp/disk.c
|
||||
fileTable A 3.6 O ucd-snmp/file.c
|
||||
laTable U $ ~3.2 O ucd-snmp/loadave.c
|
||||
systemStats.*.0 U 3.4 O ucd-snmp/vmstat*.c
|
||||
ipFwAccTable U 3.5 O misc/ipfwacc.c
|
||||
dlModTable U 4.2 O ucd-snmp/dlmod.c
|
||||
diskIOTable U 4.1 O ucd-snmp/diskio.c
|
||||
ucdDemoMIBObjects A ~3.5 O examples/ucdDemoPublic.c
|
||||
logMatch U ~3.5 O ucd-snmp/logmatch.c
|
||||
version.*.0 A ~3.2 O ucd-snmp/versioninfo.c
|
||||
snmperrs.*.0 A ~3.5 O ucd-snmp/errormib.c
|
||||
mrTable (D) ---
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
NET-SNMP-EXTEND-MIB
|
||||
nsExtendConfigTable U ~3.5 D agent/extend.c
|
||||
nsExtendOutput1Table U ~3.5 D agent/extend.c
|
||||
nsExtentOutput2Table U ~3.5 D agent/extend.c
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
NET-SNMP-AGENT-MIB
|
||||
nsModuleTable A 5.0 I agent/nsModuleTable.c
|
||||
nsCacheTable A 5.0 I agent/nsCache.c
|
||||
nsConfigDebug.*.0 A 5.0 I agent/nsDebug.c
|
||||
nsDebugTokenTable A 5.0 O
|
||||
nsConfigLogging A 5.0 I agent/nsLogging.c
|
||||
nsLoggingTable A 5.0 O
|
||||
nsTransactionTable A 5.0 I agent/nsTransactionTable.c
|
||||
netSnmpExampleScalars A 5.0 O
|
||||
netSnmpIETFWGTable A 5.0 D examples/data_set.c
|
||||
netSnmpHostsTable A 5.0 A examples/=*
|
||||
nstAgentModules A 5.0 O
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
NET-SNMP-VACM-MIB
|
||||
nsVacmAccessTable A 5.4 I agent/nsVacmAccessTable.c
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
MTA-MIB
|
||||
mtaTable U 4.2 O mibII/mta_sendmail.c
|
||||
mtaGroupTable U 4.2 O mibII/mta_sendmail.c
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
SMUX-MIB
|
||||
smuxPeerTable ---
|
||||
smuxTreeTable ---
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
BGP4-MIB (draft-ietf-idr-bgp4-mib)
|
||||
bgpPeerTable A 3.5 O smux/snmp_bgp.c
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
OSPF-MIB (draft-ietf-ospf-mib-update)
|
||||
* A 3.5 O smux/snmp_ospf.c
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
RIPv2-MIB
|
||||
* A 3.5 O smux/snmp_rip2.c
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
TUNNEL-MIB
|
||||
tunnelIfTable L 4.2 O tunnel/tunnel.c
|
||||
tunnelConfigTable L 4.2 O tunnel/tunnel.c
|
||||
tunnelInetConfigTable ---
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
SCTP-MIB
|
||||
sctpStats L 5.5 S sctp-mib/sctpScalars*
|
||||
sctpParameters L 5.5 S sctp-mib/sctpScalars*
|
||||
sctpAssocTable L 5.5 C sctp-mib/=
|
||||
sctpAssocLocalAddrTable L 5.5 C sctp-mib/=
|
||||
sctpAssocRemAddrTable L 5.5 C sctp-mib/=
|
||||
sctpLookupLocalPortTable L 5.5 C sctp-mib/=
|
||||
sctpLookupRemPortTable L 5.5 C sctp-mib/=
|
||||
sctpLookupRemHostNameTable L 5.5 C sctp-mib/=
|
||||
sctpLookupRemPrimIPAddrTable L 5.5 C sctp-mib/=
|
||||
sctpLookupRemIPAddrTable L 5.5 C sctp-mib/=
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
SNMP-TSM-MIB
|
||||
snmpTsmStats A 5.6 D tsm-mib/snmpTsmStats/=
|
||||
snmpConfiguration A 5.6 W tsm-mib/=
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
TLSTM-MIB
|
||||
snmpTlstmSession A 5.6 W tlstm-mib/=/*
|
||||
tlstmCertificateMapping.* A 5.6 w tlstm-mib/=
|
||||
tlstmCertToTSNTable A 5.6 D tlstm-mib/=/*
|
||||
tlstmParamsTable A 5.6 D tlstm-mib/=/*
|
||||
tlstmAddrTable A 5.6 D tlstm-mib/=/*
|
||||
|
||||
==============================================================================
|
||||
|
||||
Misc notes
|
||||
----------
|
||||
1: available for systems using KAME ipv6
|
||||
2: with platform SDK. See README.win32
|
||||
3: works only with Intel and Broadcom network cards and must run as root only
|
||||
|
||||
Other feature info
|
||||
------------------
|
||||
smux 3.2
|
||||
AgentX 4.0
|
||||
proxy support 4.2
|
||||
override token 5.0
|
||||
proper context support 5.2
|
||||
DISMAN-EVENT-MIB implementation rewrite 5.3
|
||||
AgentX, host, disman/event by default 5.3
|
||||
SSH Transport module 5.5
|
||||
(D)TLS Transport module 5.6
|
||||
@@ -1,47 +0,0 @@
|
||||
Net-SNMP contains a reasonably full implementation of the AgentX agent
|
||||
extensibility protocol (RFC 2741) in as much as it supports all
|
||||
the protocol operations described in this document. The core
|
||||
functionality has received a reasonable amount of exposure, and
|
||||
is believed to be more or less stable in normal use. It will
|
||||
also handle the non-graceful termination of subagents - returning
|
||||
a 'genErr' error for three successive requests before unregistering
|
||||
the unresponsive subagent.
|
||||
|
||||
A subagent will attempts to re-establish contact with a dead and
|
||||
resurrected master based on the agentxPingInterval setting. The default
|
||||
for this configuration variable is 15 seconds. It can be changed by
|
||||
putting the following line in your APPLICATION.conf file:
|
||||
|
||||
agentxPingInterval 60
|
||||
|
||||
will make the subagent try to ping the master every 60 seconds, and if
|
||||
the connection is deemed broken it'll try and reconnect to the master
|
||||
agent after that point (once every 60 seconds).
|
||||
|
||||
Similarly, a subagent will not be able to re-register in place of a
|
||||
defunct colleague until the master agent has received three requests
|
||||
for the dead connection (and hence unregistered it).
|
||||
|
||||
Some of the less frequently used features (index allocation,
|
||||
range registration, etc), have received less thorough testing,
|
||||
and may well not be fully functional. Some of the omissions
|
||||
of the earlier release (use of GetBulk, the AgentX MIB)
|
||||
are still missing from this version.
|
||||
|
||||
AgentX support is now included in the agent by default, but needs
|
||||
to be explicitly enabled before use. Activate it using by putting a line
|
||||
|
||||
master agentx
|
||||
|
||||
in the snmpd.conf file. This support is also enabled automatically
|
||||
when the '-x' flag is given (to specify a different master AgentX socket),
|
||||
or when the agent is invoked as an AgentX subagent (i.e. via the name
|
||||
'agentxd' or with the '-X' flag).
|
||||
|
||||
See the main project web page for an examples of a simple stand-alone
|
||||
subagent. (http://www.net-snmp.org/tutorial/tutorial-5/toolkit/)
|
||||
|
||||
|
||||
Please report any problems experienced to the net-snmp-coders list.
|
||||
|
||||
Dave
|
||||
@@ -1,78 +0,0 @@
|
||||
Some notes for the AIX port
|
||||
===========================
|
||||
|
||||
1. Known problems
|
||||
-----------------
|
||||
|
||||
There are the following known problems on AIX:
|
||||
|
||||
1) Shared libraries / embedded perl
|
||||
|
||||
Up to (and including) net-snmp 5.4, configure forced a static build
|
||||
on AIX which caused embedded Perl to be disabled as well.
|
||||
|
||||
Starting with net-snmp 5.4.1, we build shared libraries by default on AIX
|
||||
(like on any other platform) using run-time linking. configure forces the
|
||||
use of the required "-brtl" linker flag.
|
||||
|
||||
With net-snmp 5.5 the shared library build is broken again but the there is
|
||||
no forced static build - use --disable-shared when building.
|
||||
|
||||
2) "grep: capacity exceeded" or "sed: Command line is too long" during configure
|
||||
|
||||
The version of "grep" shipped with AIX versions up to (and including) 5.1
|
||||
has a known limitation of only supporting a maximum of 2048 characters per line.
|
||||
This may cause a significant number of "grep: capacity exceeded" errors during
|
||||
configure which breaks the build. See bug 1367794 for details. The fix is to
|
||||
either install GNU grep (and have it in PATH before the AIX grep) or to upgrade
|
||||
to AIX 5.2 or later.
|
||||
|
||||
There's a similar issue with AIX /usr/bin/sed up to at least AIX 5.3 that
|
||||
causes a significant number of "sed: Command line is too long." errors during
|
||||
configure. The fix is to install GNU sed.
|
||||
|
||||
3) nlist errors with 64-bit kernels
|
||||
|
||||
Accessing certain MIB objects on AIX 5.x machines running a 64-bit kernel will
|
||||
trigger nlist/klookup errors. Starting from net-snmp 5.4, you can avoid those
|
||||
by using
|
||||
|
||||
./configure --without-kmem-usage ...
|
||||
|
||||
|
||||
4) IPv6
|
||||
|
||||
Starting with net-snmp 5.4 you can enable the UDPIPv6 and TCPIPv6 transports
|
||||
on AIX 5.x:
|
||||
|
||||
./configure --enable-ipv6
|
||||
|
||||
There's no support for the IPv6 MIBs, though.
|
||||
|
||||
5) Compiler for Perl
|
||||
|
||||
In general, Perl modules need to be compiled with the same compiler and
|
||||
compiler options as Perl itself. configure detects some mismatches (gcc vs.
|
||||
vendor compiler), but treats different incarnations of the same compiler type
|
||||
as similar. If your version of Perl (e.g. the one supplied by IBM for AIX 5.x)
|
||||
has been compiled with cc_r on AIX, please make sure you also use CC=cc_r when
|
||||
building net-snmp. Building with xlc in this case is known to fail (see bug
|
||||
#1600099).
|
||||
|
||||
|
||||
2. Patches
|
||||
----------
|
||||
|
||||
You may want to have a look for existing AIX patches in our patches tracker
|
||||
(http://www.net-snmp.org/patches/). If you can offer patches yourself to
|
||||
improve the AIX support, please submit them there.
|
||||
|
||||
|
||||
3. Feedback
|
||||
-----------
|
||||
|
||||
Please also see README and PORTING.
|
||||
|
||||
If you have questions, additional insights or (even better) patches regarding
|
||||
net-snmp on AIX, please refer to the net-snmp mailing lists (see
|
||||
http://www.net-snmp.org/lists).
|
||||
@@ -1,22 +0,0 @@
|
||||
Some notes for the HP-UX 11.0/11i port
|
||||
======================================
|
||||
|
||||
1. Starting the net-snmp daemon via rc script
|
||||
---------------------------------------------
|
||||
|
||||
When starting the net-snmp daemon via rc script you have to trap some signals
|
||||
because otherwise the daemon will die the moment the rc script ends. I trap
|
||||
the signals 1, 2 and 3 via "trap '' 1 2 3" immediately before starting the
|
||||
daemon. I didn't check whether all these signals need to be trapped, probably
|
||||
SIGHUP will suffice. BTW this applies to the HP-UX 10.x version as well. It
|
||||
would be a good idea to ignore or handle these signals in the daemon...
|
||||
|
||||
2. Author, credits, comments
|
||||
----------------------------
|
||||
|
||||
The HP-UX 11.0 port was done by Johannes Schmidt-Fischer <jsf@InterFace-AG.com>
|
||||
|
||||
If you have questions or problems please feel free to contact me via the
|
||||
above mentioned e-mail address. Please send a copy of your e-mail to the
|
||||
net-snmp-coders mailing list - probably someone else can answer your
|
||||
question earlier than me;-)
|
||||
@@ -1,56 +0,0 @@
|
||||
Some notes for the IRIX port
|
||||
============================
|
||||
|
||||
1. Compiling
|
||||
------------
|
||||
|
||||
net-snmp 5.3.1 and later have been compiled successfully on IRIX 6.5 using the
|
||||
MIPSpro C compiler 7.4.4m in C99 mode:
|
||||
|
||||
CC=c99 ./configure && make && make install
|
||||
|
||||
Please note that the "host" module doesn't compile on IRIX, so you *cannot*
|
||||
configure with "--with-mib-modules=host".
|
||||
|
||||
Compiling with gcc may be possible, but is unsupported at this point in time
|
||||
due to difficulties with the IRIX system headers. Brent Bice has reported
|
||||
a successful build of net-snmp 5.4 with gcc 3.4.6 on a IP30 machine using:
|
||||
|
||||
CFLAGS="-D_PAGESZ=16384 -D_MIPS3_ADDRSPACE -DIP30 -DR10000 -DMP \
|
||||
-DCELL_PREPARE -DBHV_PREPARE" ./configure ...
|
||||
|
||||
See http://techpubs.sgi.com/library/tpl/cgi-bin/getdoc.cgi/0620/bks/\
|
||||
SGI_Developer/books/DevDriver_PG/sgi_html/ch10.html and
|
||||
/var/sysgen/Makefile.kernio .
|
||||
|
||||
2. CPU stats
|
||||
------------
|
||||
|
||||
net-snmp 5.4.1 and later reports CPU statistics on IRIX 6.x by default using
|
||||
the hardware/cpu/cpu_sysinfo module. There's also an alternative implementation:
|
||||
hardware/cpu/cpu_pcp. For full discussion and build instructions for cpu_pcp
|
||||
see Patch #1675869:
|
||||
|
||||
http://sf.net/support/tracker.php?aid=1675869
|
||||
|
||||
|
||||
3. Known Issues
|
||||
---------------
|
||||
|
||||
Accessing certain MIB objects on IRIX64 machines (i.e. when running a 64-bit
|
||||
kernel will trigger nlist/klookup errors. The agent will not return proper
|
||||
values for the affected MIB objects (e.g. tcpConnTable, udpTable).
|
||||
Starting from net-snmp 5.4, you can avoid nlist altogether (recommended for
|
||||
IRIX64) by using
|
||||
|
||||
./configure --without-kmem-usage ...
|
||||
|
||||
|
||||
3. Feedback
|
||||
-----------
|
||||
|
||||
Please also see README and PORTING.
|
||||
|
||||
If you have questions, additional insights or (even better) patches regarding
|
||||
net-snmp on IRIX, please refer to the net-snmp mailing lists (see
|
||||
http://www.net-snmp.org/lists).
|
||||
@@ -1,165 +0,0 @@
|
||||
This version of net-snmp supports an experimental SNMPv3 security model
|
||||
using Kerberos 5 for authentication. The protocol is described in an
|
||||
up-and-coming IETF Internet-Draft.
|
||||
|
||||
This document describes a brief overview of the Kerberos Security Model
|
||||
and how to use it.
|
||||
|
||||
DESCRIPTION:
|
||||
|
||||
The Kerberos Security Model does not use USM; it is completely seperate
|
||||
and is not tied to USM in any way. It works by placing the following
|
||||
ASN.1 sequence inside of the SNMPv3 msgSecurityParameters:
|
||||
|
||||
ksmSecurityParameters ::= SEQUENCE {
|
||||
-- The Kerberos 5 checksum type used to checksum this message
|
||||
ksmChecksumType INTEGER(0..2147483647),
|
||||
-- The actual keyed checksum data returned by Kerberos
|
||||
ksmChecksum OCTET STRING,
|
||||
-- The Kerberos 5 message (either an AP_REQ or AP_REP)
|
||||
ksmKerberosMsg OCTET STRING,
|
||||
-- The cached ticket identifier
|
||||
ksmCachedTicket INTEGER(0..2147483647)
|
||||
}
|
||||
|
||||
Note that the whole SEQUENCE is BER encoded as an OCTET STRING.
|
||||
|
||||
ksmChecksumType is an integer which corresponded to the checksum algorithm
|
||||
used to secure this message as defined by Kerberos (see section 8.3 of
|
||||
RFC1510).
|
||||
|
||||
ksmChecksum is the output of the checksum algoritm defined by ksmChecksumtype
|
||||
(with all NULs in the space for the checksum).
|
||||
|
||||
ksmKerberosMsg is a Kerberos 5 AP_REQ or AP_REP message, depending on
|
||||
whether or not it is a request or a response (AP_REQ for requests, AP_REP
|
||||
for responses).
|
||||
|
||||
ksmCachedTicket is a integer which uniquely identifies a ticked already
|
||||
cached on the agent to save the overhead of transferring a whole AP_REQ/AP_REP.
|
||||
If there is no such cached ticket, it is left at zero.
|
||||
|
||||
An agent, upon receiving a message using the KSM, will decode the AP_REQ
|
||||
contained within the security parameters and thus validate the client's
|
||||
identity. Using the subkey contained within the AP_REQ, the agent will
|
||||
validate the checksum (after first clearing the checksum bytes to zero),
|
||||
and issue a response, encoding the appropriate AP_REP message in the
|
||||
ksmSecurityParameters.
|
||||
|
||||
If the securityLevel of the message is set to AuthPriv, the scopedPdu
|
||||
payload will be encrypted using the encryption key and algorithm of the
|
||||
AP_REQ subkey. Note that in this case, the msgData will be a BER-encoded
|
||||
OCTET STRING corresponding to the "cipher" element of the EncryptedData
|
||||
sequence defined in RFC 1510, section 6.1.
|
||||
|
||||
Since this security model is experimental, the number assigned to this
|
||||
security model is taken from the recommendations of RFC 2271, section 5,
|
||||
which specify enterprise-specific Security Models of the form:
|
||||
|
||||
SnmpSecurityModel = enterpriseID * 256 + security model number
|
||||
in that enterprise ID;
|
||||
|
||||
In the case of KSM this gives us:
|
||||
|
||||
SnmpSecurityModel = 8072 * 256 + 0 = 2066432
|
||||
|
||||
|
||||
USAGE:
|
||||
|
||||
To actually USE the Kerberos Security Model, do the following:
|
||||
|
||||
0) Install Kerberos
|
||||
|
||||
Let it be stated up front - Installing Kerberos completely "cold", without
|
||||
any Kerberos experience at all, can be daunting (to say the least). If you
|
||||
already have a Kerberos infrastructure at your site, then all of the hard
|
||||
work has been done. If you do NOT, but you still want to tackle it,
|
||||
you might be interested in the Kerberos FAQ, which can be found at:
|
||||
|
||||
http://www.nrl.navy.mil/CCS/people/kenh/kerberos-faq.html
|
||||
|
||||
Currently the code in net-snmp only supports using MIT Kerberos
|
||||
libraries to link against (you should be able to use any kind of Kerberos
|
||||
server, however).
|
||||
|
||||
1) Compile net-snmp with Kerberos.
|
||||
|
||||
This assumes that you already have Kerberos libraries in place.
|
||||
|
||||
Configure net-snmp to include the Kerberos Security Model (ksm) and
|
||||
use --with-cflags and --with-ldflags to specify the location and names
|
||||
of Kerberos header files and libraries. For example, on my system I
|
||||
run:
|
||||
|
||||
./configure --with-cflags='-I/usr/krb5/include' \
|
||||
--with-ldflags='-L/usr/krb5/lib -lkrb5 -lcrypto -lcom_err -R/usr/krb5/lib'
|
||||
|
||||
Note that this is on Solaris, and that -R is required to set the correct
|
||||
shared library path. If you have a newer version of Kerberos, you might
|
||||
instead have to use:
|
||||
|
||||
-lkrb5 -lk5crypto -lcom_err
|
||||
|
||||
as the libraries to link against. If you get errors (for example, you
|
||||
get a message that says the compiler isn't working) you can check
|
||||
config.log for the output of the compiler.
|
||||
|
||||
2) Configure Kerberos and SNMP
|
||||
|
||||
Currently, net-snmp uses the "host" principal assigned to a host. This
|
||||
may change in the future. You will want to create host principals of
|
||||
the form:
|
||||
|
||||
host/f.q.d.n@YOUR.REALM
|
||||
|
||||
For example:
|
||||
|
||||
host/mydesktop.example.org@EXAMPLE.ORG
|
||||
|
||||
and place the encryption keys for these principals on every machine you
|
||||
wish to run a SNMP agent (you place each key on it's corresponding machine).
|
||||
Your Kerberos documentation should explain how to do this (in the case
|
||||
of MIT Kerberos, you want to look at the "ktadd" command inside of
|
||||
kadmin).
|
||||
|
||||
If you have a Kerberos infrastructure, you likely already have these
|
||||
principals in place on your systems.
|
||||
|
||||
If you're installing Kerberos for the first time as well, you also
|
||||
need to create client principals corresponding to your userid. See
|
||||
your Kerberos documentation.
|
||||
|
||||
On the SNMP _agent_ side, you'll want to place in your snmpd.conf file
|
||||
(the one that lives in /usr/local/share/snmp/snmpd.conf, or whereever
|
||||
you have configured on your system):
|
||||
|
||||
rwuser -s ksm userid@YOUR.REALM
|
||||
|
||||
to allow the Kerberos principal 'userid@YOUR.REALM' read/write access to
|
||||
the MIB tree.
|
||||
|
||||
3) Run the agent and client applications
|
||||
|
||||
Note that before you do any of this, you will have to have valid Kerberos
|
||||
credentials (generally acquired with the "kinit" program).
|
||||
|
||||
The agent should run without any additional flags.
|
||||
|
||||
You should run the client apps with the following flags:
|
||||
|
||||
-Y defSecurityModel=ksm
|
||||
-v 3
|
||||
-u username
|
||||
-l authNoPriv
|
||||
|
||||
for example:
|
||||
|
||||
snmpget -v 3 -Y defSecurityModel=ksm -u myname -l authNoPriv testhost \
|
||||
system.sysDescr.0
|
||||
|
||||
If you wish to encrypt the payload, change the -l argument to "authPriv".
|
||||
|
||||
If you run into problems, you can add the -Dksm flag to both the manager
|
||||
applications and the agent to get more detailed Kerberos error messages.
|
||||
Note that this setup assumes a working Kerberos infrastructure; if you
|
||||
run into problems, check to make sure Kerberos is working for you.
|
||||
@@ -1,61 +0,0 @@
|
||||
README.osX
|
||||
$Id$
|
||||
|
||||
This is what I had to do to get it to work for me. Your mileage may vary.
|
||||
If this doesn't work for you, or you have fixes for any problems listed,
|
||||
please post to <net-snmp-coders@lists.sourceforge.net>. Thanks!
|
||||
|
||||
- ALL
|
||||
|
||||
- nlist doesn't support icmpstat
|
||||
|
||||
- disable the icmp module during configure by specifying
|
||||
"--with-out-mib-modules=mibII/icmp", or at startup by adding
|
||||
"-I -icmp" to the snmpd command line.
|
||||
|
||||
|
||||
- 10.4.7 (Universal) and Leopard with 5.4 sources:
|
||||
[Supplied by Chris Jalbert]
|
||||
|
||||
- build using gcc 4.0 (see below) and configure using:
|
||||
--with-persistent-directory=/var/db/net-snmp \
|
||||
--with-defaults \
|
||||
--without-rpm \
|
||||
--with-mib-modules="host ucd-snmp/diskio" \
|
||||
--with-out-mib-modules="mibII/icmp host/hr_swrun" \
|
||||
--without-kmem-usage
|
||||
|
||||
The first line sets up persistent storage in the OS X standard location.
|
||||
|
||||
The third line is necessary because RPM is not properly disabled.
|
||||
|
||||
The fourth line includes those modules appear to build properly and
|
||||
mostly work. The next line is necessary because those sub-modules
|
||||
do not build.
|
||||
|
||||
The final line is necessary because /dev/kmem was removed in
|
||||
the Intel / Universal builds of the OS, and I believe the APIs will
|
||||
be removed in Leopard.
|
||||
This line is the most critical for proper building on OS X.
|
||||
|
||||
|
||||
- 10.3.x and earlier
|
||||
|
||||
- Some older versions of Apple's cpp doesn't like configure.
|
||||
|
||||
- run 'gcc_select' to see what version you are using, and
|
||||
'gcc_select -l' to list available versions. I've had success with
|
||||
3.3, selected by running (as root) 'gcc_select 3.3'. (Note: this was
|
||||
on Panther, 10.3.2)
|
||||
|
||||
- Some older versions of net-snmp as installed by Apple contains
|
||||
bad flags in net-snmp-config.
|
||||
|
||||
- build your own version, and install over Apple's version. The
|
||||
configure flags you need for the same configuration:
|
||||
|
||||
configure --prefix=/usr --mandir=/usr/share/man
|
||||
--infodir=/usr/share/info --with-libwrap --with-defaults
|
||||
--prefix=/usr --with-persistent-directory=/var/db/ucd-snmp
|
||||
--with-mib-modules=host
|
||||
|
||||
@@ -1,105 +0,0 @@
|
||||
README.snmpv3
|
||||
-------------
|
||||
How to setup SNMPv3, a very brief document for Dave to elaborate and
|
||||
do a better job on since I suck at writing documentation and he
|
||||
doesn't ;-) --Wes:
|
||||
|
||||
Note: SHA authentication and DES/AES encryption support is only available
|
||||
if you have OpenSSL installed or if you've compiled using
|
||||
--with-openssl=internal. If you use --with-openssl=internal please
|
||||
read the documentation in snmplib/openssl/README for important details.
|
||||
|
||||
Note: encryption support now *is* enabled in the binary releases downloadable
|
||||
from the net-snmp web site.
|
||||
|
||||
Note: this description assumes you're using the software compiled from
|
||||
source, and so installed using the default prefix location (/usr/local).
|
||||
If you're working with a vendor-provided system, or have configured
|
||||
things with a different prefix, you'll need to adjust locations accordingly.
|
||||
|
||||
CREATING THE FIRST USER:
|
||||
------------------------
|
||||
First, you need to create a new snmpv3 user and give them rights to
|
||||
do things:
|
||||
|
||||
net-snmp-config --create-snmpv3-user -a "my_password" myuser
|
||||
|
||||
WARNING: SNMPv3 pass phrases must be at least 8 characters long!
|
||||
|
||||
The above line creates the user "myuser" with a password of
|
||||
"my_password" (and uses MD5 and DES for protection). (Note that
|
||||
encryption support isn't enabled in the binary releases downloadable
|
||||
from the net-snmp web site.) net-snmp-config will also add a line
|
||||
to your snmpd.conf file to let that user have read/write access to
|
||||
your agent. You may want to change this in your snmpd.conf file
|
||||
(see the snmpd.conf manual page). Run net-snmp-config --help for
|
||||
more information about it.
|
||||
|
||||
Start the agent and test your setup:
|
||||
/usr/local/sbin/snmpd
|
||||
[...wait a few seconds... It will run in the background and
|
||||
return you to your shell immediately.]
|
||||
|
||||
snmpget -v 3 -u myuser -l authNoPriv -a MD5 -A my_password localhost sysUpTime.0
|
||||
[ this should return information about how long your agent has been up]
|
||||
|
||||
snmpget -v 3 -u myuser -l authPriv -a MD5 -A my_password
|
||||
-x DES -X my_password localhost sysUpTime.0
|
||||
[ this should return similar information, but encrypts the transmission ]
|
||||
|
||||
CREATING A SECOND USER:
|
||||
-----------------------
|
||||
Start the agent (if you didn't do so above).
|
||||
|
||||
You can create as many users as you like using the above method, but
|
||||
this details another way of doing it while the agent is running by
|
||||
modifying the user database using the snmp protocol itself:
|
||||
|
||||
Now, lets create a second user using the first user (just for fun)
|
||||
for both authentication purposes and as a template (or "cloning
|
||||
source"):
|
||||
|
||||
snmpusm -v 3 -u myuser -l authNoPriv -a MD5 -A my_password localhost create wes myuser
|
||||
|
||||
The above should have created the user "wes" with the same password as
|
||||
the "myuser" user. So then, you need to change his password using:
|
||||
|
||||
snmpusm -v 3 -u wes -l authNoPriv -a MD5 -A my_password localhost passwd my_password new_passphrase
|
||||
|
||||
See, wasn't that easy? You can now create users. Wheeee....
|
||||
|
||||
But, you'll have to add a configuration line that allows them access
|
||||
to do things. Do this with another "rwuser" line in your
|
||||
/usr/local/share/snmp/snmpd.conf file (you'll need to stop and start
|
||||
the agent again, or send the agent a SIGHUP signal):
|
||||
|
||||
rwuser wes
|
||||
|
||||
Or, optional use the "rouser" token instead of the "rwuser" token to
|
||||
only grant them read-only access.
|
||||
|
||||
Now, test your new user:
|
||||
|
||||
snmpget -v 3 -u wes -l authNoPriv -a MD5 -A new_passphrase localhost sysUpTime.0
|
||||
|
||||
|
||||
FURTHER STUDIES:
|
||||
---------------
|
||||
|
||||
Tired of all those command line authentication options?
|
||||
----------------------------------------
|
||||
put something like this in your $HOME/.snmp/snmp.conf file (make it
|
||||
readable only by you!!!):
|
||||
|
||||
defSecurityName wes
|
||||
defContext ""
|
||||
defAuthType MD5
|
||||
defSecurityLevel authNoPriv
|
||||
defAuthPassphrase new_passphrase
|
||||
defVersion 3
|
||||
|
||||
And this is in place the last of the above example lines boils down to:
|
||||
|
||||
snmpget localhost sysUpTime.0
|
||||
|
||||
Which is about as simple as I can make it for ya ;-)
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,29 +0,0 @@
|
||||
snmptrapd MySQL Logging
|
||||
-----------------------
|
||||
|
||||
A trap handler for logging traps to a MySQL database was added
|
||||
in release 5.5.0.
|
||||
|
||||
The MySQL database location and password must be configured in
|
||||
/root/.my.cnf:
|
||||
|
||||
[snmptrapd]
|
||||
host=localhost
|
||||
password=sql
|
||||
|
||||
User may also be configured, if using a MySQL user besides root.
|
||||
|
||||
snmptrapd.conf must be configured to for the queue size and
|
||||
periodic flush interval:
|
||||
|
||||
# maximum number of traps to queue before forced flush
|
||||
sqlMaxQueue 140
|
||||
|
||||
# seconds between periodic queue flushes
|
||||
sqlSaveInterval 9
|
||||
|
||||
A value of 0 for sqlSaveInterval will completely disable MySQL
|
||||
logging of traps.
|
||||
|
||||
The schema must be loaded into MySQL before running snmptrapd.
|
||||
The schema can be found in dist/schema-snmptrapd.sql
|
||||
@@ -1,343 +0,0 @@
|
||||
Improved Error Reporting and Thread-Safe Use of the SNMP Library
|
||||
|
||||
There is a need in some environments to support multiple threads
|
||||
in a single application. The SNMP Library provides the Single Session
|
||||
functions which support thread-safe operation when certain precautions
|
||||
are taken. This document describes the operation of the SNMP Library
|
||||
with a focus on its session management functions. The Traditional API
|
||||
and the Single API functions are compared and contrasted.
|
||||
A working understanding of the CMU or UCD SNMP Library
|
||||
API is recommended to fully appreciate the concepts discussed.
|
||||
The document ends with a list of restrictions for using the Single API
|
||||
in a multi-threaded application.
|
||||
|
||||
Unfortunately, the SNMPv3 support was added about the same time as
|
||||
the thread support and since they occurred in parallel the SNMPv3
|
||||
support was never checked for multi-threading correctness. It is
|
||||
most likely that it is not thread-safe at this time.
|
||||
|
||||
***** IMPORTANT ANNOUNCEMENT *****
|
||||
To the point, no resource locks are applied within the SNMP Library.
|
||||
The APDU encoding and some session management functions can be used
|
||||
in thread-safe manners. The MIB file parsing is not thread-safe.
|
||||
The Single Session API was made available in November 1998.
|
||||
Existing applications use the Traditional API, which is not thread-safe.
|
||||
The thread-safe considerations are discussed throughout this document.
|
||||
|
||||
The research and development of the Single Session API that I've completed
|
||||
was wholly funded by my employer, Internet Security Systems, Inc.
|
||||
and is distributed freely to the Internet community.
|
||||
|
||||
-Mike Slifcak, 23 April 1999
|
||||
|
||||
09 July 1999 Removed references to snmp_synch_setup and snmp_synch_reset
|
||||
|
||||
|
||||
Availability
|
||||
|
||||
The Single Session API is integrated into the currently available
|
||||
versions of the CMU SNMP library and the UC-Davis SNMP package.
|
||||
|
||||
ftp://ftp.net.cmu.edu/pub/snmp/cmu-snmp-V1.13.tar.gz and later
|
||||
Read : snmp_sess_api.3, Changes.SingleSession
|
||||
|
||||
ftp://ucd-snmp.ucdavis.edu/ucd-snmp-3.6.tar.gz and later
|
||||
Read : snmp_sess_api.3, README.thread (after version 3.6.1)
|
||||
|
||||
Both libraries work equally well in Windows NT and various
|
||||
UNIX platforms. Please read this document and refer to
|
||||
the snmp_sess_api section 3 manual page.
|
||||
|
||||
Glossary of Terms
|
||||
|
||||
APDU Application Protocol Data Unit
|
||||
API Application Programming Interface
|
||||
CMU Carnegie-Mellon University, Pittsburgh, PA.
|
||||
Library The SNMP library; Both CMU and UCD versions are applicable.
|
||||
Session Concept embodying the management of transacting SNMP APDUS.
|
||||
SNMP Simple Network Management Protocol
|
||||
UCD University of California at Davis, CA.
|
||||
|
||||
Introduction
|
||||
|
||||
The Library extends the UNIX file concept (open, close, read, write) to a Session.
|
||||
Opening a Session binds a local socket to a well-known port and creates internal
|
||||
structures to help with controlling the transaction of SNMP APDUs. Closing a
|
||||
Session releases the memory and system resources used for these purposes.
|
||||
|
||||
Since the mid-1980s, many SNMP applications have used the Traditional Session
|
||||
API to transact SNMP APDUs between the local host and SNMP-enabled devices.
|
||||
|
||||
The Traditional Session API does not support multi-threaded applications:
|
||||
|
||||
1) There are no resource locks to prevent exposing the Library's
|
||||
global data resources to corruption in a multi-threaded application;
|
||||
|
||||
2) The Traditional API functions that receive SNMP APDUs
|
||||
do not provide an interface for one of many sessions;
|
||||
|
||||
3) Errors discovered by the Library are communicated through global
|
||||
data structures and are not associated with the session
|
||||
in which the error occurred.
|
||||
|
||||
The Single Session API provides these capabilities:
|
||||
|
||||
1) Manage a single SNMP session safely, in multi-threaded or
|
||||
non-threaded applications, by avoiding access to data structures
|
||||
that the Traditional Session API may share between Sessions;
|
||||
|
||||
2) Associate errors with the session context for threaded
|
||||
and non-threaded applications.
|
||||
|
||||
|
||||
Contrasting and Comparing Traditional API and Single API
|
||||
|
||||
The Traditional API uses the struct snmp_session pointer returned
|
||||
from snmp_open() to identify one SNMP session. The Single API uses
|
||||
the opaque pointer returned from snmp_sess_open() to identify one
|
||||
SNMP session.
|
||||
|
||||
Helpful Hint : The Library copies the contents of the
|
||||
structure which is input to snmp_open() and snmp_sess_open().
|
||||
Once copied, changing that input structure's data
|
||||
has no effect on the opened SNMP Session.
|
||||
|
||||
The Traditional API uses the snmp_error() function to identify any
|
||||
library and system errors that occurred during the processing for
|
||||
one SNMP session. The Single API uses snmp_sess_error() for the
|
||||
same purpose.
|
||||
|
||||
The Traditional API manages the private Sessions list structure;
|
||||
adding to the list during snmp_open(), removing during snmp_close.
|
||||
|
||||
With few exceptions, the Traditional API calls the Single API
|
||||
for each session that appears on the Sessions list.
|
||||
|
||||
The Traditional API reads from all Sessions on the Sessions list;
|
||||
The Single API does not use the Sessions list.
|
||||
The Single API can read from only one Session.
|
||||
|
||||
Helpful Hint :
|
||||
This is the basis for thread-safe-ness of the Library.
|
||||
There are no resource locks applied.
|
||||
|
||||
|
||||
Using the Single API
|
||||
|
||||
A multi-threaded application that deploys the SNMP Library should
|
||||
should complete all MIB file parsing before additional threads
|
||||
are activated. Drawing from the parsed contents of the MIB does
|
||||
not incur any data corruption exposure once the internal MIB structures
|
||||
are initialised.
|
||||
|
||||
The application may create threads such that a single thread may manage
|
||||
a single SNMP session. The thread should call snmp_sess_init()
|
||||
to prepare a struct snmp_session structure. The thread can adjust
|
||||
session parameters such as the remote UDP port or the local UDP port,
|
||||
which must be set prior to invoking snmp_sess_open().
|
||||
|
||||
The first call to snmp_sess_init() initialises the SNMP Library,
|
||||
including the MIB parse trees, before any SNMP sessions are created.
|
||||
Applications that call snmp_sess_init() do not need to read MIBs
|
||||
nor setup environment variables to utilize the Library.
|
||||
|
||||
After the struct snmp_session is setup, the thread must call
|
||||
snmp_sess_open() to create an SNMP session. If at any time
|
||||
the thread must change the Session configuration,
|
||||
snmp_sess_session() returns the pointer to the internal configuration
|
||||
structure (a struct snmp_session, copied from snmp_sess_open).
|
||||
The thread can adjust parameters such as the session timeout
|
||||
or the community string with this returned struct snmp_session pointer.
|
||||
Changes to the remote or local port values have no effect on an opened Session.
|
||||
|
||||
The thread can build PDUs and bind variables to PDUs, as it performs its duties.
|
||||
The thread then calls snmp_sess_send() or snmp_sess_async_send() to build and send
|
||||
an SNMP APDU to the remote device. If a Get-Response-PDU is expected, the thread
|
||||
should call snmp_sess_synch_response() instead.
|
||||
|
||||
When the thread is finished using the session, it must free the resources
|
||||
that the Library used to manage the session.
|
||||
Finally, the thread must call snmp_sess_close() to end the Session.
|
||||
|
||||
Snmp_sess_init(), snmp_open(), and snmp_sess_open()
|
||||
must use the same calling parameter for a given Session.
|
||||
Other methods should use only the returned parameter from
|
||||
snmp_open() and snmp_sess_open() to access the opened SNMP Session.
|
||||
|
||||
|
||||
Error Processing
|
||||
|
||||
Two calls were added : snmp_error() and snmp_sess_error() return the
|
||||
"errno" and "snmp_errno" values from the per session data, and a string
|
||||
that describes the errors that they represent. The string must be freed
|
||||
by the caller.
|
||||
|
||||
Use snmp_error() to process failures after Traditional API calls,
|
||||
or snmp_sess_error() to process failure after Single API calls.
|
||||
In the case where an SNMP session could not be opened,
|
||||
call snmp_error() using the struct snmp_session supplied to either snmp_open()
|
||||
or snmp_sess_open().
|
||||
|
||||
|
||||
The following variables and functions are obsolete and may create problems
|
||||
in a multi-threaded application :
|
||||
|
||||
int snmp_errno
|
||||
char * snmp_detail
|
||||
snmp_set_detail()
|
||||
snmp_api_errstring()
|
||||
|
||||
|
||||
Function Summary
|
||||
|
||||
The functions in the following table are functionally equivalent,
|
||||
with the exception of these behaviors:
|
||||
- The Traditional API manages many sessions
|
||||
- The Traditional API passes a struct snmp_session pointer,
|
||||
and touches the Sessions list
|
||||
- The Single API manages only one session
|
||||
- The Single API passes an opaque pointer, and does not use Sessions list
|
||||
|
||||
Traditional Single Comment
|
||||
=========== ============== =======
|
||||
snmp_sess_init snmp_sess_init Call before either open
|
||||
snmp_open snmp_sess_open Single not on Sessions list
|
||||
snmp_sess_session Exposes snmp_session pointer
|
||||
snmp_send snmp_sess_send Send one APDU
|
||||
snmp_async_send snmp_sess_async_send Send one APDU with callback
|
||||
snmp_select_info snmp_sess_select_info Which session(s) have input
|
||||
snmp_read snmp_sess_read Read APDUs
|
||||
snmp_timeout snmp_sess_timeout Check for timeout
|
||||
snmp_close snmp_sess_close Single not on Sessions list
|
||||
snmp_synch_response snmp_sess_synch_response Send/receive one APDU
|
||||
snmp_error snmp_sess_error Get library,system errno
|
||||
|
||||
|
||||
Example 1 : Traditional API use.
|
||||
|
||||
#include "snmp_api.h"
|
||||
...
|
||||
int liberr, syserr;
|
||||
char *errstr;
|
||||
struct snmp_session Session, *sptr;
|
||||
...
|
||||
snmp_sess_init(&Session);
|
||||
Session.peername = "foo.bar.net";
|
||||
sptr = snmp_open(&Session);
|
||||
if (sptr == NULL) {
|
||||
/* Error codes found in open calling argument */
|
||||
snmp_error(&Session, &liberr, &syserr, &errstr);
|
||||
printf("SNMP create error %s.\n", errstr);
|
||||
free(errstr);
|
||||
return 0;
|
||||
}
|
||||
/* Pass sptr to snmp_error from here forward */
|
||||
...
|
||||
/* Change the community name */
|
||||
free(sptr->community);
|
||||
sptr->community = strdup("public");
|
||||
sptr->community_len = strlen("public");
|
||||
...
|
||||
if (0 == snmp_send(sptr, pdu)) {
|
||||
snmp_error(sptr, &liberr, &syserr, &errstr);
|
||||
printf("SNMP write error %s.\n", errstr);
|
||||
free(errstr);
|
||||
return 0;
|
||||
}
|
||||
snmp_close(sptr);
|
||||
|
||||
|
||||
Example 2 : Single API use.
|
||||
|
||||
#include "snmp_api.h"
|
||||
...
|
||||
int liberr, syserr;
|
||||
char *errstr;
|
||||
void *sessp; /* <-- an opaque pointer, not a struct pointer */
|
||||
struct snmp_session Session, *sptr;
|
||||
...
|
||||
snmp_sess_init(&Session);
|
||||
Session.peername = "foo.bar.net";
|
||||
sessp = snmp_sess_open(&Session);
|
||||
if (sessp == NULL) {
|
||||
/* Error codes found in open calling argument */
|
||||
snmp_error(&Session, &liberr, &syserr, &errstr);
|
||||
printf("SNMP create error %s.\n", errstr);
|
||||
free(errstr);
|
||||
return 0;
|
||||
}
|
||||
sptr = snmp_sess_session(sessp); /* <-- get the snmp_session pointer */
|
||||
|
||||
/* Pass sptr to snmp_sess_error from here forward */
|
||||
...
|
||||
/* Change the community name */
|
||||
free(sptr->community);
|
||||
sptr->community = strdup("public");
|
||||
sptr->community_len = strlen("public");
|
||||
...
|
||||
if (0 == snmp_sess_send(sessp, pdu)) {
|
||||
snmp_sess_error(sessp, &liberr, &syserr, &errstr);
|
||||
printf("SNMP write error %s.\n", errstr);
|
||||
free(errstr);
|
||||
return 0;
|
||||
}
|
||||
snmp_sess_close(sessp);
|
||||
|
||||
Example 3. Differences Between Traditional API and Single API Usage
|
||||
5a6
|
||||
> void *sessp; /* <-- an opaque pointer, not a struct pointer */
|
||||
11,13c12,14
|
||||
< sptr = snmp_open(&Session);
|
||||
< if (sptr == NULL) {
|
||||
---
|
||||
> sessp = snmp_sess_open(&Session);
|
||||
> if (sessp == NULL) {
|
||||
19c20,22
|
||||
< /* Pass sptr to snmp_error from here forward */
|
||||
---
|
||||
> sptr = snmp_sess_session(sessp); /* <-- get the snmp_session pointer */
|
||||
>
|
||||
> /* Pass sptr to snmp_sess_error from here forward */
|
||||
26,27c29,30
|
||||
< if (0 == snmp_send(sptr, pdu)) {
|
||||
< snmp_error(sptr, &liberr, &syserr, &errstr);
|
||||
---
|
||||
> if (0 == snmp_sess_send(sessp, pdu)) {
|
||||
> snmp_sess_error(sessp, &liberr, &syserr, &errstr);
|
||||
33c36
|
||||
< snmp_close(sptr);
|
||||
---
|
||||
> snmp_sess_close(sessp);
|
||||
|
||||
|
||||
Restrictions on Multi-threaded Use of the SNMP Library
|
||||
|
||||
1. Invoke SOCK_STARTUP or SOCK_CLEANUP from the main thread only.
|
||||
|
||||
2. The MIB parsing functions use global shared data and are not
|
||||
multi-thread safe when the MIB tree is under construction.
|
||||
Once the tree is built, the data can be safely referenced from
|
||||
any thread. There is no provision for freeing the MIB tree.
|
||||
Suggestion: Read the MIB files before an SNMP session is created.
|
||||
This can be accomplished by invoking snmp_sess_init from the main
|
||||
thread and discarding the buffer which is initialised.
|
||||
|
||||
3. Invoke the SNMPv2p initialisation before an SNMP session is created,
|
||||
for reasons similar to reading the MIB file.
|
||||
The SNMPv2p structures should be available to all SNMP sessions.
|
||||
CAUTION: These structures have not been tested in a multi-threaded
|
||||
application.
|
||||
|
||||
4. Sessions created using the Single API do not interact with other
|
||||
SNMP sessions. If you choose to use Traditional API calls, call
|
||||
them from a single thread. The Library cannot reference an SNMP
|
||||
session using both Traditional and Single API calls.
|
||||
|
||||
5. Using the callback mechanism for asynchronous response PDUs
|
||||
requires additional caution in a multi-threaded application.
|
||||
This means a callback function probably should probably not use
|
||||
Single API calls to further process the session.
|
||||
|
||||
6. Each call to snmp_sess_open() creates an IDS. Only a call to
|
||||
snmp_sess_close() releases the resources used by the IDS.
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
Some notes for the Tru64 Unix 5.x port
|
||||
======================================
|
||||
|
||||
1. Compiling
|
||||
------------
|
||||
|
||||
The following procedure has been proven to successfully compile net-snmp
|
||||
version 5.2.2 and later on Tru64 Unix 5.1B (Alpha EV5.6) using the Compaq C 6.5
|
||||
compiler:
|
||||
|
||||
./configure --disable-embedded-perl
|
||||
make
|
||||
su -
|
||||
make install
|
||||
|
||||
A recent GNU C compiler (gcc) will probably work, too.
|
||||
|
||||
Please note that the "host" module doesn't compile on Tru64, so you *cannot*
|
||||
run configure with "--with-mib-modules=host".
|
||||
|
||||
2. Embedded Perl
|
||||
----------------
|
||||
|
||||
The Perl package (5.00503) shipped with Tru64 Unix 5.1 isn't complete enough
|
||||
to allow to build net-snmp with embedded Perl support. If you need embedded
|
||||
Perl support, do your own Perl installation first.
|
||||
|
||||
3. IPv6
|
||||
-------
|
||||
|
||||
Starting with net-snmp 5.4 you can enable the UDPIPv6 and TCPIPv6 transports
|
||||
on Tru64 Unix 5.1:
|
||||
|
||||
./configure --enable-ipv6
|
||||
|
||||
There's no support for the IPv6 MIBs, though.
|
||||
|
||||
|
||||
4. Known problems
|
||||
-----------------
|
||||
|
||||
"make test" is known to report the following failure:
|
||||
|
||||
59: testing full snmpwalk (SNMPv2c) against agent (may take time)... FAIL
|
||||
|
||||
so it's obvious that there are still problems with some MIB modules on Tru64.
|
||||
If you have ideas how to fix them, please let us know!
|
||||
|
||||
|
||||
5. Feedback
|
||||
-----------
|
||||
|
||||
Please also see README and PORTING.
|
||||
|
||||
If you have questions, additional insights or (even better) patches regarding
|
||||
net-snmp on Tru64 Unix, please refer to the net-snmp mailing lists (see
|
||||
http://www.net-snmp.org/lists).
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,60 +0,0 @@
|
||||
TODO list of possible projects/developments/etc
|
||||
===============================================
|
||||
|
||||
APIs:
|
||||
Perl (basically OK - may need a review/update)
|
||||
PHP (PHP-shipped API is out of date, needs reworking)
|
||||
Java (see netsnmpj)
|
||||
Tk/Tcl
|
||||
WinSNMP
|
||||
Python (yapsnmp? / snmpy?)
|
||||
#Net
|
||||
|
||||
Agent MIBs:
|
||||
Notification Filtering
|
||||
Community MIB
|
||||
Proxy MIB (extended to support proxying of subtrees)
|
||||
RMON/RMON2
|
||||
MIB-2 updates (in hand)
|
||||
IPv6
|
||||
Firewall (inc. connection tracking)
|
||||
DisMan:
|
||||
monitor (done?)
|
||||
RemOps (preliminary implementation)
|
||||
Tunnel
|
||||
WWW-MIB
|
||||
Hardware Abstraction Layer:
|
||||
HostRes (convert to use HAL and clean up - in progress)
|
||||
UCDavis (convert to use HAL and update structures - in progress)
|
||||
|
||||
Extensibility:
|
||||
AgentX (reasonably stable now)
|
||||
SMUX (?obsolete?)
|
||||
embedded Perl (done? in hand?)
|
||||
" Python
|
||||
DisMan script MIB
|
||||
Extend scripts (new, so will need to bed down)
|
||||
Pass scripts (support SNMPv2 exceptions/errors)
|
||||
DLMod (OK, but MIB i/f not robust)
|
||||
|
||||
Library:
|
||||
Threading
|
||||
Debugging (heirarchical)
|
||||
Config (split syntax & processing, persist/read-only/etc)
|
||||
SecModels:
|
||||
Kerberos (?done)
|
||||
SBSM (?in hand)
|
||||
Pre-compiled MIBs
|
||||
|
||||
Traps:
|
||||
Separate thread in agen
|
||||
Pluggable modules (?done)
|
||||
Dynamic loading
|
||||
Persistent connection
|
||||
Threaded handler
|
||||
|
||||
Documentation:
|
||||
Tutorials
|
||||
Extending the agent
|
||||
Agent internals
|
||||
|
||||
@@ -1,822 +0,0 @@
|
||||
/*
|
||||
* net-snmp configuration header file
|
||||
*
|
||||
* NOTE: DO NOT EDIT include/net-snmp/net-snmp-config.h.in as your changes
|
||||
* will be overwritten. This content is in acconfig.h and merged
|
||||
* into include/net-snmp/net-snmp-config.h.in by autoheader.
|
||||
*/
|
||||
/* Portions of this file are subject to the following copyright(s). See
|
||||
* the Net-SNMP's COPYING file for more details and other copyrights
|
||||
* that may apply:
|
||||
*/
|
||||
/*
|
||||
* Portions of this file are copyrighted by:
|
||||
* Copyright <20> 2003 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms specified in the COPYING file
|
||||
* distributed with the Net-SNMP package.
|
||||
*/
|
||||
|
||||
#ifndef NET_SNMP_CONFIG_H
|
||||
#define NET_SNMP_CONFIG_H
|
||||
|
||||
|
||||
/* ********* NETSNMP_MARK_BEGIN_AUTOCONF_DEFINITIONS ********* */
|
||||
/*
|
||||
* put all autoconf-specific definitions below here
|
||||
*
|
||||
*/
|
||||
#ifndef NETSNMP_NO_AUTOCONF_DEFINITIONS
|
||||
|
||||
/* definitions added by configure on-the-fly */
|
||||
@TOP@
|
||||
@BOTTOM@
|
||||
|
||||
/* end of definitions added by configure on-the-fly */
|
||||
|
||||
/* If you have openssl 0.9.7 or above, you likely have AES support. */
|
||||
#undef NETSNMP_USE_OPENSSL
|
||||
#if (defined(NETSNMP_USE_OPENSSL) && defined(HAVE_OPENSSL_AES_H) && defined(HAVE_AES_CFB128_ENCRYPT)) || defined(NETSNMP_USE_INTERNAL_CRYPTO)
|
||||
#define HAVE_AES 1
|
||||
#endif
|
||||
|
||||
/* define random functions */
|
||||
|
||||
#ifndef HAVE_RANDOM
|
||||
#ifdef HAVE_LRAND48
|
||||
#define random lrand48
|
||||
#define srandom(s) srand48(s)
|
||||
#else
|
||||
#ifdef HAVE_RAND
|
||||
#define random rand
|
||||
#define srandom(s) srand(s)
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* define signal if DNE */
|
||||
|
||||
#ifndef HAVE_SIGNAL
|
||||
#ifdef HAVE_SIGSET
|
||||
#define signal(a,b) sigset(a,b)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_DMALLOC_H
|
||||
#define DMALLOC_FUNC_CHECK
|
||||
#endif
|
||||
|
||||
#endif /* NETSNMP_NO_AUTOCONF_DEFINITIONS */
|
||||
|
||||
|
||||
|
||||
|
||||
/* ********* NETSNMP_MARK_BEGIN_CLEAN_NAMESPACE ********* */
|
||||
/*
|
||||
* put all new net-snmp-specific definitions here
|
||||
*
|
||||
* all definitions MUST have a NETSNMP_ prefix
|
||||
*
|
||||
*/
|
||||
|
||||
/* Default (SNMP) version number for the tools to use */
|
||||
#define NETSNMP_DEFAULT_SNMP_VERSION 3
|
||||
|
||||
/* don't change these values! */
|
||||
#define NETSNMP_SNMPV1 0xAAAA /* readable by anyone */
|
||||
#define NETSNMP_SNMPV2ANY 0xA000 /* V2 Any type (includes NoAuth) */
|
||||
#define NETSNMP_SNMPV2AUTH 0x8000 /* V2 Authenticated requests only */
|
||||
|
||||
/* default list of mibs to load */
|
||||
#define NETSNMP_DEFAULT_MIBS "IP-MIB:IF-MIB:TCP-MIB:UDP-MIB:SNMPv2-MIB:RFC1213-MIB"
|
||||
|
||||
/* debugging stuff */
|
||||
/* if defined, we optimize the code to exclude all debugging calls. */
|
||||
#undef NETSNMP_NO_DEBUGGING
|
||||
/* ignore the -D flag and always print debugging information */
|
||||
#define NETSNMP_ALWAYS_DEBUG 0
|
||||
|
||||
/* reverse encoding BER packets is both faster and more efficient in space. */
|
||||
#define NETSNMP_USE_REVERSE_ASNENCODING 1
|
||||
#define NETSNMP_DEFAULT_ASNENCODING_DIRECTION 1 /* 1 = reverse, 0 = forwards */
|
||||
|
||||
/* PERSISTENT_DIRECTORY: If defined, the library is capabile of saving
|
||||
persisant information to this directory in the form of configuration
|
||||
lines: PERSISTENT_DIRECTORY/NAME.persistent.conf */
|
||||
#define NETSNMP_PERSISTENT_DIRECTORY "/var/snmp"
|
||||
|
||||
/* AGENT_DIRECTORY_MODE: the mode the agents should use to create
|
||||
directories with. Since the data stored here is probably sensitive, it
|
||||
probably should be read-only by root/administrator. */
|
||||
#define NETSNMP_AGENT_DIRECTORY_MODE 0700
|
||||
|
||||
/* MAX_PERSISTENT_BACKUPS:
|
||||
* The maximum number of persistent backups the library will try to
|
||||
* read from the persistent cache directory. If an application fails to
|
||||
* close down successfully more than this number of times, data will be lost.
|
||||
*/
|
||||
#define NETSNMP_MAX_PERSISTENT_BACKUPS 10
|
||||
|
||||
/* define the system type include file here */
|
||||
#define NETSNMP_SYSTEM_INCLUDE_FILE <net-snmp/system/generic.h>
|
||||
|
||||
/* define the machine (cpu) type include file here */
|
||||
#define NETSNMP_MACHINE_INCLUDE_FILE <net-snmp/machine/generic.h>
|
||||
|
||||
/* define the UDP buffer defaults undefined means use the OS buffers
|
||||
* by default */
|
||||
#undef NETSNMP_DEFAULT_SERVER_SEND_BUF
|
||||
#undef NETSNMP_DEFAULT_SERVER_RECV_BUF
|
||||
#undef NETSNMP_DEFAULT_CLIENT_SEND_BUF
|
||||
#undef NETSNMP_DEFAULT_CLIENT_RECV_BUF
|
||||
|
||||
/* net-snmp's major path names */
|
||||
#undef SNMPLIBPATH
|
||||
#undef SNMPSHAREPATH
|
||||
#undef SNMPCONFPATH
|
||||
#undef SNMPDLMODPATH
|
||||
|
||||
/* NETSNMP_LOGFILE: If defined it closes stdout/err/in and opens this in
|
||||
out/err's place. (stdin is closed so that sh scripts won't wait for it) */
|
||||
#undef NETSNMP_LOGFILE
|
||||
|
||||
/* default system contact */
|
||||
#undef NETSNMP_SYS_CONTACT
|
||||
|
||||
/* system location */
|
||||
#undef NETSNMP_SYS_LOC
|
||||
|
||||
/* Use libwrap to handle allow/deny hosts? */
|
||||
#undef NETSNMP_USE_LIBWRAP
|
||||
|
||||
/* Mib-2 tree Info */
|
||||
/* These are the system information variables. */
|
||||
|
||||
#define NETSNMP_VERS_DESC "unknown" /* overridden at run time */
|
||||
#define NETSNMP_SYS_NAME "unknown" /* overridden at run time */
|
||||
|
||||
/* comment out the second define to turn off functionality for any of
|
||||
these: (See README for details) */
|
||||
|
||||
/* proc PROCESSNAME [MAX] [MIN] */
|
||||
#define NETSNMP_PROCMIBNUM 2
|
||||
|
||||
/* exec/shell NAME COMMAND */
|
||||
#define NETSNMP_SHELLMIBNUM 8
|
||||
|
||||
/* swap MIN */
|
||||
#define NETSNMP_MEMMIBNUM 4
|
||||
|
||||
/* disk DISK MINSIZE */
|
||||
#define NETSNMP_DISKMIBNUM 9
|
||||
|
||||
/* load 1 5 15 */
|
||||
#define NETSNMP_LOADAVEMIBNUM 10
|
||||
|
||||
/* which version are you using? This mibloc will tell you */
|
||||
#define NETSNMP_VERSIONMIBNUM 100
|
||||
|
||||
/* Reports errors the agent runs into */
|
||||
/* (typically its "can't fork, no mem" problems) */
|
||||
#define NETSNMP_ERRORMIBNUM 101
|
||||
|
||||
/* The sub id of EXTENSIBLEMIB returned to queries of
|
||||
.iso.org.dod.internet.mgmt.mib-2.system.sysObjectID.0 */
|
||||
#define NETSNMP_AGENTID 250
|
||||
|
||||
/* This ID is returned after the AGENTID above. IE, the resulting
|
||||
value returned by a query to sysObjectID is
|
||||
EXTENSIBLEMIB.AGENTID.???, where ??? is defined below by OSTYPE */
|
||||
|
||||
#define NETSNMP_HPUX9ID 1
|
||||
#define NETSNMP_SUNOS4ID 2
|
||||
#define NETSNMP_SOLARISID 3
|
||||
#define NETSNMP_OSFID 4
|
||||
#define NETSNMP_ULTRIXID 5
|
||||
#define NETSNMP_HPUX10ID 6
|
||||
#define NETSNMP_NETBSD1ID 7
|
||||
#define NETSNMP_FREEBSDID 8
|
||||
#define NETSNMP_IRIXID 9
|
||||
#define NETSNMP_LINUXID 10
|
||||
#define NETSNMP_BSDIID 11
|
||||
#define NETSNMP_OPENBSDID 12
|
||||
#define NETSNMP_WIN32ID 13
|
||||
#define NETSNMP_HPUX11ID 14
|
||||
#define NETSNMP_AIXID 15
|
||||
#define NETSNMP_MACOSXID 16
|
||||
#define NETSNMP_DRAGONFLYID 17
|
||||
#define NETSNMP_UNKNOWNID 255
|
||||
|
||||
#ifdef hpux9
|
||||
#define NETSNMP_OSTYPE NETSNMP_HPUX9ID
|
||||
#endif
|
||||
#ifdef hpux10
|
||||
#define NETSNMP_OSTYPE NETSNMP_HPUX10ID
|
||||
#endif
|
||||
#ifdef hpux11
|
||||
#define NETSNMP_OSTYPE NETSNMP_HPUX11ID
|
||||
#endif
|
||||
#ifdef sunos4
|
||||
#define NETSNMP_OSTYPE NETSNMP_SUNOS4ID
|
||||
#endif
|
||||
#ifdef solaris2
|
||||
#define NETSNMP_OSTYPE NETSNMP_SOLARISID
|
||||
#endif
|
||||
#if defined(osf3) || defined(osf4) || defined(osf5)
|
||||
#define NETSNMP_OSTYPE NETSNMP_OSFID
|
||||
#endif
|
||||
#ifdef ultrix4
|
||||
#define NETSNMP_OSTYPE NETSNMP_ULTRIXID
|
||||
#endif
|
||||
#if defined(netbsd1) || defined(netbsd2)
|
||||
#define NETSNMP_OSTYPE NETSNMP_NETBSD1ID
|
||||
#endif
|
||||
#if defined(__FreeBSD__)
|
||||
#define NETSNMP_OSTYPE NETSNMP_FREEBSDID
|
||||
#endif
|
||||
#if defined(__DragonFly__)
|
||||
#define NETSNMP_OSTYPE NETSNMP_DRAGONFLYID
|
||||
#endif
|
||||
#if defined(irix6) || defined(irix5)
|
||||
#define NETSNMP_OSTYPE NETSNMP_IRIXID
|
||||
#endif
|
||||
#ifdef linux
|
||||
#define NETSNMP_OSTYPE NETSNMP_LINUXID
|
||||
#endif
|
||||
#if defined(bsdi2) || defined(bsdi3) || defined(bsdi4)
|
||||
#define NETSNMP_OSTYPE NETSNMP_BSDIID
|
||||
#endif
|
||||
#if defined(openbsd)
|
||||
#define NETSNMP_OSTYPE NETSNMP_OPENBSDID
|
||||
#endif
|
||||
#ifdef WIN32
|
||||
#define NETSNMP_OSTYPE NETSNMP_WIN32ID
|
||||
#endif
|
||||
#if defined(aix3) || defined(aix4) || defined(aix5) || defined(aix6) || defined(aix7)
|
||||
#define NETSNMP_OSTYPE NETSNMP_AIXID
|
||||
#endif
|
||||
#if defined(darwin) && (darwin >= 8)
|
||||
#define NETSNMP_OSTYPE NETSNMP_MACOSXID
|
||||
#endif
|
||||
/* unknown */
|
||||
#ifndef NETSNMP_OSTYPE
|
||||
#define NETSNMP_OSTYPE NETSNMP_UNKNOWNID
|
||||
#endif
|
||||
|
||||
/* The enterprise number has been assigned by the IANA group. */
|
||||
/* Optionally, this may point to the location in the tree your */
|
||||
/* company/organization has been allocated. */
|
||||
/* The assigned enterprise number for the NET_SNMP MIB modules. */
|
||||
#define NETSNMP_ENTERPRISE_OID 8072
|
||||
#define NETSNMP_ENTERPRISE_MIB 1,3,6,1,4,1,8072
|
||||
#define NETSNMP_ENTERPRISE_DOT_MIB 1.3.6.1.4.1.8072
|
||||
#define NETSNMP_ENTERPRISE_DOT_MIB_LENGTH 7
|
||||
|
||||
/* The assigned enterprise number for sysObjectID. */
|
||||
#define NETSNMP_SYSTEM_MIB 1,3,6,1,4,1,8072,3,2,NETSNMP_OSTYPE
|
||||
#define NETSNMP_SYSTEM_DOT_MIB 1.3.6.1.4.1.8072.3.2.NETSNMP_OSTYPE
|
||||
#define NETSNMP_SYSTEM_DOT_MIB_LENGTH 10
|
||||
|
||||
/* The assigned enterprise number for notifications. */
|
||||
#define NETSNMP_NOTIFICATION_MIB 1,3,6,1,4,1,8072,4
|
||||
#define NETSNMP_NOTIFICATION_DOT_MIB 1.3.6.1.4.1.8072.4
|
||||
#define NETSNMP_NOTIFICATION_DOT_MIB_LENGTH 8
|
||||
|
||||
/* this is the location of the ucdavis mib tree. It shouldn't be
|
||||
changed, as the places it is used are expected to be constant
|
||||
values or are directly tied to the UCD-SNMP-MIB. */
|
||||
#define NETSNMP_UCDAVIS_OID 2021
|
||||
#define NETSNMP_UCDAVIS_MIB 1,3,6,1,4,1,2021
|
||||
#define NETSNMP_UCDAVIS_DOT_MIB 1.3.6.1.4.1.2021
|
||||
#define NETSNMP_UCDAVIS_DOT_MIB_LENGTH 7
|
||||
|
||||
/* how long to wait (seconds) for error querys before reseting the error trap.*/
|
||||
#define NETSNMP_ERRORTIMELENGTH 600
|
||||
|
||||
/* Exec command to fix PROC problems */
|
||||
/* %s will be replaced by the process name in error */
|
||||
|
||||
/* #define NETSNMP_PROCFIXCMD "/usr/bin/perl /local/scripts/fixproc %s" */
|
||||
|
||||
/* Exec command to fix EXEC problems */
|
||||
/* %s will be replaced by the exec/script name in error */
|
||||
|
||||
/* #define NETSNMP_EXECFIXCMD "/usr/bin/perl /local/scripts/fixproc %s" */
|
||||
|
||||
/* Should exec output Cashing be used (speeds up things greatly), and
|
||||
if so, After how many seconds should the cache re-newed? Note:
|
||||
Don't define CASHETIME to disable cashing completely */
|
||||
|
||||
#define NETSNMP_EXCACHETIME 30
|
||||
#define NETSNMP_CACHEFILE ".snmp-exec-cache"
|
||||
#define NETSNMP_MAXCACHESIZE (1500*80) /* roughly 1500 lines max */
|
||||
|
||||
/* misc defaults */
|
||||
|
||||
/* default of 100 meg minimum if the minimum size is not specified in
|
||||
the config file */
|
||||
#define NETSNMP_DEFDISKMINIMUMSPACE 100000
|
||||
|
||||
/* default maximum load average before error */
|
||||
#define NETSNMP_DEFMAXLOADAVE 12.0
|
||||
|
||||
/* max times to loop reading output from execs. */
|
||||
/* Because of sleep(1)s, this will also be time to wait (in seconds) for exec
|
||||
to finish */
|
||||
#define NETSNMP_MAXREADCOUNT 100
|
||||
|
||||
/* Set if snmpgets should block and never timeout */
|
||||
/* The original CMU code had this hardcoded as = 1 */
|
||||
#define NETSNMP_SNMPBLOCK 1
|
||||
|
||||
/* How long to wait before restarting the agent after a snmpset to
|
||||
EXTENSIBLEMIB.VERSIONMIBNUM.VERRESTARTAGENT. This is
|
||||
necessary to finish the snmpset reply before restarting. */
|
||||
#define NETSNMP_RESTARTSLEEP 5
|
||||
|
||||
/* UNdefine to allow specifying zero-length community string */
|
||||
/* #define NETSNMP_NO_ZEROLENGTH_COMMUNITY 1 */
|
||||
|
||||
/* Number of community strings to store */
|
||||
#define NETSNMP_NUM_COMMUNITIES 5
|
||||
|
||||
/* internal define */
|
||||
#define NETSNMP_LASTFIELD -1
|
||||
|
||||
/* Pluggable transports. */
|
||||
|
||||
/* This is defined if support for the UDP/IP transport domain is
|
||||
available. */
|
||||
#undef NETSNMP_TRANSPORT_UDP_DOMAIN
|
||||
|
||||
/* This is defined if support for the "callback" transport domain is
|
||||
available. */
|
||||
#undef NETSNMP_TRANSPORT_CALLBACK_DOMAIN
|
||||
|
||||
/* This is defined if support for the TCP/IP transport domain is
|
||||
available. */
|
||||
#undef NETSNMP_TRANSPORT_TCP_DOMAIN
|
||||
|
||||
/* This is defined if support for the Unix transport domain
|
||||
(a.k.a. "local IPC") is available. */
|
||||
#undef NETSNMP_TRANSPORT_UNIX_DOMAIN
|
||||
|
||||
/* This is defined if support for the AAL5 PVC transport domain is
|
||||
available. */
|
||||
#undef NETSNMP_TRANSPORT_AAL5PVC_DOMAIN
|
||||
|
||||
/* This is defined if support for the IPX transport domain is
|
||||
available. */
|
||||
#undef NETSNMP_TRANSPORT_IPX_DOMAIN
|
||||
|
||||
/* This is defined if support for the UDP/IPv6 transport domain is
|
||||
available. */
|
||||
#undef NETSNMP_TRANSPORT_UDPIPV6_DOMAIN
|
||||
|
||||
/* This is defined if support for the TCP/IPv6 transport domain is
|
||||
available. */
|
||||
#undef NETSNMP_TRANSPORT_TCPIPV6_DOMAIN
|
||||
|
||||
/* This is defined if support for the TLS transport domain is
|
||||
available. */
|
||||
#undef NETSNMP_TRANSPORT_TLSBASE_DOMAIN
|
||||
|
||||
/* This is defined if support for the Alias transport domain is
|
||||
available. */
|
||||
#undef NETSNMP_TRANSPORT_ALIAS_DOMAIN
|
||||
|
||||
/* This is defined if support for the SSH transport domain is
|
||||
available. */
|
||||
#undef NETSNMP_TRANSPORT_SSH_DOMAIN
|
||||
|
||||
/* This is defined if support for the DTLS/UDP transport domain is
|
||||
available. */
|
||||
#undef NETSNMP_TRANSPORT_DTLSUDP_DOMAIN
|
||||
|
||||
/* This is defined if support for the TLS/TCP transport domain is
|
||||
available. */
|
||||
#undef NETSNMP_TRANSPORT_TLSTCP_DOMAIN
|
||||
|
||||
/* This is defined if support for stdin/out transport domain is available. */
|
||||
#undef NETSNMP_TRANSPORT_STD_DOMAIN
|
||||
|
||||
/* This is defined if support for the IPv4Base transport domain is available. */
|
||||
#undef NETSNMP_TRANSPORT_IPV4BASE_DOMAIN
|
||||
|
||||
/* define this if the USM security module is available */
|
||||
#undef NETSNMP_SECMOD_USM
|
||||
|
||||
/* define this if the KSM (kerberos based snmp) security module is available */
|
||||
#undef NETSNMP_SECMOD_KSM
|
||||
|
||||
/* define this if the local security module is available */
|
||||
#undef NETSNMP_SECMOD_LOCALSM
|
||||
|
||||
/* define if configured as a "mini-agent" */
|
||||
#undef NETSNMP_MINI_AGENT
|
||||
|
||||
/* this is the location of the net-snmp mib tree. It shouldn't be
|
||||
changed, as the places it is used are expected to be constant
|
||||
values or are directly tied to the UCD-SNMP-MIB. */
|
||||
#define NETSNMP_OID 8072
|
||||
#define NETSNMP_MIB 1,3,6,1,4,1,8072
|
||||
#define NETSNMP_DOT_MIB 1.3.6.1.4.1.8072
|
||||
#define NETSNMP_DOT_MIB_LENGTH 7
|
||||
|
||||
/* pattern for temporary file names */
|
||||
#define NETSNMP_TEMP_FILE_PATTERN "/tmp/snmpdXXXXXX"
|
||||
|
||||
/*
|
||||
* this must be before the system/machine includes, to allow them to
|
||||
* override and turn off inlining. To do so, they should do the
|
||||
* following:
|
||||
*
|
||||
* #undef NETSNMP_ENABLE_INLINE
|
||||
* #define NETSNMP_ENABLE_INLINE 0
|
||||
*
|
||||
* A user having problems with their compiler can also turn off
|
||||
* the use of inline by defining NETSNMP_NO_INLINE via their cflags:
|
||||
*
|
||||
* -DNETSNMP_NO_INLINE
|
||||
*
|
||||
* Header and source files should only test against NETSNMP_USE_INLINE:
|
||||
*
|
||||
* #ifdef NETSNMP_USE_INLINE
|
||||
* NETSNMP_INLINE function(int parm) { return parm -1; }
|
||||
* #endif
|
||||
*
|
||||
* Functions which should be static, regardless of whether or not inline
|
||||
* is available or enabled should use the NETSNMP_STATIC_INLINE macro,
|
||||
* like so:
|
||||
*
|
||||
* NETSNMP_STATIC_INLINE function(int parm) { return parm -1; }
|
||||
*
|
||||
* NOT like this:
|
||||
*
|
||||
* static NETSNMP_INLINE function(int parm) { return parm -1; }
|
||||
*
|
||||
*/
|
||||
#ifdef NETSNMP_BROKEN_INLINE
|
||||
# define NETSNMP_ENABLE_INLINE 0
|
||||
#else
|
||||
# define NETSNMP_ENABLE_INLINE 1
|
||||
#endif
|
||||
|
||||
#include NETSNMP_SYSTEM_INCLUDE_FILE
|
||||
#include NETSNMP_MACHINE_INCLUDE_FILE
|
||||
|
||||
#if NETSNMP_ENABLE_INLINE && !defined(NETSNMP_NO_INLINE)
|
||||
# define NETSNMP_USE_INLINE 1
|
||||
# ifndef NETSNMP_INLINE
|
||||
# define NETSNMP_INLINE inline
|
||||
# endif
|
||||
# ifndef NETSNMP_STATIC_INLINE
|
||||
# define NETSNMP_STATIC_INLINE static inline
|
||||
# endif
|
||||
#else
|
||||
# define NETSNMP_INLINE
|
||||
# define NETSNMP_STATIC_INLINE static
|
||||
#endif
|
||||
|
||||
#ifndef NETSNMP_IMPORT
|
||||
# define NETSNMP_IMPORT extern
|
||||
#endif
|
||||
|
||||
/* comment the next line if you are compiling with libsnmp.h
|
||||
and are not using the UC-Davis SNMP library. */
|
||||
#define UCD_SNMP_LIBRARY 1
|
||||
|
||||
/* final conclusion on nlist usage */
|
||||
#if defined(HAVE_NLIST) && defined(HAVE_STRUCT_NLIST_N_VALUE) && !defined(NETSNMP_DONT_USE_NLIST) && defined(HAVE_KMEM) && !defined(NETSNMP_NO_KMEM_USAGE)
|
||||
#define NETSNMP_CAN_USE_NLIST
|
||||
#endif
|
||||
|
||||
|
||||
/* ********* NETSNMP_MARK_BEGIN_LEGACY_DEFINITIONS *********/
|
||||
/*
|
||||
* existing definitions prior to Net-SNMP 5.4
|
||||
*
|
||||
* do not add anything new here
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef NETSNMP_NO_LEGACY_DEFINITIONS
|
||||
|
||||
#ifdef NETSNMP_DEFAULT_SNMP_VERSION
|
||||
# define DEFAULT_SNMP_VERSION NETSNMP_DEFAULT_SNMP_VERSION
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_SNMPV1
|
||||
# define SNMPV1 NETSNMP_SNMPV1
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_SNMPV2ANY
|
||||
# define SNMPV2ANY NETSNMP_SNMPV2ANY
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_SNMPV2AUTH
|
||||
# define SNMPV2AUTH NETSNMP_SNMPV2AUTH
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_DEFAULT_MIBS
|
||||
# define DEFAULT_MIBS NETSNMP_DEFAULT_MIBS
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_DEFAULT_MIBDIRS
|
||||
# define DEFAULT_MIBDIRS NETSNMP_DEFAULT_MIBDIRS
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_DEFAULT_MIBFILES
|
||||
# define DEFAULT_MIBFILES NETSNMP_DEFAULT_MIBFILES
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
|
||||
# define OPAQUE_SPECIAL_TYPES NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_ENABLE_SCAPI_AUTHPRIV
|
||||
# define SCAPI_AUTHPRIV NETSNMP_ENABLE_SCAPI_AUTHPRIV
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_USE_INTERNAL_MD5
|
||||
# define USE_INTERNAL_MD5 NETSNMP_USE_INTERNAL_MD5
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_USE_PKCS11
|
||||
# define USE_PKCS NETSNMP_USE_PKCS11
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_USE_OPENSSL
|
||||
# define USE_OPENSSL NETSNMP_USE_OPENSSL
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_NO_DEBUGGING
|
||||
# define SNMP_NO_DEBUGGING NETSNMP_NO_DEBUGGING
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_ALWAYS_DEBUG
|
||||
# define SNMP_ALWAYS_DEBUG NETSNMP_ALWAYS_DEBUG
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_USE_REVERSE_ASNENCODING
|
||||
# define USE_REVERSE_ASNENCODING NETSNMP_USE_REVERSE_ASNENCODING
|
||||
#endif
|
||||
#ifdef NETSNMP_DEFAULT_ASNENCODING_DIRECTION
|
||||
# define DEFAULT_ASNENCODING_DIRECTION NETSNMP_DEFAULT_ASNENCODING_DIRECTION
|
||||
#endif
|
||||
|
||||
#define PERSISTENT_DIRECTORY NETSNMP_PERSISTENT_DIRECTORY
|
||||
#define PERSISTENT_MASK NETSNMP_PERSISTENT_MASK
|
||||
#define AGENT_DIRECTORY_MODE NETSNMP_AGENT_DIRECTORY_MODE
|
||||
#define MAX_PERSISTENT_BACKUPS NETSNMP_MAX_PERSISTENT_BACKUPS
|
||||
#define SYSTEM_INCLUDE_FILE NETSNMP_SYSTEM_INCLUDE_FILE
|
||||
#define MACHINE_INCLUDE_FILE NETSNMP_MACHINE_INCLUDE_FILE
|
||||
|
||||
#ifdef NETSNMP_DEFAULT_SERVER_SEND_BUF
|
||||
# define DEFAULT_SERVER_SEND_BUF NETSNMP_DEFAULT_SERVER_SEND_BUF
|
||||
#endif
|
||||
#ifdef NETSNMP_DEFAULT_SERVER_RECV_BUF
|
||||
# define DEFAULT_SERVER_RECV_BUF NETSNMP_DEFAULT_SERVER_RECV_BUF
|
||||
#endif
|
||||
#ifdef NETSNMP_DEFAULT_CLIENT_SEND_BUF
|
||||
# define DEFAULT_CLIENT_SEND_BUF NETSNMP_DEFAULT_CLIENT_SEND_BUF
|
||||
#endif
|
||||
#ifdef NETSNMP_DEFAULT_CLIENT_RECV_BUF
|
||||
# define DEFAULT_CLIENT_RECV_BUF NETSNMP_DEFAULT_CLIENT_RECV_BUF
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_LOGFILE
|
||||
# define LOGFILE NETSNMP_LOGFILE
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_SYS_CONTACT
|
||||
# define SYS_CONTACT NETSNMP_SYS_CONTACT
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_SYS_LOC
|
||||
# define SYS_LOC NETSNMP_SYS_LOC
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_USE_LIBWRAP
|
||||
# define USE_LIBWRAP NETSNMP_USE_LIBWRAP
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_ENABLE_TESTING_CODE
|
||||
# define SNMP_TESTING_CODE NETSNMP_ENABLE_TESTING_CODE
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_NO_ROOT_ACCESS
|
||||
# define NO_ROOT_ACCESS NETSNMP_NO_ROOT_ACCESS
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_NO_KMEM_USAGE
|
||||
# define NO_KMEM_USAGE NETSNMP_NO_KMEM_USAGE
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_NO_DUMMY_VALUES
|
||||
# define NO_DUMMY_VALUES NETSNMP_NO_DUMMY_VALUES
|
||||
#endif
|
||||
|
||||
#define VERS_DESC NETSNMP_VERS_DESC
|
||||
#define SYS_NAME NETSNMP_SYS_NAME
|
||||
|
||||
#define PROCMIBNUM NETSNMP_PROCMIBNUM
|
||||
#define SHELLMIBNUM NETSNMP_SHELLMIBNUM
|
||||
#define MEMMIBNUM NETSNMP_MEMMIBNUM
|
||||
#define DISKMIBNUM NETSNMP_DISKMIBNUM
|
||||
|
||||
#define LOADAVEMIBNUM NETSNMP_LOADAVEMIBNUM
|
||||
#define VERSIONMIBNUM NETSNMP_VERSIONMIBNUM
|
||||
#define ERRORMIBNUM NETSNMP_ERRORMIBNUM
|
||||
#define AGENTID NETSNMP_AGENTID
|
||||
|
||||
#define HPUX9ID NETSNMP_HPUX9ID
|
||||
#define SUNOS4ID NETSNMP_SUNOS4ID
|
||||
#define SOLARISID NETSNMP_SOLARISID
|
||||
#define OSFID NETSNMP_OSFID
|
||||
#define ULTRIXID NETSNMP_ULTRIXID
|
||||
#define HPUX10ID NETSNMP_HPUX10ID
|
||||
#define NETBSD1ID NETSNMP_NETBSD1ID
|
||||
#define FREEBSDID NETSNMP_FREEBSDID
|
||||
#define IRIXID NETSNMP_IRIXID
|
||||
#define LINUXID NETSNMP_LINUXID
|
||||
#define BSDIID NETSNMP_BSDIID
|
||||
#define OPENBSDID NETSNMP_OPENBSDID
|
||||
#define WIN32ID NETSNMP_WIN32ID
|
||||
#define HPUX11ID NETSNMP_HPUX11ID
|
||||
#define AIXID NETSNMP_AIXID
|
||||
#define MACOSXID NETSNMP_MACOSXID
|
||||
#define UNKNOWNID NETSNMP_UNKNOWNID
|
||||
|
||||
#define ENTERPRISE_OID NETSNMP_ENTERPRISE_OID
|
||||
#define ENTERPRISE_MIB NETSNMP_ENTERPRISE_MIB
|
||||
#define ENTERPRISE_DOT_MIB NETSNMP_ENTERPRISE_DOT_MIB
|
||||
#define ENTERPRISE_DOT_MIB_LENGTH NETSNMP_ENTERPRISE_DOT_MIB_LENGTH
|
||||
|
||||
#define SYSTEM_MIB NETSNMP_SYSTEM_MIB
|
||||
#define SYSTEM_DOT_MIB NETSNMP_SYSTEM_DOT_MIB
|
||||
#define SYSTEM_DOT_MIB_LENGTH NETSNMP_SYSTEM_DOT_MIB_LENGTH
|
||||
|
||||
#define NOTIFICATION_MIB NETSNMP_NOTIFICATION_MIB
|
||||
#define NOTIFICATION_DOT_MIB NETSNMP_NOTIFICATION_DOT_MIB
|
||||
#define NOTIFICATION_DOT_MIB_LENGTH NETSNMP_NOTIFICATION_DOT_MIB_LENGTH
|
||||
|
||||
#define UCDAVIS_OID NETSNMP_UCDAVIS_OID
|
||||
#define UCDAVIS_MIB NETSNMP_UCDAVIS_MIB
|
||||
#define UCDAVIS_DOT_MIB NETSNMP_UCDAVIS_DOT_MIB
|
||||
#define UCDAVIS_DOT_MIB_LENGTH NETSNMP_UCDAVIS_DOT_MIB_LENGTH
|
||||
|
||||
#define ERRORTIMELENGTH NETSNMP_ERRORTIMELENGTH
|
||||
|
||||
#ifdef NETSNMP_PROCFIXCMD
|
||||
# define PROCFIXCMD NETSNMP_PROCFIXCMD
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_EXECFIXCMD
|
||||
# define EXECFIXCMD NETSNMP_EXECFIXCMD
|
||||
#endif
|
||||
|
||||
#define EXCACHETIME NETSNMP_EXCACHETIME
|
||||
#define CACHEFILE NETSNMP_CACHEFILE
|
||||
#define MAXCACHESIZE NETSNMP_MAXCACHESIZE
|
||||
|
||||
#define DEFDISKMINIMUMSPACE NETSNMP_DEFDISKMINIMUMSPACE
|
||||
#define DEFMAXLOADAVE NETSNMP_DEFMAXLOADAVE
|
||||
#define MAXREADCOUNT NETSNMP_MAXREADCOUNT
|
||||
|
||||
#define SNMPBLOCK NETSNMP_SNMPBLOCK
|
||||
#define RESTARTSLEEP NETSNMP_RESTARTSLEEP
|
||||
|
||||
#define NUM_COMMUNITIES NETSNMP_NUM_COMMUNITIES
|
||||
|
||||
#ifdef NETSNMP_NO_ZEROLENGTH_COMMUNITY
|
||||
# define NO_ZEROLENGTH_COMMUNITY NETSNMP_NO_ZEROLENGTH_COMMUNITY
|
||||
#endif
|
||||
|
||||
#define LASTFIELD NETSNMP_LASTFIELD
|
||||
|
||||
#define CONFIGURE_OPTIONS NETSNMP_CONFIGURE_OPTIONS
|
||||
|
||||
#ifdef NETSNMP_TRANSPORT_UDP_DOMAIN
|
||||
# define SNMP_TRANSPORT_UDP_DOMAIN NETSNMP_TRANSPORT_UDP_DOMAIN
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_TRANSPORT_CALLBACK_DOMAIN
|
||||
# define SNMP_TRANSPORT_CALLBACK_DOMAIN NETSNMP_TRANSPORT_CALLBACK_DOMAIN
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_TRANSPORT_TCP_DOMAIN
|
||||
# define SNMP_TRANSPORT_TCP_DOMAIN NETSNMP_TRANSPORT_TCP_DOMAIN
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_TRANSPORT_UNIX_DOMAIN
|
||||
# define SNMP_TRANSPORT_UNIX_DOMAIN NETSNMP_TRANSPORT_UNIX_DOMAIN
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_TRANSPORT_AAL5PVC_DOMAIN
|
||||
# define SNMP_TRANSPORT_AAL5PVC_DOMAIN NETSNMP_TRANSPORT_AAL5PVC_DOMAIN
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_TRANSPORT_IPX_DOMAIN
|
||||
# define SNMP_TRANSPORT_IPX_DOMAIN NETSNMP_TRANSPORT_IPX_DOMAIN
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_TRANSPORT_UDPIPV6_DOMAIN
|
||||
# define SNMP_TRANSPORT_UDPIPV6_DOMAIN NETSNMP_TRANSPORT_UDPIPV6_DOMAIN
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_TRANSPORT_TCPIPV6_DOMAIN
|
||||
# define SNMP_TRANSPORT_TCPIPV6_DOMAIN NETSNMP_TRANSPORT_TCPIPV6_DOMAIN
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_TRANSPORT_TLS_DOMAIN
|
||||
# define SNMP_TRANSPORT_TLS_DOMAIN NETSNMP_TRANSPORT_TLS_DOMAIN
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_TRANSPORT_STD_DOMAIN
|
||||
# define SNMP_TRANSPORT_STD_DOMAIN NETSNMP_TRANSPORT_STD_DOMAIN
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_SECMOD_USM
|
||||
# define SNMP_SECMOD_USM NETSNMP_SECMOD_USM
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_SECMOD_KSM
|
||||
# define SNMP_SECMOD_KSM NETSNMP_SECMOD_KSM
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_SECMOD_LOCALSM
|
||||
# define SNMP_SECMOD_LOCALSM NETSNMP_SECMOD_LOCALSM
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_REENTRANT
|
||||
# define NS_REENTRANT NETSNMP_REENTRANT
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_ENABLE_IPV6
|
||||
# define INET6 NETSNMP_ENABLE_IPV6
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_ENABLE_LOCAL_SMUX
|
||||
# define LOCAL_SMUX NETSNMP_ENABLE_LOCAL_SMUX
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_AGENTX_DOM_SOCK_ONLY
|
||||
# define AGENTX_DOM_SOCK_ONLY NETSNMP_AGENTX_DOM_SOCK_ONLY
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_SNMPTRAPD_DISABLE_AGENTX
|
||||
# define SNMPTRAPD_DISABLE_AGENTX
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_USE_KERBEROS_MIT
|
||||
# define MIT_NEW_CRYPTO NETSNMP_USE_KERBEROS_MIT
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_USE_KERBEROS_HEIMDAL
|
||||
# define HEIMDAL NETSNMP_USE_KERBEROS_HEIMDAL
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_AGENTX_SOCKET
|
||||
# define AGENTX_SOCKET NETSNMP_AGENTX_SOCKET
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_DISABLE_MIB_LOADING
|
||||
# define DISABLE_MIB_LOADING NETSNMP_DISABLE_MIB_LOADING
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_DISABLE_SNMPV1
|
||||
# define DISABLE_SNMPV1 NETSNMP_DISABLE_SNMPV1
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_DISABLE_SNMPV2C
|
||||
# define DISABLE_SNMPV2C NETSNMP_DISABLE_SNMPV2C
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_DISABLE_SET_SUPPORT
|
||||
# define DISABLE_SET_SUPPORT NETSNMP_DISABLE_SET_SUPPORT
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_DISABLE_DES
|
||||
# define DISABLE_DES NETSNMP_DISABLE_DES
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_DISABLE_MD5
|
||||
# define DISABLE_MD5 NETSNMP_DISABLE_MD5
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_DONT_USE_NLIST
|
||||
# define DONT_USE_NLIST NETSNMP_DONT_USE_NLIST
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_CAN_USE_NLIST
|
||||
# define CAN_USE_NLIST NETSNMP_CAN_USE_NLIST
|
||||
#endif
|
||||
|
||||
#ifdef NETSNMP_CAN_USE_SYSCTL
|
||||
# define CAN_USE_SYSCTL NETSNMP_CAN_USE_SYSCTL
|
||||
#endif
|
||||
|
||||
#endif /* NETSNMP_NO_LEGACY_DEFINITIONS */
|
||||
|
||||
|
||||
#endif /* NET_SNMP_CONFIG_H */
|
||||
24
net-snmp/net-snmp-5.7.3/aclocal.m4
vendored
24
net-snmp/net-snmp-5.7.3/aclocal.m4
vendored
@@ -1,24 +0,0 @@
|
||||
# generated automatically by aclocal 1.11 -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
|
||||
# 2005, 2006, 2007, 2008, 2009 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([m4/ac_add_search_path.m4])
|
||||
m4_include([m4/ac_msg_cache.m4])
|
||||
m4_include([m4/ac_msg_module_dbg.m4])
|
||||
m4_include([m4/ac_prompt_user.m4])
|
||||
m4_include([m4/libtool.m4])
|
||||
m4_include([m4/ltoptions.m4])
|
||||
m4_include([m4/ltsugar.m4])
|
||||
m4_include([m4/ltversion.m4])
|
||||
m4_include([m4/lt~obsolete.m4])
|
||||
m4_include([m4/netsnmp_arg.m4])
|
||||
m4_include([m4/netsnmp_search_libs.m4])
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,345 +0,0 @@
|
||||
#
|
||||
# Makefile for snmpd
|
||||
#
|
||||
|
||||
top_builddir = ..
|
||||
mysubdir=agent
|
||||
|
||||
# use GNU vpath, if available, to only set a path for source and headers
|
||||
# VPATH will pick up objects too, which is bad if you are sharing a
|
||||
# source dir...
|
||||
@GNU_vpath@ %.h $(srcdir)
|
||||
@GNU_vpath@ %.c $(srcdir)
|
||||
# fallback to regular VPATH for non-gnu...
|
||||
@NON_GNU_VPATH@ $(srcdir)
|
||||
|
||||
#
|
||||
# what to install
|
||||
#
|
||||
SUBDIRS=helpers mibgroup
|
||||
FTSUBDIRS=mibgroup helpers
|
||||
|
||||
INSTALLSBINPROGS= @SNMPD@
|
||||
INSTALLLIBS = libnetsnmpagent.$(LIB_EXTENSION)$(LIB_VERSION)
|
||||
INSTALLPOSTLIBS = libnetsnmpmibs.$(LIB_EXTENSION)$(LIB_VERSION)
|
||||
|
||||
INCLUDESUBDIR=agent
|
||||
HEADERS=\
|
||||
agent_read_config.h \
|
||||
agent_registry.h \
|
||||
agent_index.h \
|
||||
agent_sysORTable.h \
|
||||
agent_trap.h \
|
||||
auto_nlist.h \
|
||||
ds_agent.h \
|
||||
snmp_agent.h \
|
||||
snmp_vars.h \
|
||||
var_struct.h \
|
||||
agent_handler.h \
|
||||
net-snmp-agent-includes.h \
|
||||
mib_modules.h \
|
||||
agent_callbacks.h \
|
||||
sysORTable.h \
|
||||
all_helpers.h \
|
||||
baby_steps.h \
|
||||
bulk_to_next.h \
|
||||
cache_handler.h \
|
||||
debug_handler.h \
|
||||
instance.h \
|
||||
mode_end_call.h \
|
||||
multiplexer.h \
|
||||
null.h \
|
||||
old_api.h \
|
||||
read_only.h \
|
||||
row_merge.h \
|
||||
scalar.h \
|
||||
scalar_group.h \
|
||||
serialize.h \
|
||||
snmp_get_statistic.h \
|
||||
stash_cache.h \
|
||||
stash_to_next.h \
|
||||
table_array.h \
|
||||
table_container.h \
|
||||
table.h \
|
||||
table_data.h \
|
||||
table_dataset.h \
|
||||
table_tdata.h \
|
||||
table_iterator.h \
|
||||
watcher.h
|
||||
|
||||
HEADERSONLY=mfd.h set_helper.h
|
||||
|
||||
INCLUDESUBDIRHEADERS=$(HEADERS) $(HEADERSONLY)
|
||||
|
||||
INSTALLBUILTSUBDIRHEADERS=../include/net-snmp/agent/mib_module_config.h \
|
||||
../include/net-snmp/agent/agent_module_config.h \
|
||||
mibgroup/mib_module_includes.h
|
||||
INSTALLBUILTSUBDIR=agent
|
||||
|
||||
INCLUDEMIBGROUPDIR=agent/mibgroup
|
||||
INCLUDEMIBGROUPDIRHEADERS=struct.h util_funcs.h util_funcs/header_generic.h \
|
||||
util_funcs/header_simple_table.h util_funcs/MIB_STATS_CACHE_TIMEOUT.h
|
||||
|
||||
OTHERINSTALL=installmibgroupheaders @EMBEDPERLINSTALL@
|
||||
OTHERUNINSTALL=@EMBEDPERLUNINSTALL@
|
||||
|
||||
# XXX: need to install these They're really UCD specific, however.
|
||||
BROKEINSTALL= \
|
||||
mibgroup/struct.h \
|
||||
mibgroup/util_funcs.h \
|
||||
mibgroup/mibincl.h \
|
||||
mibgroup/ucd-snmp/dlmod.h \
|
||||
mibgroup/utilities/execute.h \
|
||||
mibgroup/header_complex.h
|
||||
|
||||
INSTALLUCDHEADERS= \
|
||||
agent_index.h \
|
||||
agent_read_config.h \
|
||||
agent_registry.h \
|
||||
agent_sysORTable.h \
|
||||
agent_trap.h \
|
||||
auto_nlist.h \
|
||||
ds_agent.h \
|
||||
header_complex.h \
|
||||
mibincl.h \
|
||||
snmp_agent.h \
|
||||
ucd-snmp-includes.h \
|
||||
ucd-snmp-agent-includes.h \
|
||||
util_funcs.h \
|
||||
var_struct.h
|
||||
|
||||
#
|
||||
# how to build it info
|
||||
#
|
||||
USELIBS = ../snmplib/libnetsnmp.$(LIB_EXTENSION)$(LIB_VERSION)
|
||||
AGENTLIB = libnetsnmpagent.$(LIB_EXTENSION)$(LIB_VERSION)
|
||||
MIBLIB = libnetsnmpmibs.$(LIB_EXTENSION)$(LIB_VERSION)
|
||||
|
||||
LAGENTLIBS = @LAGENTLIBS@
|
||||
LMIBLIBS = @LMIBLIBS@
|
||||
VAL_LIBS = @VAL_LIBS@
|
||||
PERLLDOPTS_FOR_APPS = @PERLLDOPTS_FOR_APPS@
|
||||
PERLLDOPTS_FOR_LIBS = @PERLLDOPTS_FOR_LIBS@
|
||||
LIBS = $(USELIBS) @AGENTLIBS@ $(PERLLDOPTS_FOR_APPS) $(VAL_LIBS)
|
||||
OUR_AGENT_LIBS = $(AGENTLIB) $(MIBLIB) $(LIBS) @DLLIBS@
|
||||
CPPFLAGS = $(TOP_INCLUDES) -I. $(AGENT_INCLUDES) $(MIBGROUP_INCLUDES) \
|
||||
$(SNMPLIB_INCLUDES) @CPPFLAGS@
|
||||
|
||||
|
||||
#
|
||||
# Objects
|
||||
#
|
||||
|
||||
# libnetsnmpmibs objects.
|
||||
@mibgroup_list_lo@
|
||||
@mibgroup_list_ft@
|
||||
@mibgroup_list_o@
|
||||
@agentgroup_list_lo@
|
||||
@agentgroup_list_ft@
|
||||
@agentgroup_list_o@
|
||||
FTMIBOBJS = $(mibgroup_list_ft) mib_modules.ft auto_nlist.ft
|
||||
LMIBOBJS = $(mibgroup_list_lo) mib_modules.lo auto_nlist.lo
|
||||
MIBOBJS = $(mibgroup_list_o) mib_modules.o auto_nlist.o
|
||||
|
||||
# libnetsnmpagent objects
|
||||
LIBAGENTOBJS= \
|
||||
helpers/all_helpers.o \
|
||||
helpers/baby_steps.o \
|
||||
helpers/bulk_to_next.o \
|
||||
helpers/cache_handler.o \
|
||||
helpers/debug_handler.o \
|
||||
helpers/instance.o \
|
||||
helpers/mode_end_call.o \
|
||||
helpers/multiplexer.o \
|
||||
helpers/null.o \
|
||||
helpers/old_api.o \
|
||||
helpers/read_only.o \
|
||||
helpers/row_merge.o \
|
||||
helpers/scalar.o \
|
||||
helpers/scalar_group.o \
|
||||
helpers/serialize.o \
|
||||
helpers/snmp_get_statistic.o \
|
||||
helpers/stash_cache.o \
|
||||
helpers/stash_to_next.o \
|
||||
helpers/table.o \
|
||||
helpers/table_array.o \
|
||||
helpers/table_container.o \
|
||||
helpers/table_data.o \
|
||||
helpers/table_dataset.o \
|
||||
helpers/table_iterator.o \
|
||||
helpers/table_row.o \
|
||||
helpers/table_tdata.o \
|
||||
helpers/watcher.o \
|
||||
agent_handler.o \
|
||||
agent_index.o \
|
||||
agent_read_config.o \
|
||||
agent_registry.o \
|
||||
agent_sysORTable.o \
|
||||
agent_trap.o \
|
||||
kernel.o \
|
||||
snmp_agent.o \
|
||||
snmp_vars.o \
|
||||
$(agentgroup_list_o) \
|
||||
@OTHERAGENTLIBOBJS@
|
||||
|
||||
LLIBAGENTOBJS= \
|
||||
helpers/all_helpers.lo \
|
||||
helpers/baby_steps.lo \
|
||||
helpers/bulk_to_next.lo \
|
||||
helpers/cache_handler.lo \
|
||||
helpers/debug_handler.lo \
|
||||
helpers/instance.lo \
|
||||
helpers/mode_end_call.lo \
|
||||
helpers/multiplexer.lo \
|
||||
helpers/null.lo \
|
||||
helpers/old_api.lo \
|
||||
helpers/read_only.lo \
|
||||
helpers/row_merge.lo \
|
||||
helpers/scalar.lo \
|
||||
helpers/scalar_group.lo \
|
||||
helpers/serialize.lo \
|
||||
helpers/snmp_get_statistic.lo \
|
||||
helpers/stash_cache.lo \
|
||||
helpers/stash_to_next.lo \
|
||||
helpers/table.lo \
|
||||
helpers/table_array.lo \
|
||||
helpers/table_container.lo \
|
||||
helpers/table_data.lo \
|
||||
helpers/table_dataset.lo \
|
||||
helpers/table_iterator.lo \
|
||||
helpers/table_row.lo \
|
||||
helpers/table_tdata.lo \
|
||||
helpers/watcher.lo \
|
||||
agent_handler.lo \
|
||||
agent_index.lo \
|
||||
agent_read_config.lo \
|
||||
agent_registry.lo \
|
||||
agent_sysORTable.lo \
|
||||
agent_trap.lo \
|
||||
kernel.lo \
|
||||
snmp_agent.lo \
|
||||
snmp_vars.lo \
|
||||
$(agentgroup_list_lo) \
|
||||
@OTHERAGENTLIBLOBJS@
|
||||
|
||||
LLIBAGENTFTS= \
|
||||
helpers/all_helpers.ft \
|
||||
helpers/baby_steps.ft \
|
||||
helpers/bulk_to_next.ft \
|
||||
helpers/cache_handler.ft \
|
||||
helpers/debug_handler.ft \
|
||||
helpers/instance.ft \
|
||||
helpers/mode_end_call.ft \
|
||||
helpers/multiplexer.ft \
|
||||
helpers/null.ft \
|
||||
helpers/old_api.ft \
|
||||
helpers/read_only.ft \
|
||||
helpers/row_merge.ft \
|
||||
helpers/scalar.ft \
|
||||
helpers/scalar_group.ft \
|
||||
helpers/serialize.ft \
|
||||
helpers/snmp_get_statistic.ft \
|
||||
helpers/stash_cache.ft \
|
||||
helpers/stash_to_next.ft \
|
||||
helpers/table.ft \
|
||||
helpers/table_array.ft \
|
||||
helpers/table_container.ft \
|
||||
helpers/table_data.ft \
|
||||
helpers/table_dataset.ft \
|
||||
helpers/table_iterator.ft \
|
||||
helpers/table_row.ft \
|
||||
helpers/table_tdata.ft \
|
||||
helpers/watcher.ft \
|
||||
agent_handler.ft \
|
||||
agent_index.ft \
|
||||
agent_read_config.ft \
|
||||
agent_registry.ft \
|
||||
agent_sysORTable.ft \
|
||||
agent_trap.ft \
|
||||
kernel.ft \
|
||||
snmp_agent.ft \
|
||||
snmp_vars.ft \
|
||||
$(agentgroup_list_ft) \
|
||||
@OTHERAGENTLIBLFTS@
|
||||
|
||||
# The agent objects.
|
||||
AGENTOBJS=snmpd.o @other_agentobjs@
|
||||
LAGENTOBJS=snmpd.lo @other_lagentobjs@
|
||||
FTAGENTOBJS=snmpd.ft @other_ftagentobjs@
|
||||
|
||||
#
|
||||
# Define OBJS and LOBJS for clean target (just this directory)
|
||||
#
|
||||
OBJS = $(LIBAGENTOBJS) $(AGENTOBJS) mib_modules.o auto_nlist.o
|
||||
LOBJS = $(LLIBAGENTOBJS) $(LAGENTOBJS) mib_modules.lo auto_nlist.lo
|
||||
FTOBJS = $(LLIBAGENTFTS) $(FTAGENTOBJS) mib_modules.ft auto_nlist.ft
|
||||
|
||||
FEATUREFILE = $(top_builddir)/include/net-snmp/agent/features.h
|
||||
|
||||
all: agentlib subdirs miblib $(INSTALLBINPROGS) $(INSTALLSBINPROGS)
|
||||
|
||||
#
|
||||
# build stuff targets
|
||||
#
|
||||
getkstat: getkstat.o
|
||||
$(CC) $(CFLAGS) -o $@ $? $(LIBS)
|
||||
|
||||
getkstat.o: mibgroup/kernel_sunos5.c
|
||||
$(CC) $(CFLAGS) -o $@ -D_GETKSTAT_TEST -DDODEBUG -c $?
|
||||
|
||||
getmibstat: getmibstat.o
|
||||
$(CC) $(CFLAGS) -o $@ $? $(LIBS)
|
||||
|
||||
getmibstat.o: mibgroup/kernel_sunos5.c
|
||||
$(CC) $(CFLAGS) -o $@ -D_GETMIBSTAT_TEST -DDODEBUG -c $?
|
||||
|
||||
snmpd$(EXEEXT): ${LAGENTOBJS} $(USELIBS) $(AGENTLIB) $(HELPERLIB) $(MIBLIB) $(LIBTARG)
|
||||
$(LINK) $(CFLAGS) -o $@ ${LAGENTOBJS} ${LDFLAGS} ${OUR_AGENT_LIBS}
|
||||
|
||||
libnetsnmpagent.$(LIB_EXTENSION)$(LIB_VERSION): ${LLIBAGENTOBJS} $(USELIBS)
|
||||
$(LIB_LD_CMD) $(AGENTLIB) ${LLIBAGENTOBJS} $(USELIBS) ${LAGENTLIBS} @LD_NO_UNDEFINED@ $(LDFLAGS) $(PERLLDOPTS_FOR_LIBS) $(LIB_LD_LIBS) @AGENTLIBS@
|
||||
$(RANLIB) $(AGENTLIB)
|
||||
|
||||
libnetsnmpmibs.$(LIB_EXTENSION)$(LIB_VERSION): ${LMIBOBJS} $(AGENTLIB) $(USELIBS)
|
||||
$(LIB_LD_CMD) $(MIBLIB) ${LMIBOBJS} $(AGENTLIB) $(USELIBS) @LD_NO_UNDEFINED@ $(LDFLAGS) ${LMIBLIBS} $(PERLLDOPTS_FOR_LIBS) $(LIB_LD_LIBS) @AGENTLIBS@
|
||||
$(RANLIB) $(MIBLIB)
|
||||
|
||||
agentlib: $(AGENTLIB)
|
||||
|
||||
miblib: $(MIBLIB)
|
||||
|
||||
libs: $(AGENTLIB) $(MIBLIB)
|
||||
|
||||
embedperlinstall:
|
||||
@$(SHELL) $(srcdir)/../mkinstalldirs $(INSTALL_PREFIX)$(snmplibdir)
|
||||
@$(INSTALL_DATA) $(srcdir)/snmp_perl.pl $(INSTALL_PREFIX)$(snmplibdir)/snmp_perl.pl
|
||||
@echo "install: installed snmp_perl.pl in $(INSTALL_PREFIX)$(snmplibdir)"
|
||||
|
||||
embedperluninstall:
|
||||
@rm -f $(INSTALL_PREFIX)$(snmplibdir)/snmp_perl.pl
|
||||
@echo "removed snmp_perl.pl from $(INSTALL_PREFIX)$(snmplibdir)"
|
||||
|
||||
installmibgroupheaders:
|
||||
@for it in $(INCLUDEMIBGROUPDIRHEADERS) ; do \
|
||||
itd=`dirname "$(INSTALL_PREFIX)$(includedir)/agent/$$it"` ; \
|
||||
if [ ! -d "$$itd" ] ; then \
|
||||
echo "creating directory $$itd" ; \
|
||||
$(SHELL) "$(top_srcdir)/mkinstalldirs" "$$itd" ; \
|
||||
fi ; \
|
||||
$(INSTALL_DATA) "$(top_srcdir)/$(INCLUDEMIBGROUPDIR)/$$it" \
|
||||
"$$itd" ; \
|
||||
echo "installing $$it in $$itd" ; \
|
||||
done
|
||||
|
||||
@module_list_deps@
|
||||
@agent_module_list_deps@
|
||||
@mib_module_list_deps@
|
||||
|
||||
mib_modules.lo: mibgroup/mib_module_inits.h
|
||||
#
|
||||
# dependency for snmplib object. it's here because the headers listed
|
||||
# are relative to the agent directory.
|
||||
|
||||
subdirs: agentlib
|
||||
# wait for agentlib before building 'subdirs' target
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,892 +0,0 @@
|
||||
/*
|
||||
* agent_index.c
|
||||
*
|
||||
* Maintain a registry of index allocations
|
||||
* (Primarily required for AgentX support,
|
||||
* but it could be more widely useable).
|
||||
*/
|
||||
|
||||
|
||||
#include <net-snmp/net-snmp-config.h>
|
||||
#include <net-snmp/net-snmp-features.h>
|
||||
#include <signal.h>
|
||||
#if HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
#if HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#if TIME_WITH_SYS_TIME
|
||||
# include <sys/time.h>
|
||||
# include <time.h>
|
||||
#else
|
||||
# if HAVE_SYS_TIME_H
|
||||
# include <sys/time.h>
|
||||
# else
|
||||
# include <time.h>
|
||||
# endif
|
||||
#endif
|
||||
#if HAVE_NETINET_IN_H
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
|
||||
#include <net-snmp/net-snmp-includes.h>
|
||||
#include <net-snmp/agent/net-snmp-agent-includes.h>
|
||||
#include <net-snmp/agent/agent_callbacks.h>
|
||||
#include <net-snmp/agent/agent_index.h>
|
||||
|
||||
#include "snmpd.h"
|
||||
#include "mibgroup/struct.h"
|
||||
#include <net-snmp/agent/table.h>
|
||||
#include <net-snmp/agent/table_iterator.h>
|
||||
|
||||
#ifdef USING_AGENTX_SUBAGENT_MODULE
|
||||
#include "agentx/subagent.h"
|
||||
#include "agentx/client.h"
|
||||
#endif
|
||||
|
||||
netsnmp_feature_child_of(agent_index_all, libnetsnmpagent)
|
||||
|
||||
netsnmp_feature_child_of(remove_index, agent_index_all)
|
||||
|
||||
/*
|
||||
* Initial support for index allocation
|
||||
*/
|
||||
|
||||
struct snmp_index {
|
||||
netsnmp_variable_list *varbind; /* or pointer to var_list ? */
|
||||
int allocated;
|
||||
netsnmp_session *session;
|
||||
struct snmp_index *next_oid;
|
||||
struct snmp_index *prev_oid;
|
||||
struct snmp_index *next_idx;
|
||||
} *snmp_index_head = NULL;
|
||||
|
||||
extern netsnmp_session *main_session;
|
||||
|
||||
/*
|
||||
* The caller is responsible for free()ing the memory returned by
|
||||
* this function.
|
||||
*/
|
||||
|
||||
char *
|
||||
register_string_index(oid * name, size_t name_len, char *cp)
|
||||
{
|
||||
netsnmp_variable_list varbind, *res;
|
||||
|
||||
memset(&varbind, 0, sizeof(netsnmp_variable_list));
|
||||
varbind.type = ASN_OCTET_STR;
|
||||
snmp_set_var_objid(&varbind, name, name_len);
|
||||
if (cp != ANY_STRING_INDEX) {
|
||||
snmp_set_var_value(&varbind, (u_char *) cp, strlen(cp));
|
||||
res = register_index(&varbind, ALLOCATE_THIS_INDEX, main_session);
|
||||
} else {
|
||||
res = register_index(&varbind, ALLOCATE_ANY_INDEX, main_session);
|
||||
}
|
||||
|
||||
if (res == NULL) {
|
||||
return NULL;
|
||||
} else {
|
||||
char *rv = (char *)malloc(res->val_len + 1);
|
||||
if (rv) {
|
||||
memcpy(rv, res->val.string, res->val_len);
|
||||
rv[res->val_len] = 0;
|
||||
}
|
||||
free(res);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
register_int_index(oid * name, size_t name_len, int val)
|
||||
{
|
||||
netsnmp_variable_list varbind, *res;
|
||||
|
||||
memset(&varbind, 0, sizeof(netsnmp_variable_list));
|
||||
varbind.type = ASN_INTEGER;
|
||||
snmp_set_var_objid(&varbind, name, name_len);
|
||||
varbind.val.string = varbind.buf;
|
||||
if (val != ANY_INTEGER_INDEX) {
|
||||
varbind.val_len = sizeof(long);
|
||||
*varbind.val.integer = val;
|
||||
res = register_index(&varbind, ALLOCATE_THIS_INDEX, main_session);
|
||||
} else {
|
||||
res = register_index(&varbind, ALLOCATE_ANY_INDEX, main_session);
|
||||
}
|
||||
|
||||
if (res == NULL) {
|
||||
return -1;
|
||||
} else {
|
||||
int rv = *(res->val.integer);
|
||||
free(res);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* The caller is responsible for free()ing the memory returned by
|
||||
* this function.
|
||||
*/
|
||||
|
||||
netsnmp_variable_list *
|
||||
register_oid_index(oid * name, size_t name_len,
|
||||
oid * value, size_t value_len)
|
||||
{
|
||||
netsnmp_variable_list varbind;
|
||||
|
||||
memset(&varbind, 0, sizeof(netsnmp_variable_list));
|
||||
varbind.type = ASN_OBJECT_ID;
|
||||
snmp_set_var_objid(&varbind, name, name_len);
|
||||
if (value != ANY_OID_INDEX) {
|
||||
snmp_set_var_value(&varbind, (u_char *) value,
|
||||
value_len * sizeof(oid));
|
||||
return register_index(&varbind, ALLOCATE_THIS_INDEX, main_session);
|
||||
} else {
|
||||
return register_index(&varbind, ALLOCATE_ANY_INDEX, main_session);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* The caller is responsible for free()ing the memory returned by
|
||||
* this function.
|
||||
*/
|
||||
|
||||
netsnmp_variable_list *
|
||||
register_index(netsnmp_variable_list * varbind, int flags,
|
||||
netsnmp_session * ss)
|
||||
{
|
||||
netsnmp_variable_list *rv = NULL;
|
||||
struct snmp_index *new_index, *idxptr, *idxptr2;
|
||||
struct snmp_index *prev_oid_ptr, *prev_idx_ptr;
|
||||
int res, res2, i;
|
||||
|
||||
DEBUGMSGTL(("register_index", "register "));
|
||||
DEBUGMSGVAR(("register_index", varbind));
|
||||
DEBUGMSG(("register_index", "for session %8p\n", ss));
|
||||
|
||||
#if defined(USING_AGENTX_SUBAGENT_MODULE) && !defined(TESTING)
|
||||
if (netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
|
||||
NETSNMP_DS_AGENT_ROLE) == SUB_AGENT) {
|
||||
return (agentx_register_index(ss, varbind, flags));
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
* Look for the requested OID entry
|
||||
*/
|
||||
prev_oid_ptr = NULL;
|
||||
prev_idx_ptr = NULL;
|
||||
res = 1;
|
||||
res2 = 1;
|
||||
for (idxptr = snmp_index_head; idxptr != NULL;
|
||||
prev_oid_ptr = idxptr, idxptr = idxptr->next_oid) {
|
||||
if ((res = snmp_oid_compare(varbind->name, varbind->name_length,
|
||||
idxptr->varbind->name,
|
||||
idxptr->varbind->name_length)) <= 0)
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Found the OID - now look at the registered indices
|
||||
*/
|
||||
if (res == 0 && idxptr) {
|
||||
if (varbind->type != idxptr->varbind->type)
|
||||
return NULL; /* wrong type */
|
||||
|
||||
/*
|
||||
* If we've been asked for an arbitrary new value,
|
||||
* then find the end of the list.
|
||||
* If we've been asked for any arbitrary value,
|
||||
* then look for an unused entry, and use that.
|
||||
* If there aren't any, continue as for new.
|
||||
* Otherwise, locate the given value in the (sorted)
|
||||
* list of already allocated values
|
||||
*/
|
||||
if (flags & ALLOCATE_ANY_INDEX) {
|
||||
for (idxptr2 = idxptr; idxptr2 != NULL;
|
||||
prev_idx_ptr = idxptr2, idxptr2 = idxptr2->next_idx) {
|
||||
|
||||
if (flags == ALLOCATE_ANY_INDEX && !(idxptr2->allocated)) {
|
||||
if ((rv =
|
||||
snmp_clone_varbind(idxptr2->varbind)) != NULL) {
|
||||
idxptr2->session = ss;
|
||||
idxptr2->allocated = 1;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (idxptr2 = idxptr; idxptr2 != NULL;
|
||||
prev_idx_ptr = idxptr2, idxptr2 = idxptr2->next_idx) {
|
||||
switch (varbind->type) {
|
||||
case ASN_INTEGER:
|
||||
res2 =
|
||||
(*varbind->val.integer -
|
||||
*idxptr2->varbind->val.integer);
|
||||
break;
|
||||
case ASN_OCTET_STR:
|
||||
i = SNMP_MIN(varbind->val_len,
|
||||
idxptr2->varbind->val_len);
|
||||
res2 =
|
||||
memcmp(varbind->val.string,
|
||||
idxptr2->varbind->val.string, i);
|
||||
break;
|
||||
case ASN_OBJECT_ID:
|
||||
res2 =
|
||||
snmp_oid_compare(varbind->val.objid,
|
||||
varbind->val_len / sizeof(oid),
|
||||
idxptr2->varbind->val.objid,
|
||||
idxptr2->varbind->val_len /
|
||||
sizeof(oid));
|
||||
break;
|
||||
default:
|
||||
return NULL; /* wrong type */
|
||||
}
|
||||
if (res2 <= 0)
|
||||
break;
|
||||
}
|
||||
if (res2 == 0) {
|
||||
if (idxptr2->allocated) {
|
||||
/*
|
||||
* No good: the index is in use.
|
||||
*/
|
||||
return NULL;
|
||||
} else {
|
||||
/*
|
||||
* Okay, it's unallocated, we can just claim ownership
|
||||
* here.
|
||||
*/
|
||||
if ((rv =
|
||||
snmp_clone_varbind(idxptr2->varbind)) != NULL) {
|
||||
idxptr2->session = ss;
|
||||
idxptr2->allocated = 1;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* OK - we've now located where the new entry needs to
|
||||
* be fitted into the index registry tree
|
||||
* To recap:
|
||||
* 'prev_oid_ptr' points to the head of the OID index
|
||||
* list prior to this one. If this is null, then
|
||||
* it means that this is the first OID in the list.
|
||||
* 'idxptr' points either to the head of this OID list,
|
||||
* or the next OID (if this is a new OID request)
|
||||
* These can be distinguished by the value of 'res'.
|
||||
*
|
||||
* 'prev_idx_ptr' points to the index entry that sorts
|
||||
* immediately prior to the requested value (if any).
|
||||
* If an arbitrary value is required, then this will
|
||||
* point to the last allocated index.
|
||||
* If this pointer is null, then either this is a new
|
||||
* OID request, or the requested value is the first
|
||||
* in the list.
|
||||
* 'idxptr2' points to the next sorted index (if any)
|
||||
* but is not actually needed any more.
|
||||
*
|
||||
* Clear? Good!
|
||||
* I hope you've been paying attention.
|
||||
* There'll be a test later :-)
|
||||
*/
|
||||
|
||||
/*
|
||||
* We proceed by creating the new entry
|
||||
* (by copying the entry provided)
|
||||
*/
|
||||
new_index = (struct snmp_index *) calloc(1, sizeof(struct snmp_index));
|
||||
if (new_index == NULL)
|
||||
return NULL;
|
||||
|
||||
if (NULL == snmp_varlist_add_variable(&new_index->varbind,
|
||||
varbind->name,
|
||||
varbind->name_length,
|
||||
varbind->type,
|
||||
varbind->val.string,
|
||||
varbind->val_len)) {
|
||||
/*
|
||||
* if (snmp_clone_var( varbind, new_index->varbind ) != 0 )
|
||||
*/
|
||||
free(new_index);
|
||||
return NULL;
|
||||
}
|
||||
new_index->session = ss;
|
||||
new_index->allocated = 1;
|
||||
|
||||
if (varbind->type == ASN_OCTET_STR && flags == ALLOCATE_THIS_INDEX)
|
||||
new_index->varbind->val.string[new_index->varbind->val_len] = 0;
|
||||
|
||||
/*
|
||||
* If we've been given a value, then we can use that, but
|
||||
* otherwise, we need to create a new value for this entry.
|
||||
* Note that ANY_INDEX and NEW_INDEX are both covered by this
|
||||
* test (since NEW_INDEX & ANY_INDEX = ANY_INDEX, remember?)
|
||||
*/
|
||||
if (flags & ALLOCATE_ANY_INDEX) {
|
||||
if (prev_idx_ptr) {
|
||||
if (snmp_clone_var(prev_idx_ptr->varbind, new_index->varbind)
|
||||
!= 0) {
|
||||
free(new_index);
|
||||
return NULL;
|
||||
}
|
||||
} else
|
||||
new_index->varbind->val.string = new_index->varbind->buf;
|
||||
|
||||
switch (varbind->type) {
|
||||
case ASN_INTEGER:
|
||||
if (prev_idx_ptr) {
|
||||
(*new_index->varbind->val.integer)++;
|
||||
} else
|
||||
*(new_index->varbind->val.integer) = 1;
|
||||
new_index->varbind->val_len = sizeof(long);
|
||||
break;
|
||||
case ASN_OCTET_STR:
|
||||
if (prev_idx_ptr) {
|
||||
i = new_index->varbind->val_len - 1;
|
||||
while (new_index->varbind->buf[i] == 'z') {
|
||||
new_index->varbind->buf[i] = 'a';
|
||||
i--;
|
||||
if (i < 0) {
|
||||
i = new_index->varbind->val_len;
|
||||
new_index->varbind->buf[i] = 'a';
|
||||
new_index->varbind->buf[i + 1] = 0;
|
||||
}
|
||||
}
|
||||
new_index->varbind->buf[i]++;
|
||||
} else
|
||||
strcpy((char *) new_index->varbind->buf, "aaaa");
|
||||
new_index->varbind->val_len =
|
||||
strlen((char *) new_index->varbind->buf);
|
||||
break;
|
||||
case ASN_OBJECT_ID:
|
||||
if (prev_idx_ptr) {
|
||||
i = prev_idx_ptr->varbind->val_len / sizeof(oid) - 1;
|
||||
while (new_index->varbind->val.objid[i] == 255) {
|
||||
new_index->varbind->val.objid[i] = 1;
|
||||
i--;
|
||||
if (i == 0 && new_index->varbind->val.objid[0] == 2) {
|
||||
new_index->varbind->val.objid[0] = 1;
|
||||
i = new_index->varbind->val_len / sizeof(oid);
|
||||
new_index->varbind->val.objid[i] = 0;
|
||||
new_index->varbind->val_len += sizeof(oid);
|
||||
}
|
||||
}
|
||||
new_index->varbind->val.objid[i]++;
|
||||
} else {
|
||||
/*
|
||||
* If the requested OID name is small enough,
|
||||
* * append another OID (1) and use this as the
|
||||
* * default starting value for new indexes.
|
||||
*/
|
||||
if ((varbind->name_length + 1) * sizeof(oid) <= 40) {
|
||||
for (i = 0; i < (int) varbind->name_length; i++)
|
||||
new_index->varbind->val.objid[i] =
|
||||
varbind->name[i];
|
||||
new_index->varbind->val.objid[varbind->name_length] =
|
||||
1;
|
||||
new_index->varbind->val_len =
|
||||
(varbind->name_length + 1) * sizeof(oid);
|
||||
} else {
|
||||
/*
|
||||
* Otherwise use '.1.1.1.1...'
|
||||
*/
|
||||
i = 40 / sizeof(oid);
|
||||
if (i > 4)
|
||||
i = 4;
|
||||
new_index->varbind->val_len = i * (sizeof(oid));
|
||||
for (i--; i >= 0; i--)
|
||||
new_index->varbind->val.objid[i] = 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
snmp_free_var(new_index->varbind);
|
||||
free(new_index);
|
||||
return NULL; /* Index type not supported */
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Try to duplicate the new varbind for return.
|
||||
*/
|
||||
|
||||
if ((rv = snmp_clone_varbind(new_index->varbind)) == NULL) {
|
||||
snmp_free_var(new_index->varbind);
|
||||
free(new_index);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Right - we've set up the new entry.
|
||||
* All that remains is to link it into the tree.
|
||||
* There are a number of possible cases here,
|
||||
* so watch carefully.
|
||||
*/
|
||||
if (prev_idx_ptr) {
|
||||
new_index->next_idx = prev_idx_ptr->next_idx;
|
||||
new_index->next_oid = prev_idx_ptr->next_oid;
|
||||
prev_idx_ptr->next_idx = new_index;
|
||||
} else {
|
||||
if (res == 0 && idxptr) {
|
||||
new_index->next_idx = idxptr;
|
||||
new_index->next_oid = idxptr->next_oid;
|
||||
} else {
|
||||
new_index->next_idx = NULL;
|
||||
new_index->next_oid = idxptr;
|
||||
}
|
||||
|
||||
if (prev_oid_ptr) {
|
||||
while (prev_oid_ptr) {
|
||||
prev_oid_ptr->next_oid = new_index;
|
||||
prev_oid_ptr = prev_oid_ptr->next_idx;
|
||||
}
|
||||
} else
|
||||
snmp_index_head = new_index;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*
|
||||
* Release an allocated index,
|
||||
* to allow it to be used elsewhere
|
||||
*/
|
||||
netsnmp_feature_child_of(release_index,netsnmp_unused)
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_RELEASE_INDEX
|
||||
int
|
||||
release_index(netsnmp_variable_list * varbind)
|
||||
{
|
||||
return (unregister_index(varbind, TRUE, NULL));
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_RELEASE_INDEX */
|
||||
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_REMOVE_INDEX
|
||||
/*
|
||||
* Completely remove an allocated index,
|
||||
* due to errors in the registration process.
|
||||
*/
|
||||
int
|
||||
remove_index(netsnmp_variable_list * varbind, netsnmp_session * ss)
|
||||
{
|
||||
return (unregister_index(varbind, FALSE, ss));
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_REMOVE_INDEX */
|
||||
|
||||
void
|
||||
unregister_index_by_session(netsnmp_session * ss)
|
||||
{
|
||||
struct snmp_index *idxptr, *idxptr2;
|
||||
for (idxptr = snmp_index_head; idxptr != NULL;
|
||||
idxptr = idxptr->next_oid)
|
||||
for (idxptr2 = idxptr; idxptr2 != NULL;
|
||||
idxptr2 = idxptr2->next_idx)
|
||||
if (idxptr2->session == ss) {
|
||||
idxptr2->allocated = 0;
|
||||
idxptr2->session = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
unregister_index(netsnmp_variable_list * varbind, int remember,
|
||||
netsnmp_session * ss)
|
||||
{
|
||||
struct snmp_index *idxptr, *idxptr2;
|
||||
struct snmp_index *prev_oid_ptr, *prev_idx_ptr;
|
||||
int res, res2, i;
|
||||
|
||||
#if defined(USING_AGENTX_SUBAGENT_MODULE) && !defined(TESTING)
|
||||
if (netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
|
||||
NETSNMP_DS_AGENT_ROLE) == SUB_AGENT) {
|
||||
return (agentx_unregister_index(ss, varbind));
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
* Look for the requested OID entry
|
||||
*/
|
||||
prev_oid_ptr = NULL;
|
||||
prev_idx_ptr = NULL;
|
||||
res = 1;
|
||||
res2 = 1;
|
||||
for (idxptr = snmp_index_head; idxptr != NULL;
|
||||
prev_oid_ptr = idxptr, idxptr = idxptr->next_oid) {
|
||||
if ((res = snmp_oid_compare(varbind->name, varbind->name_length,
|
||||
idxptr->varbind->name,
|
||||
idxptr->varbind->name_length)) <= 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if (res != 0)
|
||||
return INDEX_ERR_NOT_ALLOCATED;
|
||||
if (varbind->type != idxptr->varbind->type)
|
||||
return INDEX_ERR_WRONG_TYPE;
|
||||
|
||||
for (idxptr2 = idxptr; idxptr2 != NULL;
|
||||
prev_idx_ptr = idxptr2, idxptr2 = idxptr2->next_idx) {
|
||||
switch (varbind->type) {
|
||||
case ASN_INTEGER:
|
||||
res2 =
|
||||
(*varbind->val.integer -
|
||||
*idxptr2->varbind->val.integer);
|
||||
break;
|
||||
case ASN_OCTET_STR:
|
||||
i = SNMP_MIN(varbind->val_len,
|
||||
idxptr2->varbind->val_len);
|
||||
res2 =
|
||||
memcmp(varbind->val.string,
|
||||
idxptr2->varbind->val.string, i);
|
||||
break;
|
||||
case ASN_OBJECT_ID:
|
||||
res2 =
|
||||
snmp_oid_compare(varbind->val.objid,
|
||||
varbind->val_len / sizeof(oid),
|
||||
idxptr2->varbind->val.objid,
|
||||
idxptr2->varbind->val_len /
|
||||
sizeof(oid));
|
||||
break;
|
||||
default:
|
||||
return INDEX_ERR_WRONG_TYPE; /* wrong type */
|
||||
}
|
||||
if (res2 <= 0)
|
||||
break;
|
||||
}
|
||||
if (res2 != 0 || (res2 == 0 && !idxptr2->allocated)) {
|
||||
return INDEX_ERR_NOT_ALLOCATED;
|
||||
}
|
||||
if (ss != idxptr2->session)
|
||||
return INDEX_ERR_WRONG_SESSION;
|
||||
|
||||
/*
|
||||
* If this is a "normal" index unregistration,
|
||||
* mark the index entry as unused, but leave
|
||||
* it in situ. This allows differentiation
|
||||
* between ANY_INDEX and NEW_INDEX
|
||||
*/
|
||||
if (remember) {
|
||||
idxptr2->allocated = 0; /* Unused index */
|
||||
idxptr2->session = NULL;
|
||||
return SNMP_ERR_NOERROR;
|
||||
}
|
||||
/*
|
||||
* If this is a failed attempt to register a
|
||||
* number of indexes, the successful ones
|
||||
* must be removed completely.
|
||||
*/
|
||||
if (prev_idx_ptr) {
|
||||
prev_idx_ptr->next_idx = idxptr2->next_idx;
|
||||
} else if (prev_oid_ptr) {
|
||||
if (idxptr2->next_idx) /* Use p_idx_ptr as a temp variable */
|
||||
prev_idx_ptr = idxptr2->next_idx;
|
||||
else
|
||||
prev_idx_ptr = idxptr2->next_oid;
|
||||
while (prev_oid_ptr) {
|
||||
prev_oid_ptr->next_oid = prev_idx_ptr;
|
||||
prev_oid_ptr = prev_oid_ptr->next_idx;
|
||||
}
|
||||
} else {
|
||||
if (idxptr2->next_idx)
|
||||
snmp_index_head = idxptr2->next_idx;
|
||||
else
|
||||
snmp_index_head = idxptr2->next_oid;
|
||||
}
|
||||
snmp_free_var(idxptr2->varbind);
|
||||
free(idxptr2);
|
||||
return SNMP_ERR_NOERROR;
|
||||
}
|
||||
|
||||
netsnmp_feature_child_of(unregister_indexes,netsnmp_unused)
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_UNREGISTER_INDEXES
|
||||
int
|
||||
unregister_string_index(oid * name, size_t name_len, char *cp)
|
||||
{
|
||||
netsnmp_variable_list varbind;
|
||||
|
||||
memset(&varbind, 0, sizeof(netsnmp_variable_list));
|
||||
varbind.type = ASN_OCTET_STR;
|
||||
snmp_set_var_objid(&varbind, name, name_len);
|
||||
snmp_set_var_value(&varbind, (u_char *) cp, strlen(cp));
|
||||
return (unregister_index(&varbind, FALSE, main_session));
|
||||
}
|
||||
|
||||
int
|
||||
unregister_int_index(oid * name, size_t name_len, int val)
|
||||
{
|
||||
netsnmp_variable_list varbind;
|
||||
|
||||
memset(&varbind, 0, sizeof(netsnmp_variable_list));
|
||||
varbind.type = ASN_INTEGER;
|
||||
snmp_set_var_objid(&varbind, name, name_len);
|
||||
varbind.val.string = varbind.buf;
|
||||
varbind.val_len = sizeof(long);
|
||||
*varbind.val.integer = val;
|
||||
return (unregister_index(&varbind, FALSE, main_session));
|
||||
}
|
||||
|
||||
int
|
||||
unregister_oid_index(oid * name, size_t name_len,
|
||||
oid * value, size_t value_len)
|
||||
{
|
||||
netsnmp_variable_list varbind;
|
||||
|
||||
memset(&varbind, 0, sizeof(netsnmp_variable_list));
|
||||
varbind.type = ASN_OBJECT_ID;
|
||||
snmp_set_var_objid(&varbind, name, name_len);
|
||||
snmp_set_var_value(&varbind, (u_char *) value,
|
||||
value_len * sizeof(oid));
|
||||
return (unregister_index(&varbind, FALSE, main_session));
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_UNREGISTER_INDEXES */
|
||||
|
||||
void
|
||||
dump_idx_registry(void)
|
||||
{
|
||||
struct snmp_index *idxptr, *idxptr2;
|
||||
u_char *sbuf = NULL, *ebuf = NULL;
|
||||
size_t sbuf_len = 0, sout_len = 0, ebuf_len = 0, eout_len = 0;
|
||||
|
||||
if (snmp_index_head != NULL) {
|
||||
printf("\nIndex Allocations:\n");
|
||||
}
|
||||
|
||||
for (idxptr = snmp_index_head; idxptr != NULL;
|
||||
idxptr = idxptr->next_oid) {
|
||||
sout_len = 0;
|
||||
if (sprint_realloc_objid(&sbuf, &sbuf_len, &sout_len, 1,
|
||||
idxptr->varbind->name,
|
||||
idxptr->varbind->name_length)) {
|
||||
printf("%s indexes:\n", sbuf);
|
||||
} else {
|
||||
printf("%s [TRUNCATED] indexes:\n", sbuf);
|
||||
}
|
||||
|
||||
for (idxptr2 = idxptr; idxptr2 != NULL;
|
||||
idxptr2 = idxptr2->next_idx) {
|
||||
switch (idxptr2->varbind->type) {
|
||||
case ASN_INTEGER:
|
||||
printf(" %ld for session %8p, allocated %d\n",
|
||||
*idxptr2->varbind->val.integer, idxptr2->session,
|
||||
idxptr2->allocated);
|
||||
break;
|
||||
case ASN_OCTET_STR:
|
||||
printf(" \"%s\" for session %8p, allocated %d\n",
|
||||
idxptr2->varbind->val.string, idxptr2->session,
|
||||
idxptr2->allocated);
|
||||
break;
|
||||
case ASN_OBJECT_ID:
|
||||
eout_len = 0;
|
||||
if (sprint_realloc_objid(&ebuf, &ebuf_len, &eout_len, 1,
|
||||
idxptr2->varbind->val.objid,
|
||||
idxptr2->varbind->val_len /
|
||||
sizeof(oid))) {
|
||||
printf(" %s for session %8p, allocated %d\n", ebuf,
|
||||
idxptr2->session, idxptr2->allocated);
|
||||
} else {
|
||||
printf
|
||||
(" %s [TRUNCATED] for sess %8p, allocated %d\n",
|
||||
ebuf, idxptr2->session, idxptr2->allocated);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
printf("unsupported type (%d/0x%02x)\n",
|
||||
idxptr2->varbind->type, idxptr2->varbind->type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sbuf != NULL) {
|
||||
free(sbuf);
|
||||
}
|
||||
if (ebuf != NULL) {
|
||||
free(ebuf);
|
||||
}
|
||||
}
|
||||
|
||||
netsnmp_feature_child_of(count_indexes, netsnmp_unused)
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_UNUSED
|
||||
unsigned long
|
||||
count_indexes(oid * name, size_t namelen, int include_unallocated)
|
||||
{
|
||||
struct snmp_index *i = NULL, *j = NULL;
|
||||
unsigned long n = 0;
|
||||
|
||||
for (i = snmp_index_head; i != NULL; i = i->next_oid) {
|
||||
if (netsnmp_oid_equals(name, namelen,
|
||||
i->varbind->name,
|
||||
i->varbind->name_length) == 0) {
|
||||
for (j = i; j != NULL; j = j->next_idx) {
|
||||
if (j->allocated || include_unallocated) {
|
||||
n++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return n;
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_UNUSED */
|
||||
|
||||
#ifdef TESTING
|
||||
netsnmp_variable_list varbind;
|
||||
netsnmp_session main_sess, *main_session = &main_sess;
|
||||
|
||||
void
|
||||
test_string_register(int n, char *cp)
|
||||
{
|
||||
varbind->name[4] = n;
|
||||
if (register_string_index(varbind->name, varbind.name_length, cp) ==
|
||||
NULL)
|
||||
printf("allocating %s failed\n", cp);
|
||||
}
|
||||
|
||||
void
|
||||
test_int_register(int n, int val)
|
||||
{
|
||||
varbind->name[4] = n;
|
||||
if (register_int_index(varbind->name, varbind.name_length, val) == -1)
|
||||
printf("allocating %d/%d failed\n", n, val);
|
||||
}
|
||||
|
||||
void
|
||||
test_oid_register(int n, int subid)
|
||||
{
|
||||
netsnmp_variable_list *res;
|
||||
|
||||
varbind->name[4] = n;
|
||||
if (subid != -1) {
|
||||
varbind->val.objid[5] = subid;
|
||||
res = register_oid_index(varbind->name, varbind.name_length,
|
||||
varbind->val.objid,
|
||||
varbind->val_len / sizeof(oid));
|
||||
} else
|
||||
res =
|
||||
register_oid_index(varbind->name, varbind.name_length, NULL,
|
||||
0);
|
||||
|
||||
if (res == NULL)
|
||||
printf("allocating %d/%d failed\n", n, subid);
|
||||
}
|
||||
|
||||
void
|
||||
main(int argc, char argv[])
|
||||
{
|
||||
oid name[] = { 1, 2, 3, 4, 0 };
|
||||
int i;
|
||||
|
||||
memset(&varbind, 0, sizeof(netsnmp_variable_list));
|
||||
snmp_set_var_objid(&varbind, name, 5);
|
||||
varbind->type = ASN_OCTET_STR;
|
||||
/*
|
||||
* Test index structure linking:
|
||||
* a) sorted by OID
|
||||
*/
|
||||
test_string_register(20, "empty OID");
|
||||
test_string_register(10, "first OID");
|
||||
test_string_register(40, "last OID");
|
||||
test_string_register(30, "middle OID");
|
||||
|
||||
/*
|
||||
* b) sorted by index value
|
||||
*/
|
||||
test_string_register(25, "eee: empty IDX");
|
||||
test_string_register(25, "aaa: first IDX");
|
||||
test_string_register(25, "zzz: last IDX");
|
||||
test_string_register(25, "mmm: middle IDX");
|
||||
printf("This next one should fail....\n");
|
||||
test_string_register(25, "eee: empty IDX"); /* duplicate */
|
||||
printf("done\n");
|
||||
|
||||
/*
|
||||
* c) test initial index linking
|
||||
*/
|
||||
test_string_register(5, "eee: empty initial IDX");
|
||||
test_string_register(5, "aaa: replace initial IDX");
|
||||
|
||||
/*
|
||||
* Did it all work?
|
||||
*/
|
||||
dump_idx_registry();
|
||||
unregister_index_by_session(main_session);
|
||||
/*
|
||||
* Now test index allocation
|
||||
* a) integer values
|
||||
*/
|
||||
test_int_register(110, -1); /* empty */
|
||||
test_int_register(110, -1); /* append */
|
||||
test_int_register(110, 10); /* append exact */
|
||||
printf("This next one should fail....\n");
|
||||
test_int_register(110, 10); /* exact duplicate */
|
||||
printf("done\n");
|
||||
test_int_register(110, -1); /* append */
|
||||
test_int_register(110, 5); /* insert exact */
|
||||
|
||||
/*
|
||||
* b) string values
|
||||
*/
|
||||
test_string_register(120, NULL); /* empty */
|
||||
test_string_register(120, NULL); /* append */
|
||||
test_string_register(120, "aaaz");
|
||||
test_string_register(120, NULL); /* minor rollover */
|
||||
test_string_register(120, "zzzz");
|
||||
test_string_register(120, NULL); /* major rollover */
|
||||
|
||||
/*
|
||||
* c) OID values
|
||||
*/
|
||||
|
||||
test_oid_register(130, -1); /* empty */
|
||||
test_oid_register(130, -1); /* append */
|
||||
|
||||
varbind->val_len = varbind.name_length * sizeof(oid);
|
||||
memcpy(varbind->buf, varbind.name, varbind.val_len);
|
||||
varbind->val.objid = (oid *) varbind.buf;
|
||||
varbind->val_len += sizeof(oid);
|
||||
|
||||
test_oid_register(130, 255); /* append exact */
|
||||
test_oid_register(130, -1); /* minor rollover */
|
||||
test_oid_register(130, 100); /* insert exact */
|
||||
printf("This next one should fail....\n");
|
||||
test_oid_register(130, 100); /* exact duplicate */
|
||||
printf("done\n");
|
||||
|
||||
varbind->val.objid = (oid *) varbind.buf;
|
||||
for (i = 0; i < 6; i++)
|
||||
varbind->val.objid[i] = 255;
|
||||
varbind->val.objid[0] = 1;
|
||||
test_oid_register(130, 255); /* set up rollover */
|
||||
test_oid_register(130, -1); /* medium rollover */
|
||||
|
||||
for (i = 0; i < 6; i++)
|
||||
varbind->val.objid[i] = 255;
|
||||
varbind->val.objid[0] = 2;
|
||||
test_oid_register(130, 255); /* set up rollover */
|
||||
test_oid_register(130, -1); /* major rollover */
|
||||
|
||||
/*
|
||||
* Did it all work?
|
||||
*/
|
||||
dump_idx_registry();
|
||||
|
||||
/*
|
||||
* Test the various "invalid" requests
|
||||
* (unsupported types, mis-matched types, etc)
|
||||
*/
|
||||
printf("The rest of these should fail....\n");
|
||||
test_oid_register(110, -1);
|
||||
test_oid_register(110, 100);
|
||||
test_oid_register(120, -1);
|
||||
test_oid_register(120, 100);
|
||||
test_string_register(110, NULL);
|
||||
test_string_register(110, "aaaa");
|
||||
test_string_register(130, NULL);
|
||||
test_string_register(130, "aaaa");
|
||||
test_int_register(120, -1);
|
||||
test_int_register(120, 1);
|
||||
test_int_register(130, -1);
|
||||
test_int_register(130, 1);
|
||||
printf("done - this dump should be the same as before\n");
|
||||
dump_idx_registry();
|
||||
}
|
||||
#endif
|
||||
@@ -1,338 +0,0 @@
|
||||
/*
|
||||
* agent_read_config.c
|
||||
*/
|
||||
|
||||
#include <net-snmp/net-snmp-config.h>
|
||||
#include <net-snmp/net-snmp-features.h>
|
||||
|
||||
#if HAVE_SYS_PARAM_H
|
||||
#include <sys/param.h>
|
||||
#else
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#if HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#if HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#else
|
||||
#include <strings.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
|
||||
#if TIME_WITH_SYS_TIME
|
||||
# include <sys/time.h>
|
||||
# include <time.h>
|
||||
#else
|
||||
# if HAVE_SYS_TIME_H
|
||||
# include <sys/time.h>
|
||||
# else
|
||||
# include <time.h>
|
||||
# endif
|
||||
#endif
|
||||
#if HAVE_NETINET_IN_H
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
#if HAVE_NETINET_IN_SYSTM_H
|
||||
#include <netinet/in_systm.h>
|
||||
#endif
|
||||
#if HAVE_NETINET_IP_H
|
||||
#include <netinet/ip.h>
|
||||
#endif
|
||||
#ifdef NETSNMP_ENABLE_IPV6
|
||||
#if HAVE_NETINET_IP6_H
|
||||
#include <netinet/ip6.h>
|
||||
#endif
|
||||
#endif
|
||||
#if HAVE_SYS_QUEUE_H
|
||||
#include <sys/queue.h>
|
||||
#endif
|
||||
#if HAVE_SYS_SOCKET_H
|
||||
#include <sys/socket.h>
|
||||
#if HAVE_SYS_SOCKETVAR_H
|
||||
#ifndef dynix
|
||||
#include <sys/socketvar.h>
|
||||
#else
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#if HAVE_SYS_STREAM_H
|
||||
# ifdef sysv5UnixWare7
|
||||
# define _KMEMUSER 1 /* <sys/stream.h> needs this for queue_t */
|
||||
# endif
|
||||
#include <sys/stream.h>
|
||||
#endif
|
||||
#if HAVE_NET_ROUTE_H
|
||||
#include <net/route.h>
|
||||
#endif
|
||||
#if HAVE_NETINET_IP_VAR_H
|
||||
#include <netinet/ip_var.h>
|
||||
#endif
|
||||
#ifdef NETSNMP_ENABLE_IPV6
|
||||
#if HAVE_NETNETSNMP_ENABLE_IPV6_IP6_VAR_H
|
||||
#include <netinet6/ip6_var.h>
|
||||
#endif
|
||||
#endif
|
||||
#if HAVE_NETINET_IN_PCB_H
|
||||
#include <netinet/in_pcb.h>
|
||||
#endif
|
||||
#if HAVE_INET_MIB2_H
|
||||
#include <inet/mib2.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_PWD_H
|
||||
#include <pwd.h>
|
||||
#endif
|
||||
#ifdef HAVE_GRP_H
|
||||
#include <grp.h>
|
||||
#endif
|
||||
|
||||
#include <net-snmp/net-snmp-includes.h>
|
||||
#include <net-snmp/agent/net-snmp-agent-includes.h>
|
||||
|
||||
#include "mibgroup/struct.h"
|
||||
#include <net-snmp/agent/agent_trap.h>
|
||||
#include "snmpd.h"
|
||||
#include <net-snmp/agent/agent_callbacks.h>
|
||||
#include <net-snmp/agent/table.h>
|
||||
#include <net-snmp/agent/table_iterator.h>
|
||||
#include <net-snmp/agent/table_data.h>
|
||||
#include <net-snmp/agent/table_dataset.h>
|
||||
#include "agent_module_includes.h"
|
||||
#include "mib_module_includes.h"
|
||||
|
||||
netsnmp_feature_child_of(agent_read_config_all, libnetsnmpagent)
|
||||
|
||||
netsnmp_feature_child_of(snmpd_unregister_config_handler, agent_read_config_all)
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
void
|
||||
snmpd_set_agent_user(const char *token, char *cptr)
|
||||
{
|
||||
if (cptr[0] == '#') {
|
||||
char *ecp;
|
||||
int uid;
|
||||
|
||||
uid = strtoul(cptr + 1, &ecp, 10);
|
||||
if (*ecp != 0) {
|
||||
config_perror("Bad number");
|
||||
} else {
|
||||
netsnmp_ds_set_int(NETSNMP_DS_APPLICATION_ID,
|
||||
NETSNMP_DS_AGENT_USERID, uid);
|
||||
}
|
||||
#if defined(HAVE_GETPWNAM) && defined(HAVE_PWD_H)
|
||||
} else {
|
||||
struct passwd *info;
|
||||
|
||||
info = getpwnam(cptr);
|
||||
if (info)
|
||||
netsnmp_ds_set_int(NETSNMP_DS_APPLICATION_ID,
|
||||
NETSNMP_DS_AGENT_USERID, info->pw_uid);
|
||||
else
|
||||
config_perror("User not found in passwd database");
|
||||
endpwent();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
snmpd_set_agent_group(const char *token, char *cptr)
|
||||
{
|
||||
if (cptr[0] == '#') {
|
||||
char *ecp;
|
||||
int gid = strtoul(cptr + 1, &ecp, 10);
|
||||
|
||||
if (*ecp != 0) {
|
||||
config_perror("Bad number");
|
||||
} else {
|
||||
netsnmp_ds_set_int(NETSNMP_DS_APPLICATION_ID,
|
||||
NETSNMP_DS_AGENT_GROUPID, gid);
|
||||
}
|
||||
#if defined(HAVE_GETGRNAM) && defined(HAVE_GRP_H)
|
||||
} else {
|
||||
struct group *info;
|
||||
|
||||
info = getgrnam(cptr);
|
||||
if (info)
|
||||
netsnmp_ds_set_int(NETSNMP_DS_APPLICATION_ID,
|
||||
NETSNMP_DS_AGENT_GROUPID, info->gr_gid);
|
||||
else
|
||||
config_perror("Group not found in group database");
|
||||
endgrent();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef NETSNMP_NO_LISTEN_SUPPORT
|
||||
void
|
||||
snmpd_set_agent_address(const char *token, char *cptr)
|
||||
{
|
||||
char buf[SPRINT_MAX_LEN];
|
||||
char *ptr;
|
||||
|
||||
/*
|
||||
* has something been specified before?
|
||||
*/
|
||||
ptr = netsnmp_ds_get_string(NETSNMP_DS_APPLICATION_ID,
|
||||
NETSNMP_DS_AGENT_PORTS);
|
||||
|
||||
if (ptr) {
|
||||
/*
|
||||
* append to the older specification string
|
||||
*/
|
||||
snprintf(buf, sizeof(buf), "%s,%s", ptr, cptr);
|
||||
buf[sizeof(buf) - 1] = '\0';
|
||||
} else {
|
||||
strlcpy(buf, cptr, sizeof(buf));
|
||||
}
|
||||
|
||||
DEBUGMSGTL(("snmpd_ports", "port spec: %s\n", buf));
|
||||
netsnmp_ds_set_string(NETSNMP_DS_APPLICATION_ID,
|
||||
NETSNMP_DS_AGENT_PORTS, buf);
|
||||
}
|
||||
#endif /* NETSNMP_NO_LISTEN_SUPPORT */
|
||||
|
||||
void
|
||||
init_agent_read_config(const char *app)
|
||||
{
|
||||
if (app != NULL) {
|
||||
netsnmp_ds_set_string(NETSNMP_DS_LIBRARY_ID,
|
||||
NETSNMP_DS_LIB_APPTYPE, app);
|
||||
} else {
|
||||
app = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID,
|
||||
NETSNMP_DS_LIB_APPTYPE);
|
||||
}
|
||||
|
||||
register_app_config_handler("authtrapenable",
|
||||
snmpd_parse_config_authtrap, NULL,
|
||||
"1 | 2\t\t(1 = enable, 2 = disable)");
|
||||
register_app_config_handler("pauthtrapenable",
|
||||
snmpd_parse_config_authtrap, NULL, NULL);
|
||||
|
||||
|
||||
if (netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
|
||||
NETSNMP_DS_AGENT_ROLE) == MASTER_AGENT) {
|
||||
#ifndef NETSNMP_DISABLE_SNMPV1
|
||||
register_app_config_handler("trapsink",
|
||||
snmpd_parse_config_trapsink,
|
||||
snmpd_free_trapsinks,
|
||||
"host [community] [port]");
|
||||
#endif
|
||||
#ifndef NETSNMP_DISABLE_SNMPV2C
|
||||
register_app_config_handler("trap2sink",
|
||||
snmpd_parse_config_trap2sink,
|
||||
snmpd_free_trapsinks,
|
||||
"host [community] [port]");
|
||||
register_app_config_handler("informsink",
|
||||
snmpd_parse_config_informsink,
|
||||
snmpd_free_trapsinks,
|
||||
"host [community] [port]");
|
||||
#endif
|
||||
register_app_config_handler("trapsess",
|
||||
snmpd_parse_config_trapsess,
|
||||
snmpd_free_trapsinks,
|
||||
"[snmpcmdargs] host");
|
||||
}
|
||||
#if !defined(NETSNMP_DISABLE_SNMPV1) || !defined(NETSNMP_DISABLE_SNMPV2C)
|
||||
register_app_config_handler("trapcommunity",
|
||||
snmpd_parse_config_trapcommunity,
|
||||
snmpd_free_trapcommunity,
|
||||
"community-string");
|
||||
#endif /* support for community based SNMP */
|
||||
netsnmp_ds_register_config(ASN_OCTET_STR, app, "v1trapaddress",
|
||||
NETSNMP_DS_APPLICATION_ID,
|
||||
NETSNMP_DS_AGENT_TRAP_ADDR);
|
||||
#ifdef HAVE_UNISTD_H
|
||||
register_app_config_handler("agentuser",
|
||||
snmpd_set_agent_user, NULL, "userid");
|
||||
register_app_config_handler("agentgroup",
|
||||
snmpd_set_agent_group, NULL, "groupid");
|
||||
#endif
|
||||
#ifndef NETSNMP_NO_LISTEN_SUPPORT
|
||||
register_app_config_handler("agentaddress",
|
||||
snmpd_set_agent_address, NULL,
|
||||
"SNMP bind address");
|
||||
#endif /* NETSNMP_NO_LISTEN_SUPPORT */
|
||||
netsnmp_ds_register_config(ASN_BOOLEAN, app, "quit",
|
||||
NETSNMP_DS_APPLICATION_ID,
|
||||
NETSNMP_DS_AGENT_QUIT_IMMEDIATELY);
|
||||
netsnmp_ds_register_config(ASN_BOOLEAN, app, "leave_pidfile",
|
||||
NETSNMP_DS_APPLICATION_ID,
|
||||
NETSNMP_DS_AGENT_LEAVE_PIDFILE);
|
||||
netsnmp_ds_register_config(ASN_BOOLEAN, app, "dontLogTCPWrappersConnects",
|
||||
NETSNMP_DS_APPLICATION_ID,
|
||||
NETSNMP_DS_AGENT_DONT_LOG_TCPWRAPPERS_CONNECTS);
|
||||
netsnmp_ds_register_config(ASN_INTEGER, app, "maxGetbulkRepeats",
|
||||
NETSNMP_DS_APPLICATION_ID,
|
||||
NETSNMP_DS_AGENT_MAX_GETBULKREPEATS);
|
||||
netsnmp_ds_register_config(ASN_INTEGER, app, "maxGetbulkResponses",
|
||||
NETSNMP_DS_APPLICATION_ID,
|
||||
NETSNMP_DS_AGENT_MAX_GETBULKRESPONSES);
|
||||
netsnmp_init_handler_conf();
|
||||
|
||||
#include "agent_module_dot_conf.h"
|
||||
#include "mib_module_dot_conf.h"
|
||||
#ifdef TESTING
|
||||
print_config_handlers();
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
update_config(void)
|
||||
{
|
||||
snmp_call_callbacks(SNMP_CALLBACK_APPLICATION,
|
||||
SNMPD_CALLBACK_PRE_UPDATE_CONFIG, NULL);
|
||||
free_config();
|
||||
read_configs();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
snmpd_register_config_handler(const char *token,
|
||||
void (*parser) (const char *, char *),
|
||||
void (*releaser) (void), const char *help)
|
||||
{
|
||||
DEBUGMSGTL(("snmpd_register_app_config_handler",
|
||||
"registering .conf token for \"%s\"\n", token));
|
||||
register_app_config_handler(token, parser, releaser, help);
|
||||
}
|
||||
|
||||
void
|
||||
snmpd_register_const_config_handler(const char *token,
|
||||
void (*parser) (const char *, const char *),
|
||||
void (*releaser) (void), const char *help)
|
||||
{
|
||||
DEBUGMSGTL(("snmpd_register_app_config_handler",
|
||||
"registering .conf token for \"%s\"\n", token));
|
||||
register_app_config_handler(token, (void(*)(const char *, char *))parser,
|
||||
releaser, help);
|
||||
}
|
||||
|
||||
#ifdef NETSNMP_FEATURE_REQUIRE_SNMPD_UNREGISTER_CONFIG_HANDLER
|
||||
netsnmp_feature_require(unregister_app_config_handler)
|
||||
#endif /* NETSNMP_FEATURE_REQUIRE_SNMPD_UNREGISTER_CONFIG_HANDLER */
|
||||
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_SNMPD_UNREGISTER_CONFIG_HANDLER
|
||||
void
|
||||
snmpd_unregister_config_handler(const char *token)
|
||||
{
|
||||
unregister_app_config_handler(token);
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_SNMPD_UNREGISTER_CONFIG_HANDLER */
|
||||
|
||||
/*
|
||||
* this function is intended for use by mib-modules to store permenant
|
||||
* configuration information generated by sets or persistent counters
|
||||
*/
|
||||
void
|
||||
snmpd_store_config(const char *line)
|
||||
{
|
||||
read_app_config_store(line);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,236 +0,0 @@
|
||||
#include <net-snmp/net-snmp-config.h>
|
||||
#if HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#if HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#else
|
||||
#include <strings.h>
|
||||
#endif
|
||||
#include <stddef.h>
|
||||
|
||||
#include <net-snmp/net-snmp-includes.h>
|
||||
#include <net-snmp/agent/net-snmp-agent-includes.h>
|
||||
#include <net-snmp/agent/agent_callbacks.h>
|
||||
#include <net-snmp/agent/agent_sysORTable.h>
|
||||
#include <net-snmp/agent/sysORTable.h>
|
||||
|
||||
typedef struct data_node_s {
|
||||
struct sysORTable data;
|
||||
struct data_node_s* next;
|
||||
struct data_node_s* prev;
|
||||
}* data_node;
|
||||
|
||||
static data_node table = NULL;
|
||||
|
||||
static void
|
||||
erase(data_node entry)
|
||||
{
|
||||
entry->data.OR_uptime = netsnmp_get_agent_uptime();
|
||||
DEBUGMSGTL(("agent/sysORTable", "UNREG_SYSOR %p\n", &entry->data));
|
||||
snmp_call_callbacks(SNMP_CALLBACK_APPLICATION, SNMPD_CALLBACK_UNREG_SYSOR,
|
||||
&entry->data);
|
||||
free(entry->data.OR_oid);
|
||||
free(entry->data.OR_descr);
|
||||
if (entry->next == entry)
|
||||
table = NULL;
|
||||
else {
|
||||
entry->next->prev = entry->prev;
|
||||
entry->prev->next = entry->next;
|
||||
if (entry == table)
|
||||
table = entry->next;
|
||||
}
|
||||
free(entry);
|
||||
}
|
||||
|
||||
void
|
||||
netsnmp_sysORTable_foreach(void (*f)(const struct sysORTable*, void*), void* c)
|
||||
{
|
||||
DEBUGMSGTL(("agent/sysORTable", "foreach(%p, %p)\n", f, c));
|
||||
if(table) {
|
||||
data_node run = table;
|
||||
do {
|
||||
data_node tmp = run;
|
||||
run = run->next;
|
||||
f(&tmp->data, c);
|
||||
} while(table && run != table);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
register_sysORTable_sess(oid * oidin,
|
||||
size_t oidlen,
|
||||
const char *descr, netsnmp_session * ss)
|
||||
{
|
||||
data_node entry;
|
||||
|
||||
DEBUGMSGTL(("agent/sysORTable", "registering: "));
|
||||
DEBUGMSGOID(("agent/sysORTable", oidin, oidlen));
|
||||
DEBUGMSG(("agent/sysORTable", ", session %p\n", ss));
|
||||
|
||||
entry = (data_node)calloc(1, sizeof(struct data_node_s));
|
||||
if (entry == NULL) {
|
||||
DEBUGMSGTL(("agent/sysORTable", "Failed to allocate new entry\n"));
|
||||
return SYS_ORTABLE_REGISTRATION_FAILED;
|
||||
}
|
||||
|
||||
entry->data.OR_descr = strdup(descr);
|
||||
if (entry->data.OR_descr == NULL) {
|
||||
DEBUGMSGTL(("agent/sysORTable", "Failed to allocate new sysORDescr\n"));
|
||||
free(entry);
|
||||
return SYS_ORTABLE_REGISTRATION_FAILED;
|
||||
}
|
||||
|
||||
entry->data.OR_oid = (oid *) malloc(sizeof(oid) * oidlen);
|
||||
if (entry->data.OR_oid == NULL) {
|
||||
DEBUGMSGTL(("agent/sysORTable", "Failed to allocate new sysORID\n"));
|
||||
free(entry->data.OR_descr);
|
||||
free(entry);
|
||||
return SYS_ORTABLE_REGISTRATION_FAILED;
|
||||
}
|
||||
|
||||
memcpy(entry->data.OR_oid, oidin, sizeof(oid) * oidlen);
|
||||
entry->data.OR_oidlen = oidlen;
|
||||
entry->data.OR_sess = ss;
|
||||
|
||||
if(table) {
|
||||
entry->next = table;
|
||||
entry->prev = table->prev;
|
||||
table->prev->next = entry;
|
||||
table->prev = entry;
|
||||
} else
|
||||
table = entry->next = entry->prev = entry;
|
||||
|
||||
entry->data.OR_uptime = netsnmp_get_agent_uptime();
|
||||
|
||||
snmp_call_callbacks(SNMP_CALLBACK_APPLICATION,
|
||||
SNMPD_CALLBACK_REG_SYSOR, &entry->data);
|
||||
|
||||
return SYS_ORTABLE_REGISTERED_OK;
|
||||
}
|
||||
|
||||
int
|
||||
register_sysORTable(oid * oidin, size_t oidlen, const char *descr)
|
||||
{
|
||||
return register_sysORTable_sess(oidin, oidlen, descr, NULL);
|
||||
}
|
||||
|
||||
int
|
||||
unregister_sysORTable_sess(oid * oidin,
|
||||
size_t oidlen, netsnmp_session * ss)
|
||||
{
|
||||
int any_unregistered = 0;
|
||||
|
||||
DEBUGMSGTL(("agent/sysORTable", "sysORTable unregistering: "));
|
||||
DEBUGMSGOID(("agent/sysORTable", oidin, oidlen));
|
||||
DEBUGMSG(("agent/sysORTable", ", session %p\n", ss));
|
||||
|
||||
if(table) {
|
||||
data_node run = table;
|
||||
do {
|
||||
data_node tmp = run;
|
||||
run = run->next;
|
||||
if (tmp->data.OR_sess == ss &&
|
||||
snmp_oid_compare(oidin, oidlen,
|
||||
tmp->data.OR_oid, tmp->data.OR_oidlen) == 0) {
|
||||
erase(tmp);
|
||||
any_unregistered = 1;
|
||||
}
|
||||
} while(table && run != table);
|
||||
}
|
||||
|
||||
if (any_unregistered) {
|
||||
DEBUGMSGTL(("agent/sysORTable", "unregistering successfull\n"));
|
||||
return SYS_ORTABLE_UNREGISTERED_OK;
|
||||
} else {
|
||||
DEBUGMSGTL(("agent/sysORTable", "unregistering failed\n"));
|
||||
return SYS_ORTABLE_NO_SUCH_REGISTRATION;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
unregister_sysORTable(oid * oidin, size_t oidlen)
|
||||
{
|
||||
return unregister_sysORTable_sess(oidin, oidlen, NULL);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
unregister_sysORTable_by_session(netsnmp_session * ss)
|
||||
{
|
||||
DEBUGMSGTL(("agent/sysORTable",
|
||||
"sysORTable unregistering session %p\n", ss));
|
||||
|
||||
if(table) {
|
||||
data_node run = table;
|
||||
do {
|
||||
data_node tmp = run;
|
||||
run = run->next;
|
||||
if (((ss->flags & SNMP_FLAGS_SUBSESSION) &&
|
||||
tmp->data.OR_sess == ss) ||
|
||||
(!(ss->flags & SNMP_FLAGS_SUBSESSION) && tmp->data.OR_sess &&
|
||||
tmp->data.OR_sess->subsession == ss))
|
||||
erase(tmp);
|
||||
} while(table && run != table);
|
||||
}
|
||||
|
||||
DEBUGMSGTL(("agent/sysORTable",
|
||||
"sysORTable unregistering session %p done\n", ss));
|
||||
}
|
||||
|
||||
static int
|
||||
register_sysOR_callback(int majorID, int minorID, void *serverarg,
|
||||
void *clientarg)
|
||||
{
|
||||
struct sysORTable *parms = (struct sysORTable *) serverarg;
|
||||
|
||||
return register_sysORTable_sess(parms->OR_oid, parms->OR_oidlen,
|
||||
parms->OR_descr, parms->OR_sess);
|
||||
}
|
||||
|
||||
static int
|
||||
unregister_sysOR_by_session_callback(int majorID, int minorID,
|
||||
void *serverarg, void *clientarg)
|
||||
{
|
||||
netsnmp_session *session = (netsnmp_session *) serverarg;
|
||||
|
||||
unregister_sysORTable_by_session(session);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
unregister_sysOR_callback(int majorID, int minorID, void *serverarg,
|
||||
void *clientarg)
|
||||
{
|
||||
struct sysORTable *parms = (struct sysORTable *) serverarg;
|
||||
|
||||
return unregister_sysORTable_sess(parms->OR_oid,
|
||||
parms->OR_oidlen,
|
||||
parms->OR_sess);
|
||||
}
|
||||
|
||||
void
|
||||
init_agent_sysORTable(void)
|
||||
{
|
||||
DEBUGMSGTL(("agent/sysORTable", "init_agent_sysORTable\n"));
|
||||
|
||||
snmp_register_callback(SNMP_CALLBACK_APPLICATION,
|
||||
SNMPD_CALLBACK_REQ_REG_SYSOR,
|
||||
register_sysOR_callback, NULL);
|
||||
snmp_register_callback(SNMP_CALLBACK_APPLICATION,
|
||||
SNMPD_CALLBACK_REQ_UNREG_SYSOR,
|
||||
unregister_sysOR_callback, NULL);
|
||||
snmp_register_callback(SNMP_CALLBACK_APPLICATION,
|
||||
SNMPD_CALLBACK_REQ_UNREG_SYSOR_SESS,
|
||||
unregister_sysOR_by_session_callback, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
shutdown_agent_sysORTable(void)
|
||||
{
|
||||
DEBUGMSGTL(("agent/sysORTable", "shutdown_sysORTable\n"));
|
||||
while(table)
|
||||
erase(table);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,271 +0,0 @@
|
||||
#include <net-snmp/net-snmp-config.h>
|
||||
|
||||
#ifdef NETSNMP_CAN_USE_NLIST
|
||||
#if HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#else
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <netinet/in.h>
|
||||
#ifdef HAVE_NLIST_H
|
||||
#include <nlist.h>
|
||||
#endif
|
||||
#if HAVE_KVM_H
|
||||
#include <kvm.h>
|
||||
#endif
|
||||
|
||||
#include <net-snmp/agent/auto_nlist.h>
|
||||
#include "autonlist.h"
|
||||
#include "kernel.h"
|
||||
|
||||
#include <net-snmp/net-snmp-includes.h>
|
||||
#include <net-snmp/agent/ds_agent.h>
|
||||
|
||||
struct autonlist *nlists = 0;
|
||||
static void init_nlist(struct nlist *);
|
||||
|
||||
long
|
||||
auto_nlist_value(const char *string)
|
||||
{
|
||||
struct autonlist **ptr, *it = 0;
|
||||
int cmp;
|
||||
|
||||
if (string == 0)
|
||||
return 0;
|
||||
|
||||
ptr = &nlists;
|
||||
while (*ptr != 0 && it == 0) {
|
||||
cmp = strcmp((*ptr)->symbol, string);
|
||||
if (cmp == 0)
|
||||
it = *ptr;
|
||||
else if (cmp < 0) {
|
||||
ptr = &((*ptr)->left);
|
||||
} else {
|
||||
ptr = &((*ptr)->right);
|
||||
}
|
||||
}
|
||||
if (*ptr == 0) {
|
||||
#if !(defined(aix4) || defined(aix5) || defined(aix6) || defined(aix7))
|
||||
static char *n_name = NULL;
|
||||
#endif
|
||||
*ptr = (struct autonlist *) malloc(sizeof(struct autonlist));
|
||||
memset(*ptr, 0, sizeof(struct autonlist));
|
||||
it = *ptr;
|
||||
it->left = 0;
|
||||
it->right = 0;
|
||||
it->symbol = (char *) malloc(strlen(string) + 1);
|
||||
strcpy(it->symbol, string);
|
||||
/*
|
||||
* allocate an extra byte for inclusion of a preceding '_' later
|
||||
*/
|
||||
it->nl[0].n_name = (char *) malloc(strlen(string) + 2);
|
||||
#if defined(aix4) || defined(aix5) || defined(aix6) || defined(aix7)
|
||||
strcpy(it->nl[0].n_name, string);
|
||||
it->nl[0].n_name[strlen(string)+1] = '\0';
|
||||
#elif defined(freebsd9)
|
||||
sprintf(__DECONST(char*, it->nl[0].n_name), "_%s", string);
|
||||
#else
|
||||
|
||||
if (n_name != NULL)
|
||||
free(n_name);
|
||||
|
||||
n_name = malloc(strlen(string) + 2);
|
||||
if (n_name == NULL) {
|
||||
snmp_log(LOG_ERR, "nlist err: failed to allocate memory");
|
||||
return (-1);
|
||||
}
|
||||
snprintf(n_name, strlen(string) + 2, "_%s", string);
|
||||
it->nl[0].n_name = (const char*)n_name;
|
||||
#endif
|
||||
it->nl[1].n_name = 0;
|
||||
init_nlist(it->nl);
|
||||
#if !(defined(aix4) || defined(aix5) || defined(aix6) || defined(aix7) || \
|
||||
defined(netbsd1) || defined(dragonfly))
|
||||
if (it->nl[0].n_type == 0) {
|
||||
#if defined(freebsd9)
|
||||
strcpy(__DECONST(char*, it->nl[0].n_name), string);
|
||||
__DECONST(char*, it->nl[0].n_name)[strlen(string)+1] = '\0';
|
||||
#else
|
||||
static char *n_name2 = NULL;
|
||||
|
||||
if (n_name2 != NULL)
|
||||
free(n_name2);
|
||||
|
||||
n_name2 = malloc(strlen(string) + 1);
|
||||
if (n_name2 == NULL) {
|
||||
snmp_log(LOG_ERR, "nlist err: failed to allocate memory");
|
||||
return (-1);
|
||||
}
|
||||
strcpy(n_name2, string);
|
||||
it->nl[0].n_name = (const char*)n_name2;
|
||||
#endif
|
||||
init_nlist(it->nl);
|
||||
}
|
||||
#endif
|
||||
if (it->nl[0].n_type == 0) {
|
||||
if (!netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
|
||||
NETSNMP_DS_AGENT_NO_ROOT_ACCESS)) {
|
||||
snmp_log(LOG_ERR, "nlist err: neither %s nor _%s found.\n",
|
||||
string, string);
|
||||
}
|
||||
return (-1);
|
||||
} else {
|
||||
DEBUGMSGTL(("auto_nlist:auto_nlist_value",
|
||||
"found symbol %s at %lx.\n",
|
||||
it->symbol, it->nl[0].n_value));
|
||||
return (it->nl[0].n_value);
|
||||
}
|
||||
} else
|
||||
return (it->nl[0].n_value);
|
||||
}
|
||||
|
||||
int
|
||||
auto_nlist(const char *string, char *var, size_t size)
|
||||
{
|
||||
long result;
|
||||
int ret;
|
||||
result = auto_nlist_value(string);
|
||||
if (result != -1) {
|
||||
if (var != NULL) {
|
||||
ret = klookup(result, var, size);
|
||||
if (!ret)
|
||||
snmp_log(LOG_ERR,
|
||||
"auto_nlist failed on %s at location %lx\n",
|
||||
string, result);
|
||||
return ret;
|
||||
} else
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
init_nlist(struct nlist nl[])
|
||||
{
|
||||
int ret;
|
||||
#if HAVE_KVM_OPENFILES
|
||||
kvm_t *kernel;
|
||||
char kvm_errbuf[4096];
|
||||
|
||||
if ((kernel = kvm_openfiles(KERNEL_LOC, NULL, NULL, O_RDONLY, kvm_errbuf))
|
||||
== NULL) {
|
||||
if (netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
|
||||
NETSNMP_DS_AGENT_NO_ROOT_ACCESS)) {
|
||||
return;
|
||||
} else {
|
||||
snmp_log_perror("kvm_openfiles");
|
||||
snmp_log(LOG_ERR, "kvm_openfiles: %s\n", kvm_errbuf);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
if ((ret = kvm_nlist(kernel, nl)) == -1) {
|
||||
if (netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
|
||||
NETSNMP_DS_AGENT_NO_ROOT_ACCESS)) {
|
||||
return;
|
||||
} else {
|
||||
snmp_log_perror("kvm_nlist");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
kvm_close(kernel);
|
||||
#else /* ! HAVE_KVM_OPENFILES */
|
||||
#if (defined(aix4) || defined(aix5) || defined(aix6) || defined(aix7)) && defined(HAVE_KNLIST)
|
||||
if (knlist(nl, 1, sizeof(struct nlist)) == -1) {
|
||||
DEBUGMSGTL(("auto_nlist:init_nlist", "knlist failed on symbol: %s\n",
|
||||
nl[0].n_name));
|
||||
if (errno == EFAULT) {
|
||||
nl[0].n_type = 0;
|
||||
nl[0].n_value = 0;
|
||||
} else {
|
||||
snmp_log_perror("knlist");
|
||||
if (netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
|
||||
NETSNMP_DS_AGENT_NO_ROOT_ACCESS)) {
|
||||
return;
|
||||
} else {
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
if ((ret = nlist(KERNEL_LOC, nl)) == -1) {
|
||||
if (netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
|
||||
NETSNMP_DS_AGENT_NO_ROOT_ACCESS)) {
|
||||
return;
|
||||
} else {
|
||||
snmp_log_perror("nlist");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
#endif /*aix4 */
|
||||
#endif /* ! HAVE_KVM_OPENFILES */
|
||||
for (ret = 0; nl[ret].n_name != NULL; ret++) {
|
||||
#if defined(aix4) || defined(aix5) || defined(aix6) || defined(aix7)
|
||||
if (nl[ret].n_type == 0 && nl[ret].n_value != 0)
|
||||
nl[ret].n_type = 1;
|
||||
#endif
|
||||
if (nl[ret].n_type == 0) {
|
||||
if (!netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
|
||||
NETSNMP_DS_AGENT_NO_ROOT_ACCESS)) {
|
||||
DEBUGMSGTL(("auto_nlist:init_nlist", "nlist err: %s not found\n",
|
||||
nl[ret].n_name));
|
||||
}
|
||||
} else {
|
||||
DEBUGMSGTL(("auto_nlist:init_nlist", "nlist: %s 0x%X\n", nl[ret].n_name,
|
||||
(unsigned int) nl[ret].n_value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
KNLookup(struct nlist nl[], int nl_which, char *buf, size_t s)
|
||||
{
|
||||
struct nlist *nlp = &nl[nl_which];
|
||||
|
||||
if (nlp->n_value == 0) {
|
||||
snmp_log(LOG_ERR, "Accessing non-nlisted variable: %s\n",
|
||||
nlp->n_name);
|
||||
nlp->n_value = -1; /* only one error message ... */
|
||||
return 0;
|
||||
}
|
||||
if (nlp->n_value == -1)
|
||||
return 0;
|
||||
|
||||
return klookup(nlp->n_value, buf, s);
|
||||
}
|
||||
|
||||
#ifdef TESTING
|
||||
void
|
||||
auto_nlist_print_tree(int indent, struct autonlist *ptr)
|
||||
{
|
||||
char buf[1024];
|
||||
if (indent == -2) {
|
||||
snmp_log(LOG_ERR, "nlist tree:\n");
|
||||
auto_nlist_print_tree(12, nlists);
|
||||
} else {
|
||||
if (ptr == 0)
|
||||
return;
|
||||
sprintf(buf, "%%%ds\n", indent);
|
||||
/*
|
||||
* DEBUGMSGTL(("auto_nlist", "buf: %s\n",buf));
|
||||
*/
|
||||
DEBUGMSGTL(("auto_nlist", buf, ptr->symbol));
|
||||
auto_nlist_print_tree(indent + 2, ptr->left);
|
||||
auto_nlist_print_tree(indent + 2, ptr->right);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#else /* !NETSNMP_CAN_USE_NLIST */
|
||||
#include <net-snmp/agent/auto_nlist.h>
|
||||
int
|
||||
auto_nlist_noop(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif /* NETSNMP_CAN_USE_NLIST */
|
||||
@@ -1,10 +0,0 @@
|
||||
#ifndef AUTONLIST_H
|
||||
|
||||
struct autonlist {
|
||||
char *symbol;
|
||||
struct nlist nl[2];
|
||||
struct autonlist *left, *right;
|
||||
};
|
||||
|
||||
#define AUTONLIST_H
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,38 +0,0 @@
|
||||
#
|
||||
# Makefile for libnetsnmphelpers
|
||||
#
|
||||
|
||||
top_builddir=../..
|
||||
|
||||
# use GNU vpath, if available, to only set a path for source and headers
|
||||
# VPATH will pick up objects too, which is bad if you are sharing a
|
||||
# source dir...
|
||||
@GNU_vpath@ %.h $(srcdir)
|
||||
@GNU_vpath@ %.c $(srcdir)
|
||||
# fallback to regular VPATH for non-gnu...
|
||||
@NON_GNU_VPATH@ $(srcdir)
|
||||
|
||||
#
|
||||
# What to install
|
||||
#
|
||||
|
||||
INSTALLLIBS=libnetsnmphelpers.$(LIB_EXTENSION)$(LIB_VERSION)
|
||||
INCLUDESUBDIR=agent
|
||||
|
||||
#
|
||||
# Build info
|
||||
#
|
||||
HELPERLIB = libnetsnmphelpers.$(LIB_EXTENSION)$(LIB_VERSION)
|
||||
# -I. -I.. -I../..
|
||||
CPPFLAGS= $(TOP_INCLUDES) -I. $(AGENT_INCLUDES) $(MIBGROUP_INCLUDES) \
|
||||
$(SNMPLIB_INCLUDES) @CPPFLAGS@
|
||||
|
||||
OBJS = dummy.o
|
||||
|
||||
LOBJS = dummy.lo
|
||||
|
||||
all: standardall
|
||||
|
||||
libnetsnmphelpers.$(LIB_EXTENSION)$(LIB_VERSION): $(LOBJS)
|
||||
$(LIB_LD_CMD) $@ $(LOBJS) @LD_NO_UNDEFINED@ $(LDFLAGS) $(LIB_LD_LIBS)
|
||||
$(RANLIB) $@
|
||||
@@ -1,58 +0,0 @@
|
||||
/** @name handler
|
||||
* @{ */
|
||||
|
||||
#include <net-snmp/net-snmp-config.h>
|
||||
#include <net-snmp/net-snmp-features.h>
|
||||
#include <net-snmp/net-snmp-includes.h>
|
||||
#include <net-snmp/agent/net-snmp-agent-includes.h>
|
||||
|
||||
#include <net-snmp/agent/debug_handler.h>
|
||||
#include <net-snmp/agent/serialize.h>
|
||||
#include <net-snmp/agent/read_only.h>
|
||||
#include <net-snmp/agent/bulk_to_next.h>
|
||||
#include <net-snmp/agent/table_dataset.h>
|
||||
#include <net-snmp/agent/stash_cache.h>
|
||||
|
||||
netsnmp_feature_child_of(mib_helpers, libnetsnmpagent)
|
||||
|
||||
|
||||
/** call the initialization sequence for all handlers with init_ routines. */
|
||||
void
|
||||
netsnmp_init_helpers(void)
|
||||
{
|
||||
netsnmp_init_debug_helper();
|
||||
netsnmp_init_serialize();
|
||||
netsnmp_init_read_only_helper();
|
||||
netsnmp_init_bulk_to_next_helper();
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_TABLE_DATASET
|
||||
netsnmp_init_table_dataset();
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_TABLE_DATASET */
|
||||
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_ROW_MERGE
|
||||
netsnmp_init_row_merge();
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_ROW_MERGE */
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_STASH_CACHE
|
||||
netsnmp_init_stash_cache_helper();
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_STASH_CACHE */
|
||||
}
|
||||
|
||||
/** @defgroup utilities utility_handlers
|
||||
* Simplify request processing
|
||||
* A group of handlers intended to simplify certain aspects of processing
|
||||
* a request for a MIB object. These helpers do not implement any MIB
|
||||
* objects themselves. Rather they handle specific generic situations,
|
||||
* either returning an error, or passing a (possibly simpler) request
|
||||
* down to lower level handlers.
|
||||
* @ingroup handler
|
||||
*/
|
||||
|
||||
/** @defgroup leaf leaf_handlers
|
||||
* Process individual leaf objects
|
||||
* A group of handlers to implement individual leaf objects and instances
|
||||
* (both scalar objects, and individual objects and instances within a table).
|
||||
* These handlers will typically allow control to be passed down to a lower
|
||||
* level, user-provided handler, but this is (usually) optional.
|
||||
* @ingroup handler
|
||||
*/
|
||||
|
||||
/** @} */
|
||||
@@ -1,565 +0,0 @@
|
||||
/*
|
||||
* baby_steps.c
|
||||
* $Id$
|
||||
*/
|
||||
#include <net-snmp/net-snmp-config.h>
|
||||
#include <net-snmp/net-snmp-features.h>
|
||||
#include <net-snmp/net-snmp-includes.h>
|
||||
#include <net-snmp/agent/net-snmp-agent-includes.h>
|
||||
|
||||
netsnmp_feature_provide(baby_steps)
|
||||
netsnmp_feature_child_of(baby_steps, mib_helpers)
|
||||
|
||||
#ifdef NETSNMP_FEATURE_REQUIRE_BABY_STEPS
|
||||
netsnmp_feature_require(check_requests_error)
|
||||
#endif
|
||||
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_BABY_STEPS
|
||||
|
||||
#include <net-snmp/agent/baby_steps.h>
|
||||
|
||||
#define BABY_STEPS_PER_MODE_MAX 4
|
||||
#define BSTEP_USE_ORIGINAL 0xffff
|
||||
|
||||
static u_short get_mode_map[BABY_STEPS_PER_MODE_MAX] = {
|
||||
MODE_BSTEP_PRE_REQUEST, MODE_BSTEP_OBJECT_LOOKUP, BSTEP_USE_ORIGINAL, MODE_BSTEP_POST_REQUEST };
|
||||
|
||||
#ifndef NETSNMP_NO_WRITE_SUPPORT
|
||||
static u_short set_mode_map[SNMP_MSG_INTERNAL_SET_MAX][BABY_STEPS_PER_MODE_MAX] = {
|
||||
/*R1*/
|
||||
{ MODE_BSTEP_PRE_REQUEST, MODE_BSTEP_OBJECT_LOOKUP, MODE_BSTEP_ROW_CREATE,
|
||||
MODE_BSTEP_CHECK_VALUE },
|
||||
/*R2*/
|
||||
{ MODE_BSTEP_UNDO_SETUP, BABY_STEP_NONE, BABY_STEP_NONE, BABY_STEP_NONE },
|
||||
/*A */
|
||||
{ MODE_BSTEP_SET_VALUE,MODE_BSTEP_CHECK_CONSISTENCY,
|
||||
MODE_BSTEP_COMMIT, BABY_STEP_NONE },
|
||||
/*C */
|
||||
{ MODE_BSTEP_IRREVERSIBLE_COMMIT, MODE_BSTEP_UNDO_CLEANUP, MODE_BSTEP_POST_REQUEST,
|
||||
BABY_STEP_NONE},
|
||||
/*F */
|
||||
{ MODE_BSTEP_UNDO_CLEANUP, MODE_BSTEP_POST_REQUEST, BABY_STEP_NONE,
|
||||
BABY_STEP_NONE },
|
||||
/*U */
|
||||
{ MODE_BSTEP_UNDO_COMMIT, MODE_BSTEP_UNDO_SET, MODE_BSTEP_UNDO_CLEANUP,
|
||||
MODE_BSTEP_POST_REQUEST}
|
||||
};
|
||||
#endif /* NETSNMP_NO_WRITE_SUPPORT */
|
||||
|
||||
static int
|
||||
_baby_steps_helper(netsnmp_mib_handler *handler,
|
||||
netsnmp_handler_registration *reginfo,
|
||||
netsnmp_agent_request_info *reqinfo,
|
||||
netsnmp_request_info *requests);
|
||||
static int
|
||||
_baby_steps_access_multiplexer(netsnmp_mib_handler *handler,
|
||||
netsnmp_handler_registration *reginfo,
|
||||
netsnmp_agent_request_info *reqinfo,
|
||||
netsnmp_request_info *requests);
|
||||
|
||||
/** @defgroup baby_steps baby_steps
|
||||
* Calls your handler in baby_steps for set processing.
|
||||
* @ingroup handler
|
||||
* @{
|
||||
*/
|
||||
|
||||
static netsnmp_baby_steps_modes *
|
||||
netsnmp_baby_steps_modes_ref(netsnmp_baby_steps_modes *md)
|
||||
{
|
||||
md->refcnt++;
|
||||
return md;
|
||||
}
|
||||
|
||||
static void
|
||||
netsnmp_baby_steps_modes_deref(netsnmp_baby_steps_modes *md)
|
||||
{
|
||||
if (--md->refcnt == 0)
|
||||
free(md);
|
||||
}
|
||||
|
||||
/** returns a baby_steps handler that can be injected into a given
|
||||
* handler chain.
|
||||
*/
|
||||
netsnmp_mib_handler *
|
||||
netsnmp_baby_steps_handler_get(u_long modes)
|
||||
{
|
||||
netsnmp_mib_handler *mh;
|
||||
netsnmp_baby_steps_modes *md;
|
||||
|
||||
mh = netsnmp_create_handler("baby_steps", _baby_steps_helper);
|
||||
if(!mh)
|
||||
return NULL;
|
||||
|
||||
md = SNMP_MALLOC_TYPEDEF(netsnmp_baby_steps_modes);
|
||||
if (NULL == md) {
|
||||
snmp_log(LOG_ERR,"malloc failed in netsnmp_baby_steps_handler_get\n");
|
||||
netsnmp_handler_free(mh);
|
||||
mh = NULL;
|
||||
}
|
||||
else {
|
||||
md->refcnt = 1;
|
||||
mh->myvoid = md;
|
||||
mh->data_clone = (void *(*)(void *))netsnmp_baby_steps_modes_ref;
|
||||
mh->data_free = (void (*)(void *))netsnmp_baby_steps_modes_deref;
|
||||
if (0 == modes)
|
||||
modes = BABY_STEP_ALL;
|
||||
md->registered = modes;
|
||||
}
|
||||
|
||||
/*
|
||||
* don't set MIB_HANDLER_AUTO_NEXT, since we need to call lower
|
||||
* handlers with a munged mode.
|
||||
*/
|
||||
|
||||
return mh;
|
||||
}
|
||||
|
||||
/** @internal Implements the baby_steps handler */
|
||||
static int
|
||||
_baby_steps_helper(netsnmp_mib_handler *handler,
|
||||
netsnmp_handler_registration *reginfo,
|
||||
netsnmp_agent_request_info *reqinfo,
|
||||
netsnmp_request_info *requests)
|
||||
{
|
||||
netsnmp_baby_steps_modes *bs_modes;
|
||||
int save_mode, i, rc = SNMP_ERR_NOERROR;
|
||||
u_short *mode_map_ptr;
|
||||
|
||||
DEBUGMSGTL(("baby_steps", "Got request, mode %s\n",
|
||||
se_find_label_in_slist("agent_mode",reqinfo->mode)));
|
||||
|
||||
bs_modes = (netsnmp_baby_steps_modes*)handler->myvoid;
|
||||
netsnmp_assert(NULL != bs_modes);
|
||||
|
||||
switch (reqinfo->mode) {
|
||||
|
||||
#ifndef NETSNMP_NO_WRITE_SUPPORT
|
||||
case MODE_SET_RESERVE1:
|
||||
/*
|
||||
* clear completed modes
|
||||
* xxx-rks: this will break for pdus with set requests to different
|
||||
* rows in the same table when the handler is set up to use the row
|
||||
* merge helper as well (or if requests are serialized).
|
||||
*/
|
||||
bs_modes->completed = 0;
|
||||
/** fall through */
|
||||
|
||||
case MODE_SET_RESERVE2:
|
||||
case MODE_SET_ACTION:
|
||||
case MODE_SET_COMMIT:
|
||||
case MODE_SET_FREE:
|
||||
case MODE_SET_UNDO:
|
||||
mode_map_ptr = set_mode_map[reqinfo->mode];
|
||||
break;
|
||||
#endif /* NETSNMP_NO_WRITE_SUPPORT */
|
||||
|
||||
default:
|
||||
/*
|
||||
* clear completed modes
|
||||
*/
|
||||
bs_modes->completed = 0;
|
||||
|
||||
mode_map_ptr = get_mode_map;
|
||||
}
|
||||
|
||||
/*
|
||||
* NOTE: if you update this chart, please update the versions in
|
||||
* local/mib2c-conf.d/parent-set.m2i
|
||||
* agent/mibgroup/helpers/baby_steps.c
|
||||
* while you're at it.
|
||||
*/
|
||||
/*
|
||||
***********************************************************************
|
||||
* Baby Steps Flow Chart (2004.06.05) *
|
||||
* *
|
||||
* +--------------+ +================+ U = unconditional path *
|
||||
* |optional state| ||required state|| S = path for success *
|
||||
* +--------------+ +================+ E = path for error *
|
||||
***********************************************************************
|
||||
*
|
||||
* +--------------+
|
||||
* | pre |
|
||||
* | request |
|
||||
* +--------------+
|
||||
* | U
|
||||
* +-------------+ +==============+
|
||||
* | row |f|<-------|| object ||
|
||||
* | create |1| E || lookup ||
|
||||
* +-------------+ +==============+
|
||||
* E | | S | S
|
||||
* | +------------------>|
|
||||
* | +==============+
|
||||
* | E || check ||
|
||||
* |<---------------|| values ||
|
||||
* | +==============+
|
||||
* | | S
|
||||
* | +==============+
|
||||
* | +<-------|| undo ||
|
||||
* | | E || setup ||
|
||||
* | | +==============+
|
||||
* | | | S
|
||||
* | | +==============+
|
||||
* | | || set ||-------------------------->+
|
||||
* | | || value || E |
|
||||
* | | +==============+ |
|
||||
* | | | S |
|
||||
* | | +--------------+ |
|
||||
* | | | check |-------------------------->|
|
||||
* | | | consistency | E |
|
||||
* | | +--------------+ |
|
||||
* | | | S |
|
||||
* | | +==============+ +==============+ |
|
||||
* | | || commit ||-------->|| undo || |
|
||||
* | | || || E || commit || |
|
||||
* | | +==============+ +==============+ |
|
||||
* | | | S U |<--------+
|
||||
* | | +--------------+ +==============+
|
||||
* | | | irreversible | || undo ||
|
||||
* | | | commit | || set ||
|
||||
* | | +--------------+ +==============+
|
||||
* | | | U U |
|
||||
* | +-------------->|<------------------------+
|
||||
* | +==============+
|
||||
* | || undo ||
|
||||
* | || cleanup ||
|
||||
* | +==============+
|
||||
* +---------------------->| U
|
||||
* |
|
||||
* (err && f1)------------------->+
|
||||
* | |
|
||||
* +--------------+ +--------------+
|
||||
* | post |<--------| row |
|
||||
* | request | U | release |
|
||||
* +--------------+ +--------------+
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* save original mode
|
||||
*/
|
||||
save_mode = reqinfo->mode;
|
||||
for(i = 0; i < BABY_STEPS_PER_MODE_MAX; ++i ) {
|
||||
/*
|
||||
* break if we run out of baby steps for this mode
|
||||
*/
|
||||
if(mode_map_ptr[i] == BABY_STEP_NONE)
|
||||
break;
|
||||
|
||||
DEBUGMSGTL(("baby_steps", " baby step mode %s\n",
|
||||
se_find_label_in_slist("babystep_mode",mode_map_ptr[i])));
|
||||
|
||||
/*
|
||||
* skip modes the handler didn't register for
|
||||
*/
|
||||
if (BSTEP_USE_ORIGINAL != mode_map_ptr[i]) {
|
||||
u_int mode_flag;
|
||||
|
||||
#ifndef NETSNMP_NO_WRITE_SUPPORT
|
||||
/*
|
||||
* skip undo commit if commit wasn't hit, and
|
||||
* undo_cleanup if undo_setup wasn't hit.
|
||||
*/
|
||||
if((MODE_SET_UNDO == save_mode) &&
|
||||
(MODE_BSTEP_UNDO_COMMIT == mode_map_ptr[i]) &&
|
||||
!(BABY_STEP_COMMIT & bs_modes->completed)) {
|
||||
DEBUGMSGTL(("baby_steps",
|
||||
" skipping commit undo (no commit)\n"));
|
||||
continue;
|
||||
}
|
||||
else if((MODE_SET_FREE == save_mode) &&
|
||||
(MODE_BSTEP_UNDO_CLEANUP == mode_map_ptr[i]) &&
|
||||
!(BABY_STEP_UNDO_SETUP & bs_modes->completed)) {
|
||||
DEBUGMSGTL(("baby_steps",
|
||||
" skipping undo cleanup (no undo setup)\n"));
|
||||
continue;
|
||||
}
|
||||
#endif /* NETSNMP_NO_WRITE_SUPPORT */
|
||||
|
||||
reqinfo->mode = mode_map_ptr[i];
|
||||
mode_flag = netsnmp_baby_step_mode2flag( mode_map_ptr[i] );
|
||||
if((mode_flag & bs_modes->registered))
|
||||
bs_modes->completed |= mode_flag;
|
||||
else {
|
||||
DEBUGMSGTL(("baby_steps",
|
||||
" skipping mode (not registered)\n"));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
reqinfo->mode = save_mode;
|
||||
}
|
||||
|
||||
#ifdef BABY_STEPS_NEXT_MODE
|
||||
/*
|
||||
* I can't remember why I wanted the next mode in the request,
|
||||
* but it's not used anywhere, so don't use this code. saved,
|
||||
* in case I remember why I thought needed it. - rstory 040911
|
||||
*/
|
||||
if((BABY_STEPS_PER_MODE_MAX - 1) == i)
|
||||
reqinfo->next_mode_ok = BABY_STEP_NONE;
|
||||
else {
|
||||
if(BSTEP_USE_ORIGINAL == mode_map_ptr[i+1])
|
||||
reqinfo->next_mode_ok = save_mode;
|
||||
else
|
||||
reqinfo->next_mode_ok = mode_map_ptr[i+1];
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* call handlers for baby step
|
||||
*/
|
||||
rc = netsnmp_call_next_handler(handler, reginfo, reqinfo,
|
||||
requests);
|
||||
|
||||
/*
|
||||
* check for error calling handler (unlikely, but...)
|
||||
*/
|
||||
if(rc) {
|
||||
DEBUGMSGTL(("baby_steps", " ERROR:handler error\n"));
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* check for errors in any of the requests for GET-like, reserve1,
|
||||
* reserve2 and action. (there is no recovery from errors
|
||||
* in commit, free or undo.)
|
||||
*/
|
||||
if (MODE_IS_GET(save_mode)
|
||||
#ifndef NETSNMP_NO_WRITE_SUPPORT
|
||||
|| (save_mode < SNMP_MSG_INTERNAL_SET_COMMIT)
|
||||
#endif /* NETSNMP_NO_WRITE_SUPPORT */
|
||||
) {
|
||||
rc = netsnmp_check_requests_error(requests);
|
||||
if(rc) {
|
||||
DEBUGMSGTL(("baby_steps", " ERROR:request error\n"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* restore original mode
|
||||
*/
|
||||
reqinfo->mode = save_mode;
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/** initializes the baby_steps helper which then registers a baby_steps
|
||||
* handler as a run-time injectable handler for configuration file
|
||||
* use.
|
||||
*/
|
||||
netsnmp_feature_child_of(netsnmp_baby_steps_handler_init,netsnmp_unused)
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_NETSNMP_BABY_STEPS_HANDLER_INIT
|
||||
void
|
||||
netsnmp_baby_steps_handler_init(void)
|
||||
{
|
||||
netsnmp_register_handler_by_name("baby_steps",
|
||||
netsnmp_baby_steps_handler_get(BABY_STEP_ALL));
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_NETSNMP_BABY_STEPS_HANDLER_INIT */
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @defgroup access_multiplexer baby_steps_access_multiplexer: calls individual access methods based on baby_step mode.
|
||||
* @ingroup baby_steps
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** returns a baby_steps handler that can be injected into a given
|
||||
* handler chain.
|
||||
*/
|
||||
netsnmp_mib_handler *
|
||||
netsnmp_baby_steps_access_multiplexer_get(netsnmp_baby_steps_access_methods *am)
|
||||
{
|
||||
netsnmp_mib_handler *mh;
|
||||
|
||||
mh = netsnmp_create_handler("baby_steps_mux",
|
||||
_baby_steps_access_multiplexer);
|
||||
if(!mh)
|
||||
return NULL;
|
||||
|
||||
mh->myvoid = am;
|
||||
mh->flags |= MIB_HANDLER_AUTO_NEXT;
|
||||
|
||||
return mh;
|
||||
}
|
||||
|
||||
/** @internal Implements the baby_steps handler */
|
||||
static int
|
||||
_baby_steps_access_multiplexer(netsnmp_mib_handler *handler,
|
||||
netsnmp_handler_registration *reginfo,
|
||||
netsnmp_agent_request_info *reqinfo,
|
||||
netsnmp_request_info *requests)
|
||||
{
|
||||
void *temp_void;
|
||||
Netsnmp_Node_Handler *method = NULL;
|
||||
netsnmp_baby_steps_access_methods *access_methods;
|
||||
int rc = SNMP_ERR_NOERROR;
|
||||
|
||||
/** call handlers should enforce these */
|
||||
netsnmp_assert((handler!=NULL) && (reginfo!=NULL) && (reqinfo!=NULL) &&
|
||||
(requests!=NULL));
|
||||
|
||||
DEBUGMSGT(("baby_steps_mux", "mode %s\n",
|
||||
se_find_label_in_slist("babystep_mode",reqinfo->mode)));
|
||||
|
||||
access_methods = (netsnmp_baby_steps_access_methods *)handler->myvoid;
|
||||
if(!access_methods) {
|
||||
snmp_log(LOG_ERR,"baby_steps_access_multiplexer has no methods\n");
|
||||
return SNMPERR_GENERR;
|
||||
}
|
||||
|
||||
switch(reqinfo->mode) {
|
||||
|
||||
case MODE_BSTEP_PRE_REQUEST:
|
||||
if( access_methods->pre_request )
|
||||
method = access_methods->pre_request;
|
||||
break;
|
||||
|
||||
case MODE_BSTEP_OBJECT_LOOKUP:
|
||||
if( access_methods->object_lookup )
|
||||
method = access_methods->object_lookup;
|
||||
break;
|
||||
|
||||
case SNMP_MSG_GET:
|
||||
case SNMP_MSG_GETNEXT:
|
||||
if( access_methods->get_values )
|
||||
method = access_methods->get_values;
|
||||
break;
|
||||
|
||||
#ifndef NETSNMP_NO_WRITE_SUPPORT
|
||||
case MODE_BSTEP_CHECK_VALUE:
|
||||
if( access_methods->object_syntax_checks )
|
||||
method = access_methods->object_syntax_checks;
|
||||
break;
|
||||
|
||||
case MODE_BSTEP_ROW_CREATE:
|
||||
if( access_methods->row_creation )
|
||||
method = access_methods->row_creation;
|
||||
break;
|
||||
|
||||
case MODE_BSTEP_UNDO_SETUP:
|
||||
if( access_methods->undo_setup )
|
||||
method = access_methods->undo_setup;
|
||||
break;
|
||||
|
||||
case MODE_BSTEP_SET_VALUE:
|
||||
if( access_methods->set_values )
|
||||
method = access_methods->set_values;
|
||||
break;
|
||||
|
||||
case MODE_BSTEP_CHECK_CONSISTENCY:
|
||||
if( access_methods->consistency_checks )
|
||||
method = access_methods->consistency_checks;
|
||||
break;
|
||||
|
||||
case MODE_BSTEP_UNDO_SET:
|
||||
if( access_methods->undo_sets )
|
||||
method = access_methods->undo_sets;
|
||||
break;
|
||||
|
||||
case MODE_BSTEP_COMMIT:
|
||||
if( access_methods->commit )
|
||||
method = access_methods->commit;
|
||||
break;
|
||||
|
||||
case MODE_BSTEP_UNDO_COMMIT:
|
||||
if( access_methods->undo_commit )
|
||||
method = access_methods->undo_commit;
|
||||
break;
|
||||
|
||||
case MODE_BSTEP_IRREVERSIBLE_COMMIT:
|
||||
if( access_methods->irreversible_commit )
|
||||
method = access_methods->irreversible_commit;
|
||||
break;
|
||||
|
||||
case MODE_BSTEP_UNDO_CLEANUP:
|
||||
if( access_methods->undo_cleanup )
|
||||
method = access_methods->undo_cleanup;
|
||||
break;
|
||||
#endif /* NETSNMP_NO_WRITE_SUPPORT */
|
||||
|
||||
case MODE_BSTEP_POST_REQUEST:
|
||||
if( access_methods->post_request )
|
||||
method = access_methods->post_request;
|
||||
break;
|
||||
|
||||
default:
|
||||
snmp_log(LOG_ERR,"unknown mode %d\n", reqinfo->mode);
|
||||
return SNMP_ERR_GENERR;
|
||||
}
|
||||
|
||||
/*
|
||||
* if method exists, set up handler void and call method.
|
||||
*/
|
||||
if(NULL != method) {
|
||||
temp_void = handler->myvoid;
|
||||
handler->myvoid = access_methods->my_access_void;
|
||||
rc = (*method)(handler, reginfo, reqinfo, requests);
|
||||
handler->myvoid = temp_void;
|
||||
}
|
||||
else {
|
||||
rc = SNMP_ERR_GENERR;
|
||||
snmp_log(LOG_ERR,"baby steps multiplexer handler called for a mode "
|
||||
"with no handler\n");
|
||||
netsnmp_assert(NULL != method);
|
||||
}
|
||||
|
||||
/*
|
||||
* don't call any lower handlers, it will be done for us
|
||||
* since we set MIB_HANDLER_AUTO_NEXT
|
||||
*/
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* give a baby step mode, return the flag for that mode
|
||||
*/
|
||||
int
|
||||
netsnmp_baby_step_mode2flag( u_int mode )
|
||||
{
|
||||
switch( mode ) {
|
||||
case MODE_BSTEP_OBJECT_LOOKUP:
|
||||
return BABY_STEP_OBJECT_LOOKUP;
|
||||
#ifndef NETSNMP_NO_WRITE_SUPPORT
|
||||
case MODE_BSTEP_SET_VALUE:
|
||||
return BABY_STEP_SET_VALUE;
|
||||
case MODE_BSTEP_IRREVERSIBLE_COMMIT:
|
||||
return BABY_STEP_IRREVERSIBLE_COMMIT;
|
||||
case MODE_BSTEP_CHECK_VALUE:
|
||||
return BABY_STEP_CHECK_VALUE;
|
||||
case MODE_BSTEP_PRE_REQUEST:
|
||||
return BABY_STEP_PRE_REQUEST;
|
||||
case MODE_BSTEP_POST_REQUEST:
|
||||
return BABY_STEP_POST_REQUEST;
|
||||
case MODE_BSTEP_UNDO_SETUP:
|
||||
return BABY_STEP_UNDO_SETUP;
|
||||
case MODE_BSTEP_UNDO_CLEANUP:
|
||||
return BABY_STEP_UNDO_CLEANUP;
|
||||
case MODE_BSTEP_UNDO_SET:
|
||||
return BABY_STEP_UNDO_SET;
|
||||
case MODE_BSTEP_ROW_CREATE:
|
||||
return BABY_STEP_ROW_CREATE;
|
||||
case MODE_BSTEP_CHECK_CONSISTENCY:
|
||||
return BABY_STEP_CHECK_CONSISTENCY;
|
||||
case MODE_BSTEP_COMMIT:
|
||||
return BABY_STEP_COMMIT;
|
||||
case MODE_BSTEP_UNDO_COMMIT:
|
||||
return BABY_STEP_UNDO_COMMIT;
|
||||
#endif /* NETSNMP_NO_WRITE_SUPPORT */
|
||||
default:
|
||||
netsnmp_assert("unknown flag");
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/** @} */
|
||||
|
||||
#else /* NETSNMP_FEATURE_REMOVE_BABY_STEPS */
|
||||
netsnmp_feature_unused(baby_steps);
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_BABY_STEPS */
|
||||
|
||||
@@ -1,139 +0,0 @@
|
||||
#include <net-snmp/net-snmp-config.h>
|
||||
|
||||
#include <net-snmp/net-snmp-includes.h>
|
||||
#include <net-snmp/agent/net-snmp-agent-includes.h>
|
||||
|
||||
#include <net-snmp/agent/bulk_to_next.h>
|
||||
|
||||
/** @defgroup bulk_to_next bulk_to_next
|
||||
* Convert GETBULK requests into GETNEXT requests for the handler.
|
||||
* The only purpose of this handler is to convert a GETBULK request
|
||||
* to a GETNEXT request. It is inserted into handler chains where
|
||||
* the handler has not set the HANDLER_CAN_GETBULK flag.
|
||||
* @ingroup utilities
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** returns a bulk_to_next handler that can be injected into a given
|
||||
* handler chain.
|
||||
*/
|
||||
netsnmp_mib_handler *
|
||||
netsnmp_get_bulk_to_next_handler(void)
|
||||
{
|
||||
netsnmp_mib_handler *handler =
|
||||
netsnmp_create_handler("bulk_to_next",
|
||||
netsnmp_bulk_to_next_helper);
|
||||
|
||||
if (NULL != handler)
|
||||
handler->flags |= MIB_HANDLER_AUTO_NEXT;
|
||||
|
||||
return handler;
|
||||
}
|
||||
|
||||
/** takes answered requests and decrements the repeat count and
|
||||
* updates the requests to the next to-do varbind in the list */
|
||||
void
|
||||
netsnmp_bulk_to_next_fix_requests(netsnmp_request_info *requests)
|
||||
{
|
||||
netsnmp_request_info *request;
|
||||
/*
|
||||
* Make sure that:
|
||||
* - repeats remain
|
||||
* - last handler provided an answer
|
||||
* - answer didn't exceed range end (ala check_getnext_results)
|
||||
* - there is a next variable
|
||||
* then
|
||||
* update the varbinds for the next request series
|
||||
*/
|
||||
for (request = requests; request; request = request->next) {
|
||||
if (request->repeat > 0 &&
|
||||
request->requestvb->type != ASN_NULL &&
|
||||
request->requestvb->type != ASN_PRIV_RETRY &&
|
||||
(snmp_oid_compare(request->requestvb->name,
|
||||
request->requestvb->name_length,
|
||||
request->range_end,
|
||||
request->range_end_len) < 0) &&
|
||||
request->requestvb->next_variable ) {
|
||||
request->repeat--;
|
||||
snmp_set_var_objid(request->requestvb->next_variable,
|
||||
request->requestvb->name,
|
||||
request->requestvb->name_length);
|
||||
request->requestvb = request->requestvb->next_variable;
|
||||
request->requestvb->type = ASN_PRIV_RETRY;
|
||||
/*
|
||||
* if inclusive == 2, it was set in check_getnext_results for
|
||||
* the previous requestvb. Now that we've moved on, clear it.
|
||||
*/
|
||||
if (2 == request->inclusive)
|
||||
request->inclusive = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** @internal Implements the bulk_to_next handler */
|
||||
int
|
||||
netsnmp_bulk_to_next_helper(netsnmp_mib_handler *handler,
|
||||
netsnmp_handler_registration *reginfo,
|
||||
netsnmp_agent_request_info *reqinfo,
|
||||
netsnmp_request_info *requests)
|
||||
{
|
||||
|
||||
int ret = SNMP_ERR_NOERROR;
|
||||
|
||||
/*
|
||||
* this code depends on AUTO_NEXT being set
|
||||
*/
|
||||
netsnmp_assert(handler->flags & MIB_HANDLER_AUTO_NEXT);
|
||||
|
||||
/*
|
||||
* don't do anything for any modes besides GETBULK. Just return, and
|
||||
* the agent will call the next handler (AUTO_NEXT).
|
||||
*
|
||||
* for GETBULK, we munge the mode, call the next handler ourselves
|
||||
* (setting AUTO_NEXT_OVERRRIDE so the agent knows what we did),
|
||||
* restore the mode and fix up the requests.
|
||||
*/
|
||||
if(MODE_GETBULK == reqinfo->mode) {
|
||||
|
||||
DEBUGIF("bulk_to_next") {
|
||||
netsnmp_request_info *req = requests;
|
||||
while(req) {
|
||||
DEBUGMSGTL(("bulk_to_next", "Got request: "));
|
||||
DEBUGMSGOID(("bulk_to_next", req->requestvb->name,
|
||||
req->requestvb->name_length));
|
||||
DEBUGMSG(("bulk_to_next", "\n"));
|
||||
req = req->next;
|
||||
}
|
||||
}
|
||||
|
||||
reqinfo->mode = MODE_GETNEXT;
|
||||
ret =
|
||||
netsnmp_call_next_handler(handler, reginfo, reqinfo, requests);
|
||||
reqinfo->mode = MODE_GETBULK;
|
||||
|
||||
/*
|
||||
* update the varbinds for the next request series
|
||||
*/
|
||||
netsnmp_bulk_to_next_fix_requests(requests);
|
||||
|
||||
/*
|
||||
* let agent handler know that we've already called next handler
|
||||
*/
|
||||
handler->flags |= MIB_HANDLER_AUTO_NEXT_OVERRIDE_ONCE;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/** initializes the bulk_to_next helper which then registers a bulk_to_next
|
||||
* handler as a run-time injectable handler for configuration file
|
||||
* use.
|
||||
*/
|
||||
void
|
||||
netsnmp_init_bulk_to_next_helper(void)
|
||||
{
|
||||
netsnmp_register_handler_by_name("bulk_to_next",
|
||||
netsnmp_get_bulk_to_next_handler());
|
||||
}
|
||||
/** @} */
|
||||
|
||||
@@ -1,771 +0,0 @@
|
||||
/* Portions of this file are subject to the following copyright(s). See
|
||||
* the Net-SNMP's COPYING file for more details and other copyrights
|
||||
* that may apply:
|
||||
*/
|
||||
/*
|
||||
* Portions of this file are copyrighted by:
|
||||
* Copyright (C) 2007 Apple, Inc. All rights reserved.
|
||||
* Use is subject to license terms specified in the COPYING file
|
||||
* distributed with the Net-SNMP package.
|
||||
*/
|
||||
#include <net-snmp/net-snmp-config.h>
|
||||
#include <net-snmp/net-snmp-features.h>
|
||||
|
||||
#if HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#else
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#include <net-snmp/net-snmp-includes.h>
|
||||
#include <net-snmp/agent/net-snmp-agent-includes.h>
|
||||
|
||||
#include <net-snmp/agent/cache_handler.h>
|
||||
|
||||
netsnmp_feature_child_of(cache_handler, mib_helpers)
|
||||
|
||||
netsnmp_feature_child_of(cache_find_by_oid, cache_handler)
|
||||
netsnmp_feature_child_of(cache_get_head, cache_handler)
|
||||
|
||||
static netsnmp_cache *cache_head = NULL;
|
||||
static int cache_outstanding_valid = 0;
|
||||
static int _cache_load( netsnmp_cache *cache );
|
||||
|
||||
#define CACHE_RELEASE_FREQUENCY 60 /* Check for expired caches every 60s */
|
||||
|
||||
void release_cached_resources(unsigned int regNo,
|
||||
void *clientargs);
|
||||
|
||||
/** @defgroup cache_handler cache_handler
|
||||
* Maintains a cache of data for use by lower level handlers.
|
||||
* @ingroup utilities
|
||||
* This helper checks to see whether the data has been loaded "recently"
|
||||
* (according to the timeout for that particular cache) and calls the
|
||||
* registered "load_cache" routine if necessary.
|
||||
* The lower handlers can then work with this local cached data.
|
||||
*
|
||||
* A timeout value of -1 will cause netsnmp_cache_check_expired() to
|
||||
* always return true, and thus the cache will be reloaded for every
|
||||
* request.
|
||||
*
|
||||
* To minimze resource use by the agent, a periodic callback checks for
|
||||
* expired caches, and will call the free_cache function for any expired
|
||||
* cache.
|
||||
*
|
||||
* The load_cache routine should return a negative number if the cache
|
||||
* was not successfully loaded. 0 or any positive number indicates successs.
|
||||
*
|
||||
*
|
||||
* Several flags can be set to affect the operations on the cache.
|
||||
*
|
||||
* If NETSNMP_CACHE_DONT_INVALIDATE_ON_SET is set, the free_cache method
|
||||
* will not be called after a set request has processed. It is assumed that
|
||||
* the lower mib handler using the cache has maintained cache consistency.
|
||||
*
|
||||
* If NETSNMP_CACHE_DONT_FREE_BEFORE_LOAD is set, the free_cache method
|
||||
* will not be called before the load_cache method is called. It is assumed
|
||||
* that the load_cache routine will properly deal with being called with a
|
||||
* valid cache.
|
||||
*
|
||||
* If NETSNMP_CACHE_DONT_FREE_EXPIRED is set, the free_cache method will
|
||||
* not be called with the cache expires. The expired flag will be set, but
|
||||
* the valid flag will not be cleared. It is assumed that the load_cache
|
||||
* routine will properly deal with being called with a valid cache.
|
||||
*
|
||||
* If NETSNMP_CACHE_PRELOAD is set when a the cache handler is created,
|
||||
* the cache load routine will be called immediately.
|
||||
*
|
||||
* If NETSNMP_CACHE_DONT_AUTO_RELEASE is set, the periodic callback that
|
||||
* checks for expired caches will skip the cache. The cache will only be
|
||||
* checked for expiration when a request triggers the cache handler. This
|
||||
* is useful if the cache has it's own periodic callback to keep the cache
|
||||
* fresh.
|
||||
*
|
||||
* If NETSNMP_CACHE_AUTO_RELOAD is set, a timer will be set up to reload
|
||||
* the cache when it expires. This is useful for keeping the cache fresh,
|
||||
* even in the absence of incoming snmp requests.
|
||||
*
|
||||
* If NETSNMP_CACHE_RESET_TIMER_ON_USE is set, the expiry timer will be
|
||||
* reset on each cache access. In practice the 'timeout' becomes a timer
|
||||
* which triggers when the cache is no longer needed. This is useful
|
||||
* if the cache is automatically kept synchronized: e.g. by receiving
|
||||
* change notifications from Netlink, inotify or similar. This should
|
||||
* not be used if cache is not synchronized automatically as it would
|
||||
* result in stale cache information when if polling happens too fast.
|
||||
*
|
||||
*
|
||||
* Here are some suggestions for some common situations.
|
||||
*
|
||||
* Cached File:
|
||||
* If your table is based on a file that may periodically change,
|
||||
* you can test the modification date to see if the file has
|
||||
* changed since the last cache load. To get the cache helper to call
|
||||
* the load function for every request, set the timeout to -1, which
|
||||
* will cause the cache to always report that it is expired. This means
|
||||
* that you will want to prevent the agent from flushing the cache when
|
||||
* it has expired, and you will have to flush it manually if you
|
||||
* detect that the file has changed. To accomplish this, set the
|
||||
* following flags:
|
||||
*
|
||||
* NETSNMP_CACHE_DONT_FREE_EXPIRED
|
||||
* NETSNMP_CACHE_DONT_AUTO_RELEASE
|
||||
*
|
||||
*
|
||||
* Constant (periodic) reload:
|
||||
* If you want the cache kept up to date regularly, even if no requests
|
||||
* for the table are received, you can have your cache load routine
|
||||
* called periodically. This is very useful if you need to monitor the
|
||||
* data for changes (eg a <i>LastChanged</i> object). You will need to
|
||||
* prevent the agent from flushing the cache when it expires. Set the
|
||||
* cache timeout to the frequency, in seconds, that you wish to
|
||||
* reload your cache, and set the following flags:
|
||||
*
|
||||
* NETSNMP_CACHE_DONT_FREE_EXPIRED
|
||||
* NETSNMP_CACHE_DONT_AUTO_RELEASE
|
||||
* NETSNMP_CACHE_AUTO_RELOAD
|
||||
*
|
||||
* Dynamically updated, unloaded after timeout:
|
||||
* If the cache is kept up to date dynamically by listening for
|
||||
* change notifications somehow, but it should not be in memory
|
||||
* if it's not needed. Set the following flag:
|
||||
*
|
||||
* NETSNMP_CACHE_RESET_TIMER_ON_USE
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
static void
|
||||
_cache_free( netsnmp_cache *cache );
|
||||
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_CACHE_GET_HEAD
|
||||
/** get cache head
|
||||
* @internal
|
||||
* unadvertised function to get cache head. You really should not
|
||||
* do this, since the internal storage mechanism might change.
|
||||
*/
|
||||
netsnmp_cache *
|
||||
netsnmp_cache_get_head(void)
|
||||
{
|
||||
return cache_head;
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_CACHE_GET_HEAD */
|
||||
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_CACHE_FIND_BY_OID
|
||||
/** find existing cache
|
||||
*/
|
||||
netsnmp_cache *
|
||||
netsnmp_cache_find_by_oid(const oid * rootoid, int rootoid_len)
|
||||
{
|
||||
netsnmp_cache *cache;
|
||||
|
||||
for (cache = cache_head; cache; cache = cache->next) {
|
||||
if (0 == netsnmp_oid_equals(cache->rootoid, cache->rootoid_len,
|
||||
rootoid, rootoid_len))
|
||||
return cache;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_CACHE_FIND_BY_OID */
|
||||
|
||||
/** returns a cache
|
||||
*/
|
||||
netsnmp_cache *
|
||||
netsnmp_cache_create(int timeout, NetsnmpCacheLoad * load_hook,
|
||||
NetsnmpCacheFree * free_hook,
|
||||
const oid * rootoid, int rootoid_len)
|
||||
{
|
||||
netsnmp_cache *cache = NULL;
|
||||
|
||||
cache = SNMP_MALLOC_TYPEDEF(netsnmp_cache);
|
||||
if (NULL == cache) {
|
||||
snmp_log(LOG_ERR,"malloc error in netsnmp_cache_create\n");
|
||||
return NULL;
|
||||
}
|
||||
cache->timeout = timeout;
|
||||
cache->load_cache = load_hook;
|
||||
cache->free_cache = free_hook;
|
||||
cache->enabled = 1;
|
||||
|
||||
if(0 == cache->timeout)
|
||||
cache->timeout = netsnmp_ds_get_int(NETSNMP_DS_APPLICATION_ID,
|
||||
NETSNMP_DS_AGENT_CACHE_TIMEOUT);
|
||||
|
||||
|
||||
/*
|
||||
* Add the registered OID information, and tack
|
||||
* this onto the list for cache SNMP management
|
||||
*
|
||||
* Note that this list is not ordered.
|
||||
* table_iterator rules again!
|
||||
*/
|
||||
if (rootoid) {
|
||||
cache->rootoid = snmp_duplicate_objid(rootoid, rootoid_len);
|
||||
cache->rootoid_len = rootoid_len;
|
||||
cache->next = cache_head;
|
||||
if (cache_head)
|
||||
cache_head->prev = cache;
|
||||
cache_head = cache;
|
||||
}
|
||||
|
||||
return cache;
|
||||
}
|
||||
|
||||
static netsnmp_cache *
|
||||
netsnmp_cache_ref(netsnmp_cache *cache)
|
||||
{
|
||||
cache->refcnt++;
|
||||
return cache;
|
||||
}
|
||||
|
||||
static void
|
||||
netsnmp_cache_deref(netsnmp_cache *cache)
|
||||
{
|
||||
if (--cache->refcnt == 0) {
|
||||
netsnmp_cache_remove(cache);
|
||||
netsnmp_cache_free(cache);
|
||||
}
|
||||
}
|
||||
|
||||
/** frees a cache
|
||||
*/
|
||||
int
|
||||
netsnmp_cache_free(netsnmp_cache *cache)
|
||||
{
|
||||
netsnmp_cache *pos;
|
||||
|
||||
if (NULL == cache)
|
||||
return SNMPERR_SUCCESS;
|
||||
|
||||
for (pos = cache_head; pos; pos = pos->next) {
|
||||
if (pos == cache) {
|
||||
size_t out_len = 0;
|
||||
size_t buf_len = 0;
|
||||
char *buf = NULL;
|
||||
|
||||
sprint_realloc_objid((u_char **) &buf, &buf_len, &out_len,
|
||||
1, pos->rootoid, pos->rootoid_len);
|
||||
snmp_log(LOG_WARNING,
|
||||
"not freeing cache with root OID %s (still in list)\n",
|
||||
buf);
|
||||
free(buf);
|
||||
return SNMP_ERR_GENERR;
|
||||
}
|
||||
}
|
||||
|
||||
if(0 != cache->timer_id)
|
||||
netsnmp_cache_timer_stop(cache);
|
||||
|
||||
if (cache->valid)
|
||||
_cache_free(cache);
|
||||
|
||||
if (cache->timestampM)
|
||||
free(cache->timestampM);
|
||||
|
||||
if (cache->rootoid)
|
||||
free(cache->rootoid);
|
||||
|
||||
free(cache);
|
||||
|
||||
return SNMPERR_SUCCESS;
|
||||
}
|
||||
|
||||
/** removes a cache
|
||||
*/
|
||||
int
|
||||
netsnmp_cache_remove(netsnmp_cache *cache)
|
||||
{
|
||||
netsnmp_cache *cur,*prev;
|
||||
|
||||
if (!cache || !cache_head)
|
||||
return -1;
|
||||
|
||||
if (cache == cache_head) {
|
||||
cache_head = cache_head->next;
|
||||
if (cache_head)
|
||||
cache_head->prev = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
prev = cache_head;
|
||||
cur = cache_head->next;
|
||||
for (; cur; prev = cur, cur = cur->next) {
|
||||
if (cache == cur) {
|
||||
prev->next = cur->next;
|
||||
if (cur->next)
|
||||
cur->next->prev = cur->prev;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/** callback function to call cache load function */
|
||||
static void
|
||||
_timer_reload(unsigned int regNo, void *clientargs)
|
||||
{
|
||||
netsnmp_cache *cache = (netsnmp_cache *)clientargs;
|
||||
|
||||
DEBUGMSGT(("cache_timer:start", "loading cache %p\n", cache));
|
||||
|
||||
cache->expired = 1;
|
||||
|
||||
_cache_load(cache);
|
||||
}
|
||||
|
||||
/** starts the recurring cache_load callback */
|
||||
unsigned int
|
||||
netsnmp_cache_timer_start(netsnmp_cache *cache)
|
||||
{
|
||||
if(NULL == cache)
|
||||
return 0;
|
||||
|
||||
DEBUGMSGTL(( "cache_timer:start", "OID: "));
|
||||
DEBUGMSGOID(("cache_timer:start", cache->rootoid, cache->rootoid_len));
|
||||
DEBUGMSG(( "cache_timer:start", "\n"));
|
||||
|
||||
if(0 != cache->timer_id) {
|
||||
snmp_log(LOG_WARNING, "cache has existing timer id.\n");
|
||||
return cache->timer_id;
|
||||
}
|
||||
|
||||
if(! (cache->flags & NETSNMP_CACHE_AUTO_RELOAD)) {
|
||||
snmp_log(LOG_ERR,
|
||||
"cache_timer_start called but auto_reload not set.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
cache->timer_id = snmp_alarm_register(cache->timeout, SA_REPEAT,
|
||||
_timer_reload, cache);
|
||||
if(0 == cache->timer_id) {
|
||||
snmp_log(LOG_ERR,"could not register alarm\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
cache->flags &= ~NETSNMP_CACHE_AUTO_RELOAD;
|
||||
DEBUGMSGT(("cache_timer:start",
|
||||
"starting timer %lu for cache %p\n", cache->timer_id, cache));
|
||||
return cache->timer_id;
|
||||
}
|
||||
|
||||
/** stops the recurring cache_load callback */
|
||||
void
|
||||
netsnmp_cache_timer_stop(netsnmp_cache *cache)
|
||||
{
|
||||
if(NULL == cache)
|
||||
return;
|
||||
|
||||
if(0 == cache->timer_id) {
|
||||
snmp_log(LOG_WARNING, "cache has no timer id.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUGMSGT(("cache_timer:stop",
|
||||
"stopping timer %lu for cache %p\n", cache->timer_id, cache));
|
||||
|
||||
snmp_alarm_unregister(cache->timer_id);
|
||||
cache->flags |= NETSNMP_CACHE_AUTO_RELOAD;
|
||||
}
|
||||
|
||||
|
||||
/** returns a cache handler that can be injected into a given handler chain.
|
||||
*/
|
||||
netsnmp_mib_handler *
|
||||
netsnmp_cache_handler_get(netsnmp_cache* cache)
|
||||
{
|
||||
netsnmp_mib_handler *ret = NULL;
|
||||
|
||||
ret = netsnmp_create_handler("cache_handler",
|
||||
netsnmp_cache_helper_handler);
|
||||
if (ret) {
|
||||
ret->flags |= MIB_HANDLER_AUTO_NEXT;
|
||||
ret->myvoid = (void *) cache;
|
||||
|
||||
if(NULL != cache) {
|
||||
if ((cache->flags & NETSNMP_CACHE_PRELOAD) && ! cache->valid) {
|
||||
/*
|
||||
* load cache, ignore rc
|
||||
* (failed load doesn't affect registration)
|
||||
*/
|
||||
(void)_cache_load(cache);
|
||||
}
|
||||
if (cache->flags & NETSNMP_CACHE_AUTO_RELOAD)
|
||||
netsnmp_cache_timer_start(cache);
|
||||
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/** Makes sure that memory allocated for the cache is freed when the handler
|
||||
* is unregistered.
|
||||
*/
|
||||
void netsnmp_cache_handler_owns_cache(netsnmp_mib_handler *handler)
|
||||
{
|
||||
netsnmp_assert(handler->myvoid);
|
||||
((netsnmp_cache *)handler->myvoid)->refcnt++;
|
||||
handler->data_clone = (void *(*)(void *))netsnmp_cache_ref;
|
||||
handler->data_free = (void(*)(void*))netsnmp_cache_deref;
|
||||
}
|
||||
|
||||
/** returns a cache handler that can be injected into a given handler chain.
|
||||
*/
|
||||
netsnmp_mib_handler *
|
||||
netsnmp_get_cache_handler(int timeout, NetsnmpCacheLoad * load_hook,
|
||||
NetsnmpCacheFree * free_hook,
|
||||
const oid * rootoid, int rootoid_len)
|
||||
{
|
||||
netsnmp_mib_handler *ret = NULL;
|
||||
netsnmp_cache *cache = NULL;
|
||||
|
||||
ret = netsnmp_cache_handler_get(NULL);
|
||||
if (ret) {
|
||||
cache = netsnmp_cache_create(timeout, load_hook, free_hook,
|
||||
rootoid, rootoid_len);
|
||||
ret->myvoid = (void *) cache;
|
||||
netsnmp_cache_handler_owns_cache(ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/** functionally the same as calling netsnmp_register_handler() but also
|
||||
* injects a cache handler at the same time for you. */
|
||||
netsnmp_feature_child_of(netsnmp_cache_handler_register,netsnmp_unused)
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_NETSNMP_CACHE_HANDLER_REGISTER
|
||||
int
|
||||
netsnmp_cache_handler_register(netsnmp_handler_registration * reginfo,
|
||||
netsnmp_cache* cache)
|
||||
{
|
||||
netsnmp_mib_handler *handler = NULL;
|
||||
handler = netsnmp_cache_handler_get(cache);
|
||||
|
||||
netsnmp_inject_handler(reginfo, handler);
|
||||
return netsnmp_register_handler(reginfo);
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_NETSNMP_CACHE_HANDLER_REGISTER */
|
||||
|
||||
/** functionally the same as calling netsnmp_register_handler() but also
|
||||
* injects a cache handler at the same time for you. */
|
||||
netsnmp_feature_child_of(netsnmp_register_cache_handler,netsnmp_unused)
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_NETSNMP_REGISTER_CACHE_HANDLER
|
||||
int
|
||||
netsnmp_register_cache_handler(netsnmp_handler_registration * reginfo,
|
||||
int timeout, NetsnmpCacheLoad * load_hook,
|
||||
NetsnmpCacheFree * free_hook)
|
||||
{
|
||||
netsnmp_mib_handler *handler = NULL;
|
||||
handler = netsnmp_get_cache_handler(timeout, load_hook, free_hook,
|
||||
reginfo->rootoid,
|
||||
reginfo->rootoid_len);
|
||||
|
||||
netsnmp_inject_handler(reginfo, handler);
|
||||
return netsnmp_register_handler(reginfo);
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_NETSNMP_REGISTER_CACHE_HANDLER */
|
||||
|
||||
static char *
|
||||
_build_cache_name(const char *name)
|
||||
{
|
||||
char *dup = (char*)malloc(strlen(name) + strlen(CACHE_NAME) + 2);
|
||||
if (NULL == dup)
|
||||
return NULL;
|
||||
sprintf(dup, "%s:%s", CACHE_NAME, name);
|
||||
return dup;
|
||||
}
|
||||
|
||||
/** Insert the cache information for a given request (PDU) */
|
||||
void
|
||||
netsnmp_cache_reqinfo_insert(netsnmp_cache* cache,
|
||||
netsnmp_agent_request_info * reqinfo,
|
||||
const char *name)
|
||||
{
|
||||
char *cache_name = _build_cache_name(name);
|
||||
if (NULL == netsnmp_agent_get_list_data(reqinfo, cache_name)) {
|
||||
DEBUGMSGTL(("verbose:helper:cache_handler", " adding '%s' to %p\n",
|
||||
cache_name, reqinfo));
|
||||
netsnmp_agent_add_list_data(reqinfo,
|
||||
netsnmp_create_data_list(cache_name,
|
||||
cache, NULL));
|
||||
}
|
||||
SNMP_FREE(cache_name);
|
||||
}
|
||||
|
||||
/** Extract the cache information for a given request (PDU) */
|
||||
netsnmp_cache *
|
||||
netsnmp_cache_reqinfo_extract(netsnmp_agent_request_info * reqinfo,
|
||||
const char *name)
|
||||
{
|
||||
netsnmp_cache *result;
|
||||
char *cache_name = _build_cache_name(name);
|
||||
result = (netsnmp_cache*)netsnmp_agent_get_list_data(reqinfo, cache_name);
|
||||
SNMP_FREE(cache_name);
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Extract the cache information for a given request (PDU) */
|
||||
netsnmp_feature_child_of(netsnmp_extract_cache_info,netsnmp_unused)
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_NETSNMP_EXTRACT_CACHE_INFO
|
||||
netsnmp_cache *
|
||||
netsnmp_extract_cache_info(netsnmp_agent_request_info * reqinfo)
|
||||
{
|
||||
return netsnmp_cache_reqinfo_extract(reqinfo, CACHE_NAME);
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_NETSNMP_EXTRACT_CACHE_INFO */
|
||||
|
||||
|
||||
/** Check if the cache timeout has passed. Sets and return the expired flag. */
|
||||
int
|
||||
netsnmp_cache_check_expired(netsnmp_cache *cache)
|
||||
{
|
||||
if(NULL == cache)
|
||||
return 0;
|
||||
if (cache->expired)
|
||||
return 1;
|
||||
if(!cache->valid || (NULL == cache->timestampM) || (-1 == cache->timeout))
|
||||
cache->expired = 1;
|
||||
else
|
||||
cache->expired = netsnmp_ready_monotonic(cache->timestampM,
|
||||
1000 * cache->timeout);
|
||||
|
||||
return cache->expired;
|
||||
}
|
||||
|
||||
/** Reload the cache if required */
|
||||
int
|
||||
netsnmp_cache_check_and_reload(netsnmp_cache * cache)
|
||||
{
|
||||
if (!cache) {
|
||||
DEBUGMSGT(("helper:cache_handler", " no cache\n"));
|
||||
return 0; /* ?? or -1 */
|
||||
}
|
||||
if (!cache->valid || netsnmp_cache_check_expired(cache))
|
||||
return _cache_load( cache );
|
||||
else {
|
||||
DEBUGMSGT(("helper:cache_handler", " cached (%d)\n",
|
||||
cache->timeout));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/** Is the cache valid for a given request? */
|
||||
int
|
||||
netsnmp_cache_is_valid(netsnmp_agent_request_info * reqinfo,
|
||||
const char* name)
|
||||
{
|
||||
netsnmp_cache *cache = netsnmp_cache_reqinfo_extract(reqinfo, name);
|
||||
return (cache && cache->valid);
|
||||
}
|
||||
|
||||
/** Is the cache valid for a given request?
|
||||
* for backwards compatability. netsnmp_cache_is_valid() is preferred.
|
||||
*/
|
||||
netsnmp_feature_child_of(netsnmp_is_cache_valid,netsnmp_unused)
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_NETSNMP_IS_CACHE_VALID
|
||||
int
|
||||
netsnmp_is_cache_valid(netsnmp_agent_request_info * reqinfo)
|
||||
{
|
||||
return netsnmp_cache_is_valid(reqinfo, CACHE_NAME);
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_NETSNMP_IS_CACHE_VALID */
|
||||
|
||||
/** Implements the cache handler */
|
||||
int
|
||||
netsnmp_cache_helper_handler(netsnmp_mib_handler * handler,
|
||||
netsnmp_handler_registration * reginfo,
|
||||
netsnmp_agent_request_info * reqinfo,
|
||||
netsnmp_request_info * requests)
|
||||
{
|
||||
char addrstr[32];
|
||||
|
||||
netsnmp_cache *cache = NULL;
|
||||
netsnmp_handler_args cache_hint;
|
||||
|
||||
DEBUGMSGTL(("helper:cache_handler", "Got request (%d) for %s: ",
|
||||
reqinfo->mode, reginfo->handlerName));
|
||||
DEBUGMSGOID(("helper:cache_handler", reginfo->rootoid,
|
||||
reginfo->rootoid_len));
|
||||
DEBUGMSG(("helper:cache_handler", "\n"));
|
||||
|
||||
netsnmp_assert(handler->flags & MIB_HANDLER_AUTO_NEXT);
|
||||
|
||||
cache = (netsnmp_cache *) handler->myvoid;
|
||||
if (netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
|
||||
NETSNMP_DS_AGENT_NO_CACHING) ||
|
||||
!cache || !cache->enabled || !cache->load_cache) {
|
||||
DEBUGMSGT(("helper:cache_handler", " caching disabled or "
|
||||
"cache not found, disabled or had no load method\n"));
|
||||
return SNMP_ERR_NOERROR;
|
||||
}
|
||||
snprintf(addrstr,sizeof(addrstr), "%ld", (long int)cache);
|
||||
DEBUGMSGTL(("helper:cache_handler", "using cache %s: ", addrstr));
|
||||
DEBUGMSGOID(("helper:cache_handler", cache->rootoid, cache->rootoid_len));
|
||||
DEBUGMSG(("helper:cache_handler", "\n"));
|
||||
|
||||
/*
|
||||
* Make the handler-chain parameters available to
|
||||
* the cache_load hook routine.
|
||||
*/
|
||||
cache_hint.handler = handler;
|
||||
cache_hint.reginfo = reginfo;
|
||||
cache_hint.reqinfo = reqinfo;
|
||||
cache_hint.requests = requests;
|
||||
cache->cache_hint = &cache_hint;
|
||||
|
||||
switch (reqinfo->mode) {
|
||||
|
||||
case MODE_GET:
|
||||
case MODE_GETNEXT:
|
||||
case MODE_GETBULK:
|
||||
#ifndef NETSNMP_NO_WRITE_SUPPORT
|
||||
case MODE_SET_RESERVE1:
|
||||
#endif /* !NETSNMP_NO_WRITE_SUPPORT */
|
||||
|
||||
/*
|
||||
* only touch cache once per pdu request, to prevent a cache
|
||||
* reload while a module is using cached data.
|
||||
*
|
||||
* XXX: this won't catch a request reloading the cache while
|
||||
* a previous (delegated) request is still using the cache.
|
||||
* maybe use a reference counter?
|
||||
*/
|
||||
if (netsnmp_cache_is_valid(reqinfo, addrstr))
|
||||
break;
|
||||
|
||||
/*
|
||||
* call the load hook, and update the cache timestamp.
|
||||
* If it's not already there, add to reqinfo
|
||||
*/
|
||||
netsnmp_cache_check_and_reload(cache);
|
||||
netsnmp_cache_reqinfo_insert(cache, reqinfo, addrstr);
|
||||
/** next handler called automatically - 'AUTO_NEXT' */
|
||||
break;
|
||||
|
||||
#ifndef NETSNMP_NO_WRITE_SUPPORT
|
||||
case MODE_SET_RESERVE2:
|
||||
case MODE_SET_FREE:
|
||||
case MODE_SET_ACTION:
|
||||
case MODE_SET_UNDO:
|
||||
netsnmp_assert(netsnmp_cache_is_valid(reqinfo, addrstr));
|
||||
/** next handler called automatically - 'AUTO_NEXT' */
|
||||
break;
|
||||
|
||||
/*
|
||||
* A (successful) SET request wouldn't typically trigger a reload of
|
||||
* the cache, but might well invalidate the current contents.
|
||||
* Only do this on the last pass through.
|
||||
*/
|
||||
case MODE_SET_COMMIT:
|
||||
if (cache->valid &&
|
||||
! (cache->flags & NETSNMP_CACHE_DONT_INVALIDATE_ON_SET) ) {
|
||||
cache->free_cache(cache, cache->magic);
|
||||
cache->valid = 0;
|
||||
}
|
||||
/** next handler called automatically - 'AUTO_NEXT' */
|
||||
break;
|
||||
#endif /* NETSNMP_NO_WRITE_SUPPORT */
|
||||
|
||||
default:
|
||||
snmp_log(LOG_WARNING, "cache_handler: Unrecognised mode (%d)\n",
|
||||
reqinfo->mode);
|
||||
netsnmp_request_set_error_all(requests, SNMP_ERR_GENERR);
|
||||
return SNMP_ERR_GENERR;
|
||||
}
|
||||
if (cache->flags & NETSNMP_CACHE_RESET_TIMER_ON_USE)
|
||||
netsnmp_set_monotonic_marker(&cache->timestampM);
|
||||
return SNMP_ERR_NOERROR;
|
||||
}
|
||||
|
||||
static void
|
||||
_cache_free( netsnmp_cache *cache )
|
||||
{
|
||||
if (NULL != cache->free_cache) {
|
||||
cache->free_cache(cache, cache->magic);
|
||||
cache->valid = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
_cache_load( netsnmp_cache *cache )
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
/*
|
||||
* If we've got a valid cache, then release it before reloading
|
||||
*/
|
||||
if (cache->valid &&
|
||||
(! (cache->flags & NETSNMP_CACHE_DONT_FREE_BEFORE_LOAD)))
|
||||
_cache_free(cache);
|
||||
|
||||
if ( cache->load_cache)
|
||||
ret = cache->load_cache(cache, cache->magic);
|
||||
if (ret < 0) {
|
||||
DEBUGMSGT(("helper:cache_handler", " load failed (%d)\n", ret));
|
||||
cache->valid = 0;
|
||||
return ret;
|
||||
}
|
||||
cache->valid = 1;
|
||||
cache->expired = 0;
|
||||
|
||||
/*
|
||||
* If we didn't previously have any valid caches outstanding,
|
||||
* then schedule a pass of the auto-release routine.
|
||||
*/
|
||||
if ((!cache_outstanding_valid) &&
|
||||
(! (cache->flags & NETSNMP_CACHE_DONT_FREE_EXPIRED))) {
|
||||
snmp_alarm_register(CACHE_RELEASE_FREQUENCY,
|
||||
0, release_cached_resources, NULL);
|
||||
cache_outstanding_valid = 1;
|
||||
}
|
||||
netsnmp_set_monotonic_marker(&cache->timestampM);
|
||||
DEBUGMSGT(("helper:cache_handler", " loaded (%d)\n", cache->timeout));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** run regularly to automatically release cached resources.
|
||||
* xxx - method to prevent cache from expiring while a request
|
||||
* is being processed (e.g. delegated request). proposal:
|
||||
* set a flag, which would be cleared when request finished
|
||||
* (which could be acomplished by a dummy data list item in
|
||||
* agent req info & custom free function).
|
||||
*/
|
||||
void
|
||||
release_cached_resources(unsigned int regNo, void *clientargs)
|
||||
{
|
||||
netsnmp_cache *cache = NULL;
|
||||
|
||||
cache_outstanding_valid = 0;
|
||||
DEBUGMSGTL(("helper:cache_handler", "running auto-release\n"));
|
||||
for (cache = cache_head; cache; cache = cache->next) {
|
||||
DEBUGMSGTL(("helper:cache_handler"," checking %p (flags 0x%x)\n",
|
||||
cache, cache->flags));
|
||||
if (cache->valid &&
|
||||
! (cache->flags & NETSNMP_CACHE_DONT_AUTO_RELEASE)) {
|
||||
DEBUGMSGTL(("helper:cache_handler"," releasing %p\n", cache));
|
||||
/*
|
||||
* Check to see if this cache has timed out.
|
||||
* If so, release the cached resources.
|
||||
* Otherwise, note that we still have at
|
||||
* least one active cache.
|
||||
*/
|
||||
if (netsnmp_cache_check_expired(cache)) {
|
||||
if(! (cache->flags & NETSNMP_CACHE_DONT_FREE_EXPIRED))
|
||||
_cache_free(cache);
|
||||
} else {
|
||||
cache_outstanding_valid = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* If there are any caches still valid & active,
|
||||
* then schedule another pass.
|
||||
*/
|
||||
if (cache_outstanding_valid) {
|
||||
snmp_alarm_register(CACHE_RELEASE_FREQUENCY,
|
||||
0, release_cached_resources, NULL);
|
||||
}
|
||||
}
|
||||
/** @} */
|
||||
|
||||
@@ -1,166 +0,0 @@
|
||||
/* Portions of this file are subject to the following copyright(s). See
|
||||
* the Net-SNMP's COPYING file for more details and other copyrights
|
||||
* that may apply:
|
||||
*/
|
||||
/*
|
||||
* Portions of this file are copyrighted by:
|
||||
* Copyright <20> 2003 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms specified in the COPYING file
|
||||
* distributed with the Net-SNMP package.
|
||||
*/
|
||||
#include <net-snmp/net-snmp-config.h>
|
||||
#include <net-snmp/net-snmp-includes.h>
|
||||
#include <net-snmp/agent/net-snmp-agent-includes.h>
|
||||
|
||||
#include <net-snmp/agent/debug_handler.h>
|
||||
|
||||
/** @defgroup debug debug
|
||||
* Print out debugging information about the handler chain being called.
|
||||
* This is a useful module for run-time
|
||||
* debugging of requests as the pass this handler in a calling chain.
|
||||
* All debugging output is done via the standard debugging routines
|
||||
* with a token name of "helper:debug", so use the -Dhelper:debug
|
||||
* command line flag to see the output when running the snmpd
|
||||
* demon. It's not recommended you compile this into a handler chain
|
||||
* during compile time, but instead use the "injectHandler" token in
|
||||
* the snmpd.conf file (or similar) to add it to the chain later:
|
||||
*
|
||||
* injectHandler debug my_module_name
|
||||
*
|
||||
* to see an example output, try:
|
||||
*
|
||||
* injectHandler debug mibII/system
|
||||
*
|
||||
* and then run snmpwalk on the "system" group.
|
||||
*
|
||||
* @ingroup utilities
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** returns a debug handler that can be injected into a given
|
||||
* handler chain.
|
||||
*/
|
||||
netsnmp_mib_handler *
|
||||
netsnmp_get_debug_handler(void)
|
||||
{
|
||||
return netsnmp_create_handler("debug", netsnmp_debug_helper);
|
||||
}
|
||||
|
||||
#ifdef NETSNMP_NO_DEBUGGING
|
||||
|
||||
#define debug_print_requests(x)
|
||||
|
||||
#else /* NETSNMP_NO_DEBUGGING */
|
||||
|
||||
/** @internal debug print variables in a chain */
|
||||
static void
|
||||
debug_print_requests(netsnmp_request_info *requests)
|
||||
{
|
||||
netsnmp_request_info *request;
|
||||
|
||||
for (request = requests; request; request = request->next) {
|
||||
DEBUGMSGTL(("helper:debug", " #%2d: ", request->index));
|
||||
DEBUGMSGVAR(("helper:debug", request->requestvb));
|
||||
DEBUGMSG(("helper:debug", "\n"));
|
||||
|
||||
if (request->processed)
|
||||
DEBUGMSGTL(("helper:debug", " [processed]\n"));
|
||||
if (request->delegated)
|
||||
DEBUGMSGTL(("helper:debug", " [delegated]\n"));
|
||||
if (request->status)
|
||||
DEBUGMSGTL(("helper:debug", " [status = %d]\n",
|
||||
request->status));
|
||||
if (request->parent_data) {
|
||||
netsnmp_data_list *lst;
|
||||
DEBUGMSGTL(("helper:debug", " [parent data ="));
|
||||
for (lst = request->parent_data; lst; lst = lst->next) {
|
||||
DEBUGMSG(("helper:debug", " %s", lst->name));
|
||||
}
|
||||
DEBUGMSG(("helper:debug", "]\n"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* NETSNMP_NO_DEBUGGING */
|
||||
|
||||
/** @internal Implements the debug handler */
|
||||
int
|
||||
netsnmp_debug_helper(netsnmp_mib_handler *handler,
|
||||
netsnmp_handler_registration *reginfo,
|
||||
netsnmp_agent_request_info *reqinfo,
|
||||
netsnmp_request_info *requests)
|
||||
{
|
||||
int ret;
|
||||
|
||||
DEBUGIF("helper:debug") {
|
||||
netsnmp_mib_handler *hptr;
|
||||
char *cp;
|
||||
int i, count;
|
||||
|
||||
DEBUGMSGTL(("helper:debug", "Entering Debugging Helper:\n"));
|
||||
DEBUGMSGTL(("helper:debug", " Handler Registration Info:\n"));
|
||||
DEBUGMSGTL(("helper:debug", " Name: %s\n",
|
||||
reginfo->handlerName));
|
||||
DEBUGMSGTL(("helper:debug", " Context: %s\n",
|
||||
SNMP_STRORNULL(reginfo->contextName)));
|
||||
DEBUGMSGTL(("helper:debug", " Base OID: "));
|
||||
DEBUGMSGOID(("helper:debug", reginfo->rootoid, reginfo->rootoid_len));
|
||||
DEBUGMSG(("helper:debug", "\n"));
|
||||
|
||||
DEBUGMSGTL(("helper:debug", " Modes: 0x%x = ",
|
||||
reginfo->modes));
|
||||
for (count = 0, i = reginfo->modes; i; i = i >> 1, count++) {
|
||||
if (i & 0x01) {
|
||||
cp = se_find_label_in_slist("handler_can_mode",
|
||||
0x01 << count);
|
||||
DEBUGMSG(("helper:debug", "%s | ", SNMP_STRORNULL(cp)));
|
||||
}
|
||||
}
|
||||
DEBUGMSG(("helper:debug", "\n"));
|
||||
|
||||
DEBUGMSGTL(("helper:debug", " Priority: %d\n",
|
||||
reginfo->priority));
|
||||
|
||||
DEBUGMSGTL(("helper:debug", " Handler Calling Chain:\n"));
|
||||
DEBUGMSGTL(("helper:debug", " "));
|
||||
for (hptr = reginfo->handler; hptr; hptr = hptr->next) {
|
||||
DEBUGMSG(("helper:debug", " -> %s", hptr->handler_name));
|
||||
if (hptr->myvoid)
|
||||
DEBUGMSG(("helper:debug", " [myvoid = %p]", hptr->myvoid));
|
||||
}
|
||||
DEBUGMSG(("helper:debug", "\n"));
|
||||
|
||||
DEBUGMSGTL(("helper:debug", " Request information:\n"));
|
||||
DEBUGMSGTL(("helper:debug", " Mode: %s (%d = 0x%x)\n",
|
||||
se_find_label_in_slist("agent_mode", reqinfo->mode),
|
||||
reqinfo->mode, reqinfo->mode));
|
||||
DEBUGMSGTL(("helper:debug", " Request Variables:\n"));
|
||||
debug_print_requests(requests);
|
||||
|
||||
DEBUGMSGTL(("helper:debug", " --- calling next handler --- \n"));
|
||||
}
|
||||
|
||||
ret = netsnmp_call_next_handler(handler, reginfo, reqinfo, requests);
|
||||
|
||||
DEBUGIF("helper:debug") {
|
||||
DEBUGMSGTL(("helper:debug", " Results:\n"));
|
||||
DEBUGMSGTL(("helper:debug", " Returned code: %d\n", ret));
|
||||
DEBUGMSGTL(("helper:debug", " Returned Variables:\n"));
|
||||
debug_print_requests(requests);
|
||||
|
||||
DEBUGMSGTL(("helper:debug", "Exiting Debugging Helper:\n"));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/** initializes the debug helper which then registers a debug
|
||||
* handler as a run-time injectable handler for configuration file
|
||||
* use.
|
||||
*/
|
||||
void
|
||||
netsnmp_init_debug_helper(void)
|
||||
{
|
||||
netsnmp_register_handler_by_name("debug", netsnmp_get_debug_handler());
|
||||
}
|
||||
/** @} */
|
||||
@@ -1 +0,0 @@
|
||||
char const netsnmp_helpers_dummy_text[] = "dummy symbol to make sure that linking netsnmphelpers does not fail on systems that do not support empty libraries.";
|
||||
@@ -1,807 +0,0 @@
|
||||
/* Portions of this file are subject to the following copyright(s). See
|
||||
* the Net-SNMP's COPYING file for more details and other copyrights
|
||||
* that may apply:
|
||||
*/
|
||||
/*
|
||||
* Portions of this file are copyrighted by:
|
||||
* Copyright <20> 2003 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms specified in the COPYING file
|
||||
* distributed with the Net-SNMP package.
|
||||
*/
|
||||
#include <net-snmp/net-snmp-config.h>
|
||||
#include <net-snmp/net-snmp-features.h>
|
||||
|
||||
#include <net-snmp/net-snmp-includes.h>
|
||||
#include <net-snmp/agent/net-snmp-agent-includes.h>
|
||||
|
||||
#include <net-snmp/agent/instance.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#if HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#else
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#include <net-snmp/net-snmp-includes.h>
|
||||
#include <net-snmp/agent/serialize.h>
|
||||
#include <net-snmp/agent/read_only.h>
|
||||
|
||||
netsnmp_feature_provide(instance)
|
||||
netsnmp_feature_child_of(instance, mib_helpers)
|
||||
|
||||
typedef struct netsnmp_num_file_instance_s {
|
||||
int refcnt;
|
||||
char *file_name;
|
||||
FILE *filep;
|
||||
u_char type;
|
||||
int flags;
|
||||
} netsnmp_num_file_instance;
|
||||
|
||||
/** @defgroup instance instance
|
||||
* Process individual MIB instances easily.
|
||||
* @ingroup leaf
|
||||
* @{
|
||||
*/
|
||||
|
||||
static netsnmp_num_file_instance *
|
||||
netsnmp_num_file_instance_ref(netsnmp_num_file_instance *nfi)
|
||||
{
|
||||
nfi->refcnt++;
|
||||
return nfi;
|
||||
}
|
||||
|
||||
static void
|
||||
netsnmp_num_file_instance_deref(netsnmp_num_file_instance *nfi)
|
||||
{
|
||||
if (--nfi->refcnt == 0) {
|
||||
free(nfi->file_name);
|
||||
free(nfi);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance helper handler, calls netsnmp_create_handler, which
|
||||
* then could be registered, using netsnmp_register_handler().
|
||||
*
|
||||
* @return Returns a pointer to a netsnmp_mib_handler struct which contains
|
||||
* the handler's name and the access method
|
||||
*/
|
||||
netsnmp_mib_handler *
|
||||
netsnmp_get_instance_handler(void)
|
||||
{
|
||||
return netsnmp_create_handler("instance",
|
||||
netsnmp_instance_helper_handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function registers an instance helper handler, which is a way of
|
||||
* registering an exact OID such that GENEXT requests are handled entirely
|
||||
* by the helper. First need to inject it into the calling chain of the
|
||||
* handler defined by the netsnmp_handler_registration struct, reginfo.
|
||||
* The new handler is injected at the top of the list and will be the new
|
||||
* handler to be called first. This function also injects a serialize
|
||||
* handler before actually calling netsnmp_register_handle, registering
|
||||
* reginfo.
|
||||
*
|
||||
* @param reginfo a handler registration structure which could get created
|
||||
* using netsnmp_create_handler_registration. Used to register
|
||||
* an instance helper handler.
|
||||
*
|
||||
* @return
|
||||
* MIB_REGISTERED_OK is returned if the registration was a success.
|
||||
* Failures are MIB_REGISTRATION_FAILED and MIB_DUPLICATE_REGISTRATION.
|
||||
*/
|
||||
int
|
||||
netsnmp_register_instance(netsnmp_handler_registration *reginfo)
|
||||
{
|
||||
netsnmp_mib_handler *handler = netsnmp_get_instance_handler();
|
||||
handler->flags |= MIB_HANDLER_INSTANCE;
|
||||
netsnmp_inject_handler(reginfo, handler);
|
||||
return netsnmp_register_serialize(reginfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function injects a "read only" handler into the handler chain
|
||||
* prior to serializing/registering the handler.
|
||||
*
|
||||
* The only purpose of this "read only" handler is to return an
|
||||
* appropriate error for any requests passed to it in a SET mode.
|
||||
* Inserting it into your handler chain will ensure you're never
|
||||
* asked to perform a SET request so you can ignore those error
|
||||
* conditions.
|
||||
*
|
||||
* @param reginfo a handler registration structure which could get created
|
||||
* using netsnmp_create_handler_registration. Used to register
|
||||
* a read only instance helper handler.
|
||||
*
|
||||
* @return
|
||||
* MIB_REGISTERED_OK is returned if the registration was a success.
|
||||
* Failures are MIB_REGISTRATION_FAILED and MIB_DUPLICATE_REGISTRATION.
|
||||
*/
|
||||
int
|
||||
netsnmp_register_read_only_instance(netsnmp_handler_registration *reginfo)
|
||||
{
|
||||
netsnmp_inject_handler(reginfo, netsnmp_get_instance_handler());
|
||||
netsnmp_inject_handler(reginfo, netsnmp_get_read_only_handler());
|
||||
return netsnmp_register_serialize(reginfo);
|
||||
}
|
||||
|
||||
static
|
||||
netsnmp_handler_registration *
|
||||
get_reg(const char *name,
|
||||
const char *ourname,
|
||||
const oid * reg_oid, size_t reg_oid_len,
|
||||
netsnmp_num_file_instance *it,
|
||||
int modes,
|
||||
Netsnmp_Node_Handler * scalarh, Netsnmp_Node_Handler * subhandler,
|
||||
const char *contextName)
|
||||
{
|
||||
netsnmp_handler_registration *myreg;
|
||||
netsnmp_mib_handler *myhandler;
|
||||
|
||||
if (subhandler) {
|
||||
myreg =
|
||||
netsnmp_create_handler_registration(name,
|
||||
subhandler,
|
||||
reg_oid, reg_oid_len,
|
||||
modes);
|
||||
myhandler = netsnmp_create_handler(ourname, scalarh);
|
||||
myhandler->myvoid = it;
|
||||
myhandler->data_clone = (void*(*)(void*))netsnmp_num_file_instance_ref;
|
||||
myhandler->data_free = (void(*)(void*))netsnmp_num_file_instance_deref;
|
||||
netsnmp_inject_handler(myreg, myhandler);
|
||||
} else {
|
||||
myreg =
|
||||
netsnmp_create_handler_registration(name,
|
||||
scalarh,
|
||||
reg_oid, reg_oid_len,
|
||||
modes);
|
||||
myreg->handler->myvoid = it;
|
||||
myreg->handler->data_clone
|
||||
= (void *(*)(void *))netsnmp_num_file_instance_ref;
|
||||
myreg->handler->data_free
|
||||
= (void (*)(void *))netsnmp_num_file_instance_deref;
|
||||
}
|
||||
if (contextName)
|
||||
myreg->contextName = strdup(contextName);
|
||||
return myreg;
|
||||
}
|
||||
|
||||
/* Watched 'long' instances are writable on both 32-bit and 64-bit systems */
|
||||
netsnmp_feature_child_of(read_only_ulong_instance,instance)
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_READ_ONLY_ULONG_INSTANCE
|
||||
int
|
||||
netsnmp_register_read_only_ulong_instance(const char *name,
|
||||
const oid * reg_oid,
|
||||
size_t reg_oid_len, u_long * it,
|
||||
Netsnmp_Node_Handler *
|
||||
subhandler)
|
||||
{
|
||||
return netsnmp_register_watched_instance2(
|
||||
netsnmp_create_handler_registration(
|
||||
name, subhandler, reg_oid, reg_oid_len, HANDLER_CAN_RONLY),
|
||||
netsnmp_create_watcher_info(
|
||||
(void *)it, sizeof(u_long),
|
||||
ASN_UNSIGNED, WATCHER_FIXED_SIZE));
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_READ_ONLY_ULONG_INSTANCE */
|
||||
|
||||
netsnmp_feature_child_of(ulong_instance,instance)
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_ULONG_INSTANCE
|
||||
int
|
||||
netsnmp_register_ulong_instance(const char *name,
|
||||
const oid * reg_oid, size_t reg_oid_len,
|
||||
u_long * it,
|
||||
Netsnmp_Node_Handler * subhandler)
|
||||
{
|
||||
return netsnmp_register_watched_instance2(
|
||||
netsnmp_create_handler_registration(
|
||||
name, subhandler, reg_oid, reg_oid_len, HANDLER_CAN_RWRITE),
|
||||
netsnmp_create_watcher_info(
|
||||
(void *)it, sizeof(u_long),
|
||||
ASN_UNSIGNED, WATCHER_FIXED_SIZE));
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_ULONG_INSTANCE */
|
||||
|
||||
netsnmp_feature_child_of(read_only_counter32_instance,instance)
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_READ_ONLY_COUNTER32_INSTANCE
|
||||
int
|
||||
netsnmp_register_read_only_counter32_instance(const char *name,
|
||||
const oid * reg_oid,
|
||||
size_t reg_oid_len,
|
||||
u_long * it,
|
||||
Netsnmp_Node_Handler *
|
||||
subhandler)
|
||||
{
|
||||
return netsnmp_register_watched_instance2(
|
||||
netsnmp_create_handler_registration(
|
||||
name, subhandler, reg_oid, reg_oid_len, HANDLER_CAN_RONLY),
|
||||
netsnmp_create_watcher_info(
|
||||
(void *)it, sizeof(u_long),
|
||||
ASN_COUNTER, WATCHER_FIXED_SIZE));
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_READ_ONLY_COUNTER32_INSTANCE */
|
||||
|
||||
netsnmp_feature_child_of(read_only_long_instance,instance)
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_READ_ONLY_LONG_INSTANCE
|
||||
int
|
||||
netsnmp_register_read_only_long_instance(const char *name,
|
||||
const oid * reg_oid,
|
||||
size_t reg_oid_len,
|
||||
long *it,
|
||||
Netsnmp_Node_Handler * subhandler)
|
||||
{
|
||||
return netsnmp_register_watched_instance2(
|
||||
netsnmp_create_handler_registration(
|
||||
name, subhandler, reg_oid, reg_oid_len, HANDLER_CAN_RONLY),
|
||||
netsnmp_create_watcher_info(
|
||||
(void *)it, sizeof(long), ASN_INTEGER, WATCHER_FIXED_SIZE));
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_READ_ONLY_LONG_INSTANCE */
|
||||
|
||||
netsnmp_feature_child_of(long_instance,instance)
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_LONG_INSTANCE
|
||||
int
|
||||
netsnmp_register_long_instance(const char *name,
|
||||
const oid * reg_oid, size_t reg_oid_len,
|
||||
long *it, Netsnmp_Node_Handler * subhandler)
|
||||
{
|
||||
return netsnmp_register_watched_instance2(
|
||||
netsnmp_create_handler_registration(
|
||||
name, subhandler, reg_oid, reg_oid_len, HANDLER_CAN_RWRITE),
|
||||
netsnmp_create_watcher_info(
|
||||
(void *)it, sizeof(long), ASN_INTEGER, WATCHER_FIXED_SIZE));
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_LONG_INSTANCE */
|
||||
|
||||
/* Watched 'int' instances are only writable on 32-bit systems */
|
||||
netsnmp_feature_child_of(read_only_uint_instance,instance)
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_READ_ONLY_UINT_INSTANCE
|
||||
int
|
||||
netsnmp_register_read_only_uint_instance(const char *name,
|
||||
const oid * reg_oid,
|
||||
size_t reg_oid_len,
|
||||
unsigned int *it,
|
||||
Netsnmp_Node_Handler * subhandler)
|
||||
{
|
||||
return netsnmp_register_watched_instance2(
|
||||
netsnmp_create_handler_registration(
|
||||
name, subhandler, reg_oid, reg_oid_len, HANDLER_CAN_RONLY),
|
||||
netsnmp_create_watcher_info(
|
||||
(void *)it, sizeof(unsigned int),
|
||||
ASN_UNSIGNED, WATCHER_FIXED_SIZE));
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_READ_ONLY_UINT_INSTANCE */
|
||||
|
||||
netsnmp_feature_child_of(uint_instance,instance)
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_UINT_INSTANCE
|
||||
int
|
||||
netsnmp_register_uint_instance(const char *name,
|
||||
const oid * reg_oid, size_t reg_oid_len,
|
||||
unsigned int *it, Netsnmp_Node_Handler * subhandler)
|
||||
{
|
||||
return netsnmp_register_watched_instance2(
|
||||
netsnmp_create_handler_registration(
|
||||
name, subhandler, reg_oid, reg_oid_len, HANDLER_CAN_RWRITE),
|
||||
netsnmp_create_watcher_info(
|
||||
(void *)it, sizeof(unsigned int),
|
||||
ASN_UNSIGNED, WATCHER_FIXED_SIZE));
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_UINT_INSTANCE */
|
||||
|
||||
netsnmp_feature_child_of(read_only_int_instance,instance)
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_READ_ONLY_INT_INSTANCE
|
||||
int
|
||||
netsnmp_register_read_only_int_instance(const char *name,
|
||||
const oid * reg_oid, size_t reg_oid_len,
|
||||
int *it, Netsnmp_Node_Handler * subhandler)
|
||||
{
|
||||
return netsnmp_register_watched_instance2(
|
||||
netsnmp_create_handler_registration(
|
||||
name, subhandler, reg_oid, reg_oid_len, HANDLER_CAN_RONLY),
|
||||
netsnmp_create_watcher_info(
|
||||
(void *)it, sizeof(int), ASN_INTEGER, WATCHER_FIXED_SIZE));
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_READ_ONLY_INT_INSTANCE */
|
||||
|
||||
/*
|
||||
* Compatibility with earlier (inconsistently named) routine
|
||||
*/
|
||||
netsnmp_feature_child_of(register_read_only_int_instance,netsnmp_unused)
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_REGISTER_READ_ONLY_INT_INSTANCE
|
||||
int
|
||||
register_read_only_int_instance(const char *name,
|
||||
const oid * reg_oid, size_t reg_oid_len,
|
||||
int *it, Netsnmp_Node_Handler * subhandler)
|
||||
{
|
||||
return netsnmp_register_read_only_int_instance(name,
|
||||
reg_oid, reg_oid_len,
|
||||
it, subhandler);
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_REGISTER_READ_ONLY_INT_INSTANCE */
|
||||
|
||||
/*
|
||||
* Context registrations
|
||||
*/
|
||||
|
||||
netsnmp_feature_child_of(register_read_only_ulong_instance_context,instance)
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_REGISTER_READ_ONLY_ULONG_INSTANCE_CONTEXT
|
||||
int
|
||||
netsnmp_register_read_only_ulong_instance_context(const char *name,
|
||||
const oid * reg_oid,
|
||||
size_t reg_oid_len,
|
||||
u_long * it,
|
||||
Netsnmp_Node_Handler *
|
||||
subhandler,
|
||||
const char *contextName)
|
||||
{
|
||||
netsnmp_handler_registration *myreg =
|
||||
netsnmp_create_handler_registration(
|
||||
name, subhandler, reg_oid, reg_oid_len, HANDLER_CAN_RONLY);
|
||||
if (myreg && contextName)
|
||||
myreg->contextName = strdup(contextName);
|
||||
return netsnmp_register_watched_instance2(
|
||||
myreg, netsnmp_create_watcher_info(
|
||||
(void *)it, sizeof(u_long), ASN_UNSIGNED, WATCHER_FIXED_SIZE));
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_REGISTER_READ_ONLY_ULONG_INSTANCE_CONTEXT */
|
||||
|
||||
netsnmp_feature_child_of(register_ulong_instance_context,instance)
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_REGISTER_ULONG_INSTANCE_CONTEXT
|
||||
int
|
||||
netsnmp_register_ulong_instance_context(const char *name,
|
||||
const oid * reg_oid, size_t reg_oid_len,
|
||||
u_long * it,
|
||||
Netsnmp_Node_Handler * subhandler,
|
||||
const char *contextName)
|
||||
{
|
||||
netsnmp_handler_registration *myreg =
|
||||
netsnmp_create_handler_registration(
|
||||
name, subhandler, reg_oid, reg_oid_len, HANDLER_CAN_RWRITE);
|
||||
if (myreg && contextName)
|
||||
myreg->contextName = strdup(contextName);
|
||||
return netsnmp_register_watched_instance2(
|
||||
myreg, netsnmp_create_watcher_info(
|
||||
(void *)it, sizeof(u_long), ASN_UNSIGNED, WATCHER_FIXED_SIZE));
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_REGISTER_ULONG_INSTANCE_CONTEXT */
|
||||
|
||||
netsnmp_feature_child_of(register_read_only_counter32_instance_context,instance)
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_REGISTER_READ_ONLY_COUNTER32_INSTANCE_CONTEXT
|
||||
int
|
||||
netsnmp_register_read_only_counter32_instance_context(const char *name,
|
||||
const oid * reg_oid,
|
||||
size_t reg_oid_len,
|
||||
u_long * it,
|
||||
Netsnmp_Node_Handler *
|
||||
subhandler,
|
||||
const char *contextName)
|
||||
{
|
||||
netsnmp_handler_registration *myreg =
|
||||
netsnmp_create_handler_registration(
|
||||
name, subhandler, reg_oid, reg_oid_len, HANDLER_CAN_RONLY);
|
||||
if (myreg && contextName)
|
||||
myreg->contextName = strdup(contextName);
|
||||
return netsnmp_register_watched_instance2(
|
||||
myreg, netsnmp_create_watcher_info(
|
||||
(void *)it, sizeof(u_long), ASN_COUNTER, WATCHER_FIXED_SIZE));
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_REGISTER_READ_ONLY_COUNTER32_INSTANCE_CONTEXT */
|
||||
|
||||
netsnmp_feature_child_of(register_read_only_long_instance_context,instance)
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_REGISTER_READ_ONLY_LONG_INSTANCE_CONTEXT
|
||||
int
|
||||
netsnmp_register_read_only_long_instance_context(const char *name,
|
||||
const oid * reg_oid,
|
||||
size_t reg_oid_len,
|
||||
long *it,
|
||||
Netsnmp_Node_Handler
|
||||
*subhandler,
|
||||
const char *contextName)
|
||||
{
|
||||
netsnmp_handler_registration *myreg =
|
||||
netsnmp_create_handler_registration(
|
||||
name, subhandler, reg_oid, reg_oid_len, HANDLER_CAN_RONLY);
|
||||
if (myreg && contextName)
|
||||
myreg->contextName = strdup(contextName);
|
||||
return netsnmp_register_watched_instance2(
|
||||
myreg, netsnmp_create_watcher_info(
|
||||
(void *)it, sizeof(long), ASN_INTEGER, WATCHER_FIXED_SIZE));
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_REGISTER_READ_ONLY_LONG_INSTANCE_CONTEXT */
|
||||
|
||||
netsnmp_feature_child_of(register_long_instance_context,instance)
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_REGISTER_LONG_INSTANCE_CONTEXT
|
||||
int
|
||||
netsnmp_register_long_instance_context(const char *name,
|
||||
const oid * reg_oid, size_t reg_oid_len,
|
||||
long *it,
|
||||
Netsnmp_Node_Handler * subhandler,
|
||||
const char *contextName)
|
||||
{
|
||||
netsnmp_handler_registration *myreg =
|
||||
netsnmp_create_handler_registration(
|
||||
name, subhandler, reg_oid, reg_oid_len, HANDLER_CAN_RWRITE);
|
||||
if (myreg && contextName)
|
||||
myreg->contextName = strdup(contextName);
|
||||
return netsnmp_register_watched_instance2(
|
||||
myreg, netsnmp_create_watcher_info(
|
||||
(void *)it, sizeof(long), ASN_INTEGER, WATCHER_FIXED_SIZE));
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_REGISTER_LONG_INSTANCE_CONTEXT */
|
||||
|
||||
netsnmp_feature_child_of(register_int_instance_context,instance)
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_REGISTER_INT_INSTANCE_CONTEXT
|
||||
int
|
||||
netsnmp_register_int_instance_context(const char *name,
|
||||
const oid * reg_oid,
|
||||
size_t reg_oid_len,
|
||||
int *it,
|
||||
Netsnmp_Node_Handler * subhandler,
|
||||
const char *contextName)
|
||||
{
|
||||
netsnmp_handler_registration *myreg =
|
||||
netsnmp_create_handler_registration(
|
||||
name, subhandler, reg_oid, reg_oid_len, HANDLER_CAN_RWRITE);
|
||||
if (myreg && contextName)
|
||||
myreg->contextName = strdup(contextName);
|
||||
return netsnmp_register_watched_instance2(
|
||||
myreg, netsnmp_create_watcher_info(
|
||||
(void *)it, sizeof(int), ASN_INTEGER, WATCHER_FIXED_SIZE));
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_REGISTER_INT_INSTANCE_CONTEXT */
|
||||
|
||||
netsnmp_feature_child_of(register_read_only_int_instance_context,instance)
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_REGISTER_READ_ONLY_INT_INSTANCE_CONTEXT
|
||||
int
|
||||
netsnmp_register_read_only_int_instance_context(const char *name,
|
||||
const oid * reg_oid,
|
||||
size_t reg_oid_len,
|
||||
int *it,
|
||||
Netsnmp_Node_Handler * subhandler,
|
||||
const char *contextName)
|
||||
{
|
||||
netsnmp_handler_registration *myreg =
|
||||
netsnmp_create_handler_registration(
|
||||
name, subhandler, reg_oid, reg_oid_len, HANDLER_CAN_RONLY);
|
||||
if (myreg && contextName)
|
||||
myreg->contextName = strdup(contextName);
|
||||
return netsnmp_register_watched_instance2(
|
||||
myreg, netsnmp_create_watcher_info(
|
||||
(void *)it, sizeof(int), ASN_INTEGER, WATCHER_FIXED_SIZE));
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_REGISTER_READ_ONLY_INT_INSTANCE_CONTEXT */
|
||||
|
||||
/*
|
||||
* Compatibility with earlier (inconsistently named) routine
|
||||
*/
|
||||
netsnmp_feature_child_of(read_only_int_instance_context,instance)
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_READ_ONLY_INT_INSTANCE_CONTEXT
|
||||
int
|
||||
register_read_only_int_instance_context(const char *name,
|
||||
const oid * reg_oid, size_t reg_oid_len,
|
||||
int *it,
|
||||
Netsnmp_Node_Handler * subhandler,
|
||||
const char *contextName)
|
||||
{
|
||||
return netsnmp_register_read_only_int_instance_context(name,
|
||||
reg_oid, reg_oid_len,
|
||||
it, subhandler,
|
||||
contextName);
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_READ_ONLY_INT_INSTANCE_CONTEXT */
|
||||
|
||||
netsnmp_feature_child_of(register_num_file_instance,instance)
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_REGISTER_NUM_FILE_INSTANCE
|
||||
int
|
||||
netsnmp_register_num_file_instance(const char *name,
|
||||
const oid * reg_oid, size_t reg_oid_len,
|
||||
const char *file_name, int asn_type, int mode,
|
||||
Netsnmp_Node_Handler * subhandler,
|
||||
const char *contextName)
|
||||
{
|
||||
netsnmp_handler_registration *myreg;
|
||||
netsnmp_num_file_instance *nfi;
|
||||
|
||||
if ((NULL == name) || (NULL == reg_oid) || (NULL == file_name)) {
|
||||
snmp_log(LOG_ERR, "bad parameter to netsnmp_register_num_file_instance\n");
|
||||
return MIB_REGISTRATION_FAILED;
|
||||
}
|
||||
|
||||
nfi = SNMP_MALLOC_TYPEDEF(netsnmp_num_file_instance);
|
||||
if ((NULL == nfi) ||
|
||||
(NULL == (nfi->file_name = strdup(file_name)))) {
|
||||
snmp_log(LOG_ERR, "could not not allocate memory\n");
|
||||
if (NULL != nfi)
|
||||
free(nfi); /* SNMP_FREE overkill on local var */
|
||||
return MIB_REGISTRATION_FAILED;
|
||||
}
|
||||
|
||||
nfi->refcnt = 1;
|
||||
myreg = get_reg(name, "file_num_handler", reg_oid, reg_oid_len, nfi,
|
||||
mode, netsnmp_instance_num_file_handler,
|
||||
subhandler, contextName);
|
||||
if (NULL == myreg) {
|
||||
netsnmp_num_file_instance_deref(nfi);
|
||||
return MIB_REGISTRATION_FAILED;
|
||||
}
|
||||
|
||||
nfi->type = asn_type;
|
||||
|
||||
if (HANDLER_CAN_RONLY == mode)
|
||||
return netsnmp_register_read_only_instance(myreg);
|
||||
|
||||
return netsnmp_register_instance(myreg);
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_REGISTER_NUM_FILE_INSTANCE */
|
||||
|
||||
netsnmp_feature_child_of(register_int_instance,instance)
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_REGISTER_INT_INSTANCE
|
||||
/**
|
||||
* This function registers an int helper handler to a specified OID.
|
||||
*
|
||||
* @param name the name used for registration pruposes.
|
||||
*
|
||||
* @param reg_oid the OID where you want to register your integer at
|
||||
*
|
||||
* @param reg_oid_len the length of the OID
|
||||
*
|
||||
* @param it the integer value to be registered during initialization
|
||||
*
|
||||
* @param subhandler a handler to do whatever you want to do, otherwise use
|
||||
* NULL to use the default int handler.
|
||||
*
|
||||
* @return
|
||||
* MIB_REGISTERED_OK is returned if the registration was a success.
|
||||
* Failures are MIB_REGISTRATION_FAILED and MIB_DUPLICATE_REGISTRATION.
|
||||
*/
|
||||
int
|
||||
netsnmp_register_int_instance(const char *name,
|
||||
const oid * reg_oid, size_t reg_oid_len,
|
||||
int *it, Netsnmp_Node_Handler * subhandler)
|
||||
{
|
||||
return netsnmp_register_watched_instance2(
|
||||
netsnmp_create_handler_registration(
|
||||
name, subhandler, reg_oid, reg_oid_len, HANDLER_CAN_RWRITE),
|
||||
netsnmp_create_watcher_info(
|
||||
(void *)it, sizeof(int), ASN_INTEGER, WATCHER_FIXED_SIZE));
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_REGISTER_INT_INSTANCE */
|
||||
|
||||
#ifdef HAVE_DMALLOC_H
|
||||
static void free_wrapper(void * p)
|
||||
{
|
||||
free(p);
|
||||
}
|
||||
#else
|
||||
#define free_wrapper free
|
||||
#endif
|
||||
|
||||
int
|
||||
netsnmp_instance_num_file_handler(netsnmp_mib_handler *handler,
|
||||
netsnmp_handler_registration *reginfo,
|
||||
netsnmp_agent_request_info *reqinfo,
|
||||
netsnmp_request_info *requests)
|
||||
{
|
||||
netsnmp_num_file_instance *nfi;
|
||||
u_long it;
|
||||
#ifndef NETSNMP_NO_WRITE_SUPPORT
|
||||
u_long *it_save;
|
||||
#endif /* NETSNMP_NO_WRITE_SUPPORT */
|
||||
int rc;
|
||||
|
||||
netsnmp_assert(NULL != handler);
|
||||
nfi = (netsnmp_num_file_instance *)handler->myvoid;
|
||||
netsnmp_assert(NULL != nfi);
|
||||
netsnmp_assert(NULL != nfi->file_name);
|
||||
|
||||
DEBUGMSGTL(("netsnmp_instance_int_handler", "Got request: %d\n",
|
||||
reqinfo->mode));
|
||||
|
||||
switch (reqinfo->mode) {
|
||||
/*
|
||||
* data requests
|
||||
*/
|
||||
case MODE_GET:
|
||||
/*
|
||||
* Use a long here, otherwise on 64 bit use of an int would fail
|
||||
*/
|
||||
netsnmp_assert(NULL == nfi->filep);
|
||||
nfi->filep = fopen(nfi->file_name, "r");
|
||||
if (NULL == nfi->filep) {
|
||||
netsnmp_set_request_error(reqinfo, requests,
|
||||
SNMP_NOSUCHINSTANCE);
|
||||
return SNMP_ERR_NOERROR;
|
||||
}
|
||||
rc = fscanf(nfi->filep, (nfi->type == ASN_INTEGER) ? "%ld" : "%lu",
|
||||
&it);
|
||||
fclose(nfi->filep);
|
||||
nfi->filep = NULL;
|
||||
if (rc != 1) {
|
||||
netsnmp_set_request_error(reqinfo, requests,
|
||||
SNMP_NOSUCHINSTANCE);
|
||||
return SNMP_ERR_NOERROR;
|
||||
}
|
||||
snmp_set_var_typed_value(requests->requestvb, nfi->type,
|
||||
(u_char *) &it, sizeof(it));
|
||||
break;
|
||||
|
||||
/*
|
||||
* SET requests. Should only get here if registered RWRITE
|
||||
*/
|
||||
#ifndef NETSNMP_NO_WRITE_SUPPORT
|
||||
case MODE_SET_RESERVE1:
|
||||
netsnmp_assert(NULL == nfi->filep);
|
||||
if (requests->requestvb->type != nfi->type)
|
||||
netsnmp_set_request_error(reqinfo, requests,
|
||||
SNMP_ERR_WRONGTYPE);
|
||||
break;
|
||||
|
||||
case MODE_SET_RESERVE2:
|
||||
netsnmp_assert(NULL == nfi->filep);
|
||||
nfi->filep = fopen(nfi->file_name, "w+");
|
||||
if (NULL == nfi->filep) {
|
||||
netsnmp_set_request_error(reqinfo, requests,
|
||||
SNMP_ERR_NOTWRITABLE);
|
||||
return SNMP_ERR_NOERROR;
|
||||
}
|
||||
/*
|
||||
* store old info for undo later
|
||||
*/
|
||||
if (fscanf(nfi->filep, (nfi->type == ASN_INTEGER) ? "%ld" : "%lu",
|
||||
&it) != 1) {
|
||||
netsnmp_set_request_error(reqinfo, requests,
|
||||
SNMP_ERR_RESOURCEUNAVAILABLE);
|
||||
return SNMP_ERR_NOERROR;
|
||||
}
|
||||
|
||||
it_save = netsnmp_memdup(&it, sizeof(u_long));
|
||||
if (it_save == NULL) {
|
||||
netsnmp_set_request_error(reqinfo, requests,
|
||||
SNMP_ERR_RESOURCEUNAVAILABLE);
|
||||
return SNMP_ERR_NOERROR;
|
||||
}
|
||||
netsnmp_request_add_list_data(requests,
|
||||
netsnmp_create_data_list
|
||||
(INSTANCE_HANDLER_NAME, it_save,
|
||||
&free_wrapper));
|
||||
break;
|
||||
|
||||
case MODE_SET_ACTION:
|
||||
/*
|
||||
* update current
|
||||
*/
|
||||
DEBUGMSGTL(("helper:instance", "updated %s -> %ld\n", nfi->file_name,
|
||||
*(requests->requestvb->val.integer)));
|
||||
it = *(requests->requestvb->val.integer);
|
||||
rewind(nfi->filep); /* rewind to make sure we are at the beginning */
|
||||
rc = fprintf(nfi->filep, (nfi->type == ASN_INTEGER) ? "%ld" : "%lu",
|
||||
it);
|
||||
if (rc < 0) {
|
||||
netsnmp_set_request_error(reqinfo, requests,
|
||||
SNMP_ERR_GENERR);
|
||||
return SNMP_ERR_NOERROR;
|
||||
}
|
||||
break;
|
||||
|
||||
case MODE_SET_UNDO:
|
||||
it =
|
||||
*((u_int *) netsnmp_request_get_list_data(requests,
|
||||
INSTANCE_HANDLER_NAME));
|
||||
rc = fprintf(nfi->filep, (nfi->type == ASN_INTEGER) ? "%ld" : "%lu",
|
||||
it);
|
||||
if (rc < 0)
|
||||
netsnmp_set_request_error(reqinfo, requests,
|
||||
SNMP_ERR_UNDOFAILED);
|
||||
/** fall through */
|
||||
|
||||
case MODE_SET_COMMIT:
|
||||
case MODE_SET_FREE:
|
||||
if (NULL != nfi->filep) {
|
||||
fclose(nfi->filep);
|
||||
nfi->filep = NULL;
|
||||
}
|
||||
break;
|
||||
#endif /* NETSNMP_NO_WRITE_SUPPORT */
|
||||
default:
|
||||
snmp_log(LOG_ERR,
|
||||
"netsnmp_instance_num_file_handler: illegal mode\n");
|
||||
netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_GENERR);
|
||||
return SNMP_ERR_NOERROR;
|
||||
}
|
||||
|
||||
if (handler->next && handler->next->access_method)
|
||||
return netsnmp_call_next_handler(handler, reginfo, reqinfo,
|
||||
requests);
|
||||
return SNMP_ERR_NOERROR;
|
||||
}
|
||||
|
||||
int
|
||||
netsnmp_instance_helper_handler(netsnmp_mib_handler *handler,
|
||||
netsnmp_handler_registration *reginfo,
|
||||
netsnmp_agent_request_info *reqinfo,
|
||||
netsnmp_request_info *requests)
|
||||
{
|
||||
|
||||
netsnmp_variable_list *var = requests->requestvb;
|
||||
|
||||
int ret, cmp;
|
||||
|
||||
DEBUGMSGTL(("helper:instance", "Got request:\n"));
|
||||
cmp = snmp_oid_compare(requests->requestvb->name,
|
||||
requests->requestvb->name_length,
|
||||
reginfo->rootoid, reginfo->rootoid_len);
|
||||
|
||||
DEBUGMSGTL(("helper:instance", " oid:"));
|
||||
DEBUGMSGOID(("helper:instance", var->name, var->name_length));
|
||||
DEBUGMSG(("helper:instance", "\n"));
|
||||
|
||||
switch (reqinfo->mode) {
|
||||
case MODE_GET:
|
||||
if (cmp != 0) {
|
||||
netsnmp_set_request_error(reqinfo, requests,
|
||||
SNMP_NOSUCHINSTANCE);
|
||||
return SNMP_ERR_NOERROR;
|
||||
} else {
|
||||
return netsnmp_call_next_handler(handler, reginfo, reqinfo,
|
||||
requests);
|
||||
}
|
||||
break;
|
||||
|
||||
#ifndef NETSNMP_NO_WRITE_SUPPORT
|
||||
case MODE_SET_RESERVE1:
|
||||
case MODE_SET_RESERVE2:
|
||||
case MODE_SET_ACTION:
|
||||
case MODE_SET_COMMIT:
|
||||
case MODE_SET_UNDO:
|
||||
case MODE_SET_FREE:
|
||||
if (cmp != 0) {
|
||||
netsnmp_set_request_error(reqinfo, requests,
|
||||
SNMP_ERR_NOCREATION);
|
||||
return SNMP_ERR_NOERROR;
|
||||
} else {
|
||||
return netsnmp_call_next_handler(handler, reginfo, reqinfo,
|
||||
requests);
|
||||
}
|
||||
break;
|
||||
#endif /* NETSNMP_NO_WRITE_SUPPORT */
|
||||
|
||||
case MODE_GETNEXT:
|
||||
if (cmp < 0 || (cmp == 0 && requests->inclusive)) {
|
||||
reqinfo->mode = MODE_GET;
|
||||
snmp_set_var_objid(requests->requestvb, reginfo->rootoid,
|
||||
reginfo->rootoid_len);
|
||||
ret =
|
||||
netsnmp_call_next_handler(handler, reginfo, reqinfo,
|
||||
requests);
|
||||
reqinfo->mode = MODE_GETNEXT;
|
||||
/*
|
||||
* if the instance doesn't have data, set type to ASN_NULL
|
||||
* to move to the next sub-tree. Ignore delegated requests; they
|
||||
* might have data later on.
|
||||
*/
|
||||
if (!requests->delegated &&
|
||||
(requests->requestvb->type == SNMP_NOSUCHINSTANCE ||
|
||||
requests->requestvb->type == SNMP_NOSUCHOBJECT)) {
|
||||
requests->requestvb->type = ASN_NULL;
|
||||
}
|
||||
return ret;
|
||||
} else {
|
||||
return SNMP_ERR_NOERROR;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
snmp_log(LOG_ERR,
|
||||
"netsnmp_instance_helper_handler: illegal mode\n");
|
||||
netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_GENERR);
|
||||
return SNMP_ERR_NOERROR;
|
||||
}
|
||||
/*
|
||||
* got here only if illegal mode found
|
||||
*/
|
||||
return SNMP_ERR_GENERR;
|
||||
}
|
||||
|
||||
/** @}
|
||||
*/
|
||||
@@ -1,127 +0,0 @@
|
||||
/* Portions of this file are subject to the following copyright(s). See
|
||||
* the Net-SNMP's COPYING file for more details and other copyrights
|
||||
* that may apply:
|
||||
*/
|
||||
/*
|
||||
* Portions of this file are copyrighted by:
|
||||
* Copyright <20> 2003 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms specified in the COPYING file
|
||||
* distributed with the Net-SNMP package.
|
||||
*/
|
||||
#include <net-snmp/net-snmp-config.h>
|
||||
#include <net-snmp/net-snmp-features.h>
|
||||
|
||||
#include <net-snmp/net-snmp-includes.h>
|
||||
#include <net-snmp/agent/net-snmp-agent-includes.h>
|
||||
|
||||
#include <net-snmp/agent/mode_end_call.h>
|
||||
|
||||
netsnmp_feature_provide(mode_end_call)
|
||||
netsnmp_feature_child_of(mode_end_call, mib_helpers)
|
||||
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_MODE_END_CALL
|
||||
/** @defgroup mode_end_call mode_end_call
|
||||
* At the end of a series of requests, call another handler hook.
|
||||
* Handlers that want to loop through a series of requests and then
|
||||
* receive a callback at the end of a particular MODE can use this
|
||||
* helper to make this possible. For most modules, this is not
|
||||
* needed as the handler itself could perform a for() loop around the
|
||||
* request list and then perform its actions afterwards. However, if
|
||||
* something like the serialize helper is in use this isn't possible
|
||||
* because not all the requests for a given handler are being passed
|
||||
* downward in a single group. Thus, this helper *must* be added
|
||||
* above other helpers like the serialize helper to be useful.
|
||||
*
|
||||
* Multiple mode specific handlers can be registered and will be
|
||||
* called in the order they were regestered in. Callbacks regesterd
|
||||
* with a mode of NETSNMP_MODE_END_ALL_MODES will be called for all
|
||||
* modes.
|
||||
*
|
||||
* @ingroup utilities
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** returns a mode_end_call handler that can be injected into a given
|
||||
* handler chain.
|
||||
* @param endlist The callback list for the handler to make use of.
|
||||
* @return An injectable Net-SNMP handler.
|
||||
*/
|
||||
netsnmp_mib_handler *
|
||||
netsnmp_get_mode_end_call_handler(netsnmp_mode_handler_list *endlist)
|
||||
{
|
||||
netsnmp_mib_handler *me =
|
||||
netsnmp_create_handler("mode_end_call",
|
||||
netsnmp_mode_end_call_helper);
|
||||
|
||||
if (!me)
|
||||
return NULL;
|
||||
|
||||
me->myvoid = endlist;
|
||||
return me;
|
||||
}
|
||||
|
||||
/** adds a mode specific callback to the callback list.
|
||||
* @param endlist the information structure for the mode_end_call helper. Can be NULL to create a new list.
|
||||
* @param mode the mode to be called upon. A mode of NETSNMP_MODE_END_ALL_MODES = all modes.
|
||||
* @param callbackh the netsnmp_mib_handler callback to call.
|
||||
* @return the new registration information list upon success.
|
||||
*/
|
||||
netsnmp_mode_handler_list *
|
||||
netsnmp_mode_end_call_add_mode_callback(netsnmp_mode_handler_list *endlist,
|
||||
int mode,
|
||||
netsnmp_mib_handler *callbackh) {
|
||||
netsnmp_mode_handler_list *ptr, *ptr2;
|
||||
ptr = SNMP_MALLOC_TYPEDEF(netsnmp_mode_handler_list);
|
||||
if (!ptr)
|
||||
return NULL;
|
||||
|
||||
ptr->mode = mode;
|
||||
ptr->callback_handler = callbackh;
|
||||
ptr->next = NULL;
|
||||
|
||||
if (!endlist)
|
||||
return ptr;
|
||||
|
||||
/* get to end */
|
||||
for(ptr2 = endlist; ptr2->next != NULL; ptr2 = ptr2->next);
|
||||
|
||||
ptr2->next = ptr;
|
||||
return endlist;
|
||||
}
|
||||
|
||||
/** @internal Implements the mode_end_call handler */
|
||||
int
|
||||
netsnmp_mode_end_call_helper(netsnmp_mib_handler *handler,
|
||||
netsnmp_handler_registration *reginfo,
|
||||
netsnmp_agent_request_info *reqinfo,
|
||||
netsnmp_request_info *requests)
|
||||
{
|
||||
|
||||
int ret;
|
||||
int ret2 = SNMP_ERR_NOERROR;
|
||||
netsnmp_mode_handler_list *ptr;
|
||||
|
||||
/* always call the real handlers first */
|
||||
ret = netsnmp_call_next_handler(handler, reginfo, reqinfo,
|
||||
requests);
|
||||
|
||||
/* then call the callback handlers */
|
||||
for (ptr = (netsnmp_mode_handler_list*)handler->myvoid; ptr; ptr = ptr->next) {
|
||||
if (ptr->mode == NETSNMP_MODE_END_ALL_MODES ||
|
||||
reqinfo->mode == ptr->mode) {
|
||||
ret2 = netsnmp_call_handler(ptr->callback_handler, reginfo,
|
||||
reqinfo, requests);
|
||||
if (ret != SNMP_ERR_NOERROR)
|
||||
ret = ret2;
|
||||
}
|
||||
}
|
||||
|
||||
return ret2;
|
||||
}
|
||||
#else
|
||||
netsnmp_feature_unused(mode_end_call);
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_MODE_END_CALL */
|
||||
|
||||
|
||||
/** @} */
|
||||
|
||||
@@ -1,119 +0,0 @@
|
||||
#include <net-snmp/net-snmp-config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <net-snmp/net-snmp-includes.h>
|
||||
#include <net-snmp/agent/net-snmp-agent-includes.h>
|
||||
|
||||
#include <net-snmp/agent/multiplexer.h>
|
||||
|
||||
/** @defgroup multiplexer multiplexer
|
||||
* Splits mode requests into calls to different handlers.
|
||||
* @ingroup utilities
|
||||
* The multiplexer helper lets you split the calling chain depending
|
||||
* on the calling mode (get vs getnext vs set). Useful if you want
|
||||
* different routines to handle different aspects of SNMP requests,
|
||||
* which is very common for GET vs SET type actions.
|
||||
*
|
||||
* Functionally:
|
||||
*
|
||||
* -# GET requests call the get_method
|
||||
* -# GETNEXT requests call the getnext_method, or if not present, the
|
||||
* get_method.
|
||||
* -# GETBULK requests call the getbulk_method, or if not present, the
|
||||
* getnext_method, or if even that isn't present the get_method.
|
||||
* -# SET requests call the set_method, or if not present return a
|
||||
* SNMP_ERR_NOTWRITABLE error.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** returns a multiplixer handler given a netsnmp_mib_handler_methods structure of subhandlers.
|
||||
*/
|
||||
netsnmp_mib_handler *
|
||||
netsnmp_get_multiplexer_handler(netsnmp_mib_handler_methods *req)
|
||||
{
|
||||
netsnmp_mib_handler *ret = NULL;
|
||||
|
||||
if (!req) {
|
||||
snmp_log(LOG_INFO,
|
||||
"netsnmp_get_multiplexer_handler(NULL) called\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret =
|
||||
netsnmp_create_handler("multiplexer",
|
||||
netsnmp_multiplexer_helper_handler);
|
||||
if (ret) {
|
||||
ret->myvoid = (void *) req;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/** implements the multiplexer helper */
|
||||
int
|
||||
netsnmp_multiplexer_helper_handler(netsnmp_mib_handler *handler,
|
||||
netsnmp_handler_registration *reginfo,
|
||||
netsnmp_agent_request_info *reqinfo,
|
||||
netsnmp_request_info *requests)
|
||||
{
|
||||
|
||||
netsnmp_mib_handler_methods *methods;
|
||||
|
||||
if (!handler->myvoid) {
|
||||
snmp_log(LOG_INFO, "improperly registered multiplexer found\n");
|
||||
return SNMP_ERR_GENERR;
|
||||
}
|
||||
|
||||
methods = (netsnmp_mib_handler_methods *) handler->myvoid;
|
||||
|
||||
switch (reqinfo->mode) {
|
||||
case MODE_GETBULK:
|
||||
handler = methods->getbulk_handler;
|
||||
if (handler)
|
||||
break;
|
||||
/* Deliberate fallthrough to use GetNext handler */
|
||||
case MODE_GETNEXT:
|
||||
handler = methods->getnext_handler;
|
||||
if (handler)
|
||||
break;
|
||||
/* Deliberate fallthrough to use Get handler */
|
||||
case MODE_GET:
|
||||
handler = methods->get_handler;
|
||||
if (!handler) {
|
||||
netsnmp_request_set_error_all(requests, SNMP_NOSUCHOBJECT);
|
||||
}
|
||||
break;
|
||||
|
||||
#ifndef NETSNMP_NO_WRITE_SUPPORT
|
||||
case MODE_SET_RESERVE1:
|
||||
case MODE_SET_RESERVE2:
|
||||
case MODE_SET_ACTION:
|
||||
case MODE_SET_COMMIT:
|
||||
case MODE_SET_FREE:
|
||||
case MODE_SET_UNDO:
|
||||
handler = methods->set_handler;
|
||||
if (!handler) {
|
||||
netsnmp_request_set_error_all(requests, SNMP_ERR_NOTWRITABLE);
|
||||
return SNMP_ERR_NOERROR;
|
||||
}
|
||||
break;
|
||||
|
||||
/*
|
||||
* XXX: process SETs specially, and possibly others
|
||||
*/
|
||||
#endif /* NETSNMP_NO_WRITE_SUPPORT */
|
||||
default:
|
||||
snmp_log(LOG_ERR, "unsupported mode for multiplexer: %d\n",
|
||||
reqinfo->mode);
|
||||
return SNMP_ERR_GENERR;
|
||||
}
|
||||
if (!handler) {
|
||||
snmp_log(LOG_ERR,
|
||||
"No handler enabled for mode %d in multiplexer\n",
|
||||
reqinfo->mode);
|
||||
return SNMP_ERR_GENERR;
|
||||
}
|
||||
return netsnmp_call_handler(handler, reginfo, reqinfo, requests);
|
||||
}
|
||||
/** @} */
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
#include <net-snmp/net-snmp-config.h>
|
||||
|
||||
#include <net-snmp/net-snmp-includes.h>
|
||||
#include <net-snmp/agent/net-snmp-agent-includes.h>
|
||||
|
||||
#include <net-snmp/agent/null.h>
|
||||
|
||||
#if HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#else
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
int
|
||||
netsnmp_register_null(oid * loc, size_t loc_len)
|
||||
{
|
||||
return netsnmp_register_null_context(loc, loc_len, NULL);
|
||||
}
|
||||
|
||||
int
|
||||
netsnmp_register_null_context(oid * loc, size_t loc_len,
|
||||
const char *contextName)
|
||||
{
|
||||
netsnmp_handler_registration *reginfo;
|
||||
reginfo = SNMP_MALLOC_TYPEDEF(netsnmp_handler_registration);
|
||||
if (reginfo != NULL) {
|
||||
reginfo->handlerName = strdup("");
|
||||
reginfo->rootoid = loc;
|
||||
reginfo->rootoid_len = loc_len;
|
||||
reginfo->handler =
|
||||
netsnmp_create_handler("null", netsnmp_null_handler);
|
||||
if (contextName)
|
||||
reginfo->contextName = strdup(contextName);
|
||||
reginfo->modes = HANDLER_CAN_DEFAULT | HANDLER_CAN_GETBULK;
|
||||
}
|
||||
return netsnmp_register_handler(reginfo);
|
||||
}
|
||||
|
||||
int
|
||||
netsnmp_null_handler(netsnmp_mib_handler *handler,
|
||||
netsnmp_handler_registration *reginfo,
|
||||
netsnmp_agent_request_info *reqinfo,
|
||||
netsnmp_request_info *requests)
|
||||
{
|
||||
DEBUGMSGTL(("helper:null", "Got request\n"));
|
||||
|
||||
DEBUGMSGTL(("helper:null", " oid:"));
|
||||
DEBUGMSGOID(("helper:null", requests->requestvb->name,
|
||||
requests->requestvb->name_length));
|
||||
DEBUGMSG(("helper:null", "\n"));
|
||||
|
||||
switch (reqinfo->mode) {
|
||||
case MODE_GETNEXT:
|
||||
case MODE_GETBULK:
|
||||
return SNMP_ERR_NOERROR;
|
||||
|
||||
case MODE_GET:
|
||||
netsnmp_request_set_error_all(requests, SNMP_NOSUCHOBJECT);
|
||||
return SNMP_ERR_NOERROR;
|
||||
|
||||
default:
|
||||
netsnmp_request_set_error_all(requests, SNMP_ERR_NOSUCHNAME);
|
||||
return SNMP_ERR_NOERROR;
|
||||
}
|
||||
}
|
||||
@@ -1,462 +0,0 @@
|
||||
#include <net-snmp/net-snmp-config.h>
|
||||
|
||||
#include <net-snmp/net-snmp-includes.h>
|
||||
#include <net-snmp/agent/net-snmp-agent-includes.h>
|
||||
|
||||
#include <net-snmp/agent/old_api.h>
|
||||
|
||||
#if HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#else
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#include <net-snmp/agent/agent_callbacks.h>
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#define MIB_CLIENTS_ARE_EVIL 1
|
||||
|
||||
#ifdef HAVE_DMALLOC_H
|
||||
static void free_wrapper(void * p)
|
||||
{
|
||||
free(p);
|
||||
}
|
||||
#else
|
||||
#define free_wrapper free
|
||||
#endif
|
||||
|
||||
/*
|
||||
* don't use these!
|
||||
*/
|
||||
void set_current_agent_session(netsnmp_agent_session *asp);
|
||||
netsnmp_agent_session *netsnmp_get_current_agent_session(void);
|
||||
|
||||
/** @defgroup old_api old_api
|
||||
* Calls mib module code written in the old style of code.
|
||||
* @ingroup handler
|
||||
* This is a backwards compatilibity module that allows code written
|
||||
* in the old API to be run under the new handler based architecture.
|
||||
* Use it by calling netsnmp_register_old_api().
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** returns a old_api handler that should be the final calling
|
||||
* handler. Don't use this function. Use the netsnmp_register_old_api()
|
||||
* function instead.
|
||||
*/
|
||||
netsnmp_mib_handler *
|
||||
get_old_api_handler(void)
|
||||
{
|
||||
return netsnmp_create_handler("old_api", netsnmp_old_api_helper);
|
||||
}
|
||||
|
||||
struct variable *
|
||||
netsnmp_duplicate_variable(const struct variable *var)
|
||||
{
|
||||
struct variable *var2 = NULL;
|
||||
|
||||
if (var) {
|
||||
const int varsize = offsetof(struct variable, name) + var->namelen * sizeof(var->name[0]);
|
||||
var2 = malloc(varsize);
|
||||
if (var2)
|
||||
memcpy(var2, var, varsize);
|
||||
}
|
||||
return var2;
|
||||
}
|
||||
|
||||
/** Registers an old API set into the mib tree. Functionally this
|
||||
* mimics the old register_mib_context() function (and in fact the new
|
||||
* register_mib_context() function merely calls this new old_api one).
|
||||
*/
|
||||
int
|
||||
netsnmp_register_old_api(const char *moduleName,
|
||||
const struct variable *var,
|
||||
size_t varsize,
|
||||
size_t numvars,
|
||||
const oid * mibloc,
|
||||
size_t mibloclen,
|
||||
int priority,
|
||||
int range_subid,
|
||||
oid range_ubound,
|
||||
netsnmp_session * ss,
|
||||
const char *context, int timeout, int flags)
|
||||
{
|
||||
|
||||
unsigned int i;
|
||||
|
||||
/*
|
||||
* register all subtree nodes
|
||||
*/
|
||||
for (i = 0; i < numvars; i++) {
|
||||
struct variable *vp;
|
||||
netsnmp_handler_registration *reginfo =
|
||||
SNMP_MALLOC_TYPEDEF(netsnmp_handler_registration);
|
||||
if (reginfo == NULL)
|
||||
return SNMP_ERR_GENERR;
|
||||
|
||||
vp = netsnmp_duplicate_variable((const struct variable *)
|
||||
((const char *) var + varsize * i));
|
||||
|
||||
reginfo->handler = get_old_api_handler();
|
||||
reginfo->handlerName = strdup(moduleName);
|
||||
reginfo->rootoid_len = (mibloclen + vp->namelen);
|
||||
reginfo->rootoid =
|
||||
(oid *) malloc(reginfo->rootoid_len * sizeof(oid));
|
||||
if (reginfo->rootoid == NULL) {
|
||||
SNMP_FREE(vp);
|
||||
SNMP_FREE(reginfo->handlerName);
|
||||
SNMP_FREE(reginfo);
|
||||
return SNMP_ERR_GENERR;
|
||||
}
|
||||
|
||||
memcpy(reginfo->rootoid, mibloc, mibloclen * sizeof(oid));
|
||||
memcpy(reginfo->rootoid + mibloclen, vp->name, vp->namelen
|
||||
* sizeof(oid));
|
||||
reginfo->handler->myvoid = (void *) vp;
|
||||
reginfo->handler->data_clone
|
||||
= (void *(*)(void *))netsnmp_duplicate_variable;
|
||||
reginfo->handler->data_free = free;
|
||||
|
||||
reginfo->priority = priority;
|
||||
reginfo->range_subid = range_subid;
|
||||
|
||||
reginfo->range_ubound = range_ubound;
|
||||
reginfo->timeout = timeout;
|
||||
reginfo->contextName = (context) ? strdup(context) : NULL;
|
||||
reginfo->modes = vp->acl == NETSNMP_OLDAPI_RONLY ? HANDLER_CAN_RONLY :
|
||||
HANDLER_CAN_RWRITE;
|
||||
|
||||
/*
|
||||
* register ourselves in the mib tree
|
||||
*/
|
||||
if (netsnmp_register_handler(reginfo) != MIB_REGISTERED_OK) {
|
||||
/** netsnmp_handler_registration_free(reginfo); already freed */
|
||||
/* SNMP_FREE(vp); already freed */
|
||||
}
|
||||
}
|
||||
return SNMPERR_SUCCESS;
|
||||
}
|
||||
|
||||
/** registers a row within a mib table */
|
||||
int
|
||||
netsnmp_register_mib_table_row(const char *moduleName,
|
||||
const struct variable *var,
|
||||
size_t varsize,
|
||||
size_t numvars,
|
||||
oid * mibloc,
|
||||
size_t mibloclen,
|
||||
int priority,
|
||||
int var_subid,
|
||||
netsnmp_session * ss,
|
||||
const char *context, int timeout, int flags)
|
||||
{
|
||||
unsigned int i = 0, rc = 0;
|
||||
oid ubound = 0;
|
||||
|
||||
for (i = 0; i < numvars; i++) {
|
||||
const struct variable *vr =
|
||||
(const struct variable *) ((const char *) var + (i * varsize));
|
||||
netsnmp_handler_registration *r;
|
||||
if ( var_subid > (int)mibloclen ) {
|
||||
break; /* doesn't make sense */
|
||||
}
|
||||
r = SNMP_MALLOC_TYPEDEF(netsnmp_handler_registration);
|
||||
|
||||
if (r == NULL) {
|
||||
/*
|
||||
* Unregister whatever we have registered so far, and
|
||||
* return an error.
|
||||
*/
|
||||
rc = MIB_REGISTRATION_FAILED;
|
||||
break;
|
||||
}
|
||||
memset(r, 0, sizeof(netsnmp_handler_registration));
|
||||
|
||||
r->handler = get_old_api_handler();
|
||||
r->handlerName = strdup(moduleName);
|
||||
|
||||
if (r->handlerName == NULL) {
|
||||
netsnmp_handler_registration_free(r);
|
||||
break;
|
||||
}
|
||||
|
||||
r->rootoid_len = mibloclen;
|
||||
r->rootoid = (oid *) malloc(r->rootoid_len * sizeof(oid));
|
||||
|
||||
if (r->rootoid == NULL) {
|
||||
netsnmp_handler_registration_free(r);
|
||||
rc = MIB_REGISTRATION_FAILED;
|
||||
break;
|
||||
}
|
||||
memcpy(r->rootoid, mibloc, mibloclen * sizeof(oid));
|
||||
memcpy((u_char *) (r->rootoid + (var_subid - vr->namelen)), vr->name,
|
||||
vr->namelen * sizeof(oid));
|
||||
DEBUGMSGTL(("netsnmp_register_mib_table_row", "rootoid "));
|
||||
DEBUGMSGOID(("netsnmp_register_mib_table_row", r->rootoid,
|
||||
r->rootoid_len));
|
||||
DEBUGMSG(("netsnmp_register_mib_table_row", "(%d)\n",
|
||||
(var_subid - vr->namelen)));
|
||||
r->handler->myvoid = netsnmp_duplicate_variable(vr);
|
||||
r->handler->data_clone = (void *(*)(void *))netsnmp_duplicate_variable;
|
||||
r->handler->data_free = free;
|
||||
|
||||
if (r->handler->myvoid == NULL) {
|
||||
netsnmp_handler_registration_free(r);
|
||||
rc = MIB_REGISTRATION_FAILED;
|
||||
break;
|
||||
}
|
||||
|
||||
r->contextName = (context) ? strdup(context) : NULL;
|
||||
|
||||
if (context != NULL && r->contextName == NULL) {
|
||||
netsnmp_handler_registration_free(r);
|
||||
rc = MIB_REGISTRATION_FAILED;
|
||||
break;
|
||||
}
|
||||
|
||||
r->priority = priority;
|
||||
r->range_subid = 0; /* var_subid; */
|
||||
r->range_ubound = 0; /* range_ubound; */
|
||||
r->timeout = timeout;
|
||||
r->modes = HANDLER_CAN_RWRITE;
|
||||
|
||||
/*
|
||||
* Register this column and row
|
||||
*/
|
||||
if ((rc =
|
||||
netsnmp_register_handler_nocallback(r)) !=
|
||||
MIB_REGISTERED_OK) {
|
||||
DEBUGMSGTL(("netsnmp_register_mib_table_row",
|
||||
"register failed %d\n", rc));
|
||||
netsnmp_handler_registration_free(r);
|
||||
break;
|
||||
}
|
||||
|
||||
if (vr->namelen > 0) {
|
||||
if (vr->name[vr->namelen - 1] > ubound) {
|
||||
ubound = vr->name[vr->namelen - 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (rc == MIB_REGISTERED_OK) {
|
||||
struct register_parameters reg_parms;
|
||||
|
||||
reg_parms.name = mibloc;
|
||||
reg_parms.namelen = mibloclen;
|
||||
reg_parms.priority = priority;
|
||||
reg_parms.flags = (u_char) flags;
|
||||
reg_parms.range_subid = var_subid;
|
||||
reg_parms.range_ubound = ubound;
|
||||
reg_parms.timeout = timeout;
|
||||
reg_parms.contextName = context;
|
||||
rc = snmp_call_callbacks(SNMP_CALLBACK_APPLICATION,
|
||||
SNMPD_CALLBACK_REGISTER_OID, ®_parms);
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/** implements the old_api handler */
|
||||
int
|
||||
netsnmp_old_api_helper(netsnmp_mib_handler *handler,
|
||||
netsnmp_handler_registration *reginfo,
|
||||
netsnmp_agent_request_info *reqinfo,
|
||||
netsnmp_request_info *requests)
|
||||
{
|
||||
|
||||
#if MIB_CLIENTS_ARE_EVIL
|
||||
oid save[MAX_OID_LEN];
|
||||
size_t savelen = 0;
|
||||
#endif
|
||||
struct variable compat_var, *cvp = &compat_var;
|
||||
int exact = 1;
|
||||
int status;
|
||||
|
||||
struct variable *vp;
|
||||
netsnmp_old_api_cache *cacheptr;
|
||||
netsnmp_agent_session *oldasp = NULL;
|
||||
u_char *access = NULL;
|
||||
WriteMethod *write_method = NULL;
|
||||
size_t len;
|
||||
size_t tmp_len;
|
||||
oid tmp_name[MAX_OID_LEN];
|
||||
|
||||
vp = (struct variable *) handler->myvoid;
|
||||
|
||||
/*
|
||||
* create old variable structure with right information
|
||||
*/
|
||||
memcpy(cvp->name, reginfo->rootoid,
|
||||
reginfo->rootoid_len * sizeof(oid));
|
||||
cvp->namelen = reginfo->rootoid_len;
|
||||
cvp->type = vp->type;
|
||||
cvp->magic = vp->magic;
|
||||
cvp->acl = vp->acl;
|
||||
cvp->findVar = vp->findVar;
|
||||
|
||||
switch (reqinfo->mode) {
|
||||
case MODE_GETNEXT:
|
||||
case MODE_GETBULK:
|
||||
exact = 0;
|
||||
}
|
||||
|
||||
for (; requests; requests = requests->next) {
|
||||
|
||||
#if MIB_CLIENTS_ARE_EVIL
|
||||
savelen = requests->requestvb->name_length;
|
||||
memcpy(save, requests->requestvb->name, savelen * sizeof(oid));
|
||||
#endif
|
||||
|
||||
switch (reqinfo->mode) {
|
||||
case MODE_GET:
|
||||
case MODE_GETNEXT:
|
||||
#ifndef NETSNMP_NO_WRITE_SUPPORT
|
||||
case MODE_SET_RESERVE1:
|
||||
#endif /* !NETSNMP_NO_WRITE_SUPPORT */
|
||||
/*
|
||||
* Actually call the old mib-module function
|
||||
*/
|
||||
if (vp && vp->findVar) {
|
||||
memcpy(tmp_name, requests->requestvb->name,
|
||||
requests->requestvb->name_length*sizeof(oid));
|
||||
tmp_len = requests->requestvb->name_length;
|
||||
access = (*(vp->findVar)) (cvp, tmp_name, &tmp_len,
|
||||
exact, &len, &write_method);
|
||||
snmp_set_var_objid( requests->requestvb, tmp_name, tmp_len );
|
||||
}
|
||||
else
|
||||
access = NULL;
|
||||
|
||||
#ifdef WWW_FIX
|
||||
if (IS_DELEGATED(cvp->type)) {
|
||||
add_method = (AddVarMethod *) statP;
|
||||
requests->delayed = 1;
|
||||
have_delegated = 1;
|
||||
continue; /* WWW: This may not get to the right place */
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* WWW: end range checking
|
||||
*/
|
||||
if (access) {
|
||||
/*
|
||||
* result returned
|
||||
*/
|
||||
#ifndef NETSNMP_NO_WRITE_SUPPORT
|
||||
if (reqinfo->mode != MODE_SET_RESERVE1)
|
||||
#endif /* !NETSNMP_NO_WRITE_SUPPORT */
|
||||
snmp_set_var_typed_value(requests->requestvb,
|
||||
cvp->type, access, len);
|
||||
} else {
|
||||
/*
|
||||
* no result returned
|
||||
*/
|
||||
#if MIB_CLIENTS_ARE_EVIL
|
||||
if (access == NULL) {
|
||||
if (netsnmp_oid_equals(requests->requestvb->name,
|
||||
requests->requestvb->name_length,
|
||||
save, savelen) != 0) {
|
||||
DEBUGMSGTL(("old_api", "evil_client: %s\n",
|
||||
reginfo->handlerName));
|
||||
memcpy(requests->requestvb->name, save,
|
||||
savelen * sizeof(oid));
|
||||
requests->requestvb->name_length = savelen;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* AAA: fall through for everything that is a set (see BBB)
|
||||
*/
|
||||
#ifndef NETSNMP_NO_WRITE_SUPPORT
|
||||
if (reqinfo->mode != MODE_SET_RESERVE1)
|
||||
#endif /* !NETSNMP_NO_WRITE_SUPPORT */
|
||||
break;
|
||||
|
||||
cacheptr = SNMP_MALLOC_TYPEDEF(netsnmp_old_api_cache);
|
||||
if (!cacheptr)
|
||||
return netsnmp_set_request_error(reqinfo, requests,
|
||||
SNMP_ERR_RESOURCEUNAVAILABLE);
|
||||
cacheptr->data = access;
|
||||
cacheptr->write_method = write_method;
|
||||
write_method = NULL;
|
||||
netsnmp_request_add_list_data(requests,
|
||||
netsnmp_create_data_list
|
||||
(OLD_API_NAME, cacheptr,
|
||||
&free_wrapper));
|
||||
/*
|
||||
* BBB: fall through for everything that is a set (see AAA)
|
||||
*/
|
||||
|
||||
default:
|
||||
/*
|
||||
* WWW: explicitly list the SET conditions
|
||||
*/
|
||||
/*
|
||||
* (the rest of the) SET contions
|
||||
*/
|
||||
cacheptr =
|
||||
(netsnmp_old_api_cache *)
|
||||
netsnmp_request_get_list_data(requests, OLD_API_NAME);
|
||||
|
||||
if (cacheptr == NULL || cacheptr->write_method == NULL) {
|
||||
/*
|
||||
* WWW: try to set ourselves if possible?
|
||||
*/
|
||||
return netsnmp_set_request_error(reqinfo, requests,
|
||||
SNMP_ERR_NOTWRITABLE);
|
||||
}
|
||||
|
||||
oldasp = netsnmp_get_current_agent_session();
|
||||
set_current_agent_session(reqinfo->asp);
|
||||
status =
|
||||
(*(cacheptr->write_method)) (reqinfo->mode,
|
||||
requests->requestvb->val.
|
||||
string,
|
||||
requests->requestvb->type,
|
||||
requests->requestvb->val_len,
|
||||
cacheptr->data,
|
||||
requests->requestvb->name,
|
||||
requests->requestvb->
|
||||
name_length);
|
||||
set_current_agent_session(oldasp);
|
||||
|
||||
if (status != SNMP_ERR_NOERROR) {
|
||||
netsnmp_set_request_error(reqinfo, requests, status);
|
||||
}
|
||||
|
||||
/*
|
||||
* clean up is done by the automatic freeing of the
|
||||
* cache stored in the request.
|
||||
*/
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
return SNMP_ERR_NOERROR;
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
||||
/*
|
||||
* don't use this!
|
||||
*/
|
||||
static netsnmp_agent_session *current_agent_session = NULL;
|
||||
netsnmp_agent_session *
|
||||
netsnmp_get_current_agent_session(void)
|
||||
{
|
||||
return current_agent_session;
|
||||
}
|
||||
|
||||
/*
|
||||
* don't use this!
|
||||
*/
|
||||
void
|
||||
set_current_agent_session(netsnmp_agent_session *asp)
|
||||
{
|
||||
current_agent_session = asp;
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
#include <net-snmp/net-snmp-config.h>
|
||||
|
||||
#include <net-snmp/net-snmp-includes.h>
|
||||
#include <net-snmp/agent/net-snmp-agent-includes.h>
|
||||
|
||||
#include <net-snmp/agent/read_only.h>
|
||||
|
||||
/** @defgroup read_only read_only
|
||||
* Make your handler read_only automatically
|
||||
* The only purpose of this handler is to return an
|
||||
* appropriate error for any requests passed to it in a SET mode.
|
||||
* Inserting it into your handler chain will ensure you're never
|
||||
* asked to perform a SET request so you can ignore those error
|
||||
* conditions.
|
||||
* @ingroup utilities
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** returns a read_only handler that can be injected into a given
|
||||
* handler chain.
|
||||
*/
|
||||
netsnmp_mib_handler *
|
||||
netsnmp_get_read_only_handler(void)
|
||||
{
|
||||
netsnmp_mib_handler *ret = NULL;
|
||||
|
||||
ret = netsnmp_create_handler("read_only",
|
||||
netsnmp_read_only_helper);
|
||||
if (ret) {
|
||||
ret->flags |= MIB_HANDLER_AUTO_NEXT;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/** @internal Implements the read_only handler */
|
||||
int
|
||||
netsnmp_read_only_helper(netsnmp_mib_handler *handler,
|
||||
netsnmp_handler_registration *reginfo,
|
||||
netsnmp_agent_request_info *reqinfo,
|
||||
netsnmp_request_info *requests)
|
||||
{
|
||||
|
||||
DEBUGMSGTL(("helper:read_only", "Got request\n"));
|
||||
|
||||
switch (reqinfo->mode) {
|
||||
|
||||
#ifndef NETSNMP_NO_WRITE_SUPPORT
|
||||
case MODE_SET_RESERVE1:
|
||||
case MODE_SET_RESERVE2:
|
||||
case MODE_SET_ACTION:
|
||||
case MODE_SET_COMMIT:
|
||||
case MODE_SET_FREE:
|
||||
case MODE_SET_UNDO:
|
||||
netsnmp_request_set_error_all(requests, SNMP_ERR_NOTWRITABLE);
|
||||
return SNMP_ERR_NOTWRITABLE;
|
||||
#endif /* NETSNMP_NO_WRITE_SUPPORT */
|
||||
|
||||
case MODE_GET:
|
||||
case MODE_GETNEXT:
|
||||
case MODE_GETBULK:
|
||||
/* next handler called automatically - 'AUTO_NEXT' */
|
||||
return SNMP_ERR_NOERROR;
|
||||
}
|
||||
|
||||
netsnmp_request_set_error_all(requests, SNMP_ERR_GENERR);
|
||||
return SNMP_ERR_GENERR;
|
||||
}
|
||||
|
||||
/** initializes the read_only helper which then registers a read_only
|
||||
* handler as a run-time injectable handler for configuration file
|
||||
* use.
|
||||
*/
|
||||
void
|
||||
netsnmp_init_read_only_helper(void)
|
||||
{
|
||||
netsnmp_register_handler_by_name("read_only",
|
||||
netsnmp_get_read_only_handler());
|
||||
}
|
||||
/** @} */
|
||||
|
||||
@@ -1,381 +0,0 @@
|
||||
#include <net-snmp/net-snmp-config.h>
|
||||
#include <net-snmp/net-snmp-features.h>
|
||||
|
||||
#include <net-snmp/net-snmp-includes.h>
|
||||
#include <net-snmp/agent/net-snmp-agent-includes.h>
|
||||
|
||||
#include <net-snmp/agent/row_merge.h>
|
||||
|
||||
#if HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#else
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
netsnmp_feature_provide(row_merge)
|
||||
netsnmp_feature_child_of(row_merge, row_merge_all)
|
||||
netsnmp_feature_child_of(row_merge_all, mib_helpers)
|
||||
|
||||
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_ROW_MERGE
|
||||
/** @defgroup row_merge row_merge
|
||||
* Calls sub handlers with request for one row at a time.
|
||||
* @ingroup utilities
|
||||
* This helper splits a whole bunch of requests into chunks based on the row
|
||||
* index that they refer to, and passes all requests for a given row to the lower handlers.
|
||||
* This is useful for handlers that don't want to process multiple rows at the
|
||||
* same time, but are happy to iterate through the request list for a single row.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** returns a row_merge handler that can be injected into a given
|
||||
* handler chain.
|
||||
*/
|
||||
netsnmp_mib_handler *
|
||||
netsnmp_get_row_merge_handler(int prefix_len)
|
||||
{
|
||||
netsnmp_mib_handler *ret = NULL;
|
||||
ret = netsnmp_create_handler("row_merge",
|
||||
netsnmp_row_merge_helper_handler);
|
||||
if (ret) {
|
||||
ret->myvoid = (void *)(intptr_t)prefix_len;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/** functionally the same as calling netsnmp_register_handler() but also
|
||||
* injects a row_merge handler at the same time for you. */
|
||||
netsnmp_feature_child_of(register_row_merge, row_merge_all)
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_REGISTER_ROW_MERGE
|
||||
int
|
||||
netsnmp_register_row_merge(netsnmp_handler_registration *reginfo)
|
||||
{
|
||||
netsnmp_inject_handler(reginfo,
|
||||
netsnmp_get_row_merge_handler(reginfo->rootoid_len+1));
|
||||
return netsnmp_register_handler(reginfo);
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_REGISTER_ROW_MERGE */
|
||||
|
||||
static void
|
||||
_rm_status_free(void *mem)
|
||||
{
|
||||
netsnmp_row_merge_status *rm_status = (netsnmp_row_merge_status*)mem;
|
||||
|
||||
if (NULL != rm_status->saved_requests)
|
||||
free(rm_status->saved_requests);
|
||||
|
||||
if (NULL != rm_status->saved_status)
|
||||
free(rm_status->saved_status);
|
||||
|
||||
free(mem);
|
||||
}
|
||||
|
||||
|
||||
/** retrieve row_merge_status
|
||||
*/
|
||||
netsnmp_row_merge_status *
|
||||
netsnmp_row_merge_status_get(netsnmp_handler_registration *reginfo,
|
||||
netsnmp_agent_request_info *reqinfo,
|
||||
int create_missing)
|
||||
{
|
||||
netsnmp_row_merge_status *rm_status;
|
||||
char buf[64];
|
||||
int rc;
|
||||
|
||||
/*
|
||||
* see if we've already been here
|
||||
*/
|
||||
rc = snprintf(buf, sizeof(buf), "row_merge:%p", reginfo);
|
||||
if ((-1 == rc) || ((size_t)rc >= sizeof(buf))) {
|
||||
snmp_log(LOG_ERR,"error creating key\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
rm_status = (netsnmp_row_merge_status*)netsnmp_agent_get_list_data(reqinfo, buf);
|
||||
if ((NULL == rm_status) && create_missing) {
|
||||
netsnmp_data_list *data_list;
|
||||
|
||||
rm_status = SNMP_MALLOC_TYPEDEF(netsnmp_row_merge_status);
|
||||
if (NULL == rm_status) {
|
||||
snmp_log(LOG_ERR,"error allocating memory\n");
|
||||
return NULL;
|
||||
}
|
||||
data_list = netsnmp_create_data_list(buf, rm_status,
|
||||
_rm_status_free);
|
||||
if (NULL == data_list) {
|
||||
free(rm_status);
|
||||
return NULL;
|
||||
}
|
||||
netsnmp_agent_add_list_data(reqinfo, data_list);
|
||||
}
|
||||
|
||||
return rm_status;
|
||||
}
|
||||
|
||||
/** Determine if this is the first row
|
||||
*
|
||||
* returns 1 if this is the first row for this pass of the handler.
|
||||
*/
|
||||
int
|
||||
netsnmp_row_merge_status_first(netsnmp_handler_registration *reginfo,
|
||||
netsnmp_agent_request_info *reqinfo)
|
||||
{
|
||||
netsnmp_row_merge_status *rm_status;
|
||||
|
||||
/*
|
||||
* find status
|
||||
*/
|
||||
rm_status = netsnmp_row_merge_status_get(reginfo, reqinfo, 0);
|
||||
if (NULL == rm_status)
|
||||
return 0;
|
||||
|
||||
return (rm_status->count == 1) ? 1 : (rm_status->current == 1);
|
||||
}
|
||||
|
||||
/** Determine if this is the last row
|
||||
*
|
||||
* returns 1 if this is the last row for this pass of the handler.
|
||||
*/
|
||||
int
|
||||
netsnmp_row_merge_status_last(netsnmp_handler_registration *reginfo,
|
||||
netsnmp_agent_request_info *reqinfo)
|
||||
{
|
||||
netsnmp_row_merge_status *rm_status;
|
||||
|
||||
/*
|
||||
* find status
|
||||
*/
|
||||
rm_status = netsnmp_row_merge_status_get(reginfo, reqinfo, 0);
|
||||
if (NULL == rm_status)
|
||||
return 0;
|
||||
|
||||
return (rm_status->count == 1) ? 1 :
|
||||
(rm_status->current == rm_status->rows);
|
||||
}
|
||||
|
||||
|
||||
#define ROW_MERGE_WAITING 0
|
||||
#define ROW_MERGE_ACTIVE 1
|
||||
#define ROW_MERGE_DONE 2
|
||||
#define ROW_MERGE_HEAD 3
|
||||
|
||||
/** Implements the row_merge handler */
|
||||
int
|
||||
netsnmp_row_merge_helper_handler(netsnmp_mib_handler *handler,
|
||||
netsnmp_handler_registration *reginfo,
|
||||
netsnmp_agent_request_info *reqinfo,
|
||||
netsnmp_request_info *requests)
|
||||
{
|
||||
netsnmp_request_info *request, **saved_requests;
|
||||
char *saved_status;
|
||||
netsnmp_row_merge_status *rm_status;
|
||||
int i, j, ret, tail, count, final_rc = SNMP_ERR_NOERROR;
|
||||
|
||||
/*
|
||||
* Use the prefix length as supplied during registration, rather
|
||||
* than trying to second-guess what the MIB implementer wanted.
|
||||
*/
|
||||
int SKIP_OID = (int)(intptr_t)handler->myvoid;
|
||||
|
||||
DEBUGMSGTL(("helper:row_merge", "Got request (%d): ", SKIP_OID));
|
||||
DEBUGMSGOID(("helper:row_merge", reginfo->rootoid, reginfo->rootoid_len));
|
||||
DEBUGMSG(("helper:row_merge", "\n"));
|
||||
|
||||
/*
|
||||
* find or create status
|
||||
*/
|
||||
rm_status = netsnmp_row_merge_status_get(reginfo, reqinfo, 1);
|
||||
|
||||
/*
|
||||
* Count the requests, and set up an array to keep
|
||||
* track of the original order.
|
||||
*/
|
||||
for (count = 0, request = requests; request; request = request->next) {
|
||||
DEBUGIF("helper:row_merge") {
|
||||
DEBUGMSGTL(("helper:row_merge", " got varbind: "));
|
||||
DEBUGMSGOID(("helper:row_merge", request->requestvb->name,
|
||||
request->requestvb->name_length));
|
||||
DEBUGMSG(("helper:row_merge", "\n"));
|
||||
}
|
||||
count++;
|
||||
}
|
||||
|
||||
/*
|
||||
* Optimization: skip all this if there is just one request
|
||||
*/
|
||||
if(count == 1) {
|
||||
rm_status->count = count;
|
||||
if (requests->processed)
|
||||
return SNMP_ERR_NOERROR;
|
||||
return netsnmp_call_next_handler(handler, reginfo, reqinfo, requests);
|
||||
}
|
||||
|
||||
/*
|
||||
* we really should only have to do this once, instead of every pass.
|
||||
* as a precaution, we'll do it every time, but put in some asserts
|
||||
* to see if we have to.
|
||||
*/
|
||||
/*
|
||||
* if the count changed, re-do everything
|
||||
*/
|
||||
if ((0 != rm_status->count) && (rm_status->count != count)) {
|
||||
/*
|
||||
* ok, i know next/bulk can cause this condition. Probably
|
||||
* GET, too. need to rethink this mode counting. maybe
|
||||
* add the mode to the rm_status structure? xxx-rks
|
||||
*/
|
||||
if ((reqinfo->mode != MODE_GET) &&
|
||||
(reqinfo->mode != MODE_GETNEXT) &&
|
||||
(reqinfo->mode != MODE_GETBULK)) {
|
||||
netsnmp_assert((NULL != rm_status->saved_requests) &&
|
||||
(NULL != rm_status->saved_status));
|
||||
}
|
||||
DEBUGMSGTL(("helper:row_merge", "count changed! do over...\n"));
|
||||
|
||||
SNMP_FREE(rm_status->saved_requests);
|
||||
SNMP_FREE(rm_status->saved_status);
|
||||
|
||||
rm_status->count = 0;
|
||||
rm_status->rows = 0;
|
||||
}
|
||||
|
||||
if (0 == rm_status->count) {
|
||||
/*
|
||||
* allocate memory for saved structure
|
||||
*/
|
||||
rm_status->saved_requests =
|
||||
(netsnmp_request_info**)calloc(count+1,
|
||||
sizeof(netsnmp_request_info*));
|
||||
rm_status->saved_status = (char*)calloc(count,sizeof(char));
|
||||
}
|
||||
|
||||
saved_status = rm_status->saved_status;
|
||||
saved_requests = rm_status->saved_requests;
|
||||
|
||||
/*
|
||||
* set up saved requests, and set any processed requests to done
|
||||
*/
|
||||
i = 0;
|
||||
for (request = requests; request; request = request->next, i++) {
|
||||
if (request->processed) {
|
||||
saved_status[i] = ROW_MERGE_DONE;
|
||||
DEBUGMSGTL(("helper:row_merge", " skipping processed oid: "));
|
||||
DEBUGMSGOID(("helper:row_merge", request->requestvb->name,
|
||||
request->requestvb->name_length));
|
||||
DEBUGMSG(("helper:row_merge", "\n"));
|
||||
}
|
||||
else
|
||||
saved_status[i] = ROW_MERGE_WAITING;
|
||||
if (0 != rm_status->count)
|
||||
netsnmp_assert(saved_requests[i] == request);
|
||||
saved_requests[i] = request;
|
||||
saved_requests[i]->prev = NULL;
|
||||
}
|
||||
saved_requests[i] = NULL;
|
||||
|
||||
/*
|
||||
* Note that saved_requests[count] is valid
|
||||
* (because of the 'count+1' in the calloc above),
|
||||
* but NULL (since it's past the end of the list).
|
||||
* This simplifies the re-linking later.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Work through the (unprocessed) requests in order.
|
||||
* For each of these, search the rest of the list for any
|
||||
* matching indexes, and link them into a new list.
|
||||
*/
|
||||
for (i=0; i<count; i++) {
|
||||
if (saved_status[i] != ROW_MERGE_WAITING)
|
||||
continue;
|
||||
|
||||
if (0 == rm_status->count)
|
||||
rm_status->rows++;
|
||||
DEBUGMSGTL(("helper:row_merge", " row %d oid[%d]: ", rm_status->rows, i));
|
||||
DEBUGMSGOID(("helper:row_merge", saved_requests[i]->requestvb->name,
|
||||
saved_requests[i]->requestvb->name_length));
|
||||
DEBUGMSG(("helper:row_merge", "\n"));
|
||||
|
||||
saved_requests[i]->next = NULL;
|
||||
saved_status[i] = ROW_MERGE_HEAD;
|
||||
tail = i;
|
||||
for (j=i+1; j<count; j++) {
|
||||
if (saved_status[j] != ROW_MERGE_WAITING)
|
||||
continue;
|
||||
|
||||
DEBUGMSGTL(("helper:row_merge", "? oid[%d]: ", j));
|
||||
DEBUGMSGOID(("helper:row_merge",
|
||||
saved_requests[j]->requestvb->name,
|
||||
saved_requests[j]->requestvb->name_length));
|
||||
if (!snmp_oid_compare(
|
||||
saved_requests[i]->requestvb->name+SKIP_OID,
|
||||
saved_requests[i]->requestvb->name_length-SKIP_OID,
|
||||
saved_requests[j]->requestvb->name+SKIP_OID,
|
||||
saved_requests[j]->requestvb->name_length-SKIP_OID)) {
|
||||
DEBUGMSG(("helper:row_merge", " match\n"));
|
||||
saved_requests[tail]->next = saved_requests[j];
|
||||
saved_requests[j]->next = NULL;
|
||||
saved_requests[j]->prev = saved_requests[tail];
|
||||
saved_status[j] = ROW_MERGE_ACTIVE;
|
||||
tail = j;
|
||||
}
|
||||
else
|
||||
DEBUGMSG(("helper:row_merge", " no match\n"));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* not that we have a list for each row, call next handler...
|
||||
*/
|
||||
if (0 == rm_status->count)
|
||||
rm_status->count = count;
|
||||
rm_status->current = 0;
|
||||
for (i=0; i<count; i++) {
|
||||
if (saved_status[i] != ROW_MERGE_HEAD)
|
||||
continue;
|
||||
|
||||
/*
|
||||
* found the head of a new row,
|
||||
* call the next handler with this list
|
||||
*/
|
||||
rm_status->current++;
|
||||
ret = netsnmp_call_next_handler(handler, reginfo, reqinfo,
|
||||
saved_requests[i]);
|
||||
if (ret != SNMP_ERR_NOERROR) {
|
||||
snmp_log(LOG_WARNING,
|
||||
"bad rc (%d) from next handler in row_merge\n", ret);
|
||||
if (SNMP_ERR_NOERROR == final_rc)
|
||||
final_rc = ret;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* restore original linked list
|
||||
*/
|
||||
for (i=0; i<count; i++) {
|
||||
saved_requests[i]->next = saved_requests[i+1];
|
||||
if (i>0)
|
||||
saved_requests[i]->prev = saved_requests[i-1];
|
||||
}
|
||||
|
||||
return final_rc;
|
||||
}
|
||||
|
||||
/**
|
||||
* initializes the row_merge helper which then registers a row_merge
|
||||
* handler as a run-time injectable handler for configuration file
|
||||
* use.
|
||||
*/
|
||||
void
|
||||
netsnmp_init_row_merge(void)
|
||||
{
|
||||
netsnmp_register_handler_by_name("row_merge",
|
||||
netsnmp_get_row_merge_handler(-1));
|
||||
}
|
||||
#else /* NETSNMP_FEATURE_REMOVE_ROW_MERGE */
|
||||
netsnmp_feature_unused(row_merge);
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_ROW_MERGE */
|
||||
|
||||
|
||||
/** @} */
|
||||
|
||||
@@ -1,199 +0,0 @@
|
||||
/* Portions of this file are subject to the following copyright(s). See
|
||||
* the Net-SNMP's COPYING file for more details and other copyrights
|
||||
* that may apply:
|
||||
*/
|
||||
/*
|
||||
* Portions of this file are copyrighted by:
|
||||
* Copyright <20> 2003 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms specified in the COPYING file
|
||||
* distributed with the Net-SNMP package.
|
||||
*/
|
||||
#include <net-snmp/net-snmp-config.h>
|
||||
|
||||
#include <net-snmp/net-snmp-includes.h>
|
||||
#include <net-snmp/agent/net-snmp-agent-includes.h>
|
||||
|
||||
#include <net-snmp/agent/scalar.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#if HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#else
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#include <net-snmp/agent/instance.h>
|
||||
#include <net-snmp/agent/serialize.h>
|
||||
#include <net-snmp/agent/read_only.h>
|
||||
|
||||
/** @defgroup scalar scalar
|
||||
* Process scalars easily.
|
||||
* @ingroup leaf
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates a scalar handler calling netsnmp_create_handler with a
|
||||
* handler name defaulted to "scalar" and access method,
|
||||
* netsnmp_scalar_helper_handler.
|
||||
*
|
||||
* @return Returns a pointer to a netsnmp_mib_handler struct which contains
|
||||
* the handler's name and the access method
|
||||
*
|
||||
* @see netsnmp_get_scalar_handler
|
||||
* @see netsnmp_register_scalar
|
||||
*/
|
||||
netsnmp_mib_handler *
|
||||
netsnmp_get_scalar_handler(void)
|
||||
{
|
||||
return netsnmp_create_handler("scalar",
|
||||
netsnmp_scalar_helper_handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function registers a scalar helper handler. The registered OID,
|
||||
* reginfo->rootoid, space is extended for the instance subid using
|
||||
* realloc() but the reginfo->rootoid_len length is not extended just yet.
|
||||
* .This function subsequently injects the instance, scalar, and serialize
|
||||
* helper handlers before actually registering reginfo.
|
||||
*
|
||||
* Each handler is injected/pushed to the top of the handler chain list
|
||||
* and will be processed last in first out, LIFO.
|
||||
*
|
||||
* @param reginfo a handler registration structure which could get created
|
||||
* using netsnmp_create_handler_registration. Used to register
|
||||
* a scalar helper handler.
|
||||
*
|
||||
* @return MIB_REGISTERED_OK is returned if the registration was a success.
|
||||
* Failures are MIB_REGISTRATION_FAILURE and MIB_DUPLICATE_REGISTRATION.
|
||||
*
|
||||
* @see netsnmp_register_read_only_scalar
|
||||
* @see netsnmp_get_scalar_handler
|
||||
*/
|
||||
|
||||
int
|
||||
netsnmp_register_scalar(netsnmp_handler_registration *reginfo)
|
||||
{
|
||||
/*
|
||||
* Extend the registered OID with space for the instance subid
|
||||
* (but don't extend the length just yet!)
|
||||
*/
|
||||
reginfo->rootoid = (oid*)realloc(reginfo->rootoid,
|
||||
(reginfo->rootoid_len+1) * sizeof(oid) );
|
||||
reginfo->rootoid[ reginfo->rootoid_len ] = 0;
|
||||
|
||||
netsnmp_inject_handler(reginfo, netsnmp_get_instance_handler());
|
||||
netsnmp_inject_handler(reginfo, netsnmp_get_scalar_handler());
|
||||
return netsnmp_register_serialize(reginfo);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This function registers a read only scalar helper handler. This
|
||||
* function is very similar to netsnmp_register_scalar the only addition
|
||||
* is that the "read_only" handler is injected into the handler chain
|
||||
* prior to injecting the serialize handler and registering reginfo.
|
||||
*
|
||||
* @param reginfo a handler registration structure which could get created
|
||||
* using netsnmp_create_handler_registration. Used to register
|
||||
* a read only scalar helper handler.
|
||||
*
|
||||
* @return MIB_REGISTERED_OK is returned if the registration was a success.
|
||||
* Failures are MIB_REGISTRATION_FAILURE and MIB_DUPLICATE_REGISTRATION.
|
||||
*
|
||||
* @see netsnmp_register_scalar
|
||||
* @see netsnmp_get_scalar_handler
|
||||
*
|
||||
*/
|
||||
|
||||
int
|
||||
netsnmp_register_read_only_scalar(netsnmp_handler_registration *reginfo)
|
||||
{
|
||||
/*
|
||||
* Extend the registered OID with space for the instance subid
|
||||
* (but don't extend the length just yet!)
|
||||
*/
|
||||
reginfo->rootoid = (oid*)realloc(reginfo->rootoid,
|
||||
(reginfo->rootoid_len+1) * sizeof(oid) );
|
||||
reginfo->rootoid[ reginfo->rootoid_len ] = 0;
|
||||
|
||||
netsnmp_inject_handler(reginfo, netsnmp_get_instance_handler());
|
||||
netsnmp_inject_handler(reginfo, netsnmp_get_scalar_handler());
|
||||
netsnmp_inject_handler(reginfo, netsnmp_get_read_only_handler());
|
||||
return netsnmp_register_serialize(reginfo);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
netsnmp_scalar_helper_handler(netsnmp_mib_handler *handler,
|
||||
netsnmp_handler_registration *reginfo,
|
||||
netsnmp_agent_request_info *reqinfo,
|
||||
netsnmp_request_info *requests)
|
||||
{
|
||||
|
||||
netsnmp_variable_list *var = requests->requestvb;
|
||||
|
||||
int ret, cmp;
|
||||
int namelen;
|
||||
|
||||
DEBUGMSGTL(("helper:scalar", "Got request:\n"));
|
||||
namelen = SNMP_MIN(requests->requestvb->name_length,
|
||||
reginfo->rootoid_len);
|
||||
cmp = snmp_oid_compare(requests->requestvb->name, namelen,
|
||||
reginfo->rootoid, reginfo->rootoid_len);
|
||||
|
||||
DEBUGMSGTL(("helper:scalar", " oid:"));
|
||||
DEBUGMSGOID(("helper:scalar", var->name, var->name_length));
|
||||
DEBUGMSG(("helper:scalar", "\n"));
|
||||
|
||||
switch (reqinfo->mode) {
|
||||
case MODE_GET:
|
||||
if (cmp != 0) {
|
||||
netsnmp_set_request_error(reqinfo, requests,
|
||||
SNMP_NOSUCHOBJECT);
|
||||
return SNMP_ERR_NOERROR;
|
||||
} else {
|
||||
reginfo->rootoid[reginfo->rootoid_len++] = 0;
|
||||
ret = netsnmp_call_next_handler(handler, reginfo, reqinfo,
|
||||
requests);
|
||||
reginfo->rootoid_len--;
|
||||
return ret;
|
||||
}
|
||||
break;
|
||||
|
||||
#ifndef NETSNMP_NO_WRITE_SUPPORT
|
||||
case MODE_SET_RESERVE1:
|
||||
case MODE_SET_RESERVE2:
|
||||
case MODE_SET_ACTION:
|
||||
case MODE_SET_COMMIT:
|
||||
case MODE_SET_UNDO:
|
||||
case MODE_SET_FREE:
|
||||
if (cmp != 0) {
|
||||
netsnmp_set_request_error(reqinfo, requests,
|
||||
SNMP_ERR_NOCREATION);
|
||||
return SNMP_ERR_NOERROR;
|
||||
} else {
|
||||
reginfo->rootoid[reginfo->rootoid_len++] = 0;
|
||||
ret = netsnmp_call_next_handler(handler, reginfo, reqinfo,
|
||||
requests);
|
||||
reginfo->rootoid_len--;
|
||||
return ret;
|
||||
}
|
||||
break;
|
||||
#endif /* NETSNMP_NO_WRITE_SUPPORT */
|
||||
|
||||
case MODE_GETNEXT:
|
||||
reginfo->rootoid[reginfo->rootoid_len++] = 0;
|
||||
ret = netsnmp_call_next_handler(handler, reginfo, reqinfo, requests);
|
||||
reginfo->rootoid_len--;
|
||||
return ret;
|
||||
}
|
||||
/*
|
||||
* got here only if illegal mode found
|
||||
*/
|
||||
return SNMP_ERR_GENERR;
|
||||
}
|
||||
|
||||
/** @}
|
||||
*/
|
||||
@@ -1,209 +0,0 @@
|
||||
#include <net-snmp/net-snmp-config.h>
|
||||
|
||||
#include <net-snmp/net-snmp-includes.h>
|
||||
#include <net-snmp/agent/net-snmp-agent-includes.h>
|
||||
|
||||
#include <net-snmp/agent/scalar_group.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#if HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#else
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#include <net-snmp/agent/instance.h>
|
||||
#include <net-snmp/agent/serialize.h>
|
||||
|
||||
static netsnmp_scalar_group*
|
||||
clone_scalar_group(netsnmp_scalar_group* src)
|
||||
{
|
||||
netsnmp_scalar_group *t = SNMP_MALLOC_TYPEDEF(netsnmp_scalar_group);
|
||||
if(t != NULL) {
|
||||
t->lbound = src->lbound;
|
||||
t->ubound = src->ubound;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
/** @defgroup scalar_group_group scalar_group
|
||||
* Process groups of scalars.
|
||||
* @ingroup leaf
|
||||
* @{
|
||||
*/
|
||||
netsnmp_mib_handler *
|
||||
netsnmp_get_scalar_group_handler(oid first, oid last)
|
||||
{
|
||||
netsnmp_mib_handler *ret = NULL;
|
||||
netsnmp_scalar_group *sgroup = NULL;
|
||||
|
||||
ret = netsnmp_create_handler("scalar_group",
|
||||
netsnmp_scalar_group_helper_handler);
|
||||
if (ret) {
|
||||
sgroup = SNMP_MALLOC_TYPEDEF(netsnmp_scalar_group);
|
||||
if (NULL == sgroup) {
|
||||
netsnmp_handler_free(ret);
|
||||
ret = NULL;
|
||||
}
|
||||
else {
|
||||
sgroup->lbound = first;
|
||||
sgroup->ubound = last;
|
||||
ret->myvoid = (void *)sgroup;
|
||||
ret->data_free = free;
|
||||
ret->data_clone = (void *(*)(void *))clone_scalar_group;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
netsnmp_register_scalar_group(netsnmp_handler_registration *reginfo,
|
||||
oid first, oid last)
|
||||
{
|
||||
netsnmp_inject_handler(reginfo, netsnmp_get_instance_handler());
|
||||
netsnmp_inject_handler(reginfo, netsnmp_get_scalar_group_handler(first, last));
|
||||
return netsnmp_register_serialize(reginfo);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
netsnmp_scalar_group_helper_handler(netsnmp_mib_handler *handler,
|
||||
netsnmp_handler_registration *reginfo,
|
||||
netsnmp_agent_request_info *reqinfo,
|
||||
netsnmp_request_info *requests)
|
||||
{
|
||||
netsnmp_variable_list *var = requests->requestvb;
|
||||
|
||||
netsnmp_scalar_group *sgroup = (netsnmp_scalar_group *)handler->myvoid;
|
||||
int ret, cmp;
|
||||
int namelen;
|
||||
oid subid, root_tmp[MAX_OID_LEN], *root_save;
|
||||
|
||||
DEBUGMSGTL(("helper:scalar_group", "Got request:\n"));
|
||||
namelen = SNMP_MIN(requests->requestvb->name_length,
|
||||
reginfo->rootoid_len);
|
||||
cmp = snmp_oid_compare(requests->requestvb->name, namelen,
|
||||
reginfo->rootoid, reginfo->rootoid_len);
|
||||
|
||||
DEBUGMSGTL(( "helper:scalar_group", " cmp=%d, oid:", cmp));
|
||||
DEBUGMSGOID(("helper:scalar_group", var->name, var->name_length));
|
||||
DEBUGMSG(( "helper:scalar_group", "\n"));
|
||||
|
||||
/*
|
||||
* copy root oid to root_tmp, set instance to 0. (subid set later on)
|
||||
* save rootoid, since we'll replace it before calling next handler,
|
||||
* and need to restore it afterwards.
|
||||
*/
|
||||
memcpy(root_tmp, reginfo->rootoid, reginfo->rootoid_len * sizeof(oid));
|
||||
root_tmp[reginfo->rootoid_len + 1] = 0;
|
||||
root_save = reginfo->rootoid;
|
||||
|
||||
ret = SNMP_ERR_NOCREATION;
|
||||
switch (reqinfo->mode) {
|
||||
/*
|
||||
* The handling of "exact" requests is basically the same.
|
||||
* The only difference between GET and SET requests is the
|
||||
* error/exception to return on failure.
|
||||
*/
|
||||
case MODE_GET:
|
||||
ret = SNMP_NOSUCHOBJECT;
|
||||
/* Fallthrough */
|
||||
|
||||
#ifndef NETSNMP_NO_WRITE_SUPPORT
|
||||
case MODE_SET_RESERVE1:
|
||||
case MODE_SET_RESERVE2:
|
||||
case MODE_SET_ACTION:
|
||||
case MODE_SET_COMMIT:
|
||||
case MODE_SET_UNDO:
|
||||
case MODE_SET_FREE:
|
||||
#endif /* NETSNMP_NO_WRITE_SUPPORT */
|
||||
if (cmp != 0 ||
|
||||
requests->requestvb->name_length <= reginfo->rootoid_len) {
|
||||
/*
|
||||
* Common prefix doesn't match, or only *just* matches
|
||||
* the registered root (so can't possibly match a scalar)
|
||||
*/
|
||||
netsnmp_set_request_error(reqinfo, requests, ret);
|
||||
return SNMP_ERR_NOERROR;
|
||||
} else {
|
||||
/*
|
||||
* Otherwise,
|
||||
* extract the object subidentifier from the request,
|
||||
* check this is (probably) valid, and then fudge the
|
||||
* registered 'rootoid' to match, before passing the
|
||||
* request off to the next handler ('scalar').
|
||||
*
|
||||
* Note that we don't bother checking instance subidentifiers
|
||||
* here. That's left to the scalar helper.
|
||||
*/
|
||||
subid = requests->requestvb->name[reginfo->rootoid_len];
|
||||
if (subid < sgroup->lbound ||
|
||||
subid > sgroup->ubound) {
|
||||
netsnmp_set_request_error(reqinfo, requests, ret);
|
||||
return SNMP_ERR_NOERROR;
|
||||
}
|
||||
root_tmp[reginfo->rootoid_len] = subid;
|
||||
reginfo->rootoid_len += 2;
|
||||
reginfo->rootoid = root_tmp;
|
||||
ret = netsnmp_call_next_handler(handler, reginfo, reqinfo,
|
||||
requests);
|
||||
reginfo->rootoid = root_save;
|
||||
reginfo->rootoid_len -= 2;
|
||||
return ret;
|
||||
}
|
||||
break;
|
||||
|
||||
case MODE_GETNEXT:
|
||||
/*
|
||||
* If we're being asked for something before (or exactly matches)
|
||||
* the registered root OID, then start with the first object.
|
||||
* If we're being asked for something that exactly matches an object
|
||||
* OID, then that's what we pass down.
|
||||
* Otherwise, we pass down the OID of the *next* object....
|
||||
*/
|
||||
if (cmp < 0 ||
|
||||
requests->requestvb->name_length <= reginfo->rootoid_len) {
|
||||
subid = sgroup->lbound;
|
||||
} else if (requests->requestvb->name_length == reginfo->rootoid_len+1)
|
||||
subid = requests->requestvb->name[reginfo->rootoid_len];
|
||||
else
|
||||
subid = requests->requestvb->name[reginfo->rootoid_len]+1;
|
||||
|
||||
/*
|
||||
* ... always assuming this is (potentially) valid, of course.
|
||||
*/
|
||||
if (subid < sgroup->lbound)
|
||||
subid = sgroup->lbound;
|
||||
else if (subid > sgroup->ubound)
|
||||
return SNMP_ERR_NOERROR;
|
||||
|
||||
root_tmp[reginfo->rootoid_len] = subid;
|
||||
reginfo->rootoid_len += 2;
|
||||
reginfo->rootoid = root_tmp;
|
||||
ret = netsnmp_call_next_handler(handler, reginfo, reqinfo,
|
||||
requests);
|
||||
/*
|
||||
* If we didn't get an answer (due to holes in the group)
|
||||
* set things up to retry again.
|
||||
*/
|
||||
if (!requests->delegated &&
|
||||
(requests->requestvb->type == ASN_NULL ||
|
||||
requests->requestvb->type == SNMP_NOSUCHOBJECT ||
|
||||
requests->requestvb->type == SNMP_NOSUCHINSTANCE)) {
|
||||
snmp_set_var_objid(requests->requestvb,
|
||||
reginfo->rootoid, reginfo->rootoid_len - 1);
|
||||
requests->requestvb->name[reginfo->rootoid_len - 2] = ++subid;
|
||||
requests->requestvb->type = ASN_PRIV_RETRY;
|
||||
}
|
||||
reginfo->rootoid = root_save;
|
||||
reginfo->rootoid_len -= 2;
|
||||
return ret;
|
||||
}
|
||||
/*
|
||||
* got here only if illegal mode found
|
||||
*/
|
||||
return SNMP_ERR_GENERR;
|
||||
}
|
||||
|
||||
/** @}
|
||||
*/
|
||||
@@ -1,93 +0,0 @@
|
||||
#include <net-snmp/net-snmp-config.h>
|
||||
|
||||
#include <net-snmp/net-snmp-includes.h>
|
||||
#include <net-snmp/agent/net-snmp-agent-includes.h>
|
||||
|
||||
#include <net-snmp/agent/serialize.h>
|
||||
|
||||
/** @defgroup serialize serialize
|
||||
* Calls sub handlers one request at a time.
|
||||
* @ingroup utilities
|
||||
* This functionally passes in one request at a time
|
||||
* into lower handlers rather than a whole bunch of requests at once.
|
||||
* This is useful for handlers that don't want to iterate through the
|
||||
* request lists themselves. Generally, this is probably less
|
||||
* efficient so use with caution. The serialize handler might be
|
||||
* useable to dynamically fix handlers with broken looping code,
|
||||
* however.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** returns a serialize handler that can be injected into a given
|
||||
* handler chain.
|
||||
*/
|
||||
netsnmp_mib_handler *
|
||||
netsnmp_get_serialize_handler(void)
|
||||
{
|
||||
return netsnmp_create_handler("serialize",
|
||||
netsnmp_serialize_helper_handler);
|
||||
}
|
||||
|
||||
/** functionally the same as calling netsnmp_register_handler() but also
|
||||
* injects a serialize handler at the same time for you. */
|
||||
int
|
||||
netsnmp_register_serialize(netsnmp_handler_registration *reginfo)
|
||||
{
|
||||
netsnmp_inject_handler(reginfo, netsnmp_get_serialize_handler());
|
||||
return netsnmp_register_handler(reginfo);
|
||||
}
|
||||
|
||||
/** Implements the serial handler */
|
||||
int
|
||||
netsnmp_serialize_helper_handler(netsnmp_mib_handler *handler,
|
||||
netsnmp_handler_registration *reginfo,
|
||||
netsnmp_agent_request_info *reqinfo,
|
||||
netsnmp_request_info *requests)
|
||||
{
|
||||
|
||||
netsnmp_request_info *request, *requesttmp;
|
||||
|
||||
DEBUGMSGTL(("helper:serialize", "Got request\n"));
|
||||
/*
|
||||
* loop through requests
|
||||
*/
|
||||
for (request = requests; request; request = request->next) {
|
||||
int ret;
|
||||
|
||||
/*
|
||||
* store next pointer and delete it
|
||||
*/
|
||||
requesttmp = request->next;
|
||||
request->next = NULL;
|
||||
|
||||
/*
|
||||
* call the next handler
|
||||
*/
|
||||
ret =
|
||||
netsnmp_call_next_handler(handler, reginfo, reqinfo, request);
|
||||
|
||||
/*
|
||||
* restore original next pointer
|
||||
*/
|
||||
request->next = requesttmp;
|
||||
|
||||
if (ret != SNMP_ERR_NOERROR)
|
||||
return ret;
|
||||
}
|
||||
|
||||
return SNMP_ERR_NOERROR;
|
||||
}
|
||||
|
||||
/**
|
||||
* initializes the serialize helper which then registers a serialize
|
||||
* handler as a run-time injectable handler for configuration file
|
||||
* use.
|
||||
*/
|
||||
void
|
||||
netsnmp_init_serialize(void)
|
||||
{
|
||||
netsnmp_register_handler_by_name("serialize",
|
||||
netsnmp_get_serialize_handler());
|
||||
}
|
||||
/** @} */
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
#include <net-snmp/net-snmp-config.h>
|
||||
#include <net-snmp/net-snmp-features.h>
|
||||
#include <net-snmp/net-snmp-includes.h>
|
||||
#include <net-snmp/agent/net-snmp-agent-includes.h>
|
||||
|
||||
#include <net-snmp/agent/snmp_get_statistic.h>
|
||||
|
||||
netsnmp_feature_provide(helper_statistics)
|
||||
netsnmp_feature_child_of(helper_statistics, mib_helpers)
|
||||
|
||||
#ifdef NETSNMP_FEATURE_REQUIRE_HELPER_STATISTICS
|
||||
/* if we're not needed, then neither is this */
|
||||
netsnmp_feature_require(statistics)
|
||||
#endif
|
||||
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_HELPER_STATISTICS
|
||||
static int
|
||||
netsnmp_get_statistic_helper_handler(netsnmp_mib_handler *handler,
|
||||
netsnmp_handler_registration *reginfo,
|
||||
netsnmp_agent_request_info *reqinfo,
|
||||
netsnmp_request_info *requests)
|
||||
{
|
||||
if (reqinfo->mode == MODE_GET) {
|
||||
const oid idx = requests->requestvb->name[reginfo->rootoid_len - 2] +
|
||||
(oid)(uintptr_t)handler->myvoid;
|
||||
uint32_t value;
|
||||
|
||||
if (idx > NETSNMP_STAT_MAX_STATS)
|
||||
return SNMP_ERR_GENERR;
|
||||
value = snmp_get_statistic(idx);
|
||||
snmp_set_var_typed_value(requests->requestvb, ASN_COUNTER,
|
||||
(const u_char*)&value, sizeof(value));
|
||||
return SNMP_ERR_NOERROR;
|
||||
}
|
||||
return SNMP_ERR_GENERR;
|
||||
}
|
||||
|
||||
static netsnmp_mib_handler *
|
||||
netsnmp_get_statistic_handler(int offset)
|
||||
{
|
||||
netsnmp_mib_handler *ret =
|
||||
netsnmp_create_handler("get_statistic",
|
||||
netsnmp_get_statistic_helper_handler);
|
||||
if (ret) {
|
||||
ret->flags |= MIB_HANDLER_AUTO_NEXT;
|
||||
ret->myvoid = (void*)(uintptr_t)offset;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
netsnmp_register_statistic_handler(netsnmp_handler_registration *reginfo,
|
||||
oid start, int begin, int end)
|
||||
{
|
||||
netsnmp_inject_handler(reginfo,
|
||||
netsnmp_get_statistic_handler(begin - start));
|
||||
return netsnmp_register_scalar_group(reginfo, start, start + (end - begin));
|
||||
}
|
||||
#else /* !NETSNMP_FEATURE_REMOVE_HELPER_GET_STATISTICS */
|
||||
netsnmp_feature_unused(helper_statistics);
|
||||
#endif /* !NETSNMP_FEATURE_REMOVE_HELPER_GET_STATISTICS */
|
||||
@@ -1,252 +0,0 @@
|
||||
#include <net-snmp/net-snmp-config.h>
|
||||
|
||||
#include <net-snmp/net-snmp-features.h>
|
||||
#include <net-snmp/net-snmp-includes.h>
|
||||
#include <net-snmp/agent/net-snmp-agent-includes.h>
|
||||
|
||||
netsnmp_feature_provide(stash_cache)
|
||||
netsnmp_feature_child_of(stash_cache, mib_helpers)
|
||||
#ifdef NETSNMP_FEATURE_REQUIRE_STASH_CACHE
|
||||
netsnmp_feature_require(oid_stash)
|
||||
netsnmp_feature_require(oid_stash_iterate)
|
||||
netsnmp_feature_require(oid_stash_get_data)
|
||||
#endif
|
||||
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_STASH_CACHE
|
||||
#include <net-snmp/agent/stash_to_next.h>
|
||||
|
||||
#include <net-snmp/agent/stash_cache.h>
|
||||
|
||||
extern NetsnmpCacheLoad _netsnmp_stash_cache_load;
|
||||
extern NetsnmpCacheFree _netsnmp_stash_cache_free;
|
||||
|
||||
/** @defgroup stash_cache stash_cache
|
||||
* Automatically caches data for certain handlers.
|
||||
* This handler caches data in an optimized way which may alleviate
|
||||
* the need for the lower level handlers to perform as much
|
||||
* optimization. Specifically, somewhere in the lower level handlers
|
||||
* must be a handler that supports the MODE_GET_STASH operation.
|
||||
* Note that the table_iterator helper supports this.
|
||||
* @ingroup handler
|
||||
* @{
|
||||
*/
|
||||
|
||||
netsnmp_stash_cache_info *
|
||||
netsnmp_get_new_stash_cache(void)
|
||||
{
|
||||
netsnmp_stash_cache_info *cinfo;
|
||||
|
||||
cinfo = SNMP_MALLOC_TYPEDEF(netsnmp_stash_cache_info);
|
||||
if (cinfo != NULL)
|
||||
cinfo->cache_length = 30;
|
||||
return cinfo;
|
||||
}
|
||||
|
||||
/** returns a stash_cache handler that can be injected into a given
|
||||
* handler chain (with the specified timeout and root OID values),
|
||||
* but *only* if that handler chain explicitly supports stash cache processing.
|
||||
*/
|
||||
netsnmp_mib_handler *
|
||||
netsnmp_get_timed_bare_stash_cache_handler(int timeout, oid *rootoid, size_t rootoid_len)
|
||||
{
|
||||
netsnmp_mib_handler *handler;
|
||||
netsnmp_cache *cinfo;
|
||||
|
||||
cinfo = netsnmp_cache_create( timeout, _netsnmp_stash_cache_load,
|
||||
_netsnmp_stash_cache_free, rootoid, rootoid_len );
|
||||
|
||||
if (!cinfo)
|
||||
return NULL;
|
||||
|
||||
handler = netsnmp_cache_handler_get( cinfo );
|
||||
if (!handler) {
|
||||
free(cinfo);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
handler->next = netsnmp_create_handler("stash_cache", netsnmp_stash_cache_helper);
|
||||
if (!handler->next) {
|
||||
netsnmp_handler_free(handler);
|
||||
free(cinfo);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
handler->myvoid = cinfo;
|
||||
netsnmp_cache_handler_owns_cache(handler);
|
||||
|
||||
return handler;
|
||||
}
|
||||
|
||||
/** returns a single stash_cache handler that can be injected into a given
|
||||
* handler chain (with a fixed timeout), but *only* if that handler chain
|
||||
* explicitly supports stash cache processing.
|
||||
*/
|
||||
netsnmp_mib_handler *
|
||||
netsnmp_get_bare_stash_cache_handler(void)
|
||||
{
|
||||
return netsnmp_get_timed_bare_stash_cache_handler( 30, NULL, 0 );
|
||||
}
|
||||
|
||||
/** returns a stash_cache handler sub-chain that can be injected into a given
|
||||
* (arbitrary) handler chain, using a fixed cache timeout.
|
||||
*/
|
||||
netsnmp_mib_handler *
|
||||
netsnmp_get_stash_cache_handler(void)
|
||||
{
|
||||
netsnmp_mib_handler *handler = netsnmp_get_bare_stash_cache_handler();
|
||||
if (handler && handler->next) {
|
||||
handler->next->next = netsnmp_get_stash_to_next_handler();
|
||||
}
|
||||
return handler;
|
||||
}
|
||||
|
||||
/** returns a stash_cache handler sub-chain that can be injected into a given
|
||||
* (arbitrary) handler chain, using a configurable cache timeout.
|
||||
*/
|
||||
netsnmp_mib_handler *
|
||||
netsnmp_get_timed_stash_cache_handler(int timeout, oid *rootoid, size_t rootoid_len)
|
||||
{
|
||||
netsnmp_mib_handler *handler =
|
||||
netsnmp_get_timed_bare_stash_cache_handler(timeout, rootoid, rootoid_len);
|
||||
if (handler && handler->next) {
|
||||
handler->next->next = netsnmp_get_stash_to_next_handler();
|
||||
}
|
||||
return handler;
|
||||
}
|
||||
|
||||
/** extracts a pointer to the stash_cache info from the reqinfo structure. */
|
||||
netsnmp_oid_stash_node **
|
||||
netsnmp_extract_stash_cache(netsnmp_agent_request_info *reqinfo)
|
||||
{
|
||||
return (netsnmp_oid_stash_node**)netsnmp_agent_get_list_data(reqinfo, STASH_CACHE_NAME);
|
||||
}
|
||||
|
||||
|
||||
/** @internal Implements the stash_cache handler */
|
||||
int
|
||||
netsnmp_stash_cache_helper(netsnmp_mib_handler *handler,
|
||||
netsnmp_handler_registration *reginfo,
|
||||
netsnmp_agent_request_info *reqinfo,
|
||||
netsnmp_request_info *requests)
|
||||
{
|
||||
netsnmp_cache *cache;
|
||||
netsnmp_stash_cache_info *cinfo;
|
||||
netsnmp_oid_stash_node *cnode;
|
||||
netsnmp_variable_list *cdata;
|
||||
netsnmp_request_info *request;
|
||||
|
||||
DEBUGMSGTL(("helper:stash_cache", "Got request\n"));
|
||||
|
||||
cache = netsnmp_cache_reqinfo_extract( reqinfo, reginfo->handlerName );
|
||||
if (!cache) {
|
||||
DEBUGMSGTL(("helper:stash_cache", "No cache structure\n"));
|
||||
return SNMP_ERR_GENERR;
|
||||
}
|
||||
cinfo = (netsnmp_stash_cache_info *) cache->magic;
|
||||
|
||||
switch (reqinfo->mode) {
|
||||
|
||||
case MODE_GET:
|
||||
DEBUGMSGTL(("helper:stash_cache", "Processing GET request\n"));
|
||||
for(request = requests; request; request = request->next) {
|
||||
cdata = (netsnmp_variable_list*)
|
||||
netsnmp_oid_stash_get_data(cinfo->cache,
|
||||
requests->requestvb->name,
|
||||
requests->requestvb->name_length);
|
||||
if (cdata && cdata->val.string && cdata->val_len) {
|
||||
DEBUGMSGTL(("helper:stash_cache", "Found cached GET varbind\n"));
|
||||
DEBUGMSGOID(("helper:stash_cache", cdata->name, cdata->name_length));
|
||||
DEBUGMSG(("helper:stash_cache", "\n"));
|
||||
snmp_set_var_typed_value(request->requestvb, cdata->type,
|
||||
cdata->val.string, cdata->val_len);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case MODE_GETNEXT:
|
||||
DEBUGMSGTL(("helper:stash_cache", "Processing GETNEXT request\n"));
|
||||
for(request = requests; request; request = request->next) {
|
||||
cnode =
|
||||
netsnmp_oid_stash_getnext_node(cinfo->cache,
|
||||
requests->requestvb->name,
|
||||
requests->requestvb->name_length);
|
||||
if (cnode && cnode->thedata) {
|
||||
cdata = (netsnmp_variable_list*)cnode->thedata;
|
||||
if (cdata->val.string && cdata->name && cdata->name_length) {
|
||||
DEBUGMSGTL(("helper:stash_cache", "Found cached GETNEXT varbind\n"));
|
||||
DEBUGMSGOID(("helper:stash_cache", cdata->name, cdata->name_length));
|
||||
DEBUGMSG(("helper:stash_cache", "\n"));
|
||||
snmp_set_var_typed_value(request->requestvb, cdata->type,
|
||||
cdata->val.string, cdata->val_len);
|
||||
snmp_set_var_objid(request->requestvb, cdata->name,
|
||||
cdata->name_length);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
cinfo->cache_valid = 0;
|
||||
return netsnmp_call_next_handler(handler, reginfo, reqinfo,
|
||||
requests);
|
||||
}
|
||||
|
||||
return SNMP_ERR_NOERROR;
|
||||
}
|
||||
|
||||
/** updates a given cache depending on whether it needs to or not.
|
||||
*/
|
||||
int
|
||||
_netsnmp_stash_cache_load( netsnmp_cache *cache, void *magic )
|
||||
{
|
||||
netsnmp_mib_handler *handler = cache->cache_hint->handler;
|
||||
netsnmp_handler_registration *reginfo = cache->cache_hint->reginfo;
|
||||
netsnmp_agent_request_info *reqinfo = cache->cache_hint->reqinfo;
|
||||
netsnmp_request_info *requests = cache->cache_hint->requests;
|
||||
netsnmp_stash_cache_info *cinfo = (netsnmp_stash_cache_info*) magic;
|
||||
int old_mode;
|
||||
int ret;
|
||||
|
||||
if (!cinfo) {
|
||||
cinfo = netsnmp_get_new_stash_cache();
|
||||
cache->magic = cinfo;
|
||||
}
|
||||
|
||||
/* change modes to the GET_STASH mode */
|
||||
old_mode = reqinfo->mode;
|
||||
reqinfo->mode = MODE_GET_STASH;
|
||||
netsnmp_agent_add_list_data(reqinfo,
|
||||
netsnmp_create_data_list(STASH_CACHE_NAME,
|
||||
&cinfo->cache, NULL));
|
||||
|
||||
/* have the next handler fill stuff in and switch modes back */
|
||||
ret = netsnmp_call_next_handler(handler->next, reginfo, reqinfo, requests);
|
||||
reqinfo->mode = old_mode;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
_netsnmp_stash_cache_free( netsnmp_cache *cache, void *magic )
|
||||
{
|
||||
netsnmp_stash_cache_info *cinfo = (netsnmp_stash_cache_info*) magic;
|
||||
netsnmp_oid_stash_free(&cinfo->cache,
|
||||
(NetSNMPStashFreeNode *) snmp_free_var);
|
||||
return;
|
||||
}
|
||||
|
||||
/** initializes the stash_cache helper which then registers a stash_cache
|
||||
* handler as a run-time injectable handler for configuration file
|
||||
* use.
|
||||
*/
|
||||
void
|
||||
netsnmp_init_stash_cache_helper(void)
|
||||
{
|
||||
netsnmp_register_handler_by_name("stash_cache",
|
||||
netsnmp_get_stash_cache_handler());
|
||||
}
|
||||
/** @} */
|
||||
|
||||
#else /* NETSNMP_FEATURE_REMOVE_STASH_CACHE */
|
||||
netsnmp_feature_unused(stash_cache);
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_STASH_CACHE */
|
||||
@@ -1,129 +0,0 @@
|
||||
#include <net-snmp/net-snmp-config.h>
|
||||
|
||||
#include <net-snmp/net-snmp-features.h>
|
||||
#include <net-snmp/net-snmp-includes.h>
|
||||
#include <net-snmp/agent/net-snmp-agent-includes.h>
|
||||
|
||||
netsnmp_feature_provide(stash_to_next)
|
||||
netsnmp_feature_child_of(stash_to_next, mib_helpers)
|
||||
|
||||
#ifdef NETSNMP_FEATURE_REQUIRE_STASH_TO_NEXT
|
||||
netsnmp_feature_require(oid_stash)
|
||||
netsnmp_feature_require(oid_stash_add_data)
|
||||
#endif
|
||||
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_STASH_TO_NEXT
|
||||
#include <net-snmp/agent/stash_to_next.h>
|
||||
|
||||
#include <net-snmp/agent/stash_cache.h>
|
||||
|
||||
/** @defgroup stash_to_next stash_to_next
|
||||
* Convert GET_STASH requests into GETNEXT requests for the handler.
|
||||
* The purpose of this handler is to convert a GET_STASH auto-cache request
|
||||
* to a series of GETNEXT requests. It can be inserted into a handler chain
|
||||
* where the lower-level handlers don't process such requests themselves.
|
||||
* @ingroup utilities
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** returns a stash_to_next handler that can be injected into a given
|
||||
* handler chain.
|
||||
*/
|
||||
netsnmp_mib_handler *
|
||||
netsnmp_get_stash_to_next_handler(void)
|
||||
{
|
||||
netsnmp_mib_handler *handler =
|
||||
netsnmp_create_handler("stash_to_next",
|
||||
netsnmp_stash_to_next_helper);
|
||||
|
||||
if (NULL != handler)
|
||||
handler->flags |= MIB_HANDLER_AUTO_NEXT;
|
||||
|
||||
return handler;
|
||||
}
|
||||
|
||||
/** @internal Implements the stash_to_next handler */
|
||||
int
|
||||
netsnmp_stash_to_next_helper(netsnmp_mib_handler *handler,
|
||||
netsnmp_handler_registration *reginfo,
|
||||
netsnmp_agent_request_info *reqinfo,
|
||||
netsnmp_request_info *requests)
|
||||
{
|
||||
|
||||
int ret = SNMP_ERR_NOERROR;
|
||||
int namelen;
|
||||
int finished = 0;
|
||||
netsnmp_oid_stash_node **cinfo;
|
||||
netsnmp_variable_list *vb;
|
||||
netsnmp_request_info *reqtmp;
|
||||
|
||||
/*
|
||||
* this code depends on AUTO_NEXT being set
|
||||
*/
|
||||
netsnmp_assert(handler->flags & MIB_HANDLER_AUTO_NEXT);
|
||||
|
||||
/*
|
||||
* Don't do anything for any modes except GET_STASH. Just return,
|
||||
* and the agent will call the next handler (AUTO_NEXT).
|
||||
*
|
||||
* If the handler chain already supports GET_STASH, we don't
|
||||
* need to do anything here either. Once again, we just return
|
||||
* and the agent will call the next handler (AUTO_NEXT).
|
||||
*
|
||||
* Otherwise, we munge the mode to GET_NEXT, and call the
|
||||
* next handler ourselves, repeatedly until we've retrieved the
|
||||
* full contents of the table or subtree.
|
||||
* Then restore the mode and return to the calling handler
|
||||
* (setting AUTO_NEXT_OVERRRIDE so the agent knows what we did).
|
||||
*/
|
||||
if (MODE_GET_STASH == reqinfo->mode) {
|
||||
if ( reginfo->modes & HANDLER_CAN_STASH ) {
|
||||
return ret;
|
||||
}
|
||||
cinfo = netsnmp_extract_stash_cache( reqinfo );
|
||||
reqtmp = SNMP_MALLOC_TYPEDEF(netsnmp_request_info);
|
||||
vb = reqtmp->requestvb = SNMP_MALLOC_TYPEDEF( netsnmp_variable_list );
|
||||
vb->type = ASN_NULL;
|
||||
snmp_set_var_objid( vb, reginfo->rootoid, reginfo->rootoid_len );
|
||||
|
||||
reqinfo->mode = MODE_GETNEXT;
|
||||
while (!finished) {
|
||||
ret = netsnmp_call_next_handler(handler, reginfo, reqinfo, reqtmp);
|
||||
namelen = SNMP_MIN(vb->name_length, reginfo->rootoid_len);
|
||||
if ( !snmp_oid_compare( reginfo->rootoid, reginfo->rootoid_len,
|
||||
vb->name, namelen) &&
|
||||
vb->type != ASN_NULL && vb->type != SNMP_ENDOFMIBVIEW ) {
|
||||
/*
|
||||
* This result is relevant so save it, and prepare
|
||||
* the request varbind for the next query.
|
||||
*/
|
||||
netsnmp_oid_stash_add_data( cinfo, vb->name, vb->name_length,
|
||||
snmp_clone_varbind( vb ));
|
||||
/*
|
||||
* Tidy up the response structure,
|
||||
* ready for retrieving the next entry
|
||||
*/
|
||||
netsnmp_free_all_list_data(reqtmp->parent_data);
|
||||
reqtmp->parent_data = NULL;
|
||||
reqtmp->processed = 0;
|
||||
vb->type = ASN_NULL;
|
||||
} else {
|
||||
finished = 1;
|
||||
}
|
||||
}
|
||||
reqinfo->mode = MODE_GET_STASH;
|
||||
|
||||
/*
|
||||
* let the handler chain processing know that we've already
|
||||
* called the next handler
|
||||
*/
|
||||
handler->flags |= MIB_HANDLER_AUTO_NEXT_OVERRIDE_ONCE;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
/** @} */
|
||||
|
||||
#else /* ! NETSNMP_FEATURE_REMOVE_STASH_TO_NEXT */
|
||||
netsnmp_feature_unused(stash_to_next);
|
||||
#endif /* ! NETSNMP_FEATURE_REMOVE_STASH_TO_NEXT */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,919 +0,0 @@
|
||||
/*
|
||||
* table_array.c
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include <net-snmp/net-snmp-config.h>
|
||||
#include <net-snmp/net-snmp-features.h>
|
||||
|
||||
#include <net-snmp/net-snmp-includes.h>
|
||||
#include <net-snmp/agent/net-snmp-agent-includes.h>
|
||||
|
||||
#include <net-snmp/agent/table_array.h>
|
||||
|
||||
#if HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#else
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#include <net-snmp/agent/table.h>
|
||||
#include <net-snmp/library/container.h>
|
||||
#include <net-snmp/library/snmp_assert.h>
|
||||
|
||||
netsnmp_feature_child_of(table_array_all, mib_helpers)
|
||||
|
||||
netsnmp_feature_child_of(table_array_register,table_array_all)
|
||||
netsnmp_feature_child_of(table_array_find_table_array_handler,table_array_all)
|
||||
netsnmp_feature_child_of(table_array_extract_array_context,table_array_all)
|
||||
netsnmp_feature_child_of(table_array_check_row_status,table_array_all)
|
||||
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_TABLE_CONTAINER
|
||||
|
||||
/*
|
||||
* snmp.h:#define SNMP_MSG_INTERNAL_SET_BEGIN -1
|
||||
* snmp.h:#define SNMP_MSG_INTERNAL_SET_RESERVE1 0
|
||||
* snmp.h:#define SNMP_MSG_INTERNAL_SET_RESERVE2 1
|
||||
* snmp.h:#define SNMP_MSG_INTERNAL_SET_ACTION 2
|
||||
* snmp.h:#define SNMP_MSG_INTERNAL_SET_COMMIT 3
|
||||
* snmp.h:#define SNMP_MSG_INTERNAL_SET_FREE 4
|
||||
* snmp.h:#define SNMP_MSG_INTERNAL_SET_UNDO 5
|
||||
*/
|
||||
|
||||
static const char *mode_name[] = {
|
||||
"Reserve 1",
|
||||
"Reserve 2",
|
||||
"Action",
|
||||
"Commit",
|
||||
"Free",
|
||||
"Undo"
|
||||
};
|
||||
|
||||
/*
|
||||
* PRIVATE structure for holding important info for each table.
|
||||
*/
|
||||
typedef struct table_container_data_s {
|
||||
|
||||
/** registration info for the table */
|
||||
netsnmp_table_registration_info *tblreg_info;
|
||||
|
||||
/** container for the table rows */
|
||||
netsnmp_container *table;
|
||||
|
||||
/*
|
||||
* mutex_type lock;
|
||||
*/
|
||||
|
||||
/** do we want to group rows with the same index
|
||||
* together when calling callbacks? */
|
||||
int group_rows;
|
||||
|
||||
/** callbacks for this table */
|
||||
netsnmp_table_array_callbacks *cb;
|
||||
|
||||
} table_container_data;
|
||||
|
||||
/** @defgroup table_array table_array
|
||||
* Helps you implement a table when data can be stored locally. The data is stored in a sorted array, using a binary search for lookups.
|
||||
* @ingroup table
|
||||
*
|
||||
* The table_array handler is used (automatically) in conjuntion
|
||||
* with the @link table table@endlink handler. It is primarily
|
||||
* intended to be used with the mib2c configuration file
|
||||
* mib2c.array-user.conf.
|
||||
*
|
||||
* The code generated by mib2c is useful when you have control of
|
||||
* the data for each row. If you cannot control when rows are added
|
||||
* and deleted (or at least be notified of changes to row data),
|
||||
* then this handler is probably not for you.
|
||||
*
|
||||
* This handler makes use of callbacks (function pointers) to
|
||||
* handle various tasks. Code is generated for each callback,
|
||||
* but will need to be reviewed and flushed out by the user.
|
||||
*
|
||||
* NOTE NOTE NOTE: Once place where mib2c is somewhat lacking
|
||||
* is with regards to tables with external indices. If your
|
||||
* table makes use of one or more external indices, please
|
||||
* review the generated code very carefully for comments
|
||||
* regarding external indices.
|
||||
*
|
||||
* NOTE NOTE NOTE: This helper, the API and callbacks are still
|
||||
* being tested and may change.
|
||||
*
|
||||
* The generated code will define a structure for storage of table
|
||||
* related data. This structure must be used, as it contains the index
|
||||
* OID for the row, which is used for keeping the array sorted. You can
|
||||
* add addition fields or data to the structure for your own use.
|
||||
*
|
||||
* The generated code will also have code to handle SNMP-SET processing.
|
||||
* If your table does not support any SET operations, simply comment
|
||||
* out the \#define \<PREFIX\>_SET_HANDLING (where \<PREFIX\> is your
|
||||
* table name) in the header file.
|
||||
*
|
||||
* SET processing modifies the row in-place. The duplicate_row
|
||||
* callback will be called to save a copy of the original row.
|
||||
* In the event of a failure before the commite phase, the
|
||||
* row_copy callback will be called to restore the original row
|
||||
* from the copy.
|
||||
*
|
||||
* Code will be generated to handle row creation. This code may be
|
||||
* disabled by commenting out the \#define \<PREFIX\>_ROW_CREATION
|
||||
* in the header file.
|
||||
*
|
||||
* If your table contains a RowStatus object, by default the
|
||||
* code will not allow object in an active row to be modified.
|
||||
* To allow active rows to be modified, remove the comment block
|
||||
* around the \#define \<PREFIX\>_CAN_MODIFY_ACTIVE_ROW in the header
|
||||
* file.
|
||||
*
|
||||
* Code will be generated to maintain a secondary index for all
|
||||
* rows, stored in a binary tree. This is very useful for finding
|
||||
* rows by a key other than the OID index. By default, the functions
|
||||
* for maintaining this tree will be based on a character string.
|
||||
* NOTE: this will likely be made into a more generic mechanism,
|
||||
* using new callback methods, in the near future.
|
||||
*
|
||||
* The generated code contains many TODO comments. Make sure you
|
||||
* check each one to see if it applies to your code. Examples include
|
||||
* checking indices for syntax (ranges, etc), initializing default
|
||||
* values in newly created rows, checking for row activation and
|
||||
* deactivation requirements, etc.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**********************************************************************
|
||||
**********************************************************************
|
||||
* *
|
||||
* *
|
||||
* PUBLIC Registration functions *
|
||||
* *
|
||||
* *
|
||||
**********************************************************************
|
||||
**********************************************************************/
|
||||
/** register specified callbacks for the specified table/oid. If the
|
||||
group_rows parameter is set, the row related callbacks will be
|
||||
called once for each unique row index. Otherwise, each callback
|
||||
will be called only once, for all objects.
|
||||
*/
|
||||
int
|
||||
netsnmp_table_container_register(netsnmp_handler_registration *reginfo,
|
||||
netsnmp_table_registration_info *tabreg,
|
||||
netsnmp_table_array_callbacks *cb,
|
||||
netsnmp_container *container,
|
||||
int group_rows)
|
||||
{
|
||||
table_container_data *tad = SNMP_MALLOC_TYPEDEF(table_container_data);
|
||||
if (!tad)
|
||||
return SNMPERR_GENERR;
|
||||
tad->tblreg_info = tabreg; /* we need it too, but it really is not ours */
|
||||
|
||||
if (!cb) {
|
||||
snmp_log(LOG_ERR, "table_array registration with no callbacks\n" );
|
||||
free(tad); /* SNMP_FREE is overkill for local var */
|
||||
return SNMPERR_GENERR;
|
||||
}
|
||||
/*
|
||||
* check for required callbacks
|
||||
*/
|
||||
if ((cb->can_set &&
|
||||
((NULL==cb->duplicate_row) || (NULL==cb->delete_row) ||
|
||||
(NULL==cb->row_copy)) )) {
|
||||
snmp_log(LOG_ERR, "table_array registration with incomplete "
|
||||
"callback structure.\n");
|
||||
free(tad); /* SNMP_FREE is overkill for local var */
|
||||
return SNMPERR_GENERR;
|
||||
}
|
||||
|
||||
if (NULL==container) {
|
||||
tad->table = netsnmp_container_find("table_array");
|
||||
snmp_log(LOG_ERR, "table_array couldn't allocate container\n" );
|
||||
free(tad); /* SNMP_FREE is overkill for local var */
|
||||
return SNMPERR_GENERR;
|
||||
} else
|
||||
tad->table = container;
|
||||
if (NULL==tad->table->compare)
|
||||
tad->table->compare = netsnmp_compare_netsnmp_index;
|
||||
if (NULL==tad->table->ncompare)
|
||||
tad->table->ncompare = netsnmp_ncompare_netsnmp_index;
|
||||
|
||||
tad->cb = cb;
|
||||
|
||||
reginfo->handler->myvoid = tad;
|
||||
|
||||
return netsnmp_register_table(reginfo, tabreg);
|
||||
}
|
||||
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_TABLE_ARRAY_REGISTER
|
||||
int
|
||||
netsnmp_table_array_register(netsnmp_handler_registration *reginfo,
|
||||
netsnmp_table_registration_info *tabreg,
|
||||
netsnmp_table_array_callbacks *cb,
|
||||
netsnmp_container *container,
|
||||
int group_rows)
|
||||
{
|
||||
netsnmp_inject_handler(reginfo,
|
||||
netsnmp_create_handler(reginfo->handlerName,
|
||||
netsnmp_table_array_helper_handler));
|
||||
return netsnmp_table_container_register(reginfo, tabreg, cb,
|
||||
container, group_rows);
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_TABLE_ARRAY_REGISTER */
|
||||
|
||||
/** find the handler for the table_array helper. */
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_TABLE_ARRAY_FIND_TABLE_ARRAY_HANDLER
|
||||
netsnmp_mib_handler *
|
||||
netsnmp_find_table_array_handler(netsnmp_handler_registration *reginfo)
|
||||
{
|
||||
netsnmp_mib_handler *mh;
|
||||
if (!reginfo)
|
||||
return NULL;
|
||||
mh = reginfo->handler;
|
||||
while (mh) {
|
||||
if (mh->access_method == netsnmp_table_array_helper_handler)
|
||||
break;
|
||||
mh = mh->next;
|
||||
}
|
||||
|
||||
return mh;
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_TABLE_ARRAY_FIND_TABLE_ARRAY_HANDLER */
|
||||
|
||||
/** find the context data used by the table_array helper */
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_TABLE_ARRAY_EXTRACT_ARRAY_CONTEXT
|
||||
netsnmp_container *
|
||||
netsnmp_extract_array_context(netsnmp_request_info *request)
|
||||
{
|
||||
return (netsnmp_container*)netsnmp_request_get_list_data(request, TABLE_ARRAY_NAME);
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_TABLE_ARRAY_EXTRACT_ARRAY_CONTEXT */
|
||||
|
||||
/** this function is called to validate RowStatus transitions. */
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_TABLE_ARRAY_CHECK_ROW_STATUS
|
||||
int
|
||||
netsnmp_table_array_check_row_status(netsnmp_table_array_callbacks *cb,
|
||||
netsnmp_request_group *ag,
|
||||
long *rs_new, long *rs_old)
|
||||
{
|
||||
netsnmp_index *row_ctx;
|
||||
netsnmp_index *undo_ctx;
|
||||
if (!ag || !cb)
|
||||
return SNMPERR_GENERR;
|
||||
row_ctx = ag->existing_row;
|
||||
undo_ctx = ag->undo_info;
|
||||
|
||||
/*
|
||||
* xxx-rks: revisit row delete scenario
|
||||
*/
|
||||
if (row_ctx) {
|
||||
/*
|
||||
* either a new row, or change to old row
|
||||
*/
|
||||
/*
|
||||
* is it set to active?
|
||||
*/
|
||||
if (RS_IS_GOING_ACTIVE(*rs_new)) {
|
||||
/*
|
||||
* is it ready to be active?
|
||||
*/
|
||||
if ((NULL==cb->can_activate) ||
|
||||
cb->can_activate(undo_ctx, row_ctx, ag))
|
||||
*rs_new = RS_ACTIVE;
|
||||
else
|
||||
return SNMP_ERR_INCONSISTENTVALUE;
|
||||
} else {
|
||||
/*
|
||||
* not going active
|
||||
*/
|
||||
if (undo_ctx) {
|
||||
/*
|
||||
* change
|
||||
*/
|
||||
if (RS_IS_ACTIVE(*rs_old)) {
|
||||
/*
|
||||
* check pre-reqs for deactivation
|
||||
*/
|
||||
if (cb->can_deactivate &&
|
||||
!cb->can_deactivate(undo_ctx, row_ctx, ag)) {
|
||||
return SNMP_ERR_INCONSISTENTVALUE;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* new row
|
||||
*/
|
||||
}
|
||||
|
||||
if (*rs_new != RS_DESTROY) {
|
||||
if ((NULL==cb->can_activate) ||
|
||||
cb->can_activate(undo_ctx, row_ctx, ag))
|
||||
*rs_new = RS_NOTINSERVICE;
|
||||
else
|
||||
*rs_new = RS_NOTREADY;
|
||||
} else {
|
||||
if (cb->can_delete && !cb->can_delete(undo_ctx, row_ctx, ag)) {
|
||||
return SNMP_ERR_INCONSISTENTVALUE;
|
||||
}
|
||||
ag->row_deleted = 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* check pre-reqs for delete row
|
||||
*/
|
||||
if (cb->can_delete && !cb->can_delete(undo_ctx, row_ctx, ag)) {
|
||||
return SNMP_ERR_INCONSISTENTVALUE;
|
||||
}
|
||||
}
|
||||
|
||||
return SNMP_ERR_NOERROR;
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_TABLE_ARRAY_CHECK_ROW_STATUS */
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @cond */
|
||||
/**********************************************************************
|
||||
**********************************************************************
|
||||
**********************************************************************
|
||||
**********************************************************************
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
* EVERYTHING BELOW THIS IS PRIVATE IMPLEMENTATION DETAILS. *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
**********************************************************************
|
||||
**********************************************************************
|
||||
**********************************************************************
|
||||
**********************************************************************/
|
||||
|
||||
/**********************************************************************
|
||||
**********************************************************************
|
||||
* *
|
||||
* *
|
||||
* Structures, Utility/convenience functions *
|
||||
* *
|
||||
* *
|
||||
**********************************************************************
|
||||
**********************************************************************/
|
||||
/*
|
||||
* context info for SET requests
|
||||
*/
|
||||
#ifndef NETSNMP_NO_WRITE_SUPPORT
|
||||
typedef struct set_context_s {
|
||||
netsnmp_agent_request_info *agtreq_info;
|
||||
table_container_data *tad;
|
||||
int status;
|
||||
} set_context;
|
||||
#endif /* NETSNMP_NO_WRITE_SUPPORT */
|
||||
|
||||
void
|
||||
build_new_oid(netsnmp_handler_registration *reginfo,
|
||||
netsnmp_table_request_info *tblreq_info,
|
||||
netsnmp_index *row, netsnmp_request_info *current)
|
||||
{
|
||||
oid coloid[MAX_OID_LEN];
|
||||
|
||||
if (!tblreq_info || !reginfo || !row || !current)
|
||||
return;
|
||||
|
||||
memcpy(coloid, reginfo->rootoid, reginfo->rootoid_len * sizeof(oid));
|
||||
|
||||
/** table.entry */
|
||||
coloid[reginfo->rootoid_len] = 1;
|
||||
|
||||
/** table.entry.column */
|
||||
coloid[reginfo->rootoid_len + 1] = tblreq_info->colnum;
|
||||
|
||||
/** table.entry.column.index */
|
||||
memcpy(&coloid[reginfo->rootoid_len + 2], row->oids,
|
||||
row->len * sizeof(oid));
|
||||
|
||||
snmp_set_var_objid(current->requestvb, coloid,
|
||||
reginfo->rootoid_len + 2 + row->len);
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
**********************************************************************
|
||||
* *
|
||||
* *
|
||||
* GET procession functions *
|
||||
* *
|
||||
* *
|
||||
**********************************************************************
|
||||
**********************************************************************/
|
||||
int
|
||||
process_get_requests(netsnmp_handler_registration *reginfo,
|
||||
netsnmp_agent_request_info *agtreq_info,
|
||||
netsnmp_request_info *requests,
|
||||
table_container_data * tad)
|
||||
{
|
||||
int rc = SNMP_ERR_NOERROR;
|
||||
netsnmp_request_info *current;
|
||||
netsnmp_index *row = NULL;
|
||||
netsnmp_table_request_info *tblreq_info;
|
||||
netsnmp_variable_list *var;
|
||||
|
||||
/*
|
||||
* Loop through each of the requests, and
|
||||
* try to find the appropriate row from the container.
|
||||
*/
|
||||
for (current = requests; current; current = current->next) {
|
||||
|
||||
var = current->requestvb;
|
||||
DEBUGMSGTL(("table_array:get",
|
||||
" process_get_request oid:"));
|
||||
DEBUGMSGOID(("table_array:get", var->name,
|
||||
var->name_length));
|
||||
DEBUGMSG(("table_array:get", "\n"));
|
||||
|
||||
/*
|
||||
* skip anything that doesn't need processing.
|
||||
*/
|
||||
if (current->processed != 0) {
|
||||
DEBUGMSGTL(("table_array:get", "already processed\n"));
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get pointer to the table information for this request. This
|
||||
* information was saved by table_helper_handler. When
|
||||
* debugging, we double check a few assumptions. For example,
|
||||
* the table_helper_handler should enforce column boundaries.
|
||||
*/
|
||||
tblreq_info = netsnmp_extract_table_info(current);
|
||||
netsnmp_assert(tblreq_info->colnum <= tad->tblreg_info->max_column);
|
||||
|
||||
if ((agtreq_info->mode == MODE_GETNEXT) ||
|
||||
(agtreq_info->mode == MODE_GETBULK)) {
|
||||
/*
|
||||
* find the row
|
||||
*/
|
||||
row = netsnmp_table_index_find_next_row(tad->table, tblreq_info);
|
||||
if (!row) {
|
||||
/*
|
||||
* no results found.
|
||||
*
|
||||
* xxx-rks: how do we skip this entry for the next handler,
|
||||
* but still allow it a chance to hit another handler?
|
||||
*/
|
||||
DEBUGMSGTL(("table_array:get", "no row found\n"));
|
||||
netsnmp_set_request_error(agtreq_info, current,
|
||||
SNMP_ENDOFMIBVIEW);
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* * if data was found, make sure it has the column we want
|
||||
*/
|
||||
/* xxx-rks: add suport for sparse tables */
|
||||
|
||||
/*
|
||||
* build new oid
|
||||
*/
|
||||
build_new_oid(reginfo, tblreq_info, row, current);
|
||||
|
||||
} /** GETNEXT/GETBULK */
|
||||
else {
|
||||
netsnmp_index index;
|
||||
index.oids = tblreq_info->index_oid;
|
||||
index.len = tblreq_info->index_oid_len;
|
||||
|
||||
row = (netsnmp_index*)CONTAINER_FIND(tad->table, &index);
|
||||
if (!row) {
|
||||
DEBUGMSGTL(("table_array:get", "no row found\n"));
|
||||
netsnmp_set_request_error(agtreq_info, current,
|
||||
SNMP_NOSUCHINSTANCE);
|
||||
continue;
|
||||
}
|
||||
} /** GET */
|
||||
|
||||
/*
|
||||
* get the data
|
||||
*/
|
||||
rc = tad->cb->get_value(current, row, tblreq_info);
|
||||
|
||||
} /** for ( ... requests ... ) */
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
**********************************************************************
|
||||
* *
|
||||
* *
|
||||
* SET procession functions *
|
||||
* *
|
||||
* *
|
||||
**********************************************************************
|
||||
**********************************************************************/
|
||||
|
||||
void
|
||||
group_requests(netsnmp_agent_request_info *agtreq_info,
|
||||
netsnmp_request_info *requests,
|
||||
netsnmp_container *request_group, table_container_data * tad)
|
||||
{
|
||||
netsnmp_table_request_info *tblreq_info;
|
||||
netsnmp_index *row, *tmp, index;
|
||||
netsnmp_request_info *current;
|
||||
netsnmp_request_group *g;
|
||||
netsnmp_request_group_item *i;
|
||||
|
||||
for (current = requests; current; current = current->next) {
|
||||
/*
|
||||
* skip anything that doesn't need processing.
|
||||
*/
|
||||
if (current->processed != 0) {
|
||||
DEBUGMSGTL(("table_array:group",
|
||||
"already processed\n"));
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* 3.2.1 Setup and paranoia
|
||||
* *
|
||||
* * Get pointer to the table information for this request. This
|
||||
* * information was saved by table_helper_handler. When
|
||||
* * debugging, we double check a few assumptions. For example,
|
||||
* * the table_helper_handler should enforce column boundaries.
|
||||
*/
|
||||
row = NULL;
|
||||
tblreq_info = netsnmp_extract_table_info(current);
|
||||
netsnmp_assert(tblreq_info->colnum <= tad->tblreg_info->max_column);
|
||||
|
||||
/*
|
||||
* search for index
|
||||
*/
|
||||
index.oids = tblreq_info->index_oid;
|
||||
index.len = tblreq_info->index_oid_len;
|
||||
tmp = (netsnmp_index*)CONTAINER_FIND(request_group, &index);
|
||||
if (tmp) {
|
||||
DEBUGMSGTL(("table_array:group",
|
||||
" existing group:"));
|
||||
DEBUGMSGOID(("table_array:group", index.oids,
|
||||
index.len));
|
||||
DEBUGMSG(("table_array:group", "\n"));
|
||||
g = (netsnmp_request_group *) tmp;
|
||||
i = SNMP_MALLOC_TYPEDEF(netsnmp_request_group_item);
|
||||
if (i == NULL)
|
||||
return;
|
||||
i->ri = current;
|
||||
i->tri = tblreq_info;
|
||||
i->next = g->list;
|
||||
g->list = i;
|
||||
|
||||
/** xxx-rks: store map of colnum to request */
|
||||
continue;
|
||||
}
|
||||
|
||||
DEBUGMSGTL(("table_array:group", " new group"));
|
||||
DEBUGMSGOID(("table_array:group", index.oids,
|
||||
index.len));
|
||||
DEBUGMSG(("table_array:group", "\n"));
|
||||
g = SNMP_MALLOC_TYPEDEF(netsnmp_request_group);
|
||||
i = SNMP_MALLOC_TYPEDEF(netsnmp_request_group_item);
|
||||
if (i == NULL || g == NULL) {
|
||||
SNMP_FREE(i);
|
||||
SNMP_FREE(g);
|
||||
return;
|
||||
}
|
||||
g->list = i;
|
||||
g->table = tad->table;
|
||||
i->ri = current;
|
||||
i->tri = tblreq_info;
|
||||
/** xxx-rks: store map of colnum to request */
|
||||
|
||||
/*
|
||||
* search for row. all changes are made to the original row,
|
||||
* later, we'll make a copy in undo_info before we start processing.
|
||||
*/
|
||||
row = g->existing_row = (netsnmp_index*)CONTAINER_FIND(tad->table, &index);
|
||||
if (!g->existing_row) {
|
||||
if (!tad->cb->create_row) {
|
||||
#ifndef NETSNMP_NO_WRITE_SUPPORT
|
||||
if(MODE_IS_SET(agtreq_info->mode))
|
||||
netsnmp_set_request_error(agtreq_info, current,
|
||||
SNMP_ERR_NOTWRITABLE);
|
||||
else
|
||||
#endif /* NETSNMP_NO_WRITE_SUPPORT */
|
||||
netsnmp_set_request_error(agtreq_info, current,
|
||||
SNMP_NOSUCHINSTANCE);
|
||||
free(g);
|
||||
free(i);
|
||||
continue;
|
||||
}
|
||||
/** use undo_info temporarily */
|
||||
row = g->existing_row = tad->cb->create_row(&index);
|
||||
if (!row) {
|
||||
/* xxx-rks : parameter to create_row to allow
|
||||
* for better error reporting. */
|
||||
netsnmp_set_request_error(agtreq_info, current,
|
||||
SNMP_ERR_GENERR);
|
||||
free(g);
|
||||
free(i);
|
||||
continue;
|
||||
}
|
||||
g->row_created = 1;
|
||||
}
|
||||
|
||||
g->index.oids = row->oids;
|
||||
g->index.len = row->len;
|
||||
|
||||
CONTAINER_INSERT(request_group, g);
|
||||
|
||||
} /** for( current ... ) */
|
||||
}
|
||||
|
||||
#ifndef NETSNMP_NO_WRITE_SUPPORT
|
||||
static void
|
||||
release_netsnmp_request_group(netsnmp_index *g, void *v)
|
||||
{
|
||||
netsnmp_request_group_item *tmp;
|
||||
netsnmp_request_group *group = (netsnmp_request_group *) g;
|
||||
|
||||
if (!g)
|
||||
return;
|
||||
while (group->list) {
|
||||
tmp = group->list;
|
||||
group->list = tmp->next;
|
||||
free(tmp);
|
||||
}
|
||||
|
||||
free(group);
|
||||
}
|
||||
|
||||
static void
|
||||
release_netsnmp_request_groups(void *vp)
|
||||
{
|
||||
netsnmp_container *c = (netsnmp_container*)vp;
|
||||
CONTAINER_FOR_EACH(c, (netsnmp_container_obj_func*)
|
||||
release_netsnmp_request_group, NULL);
|
||||
CONTAINER_FREE(c);
|
||||
}
|
||||
|
||||
static void
|
||||
process_set_group(netsnmp_index *o, void *c)
|
||||
{
|
||||
/* xxx-rks: should we continue processing after an error?? */
|
||||
set_context *context = (set_context *) c;
|
||||
netsnmp_request_group *ag = (netsnmp_request_group *) o;
|
||||
int rc = SNMP_ERR_NOERROR;
|
||||
|
||||
switch (context->agtreq_info->mode) {
|
||||
|
||||
case MODE_SET_RESERVE1:/** -> SET_RESERVE2 || SET_FREE */
|
||||
|
||||
/*
|
||||
* if not a new row, save undo info
|
||||
*/
|
||||
if (ag->row_created == 0) {
|
||||
if (context->tad->cb->duplicate_row)
|
||||
ag->undo_info = context->tad->cb->duplicate_row(ag->existing_row);
|
||||
else
|
||||
ag->undo_info = NULL;
|
||||
if (NULL == ag->undo_info) {
|
||||
rc = SNMP_ERR_RESOURCEUNAVAILABLE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (context->tad->cb->set_reserve1)
|
||||
context->tad->cb->set_reserve1(ag);
|
||||
break;
|
||||
|
||||
case MODE_SET_RESERVE2:/** -> SET_ACTION || SET_FREE */
|
||||
if (context->tad->cb->set_reserve2)
|
||||
context->tad->cb->set_reserve2(ag);
|
||||
break;
|
||||
|
||||
case MODE_SET_ACTION:/** -> SET_COMMIT || SET_UNDO */
|
||||
if (context->tad->cb->set_action)
|
||||
context->tad->cb->set_action(ag);
|
||||
break;
|
||||
|
||||
case MODE_SET_COMMIT:/** FINAL CHANCE ON SUCCESS */
|
||||
if (ag->row_created == 0) {
|
||||
/*
|
||||
* this is an existing row, has it been deleted?
|
||||
*/
|
||||
if (ag->row_deleted == 1) {
|
||||
DEBUGMSGT((TABLE_ARRAY_NAME, "action: deleting row\n"));
|
||||
if (CONTAINER_REMOVE(ag->table, ag->existing_row) != 0) {
|
||||
rc = SNMP_ERR_COMMITFAILED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (ag->row_deleted == 0) {
|
||||
/*
|
||||
* new row (that hasn't been deleted) should be inserted
|
||||
*/
|
||||
DEBUGMSGT((TABLE_ARRAY_NAME, "action: inserting row\n"));
|
||||
if (CONTAINER_INSERT(ag->table, ag->existing_row) != 0) {
|
||||
rc = SNMP_ERR_COMMITFAILED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (context->tad->cb->set_commit)
|
||||
context->tad->cb->set_commit(ag);
|
||||
|
||||
/** no more use for undo_info, so free it */
|
||||
if (ag->undo_info) {
|
||||
context->tad->cb->delete_row(ag->undo_info);
|
||||
ag->undo_info = NULL;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* XXX-rks: finish row cooperative notifications
|
||||
* if the table has requested it, send cooperative notifications
|
||||
* for row operations.
|
||||
*/
|
||||
if (context->tad->notifications) {
|
||||
if (ag->undo_info) {
|
||||
if (!ag->existing_row)
|
||||
netsnmp_monitor_notify(EVENT_ROW_DEL);
|
||||
else
|
||||
netsnmp_monitor_notify(EVENT_ROW_MOD);
|
||||
}
|
||||
else
|
||||
netsnmp_monitor_notify(EVENT_ROW_ADD);
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((ag->row_created == 0) && (ag->row_deleted == 1)) {
|
||||
context->tad->cb->delete_row(ag->existing_row);
|
||||
ag->existing_row = NULL;
|
||||
}
|
||||
break;
|
||||
|
||||
case MODE_SET_FREE:/** FINAL CHANCE ON FAILURE */
|
||||
if (context->tad->cb->set_free)
|
||||
context->tad->cb->set_free(ag);
|
||||
|
||||
/** no more use for undo_info, so free it */
|
||||
if (ag->row_created == 1) {
|
||||
if (context->tad->cb->delete_row)
|
||||
context->tad->cb->delete_row(ag->existing_row);
|
||||
ag->existing_row = NULL;
|
||||
}
|
||||
else {
|
||||
if (context->tad->cb->delete_row)
|
||||
context->tad->cb->delete_row(ag->undo_info);
|
||||
ag->undo_info = NULL;
|
||||
}
|
||||
break;
|
||||
|
||||
case MODE_SET_UNDO:/** FINAL CHANCE ON FAILURE */
|
||||
/*
|
||||
* status already set - don't change it now
|
||||
*/
|
||||
if (context->tad->cb->set_undo)
|
||||
context->tad->cb->set_undo(ag);
|
||||
|
||||
/*
|
||||
* no more use for undo_info, so free it
|
||||
*/
|
||||
if (ag->row_created == 0) {
|
||||
/*
|
||||
* restore old values
|
||||
*/
|
||||
context->tad->cb->row_copy(ag->existing_row, ag->undo_info);
|
||||
context->tad->cb->delete_row(ag->undo_info);
|
||||
ag->undo_info = NULL;
|
||||
}
|
||||
else {
|
||||
context->tad->cb->delete_row(ag->existing_row);
|
||||
ag->existing_row = NULL;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
snmp_log(LOG_ERR, "unknown mode processing SET for "
|
||||
"netsnmp_table_array_helper_handler\n");
|
||||
rc = SNMP_ERR_GENERR;
|
||||
break;
|
||||
}
|
||||
|
||||
if (rc)
|
||||
netsnmp_set_request_error(context->agtreq_info,
|
||||
ag->list->ri, rc);
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
process_set_requests(netsnmp_agent_request_info *agtreq_info,
|
||||
netsnmp_request_info *requests,
|
||||
table_container_data * tad, char *handler_name)
|
||||
{
|
||||
set_context context;
|
||||
netsnmp_container *request_group;
|
||||
|
||||
/*
|
||||
* create and save structure for set info
|
||||
*/
|
||||
request_group = (netsnmp_container*) netsnmp_agent_get_list_data
|
||||
(agtreq_info, handler_name);
|
||||
if (request_group == NULL) {
|
||||
netsnmp_data_list *tmp;
|
||||
request_group = netsnmp_container_find("request_group:"
|
||||
"table_container");
|
||||
request_group->compare = netsnmp_compare_netsnmp_index;
|
||||
request_group->ncompare = netsnmp_ncompare_netsnmp_index;
|
||||
|
||||
DEBUGMSGTL(("table_array", "Grouping requests by oid\n"));
|
||||
|
||||
tmp = netsnmp_create_data_list(handler_name,
|
||||
request_group,
|
||||
release_netsnmp_request_groups);
|
||||
netsnmp_agent_add_list_data(agtreq_info, tmp);
|
||||
/*
|
||||
* group requests.
|
||||
*/
|
||||
group_requests(agtreq_info, requests, request_group, tad);
|
||||
}
|
||||
|
||||
/*
|
||||
* process each group one at a time
|
||||
*/
|
||||
context.agtreq_info = agtreq_info;
|
||||
context.tad = tad;
|
||||
context.status = SNMP_ERR_NOERROR;
|
||||
CONTAINER_FOR_EACH(request_group,
|
||||
(netsnmp_container_obj_func*)process_set_group,
|
||||
&context);
|
||||
|
||||
return context.status;
|
||||
}
|
||||
#endif /* NETSNMP_NO_WRITE_SUPPORT */
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
**********************************************************************
|
||||
* *
|
||||
* *
|
||||
* netsnmp_table_array_helper_handler() *
|
||||
* *
|
||||
* *
|
||||
**********************************************************************
|
||||
**********************************************************************/
|
||||
int
|
||||
netsnmp_table_array_helper_handler(netsnmp_mib_handler *handler,
|
||||
netsnmp_handler_registration *reginfo,
|
||||
netsnmp_agent_request_info *agtreq_info,
|
||||
netsnmp_request_info *requests)
|
||||
{
|
||||
|
||||
/*
|
||||
* First off, get our pointer from the handler. This
|
||||
* lets us get to the table registration information we
|
||||
* saved in get_table_array_handler(), as well as the
|
||||
* container where the actual table data is stored.
|
||||
*/
|
||||
int rc = SNMP_ERR_NOERROR;
|
||||
table_container_data *tad = (table_container_data *)handler->myvoid;
|
||||
|
||||
if (agtreq_info->mode < 0 || agtreq_info->mode > 5) {
|
||||
DEBUGMSGTL(("table_array", "Mode %d, Got request:\n",
|
||||
agtreq_info->mode));
|
||||
} else {
|
||||
DEBUGMSGTL(("table_array", "Mode %s, Got request:\n",
|
||||
mode_name[agtreq_info->mode]));
|
||||
}
|
||||
|
||||
#ifndef NETSNMP_NO_WRITE_SUPPORT
|
||||
if (MODE_IS_SET(agtreq_info->mode)) {
|
||||
/*
|
||||
* netsnmp_mutex_lock(&tad->lock);
|
||||
*/
|
||||
rc = process_set_requests(agtreq_info, requests,
|
||||
tad, handler->handler_name);
|
||||
/*
|
||||
* netsnmp_mutex_unlock(&tad->lock);
|
||||
*/
|
||||
} else
|
||||
#endif /* NETSNMP_NO_WRITE_SUPPORT */
|
||||
rc = process_get_requests(reginfo, agtreq_info, requests, tad);
|
||||
|
||||
if (rc != SNMP_ERR_NOERROR) {
|
||||
DEBUGMSGTL(("table_array", "processing returned rc %d\n", rc));
|
||||
}
|
||||
|
||||
/*
|
||||
* Now we've done our processing. If there is another handler below us,
|
||||
* call them.
|
||||
*/
|
||||
if (handler->next) {
|
||||
rc = netsnmp_call_next_handler(handler, reginfo, agtreq_info, requests);
|
||||
if (rc != SNMP_ERR_NOERROR) {
|
||||
DEBUGMSGTL(("table_array", "next handler returned rc %d\n", rc));
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_TABLE_CONTAINER */
|
||||
/** @endcond */
|
||||
@@ -1,876 +0,0 @@
|
||||
/*
|
||||
* table_container.c
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include <net-snmp/net-snmp-config.h>
|
||||
#include <net-snmp/net-snmp-features.h>
|
||||
|
||||
#include <net-snmp/net-snmp-includes.h>
|
||||
#include <net-snmp/agent/net-snmp-agent-includes.h>
|
||||
|
||||
#include <net-snmp/agent/table_container.h>
|
||||
|
||||
#if HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#else
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#include <net-snmp/agent/table.h>
|
||||
#include <net-snmp/library/container.h>
|
||||
#include <net-snmp/library/snmp_assert.h>
|
||||
|
||||
netsnmp_feature_provide(table_container)
|
||||
netsnmp_feature_child_of(table_container, table_container_all)
|
||||
netsnmp_feature_child_of(table_container_replace_row, table_container_all)
|
||||
netsnmp_feature_child_of(table_container_extract, table_container_all)
|
||||
netsnmp_feature_child_of(table_container_management, table_container_all)
|
||||
netsnmp_feature_child_of(table_container_row_remove, table_container_all)
|
||||
netsnmp_feature_child_of(table_container_row_insert, table_container_all)
|
||||
netsnmp_feature_child_of(table_container_all, mib_helpers)
|
||||
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_TABLE_CONTAINER
|
||||
|
||||
/*
|
||||
* snmp.h:#define SNMP_MSG_INTERNAL_SET_BEGIN -1
|
||||
* snmp.h:#define SNMP_MSG_INTERNAL_SET_RESERVE1 0
|
||||
* snmp.h:#define SNMP_MSG_INTERNAL_SET_RESERVE2 1
|
||||
* snmp.h:#define SNMP_MSG_INTERNAL_SET_ACTION 2
|
||||
* snmp.h:#define SNMP_MSG_INTERNAL_SET_COMMIT 3
|
||||
* snmp.h:#define SNMP_MSG_INTERNAL_SET_FREE 4
|
||||
* snmp.h:#define SNMP_MSG_INTERNAL_SET_UNDO 5
|
||||
*/
|
||||
|
||||
/*
|
||||
* PRIVATE structure for holding important info for each table.
|
||||
*/
|
||||
typedef struct container_table_data_s {
|
||||
|
||||
/** Number of handlers whose myvoid pointer points to this structure. */
|
||||
int refcnt;
|
||||
|
||||
/** registration info for the table */
|
||||
netsnmp_table_registration_info *tblreg_info;
|
||||
|
||||
/** container for the table rows */
|
||||
netsnmp_container *table;
|
||||
|
||||
/*
|
||||
* mutex_type lock;
|
||||
*/
|
||||
|
||||
/* what type of key do we want? */
|
||||
char key_type;
|
||||
|
||||
} container_table_data;
|
||||
|
||||
/** @defgroup table_container table_container
|
||||
* Helps you implement a table when data can be found via a netsnmp_container.
|
||||
* @ingroup table
|
||||
*
|
||||
* The table_container handler is used (automatically) in conjuntion
|
||||
* with the @link table table@endlink handler.
|
||||
*
|
||||
* This handler will use the index information provided by
|
||||
* the @link table @endlink handler to find the row needed to process
|
||||
* the request.
|
||||
*
|
||||
* The container must use one of 3 key types. It is the sub-handler's
|
||||
* responsibility to ensure that the container and key type match (unless
|
||||
* neither is specified, in which case a default will be used.)
|
||||
*
|
||||
* The current key types are:
|
||||
*
|
||||
* TABLE_CONTAINER_KEY_NETSNMP_INDEX
|
||||
* The container should do comparisons based on a key that may be cast
|
||||
* to a netsnmp index (netsnmp_index *). This index contains only the
|
||||
* index portion of the OID, not the entire OID.
|
||||
*
|
||||
* TABLE_CONTAINER_KEY_VARBIND_INDEX
|
||||
* The container should do comparisons based on a key that may be cast
|
||||
* to a netsnmp variable list (netsnmp_variable_list *). This variable
|
||||
* list will contain one varbind for each index component.
|
||||
*
|
||||
* TABLE_CONTAINER_KEY_VARBIND_RAW (NOTE: unimplemented)
|
||||
* While not yet implemented, future plans include passing the request
|
||||
* varbind with the full OID to a container.
|
||||
*
|
||||
* If a key type is not specified at registration time, the default key type
|
||||
* of TABLE_CONTAINER_KEY_NETSNMP_INDEX will be used. If a container is
|
||||
* provided, or the handler name is aliased to a container type, the container
|
||||
* must use a netsnmp index.
|
||||
*
|
||||
* If no container is provided, a lookup will be made based on the
|
||||
* sub-handler's name, or if that isn't found, "table_container". The
|
||||
* table_container key type will be netsnmp_index.
|
||||
*
|
||||
* The container must, at a minimum, implement find and find_next. If a NULL
|
||||
* key is passed to the container, it must return the first item, if any.
|
||||
* All containers provided by net-snmp fulfil this requirement.
|
||||
*
|
||||
* This handler will only register to process 'data lookup' modes. In
|
||||
* traditional net-snmp modes, that is any GET-like mode (GET, GET-NEXT,
|
||||
* GET-BULK) or the first phase of a SET (RESERVE1). In the new baby-steps
|
||||
* mode, DATA_LOOKUP is it's own mode, and is a pre-cursor to other modes.
|
||||
*
|
||||
* When called, the handler will call the appropriate container method
|
||||
* with the appropriate key type. If a row was not found, the result depends
|
||||
* on the mode.
|
||||
*
|
||||
* GET Processing
|
||||
* An exact match must be found. If one is not, the error NOSUCHINSTANCE
|
||||
* is set.
|
||||
*
|
||||
* GET-NEXT / GET-BULK
|
||||
* If no row is found, the column number will be increased (using any
|
||||
* valid_columns structure that may have been provided), and the first row
|
||||
* will be retrieved. If no first row is found, the processed flag will be
|
||||
* set, so that the sub-handler can skip any processing related to the
|
||||
* request. The agent will notice this unsatisfied request, and attempt to
|
||||
* pass it to the next appropriate handler.
|
||||
*
|
||||
* SET
|
||||
* If the hander did not register with the HANDLER_CAN_NOT_CREATE flag
|
||||
* set in the registration modes, it is assumed that this is a row
|
||||
* creation request and a NULL row is added to the request's data list.
|
||||
* The sub-handler is responsbile for dealing with any row creation
|
||||
* contraints and inserting any newly created rows into the container
|
||||
* and the request's data list.
|
||||
*
|
||||
* If a row is found, it will be inserted into
|
||||
* the request's data list. The sub-handler may retrieve it by calling
|
||||
* netsnmp_container_table_extract_context(request); *
|
||||
* NOTE NOTE NOTE:
|
||||
*
|
||||
* This helper and it's API are still being tested and are subject to change.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
static int
|
||||
_container_table_handler(netsnmp_mib_handler *handler,
|
||||
netsnmp_handler_registration *reginfo,
|
||||
netsnmp_agent_request_info *agtreq_info,
|
||||
netsnmp_request_info *requests);
|
||||
|
||||
static void *
|
||||
_find_next_row(netsnmp_container *c,
|
||||
netsnmp_table_request_info *tblreq,
|
||||
void * key);
|
||||
|
||||
/**********************************************************************
|
||||
**********************************************************************
|
||||
* *
|
||||
* *
|
||||
* PUBLIC Registration functions *
|
||||
* *
|
||||
* *
|
||||
**********************************************************************
|
||||
**********************************************************************/
|
||||
|
||||
/* ==================================
|
||||
*
|
||||
* Container Table API: Table maintenance
|
||||
*
|
||||
* ================================== */
|
||||
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_TABLE_CONTAINER_MANAGEMENT
|
||||
container_table_data *
|
||||
netsnmp_tcontainer_create_table( const char *name,
|
||||
netsnmp_container *container, long flags )
|
||||
{
|
||||
container_table_data *table;
|
||||
|
||||
table = SNMP_MALLOC_TYPEDEF(container_table_data);
|
||||
if (!table)
|
||||
return NULL;
|
||||
if (container)
|
||||
table->table = container;
|
||||
else {
|
||||
table->table = netsnmp_container_find("table_container");
|
||||
if (!table->table) {
|
||||
SNMP_FREE(table);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (flags)
|
||||
table->key_type = (char)(flags & 0x03); /* Use lowest two bits */
|
||||
else
|
||||
table->key_type = TABLE_CONTAINER_KEY_NETSNMP_INDEX;
|
||||
|
||||
if (!table->table->compare)
|
||||
table->table->compare = netsnmp_compare_netsnmp_index;
|
||||
if (!table->table->ncompare)
|
||||
table->table->ncompare = netsnmp_ncompare_netsnmp_index;
|
||||
|
||||
return table;
|
||||
}
|
||||
|
||||
void
|
||||
netsnmp_tcontainer_delete_table( container_table_data *table )
|
||||
{
|
||||
if (!table)
|
||||
return;
|
||||
|
||||
if (table->table)
|
||||
CONTAINER_FREE(table->table);
|
||||
|
||||
SNMP_FREE(table);
|
||||
return;
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_TABLE_CONTAINER_MANAGEMENT */
|
||||
|
||||
/*
|
||||
* The various standalone row operation routines
|
||||
* (create/clone/copy/delete)
|
||||
* will be specific to a particular table,
|
||||
* so can't be implemented here.
|
||||
*/
|
||||
|
||||
int
|
||||
netsnmp_tcontainer_add_row( container_table_data *table, netsnmp_index *row )
|
||||
{
|
||||
if (!table || !table->table || !row)
|
||||
return -1;
|
||||
CONTAINER_INSERT( table->table, row );
|
||||
return 0;
|
||||
}
|
||||
|
||||
netsnmp_index *
|
||||
netsnmp_tcontainer_remove_row( container_table_data *table, netsnmp_index *row )
|
||||
{
|
||||
if (!table || !table->table || !row)
|
||||
return NULL;
|
||||
CONTAINER_REMOVE( table->table, row );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_TABLE_CONTAINER_REPLACE_ROW
|
||||
int
|
||||
netsnmp_tcontainer_replace_row( container_table_data *table,
|
||||
netsnmp_index *old_row, netsnmp_index *new_row )
|
||||
{
|
||||
if (!table || !table->table || !old_row || !new_row)
|
||||
return -1;
|
||||
netsnmp_tcontainer_remove_row( table, old_row );
|
||||
netsnmp_tcontainer_add_row( table, new_row );
|
||||
return 0;
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_TABLE_CONTAINER_REPLACE_ROW */
|
||||
|
||||
/* netsnmp_tcontainer_remove_delete_row() will be table-specific too */
|
||||
|
||||
|
||||
/* ==================================
|
||||
*
|
||||
* Container Table API: MIB maintenance
|
||||
*
|
||||
* ================================== */
|
||||
|
||||
static container_table_data *
|
||||
netsnmp_container_table_data_clone(container_table_data *tad)
|
||||
{
|
||||
++tad->refcnt;
|
||||
return tad;
|
||||
}
|
||||
|
||||
static void
|
||||
netsnmp_container_table_data_free(container_table_data *tad)
|
||||
{
|
||||
if (--tad->refcnt == 0)
|
||||
free(tad);
|
||||
}
|
||||
|
||||
/** returns a netsnmp_mib_handler object for the table_container helper */
|
||||
netsnmp_mib_handler *
|
||||
netsnmp_container_table_handler_get(netsnmp_table_registration_info *tabreg,
|
||||
netsnmp_container *container, char key_type)
|
||||
{
|
||||
container_table_data *tad;
|
||||
netsnmp_mib_handler *handler;
|
||||
|
||||
if (NULL == tabreg) {
|
||||
snmp_log(LOG_ERR, "bad param in netsnmp_container_table_register\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tad = SNMP_MALLOC_TYPEDEF(container_table_data);
|
||||
handler = netsnmp_create_handler("table_container",
|
||||
_container_table_handler);
|
||||
if((NULL == tad) || (NULL == handler)) {
|
||||
if(tad) free(tad); /* SNMP_FREE wasted on locals */
|
||||
if(handler) free(handler); /* SNMP_FREE wasted on locals */
|
||||
snmp_log(LOG_ERR,
|
||||
"malloc failure in netsnmp_container_table_register\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tad->refcnt = 1;
|
||||
tad->tblreg_info = tabreg; /* we need it too, but it really is not ours */
|
||||
if(key_type)
|
||||
tad->key_type = key_type;
|
||||
else
|
||||
tad->key_type = TABLE_CONTAINER_KEY_NETSNMP_INDEX;
|
||||
|
||||
if(NULL == container)
|
||||
container = netsnmp_container_find("table_container");
|
||||
tad->table = container;
|
||||
|
||||
if (NULL==container->compare)
|
||||
container->compare = netsnmp_compare_netsnmp_index;
|
||||
if (NULL==container->ncompare)
|
||||
container->ncompare = netsnmp_ncompare_netsnmp_index;
|
||||
|
||||
handler->myvoid = (void*)tad;
|
||||
handler->data_clone = (void *(*)(void *))netsnmp_container_table_data_clone;
|
||||
handler->data_free = (void (*)(void *))netsnmp_container_table_data_free;
|
||||
handler->flags |= MIB_HANDLER_AUTO_NEXT;
|
||||
|
||||
return handler;
|
||||
}
|
||||
|
||||
int
|
||||
netsnmp_container_table_register(netsnmp_handler_registration *reginfo,
|
||||
netsnmp_table_registration_info *tabreg,
|
||||
netsnmp_container *container, char key_type )
|
||||
{
|
||||
netsnmp_mib_handler *handler;
|
||||
|
||||
if ((NULL == reginfo) || (NULL == reginfo->handler) || (NULL == tabreg)) {
|
||||
snmp_log(LOG_ERR, "bad param in netsnmp_container_table_register\n");
|
||||
return SNMPERR_GENERR;
|
||||
}
|
||||
|
||||
if (NULL==container)
|
||||
container = netsnmp_container_find(reginfo->handlerName);
|
||||
|
||||
handler = netsnmp_container_table_handler_get(tabreg, container, key_type);
|
||||
netsnmp_inject_handler(reginfo, handler );
|
||||
|
||||
return netsnmp_register_table(reginfo, tabreg);
|
||||
}
|
||||
|
||||
int
|
||||
netsnmp_container_table_unregister(netsnmp_handler_registration *reginfo)
|
||||
{
|
||||
container_table_data *tad;
|
||||
|
||||
if (!reginfo)
|
||||
return MIB_UNREGISTRATION_FAILED;
|
||||
tad = (container_table_data *)
|
||||
netsnmp_find_handler_data_by_name(reginfo, "table_container");
|
||||
if (tad) {
|
||||
CONTAINER_FREE( tad->table );
|
||||
tad->table = NULL;
|
||||
/*
|
||||
* Note: don't free the memory tad points at here - that is done
|
||||
* by netsnmp_container_table_data_free().
|
||||
*/
|
||||
}
|
||||
return netsnmp_unregister_table( reginfo );
|
||||
}
|
||||
|
||||
/** retrieve the container used by the table_container helper */
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_TABLE_CONTAINER_EXTRACT
|
||||
netsnmp_container*
|
||||
netsnmp_container_table_container_extract(netsnmp_request_info *request)
|
||||
{
|
||||
return (netsnmp_container *)
|
||||
netsnmp_request_get_list_data(request, TABLE_CONTAINER_CONTAINER);
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_TABLE_CONTAINER_EXTRACT */
|
||||
|
||||
#ifndef NETSNMP_USE_INLINE
|
||||
/** find the context data used by the table_container helper */
|
||||
void *
|
||||
netsnmp_container_table_row_extract(netsnmp_request_info *request)
|
||||
{
|
||||
/*
|
||||
* NOTE: this function must match in table_container.c and table_container.h.
|
||||
* if you change one, change them both!
|
||||
*/
|
||||
return netsnmp_request_get_list_data(request, TABLE_CONTAINER_ROW);
|
||||
}
|
||||
/** find the context data used by the table_container helper */
|
||||
void *
|
||||
netsnmp_container_table_extract_context(netsnmp_request_info *request)
|
||||
{
|
||||
/*
|
||||
* NOTE: this function must match in table_container.c and table_container.h.
|
||||
* if you change one, change them both!
|
||||
*/
|
||||
return netsnmp_request_get_list_data(request, TABLE_CONTAINER_ROW);
|
||||
}
|
||||
#endif /* inline */
|
||||
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_TABLE_CONTAINER_ROW_INSERT
|
||||
/** inserts a newly created table_container entry into a request list */
|
||||
void
|
||||
netsnmp_container_table_row_insert(netsnmp_request_info *request,
|
||||
netsnmp_index *row)
|
||||
{
|
||||
netsnmp_request_info *req;
|
||||
netsnmp_table_request_info *table_info = NULL;
|
||||
netsnmp_variable_list *this_index = NULL;
|
||||
netsnmp_variable_list *that_index = NULL;
|
||||
oid base_oid[] = {0, 0}; /* Make sure index OIDs are legal! */
|
||||
oid this_oid[MAX_OID_LEN];
|
||||
oid that_oid[MAX_OID_LEN];
|
||||
size_t this_oid_len, that_oid_len;
|
||||
|
||||
if (!request)
|
||||
return;
|
||||
|
||||
/*
|
||||
* We'll add the new row information to any request
|
||||
* structure with the same index values as the request
|
||||
* passed in (which includes that one!).
|
||||
*
|
||||
* So construct an OID based on these index values.
|
||||
*/
|
||||
|
||||
table_info = netsnmp_extract_table_info(request);
|
||||
this_index = table_info->indexes;
|
||||
build_oid_noalloc(this_oid, MAX_OID_LEN, &this_oid_len,
|
||||
base_oid, 2, this_index);
|
||||
|
||||
/*
|
||||
* We need to look through the whole of the request list
|
||||
* (as received by the current handler), as there's no
|
||||
* guarantee that this routine will be called by the first
|
||||
* varbind that refers to this row.
|
||||
* In particular, a RowStatus controlled row creation
|
||||
* may easily occur later in the variable list.
|
||||
*
|
||||
* So first, we rewind to the head of the list....
|
||||
*/
|
||||
for (req=request; req->prev; req=req->prev)
|
||||
;
|
||||
|
||||
/*
|
||||
* ... and then start looking for matching indexes
|
||||
* (by constructing OIDs from these index values)
|
||||
*/
|
||||
for (; req; req=req->next) {
|
||||
if (req->processed)
|
||||
continue;
|
||||
|
||||
table_info = netsnmp_extract_table_info(req);
|
||||
that_index = table_info->indexes;
|
||||
build_oid_noalloc(that_oid, MAX_OID_LEN, &that_oid_len,
|
||||
base_oid, 2, that_index);
|
||||
|
||||
/*
|
||||
* This request has the same index values,
|
||||
* so add the newly-created row information.
|
||||
*/
|
||||
if (snmp_oid_compare(this_oid, this_oid_len,
|
||||
that_oid, that_oid_len) == 0) {
|
||||
netsnmp_request_add_list_data(req,
|
||||
netsnmp_create_data_list(TABLE_CONTAINER_ROW, row, NULL));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_TABLE_CONTAINER_ROW_INSERT */
|
||||
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_TABLE_CONTAINER_ROW_REMOVE
|
||||
/** removes a table_container entry from a request list */
|
||||
void
|
||||
netsnmp_container_table_row_remove(netsnmp_request_info *request,
|
||||
netsnmp_index *row)
|
||||
{
|
||||
netsnmp_request_info *req;
|
||||
netsnmp_table_request_info *table_info = NULL;
|
||||
netsnmp_variable_list *this_index = NULL;
|
||||
netsnmp_variable_list *that_index = NULL;
|
||||
oid base_oid[] = {0, 0}; /* Make sure index OIDs are legal! */
|
||||
oid this_oid[MAX_OID_LEN];
|
||||
oid that_oid[MAX_OID_LEN];
|
||||
size_t this_oid_len, that_oid_len;
|
||||
|
||||
if (!request)
|
||||
return;
|
||||
|
||||
/*
|
||||
* We'll add the new row information to any request
|
||||
* structure with the same index values as the request
|
||||
* passed in (which includes that one!).
|
||||
*
|
||||
* So construct an OID based on these index values.
|
||||
*/
|
||||
|
||||
table_info = netsnmp_extract_table_info(request);
|
||||
this_index = table_info->indexes;
|
||||
build_oid_noalloc(this_oid, MAX_OID_LEN, &this_oid_len,
|
||||
base_oid, 2, this_index);
|
||||
|
||||
/*
|
||||
* We need to look through the whole of the request list
|
||||
* (as received by the current handler), as there's no
|
||||
* guarantee that this routine will be called by the first
|
||||
* varbind that refers to this row.
|
||||
* In particular, a RowStatus controlled row creation
|
||||
* may easily occur later in the variable list.
|
||||
*
|
||||
* So first, we rewind to the head of the list....
|
||||
*/
|
||||
for (req=request; req->prev; req=req->prev)
|
||||
;
|
||||
|
||||
/*
|
||||
* ... and then start looking for matching indexes
|
||||
* (by constructing OIDs from these index values)
|
||||
*/
|
||||
for (; req; req=req->next) {
|
||||
if (req->processed)
|
||||
continue;
|
||||
|
||||
table_info = netsnmp_extract_table_info(req);
|
||||
that_index = table_info->indexes;
|
||||
build_oid_noalloc(that_oid, MAX_OID_LEN, &that_oid_len,
|
||||
base_oid, 2, that_index);
|
||||
|
||||
/*
|
||||
* This request has the same index values,
|
||||
* so add the newly-created row information.
|
||||
*/
|
||||
if (snmp_oid_compare(this_oid, this_oid_len,
|
||||
that_oid, that_oid_len) == 0) {
|
||||
netsnmp_request_remove_list_data(req, TABLE_CONTAINER_ROW);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_TABLE_CONTAINER_ROW_REMOVE */
|
||||
|
||||
/** @cond */
|
||||
/**********************************************************************
|
||||
**********************************************************************
|
||||
* *
|
||||
* *
|
||||
* DATA LOOKUP functions *
|
||||
* *
|
||||
* *
|
||||
**********************************************************************
|
||||
**********************************************************************/
|
||||
NETSNMP_STATIC_INLINE void
|
||||
_set_key( container_table_data * tad, netsnmp_request_info *request,
|
||||
netsnmp_table_request_info *tblreq_info,
|
||||
void **key, netsnmp_index *index )
|
||||
{
|
||||
if (TABLE_CONTAINER_KEY_NETSNMP_INDEX == tad->key_type) {
|
||||
index->oids = tblreq_info->index_oid;
|
||||
index->len = tblreq_info->index_oid_len;
|
||||
*key = index;
|
||||
}
|
||||
else if (TABLE_CONTAINER_KEY_VARBIND_INDEX == tad->key_type) {
|
||||
*key = tblreq_info->indexes;
|
||||
}
|
||||
#if 0
|
||||
else if (TABLE_CONTAINER_KEY_VARBIND_RAW == tad->key_type) {
|
||||
*key = request->requestvb;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
*key = NULL;
|
||||
}
|
||||
|
||||
|
||||
NETSNMP_STATIC_INLINE void
|
||||
_data_lookup(netsnmp_handler_registration *reginfo,
|
||||
netsnmp_agent_request_info *agtreq_info,
|
||||
netsnmp_request_info *request, container_table_data * tad)
|
||||
{
|
||||
netsnmp_index *row = NULL;
|
||||
netsnmp_table_request_info *tblreq_info;
|
||||
netsnmp_variable_list *var;
|
||||
netsnmp_index index;
|
||||
void *key;
|
||||
|
||||
var = request->requestvb;
|
||||
|
||||
DEBUGIF("table_container") {
|
||||
DEBUGMSGTL(("table_container", " data_lookup oid:"));
|
||||
DEBUGMSGOID(("table_container", var->name, var->name_length));
|
||||
DEBUGMSG(("table_container", "\n"));
|
||||
}
|
||||
|
||||
/*
|
||||
* Get pointer to the table information for this request. This
|
||||
* information was saved by table_helper_handler.
|
||||
*/
|
||||
tblreq_info = netsnmp_extract_table_info(request);
|
||||
/** the table_helper_handler should enforce column boundaries. */
|
||||
netsnmp_assert((NULL != tblreq_info) &&
|
||||
(tblreq_info->colnum <= tad->tblreg_info->max_column));
|
||||
|
||||
if ((agtreq_info->mode == MODE_GETNEXT) ||
|
||||
(agtreq_info->mode == MODE_GETBULK)) {
|
||||
/*
|
||||
* find the row. This will automatically move to the next
|
||||
* column, if necessary.
|
||||
*/
|
||||
_set_key( tad, request, tblreq_info, &key, &index );
|
||||
row = (netsnmp_index*)_find_next_row(tad->table, tblreq_info, key);
|
||||
if (row) {
|
||||
/*
|
||||
* update indexes in tblreq_info (index & varbind),
|
||||
* then update request varbind oid
|
||||
*/
|
||||
if(TABLE_CONTAINER_KEY_NETSNMP_INDEX == tad->key_type) {
|
||||
tblreq_info->index_oid_len = row->len;
|
||||
memcpy(tblreq_info->index_oid, row->oids,
|
||||
row->len * sizeof(oid));
|
||||
netsnmp_update_variable_list_from_index(tblreq_info);
|
||||
}
|
||||
else if (TABLE_CONTAINER_KEY_VARBIND_INDEX == tad->key_type) {
|
||||
/** xxx-rks: shouldn't tblreq_info->indexes be updated
|
||||
before we call this?? */
|
||||
netsnmp_update_indexes_from_variable_list(tblreq_info);
|
||||
}
|
||||
|
||||
if (TABLE_CONTAINER_KEY_VARBIND_RAW != tad->key_type) {
|
||||
netsnmp_table_build_oid_from_index(reginfo, request,
|
||||
tblreq_info);
|
||||
}
|
||||
}
|
||||
else {
|
||||
/*
|
||||
* no results found. Flag the request so lower handlers will
|
||||
* ignore it, but it is not an error - getnext will move
|
||||
* on to another handler to process this request.
|
||||
*/
|
||||
netsnmp_set_request_error(agtreq_info, request, SNMP_ENDOFMIBVIEW);
|
||||
DEBUGMSGTL(("table_container", "no row found\n"));
|
||||
}
|
||||
} /** GETNEXT/GETBULK */
|
||||
else {
|
||||
|
||||
_set_key( tad, request, tblreq_info, &key, &index );
|
||||
row = (netsnmp_index*)CONTAINER_FIND(tad->table, key);
|
||||
if (NULL == row) {
|
||||
/*
|
||||
* not results found. For a get, that is an error
|
||||
*/
|
||||
DEBUGMSGTL(("table_container", "no row found\n"));
|
||||
#ifndef NETSNMP_NO_WRITE_SUPPORT
|
||||
if((agtreq_info->mode != MODE_SET_RESERVE1) || /* get */
|
||||
(reginfo->modes & HANDLER_CAN_NOT_CREATE)) { /* no create */
|
||||
#endif /* NETSNMP_NO_WRITE_SUPPORT */
|
||||
netsnmp_set_request_error(agtreq_info, request,
|
||||
SNMP_NOSUCHINSTANCE);
|
||||
#ifndef NETSNMP_NO_WRITE_SUPPORT
|
||||
}
|
||||
#endif /* NETSNMP_NO_WRITE_SUPPORT */
|
||||
}
|
||||
} /** GET/SET */
|
||||
|
||||
/*
|
||||
* save the data and table in the request.
|
||||
*/
|
||||
if (SNMP_ENDOFMIBVIEW != request->requestvb->type) {
|
||||
if (NULL != row)
|
||||
netsnmp_request_add_list_data(request,
|
||||
netsnmp_create_data_list
|
||||
(TABLE_CONTAINER_ROW,
|
||||
row, NULL));
|
||||
netsnmp_request_add_list_data(request,
|
||||
netsnmp_create_data_list
|
||||
(TABLE_CONTAINER_CONTAINER,
|
||||
tad->table, NULL));
|
||||
}
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
**********************************************************************
|
||||
* *
|
||||
* *
|
||||
* netsnmp_table_container_helper_handler() *
|
||||
* *
|
||||
* *
|
||||
**********************************************************************
|
||||
**********************************************************************/
|
||||
static int
|
||||
_container_table_handler(netsnmp_mib_handler *handler,
|
||||
netsnmp_handler_registration *reginfo,
|
||||
netsnmp_agent_request_info *agtreq_info,
|
||||
netsnmp_request_info *requests)
|
||||
{
|
||||
int rc = SNMP_ERR_NOERROR;
|
||||
int oldmode, need_processing = 0;
|
||||
container_table_data *tad;
|
||||
|
||||
/** sanity checks */
|
||||
netsnmp_assert((NULL != handler) && (NULL != handler->myvoid));
|
||||
netsnmp_assert((NULL != reginfo) && (NULL != agtreq_info));
|
||||
|
||||
DEBUGMSGTL(("table_container", "Mode %s, Got request:\n",
|
||||
se_find_label_in_slist("agent_mode",agtreq_info->mode)));
|
||||
|
||||
/*
|
||||
* First off, get our pointer from the handler. This
|
||||
* lets us get to the table registration information we
|
||||
* saved in get_table_container_handler(), as well as the
|
||||
* container where the actual table data is stored.
|
||||
*/
|
||||
tad = (container_table_data *)handler->myvoid;
|
||||
|
||||
/*
|
||||
* only do data lookup for first pass
|
||||
*
|
||||
* xxx-rks: this should really be handled up one level. we should
|
||||
* be able to say what modes we want to be called for during table
|
||||
* registration.
|
||||
*/
|
||||
oldmode = agtreq_info->mode;
|
||||
if(MODE_IS_GET(oldmode)
|
||||
#ifndef NETSNMP_NO_WRITE_SUPPORT
|
||||
|| (MODE_SET_RESERVE1 == oldmode)
|
||||
#endif /* NETSNMP_NO_WRITE_SUPPORT */
|
||||
) {
|
||||
netsnmp_request_info *curr_request;
|
||||
/*
|
||||
* Loop through each of the requests, and
|
||||
* try to find the appropriate row from the container.
|
||||
*/
|
||||
for (curr_request = requests; curr_request; curr_request = curr_request->next) {
|
||||
/*
|
||||
* skip anything that doesn't need processing.
|
||||
*/
|
||||
if (curr_request->processed != 0) {
|
||||
DEBUGMSGTL(("table_container", "already processed\n"));
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* find data for this request
|
||||
*/
|
||||
_data_lookup(reginfo, agtreq_info, curr_request, tad);
|
||||
|
||||
if(curr_request->processed)
|
||||
continue;
|
||||
|
||||
++need_processing;
|
||||
} /** for ( ... requests ... ) */
|
||||
}
|
||||
|
||||
/*
|
||||
* send GET instead of GETNEXT to sub-handlers
|
||||
* xxx-rks: again, this should be handled further up.
|
||||
*/
|
||||
if ((oldmode == MODE_GETNEXT) && (handler->next)) {
|
||||
/*
|
||||
* tell agent handlder not to auto call next handler
|
||||
*/
|
||||
handler->flags |= MIB_HANDLER_AUTO_NEXT_OVERRIDE_ONCE;
|
||||
|
||||
/*
|
||||
* if we found rows to process, pretend to be a get request
|
||||
* and call handler below us.
|
||||
*/
|
||||
if(need_processing > 0) {
|
||||
agtreq_info->mode = MODE_GET;
|
||||
rc = netsnmp_call_next_handler(handler, reginfo, agtreq_info,
|
||||
requests);
|
||||
if (rc != SNMP_ERR_NOERROR) {
|
||||
DEBUGMSGTL(("table_container",
|
||||
"next handler returned %d\n", rc));
|
||||
}
|
||||
|
||||
agtreq_info->mode = oldmode; /* restore saved mode */
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
/** @endcond */
|
||||
|
||||
|
||||
/* ==================================
|
||||
*
|
||||
* Container Table API: Row operations
|
||||
*
|
||||
* ================================== */
|
||||
|
||||
static void *
|
||||
_find_next_row(netsnmp_container *c,
|
||||
netsnmp_table_request_info *tblreq,
|
||||
void * key)
|
||||
{
|
||||
void *row = NULL;
|
||||
|
||||
if (!c || !tblreq || !tblreq->reg_info ) {
|
||||
snmp_log(LOG_ERR,"_find_next_row param error\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* table helper should have made sure we aren't below our minimum column
|
||||
*/
|
||||
netsnmp_assert(tblreq->colnum >= tblreq->reg_info->min_column);
|
||||
|
||||
/*
|
||||
* if no indexes then use first row.
|
||||
*/
|
||||
if(tblreq->number_indexes == 0) {
|
||||
row = CONTAINER_FIRST(c);
|
||||
} else {
|
||||
|
||||
if(NULL == key) {
|
||||
netsnmp_index index;
|
||||
index.oids = tblreq->index_oid;
|
||||
index.len = tblreq->index_oid_len;
|
||||
row = CONTAINER_NEXT(c, &index);
|
||||
}
|
||||
else
|
||||
row = CONTAINER_NEXT(c, key);
|
||||
|
||||
/*
|
||||
* we don't have a row, but we might be at the end of a
|
||||
* column, so try the next column.
|
||||
*/
|
||||
if (NULL == row) {
|
||||
/*
|
||||
* don't set tblreq next_col unless we know there is one,
|
||||
* so we don't mess up table handler sparse table processing.
|
||||
*/
|
||||
oid next_col = netsnmp_table_next_column(tblreq);
|
||||
if (0 != next_col) {
|
||||
tblreq->colnum = next_col;
|
||||
row = CONTAINER_FIRST(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return row;
|
||||
}
|
||||
|
||||
/**
|
||||
* deprecated, backwards compatability only
|
||||
*
|
||||
* expected impact to remove: none
|
||||
* - used between helpers, shouldn't have been used by end users
|
||||
*
|
||||
* replacement: none
|
||||
* - never should have been a public method in the first place
|
||||
*/
|
||||
netsnmp_index *
|
||||
netsnmp_table_index_find_next_row(netsnmp_container *c,
|
||||
netsnmp_table_request_info *tblreq)
|
||||
{
|
||||
return (netsnmp_index*)_find_next_row(c, tblreq, NULL );
|
||||
}
|
||||
|
||||
/* ==================================
|
||||
*
|
||||
* Container Table API: Index operations
|
||||
*
|
||||
* ================================== */
|
||||
|
||||
#else /* NETSNMP_FEATURE_REMOVE_TABLE_CONTAINER */
|
||||
netsnmp_feature_unused(table_container);
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_TABLE_CONTAINER */
|
||||
/** @} */
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,347 +0,0 @@
|
||||
/*
|
||||
* table_generic.c
|
||||
*
|
||||
* Generic table API framework
|
||||
*/
|
||||
|
||||
/** @defgroup table_generic generic_table_API
|
||||
* General requirements for a table helper.
|
||||
* @ingroup table
|
||||
*
|
||||
* A given table helper need not implement the whole of this API,
|
||||
* and may need to adjust the prototype of certain routines.
|
||||
* But this description provides a suitable standard design framework.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* =======================================================
|
||||
*
|
||||
* Table Maintenance:
|
||||
* create/delete table
|
||||
* create/copy/clone/delete row
|
||||
* add/replace/remove row
|
||||
*
|
||||
* ======================================================= */
|
||||
|
||||
/** @defgroup table_maintenance table_maintenance
|
||||
*
|
||||
* Routines for maintaining the contents of a table.
|
||||
* This would typically be part of implementing an SNMP MIB,
|
||||
* but could potentially also be used for a standalone table.
|
||||
*
|
||||
* This section of the generic API is primarily relevant to
|
||||
* table helpers where the representation of the table is
|
||||
* constructed and maintained within the helper itself.
|
||||
* "External" tables will typically look after such aspects
|
||||
* directly, although this section of the abstract API
|
||||
* framework could also help direct the design of such
|
||||
* table-specific implementations.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** Create a structure to represent the table.
|
||||
*
|
||||
* This could be as simple as the head of a linked
|
||||
* list, or a more complex container structure.
|
||||
* The 'name' field would typically be used to
|
||||
* distinguish between several tables implemented
|
||||
* using the same table helper. The 'flags' field
|
||||
* would be used to control various (helper-specific)
|
||||
* aspects of table behaviour.
|
||||
*
|
||||
* The table structure returned should typically be
|
||||
* regarded as an opaque, private structure. All
|
||||
* operations on the content of the table should
|
||||
* ideally use the appropriate routines from this API.
|
||||
*/
|
||||
void *
|
||||
netsnmp_generic_create_table( const char *name, int flags ) {
|
||||
}
|
||||
|
||||
/** Release the structure representing a table.
|
||||
* Any rows still contained within the table
|
||||
* should also be removed and deleted.
|
||||
*/
|
||||
void
|
||||
netsnmp_generic_delete_table( void *table ) {
|
||||
}
|
||||
|
||||
/** Create a new row structure suitable for this style of table.
|
||||
* Note that this would typically be a 'standalone' row, and
|
||||
* would not automatically be inserted into an actual table.
|
||||
*/
|
||||
void *
|
||||
netsnmp_generic_create_row( void ) {
|
||||
}
|
||||
|
||||
/** Create a new copy of the specified row.
|
||||
*/
|
||||
void *
|
||||
netsnmp_generic_clone_row( void *row ) {
|
||||
}
|
||||
|
||||
/** Copy the contents of one row into another.
|
||||
* The destination row structure should be
|
||||
* created before this routine is called.
|
||||
*/
|
||||
int
|
||||
netsnmp_generic_copy_row( void *dst_row, void *src_row ) {
|
||||
}
|
||||
|
||||
/** Delete a row data structure.
|
||||
* The row should be removed from any relevant
|
||||
* table(s) before this routine is called.
|
||||
*/
|
||||
void
|
||||
netsnmp_generic_delete_row( void *row ) {
|
||||
}
|
||||
|
||||
/** Add a row to the table.
|
||||
*/
|
||||
int
|
||||
netsnmp_generic_add_row( void *table, void *row ) {
|
||||
}
|
||||
|
||||
/** Replace one row with another in the table.
|
||||
* This will typically (but not necessarily) involve
|
||||
* two rows sharing the same index information (e.g.
|
||||
* to implement update/restore-style SET behaviour).
|
||||
*/
|
||||
int
|
||||
netsnmp_generic_replace_row( void *table, void *old_row, void *new_row ) {
|
||||
}
|
||||
|
||||
/** Remove a row from the table.
|
||||
* The data structure for the row should not be released,
|
||||
* and would be the return value of this routine.
|
||||
*/
|
||||
void *
|
||||
netsnmp_generic_remove_row( void *table, void *row ) {
|
||||
}
|
||||
|
||||
/** Remove and delete a row from the table.
|
||||
*/
|
||||
void
|
||||
netsnmp_generic_remove_delete_row( void *table, void *row ) {
|
||||
}
|
||||
|
||||
/** @} end of table_maintenance */
|
||||
|
||||
/* =======================================================
|
||||
*
|
||||
* MIB Maintenance:
|
||||
* create a handler registration
|
||||
* register/unregister table
|
||||
* extract table from request
|
||||
* extract/insert row
|
||||
*
|
||||
* ======================================================= */
|
||||
|
||||
/** @defgroup mib_maintenance mib_maintenance
|
||||
*
|
||||
* Routines for maintaining a MIB table.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** Create a MIB handler structure.
|
||||
* This will typically be invoked within the corresponding
|
||||
* 'netsnmp_generic_register' routine (or the registration
|
||||
* code of a sub-helper based on this helper).
|
||||
*
|
||||
* Alternatively, it might be called from the initialisation
|
||||
* code of a particular MIB table implementation.
|
||||
*/
|
||||
netsnmp_mib_handler *
|
||||
netsnmp_generic_get_handler(void /* table specific */ ) {
|
||||
|
||||
}
|
||||
|
||||
/** Free a MIB handler structure, releasing any related resources.
|
||||
* Possibly called automatically by 'netsnmp_unregister_handler' ?
|
||||
*/
|
||||
netsnmp_generic_free_handler( netsnmp_mib_handler *handler ) {
|
||||
|
||||
}
|
||||
|
||||
/** Register a MIB table with the SNMP agent.
|
||||
*/
|
||||
int
|
||||
netsnmp_generic_register(netsnmp_handler_registration *reginfo,
|
||||
void *table,
|
||||
netsnmp_table_registration_info *table_info) {
|
||||
}
|
||||
|
||||
/** Unregister a MIB table from the SNMP agent.
|
||||
* This should also release the internal representation of the table.
|
||||
* ?? Is a table-specific version of this needed, or would
|
||||
* 'netsnmp_unregister_handler' + 'netsnmp_generic_free_handler' do?
|
||||
*/
|
||||
int
|
||||
netsnmp_generic_unregister(netsnmp_handler_registration *reginfo) {
|
||||
}
|
||||
|
||||
/** Extract the table relating to a requested varbind.
|
||||
*/
|
||||
void
|
||||
netsnmp_generic_extract_table( netsnmp_request_info *request ) {
|
||||
}
|
||||
|
||||
/** Extract the row relating to a requested varbind.
|
||||
*/
|
||||
void
|
||||
netsnmp_generic_extract_row( netsnmp_request_info *request ) {
|
||||
}
|
||||
|
||||
/** Associate a (new) row with the requested varbind.
|
||||
* The row should also be associated with any other
|
||||
* varbinds that refer to the same index values.
|
||||
*/
|
||||
void
|
||||
netsnmp_generic_insert_row( netsnmp_request_info *request, void *row ) {
|
||||
}
|
||||
|
||||
/** @} end of mib_maintenance */
|
||||
|
||||
/* =======================================================
|
||||
*
|
||||
* Row Operations
|
||||
* get first/this/next row
|
||||
* get row/next row by index
|
||||
* get row/next row by OID
|
||||
* number of rows
|
||||
*
|
||||
* ======================================================= */
|
||||
|
||||
/** @defgroup table_rows table_rows
|
||||
*
|
||||
* Routines for working with the rows of a table.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** Retrieve the first row of the table.
|
||||
*/
|
||||
void *
|
||||
netsnmp_generic_row_first( void *table ) {
|
||||
}
|
||||
|
||||
/** Retrieve the given row from the table.
|
||||
* This could either be the same data pointer,
|
||||
* passed in, or a separate row structure
|
||||
* sharing the same index values (or NULL).
|
||||
*
|
||||
* This routine also provides a means to tell
|
||||
* whether a given row is present in the table.
|
||||
*/
|
||||
void *
|
||||
netsnmp_generic_row_get( void *table, void *row ) {
|
||||
}
|
||||
|
||||
/** Retrieve the following row from the table.
|
||||
* If the specified row is not present, this
|
||||
* routine should return the entry next after
|
||||
* the position this row would have occupied.
|
||||
*/
|
||||
void *
|
||||
netsnmp_generic_row_next( void *table, void *row ) {
|
||||
}
|
||||
|
||||
/** Retrieve the row with the specified index values.
|
||||
*/
|
||||
void *
|
||||
netsnmp_generic_row_get_byidx( void *table,
|
||||
netsnmp_variable_list *indexes ) {
|
||||
}
|
||||
|
||||
/** Retrieve the next row after the specified index values.
|
||||
*/
|
||||
void *
|
||||
netsnmp_generic_row_next_byidx( void *table,
|
||||
netsnmp_variable_list *indexes ) {
|
||||
|
||||
}
|
||||
|
||||
/** Retrieve the row with the specified instance OIDs.
|
||||
*/
|
||||
void *
|
||||
netsnmp_generic_row_get_byoid( void *table, oid *instance, size_t len ) {
|
||||
}
|
||||
|
||||
/** Retrieve the next row after the specified instance OIDs.
|
||||
*/
|
||||
void *
|
||||
netsnmp_generic_row_next_byoid( void *table, oid *instance, size_t len ) {
|
||||
}
|
||||
|
||||
/** Report the number of rows in the table.
|
||||
*/
|
||||
int
|
||||
netsnmp_generic_row_count( void *table ) {
|
||||
}
|
||||
|
||||
/** @} end of table_rows */
|
||||
|
||||
/* =======================================================
|
||||
*
|
||||
* Index Operations
|
||||
* get table index structure
|
||||
* get row index values/OIDs
|
||||
* compare row with index/OIDs
|
||||
* subtree comparisons (index/OIDs)
|
||||
*
|
||||
* ======================================================= */
|
||||
|
||||
/** @defgroup table_indexes table_indexes
|
||||
*
|
||||
* Routines for working with row indexes.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** Retrieve the indexing structure of the table.
|
||||
*/
|
||||
netsnmp_variable_list *
|
||||
netsnmp_generic_idx( void *table ) {
|
||||
}
|
||||
|
||||
/** Report the index values for a row.
|
||||
*/
|
||||
netsnmp_variable_list *
|
||||
netsnmp_generic_row_idx( void *row ) {
|
||||
}
|
||||
|
||||
/** Report the instance OIDs for a row.
|
||||
*/
|
||||
size_t
|
||||
netsnmp_generic_row_oid( void *row, oid *instances ) {
|
||||
}
|
||||
|
||||
/** Compare a row against the specified index values.
|
||||
*/
|
||||
int
|
||||
netsnmp_generic_compare_idx( void *row, netsnmp_variable_list *index ) {
|
||||
}
|
||||
|
||||
/** Compare a row against the specified instance OIDs.
|
||||
*/
|
||||
int
|
||||
netsnmp_generic_compare_oid( void *row, oid *instances, size_t len ) {
|
||||
}
|
||||
|
||||
/** Check if a row lies within a subtree of index values.
|
||||
*/
|
||||
int
|
||||
netsnmp_generic_compare_subtree_idx( void *row, netsnmp_variable_list *index ) {
|
||||
}
|
||||
|
||||
/** Check if a row lies within a subtree of instance OIDs.
|
||||
*/
|
||||
int
|
||||
netsnmp_generic_compare_subtree_oid( void *row, oid *instances, size_t len ) {
|
||||
}
|
||||
|
||||
/** @} end of table_indexes */
|
||||
/** @} end of table_generic */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,264 +0,0 @@
|
||||
/*
|
||||
* table_row.c
|
||||
*
|
||||
* Helper for registering single row slices of a shared table
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
#define TABLE_ROW_DATA "table_row"
|
||||
|
||||
#include <net-snmp/net-snmp-config.h>
|
||||
#include <net-snmp/net-snmp-features.h>
|
||||
|
||||
#if HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#else
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#include <net-snmp/net-snmp-includes.h>
|
||||
#include <net-snmp/agent/net-snmp-agent-includes.h>
|
||||
|
||||
#include <net-snmp/agent/table.h>
|
||||
#include <net-snmp/agent/table_container.h>
|
||||
#include <net-snmp/library/container.h>
|
||||
#include <net-snmp/library/snmp_assert.h>
|
||||
|
||||
netsnmp_feature_child_of(table_row_all, mib_helpers)
|
||||
|
||||
netsnmp_feature_child_of(table_row_extract, table_row_all)
|
||||
|
||||
|
||||
/*
|
||||
* snmp.h:#define SNMP_MSG_INTERNAL_SET_BEGIN -1
|
||||
* snmp.h:#define SNMP_MSG_INTERNAL_SET_RESERVE1 0
|
||||
* snmp.h:#define SNMP_MSG_INTERNAL_SET_RESERVE2 1
|
||||
* snmp.h:#define SNMP_MSG_INTERNAL_SET_ACTION 2
|
||||
* snmp.h:#define SNMP_MSG_INTERNAL_SET_COMMIT 3
|
||||
* snmp.h:#define SNMP_MSG_INTERNAL_SET_FREE 4
|
||||
* snmp.h:#define SNMP_MSG_INTERNAL_SET_UNDO 5
|
||||
*/
|
||||
|
||||
/** @defgroup table_row table_row
|
||||
* Helps you implement a table shared across two or more subagents,
|
||||
* or otherwise split into individual row slices.
|
||||
* @ingroup table
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
static Netsnmp_Node_Handler _table_row_handler;
|
||||
static Netsnmp_Node_Handler _table_row_default_handler;
|
||||
|
||||
/**********************************************************************
|
||||
**********************************************************************
|
||||
* *
|
||||
* *
|
||||
* PUBLIC Registration functions *
|
||||
* *
|
||||
* *
|
||||
**********************************************************************
|
||||
**********************************************************************/
|
||||
|
||||
/* ==================================
|
||||
*
|
||||
* Table Row API: Table maintenance
|
||||
*
|
||||
* This helper doesn't operate with the complete
|
||||
* table, so these routines are not relevant.
|
||||
*
|
||||
* ================================== */
|
||||
|
||||
|
||||
/* ==================================
|
||||
*
|
||||
* Table Row API: MIB maintenance
|
||||
*
|
||||
* ================================== */
|
||||
|
||||
/** returns a netsnmp_mib_handler object for the table_container helper */
|
||||
netsnmp_mib_handler *
|
||||
netsnmp_table_row_handler_get(void *row)
|
||||
{
|
||||
netsnmp_mib_handler *handler;
|
||||
|
||||
handler = netsnmp_create_handler("table_row",
|
||||
_table_row_handler);
|
||||
if(NULL == handler) {
|
||||
snmp_log(LOG_ERR,
|
||||
"malloc failure in netsnmp_table_row_register\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
handler->myvoid = (void*)row;
|
||||
handler->flags |= MIB_HANDLER_INSTANCE;
|
||||
/* handler->flags |= MIB_HANDLER_AUTO_NEXT; ??? */
|
||||
|
||||
return handler;
|
||||
}
|
||||
|
||||
int
|
||||
netsnmp_table_row_register(netsnmp_handler_registration *reginfo,
|
||||
netsnmp_table_registration_info *tabreg,
|
||||
void *row, netsnmp_variable_list *index)
|
||||
{
|
||||
netsnmp_handler_registration *reg2;
|
||||
netsnmp_mib_handler *handler;
|
||||
oid row_oid[MAX_OID_LEN];
|
||||
size_t row_oid_len, len;
|
||||
char tmp[SNMP_MAXBUF_MEDIUM];
|
||||
|
||||
if ((NULL == reginfo) || (NULL == reginfo->handler) || (NULL == tabreg)) {
|
||||
snmp_log(LOG_ERR, "bad param in netsnmp_table_row_register\n");
|
||||
return SNMPERR_GENERR;
|
||||
}
|
||||
|
||||
/*
|
||||
* The first table_row invoked for a particular table should
|
||||
* register the full table as well, with a default handler to
|
||||
* process requests for non-existent (or incomplete) rows.
|
||||
*
|
||||
* Subsequent table_row registrations attempting to set up
|
||||
* this default handler would fail - preferably silently!
|
||||
*/
|
||||
snprintf(tmp, sizeof(tmp), "%s_table", reginfo->handlerName);
|
||||
reg2 = netsnmp_create_handler_registration(
|
||||
tmp, _table_row_default_handler,
|
||||
reginfo->rootoid, reginfo->rootoid_len,
|
||||
reginfo->modes);
|
||||
netsnmp_register_table(reg2, tabreg); /* Ignore return value */
|
||||
|
||||
/*
|
||||
* Adjust the OID being registered, to take account
|
||||
* of the indexes and column range provided....
|
||||
*/
|
||||
row_oid_len = reginfo->rootoid_len;
|
||||
memcpy( row_oid, (u_char *) reginfo->rootoid, row_oid_len * sizeof(oid));
|
||||
row_oid[row_oid_len++] = 1; /* tableEntry */
|
||||
row_oid[row_oid_len++] = tabreg->min_column;
|
||||
reginfo->range_ubound = tabreg->max_column;
|
||||
reginfo->range_subid = row_oid_len-1;
|
||||
build_oid_noalloc(&row_oid[row_oid_len],
|
||||
MAX_OID_LEN-row_oid_len, &len, NULL, 0, index);
|
||||
row_oid_len += len;
|
||||
free(reginfo->rootoid);
|
||||
reginfo->rootoid = snmp_duplicate_objid(row_oid, row_oid_len);
|
||||
reginfo->rootoid_len = row_oid_len;
|
||||
|
||||
|
||||
/*
|
||||
* ... insert a minimal handler ...
|
||||
*/
|
||||
handler = netsnmp_table_row_handler_get(row);
|
||||
netsnmp_inject_handler(reginfo, handler );
|
||||
|
||||
/*
|
||||
* ... and register the row
|
||||
*/
|
||||
return netsnmp_register_handler(reginfo);
|
||||
}
|
||||
|
||||
|
||||
/** return the row data structure supplied to the table_row helper */
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_TABLE_ROW_EXTRACT
|
||||
void *
|
||||
netsnmp_table_row_extract(netsnmp_request_info *request)
|
||||
{
|
||||
return netsnmp_request_get_list_data(request, TABLE_ROW_DATA);
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_TABLE_ROW_EXTRACT */
|
||||
/** @cond */
|
||||
|
||||
/**********************************************************************
|
||||
**********************************************************************
|
||||
* *
|
||||
* *
|
||||
* netsnmp_table_row_helper_handler() *
|
||||
* *
|
||||
* *
|
||||
**********************************************************************
|
||||
**********************************************************************/
|
||||
|
||||
static int
|
||||
_table_row_handler(netsnmp_mib_handler *handler,
|
||||
netsnmp_handler_registration *reginfo,
|
||||
netsnmp_agent_request_info *reqinfo,
|
||||
netsnmp_request_info *requests)
|
||||
{
|
||||
int rc = SNMP_ERR_NOERROR;
|
||||
netsnmp_request_info *req;
|
||||
void *row;
|
||||
|
||||
/** sanity checks */
|
||||
netsnmp_assert((NULL != handler) && (NULL != handler->myvoid));
|
||||
netsnmp_assert((NULL != reginfo) && (NULL != reqinfo));
|
||||
|
||||
DEBUGMSGTL(("table_row", "Mode %s, Got request:\n",
|
||||
se_find_label_in_slist("agent_mode",reqinfo->mode)));
|
||||
|
||||
/*
|
||||
* First off, get our pointer from the handler.
|
||||
* This contains the row that was actually registered.
|
||||
* Make this available for each of the requests passed in.
|
||||
*/
|
||||
row = handler->myvoid;
|
||||
for (req = requests; req; req=req->next)
|
||||
netsnmp_request_add_list_data(req,
|
||||
netsnmp_create_data_list(TABLE_ROW_DATA, row, NULL));
|
||||
|
||||
/*
|
||||
* Then call the next handler, to actually process the request
|
||||
*/
|
||||
rc = netsnmp_call_next_handler(handler, reginfo, reqinfo, requests);
|
||||
if (rc != SNMP_ERR_NOERROR) {
|
||||
DEBUGMSGTL(("table_row", "next handler returned %d\n", rc));
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int
|
||||
_table_row_default_handler(netsnmp_mib_handler *handler,
|
||||
netsnmp_handler_registration *reginfo,
|
||||
netsnmp_agent_request_info *reqinfo,
|
||||
netsnmp_request_info *requests)
|
||||
{
|
||||
netsnmp_request_info *req;
|
||||
netsnmp_table_request_info *table_info;
|
||||
netsnmp_table_registration_info *tabreg;
|
||||
|
||||
tabreg = netsnmp_find_table_registration_info(reginfo);
|
||||
for ( req=requests; req; req=req->next ) {
|
||||
table_info = netsnmp_extract_table_info( req );
|
||||
if (( table_info->colnum >= tabreg->min_column ) ||
|
||||
( table_info->colnum <= tabreg->max_column )) {
|
||||
netsnmp_set_request_error( reqinfo, req, SNMP_NOSUCHINSTANCE );
|
||||
} else {
|
||||
netsnmp_set_request_error( reqinfo, req, SNMP_NOSUCHOBJECT );
|
||||
}
|
||||
}
|
||||
return SNMP_ERR_NOERROR;
|
||||
}
|
||||
/** @endcond */
|
||||
|
||||
|
||||
/* ==================================
|
||||
*
|
||||
* Table Row API: Row operations
|
||||
*
|
||||
* This helper doesn't operate with the complete
|
||||
* table, so these routines are not relevant.
|
||||
*
|
||||
* ================================== */
|
||||
|
||||
|
||||
/* ==================================
|
||||
*
|
||||
* Table Row API: Index operations
|
||||
*
|
||||
* This helper doesn't operate with the complete
|
||||
* table, so these routines are not relevant.
|
||||
*
|
||||
* ================================== */
|
||||
|
||||
/** @} */
|
||||
@@ -1,651 +0,0 @@
|
||||
#include <net-snmp/net-snmp-config.h>
|
||||
#include <net-snmp/net-snmp-features.h>
|
||||
|
||||
#include <net-snmp/net-snmp-includes.h>
|
||||
#include <net-snmp/agent/net-snmp-agent-includes.h>
|
||||
|
||||
#include <net-snmp/agent/table_tdata.h>
|
||||
|
||||
#if HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#else
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#include <net-snmp/agent/table.h>
|
||||
#include <net-snmp/agent/table_container.h>
|
||||
#include <net-snmp/agent/read_only.h>
|
||||
|
||||
#if HAVE_DMALLOC_H
|
||||
#include <dmalloc.h>
|
||||
#endif
|
||||
|
||||
netsnmp_feature_child_of(table_tdata_all, mib_helpers)
|
||||
netsnmp_feature_child_of(table_tdata, table_tdata_all)
|
||||
netsnmp_feature_child_of(table_tdata_delete_table, table_tdata_all)
|
||||
netsnmp_feature_child_of(table_tdata_extract_table, table_tdata_all)
|
||||
netsnmp_feature_child_of(table_tdata_remove_row, table_tdata_all)
|
||||
netsnmp_feature_child_of(table_tdata_insert_row, table_tdata_all)
|
||||
|
||||
#ifdef NETSNMP_FEATURE_REQUIRE_TABLE_TDATA
|
||||
netsnmp_feature_require(table_container_row_insert)
|
||||
#ifdef NETSNMP_FEATURE_REQUIRE_TABLE_TDATA_REMOVE_ROW
|
||||
netsnmp_feature_require(table_container_row_remove)
|
||||
#endif /* NETSNMP_FEATURE_REQUIRE_TABLE_TDATA_REMOVE_ROW */
|
||||
#endif /* NETSNMP_FEATURE_REQUIRE_TABLE_TDATA */
|
||||
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_TABLE_TDATA
|
||||
|
||||
/** @defgroup tdata tdata
|
||||
* Implement a table with datamatted storage.
|
||||
* @ingroup table
|
||||
*
|
||||
* This helper helps you implement a table where all the rows are
|
||||
* expected to be stored within the agent itself and not in some
|
||||
* external storage location. It can be used to store a list of
|
||||
* rows, where a row consists of the indexes to the table and a
|
||||
* generic data pointer. You can then implement a subhandler which
|
||||
* is passed the exact row definition and data it must return data
|
||||
* for or accept data for. Complex GETNEXT handling is greatly
|
||||
* simplified in this case.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* ==================================
|
||||
*
|
||||
* TData API: Table maintenance
|
||||
*
|
||||
* ================================== */
|
||||
|
||||
/*
|
||||
* generates the index portion of an table oid from a varlist.
|
||||
*/
|
||||
void
|
||||
_netsnmp_tdata_generate_index_oid(netsnmp_tdata_row *row)
|
||||
{
|
||||
build_oid(&row->oid_index.oids, &row->oid_index.len, NULL, 0, row->indexes);
|
||||
}
|
||||
|
||||
/** creates and returns a 'tdata' table data structure */
|
||||
netsnmp_tdata *
|
||||
netsnmp_tdata_create_table(const char *name, long flags)
|
||||
{
|
||||
netsnmp_tdata *table = SNMP_MALLOC_TYPEDEF(netsnmp_tdata);
|
||||
if ( !table )
|
||||
return NULL;
|
||||
|
||||
table->flags = flags;
|
||||
if (name)
|
||||
table->name = strdup(name);
|
||||
|
||||
if (!(table->flags & TDATA_FLAG_NO_CONTAINER)) {
|
||||
table->container = netsnmp_container_find( name );
|
||||
if (!table->container)
|
||||
table->container = netsnmp_container_find( "table_container" );
|
||||
if (table->container)
|
||||
table->container->container_name = strdup(name);
|
||||
}
|
||||
return table;
|
||||
}
|
||||
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_TABLE_TDATA_DELETE_TABLE
|
||||
/** creates and returns a 'tdata' table data structure */
|
||||
void
|
||||
netsnmp_tdata_delete_table(netsnmp_tdata *table)
|
||||
{
|
||||
if (!table)
|
||||
return;
|
||||
|
||||
if (table->name)
|
||||
free(table->name);
|
||||
if (table->container)
|
||||
CONTAINER_FREE(table->container);
|
||||
|
||||
SNMP_FREE(table);
|
||||
return;
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_TABLE_TDATA_DELETE_TABLE */
|
||||
|
||||
/** creates and returns a pointer to new row data structure */
|
||||
netsnmp_tdata_row *
|
||||
netsnmp_tdata_create_row(void)
|
||||
{
|
||||
netsnmp_tdata_row *row = SNMP_MALLOC_TYPEDEF(netsnmp_tdata_row);
|
||||
return row;
|
||||
}
|
||||
|
||||
/** clones a 'tdata' row. DOES NOT CLONE THE TABLE-SPECIFIC ENTRY DATA. */
|
||||
netsnmp_feature_child_of(tdata_clone_row, table_tdata_all)
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_TDATA_CLONE_ROW
|
||||
netsnmp_tdata_row *
|
||||
netsnmp_tdata_clone_row(netsnmp_tdata_row *row)
|
||||
{
|
||||
netsnmp_tdata_row *newrow = NULL;
|
||||
if (!row)
|
||||
return NULL;
|
||||
|
||||
newrow = netsnmp_memdup(row, sizeof(netsnmp_tdata_row));
|
||||
if (!newrow)
|
||||
return NULL;
|
||||
|
||||
if (row->indexes) {
|
||||
newrow->indexes = snmp_clone_varbind(newrow->indexes);
|
||||
if (!newrow->indexes) {
|
||||
SNMP_FREE(newrow);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (row->oid_index.oids) {
|
||||
newrow->oid_index.oids =
|
||||
snmp_duplicate_objid(row->oid_index.oids, row->oid_index.len);
|
||||
if (!newrow->oid_index.oids) {
|
||||
if (newrow->indexes)
|
||||
snmp_free_varbind(newrow->indexes);
|
||||
SNMP_FREE(newrow);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return newrow;
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_TDATA_CLONE_ROW */
|
||||
|
||||
/** copy the contents of a 'tdata' row.
|
||||
DOES NOT COPY THE TABLE-SPECIFIC ENTRY DATA. */
|
||||
netsnmp_feature_child_of(tdata_copy_row, table_tdata_all)
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_TDATA_COPY_ROW
|
||||
int
|
||||
netsnmp_tdata_copy_row(netsnmp_tdata_row *dst_row, netsnmp_tdata_row *src_row)
|
||||
{
|
||||
if ( !src_row || !dst_row )
|
||||
return -1;
|
||||
|
||||
memcpy((u_char *) dst_row, (u_char *) src_row,
|
||||
sizeof(netsnmp_tdata_row));
|
||||
if (src_row->indexes) {
|
||||
dst_row->indexes = snmp_clone_varbind(src_row->indexes);
|
||||
if (!dst_row->indexes)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (src_row->oid_index.oids) {
|
||||
dst_row->oid_index.oids = snmp_duplicate_objid(src_row->oid_index.oids,
|
||||
src_row->oid_index.len);
|
||||
if (!dst_row->oid_index.oids)
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_TDATA_COPY_ROW */
|
||||
|
||||
/** deletes the memory used by the specified row
|
||||
* returns the table-specific entry data
|
||||
* (that it doesn't know how to delete) */
|
||||
void *
|
||||
netsnmp_tdata_delete_row(netsnmp_tdata_row *row)
|
||||
{
|
||||
void *data;
|
||||
|
||||
if (!row)
|
||||
return NULL;
|
||||
|
||||
/*
|
||||
* free the memory we can
|
||||
*/
|
||||
if (row->indexes)
|
||||
snmp_free_varbind(row->indexes);
|
||||
SNMP_FREE(row->oid_index.oids);
|
||||
data = row->data;
|
||||
free(row);
|
||||
|
||||
/*
|
||||
* return the void * pointer
|
||||
*/
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a row to the given table (stored in proper lexographical order).
|
||||
*
|
||||
* returns SNMPERR_SUCCESS on successful addition.
|
||||
* or SNMPERR_GENERR on failure (E.G., indexes already existed)
|
||||
*/
|
||||
int
|
||||
netsnmp_tdata_add_row(netsnmp_tdata *table,
|
||||
netsnmp_tdata_row *row)
|
||||
{
|
||||
if (!row || !table)
|
||||
return SNMPERR_GENERR;
|
||||
|
||||
if (row->indexes)
|
||||
_netsnmp_tdata_generate_index_oid(row);
|
||||
|
||||
if (!row->oid_index.oids) {
|
||||
snmp_log(LOG_ERR,
|
||||
"illegal data attempted to be added to table %s (no index)\n",
|
||||
table->name);
|
||||
return SNMPERR_GENERR;
|
||||
}
|
||||
|
||||
/*
|
||||
* The individual index values probably won't be needed,
|
||||
* so this memory can be released.
|
||||
* Note that this is purely internal to the helper.
|
||||
* The calling application can set this flag as
|
||||
* a hint to the helper that these values aren't
|
||||
* required, but it's up to the helper as to
|
||||
* whether it takes any notice or not!
|
||||
*/
|
||||
if (table->flags & TDATA_FLAG_NO_STORE_INDEXES) {
|
||||
snmp_free_varbind(row->indexes);
|
||||
row->indexes = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* add this row to the stored table
|
||||
*/
|
||||
if (CONTAINER_INSERT( table->container, row ) != 0)
|
||||
return SNMPERR_GENERR;
|
||||
|
||||
DEBUGMSGTL(("tdata_add_row", "added row (%p)\n", row));
|
||||
|
||||
return SNMPERR_SUCCESS;
|
||||
}
|
||||
|
||||
/** swaps out origrow with newrow. This does *not* delete/free anything! */
|
||||
netsnmp_feature_child_of(tdata_replace_row, table_tdata_all)
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_TDATA_REPLACE_ROW
|
||||
void
|
||||
netsnmp_tdata_replace_row(netsnmp_tdata *table,
|
||||
netsnmp_tdata_row *origrow,
|
||||
netsnmp_tdata_row *newrow)
|
||||
{
|
||||
netsnmp_tdata_remove_row(table, origrow);
|
||||
netsnmp_tdata_add_row(table, newrow);
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_TDATA_REPLACE_ROW */
|
||||
|
||||
/**
|
||||
* removes a row from the given table and returns it (no free's called)
|
||||
*
|
||||
* returns the row pointer itself on successful removing.
|
||||
* or NULL on failure (bad arguments)
|
||||
*/
|
||||
netsnmp_tdata_row *
|
||||
netsnmp_tdata_remove_row(netsnmp_tdata *table,
|
||||
netsnmp_tdata_row *row)
|
||||
{
|
||||
if (!row || !table)
|
||||
return NULL;
|
||||
|
||||
CONTAINER_REMOVE( table->container, row );
|
||||
return row;
|
||||
}
|
||||
|
||||
/**
|
||||
* removes and frees a row of the given table and
|
||||
* returns the table-specific entry data
|
||||
*
|
||||
* returns the void * pointer on successful deletion.
|
||||
* or NULL on failure (bad arguments)
|
||||
*/
|
||||
void *
|
||||
netsnmp_tdata_remove_and_delete_row(netsnmp_tdata *table,
|
||||
netsnmp_tdata_row *row)
|
||||
{
|
||||
if (!row || !table)
|
||||
return NULL;
|
||||
|
||||
/*
|
||||
* remove it from the list
|
||||
*/
|
||||
netsnmp_tdata_remove_row(table, row);
|
||||
return netsnmp_tdata_delete_row(row);
|
||||
}
|
||||
|
||||
|
||||
/* ==================================
|
||||
*
|
||||
* TData API: MIB maintenance
|
||||
*
|
||||
* ================================== */
|
||||
|
||||
Netsnmp_Node_Handler _netsnmp_tdata_helper_handler;
|
||||
|
||||
/** Creates a tdata handler and returns it */
|
||||
netsnmp_mib_handler *
|
||||
netsnmp_get_tdata_handler(netsnmp_tdata *table)
|
||||
{
|
||||
netsnmp_mib_handler *ret = NULL;
|
||||
|
||||
if (!table) {
|
||||
snmp_log(LOG_INFO,
|
||||
"netsnmp_get_tdata_handler(NULL) called\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = netsnmp_create_handler(TABLE_TDATA_NAME,
|
||||
_netsnmp_tdata_helper_handler);
|
||||
if (ret) {
|
||||
ret->flags |= MIB_HANDLER_AUTO_NEXT;
|
||||
ret->myvoid = (void *) table;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* The helper handler that takes care of passing a specific row of
|
||||
* data down to the lower handler(s). The table_container helper
|
||||
* has already taken care of identifying the appropriate row of the
|
||||
* table (and converting GETNEXT requests into an equivalent GET request)
|
||||
* So all we need to do here is make sure that the row is accessible
|
||||
* using tdata-style retrieval techniques as well.
|
||||
*/
|
||||
int
|
||||
_netsnmp_tdata_helper_handler(netsnmp_mib_handler *handler,
|
||||
netsnmp_handler_registration *reginfo,
|
||||
netsnmp_agent_request_info *reqinfo,
|
||||
netsnmp_request_info *requests)
|
||||
{
|
||||
netsnmp_tdata *table = (netsnmp_tdata *) handler->myvoid;
|
||||
netsnmp_request_info *request;
|
||||
netsnmp_table_request_info *table_info;
|
||||
netsnmp_tdata_row *row;
|
||||
int need_processing = 1;
|
||||
|
||||
switch ( reqinfo->mode ) {
|
||||
case MODE_GET:
|
||||
need_processing = 0; /* only need processing if some vars found */
|
||||
/** Fall through */
|
||||
|
||||
#ifndef NETSNMP_NO_WRITE_SUPPORT
|
||||
case MODE_SET_RESERVE1:
|
||||
#endif /* NETSNMP_NO_WRITE_SUPPORT */
|
||||
|
||||
for (request = requests; request; request = request->next) {
|
||||
if (request->processed)
|
||||
continue;
|
||||
|
||||
table_info = netsnmp_extract_table_info(request);
|
||||
if (!table_info) {
|
||||
netsnmp_assert(table_info); /* yes, this will always hit */
|
||||
netsnmp_set_request_error(reqinfo, request, SNMP_ERR_GENERR);
|
||||
continue; /* eek */
|
||||
}
|
||||
row = (netsnmp_tdata_row*)netsnmp_container_table_row_extract( request );
|
||||
if (!row && (reqinfo->mode == MODE_GET)) {
|
||||
netsnmp_assert(row); /* yes, this will always hit */
|
||||
netsnmp_set_request_error(reqinfo, request, SNMP_ERR_GENERR);
|
||||
continue; /* eek */
|
||||
}
|
||||
++need_processing;
|
||||
netsnmp_request_add_list_data(request,
|
||||
netsnmp_create_data_list(
|
||||
TABLE_TDATA_TABLE, table, NULL));
|
||||
netsnmp_request_add_list_data(request,
|
||||
netsnmp_create_data_list(
|
||||
TABLE_TDATA_ROW, row, NULL));
|
||||
}
|
||||
/** skip next handler if processing not needed */
|
||||
if (!need_processing)
|
||||
handler->flags |= MIB_HANDLER_AUTO_NEXT_OVERRIDE_ONCE;
|
||||
}
|
||||
|
||||
/* next handler called automatically - 'AUTO_NEXT' */
|
||||
return SNMP_ERR_NOERROR;
|
||||
}
|
||||
|
||||
|
||||
/** registers a tdata-based MIB table */
|
||||
int
|
||||
netsnmp_tdata_register(netsnmp_handler_registration *reginfo,
|
||||
netsnmp_tdata *table,
|
||||
netsnmp_table_registration_info *table_info)
|
||||
{
|
||||
netsnmp_inject_handler(reginfo, netsnmp_get_tdata_handler(table));
|
||||
return netsnmp_container_table_register(reginfo, table_info,
|
||||
table->container, TABLE_CONTAINER_KEY_NETSNMP_INDEX);
|
||||
}
|
||||
|
||||
netsnmp_feature_child_of(tdata_unregister, table_tdata_all)
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_TDATA_UNREGISTER
|
||||
int
|
||||
netsnmp_tdata_unregister(netsnmp_handler_registration *reginfo)
|
||||
{
|
||||
/* free table; */
|
||||
return netsnmp_container_table_unregister(reginfo);
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_TDATA_UNREGISTER */
|
||||
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_TABLE_TDATA_EXTRACT_TABLE
|
||||
/** extracts the tdata table from the request structure */
|
||||
netsnmp_tdata *
|
||||
netsnmp_tdata_extract_table(netsnmp_request_info *request)
|
||||
{
|
||||
return (netsnmp_tdata *) netsnmp_request_get_list_data(request,
|
||||
TABLE_TDATA_TABLE);
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_TABLE_TDATA_EXTRACT_TABLE */
|
||||
|
||||
/** extracts the tdata container from the request structure */
|
||||
netsnmp_feature_child_of(tdata_extract_container, table_tdata_all)
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_TDATA_EXTRACT_CONTAINER
|
||||
netsnmp_container *
|
||||
netsnmp_tdata_extract_container(netsnmp_request_info *request)
|
||||
{
|
||||
netsnmp_tdata *tdata = (netsnmp_tdata*)
|
||||
netsnmp_request_get_list_data(request, TABLE_TDATA_TABLE);
|
||||
return ( tdata ? tdata->container : NULL );
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_TDATA_EXTRACT_CONTAINER */
|
||||
|
||||
/** extracts the tdata row being accessed from the request structure */
|
||||
netsnmp_tdata_row *
|
||||
netsnmp_tdata_extract_row(netsnmp_request_info *request)
|
||||
{
|
||||
return (netsnmp_tdata_row *) netsnmp_container_table_row_extract(request);
|
||||
}
|
||||
|
||||
/** extracts the (table-specific) entry being accessed from the
|
||||
* request structure */
|
||||
void *
|
||||
netsnmp_tdata_extract_entry(netsnmp_request_info *request)
|
||||
{
|
||||
netsnmp_tdata_row *row =
|
||||
(netsnmp_tdata_row *) netsnmp_tdata_extract_row(request);
|
||||
if (row)
|
||||
return row->data;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_TABLE_TDATA_INSERT_ROW
|
||||
/** inserts a newly created tdata row into a request */
|
||||
NETSNMP_INLINE void
|
||||
netsnmp_insert_tdata_row(netsnmp_request_info *request,
|
||||
netsnmp_tdata_row *row)
|
||||
{
|
||||
netsnmp_container_table_row_insert(request, (netsnmp_index *)row);
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_TABLE_TDATA_INSERT_ROW */
|
||||
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_TABLE_TDATA_REMOVE_ROW
|
||||
/** inserts a newly created tdata row into a request */
|
||||
NETSNMP_INLINE void
|
||||
netsnmp_remove_tdata_row(netsnmp_request_info *request,
|
||||
netsnmp_tdata_row *row)
|
||||
{
|
||||
netsnmp_container_table_row_remove(request, (netsnmp_index *)row);
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_TABLE_TDATA_REMOVE_ROW */
|
||||
|
||||
|
||||
/* ==================================
|
||||
*
|
||||
* Generic API: Row operations
|
||||
*
|
||||
* ================================== */
|
||||
|
||||
/** returns the (table-specific) entry data for a given row */
|
||||
void *
|
||||
netsnmp_tdata_row_entry( netsnmp_tdata_row *row )
|
||||
{
|
||||
if (row)
|
||||
return row->data;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/** returns the first row in the table */
|
||||
netsnmp_tdata_row *
|
||||
netsnmp_tdata_row_first(netsnmp_tdata *table)
|
||||
{
|
||||
return (netsnmp_tdata_row *)CONTAINER_FIRST( table->container );
|
||||
}
|
||||
|
||||
/** finds a row in the 'tdata' table given another row */
|
||||
netsnmp_tdata_row *
|
||||
netsnmp_tdata_row_get( netsnmp_tdata *table,
|
||||
netsnmp_tdata_row *row)
|
||||
{
|
||||
return (netsnmp_tdata_row*)CONTAINER_FIND( table->container, row );
|
||||
}
|
||||
|
||||
/** returns the next row in the table */
|
||||
netsnmp_tdata_row *
|
||||
netsnmp_tdata_row_next( netsnmp_tdata *table,
|
||||
netsnmp_tdata_row *row)
|
||||
{
|
||||
return (netsnmp_tdata_row *)CONTAINER_NEXT( table->container, row );
|
||||
}
|
||||
|
||||
/** finds a row in the 'tdata' table given the index values */
|
||||
netsnmp_tdata_row *
|
||||
netsnmp_tdata_row_get_byidx(netsnmp_tdata *table,
|
||||
netsnmp_variable_list *indexes)
|
||||
{
|
||||
oid searchfor[ MAX_OID_LEN];
|
||||
size_t searchfor_len = MAX_OID_LEN;
|
||||
|
||||
build_oid_noalloc(searchfor, MAX_OID_LEN, &searchfor_len, NULL, 0,
|
||||
indexes);
|
||||
return netsnmp_tdata_row_get_byoid(table, searchfor, searchfor_len);
|
||||
}
|
||||
|
||||
/** finds a row in the 'tdata' table given the index OID */
|
||||
netsnmp_tdata_row *
|
||||
netsnmp_tdata_row_get_byoid(netsnmp_tdata *table,
|
||||
oid * searchfor, size_t searchfor_len)
|
||||
{
|
||||
netsnmp_index index;
|
||||
if (!table)
|
||||
return NULL;
|
||||
|
||||
index.oids = searchfor;
|
||||
index.len = searchfor_len;
|
||||
return (netsnmp_tdata_row*)CONTAINER_FIND( table->container, &index );
|
||||
}
|
||||
|
||||
/** finds the lexically next row in the 'tdata' table
|
||||
given the index values */
|
||||
netsnmp_tdata_row *
|
||||
netsnmp_tdata_row_next_byidx(netsnmp_tdata *table,
|
||||
netsnmp_variable_list *indexes)
|
||||
{
|
||||
oid searchfor[ MAX_OID_LEN];
|
||||
size_t searchfor_len = MAX_OID_LEN;
|
||||
|
||||
build_oid_noalloc(searchfor, MAX_OID_LEN, &searchfor_len, NULL, 0,
|
||||
indexes);
|
||||
return netsnmp_tdata_row_next_byoid(table, searchfor, searchfor_len);
|
||||
}
|
||||
|
||||
/** finds the lexically next row in the 'tdata' table
|
||||
given the index OID */
|
||||
netsnmp_tdata_row *
|
||||
netsnmp_tdata_row_next_byoid(netsnmp_tdata *table,
|
||||
oid * searchfor, size_t searchfor_len)
|
||||
{
|
||||
netsnmp_index index;
|
||||
if (!table)
|
||||
return NULL;
|
||||
|
||||
index.oids = searchfor;
|
||||
index.len = searchfor_len;
|
||||
return (netsnmp_tdata_row*)CONTAINER_NEXT( table->container, &index );
|
||||
}
|
||||
|
||||
netsnmp_feature_child_of(tdata_row_count, table_tdata_all)
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_TDATA_ROW_COUNT
|
||||
int
|
||||
netsnmp_tdata_row_count(netsnmp_tdata *table)
|
||||
{
|
||||
if (!table)
|
||||
return 0;
|
||||
return CONTAINER_SIZE( table->container );
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_TDATA_ROW_COUNT */
|
||||
|
||||
/* ==================================
|
||||
*
|
||||
* Generic API: Index operations on a 'tdata' table
|
||||
*
|
||||
* ================================== */
|
||||
|
||||
|
||||
/** compare a row with the given index values */
|
||||
netsnmp_feature_child_of(tdata_compare_idx, table_tdata_all)
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_TDATA_COMPARE_IDX
|
||||
int
|
||||
netsnmp_tdata_compare_idx(netsnmp_tdata_row *row,
|
||||
netsnmp_variable_list *indexes)
|
||||
{
|
||||
oid searchfor[ MAX_OID_LEN];
|
||||
size_t searchfor_len = MAX_OID_LEN;
|
||||
|
||||
build_oid_noalloc(searchfor, MAX_OID_LEN, &searchfor_len, NULL, 0,
|
||||
indexes);
|
||||
return netsnmp_tdata_compare_oid(row, searchfor, searchfor_len);
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_TDATA_COMPARE_IDX */
|
||||
|
||||
/** compare a row with the given index OID */
|
||||
int
|
||||
netsnmp_tdata_compare_oid(netsnmp_tdata_row *row,
|
||||
oid * compareto, size_t compareto_len)
|
||||
{
|
||||
netsnmp_index *index = (netsnmp_index *)row;
|
||||
return snmp_oid_compare( index->oids, index->len,
|
||||
compareto, compareto_len);
|
||||
}
|
||||
|
||||
int
|
||||
netsnmp_tdata_compare_subtree_idx(netsnmp_tdata_row *row,
|
||||
netsnmp_variable_list *indexes)
|
||||
{
|
||||
oid searchfor[ MAX_OID_LEN];
|
||||
size_t searchfor_len = MAX_OID_LEN;
|
||||
|
||||
build_oid_noalloc(searchfor, MAX_OID_LEN, &searchfor_len, NULL, 0,
|
||||
indexes);
|
||||
return netsnmp_tdata_compare_subtree_oid(row, searchfor, searchfor_len);
|
||||
}
|
||||
|
||||
int
|
||||
netsnmp_tdata_compare_subtree_oid(netsnmp_tdata_row *row,
|
||||
oid * compareto, size_t compareto_len)
|
||||
{
|
||||
netsnmp_index *index = (netsnmp_index *)row;
|
||||
return snmp_oidtree_compare( index->oids, index->len,
|
||||
compareto, compareto_len);
|
||||
}
|
||||
#else /* NETSNMP_FEATURE_REMOVE_TABLE_TDATA */
|
||||
netsnmp_feature_unused(table_tdata);
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_TABLE_TDATA */
|
||||
|
||||
|
||||
/** @}
|
||||
*/
|
||||
@@ -1,661 +0,0 @@
|
||||
#include <net-snmp/net-snmp-config.h>
|
||||
#include <net-snmp/net-snmp-features.h>
|
||||
|
||||
#include <net-snmp/net-snmp-includes.h>
|
||||
#include <net-snmp/agent/net-snmp-agent-includes.h>
|
||||
|
||||
#include <net-snmp/agent/watcher.h>
|
||||
|
||||
#include <net-snmp/agent/instance.h>
|
||||
#include <net-snmp/agent/scalar.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#ifdef HAVE_DMALLOC_H
|
||||
static void free_wrapper(void * p)
|
||||
{
|
||||
free(p);
|
||||
}
|
||||
#else
|
||||
#define free_wrapper free
|
||||
#endif
|
||||
|
||||
netsnmp_feature_provide(watcher_all)
|
||||
netsnmp_feature_child_of(watcher_all, mib_helpers)
|
||||
netsnmp_feature_child_of(watcher_create_info6, watcher_all)
|
||||
netsnmp_feature_child_of(watcher_register_timestamp, watcher_all)
|
||||
netsnmp_feature_child_of(watcher_ulong_scalar, watcher_all)
|
||||
netsnmp_feature_child_of(watcher_read_only_ulong_scalar, watcher_all)
|
||||
netsnmp_feature_child_of(watcher_read_only_int_scalar, watcher_all)
|
||||
netsnmp_feature_child_of(watcher_long_scalar, watcher_all)
|
||||
netsnmp_feature_child_of(watcher_read_only_long_scalar, watcher_all)
|
||||
netsnmp_feature_child_of(watcher_int_scalar, watcher_all)
|
||||
netsnmp_feature_child_of(read_only_counter32_scalar, watcher_all)
|
||||
netsnmp_feature_child_of(watcher_spinlock, watcher_all)
|
||||
|
||||
/** @defgroup watcher watcher
|
||||
* Watch a specified variable and process it as an instance or scalar object
|
||||
* @ingroup leaf
|
||||
* @{
|
||||
*/
|
||||
netsnmp_mib_handler *
|
||||
netsnmp_get_watcher_handler(void)
|
||||
{
|
||||
netsnmp_mib_handler *ret = NULL;
|
||||
|
||||
ret = netsnmp_create_handler("watcher",
|
||||
netsnmp_watcher_helper_handler);
|
||||
if (ret) {
|
||||
ret->flags |= MIB_HANDLER_AUTO_NEXT;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
netsnmp_watcher_info *
|
||||
netsnmp_init_watcher_info6(netsnmp_watcher_info *winfo,
|
||||
void *data, size_t size, u_char type,
|
||||
int flags, size_t max_size, size_t* size_p)
|
||||
{
|
||||
winfo->data = data;
|
||||
winfo->data_size = size;
|
||||
winfo->max_size = max_size;
|
||||
winfo->type = type;
|
||||
winfo->flags = flags;
|
||||
winfo->data_size_p = size_p;
|
||||
return winfo;
|
||||
}
|
||||
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_WATCHER_CREATE_INFO6
|
||||
netsnmp_watcher_info *
|
||||
netsnmp_create_watcher_info6(void *data, size_t size, u_char type,
|
||||
int flags, size_t max_size, size_t* size_p)
|
||||
{
|
||||
netsnmp_watcher_info *winfo = SNMP_MALLOC_TYPEDEF(netsnmp_watcher_info);
|
||||
if (winfo)
|
||||
netsnmp_init_watcher_info6(winfo, data, size, type, flags, max_size,
|
||||
size_p);
|
||||
return winfo;
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_WATCHER_CREATE_INFO6 */
|
||||
|
||||
netsnmp_watcher_info *
|
||||
netsnmp_init_watcher_info(netsnmp_watcher_info *winfo,
|
||||
void *data, size_t size, u_char type, int flags)
|
||||
{
|
||||
return netsnmp_init_watcher_info6(winfo, data, size,
|
||||
type, (flags ? flags : WATCHER_FIXED_SIZE),
|
||||
size, /* Probably wrong for non-fixed
|
||||
* size data */
|
||||
NULL);
|
||||
}
|
||||
|
||||
netsnmp_watcher_info *
|
||||
netsnmp_create_watcher_info(void *data, size_t size, u_char type, int flags)
|
||||
{
|
||||
netsnmp_watcher_info *winfo = SNMP_MALLOC_TYPEDEF(netsnmp_watcher_info);
|
||||
if (winfo)
|
||||
netsnmp_init_watcher_info(winfo, data, size, type, flags);
|
||||
return winfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a watched scalar. The caller remains the owner of watchinfo.
|
||||
*
|
||||
* @see netsnmp_register_watched_instance2()
|
||||
*/
|
||||
int
|
||||
netsnmp_register_watched_instance(netsnmp_handler_registration *reginfo,
|
||||
netsnmp_watcher_info *watchinfo)
|
||||
{
|
||||
netsnmp_mib_handler *whandler;
|
||||
|
||||
whandler = netsnmp_get_watcher_handler();
|
||||
whandler->myvoid = (void *)watchinfo;
|
||||
|
||||
netsnmp_inject_handler(reginfo, whandler);
|
||||
return netsnmp_register_instance(reginfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a watched scalar. Ownership of watchinfo is transferred to the handler.
|
||||
*
|
||||
* @see netsnmp_register_watched_instance()
|
||||
*/
|
||||
int
|
||||
netsnmp_register_watched_instance2(netsnmp_handler_registration *reginfo,
|
||||
netsnmp_watcher_info *watchinfo)
|
||||
{
|
||||
netsnmp_mib_handler *whandler;
|
||||
|
||||
whandler = netsnmp_get_watcher_handler();
|
||||
whandler->myvoid = (void *)watchinfo;
|
||||
netsnmp_owns_watcher_info(whandler);
|
||||
|
||||
netsnmp_inject_handler(reginfo, whandler);
|
||||
return netsnmp_register_instance(reginfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a watched scalar. The caller remains the owner of watchinfo.
|
||||
*
|
||||
* @see netsnmp_register_watched_scalar2()
|
||||
*/
|
||||
int
|
||||
netsnmp_register_watched_scalar(netsnmp_handler_registration *reginfo,
|
||||
netsnmp_watcher_info *watchinfo)
|
||||
{
|
||||
netsnmp_mib_handler *whandler;
|
||||
|
||||
whandler = netsnmp_get_watcher_handler();
|
||||
whandler->myvoid = (void *)watchinfo;
|
||||
|
||||
netsnmp_inject_handler(reginfo, whandler);
|
||||
return netsnmp_register_scalar(reginfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a watched scalar. Ownership of watchinfo is transferred to the handler.
|
||||
*
|
||||
* @see netsnmp_register_watched_scalar()
|
||||
*/
|
||||
int
|
||||
netsnmp_register_watched_scalar2(netsnmp_handler_registration *reginfo,
|
||||
netsnmp_watcher_info *watchinfo)
|
||||
{
|
||||
netsnmp_mib_handler *whandler;
|
||||
|
||||
whandler = netsnmp_get_watcher_handler();
|
||||
whandler->myvoid = (void *)watchinfo;
|
||||
netsnmp_owns_watcher_info(whandler);
|
||||
|
||||
netsnmp_inject_handler(reginfo, whandler);
|
||||
return netsnmp_register_scalar(reginfo);
|
||||
}
|
||||
|
||||
void
|
||||
netsnmp_owns_watcher_info(netsnmp_mib_handler *handler)
|
||||
{
|
||||
netsnmp_assert(handler);
|
||||
netsnmp_assert(handler->myvoid);
|
||||
handler->data_clone = (void *(*)(void *))netsnmp_clone_watcher_info;
|
||||
handler->data_free = free;
|
||||
}
|
||||
|
||||
/** @cond */
|
||||
|
||||
NETSNMP_STATIC_INLINE size_t
|
||||
get_data_size(const netsnmp_watcher_info* winfo)
|
||||
{
|
||||
if (winfo->flags & WATCHER_SIZE_STRLEN)
|
||||
return strlen((const char*)winfo->data);
|
||||
else {
|
||||
size_t res;
|
||||
if (winfo->flags & WATCHER_SIZE_IS_PTR)
|
||||
res = *winfo->data_size_p;
|
||||
else
|
||||
res = winfo->data_size;
|
||||
if (winfo->flags & WATCHER_SIZE_UNIT_OIDS)
|
||||
res *= sizeof(oid);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
NETSNMP_STATIC_INLINE void
|
||||
set_data(netsnmp_watcher_info* winfo, void* data, size_t size)
|
||||
{
|
||||
memcpy(winfo->data, data, size);
|
||||
if (winfo->flags & WATCHER_SIZE_STRLEN)
|
||||
((char*)winfo->data)[size] = '\0';
|
||||
else {
|
||||
if (winfo->flags & WATCHER_SIZE_UNIT_OIDS)
|
||||
size /= sizeof(oid);
|
||||
if (winfo->flags & WATCHER_SIZE_IS_PTR)
|
||||
*winfo->data_size_p = size;
|
||||
else
|
||||
winfo->data_size = size;
|
||||
}
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
size_t size;
|
||||
char data[1];
|
||||
} netsnmp_watcher_cache;
|
||||
|
||||
NETSNMP_STATIC_INLINE netsnmp_watcher_cache*
|
||||
netsnmp_watcher_cache_create(const void* data, size_t size)
|
||||
{
|
||||
netsnmp_watcher_cache *res = (netsnmp_watcher_cache*)
|
||||
malloc(sizeof(netsnmp_watcher_cache) + size - 1);
|
||||
if (res) {
|
||||
res->size = size;
|
||||
memcpy(res->data, data, size);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/** @endcond */
|
||||
|
||||
int
|
||||
netsnmp_watcher_helper_handler(netsnmp_mib_handler *handler,
|
||||
netsnmp_handler_registration *reginfo,
|
||||
netsnmp_agent_request_info *reqinfo,
|
||||
netsnmp_request_info *requests)
|
||||
{
|
||||
netsnmp_watcher_info *winfo = (netsnmp_watcher_info *) handler->myvoid;
|
||||
netsnmp_watcher_cache *old_data;
|
||||
|
||||
DEBUGMSGTL(("helper:watcher", "Got request: %d\n", reqinfo->mode));
|
||||
DEBUGMSGTL(( "helper:watcher", " oid:"));
|
||||
DEBUGMSGOID(("helper:watcher", requests->requestvb->name,
|
||||
requests->requestvb->name_length));
|
||||
DEBUGMSG(( "helper:watcher", "\n"));
|
||||
|
||||
switch (reqinfo->mode) {
|
||||
/*
|
||||
* data requests
|
||||
*/
|
||||
case MODE_GET:
|
||||
snmp_set_var_typed_value(requests->requestvb,
|
||||
winfo->type,
|
||||
winfo->data,
|
||||
get_data_size(winfo));
|
||||
break;
|
||||
|
||||
/*
|
||||
* SET requests. Should only get here if registered RWRITE
|
||||
*/
|
||||
#ifndef NETSNMP_NO_WRITE_SUPPORT
|
||||
case MODE_SET_RESERVE1:
|
||||
if (requests->requestvb->type != winfo->type) {
|
||||
netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_WRONGTYPE);
|
||||
handler->flags |= MIB_HANDLER_AUTO_NEXT_OVERRIDE_ONCE;
|
||||
} else if (((winfo->flags & WATCHER_MAX_SIZE) &&
|
||||
requests->requestvb->val_len > winfo->max_size) ||
|
||||
((winfo->flags & WATCHER_FIXED_SIZE) &&
|
||||
requests->requestvb->val_len != get_data_size(winfo))) {
|
||||
netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_WRONGLENGTH);
|
||||
handler->flags |= MIB_HANDLER_AUTO_NEXT_OVERRIDE_ONCE;
|
||||
} else if ((winfo->flags & WATCHER_SIZE_STRLEN) &&
|
||||
(memchr(requests->requestvb->val.string, '\0',
|
||||
requests->requestvb->val_len) != NULL)) {
|
||||
netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_WRONGVALUE);
|
||||
handler->flags |= MIB_HANDLER_AUTO_NEXT_OVERRIDE_ONCE;
|
||||
}
|
||||
break;
|
||||
|
||||
case MODE_SET_RESERVE2:
|
||||
/*
|
||||
* store old info for undo later
|
||||
*/
|
||||
old_data =
|
||||
netsnmp_watcher_cache_create(winfo->data, get_data_size(winfo));
|
||||
if (old_data == NULL) {
|
||||
netsnmp_set_request_error(reqinfo, requests,
|
||||
SNMP_ERR_RESOURCEUNAVAILABLE);
|
||||
handler->flags |= MIB_HANDLER_AUTO_NEXT_OVERRIDE_ONCE;
|
||||
} else
|
||||
netsnmp_request_add_list_data(requests,
|
||||
netsnmp_create_data_list
|
||||
("watcher", old_data, &free_wrapper));
|
||||
break;
|
||||
|
||||
case MODE_SET_FREE:
|
||||
/*
|
||||
* nothing to do
|
||||
*/
|
||||
break;
|
||||
|
||||
case MODE_SET_ACTION:
|
||||
/*
|
||||
* update current
|
||||
*/
|
||||
set_data(winfo, (void *)requests->requestvb->val.string,
|
||||
requests->requestvb->val_len);
|
||||
break;
|
||||
|
||||
case MODE_SET_UNDO:
|
||||
old_data = (netsnmp_watcher_cache*)netsnmp_request_get_list_data(requests, "watcher");
|
||||
set_data(winfo, old_data->data, old_data->size);
|
||||
break;
|
||||
|
||||
case MODE_SET_COMMIT:
|
||||
break;
|
||||
#endif /* NETSNMP_NO_WRITE_SUPPORT */
|
||||
|
||||
default:
|
||||
snmp_log(LOG_ERR, "watcher handler called with an unknown mode: %d\n",
|
||||
reqinfo->mode);
|
||||
return SNMP_ERR_GENERR;
|
||||
|
||||
}
|
||||
|
||||
/* next handler called automatically - 'AUTO_NEXT' */
|
||||
return SNMP_ERR_NOERROR;
|
||||
}
|
||||
|
||||
|
||||
/***************************
|
||||
*
|
||||
* A specialised form of the above, reporting
|
||||
* the sysUpTime indicated by a given timestamp
|
||||
*
|
||||
***************************/
|
||||
|
||||
netsnmp_mib_handler *
|
||||
netsnmp_get_watched_timestamp_handler(void)
|
||||
{
|
||||
netsnmp_mib_handler *ret = NULL;
|
||||
|
||||
ret = netsnmp_create_handler("watcher-timestamp",
|
||||
netsnmp_watched_timestamp_handler);
|
||||
if (ret) {
|
||||
ret->flags |= MIB_HANDLER_AUTO_NEXT;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
netsnmp_watched_timestamp_register(netsnmp_mib_handler *whandler,
|
||||
netsnmp_handler_registration *reginfo,
|
||||
marker_t timestamp)
|
||||
{
|
||||
whandler->myvoid = (void *)timestamp;
|
||||
netsnmp_inject_handler(reginfo, whandler);
|
||||
return netsnmp_register_scalar(reginfo); /* XXX - or instance? */
|
||||
}
|
||||
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_WATCHER_REGISTER_TIMESTAMP
|
||||
int
|
||||
netsnmp_register_watched_timestamp(netsnmp_handler_registration *reginfo,
|
||||
marker_t timestamp)
|
||||
{
|
||||
netsnmp_mib_handler *whandler;
|
||||
|
||||
whandler = netsnmp_get_watched_timestamp_handler();
|
||||
|
||||
return netsnmp_watched_timestamp_register(whandler, reginfo, timestamp);
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_WATCHER_REGISTER_TIMESTAMP */
|
||||
|
||||
|
||||
int
|
||||
netsnmp_watched_timestamp_handler(netsnmp_mib_handler *handler,
|
||||
netsnmp_handler_registration *reginfo,
|
||||
netsnmp_agent_request_info *reqinfo,
|
||||
netsnmp_request_info *requests)
|
||||
{
|
||||
marker_t timestamp = (marker_t) handler->myvoid;
|
||||
long uptime;
|
||||
|
||||
DEBUGMSGTL(("helper:watcher:timestamp",
|
||||
"Got request: %d\n", reqinfo->mode));
|
||||
DEBUGMSGTL(( "helper:watcher:timestamp", " oid:"));
|
||||
DEBUGMSGOID(("helper:watcher:timestamp", requests->requestvb->name,
|
||||
requests->requestvb->name_length));
|
||||
DEBUGMSG(( "helper:watcher:timestamp", "\n"));
|
||||
|
||||
switch (reqinfo->mode) {
|
||||
/*
|
||||
* data requests
|
||||
*/
|
||||
case MODE_GET:
|
||||
if (handler->flags & NETSNMP_WATCHER_DIRECT)
|
||||
uptime = * (long*)timestamp;
|
||||
else
|
||||
uptime = netsnmp_marker_uptime( timestamp );
|
||||
snmp_set_var_typed_value(requests->requestvb,
|
||||
ASN_TIMETICKS,
|
||||
(u_char *) &uptime,
|
||||
sizeof(uptime));
|
||||
break;
|
||||
|
||||
/*
|
||||
* Timestamps are inherently Read-Only,
|
||||
* so don't need to support SET requests.
|
||||
*/
|
||||
#ifndef NETSNMP_NO_WRITE_SUPPORT
|
||||
case MODE_SET_RESERVE1:
|
||||
netsnmp_set_request_error(reqinfo, requests,
|
||||
SNMP_ERR_NOTWRITABLE);
|
||||
handler->flags |= MIB_HANDLER_AUTO_NEXT_OVERRIDE_ONCE;
|
||||
return SNMP_ERR_NOTWRITABLE;
|
||||
#endif /* NETSNMP_NO_WRITE_SUPPORT */
|
||||
}
|
||||
|
||||
/* next handler called automatically - 'AUTO_NEXT' */
|
||||
return SNMP_ERR_NOERROR;
|
||||
}
|
||||
|
||||
/***************************
|
||||
*
|
||||
* Another specialised form of the above,
|
||||
* implementing a 'TestAndIncr' spinlock
|
||||
*
|
||||
***************************/
|
||||
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_WATCHER_SPINLOCK
|
||||
|
||||
netsnmp_mib_handler *
|
||||
netsnmp_get_watched_spinlock_handler(void)
|
||||
{
|
||||
netsnmp_mib_handler *ret = NULL;
|
||||
|
||||
ret = netsnmp_create_handler("watcher-spinlock",
|
||||
netsnmp_watched_spinlock_handler);
|
||||
if (ret) {
|
||||
ret->flags |= MIB_HANDLER_AUTO_NEXT;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
netsnmp_register_watched_spinlock(netsnmp_handler_registration *reginfo,
|
||||
int *spinlock)
|
||||
{
|
||||
netsnmp_mib_handler *whandler;
|
||||
netsnmp_watcher_info *winfo;
|
||||
|
||||
whandler = netsnmp_get_watched_spinlock_handler();
|
||||
whandler->myvoid = (void *)spinlock;
|
||||
winfo = netsnmp_create_watcher_info((void *)spinlock,
|
||||
sizeof(int), ASN_INTEGER, WATCHER_FIXED_SIZE);
|
||||
netsnmp_inject_handler(reginfo, whandler);
|
||||
return netsnmp_register_watched_scalar2(reginfo, winfo);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
netsnmp_watched_spinlock_handler(netsnmp_mib_handler *handler,
|
||||
netsnmp_handler_registration *reginfo,
|
||||
netsnmp_agent_request_info *reqinfo,
|
||||
netsnmp_request_info *requests)
|
||||
{
|
||||
int *spinlock = (int *) handler->myvoid;
|
||||
netsnmp_request_info *request;
|
||||
|
||||
DEBUGMSGTL(("helper:watcher:spinlock",
|
||||
"Got request: %d\n", reqinfo->mode));
|
||||
DEBUGMSGTL(( "helper:watcher:spinlock", " oid:"));
|
||||
DEBUGMSGOID(("helper:watcher:spinlock", requests->requestvb->name,
|
||||
requests->requestvb->name_length));
|
||||
DEBUGMSG(( "helper:watcher:spinlock", "\n"));
|
||||
|
||||
switch (reqinfo->mode) {
|
||||
/*
|
||||
* Ensure the assigned value matches the current one
|
||||
*/
|
||||
#ifndef NETSNMP_NO_WRITE_SUPPORT
|
||||
case MODE_SET_RESERVE1:
|
||||
for (request=requests; request; request=request->next) {
|
||||
if (request->processed)
|
||||
continue;
|
||||
|
||||
if (*request->requestvb->val.integer != *spinlock) {
|
||||
netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_WRONGVALUE);
|
||||
handler->flags |= MIB_HANDLER_AUTO_NEXT_OVERRIDE_ONCE;
|
||||
return SNMP_ERR_WRONGVALUE;
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
/*
|
||||
* Everything else worked, so increment the spinlock
|
||||
*/
|
||||
case MODE_SET_COMMIT:
|
||||
(*spinlock)++;
|
||||
break;
|
||||
#endif /* NETSNMP_NO_WRITE_SUPPORT */
|
||||
}
|
||||
|
||||
/* next handler called automatically - 'AUTO_NEXT' */
|
||||
return SNMP_ERR_NOERROR;
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_WATCHER_SPINLOCK */
|
||||
|
||||
/***************************
|
||||
*
|
||||
* Convenience registration routines - modelled on
|
||||
* the equivalent netsnmp_register_*_instance() calls
|
||||
*
|
||||
***************************/
|
||||
|
||||
netsnmp_watcher_info *
|
||||
netsnmp_clone_watcher_info(netsnmp_watcher_info *winfo)
|
||||
{
|
||||
netsnmp_watcher_info *copy = malloc(sizeof(*copy));
|
||||
if (copy)
|
||||
*copy = *winfo;
|
||||
return copy;
|
||||
}
|
||||
|
||||
static int
|
||||
register_scalar_watcher(const char* name,
|
||||
const oid* reg_oid, size_t reg_oid_len,
|
||||
void *data, size_t size, u_char type,
|
||||
Netsnmp_Node_Handler * subhandler, int mode)
|
||||
{
|
||||
netsnmp_handler_registration *reginfo = NULL;
|
||||
netsnmp_mib_handler *whandler = NULL;
|
||||
netsnmp_watcher_info* watchinfo =
|
||||
netsnmp_create_watcher_info(data, size, type, WATCHER_FIXED_SIZE);
|
||||
if (watchinfo)
|
||||
whandler = netsnmp_get_watcher_handler();
|
||||
if (watchinfo && whandler) {
|
||||
whandler->myvoid = watchinfo;
|
||||
netsnmp_owns_watcher_info(whandler);
|
||||
reginfo =
|
||||
netsnmp_create_handler_registration(
|
||||
name, subhandler, reg_oid, reg_oid_len, mode);
|
||||
}
|
||||
if (watchinfo && whandler && reginfo) {
|
||||
netsnmp_inject_handler(reginfo, whandler);
|
||||
return netsnmp_register_scalar(reginfo);
|
||||
}
|
||||
if (whandler)
|
||||
netsnmp_handler_free(whandler);
|
||||
else if (watchinfo)
|
||||
free(watchinfo);
|
||||
return SNMP_ERR_RESOURCEUNAVAILABLE;
|
||||
}
|
||||
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_WATCHER_ULONG_SCALAR
|
||||
int
|
||||
netsnmp_register_ulong_scalar(const char *name,
|
||||
const oid * reg_oid, size_t reg_oid_len,
|
||||
u_long * it,
|
||||
Netsnmp_Node_Handler * subhandler)
|
||||
{
|
||||
return register_scalar_watcher(
|
||||
name, reg_oid, reg_oid_len,
|
||||
(void *)it, sizeof( u_long ),
|
||||
ASN_UNSIGNED, subhandler, HANDLER_CAN_RWRITE);
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_WATCHER_ULONG_SCALAR */
|
||||
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_WATCHER_READ_ONLY_ULONG_SCALAR
|
||||
int
|
||||
netsnmp_register_read_only_ulong_scalar(const char *name,
|
||||
const oid * reg_oid, size_t reg_oid_len,
|
||||
u_long * it,
|
||||
Netsnmp_Node_Handler * subhandler)
|
||||
{
|
||||
return register_scalar_watcher(
|
||||
name, reg_oid, reg_oid_len,
|
||||
(void *)it, sizeof( u_long ),
|
||||
ASN_UNSIGNED, subhandler, HANDLER_CAN_RONLY);
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_WATCHER_READ_ONLY_ULONG_SCALAR */
|
||||
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_WATCHER_LONG_SCALAR
|
||||
int
|
||||
netsnmp_register_long_scalar(const char *name,
|
||||
const oid * reg_oid, size_t reg_oid_len,
|
||||
long * it,
|
||||
Netsnmp_Node_Handler * subhandler)
|
||||
{
|
||||
return register_scalar_watcher(
|
||||
name, reg_oid, reg_oid_len,
|
||||
(void *)it, sizeof( long ),
|
||||
ASN_INTEGER, subhandler, HANDLER_CAN_RWRITE);
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_WATCHER_LONG_SCALAR */
|
||||
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_WATCHER_READ_ONLY_LONG_SCALAR
|
||||
int
|
||||
netsnmp_register_read_only_long_scalar(const char *name,
|
||||
const oid * reg_oid, size_t reg_oid_len,
|
||||
long * it,
|
||||
Netsnmp_Node_Handler * subhandler)
|
||||
{
|
||||
return register_scalar_watcher(
|
||||
name, reg_oid, reg_oid_len,
|
||||
(void *)it, sizeof( long ),
|
||||
ASN_INTEGER, subhandler, HANDLER_CAN_RONLY);
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_WATCHER_READ_ONLY_LONG_SCALAR */
|
||||
|
||||
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_WATCHER_INT_SCALAR
|
||||
int
|
||||
netsnmp_register_int_scalar(const char *name,
|
||||
const oid * reg_oid, size_t reg_oid_len,
|
||||
int * it,
|
||||
Netsnmp_Node_Handler * subhandler)
|
||||
{
|
||||
return register_scalar_watcher(
|
||||
name, reg_oid, reg_oid_len,
|
||||
(void *)it, sizeof( int ),
|
||||
ASN_INTEGER, subhandler, HANDLER_CAN_RWRITE);
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_WATCHER_INT_SCALAR */
|
||||
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_WATCHER_READ_ONLY_INT_SCALAR
|
||||
int
|
||||
netsnmp_register_read_only_int_scalar(const char *name,
|
||||
const oid * reg_oid, size_t reg_oid_len,
|
||||
int * it,
|
||||
Netsnmp_Node_Handler * subhandler)
|
||||
{
|
||||
return register_scalar_watcher(
|
||||
name, reg_oid, reg_oid_len,
|
||||
(void *)it, sizeof( int ),
|
||||
ASN_INTEGER, subhandler, HANDLER_CAN_RONLY);
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_WATCHER_READ_ONLY_INT_SCALAR */
|
||||
|
||||
#ifndef NETSNMP_FEATURE_REMOVE_READ_ONLY_COUNTER32_SCALAR
|
||||
int
|
||||
netsnmp_register_read_only_counter32_scalar(const char *name,
|
||||
const oid * reg_oid, size_t reg_oid_len,
|
||||
u_long * it,
|
||||
Netsnmp_Node_Handler * subhandler)
|
||||
{
|
||||
return register_scalar_watcher(
|
||||
name, reg_oid, reg_oid_len,
|
||||
(void *)it, sizeof( u_long ),
|
||||
ASN_COUNTER, subhandler, HANDLER_CAN_RONLY);
|
||||
}
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_READ_ONLY_COUNTER32_SCALAR */
|
||||
/** @} */
|
||||
|
||||
@@ -1,266 +0,0 @@
|
||||
/***********************************************************************
|
||||
Net-SNMP - Simple Network Management Protocol agent library.
|
||||
***********************************************************************/
|
||||
/** @file kernel.c
|
||||
* Net-SNMP Kernel Data Access Library.
|
||||
* Provides access to kernel virtual memory for systems that
|
||||
* support it.
|
||||
* @author See README file for a list of contributors
|
||||
*/
|
||||
/* Copyrights:
|
||||
* Copyright holders are listed in README file.
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted. License terms are specified
|
||||
* in COPYING file distributed with the Net-SNMP package.
|
||||
*/
|
||||
/***********************************************************************/
|
||||
|
||||
#include <net-snmp/net-snmp-config.h>
|
||||
|
||||
#ifdef NETSNMP_CAN_USE_NLIST
|
||||
|
||||
#include <sys/types.h>
|
||||
#if HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#if HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
#if HAVE_FCNTL_H
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#if HAVE_NETINET_IN_H
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
#if HAVE_KVM_H
|
||||
#include <kvm.h>
|
||||
#endif
|
||||
|
||||
#include <net-snmp/net-snmp-includes.h>
|
||||
|
||||
#include "kernel.h"
|
||||
#include <net-snmp/agent/ds_agent.h>
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
|
||||
#if HAVE_KVM_H
|
||||
kvm_t *kd = NULL;
|
||||
|
||||
/**
|
||||
* Initialize the support for accessing kernel virtual memory.
|
||||
*
|
||||
* @return TRUE upon success; FALSE upon failure.
|
||||
*/
|
||||
int
|
||||
init_kmem(const char *file)
|
||||
{
|
||||
int res = TRUE;
|
||||
|
||||
#if HAVE_KVM_OPENFILES
|
||||
char err[4096];
|
||||
|
||||
kd = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, err);
|
||||
if (!kd)
|
||||
#ifdef KVM_NO_FILES
|
||||
kd = kvm_openfiles(NULL, NULL, NULL, KVM_NO_FILES, err);
|
||||
#else
|
||||
kd = kvm_openfiles(NULL, "/dev/null", NULL, O_RDONLY, err);
|
||||
#endif
|
||||
if (!kd && !netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
|
||||
NETSNMP_DS_AGENT_NO_ROOT_ACCESS)) {
|
||||
snmp_log(LOG_CRIT, "init_kmem: kvm_openfiles failed: %s\n", err);
|
||||
res = FALSE;
|
||||
}
|
||||
#else
|
||||
kd = kvm_open(NULL, NULL, NULL, O_RDONLY, NULL);
|
||||
if (!kd && !netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
|
||||
NETSNMP_DS_AGENT_NO_ROOT_ACCESS)) {
|
||||
snmp_log(LOG_CRIT, "init_kmem: kvm_open failed: %s\n",
|
||||
strerror(errno));
|
||||
res = FALSE;
|
||||
}
|
||||
#endif /* HAVE_KVM_OPENFILES */
|
||||
return res;
|
||||
}
|
||||
|
||||
/** Reads kernel memory.
|
||||
* Seeks to the specified location in kmem, then
|
||||
* does a read of given amount ob bytes into target buffer.
|
||||
*
|
||||
* @param off The location to seek.
|
||||
*
|
||||
* @param target The target buffer to read into.
|
||||
*
|
||||
* @param siz Number of bytes to read.
|
||||
*
|
||||
* @return gives 1 on success and 0 on failure.
|
||||
*/
|
||||
int
|
||||
klookup(unsigned long off, void *target, size_t siz)
|
||||
{
|
||||
int result;
|
||||
|
||||
if (kd == NULL)
|
||||
return 0;
|
||||
result = kvm_read(kd, off, target, siz);
|
||||
if (result != siz) {
|
||||
#if HAVE_KVM_OPENFILES
|
||||
snmp_log(LOG_ERR, "kvm_read(*, %lx, %p, %x) = %d: %s\n", off,
|
||||
target, (unsigned) siz, result, kvm_geterr(kd));
|
||||
#else
|
||||
snmp_log(LOG_ERR, "kvm_read(*, %lx, %p, %d) = %d: ", off, target,
|
||||
(unsigned) siz, result);
|
||||
snmp_log_perror("klookup");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/** Closes the kernel memory support.
|
||||
*/
|
||||
void
|
||||
free_kmem(void)
|
||||
{
|
||||
if (kd != NULL)
|
||||
{
|
||||
kvm_close(kd);
|
||||
kd = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#else /* HAVE_KVM_H */
|
||||
|
||||
static off_t klseek(off_t);
|
||||
static int klread(char *, int);
|
||||
int swap = -1, mem = -1, kmem = -1;
|
||||
|
||||
/**
|
||||
* Initialize the support for accessing kernel virtual memory.
|
||||
*
|
||||
* @return TRUE upon success; FALSE upon failure.
|
||||
*/
|
||||
int
|
||||
init_kmem(const char *file)
|
||||
{
|
||||
const int no_root_access = netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
|
||||
NETSNMP_DS_AGENT_NO_ROOT_ACCESS);
|
||||
int res = TRUE;
|
||||
|
||||
kmem = open(file, O_RDONLY);
|
||||
if (kmem < 0 && !no_root_access) {
|
||||
snmp_log_perror(file);
|
||||
res = FALSE;
|
||||
}
|
||||
if (kmem >= 0)
|
||||
fcntl(kmem, F_SETFD, 1/*FD_CLOEXEC*/);
|
||||
mem = open("/dev/mem", O_RDONLY);
|
||||
if (mem < 0 && !no_root_access) {
|
||||
snmp_log_perror("/dev/mem");
|
||||
res = FALSE;
|
||||
}
|
||||
if (mem >= 0)
|
||||
fcntl(mem, F_SETFD, 1/*FD_CLOEXEC*/);
|
||||
#ifdef DMEM_LOC
|
||||
swap = open(DMEM_LOC, O_RDONLY);
|
||||
if (swap < 0 && !no_root_access) {
|
||||
snmp_log_perror(DMEM_LOC);
|
||||
res = FALSE;
|
||||
}
|
||||
if (swap >= 0)
|
||||
fcntl(swap, F_SETFD, 1/*FD_CLOEXEC*/);
|
||||
#endif
|
||||
return res;
|
||||
}
|
||||
|
||||
/** @private
|
||||
* Seek into the kernel for a value.
|
||||
*/
|
||||
static off_t
|
||||
klseek(off_t base)
|
||||
{
|
||||
return (lseek(kmem, (off_t) base, SEEK_SET));
|
||||
}
|
||||
|
||||
/** @private
|
||||
* Read from the kernel.
|
||||
*/
|
||||
static int
|
||||
klread(char *buf, int buflen)
|
||||
{
|
||||
return (read(kmem, buf, buflen));
|
||||
}
|
||||
|
||||
/** Reads kernel memory.
|
||||
* Seeks to the specified location in kmem, then
|
||||
* does a read of given amount ob bytes into target buffer.
|
||||
*
|
||||
* @param off The location to seek.
|
||||
*
|
||||
* @param target The target buffer to read into.
|
||||
*
|
||||
* @param siz Number of bytes to read.
|
||||
*
|
||||
* @return gives 1 on success and 0 on failure.
|
||||
*/
|
||||
int
|
||||
klookup(unsigned long off, void *target, size_t siz)
|
||||
{
|
||||
long retsiz;
|
||||
|
||||
if (kmem < 0)
|
||||
return 0;
|
||||
|
||||
if ((retsiz = klseek((off_t) off)) != off) {
|
||||
snmp_log(LOG_ERR, "klookup(%lx, %p, %d): ", off, target, (int) siz);
|
||||
snmp_log_perror("klseek");
|
||||
return (0);
|
||||
}
|
||||
if ((retsiz = klread(target, siz)) != siz) {
|
||||
if (snmp_get_do_debugging()) {
|
||||
/*
|
||||
* these happen too often on too many architectures to print them
|
||||
* unless we're in debugging mode. People get very full log files.
|
||||
*/
|
||||
snmp_log(LOG_ERR, "klookup(%lx, %p, %d): ", off, target, (int) siz);
|
||||
snmp_log_perror("klread");
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
DEBUGMSGTL(("verbose:kernel:klookup", "klookup(%lx, %p, %d) succeeded",
|
||||
off, target, (int) siz));
|
||||
return (1);
|
||||
}
|
||||
|
||||
/** Closes the kernel memory support.
|
||||
*/
|
||||
void
|
||||
free_kmem(void)
|
||||
{
|
||||
if (swap >= 0) {
|
||||
close(swap);
|
||||
swap = -1;
|
||||
}
|
||||
if (mem >= 0) {
|
||||
close(mem);
|
||||
mem = -1;
|
||||
}
|
||||
if (kmem >= 0) {
|
||||
close(kmem);
|
||||
kmem = -1;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* HAVE_KVM_H */
|
||||
|
||||
#else
|
||||
int unused; /* Suppress "empty translation unit" warning */
|
||||
#endif /* NETSNMP_CAN_USE_NLIST */
|
||||
@@ -1,31 +0,0 @@
|
||||
/***********************************************************************
|
||||
Net-SNMP - Simple Network Management Protocol agent library.
|
||||
***********************************************************************/
|
||||
/** @file kernel.h
|
||||
* Net-SNMP Kernel Data Access Library - header.
|
||||
* Provides access to kernel virtual memory for systems that
|
||||
* support it.
|
||||
* @author See README file for a list of contributors
|
||||
*/
|
||||
/* Copyrights:
|
||||
* Copyright holders are listed in README file.
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted. License terms are specified
|
||||
* in COPYING file distributed with the Net-SNMP package.
|
||||
*/
|
||||
/***********************************************************************/
|
||||
|
||||
#ifdef NETSNMP_CAN_USE_NLIST
|
||||
extern int init_kmem(const char *);
|
||||
extern int klookup(unsigned long, void *, size_t);
|
||||
extern void free_kmem(void);
|
||||
#define NETSNMP_KLOOKUP(x,y,z) klookup((unsigned long) x,y,z)
|
||||
#else
|
||||
#define NETSNMP_KLOOKUP(x,y,z) (0)
|
||||
#endif
|
||||
|
||||
#if HAVE_KVM_H
|
||||
#include <kvm.h>
|
||||
extern kvm_t *kd;
|
||||
#endif
|
||||
/***********************************************************************/
|
||||
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* m2m.h
|
||||
*/
|
||||
|
||||
struct get_req_state {
|
||||
int type;
|
||||
void *info;
|
||||
};
|
||||
|
||||
/*
|
||||
* values for type field in get_req_state
|
||||
*/
|
||||
#define ALARM_GET_REQ 1
|
||||
#define EVENT_GET_REQ 2
|
||||
|
||||
/*
|
||||
* the following define is used to document a routine or variable which
|
||||
* ** is not static to a module.
|
||||
*/
|
||||
#define Export
|
||||
|
||||
/*
|
||||
* values for EntryStatus
|
||||
*/
|
||||
#define ENTRY_ACTIVE 1
|
||||
#define ENTRY_NOTINSERVICE 2
|
||||
#define ENTRY_NOTREADY 3
|
||||
#define ENTRY_CREATEANDGO 4
|
||||
#define ENTRY_CREATEANDWAIT 5
|
||||
#define ENTRY_DESTROY 6
|
||||
|
||||
/*
|
||||
* maximum length for an OwnerString variable
|
||||
*/
|
||||
#define MAX_OWNER_STR_LEN 128
|
||||
|
||||
/*
|
||||
* maximum length for a description field
|
||||
*/
|
||||
#define MAX_DESCRIPTION_LEN 128
|
||||
|
||||
/*
|
||||
* defines for noting whether the incoming packet is unicast, broadcast,
|
||||
* ** or multicast
|
||||
*/
|
||||
#define PKT_UNICAST 0
|
||||
#define PKT_BROADCAST 1
|
||||
#define PKT_MULTICAST 2
|
||||
|
||||
/*
|
||||
* macro to compare two ethernet addresses. addr1 is a pointer to a
|
||||
* ** struct ether_addr; addr2 is just a struct ether_addr.
|
||||
*/
|
||||
#define sameEtherAddr(addr1, addr2) \
|
||||
((*((short *)((addr1)->ether_addr_octet)) == \
|
||||
*((short *)((addr2).ether_addr_octet))) &&\
|
||||
(*((short *)(((addr1)->ether_addr_octet) + 2)) == \
|
||||
*((short *)((((addr2).ether_addr_octet) + 2)))) &&\
|
||||
(*((short *)(((addr1)->ether_addr_octet) + 4)) == \
|
||||
*((short *)((((addr2).ether_addr_octet) + 4)))))
|
||||
@@ -1,87 +0,0 @@
|
||||
/*
|
||||
* wrapper to call all the mib module initialization functions
|
||||
*/
|
||||
|
||||
#include <net-snmp/agent/mib_module_config.h>
|
||||
#include <net-snmp/net-snmp-config.h>
|
||||
#if HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#else
|
||||
#include <strings.h>
|
||||
#endif
|
||||
#if HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#if TIME_WITH_SYS_TIME
|
||||
# include <sys/time.h>
|
||||
# include <time.h>
|
||||
#else
|
||||
# if HAVE_SYS_TIME_H
|
||||
# include <sys/time.h>
|
||||
# else
|
||||
# include <time.h>
|
||||
# endif
|
||||
#endif
|
||||
#if HAVE_NETINET_IN_H
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
|
||||
#include <net-snmp/net-snmp-includes.h>
|
||||
#include <net-snmp/agent/net-snmp-agent-includes.h>
|
||||
#include "m2m.h"
|
||||
#ifdef USING_IF_MIB_DATA_ACCESS_INTERFACE_MODULE
|
||||
#include <net-snmp/data_access/interface.h>
|
||||
#endif
|
||||
|
||||
#include "mibgroup/struct.h"
|
||||
#include <net-snmp/agent/mib_modules.h>
|
||||
#include <net-snmp/agent/table.h>
|
||||
#include <net-snmp/agent/table_iterator.h>
|
||||
#include "mib_module_includes.h"
|
||||
|
||||
static int need_shutdown = 0;
|
||||
|
||||
static int
|
||||
_shutdown_mib_modules(int majorID, int minorID, void *serve, void *client)
|
||||
{
|
||||
if (! need_shutdown) {
|
||||
netsnmp_assert(need_shutdown == 1);
|
||||
}
|
||||
else {
|
||||
#include "mib_module_shutdown.h"
|
||||
|
||||
need_shutdown = 0;
|
||||
}
|
||||
|
||||
return SNMPERR_SUCCESS; /* callback rc ignored */
|
||||
}
|
||||
|
||||
void
|
||||
init_mib_modules(void)
|
||||
{
|
||||
static int once = 0;
|
||||
|
||||
#ifdef USING_IF_MIB_DATA_ACCESS_INTERFACE_MODULE
|
||||
netsnmp_access_interface_init();
|
||||
#endif
|
||||
# include "mib_module_inits.h"
|
||||
|
||||
need_shutdown = 1;
|
||||
|
||||
if (once == 0) {
|
||||
int rc;
|
||||
once = 1;
|
||||
rc = snmp_register_callback( SNMP_CALLBACK_LIBRARY,
|
||||
SNMP_CALLBACK_SHUTDOWN,
|
||||
_shutdown_mib_modules,
|
||||
NULL);
|
||||
|
||||
if( rc != SNMP_ERR_NOERROR )
|
||||
snmp_log(LOG_ERR, "error registering for SHUTDOWN callback "
|
||||
"for mib modules\n");
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,41 +0,0 @@
|
||||
top_builddir=../..
|
||||
mysubdir=agent/mibgroup
|
||||
|
||||
# currently assumes gcc: (XXX: fix via configure tests)
|
||||
DLFLAGS=-fPIC -shared
|
||||
|
||||
# use GNU vpath, if available, to only set a path for source and headers
|
||||
# VPATH will pick up objects too, which is bad if you are sharing a
|
||||
# source dir...
|
||||
@GNU_vpath@ %.h $(srcdir)
|
||||
@GNU_vpath@ %.c $(srcdir)
|
||||
# fallback to regular VPATH for non-gnu...
|
||||
@NON_GNU_VPATH@ $(srcdir)
|
||||
|
||||
|
||||
CPPFLAGS= $(TOP_INCLUDES) -I. $(AGENT_INCLUDES) $(MIBGROUP_INCLUDES) \
|
||||
$(SNMPLIB_INCLUDES) @CPPFLAGS@ $(LIB_CFLAGS)
|
||||
|
||||
OTHERCLEANTARGETS=@dllcleans@
|
||||
|
||||
FEATUREFILE=../../include/net-snmp/agent/features-mibgroups.h
|
||||
|
||||
# Need a special .c -> .o definition here to make sure we place the
|
||||
# object files in the sub directory.
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
|
||||
|
||||
@mib_module_list_o@
|
||||
@mib_module_list_lo@
|
||||
@mib_module_list_c@
|
||||
@mib_module_list_ft@
|
||||
|
||||
OBJS = $(mib_module_list_o)
|
||||
LOBJS = $(mib_module_list_lo)
|
||||
SRCS = $(mib_module_list_c)
|
||||
FTOBJS = $(mib_module_list_ft)
|
||||
|
||||
all: standardall $(LOBJS)
|
||||
|
||||
@module_rules@
|
||||
@@ -1,113 +0,0 @@
|
||||
This directory holds the implementation of individual MIB groups.
|
||||
Currently, this contains the eight MIB-2 groups, plus a basic template
|
||||
for new MIB groups (examples/example.c and examples/example.h)
|
||||
|
||||
Additionally, you may wish to check out the 'mib2c' perl script in the
|
||||
SRCDIR/local directory that can convert a written mib into C template
|
||||
files for use with this package as mib modules.
|
||||
|
||||
Each group consists of two files:
|
||||
|
||||
examples/example.h: interface information
|
||||
|
||||
- declaration of the initialisation function 'init_example'
|
||||
(optional)
|
||||
- declaration of the function(s) for retrieving variable
|
||||
information 'var_example'
|
||||
- declaration of the function(s) for setting variable
|
||||
information (if appropriate)
|
||||
|
||||
- declaration of the function(s) for parsing the snmpd.conf file
|
||||
(optional)
|
||||
- a call to config_parse_dot_conf() to explain to the .conf
|
||||
parser which tokens we want to parse.
|
||||
(optional)
|
||||
|
||||
- definitions of the MIB group 'magic numbers'
|
||||
declarations of the 'public' functions
|
||||
|
||||
- a list of the variables in the group, including
|
||||
type information, mapping between magic numbers
|
||||
and OID sub-identifiers within the group,
|
||||
accessibility information, and the relevant
|
||||
function for retrieving this variable's value.
|
||||
They *must* be listed in the mib-descending order.
|
||||
- a call to 'config_load_mib', identifying the location of
|
||||
this MIB group within the general MIB structure.
|
||||
- a call to 'config_require' to identify any other files
|
||||
that are required by the implementation of this group.
|
||||
(optional)
|
||||
|
||||
(these last three are only visible within the 'glue' file 'snmp_vars.c'
|
||||
(if at all), but are declared here for ease of maintainance)
|
||||
|
||||
|
||||
|
||||
examples/example.c: implementation code
|
||||
(can be non-existant if only the .h file is needed)
|
||||
|
||||
- a list of kernel information needed to report
|
||||
on this group
|
||||
- an initialisation function (optional)
|
||||
- a routine to parse an snmpd.conf line.
|
||||
- a routine to free resources from above and return to
|
||||
default settings.
|
||||
- 'header' function(s) to map the OID requested
|
||||
to the next appropriate OID
|
||||
(and similar system-independent setup)
|
||||
- function(s) (possibly system-specific) to
|
||||
determine and return the value of the
|
||||
variable requested.
|
||||
- (optionally) functions used to set values
|
||||
- other functions used internally
|
||||
|
||||
|
||||
To implement a new MIB group, copy the two files 'example.c'
|
||||
and 'example.h' to appropriate new files ({MODULENAME}.c and {MODULENAME}.h),
|
||||
and edit them as follows:
|
||||
|
||||
example.h:
|
||||
globally change "example" to the new module name
|
||||
and update the initial comment.
|
||||
replace the EXAMPLE* defines with the list of
|
||||
variables within this new group
|
||||
fill in the 'MODULENAME_variables' structure with these
|
||||
new variables, updating the type, accessibility
|
||||
and sub-identifier information as appropriate.
|
||||
replace 'variableN' with the maximum size of the
|
||||
returned OID (omitting the group prefix).
|
||||
For non-table values, this will probably be one
|
||||
greater than the length of the sub-identifier.
|
||||
update or remove the 'config_parse_dot_conf' call if
|
||||
you need to handle lines in the snmpd.conf files.
|
||||
update the 'config_load_mib' call with the appropriate
|
||||
location within the global MIB structure, and
|
||||
its length (note that 'MIB' has length 6)
|
||||
provide a suitable 'config_require' call if this
|
||||
code uses routines from any other files within
|
||||
the 'mibgroup' directory (such as 'util_funcs.c')
|
||||
|
||||
|
||||
|
||||
example.c:
|
||||
globally change "example" to the new module name
|
||||
and update the initial comment.
|
||||
replace the 'MODULENAME_nl' name list with any necessary
|
||||
kernel variables, and update the associated #define's
|
||||
replace the name length definition within the 'header'
|
||||
function with the length of the requesting OID
|
||||
(i.e. the sum of the lengths given in the subtree
|
||||
definition, and the variable structure above).
|
||||
replace the basic 'switch' structure within the
|
||||
'var_MODULENAME' function with the necessary code
|
||||
to calculate the required information.
|
||||
(plus any other internal functions as needed).
|
||||
|
||||
It will then be necessary to (re-)run the configure script with the
|
||||
option
|
||||
--with-mib-modules="MODULENAME"
|
||||
|
||||
(where MODULENAME matches the name of the .c/.h file pair exactly).
|
||||
Note that if anything in the config_* macros changes, or the init function
|
||||
is added or removed, then the configure script will need to be re-run.
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
[1] What is SMUX?
|
||||
|
||||
SMUX is the snmp multiplexing protocol (RFC 1227). It can be used by an
|
||||
snmp agent to query variables maintained by another user-level process.
|
||||
|
||||
[2] Why is it relevant to net-snmp?
|
||||
|
||||
The original ucd-snmp agent needed a mechanism to query statistics from
|
||||
GateD. GateD has traditionally supported this functionality via SMUX.
|
||||
Hence SMUX was implemented within the ucd-snmp framework to extract
|
||||
routing protocol statistics from GateD.
|
||||
|
||||
net-snmp continues to support smux, and many applications still use it.
|
||||
|
||||
[3] What is GateD?
|
||||
|
||||
GateD is the 'Gateway Daemon' which implements a variety of routing
|
||||
protocols on a variety of platforms (OSes). This was formerly available
|
||||
as open source, but has since been made closed and entirely un-free.
|
||||
Other routing protocol daemons such a quagga (http://www.quagga.net)
|
||||
support SMUX.
|
||||
|
||||
[4] Can SMUX extract statistics from other user-level processes?
|
||||
|
||||
Yes, the current implementation allows for the registration of any MIB
|
||||
that might be registered by a SMUX peer.
|
||||
|
||||
[5] How does it work?
|
||||
|
||||
Assuming 'snmpd' is already up and running, when the SMUX peer comes up,
|
||||
it identifies itself with an oid identifier and string password, and
|
||||
registers any MIBs it would like to implement. When 'snmpd' receives
|
||||
queries for these MIBs, it passes these queries to the peer.
|
||||
|
||||
[6] Who implemented SMUX for ucd-snmp?
|
||||
|
||||
SMUX was implemented by Rohit Dube. He had oodles of help from
|
||||
ucd-snmp-coders (Dave, Niels, Wes, Simon, Felix, Leonti) and gated-people
|
||||
(Acee, Feiyi, Larry, Sue). [If I missed somebody, sorry in advance and
|
||||
do let me know]. Later, Nick Amato re-write the entire SMUX package so
|
||||
the code today is mostly his.
|
||||
|
||||
[7] How do I find out more about SMUX?
|
||||
|
||||
Read the RFC and the code, mainly, but only for legacy code.
|
||||
|
||||
*New* sub-agent development should use the AgentX protocol instead,
|
||||
which is not only standardized (RFC 2741 + 2742), but is outright superior
|
||||
to smux in a number of important ways (handles SET requests reliably,
|
||||
able to handle overlapping registrations, aware of SNMPv3 contexts, etc.)
|
||||
|
||||
Only build new smux support if you have to.
|
||||
@@ -1,56 +0,0 @@
|
||||
/**************************************************************
|
||||
* Copyright (C) 2001 Alex Rozin, Optical Access
|
||||
*
|
||||
* All Rights Reserved
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software and its
|
||||
* documentation for any purpose and without fee is hereby granted,
|
||||
* provided that the above copyright notice appear in all copies and that
|
||||
* both that copyright notice and this permission notice appear in
|
||||
* supporting documentation.
|
||||
*
|
||||
* ALEX ROZIN DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
||||
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
|
||||
* ALEX ROZIN BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
|
||||
* ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
******************************************************************/
|
||||
|
||||
/*
|
||||
* $Log$
|
||||
* Revision 5.0 2002/04/20 07:30:00 hardaker
|
||||
* cvs file version number change
|
||||
*
|
||||
* Revision 1.2 2002/04/20 07:07:34 hardaker
|
||||
* White space, oh glorious white space.
|
||||
* How great our though?
|
||||
* The code is fine.
|
||||
* We agree on functionality easily.
|
||||
* What really troubles us?
|
||||
* Something we can't see.
|
||||
* Something between the code.
|
||||
* We bow down to your magnificence,
|
||||
* For you are everywhere,
|
||||
* Between everything.
|
||||
* Pretty nothingness you are.
|
||||
*
|
||||
* Revision 1.1 2001/05/09 19:36:13 slif
|
||||
* Include Alex Rozin's Rmon.
|
||||
*
|
||||
* Revision 1.1.2.1 2001/04/16 14:45:05 alex
|
||||
* Rmon1 : first edition
|
||||
*
|
||||
*/
|
||||
|
||||
config_require(Rmon/rows)
|
||||
config_require(Rmon/agutil)
|
||||
config_require(Rmon/statistics)
|
||||
/* older implementation: */
|
||||
/* config_require(Rmon/alarm) */
|
||||
config_require(Rmon/alarmTable)
|
||||
config_require(Rmon/history)
|
||||
config_require(Rmon/event)
|
||||
config_add_mib(RMON-MIB)
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
|
||||
Important notes.
|
||||
===============
|
||||
1. This implementation is actually a system independent
|
||||
template. It means that the question "Where and how
|
||||
may I collect the monitored statistics ?" is taken out
|
||||
from the scope. Actually, it is emulated with random values.
|
||||
You are free to rewrite the function 'get_history_data'
|
||||
for your system. Don't forget also to insert DataSourse
|
||||
checking in 'history_Validate' function. (Both functions
|
||||
are in the file history.c).
|
||||
|
||||
2. This implementation has two RMON mib understanding extensions
|
||||
(I hope it does not break anything; nevertheless you may use
|
||||
it in completely standard way).
|
||||
|
||||
2.1. I permit to set VALID entryStatus when entry doesn't exit;
|
||||
in this case PDU has to have the necessary & valid set
|
||||
of non-default values
|
||||
|
||||
2.2. I permit to travel from VALID to 'UNDER_CREATION' state:
|
||||
these ways a manager can change control entry and validate
|
||||
it once more.
|
||||
|
||||
|
||||
THANKS
|
||||
======
|
||||
Mr. Michael J. Slifcak of Internet Security Systems, Inc has provided
|
||||
a number of remarks, I implemented ALL of them.
|
||||
|
||||
@@ -1,299 +0,0 @@
|
||||
/**************************************************************
|
||||
* Copyright (C) 2001 Alex Rozin, Optical Access
|
||||
*
|
||||
* All Rights Reserved
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software and its
|
||||
* documentation for any purpose and without fee is hereby granted,
|
||||
* provided that the above copyright notice appear in all copies and that
|
||||
* both that copyright notice and this permission notice appear in
|
||||
* supporting documentation.
|
||||
*
|
||||
* ALEX ROZIN DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
||||
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
|
||||
* ALEX ROZIN BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
|
||||
* ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
******************************************************************/
|
||||
|
||||
#include <net-snmp/net-snmp-config.h>
|
||||
#include <net-snmp/net-snmp-includes.h>
|
||||
#include <net-snmp/agent/net-snmp-agent-includes.h>
|
||||
|
||||
#include "agutil.h"
|
||||
#include "agutil_api.h"
|
||||
|
||||
#ifndef OPTICALL_ACESS /* in OpticalAccess case : find them in ~agent/mibgroup/nbase directory */
|
||||
void
|
||||
ag_trace(const char *format, ...)
|
||||
{
|
||||
#define AG_MAX_MSG_LEN 120
|
||||
char msg[AG_MAX_MSG_LEN];
|
||||
va_list args;
|
||||
|
||||
/*
|
||||
* create msg
|
||||
*/
|
||||
va_start(args, format);
|
||||
vsnprintf(msg, AG_MAX_MSG_LEN - 1, format, args);
|
||||
|
||||
snmp_log(LOG_INFO, "%s\n", msg);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
int
|
||||
AGUTIL_advance_index_name(struct variable *vp, oid * name,
|
||||
size_t * length, int exact)
|
||||
{
|
||||
int result;
|
||||
|
||||
if (exact)
|
||||
return 0;
|
||||
|
||||
if (*length <= vp->namelen) {
|
||||
result =
|
||||
snmp_oid_compare(name, *length, vp->name, (int) vp->namelen);
|
||||
memcpy((char *) name, (char *) vp->name,
|
||||
((int) vp->namelen) * sizeof(oid));
|
||||
*length = vp->namelen;
|
||||
} else {
|
||||
/*
|
||||
* If the name is given with indexes - compare only the oids.
|
||||
*/
|
||||
result =
|
||||
snmp_oid_compare(name, (int) vp->namelen, vp->name,
|
||||
(int) vp->namelen);
|
||||
/*
|
||||
* If it's not the same oid - change name to the new oid
|
||||
*/
|
||||
if (result < 0) {
|
||||
memcpy((char *) name, (char *) vp->name,
|
||||
((int) vp->namelen) * sizeof(oid));
|
||||
*length = vp->namelen;
|
||||
}
|
||||
}
|
||||
|
||||
if (result > 0) {
|
||||
ag_trace("*length=%d result=%d !!!", (int) *length, (int) result);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* Function: AGUTIL_get_int_value
|
||||
*
|
||||
* Description:
|
||||
* Check/Get long value from the PDU..
|
||||
* The parameters 'min_value' & 'max_value' allow to check the diaposon
|
||||
* of the value. If (max_value <= min_value) we avoid this checking.
|
||||
*
|
||||
* Returns:
|
||||
* SNMP_ERR_NOERROR
|
||||
* SNMP_ERR_WRONGTYPE
|
||||
* SNMP_ERR_WRONGLENGTH
|
||||
* SNMP_ERR_WRONGENCODING
|
||||
* SNMP_ERR_BADVALUE
|
||||
*********************************************************************/
|
||||
int
|
||||
AGUTIL_get_int_value(u_char * var_val, u_char var_val_type,
|
||||
size_t var_val_len, long min_value, long max_value,
|
||||
long *long_tmp)
|
||||
{
|
||||
if (var_val_type != ASN_INTEGER && var_val_type != ASN_TIMETICKS) {
|
||||
ag_trace("not ASN_INTEGER 0x%lx", (long) var_val_type);
|
||||
return SNMP_ERR_WRONGTYPE;
|
||||
}
|
||||
|
||||
if (var_val_len > sizeof(long)) {
|
||||
ag_trace("wrong len=%d", (int) var_val_len);
|
||||
return SNMP_ERR_WRONGLENGTH;
|
||||
}
|
||||
|
||||
*long_tmp = *((long *) var_val);
|
||||
|
||||
if (max_value > min_value) {
|
||||
if (*long_tmp < min_value) {
|
||||
ag_trace("%ld=long_tmp < min=%ld", (long) *long_tmp,
|
||||
(long) min_value);
|
||||
return SNMP_ERR_BADVALUE;
|
||||
}
|
||||
|
||||
if (*long_tmp > max_value) {
|
||||
ag_trace("%ld=long_tmp > max=%ld", (long) *long_tmp,
|
||||
(long) max_value);
|
||||
return SNMP_ERR_BADVALUE;
|
||||
}
|
||||
}
|
||||
|
||||
return SNMP_ERR_NOERROR;
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
* Function: AGUTIL_get_string_value
|
||||
*
|
||||
* Description:
|
||||
* Check/Get 'DisplayString' value from the PDU..
|
||||
*
|
||||
* Returns:
|
||||
* SNMP_ERR_NOERROR
|
||||
* SNMP_ERR_WRONGTYPE
|
||||
* SNMP_ERR_WRONGLENGTH
|
||||
* SNMP_ERR_WRONGENCODING
|
||||
* SNMP_ERR_BADVALUE
|
||||
*********************************************************************/
|
||||
int
|
||||
AGUTIL_get_string_value(u_char * var_val, u_char var_val_type,
|
||||
size_t var_val_len, size_t buffer_max_size,
|
||||
u_char should_zero_limited,
|
||||
size_t * buffer_actual_size, char *buffer)
|
||||
{
|
||||
if (var_val_type != ASN_OCTET_STR) {
|
||||
ag_trace("not ASN_OCTET_STR 0x%lx", (long) var_val_type);
|
||||
return SNMP_ERR_WRONGTYPE;
|
||||
}
|
||||
|
||||
if (var_val_len > buffer_max_size) {
|
||||
ag_trace("wrong len=%d > %d", (int) var_val_len, buffer_max_size);
|
||||
return SNMP_ERR_WRONGLENGTH;
|
||||
}
|
||||
|
||||
if (buffer_actual_size)
|
||||
*buffer_actual_size = var_val_len;
|
||||
|
||||
memcpy(buffer, var_val, var_val_len);
|
||||
if (should_zero_limited) {
|
||||
buffer[var_val_len] = 0;
|
||||
if (buffer_actual_size)
|
||||
*buffer_actual_size += 1;
|
||||
}
|
||||
|
||||
return SNMP_ERR_NOERROR;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
int
|
||||
AGUTIL_get_oid_value(u_char * var_val, u_char var_val_type,
|
||||
size_t var_val_len, VAR_OID_T * data_source_ptr)
|
||||
{
|
||||
register int iii;
|
||||
register oid *oid_var;
|
||||
|
||||
if (var_val_len > MAX_OID_LEN) {
|
||||
ag_trace("wrong len=%d > %d", (int) var_val_len, MAX_OID_LEN);
|
||||
return SNMP_ERR_WRONGLENGTH;
|
||||
}
|
||||
|
||||
var_val_len /= sizeof(oid);
|
||||
data_source_ptr->length = var_val_len;
|
||||
oid_var = (oid *) var_val;
|
||||
for (iii = 0; iii < (int)data_source_ptr->length; iii++)
|
||||
data_source_ptr->objid[iii] = oid_var[iii];
|
||||
|
||||
return SNMP_ERR_NOERROR;
|
||||
}
|
||||
|
||||
u_long
|
||||
AGUTIL_sys_up_time(void)
|
||||
{
|
||||
return netsnmp_get_agent_runtime();
|
||||
}
|
||||
|
||||
/*
|
||||
* NOTE: this function is a template for system dependent
|
||||
* implementation. Actually it (in debug purposes) returns
|
||||
* random (but likely) data */
|
||||
void
|
||||
SYSTEM_get_eth_statistics(VAR_OID_T * data_source, ETH_STATS_T * where)
|
||||
{
|
||||
#if OPTICALL_ACESS
|
||||
where->ifIndex = data_source->objid[data_source->length - 1];
|
||||
agent_get_Rmon_ethernet_statistics(where->ifIndex, 1, /* exact */
|
||||
where);
|
||||
#else /* OPTICALL_ACESS */
|
||||
static ETH_STATS_T prev = { -1, -1 };
|
||||
static time_t ifLastRead = 0;
|
||||
time_t curr_time;
|
||||
u_char need_to_read;
|
||||
u_long rc;
|
||||
|
||||
where->ifIndex = data_source->objid[data_source->length - 1];
|
||||
need_to_read = (where->ifIndex != prev.ifIndex);
|
||||
if (!need_to_read) {
|
||||
curr_time = time(NULL);
|
||||
need_to_read = (curr_time - ifLastRead > 1);
|
||||
}
|
||||
|
||||
if (need_to_read) {
|
||||
rc = (u_long) (1.0 +
|
||||
((double) rand() / (double) RAND_MAX) * 100.0);
|
||||
ifLastRead = time(NULL);
|
||||
prev.ifIndex = where->ifIndex;
|
||||
} else
|
||||
rc = 0;
|
||||
|
||||
memcpy(where, &prev, sizeof(ETH_STATS_T));
|
||||
where->octets += rc * 100 * 200;
|
||||
where->packets += rc * 100;
|
||||
where->bcast_pkts += rc * 2;
|
||||
where->mcast_pkts += rc * 3;
|
||||
where->crc_align += rc;
|
||||
where->undersize += 0;
|
||||
where->oversize += 0;
|
||||
where->fragments += rc / 2;
|
||||
where->jabbers += 0;
|
||||
where->collisions += rc / 4;
|
||||
|
||||
where->pkts_64 += rc * 10;
|
||||
where->pkts_65_127 += rc * 50;
|
||||
where->pkts_128_255 += rc * 20;
|
||||
where->pkts_256_511 += rc * 10;
|
||||
where->pkts_512_1023 += rc * 15;
|
||||
where->pkts_1024_1518 += rc * 5;
|
||||
|
||||
need_to_read = prev.ifIndex;
|
||||
memcpy(&prev, where, sizeof(ETH_STATS_T));
|
||||
prev.ifIndex = need_to_read;
|
||||
#endif /* OPTICALL_ACESS */
|
||||
}
|
||||
|
||||
#if 0 /* for memory debug */
|
||||
static u_long dbg_mem_cnt = 0;
|
||||
|
||||
void *
|
||||
dbg_f_AGMALLOC(size_t size)
|
||||
{
|
||||
dbg_mem_cnt++;
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
void
|
||||
dbg_f_AGFREE(void *ptr)
|
||||
{
|
||||
dbg_mem_cnt--;
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
char *
|
||||
dbg_f_AGSTRDUP(const char *s)
|
||||
{
|
||||
dbg_mem_cnt++;
|
||||
return strdup(s);
|
||||
}
|
||||
|
||||
void
|
||||
dbg_f_AG_MEM_REPORT(void)
|
||||
{
|
||||
ag_trace("dbg_mem_cnt=%ld", (long) dbg_mem_cnt);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void
|
||||
init_agutil(void)
|
||||
{
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user