void agentx_reopen_session(unsigned int clientreg, void *clientarg) { DEBUGMSGTL(("agentx/subagent", "agentx_reopen_session(%d) called\n", clientreg)); if (subagent_open_master_session() == 0) { /* * Successful. Delete the alarm handle if one exists. */ if (clientreg != 0) { snmp_alarm_unregister(clientreg); } /* * Reregister all our nodes. */ register_mib_reattach(); /* * Register a ping alarm (if need be). */ subagent_register_ping_alarm(0, 0, 0, main_session); } else { if (clientreg == 0) { /* * Register a reattach alarm for later */ subagent_register_ping_alarm(0, 0, 0, main_session); } } }
/* * returns non-zero on error */ int subagent_pre_init(void) { DEBUGMSGTL(("agentx/subagent", "initializing....\n")); /* * set up callbacks to initiate master agent pings for this session */ netsnmp_ds_register_config(ASN_INTEGER, netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_APPTYPE), "agentxPingInterval", NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_AGENTX_PING_INTERVAL); if (netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_ROLE) != SUB_AGENT) { return 0; } /* * if a valid ping interval has been defined, call agentx_reopen_session * * to try to connect to master or setup a ping alarm if it couldn't * * succeed */ if (netsnmp_ds_get_int(NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_AGENTX_PING_INTERVAL) > 0) agentx_reopen_session(0, NULL); else /* if no ping interval was set up, just try to connect once */ subagent_open_master_session(); if (!main_session) return -1; DEBUGMSGTL(("agentx/subagent", "initializing.... DONE\n")); return 0; }
int subagent_startup (int majorID, int minorID, void *serverarg, void *clientarg) { DEBUGMSGTL (("agentx/subagent", "connecting to master...\n")); /* * if a valid ping interval has been defined, call agentx_reopen_session * to try to connect to master or setup a ping alarm if it couldn't * succeed. if no ping interval was set up, just try to connect once. */ if (netsnmp_ds_get_int (NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_AGENTX_PING_INTERVAL) > 0) agentx_reopen_session (0, NULL); else { subagent_open_master_session (); } return 0; }