net-snmp
5.4.1
|
00001 /* 00002 * wrapper to call all the mib module initialization functions 00003 */ 00004 00005 #include <net-snmp/agent/mib_module_config.h> 00006 #include <net-snmp/net-snmp-config.h> 00007 #if HAVE_STRING_H 00008 #include <string.h> 00009 #else 00010 #include <strings.h> 00011 #endif 00012 #if HAVE_STDLIB_H 00013 #include <stdlib.h> 00014 #endif 00015 #if HAVE_UNISTD_H 00016 #include <unistd.h> 00017 #endif 00018 #include <sys/types.h> 00019 #if TIME_WITH_SYS_TIME 00020 # ifdef WIN32 00021 # include <sys/timeb.h> 00022 # else 00023 # include <sys/time.h> 00024 # endif 00025 # include <time.h> 00026 #else 00027 # if HAVE_SYS_TIME_H 00028 # include <sys/time.h> 00029 # else 00030 # include <time.h> 00031 # endif 00032 #endif 00033 #if HAVE_NETINET_IN_H 00034 #include <netinet/in.h> 00035 #endif 00036 #if HAVE_WINSOCK_H 00037 #include <winsock.h> 00038 #endif 00039 00040 #include <net-snmp/net-snmp-includes.h> 00041 #include <net-snmp/agent/net-snmp-agent-includes.h> 00042 #include "m2m.h" 00043 #ifdef USING_IF_MIB_DATA_ACCESS_INTERFACE_MODULE 00044 #include <net-snmp/data_access/interface.h> 00045 #endif 00046 00047 #include "mibgroup/struct.h" 00048 #include <net-snmp/agent/mib_modules.h> 00049 #include <net-snmp/agent/table.h> 00050 #include <net-snmp/agent/table_iterator.h> 00051 #include "mib_module_includes.h" 00052 #ifdef USING_AGENTX_SUBAGENT_MODULE 00053 #include "mibgroup/agentx/subagent.h" 00054 #endif 00055 00056 static int need_shutdown = 0; 00057 00058 static int 00059 _shutdown_mib_modules(int majorID, int minorID, void *serve, void *client) 00060 { 00061 if (! need_shutdown) { 00062 netsnmp_assert(need_shutdown == 1); 00063 } 00064 else { 00065 #include "mib_module_shutdown.h" 00066 00067 need_shutdown = 0; 00068 } 00069 00070 return SNMPERR_SUCCESS; /* callback rc ignored */ 00071 } 00072 00073 void 00074 init_mib_modules(void) 00075 { 00076 static int once = 0; 00077 00078 #ifdef USING_IF_MIB_DATA_ACCESS_INTERFACE_MODULE 00079 netsnmp_access_interface_init(); 00080 #endif 00081 # include "mib_module_inits.h" 00082 00083 need_shutdown = 1; 00084 00085 if (once == 0) { 00086 int rc; 00087 once = 1; 00088 rc = snmp_register_callback( SNMP_CALLBACK_LIBRARY, 00089 SNMP_CALLBACK_SHUTDOWN, 00090 _shutdown_mib_modules, 00091 NULL); 00092 00093 if( rc != SNMP_ERR_NOERROR ) 00094 snmp_log(LOG_ERR, "error registering for SHUTDOWN callback " 00095 "for mib modules\n"); 00096 } 00097 }