📄 axapi.c
字号:
septr->agentxSessAdminStatus = ENVOY_AX_SESSION_UP; septr->agentxSessOpenTime = slptr->timestamp; septr->agentxSessAgentXVer = (bits32_t)slptr->version; septr->agentxSessTimeout = (bits32_t)slptr->timeout; ENVOY_SNMP_RELEASE_WRITE_LOCK(SNMP_infrastructure_lock); return (septr);}AX_SESSENT_T *AxSessGetEntry (int tcount, OIDC_T *tlist)/*** NAME**** AxSessGetEntry() - Retrieves a session table entry**** PARAMETERS**** tcount -- Count of sub-ids** tlist -- Pointer to an array of bits32_ts representing an instance**** DESCRIPTION**** Information about a single open session between the AgentX master agent and** a subagent is contained in this entry.**** RETURNS**** Success -- Pointer to a Session Entry structure** Failure -- Zero (0)*/{ ENVOY_AX_SESSION_T **tsp; /* Check on the instance info */ if (tcount != 2) return 0; /* Try to get the infrastructure lock */#if INSTALL_ENVOY_SNMP_LOCK if (ENVOY_SNMP_GET_WRITE_LOCK(SNMP_infrastructure_lock)) { BUG(BUG_ENVOY_LOCKING, BUG_CONTINUABLE, 0, (BUG_OUT, "AxSessGetEntry: infrastructure lock is broken", 0)); return(0); }#endif for (tsp = &envoy_ax_session_list; *tsp != NULL; tsp = &((*tsp)->next)) { if ((tlist[0] == (OIDC_T)((*tsp)->connection_id)) && (tlist[1] == (OIDC_T)((*tsp)->session_id))) return (create_sessentry (*tsp)); } /* No match. */ ENVOY_SNMP_RELEASE_WRITE_LOCK(SNMP_infrastructure_lock); return 0;}AX_SESSENT_T *AxSessGetNext (int tcount, OIDC_T *tlist)/*** NAME**** AxSessGetNext() - Retrieves the next session table entry**** PARAMETERS**** tcount -- Count of sub-ids** tlist -- Pointer to an array of bits32_ts representing an instance**** DESCRIPTION**** An agentxSessionEntry describes a single AgentX transport connection.**** RETURNS**** Success -- Pointer to a Connection Entry structure** Failure -- Zero (0)*/{ ENVOY_AX_SESSION_T **tsp; OIDC_T listoid[2]; OIDC_T bestcidx = 0xFFFF; OIDC_T bestsidx = 0xFFFF; /* Try to get the infrastructure lock */#if INSTALL_ENVOY_SNMP_LOCK if (ENVOY_SNMP_GET_WRITE_LOCK(SNMP_infrastructure_lock)) { BUG(BUG_ENVOY_LOCKING, BUG_CONTINUABLE, 0, (BUG_OUT, "AxSessGetNext: infrastructure lock is broken", 0)); return(0); }#endif for (tsp = &envoy_ax_session_list; *tsp != NULL; tsp = &((*tsp)->next)) { listoid[0] = (OIDC_T) ((*tsp)->connection_id); listoid[1] = (OIDC_T) ((*tsp)->session_id); if (oidcmp2 (2, listoid, tcount, tlist) > 0) { if ((listoid[0] < bestcidx) || ((listoid[0] == bestcidx) && (listoid[1] < bestsidx))) { bestcidx = listoid[0]; bestsidx = listoid[1]; } } } for (tsp = &envoy_ax_session_list; *tsp != NULL; tsp = &((*tsp)->next)) { listoid[0] = (OIDC_T) ((*tsp)->connection_id); listoid[1] = (OIDC_T) ((*tsp)->session_id); if ((listoid[0] == bestcidx) && (listoid[1] == bestsidx)) return (create_sessentry (*tsp)); } /* No match. */ ENVOY_SNMP_RELEASE_WRITE_LOCK(SNMP_infrastructure_lock); return 0;}/****************************//*** REGISTRATION GROUP ***//****************************/static AX_REGENT_T *create_regentry (ENVOY_AX_MA_REGLIST_T *rlptr)/*** NAME*** create_regentry() - Retrieves a registration table entry**** PARAMETERS**** rlptr -- Pointer to an element of the registration list**** DESCRIPTION**** Copies information from a REGLIST structure to a new REGENT**** RETURNS**** Pointer to the new structure of type AX_REGENT_T, or 0 if failure.*/{ AX_REGENT_T *reptr; ENVOY_AX_CONTEXT_T *ctxptr; if (!rlptr) return 0; if (!(reptr = SNMP_memory_alloc (sizeof (AX_REGENT_T)))) return 0; reptr->agentxConnIndex = (int)(rlptr->connection_id); reptr->agentxSessIndex = (int)(rlptr->session_id); reptr->agentxRegIndex = (int)(rlptr->reg_index); /* * Get the context from the id stored in the regleaf * Then copy it into the REGENT structure */ if (!(ctxptr = ax_context_index (rlptr->context_id))) { SNMP_memory_free (reptr); return 0; } if (EBufferClone(&ctxptr->context, &reptr->agentxRegContext)) { SNMP_memory_free (reptr); return 0; } if ((build_object_id (rlptr->start_oid.num_components, rlptr->start_oid.component_list, &(reptr->agentxRegStart)) < 0)) { SNMP_memory_free (reptr); return 0; } reptr->agentxRegRangeSubId = (bits32_t)(rlptr->range_id); reptr->agentxRegUpperBound = (bits32_t)(rlptr->bound); reptr->agentxRegPriority = (bits32_t)(rlptr->priority); reptr->agentxRegTimeout = (bits32_t)(rlptr->mibleaf->timeout); if (rlptr->flags & ENVOY_AX_BIT_INSTANCE) reptr->agentxRegInstance = 1; else reptr->agentxRegInstance = 2; ENVOY_SNMP_RELEASE_WRITE_LOCK(SNMP_infrastructure_lock); return (reptr);}AX_REGENT_T *AxRegGetEntry (int tcount, OIDC_T *tlist)/*** NAME**** AxRegGetEntry() - Retrieves a registration table entry**** PARAMETERS**** tcount -- Count of sub-ids** tlist -- Pointer to an array of bits32_ts representing an instance**** DESCRIPTION**** Information for a single registered region is contained in this entry.**** RETURNS**** Success -- Pointer to a Session Entry structure** Failure -- Zero (0)*/{ ENVOY_AX_MA_REGLIST_T **trp; /* Check on instance info */ if (tcount != 3) return 0; /* Try to get the infrastructure lock */#if INSTALL_ENVOY_SNMP_LOCK if (ENVOY_SNMP_GET_WRITE_LOCK(SNMP_infrastructure_lock)) { BUG(BUG_ENVOY_LOCKING, BUG_CONTINUABLE, 0, (BUG_OUT, "AxRegGetEntry: infrastructure lock is broken", 0)); return(0); }#endif for (trp = &envoy_ax_registration_list; *trp != NULL; trp = &((*trp)->next)) { if ((tlist[0] == (OIDC_T)((*trp)->connection_id)) && (tlist[1] == (OIDC_T)((*trp)->session_id)) && (tlist[2] == (OIDC_T)((*trp)->reg_index))) return (create_regentry (*trp)); } /* No match. */ ENVOY_SNMP_RELEASE_WRITE_LOCK(SNMP_infrastructure_lock); return 0;}AX_REGENT_T *AxRegGetNext (int tcount, OIDC_T *tlist)/*** NAME**** AxRegGetNext() - Retrieves the next registration table entry**** PARAMETERS**** tcount -- Count of sub-ids** tlist -- Pointer to an array of bits32_ts representing an instance**** DESCRIPTION**** An agentxRegistration Entry describes a single registered region.**** RETURNS**** Success -- Pointer to a Connection Entry structure** Failure -- Zero (0)*/{ ENVOY_AX_MA_REGLIST_T **trp; OIDC_T listoid[3]; /* Try to get the infrastructure lock */#if INSTALL_ENVOY_SNMP_LOCK if (ENVOY_SNMP_GET_WRITE_LOCK(SNMP_infrastructure_lock)) { BUG(BUG_ENVOY_LOCKING, BUG_CONTINUABLE, 0, (BUG_OUT, "AxRegGetNext: infrastructure lock is broken", 0)); return(0); }#endif for (trp = &envoy_ax_registration_list; *trp != NULL; trp = &((*trp)->next)) { listoid[0] = (OIDC_T) ((*trp)->connection_id); listoid[1] = (OIDC_T) ((*trp)->session_id); listoid[2] = (OIDC_T) ((*trp)->reg_index); if (oidcmp2 (3, listoid, tcount, tlist) > 0) return (create_regentry (*trp)); } /* No match. */ ENVOY_SNMP_RELEASE_WRITE_LOCK(SNMP_infrastructure_lock); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -