📄 axmth.c
字号:
* up(1) = VAL_agentxSessionAdminStatus_up * down(2) = VAL_agentxSessionAdminStatus_down */ getproc_got_int32 (pktp, vbp, sessData -> agentxSessAdminStatus); break; case LEAF_agentxSessionOpenTime: getproc_got_uint32 (pktp, vbp, sessData -> agentxSessOpenTime, VT_TIMETICKS); break; case LEAF_agentxSessionAgentXVer: getproc_got_int32 (pktp, vbp, sessData -> agentxSessAgentXVer); break; case LEAF_agentxSessionTimeout: getproc_got_int32 (pktp, vbp, sessData -> agentxSessTimeout); break; default: return GEN_ERR; } return NO_ERROR;}/****************************************************************************NAME: agentxSessionEntry_getPURPOSE: Routine to get information about an element in the agentx session listPARAMETERS: OIDC_T Last component of the object id leading to the leaf node in the MIB. This is usually the identifier for the particular attribute in the table. int Number of components in the unused part of the object identifier OIDC_T * Unused part of the object identifier SNMP_PKT_T * SNMP packet currently being processed. VB_T * Variable being processed. RETURNS: void****************************************************************************/void agentxSessionEntry_get (OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp){ bits32_t error; AX_SESSENT_T *sessEntry; /* * Find all the varbinds that share the same getproc and instance */ group_by_getproc_and_instance (pktp, vbp, tcount, tlist); if (tcount != agentxSessionEntry_INSTANCE_LEN) { for (; vbp; vbp = vbp -> vb_link) getproc_nosuchins (pktp, vbp); return; } if ((sessEntry = AxSessGetEntry (tcount, tlist))) { /* * Retrieve all the values from the same data structure */ for (; vbp; vbp = vbp -> vb_link) { if ((error = agentxSessionEntry_get_value (vbp->vb_ml.ml_last_match, pktp, vbp, sessEntry)) != NO_ERROR) getproc_error (pktp, vbp, error); } EBufferClean (&sessEntry->agentxSessDescr); if (sessEntry->agentxSessObjectID.num_components) SNMP_memory_free (sessEntry->agentxSessObjectID.component_list); SNMP_memory_free (sessEntry); } else for (; vbp; vbp = vbp -> vb_link) getproc_nosuchins (pktp, vbp);}/****************************************************************************NAME: agentxSessionEntry_nextPURPOSE: Routine to get information about the next element in the session listPARAMETERS: OIDC_T Last component of the object id leading to the leaf node in the MIB. This is usually the identifier for the particular attribute in the table. int Number of components in the unused part of the object identifier OIDC_T * Unused part of the object identifier SNMP_PKT_T * SNMP packet currently being processed. VB_T * Variable being processed.RETURNS: void****************************************************************************/void agentxSessionEntry_next (OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp){ AX_SESSENT_T *nextEntry = 0; bits32_t error; OIDC_T best_instance[agentxSessionEntry_INSTANCE_LEN]; /* * Find all the varbinds that share the same getproc and instance, * then get the next instance, if any. */ group_by_getproc_and_instance (pktp, vbp, tcount, tlist); if ((nextEntry = AxSessGetNext (tcount, tlist))) { /* * We found the next instance. * Get the values and set the instance for all the varbinds * for this row of this table. */ best_instance[0] = nextEntry->agentxConnIndex; best_instance[1] = nextEntry->agentxSessIndex; for (; vbp ; vbp = vbp -> vb_link) { if ((error = agentxSessionEntry_get_value (vbp -> vb_ml.ml_last_match, pktp, vbp, nextEntry)) == NO_ERROR) nextproc_next_instance (pktp, vbp, agentxSessionEntry_INSTANCE_LEN, best_instance); else nextproc_error (pktp, vbp, error); } EBufferClean (&nextEntry->agentxSessDescr); if (nextEntry->agentxSessObjectID.num_components) SNMP_memory_free (nextEntry->agentxSessObjectID.component_list); SNMP_memory_free (nextEntry); } else { /* * There's no more in this table */ for (; vbp ; vbp = vbp -> vb_link) nextproc_no_next (pktp, vbp); }}/****************************************************************************NAME: agentxSessionEntry_commitPURPOSE: Routine called at cleanup time to actually shutdown a session We don't want to do this before shutdown in case we need to undo itPARAMETERS:RETURNS: void****************************************************************************/static void agentxSessionEntry_commit(ptr_t value){ (void) envoy_ax_ma_cleanup_session_mth((bits32_t)((VB_T *)value)->vb_priv, ENVOY_AX_CLOSE_MANAGER);}/****************************************************************************NAME: agentxSessionEntry_undoPURPOSE: Try to undo any sets we've done to an agentx session struct.PARAMETERS: OIDC_T Last component of the object id leading to the leaf node in the MIB. This is usually the identifier for the particular attribute in the table. int Number of components in the unused part of the object identifier OIDC_T * Unused part of the object identifier SNMP_PKT_T * SNMP packet currently being processed. VB_T * Variable being processed.RETURNS: void****************************************************************************/static void agentxSessionEntry_undo(OIDC_T last_match, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp){switch(vbp->vb_ml.ml_last_match) { case LEAF_agentxSessionAdminStatus: /* reset the cleanup proc so we won't shutdown the session */ vbp->vb_free_priv = 0; undoproc_good(pktp, vbp); break; }return;}/****************************************************************************NAME: agentxSessionEntry_testPURPOSE: Routine to gather and test objects for setting a single row in the agentx subagent table. We validate all of the objects but will only set one of them. We do this because there is only one settable object: admin status. This routine tests whether there are more that one set requests for admin status in this packet and if there are whether they all agree. If they do not then the inconsistent value error is set.PARAMETERS: OIDC_T Last component of the object id leading to the leaf node in the MIB. This is usually the identifier for the particular attribute in the table. int Number of components in the unused part of the object identifier OIDC_T * Unused part of the object identifier SNMP_PKT_T * SNMP packet currently being processed. VB_T * Variable being processed. RETURNS: void****************************************************************************/void agentxSessionEntry_test (OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp){ AX_SESSENT_T *sessEntry; VB_T *group_vbp; int down_requests=0; int up_requests=0; /* * Validate instance: * Check instance length. * First sub-id must be non-zero. */ if (tcount != agentxSessionEntry_INSTANCE_LEN || tlist[0] == 0) { testproc_error (pktp, vbp, NO_CREATION); return; } if ((sessEntry = AxSessGetEntry (tcount, tlist)) == 0) { testproc_error (pktp, vbp, NO_CREATION); return; } /* * Find all the varbinds that share the same getproc and instance */ group_by_getproc_and_instance (pktp, vbp, tcount, tlist); /* * Now check each varbind * * If the last_match is anything other than SessionAdminStatus * then call testproc_error and return. * * Otherwise go through all the varbinds in the group and make * sure they agree on whether to go or go down. */ for (group_vbp = vbp; group_vbp; group_vbp = group_vbp -> vb_link) { switch (group_vbp -> vb_ml.ml_last_match) { case LEAF_agentxSessionAdminStatus: switch (VB_GET_INT32 (group_vbp)) { case VAL_agentxSessionAdminStatus_down: down_requests++; break; case VAL_agentxSessionAdminStatus_up: up_requests++; break; default: testproc_error (pktp, group_vbp, WRONG_VALUE); EBufferClean (&sessEntry->agentxSessDescr); if (sessEntry->agentxSessObjectID.num_components) SNMP_memory_free (sessEntry->agentxSessObjectID.component_list); SNMP_memory_free (sessEntry); return; } break; default: testproc_error (pktp, group_vbp, GEN_ERR); EBufferClean (&sessEntry->agentxSessDescr); if (sessEntry->agentxSessObjectID.num_components) SNMP_memory_free (sessEntry->agentxSessObjectID.component_list); SNMP_memory_free (sessEntry); return; } } if ((up_requests && !down_requests) || (down_requests && !up_requests)) { if ((VB_GET_INT32 (vbp)) == VAL_agentxSessionAdminStatus_up) setproc_all_bits (pktp, vbp); else testproc_good (pktp, vbp); for (group_vbp = vbp; group_vbp; group_vbp = group_vbp -> vb_link) { if (group_vbp != vbp) { testproc_good (pktp, group_vbp); setproc_all_bits (pktp, group_vbp); } } } else testproc_error (pktp, vbp, INCONSISTENT_VALUE); EBufferClean (&sessEntry->agentxSessDescr); if (sessEntry->agentxSessObjectID.num_components) SNMP_memory_free (sessEntry->agentxSessObjectID.component_list); SNMP_memory_free (sessEntry);}/****************************************************************************NAME: agentxSessionEntry_setPURPOSE: Try to perform set on Agentx Session data.PARAMETERS: OIDC_T Last component of the object id leading to the leaf node in the MIB. This is usually the identifier for the particular attribute in the table. int Number of components in the unused part of the object identifier OIDC_T * Unused part of the object identifier SNMP_PKT_T * SNMP packet currently being processed. VB_T * Variable being processed.RETURNS: void****************************************************************************/void agentxSessionEntry_set (OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp){ switch (vbp -> vb_ml.ml_last_match) { case LEAF_agentxSessionAdminStatus: { switch (VB_GET_INT32 (vbp)) { case VAL_agentxSessionAdminStatus_down: undoproc_set(pktp, vbp, agentxSessionEntry_undo); setproc_good(pktp, vbp); vbp->vb_free_priv = agentxSessionEntry_commit; vbp->vb_priv = (ptr_t)tlist[1]; break; case VAL_agentxSessionAdminStatus_up: undoproc_set(pktp, vbp, agentxSessionEntry_undo); setproc_good(pktp, vbp); break; default: setproc_error (pktp, vbp, COMMIT_FAILED); break; } } break; default: setproc_error (pktp, vbp, COMMIT_FAILED); return; }}/****************************************************************************NAME: agentxSession_getPURPOSE: Routine to get information about an element in the agentx session. This getproc is called to retrieve the scalar representing the time the session table was last changed.PARAMETERS: OIDC_T Last component of the object id leading to the leaf node in the MIB. This is usually the identifier for the particular attribute in the table. int Number of components in the unused part of the
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -