📄 v3cmpnt.c
字号:
**/extern OBJ_ID_T objid_v3snmp_communitymib_node;extern MIBNODE_T v3snmp_communitymib_node;void v3_add_v3_mibs (void){ MIBNODE_T *rnode; int status; /* RFC2571.MIB */ status = Add_Node_From_Root(&mib_root_node, &objid_v3snmp_engine_node, &v3snmp_engine_node, &rnode); /* RFC2572.MIB */ status = Add_Node_From_Root(&mib_root_node, &objid_v3snmp_mpdmib_node, &v3snmp_mpdmib_node, &rnode); /* RFC2574.MIB */ status = Add_Node_From_Root(&mib_root_node, &objid_v3usm_root_node, &v3usm_root_node, &rnode); #if INSTALL_SNMP_V3_DIFFIE_HELLMAN /* RFC2786.MIB */ status = Add_Node_From_Root(&mib_root_node, &objid_v3usm_dh_node, &v3usm_dh_node, &rnode);#endif /* INSTALL_SNMP_V3_DIFFIE_HELLMAN */ /* RFC2575.MIB */ status = Add_Node_From_Root(&mib_root_node, &objid_v3vacm_access_root_node, &v3vacm_access_root_node, &rnode); status = Add_Node_From_Root(&mib_root_node, &objid_v3vacm_context_root_node, &v3vacm_context_root_node, &rnode); status = Add_Node_From_Root(&mib_root_node, &objid_v3vacm_group_root_node, &v3vacm_group_root_node, &rnode); #if INSTALL_ENVOY_SNMP_V3_TARGET /* RFC2573.MIB */ status = Add_Node_From_Root(&mib_root_node, &objid_v3snmp_targetmib_node, &v3snmp_targetmib_node, &rnode);#if INSTALL_ENVOY_SNMP_V3_NOTIFY status = Add_Node_From_Root(&mib_root_node, &objid_v3snmp_notifymib_node, &v3snmp_notifymib_node, &rnode);#endif /* #if INSTALL_ENVOY_SNMP_V3_NOTIFY */#if INSTALL_ENVOY_SNMP_V3_PROXY status = Add_Node_From_Root(&mib_root_node, &objid_v3snmp_proxymib_node, &v3snmp_proxymib_node, &rnode);#endif /* #if INSTALL_ENVOY_SNMP_V3_PROXY */#if INSTALL_ENVOY_SNMP_COEXISTENCE /* RFC2576.MIB */ status = Add_Node_From_Root(&mib_root_node, &objid_v3snmp_communitymib_node, &v3snmp_communitymib_node, &rnode);#endif /* #if INSTALL_ENVOY_SNMP_COEXISTENCE */#endif /* #if INSTALL_ENVOY_SNMP_V3_TARGET */}void snmpCleanUserTable (void) { MIBNODE_T *rnode; SNMP_USER_T *user; ENVOY_SNMP_GET_WRITE_LOCK(SNMP_CoarseLock); /* First, clean out the user table */ while ((user = SNMP_User_Next_User (NULL)) != NULL) { SNMP_User_Deinstall (user); SNMP_User_Destroy (user); } /* Then, remove the dynamically added node for the user table from the MIB tree. */ if ((rnode = Remove_Node_From_Root(&mib_root_node, &objid_v3usm_root_node)) != &v3usm_root_node) ; /* Do we need to do something here for the Diffie-Hellman objects? */ ENVOY_SNMP_RELEASE_WRITE_LOCK(SNMP_CoarseLock); } void snmpCleanSecurityToGroupTable (void) { MIBNODE_T *rnode; SNMP_GROUP_T *group; ENVOY_SNMP_GET_WRITE_LOCK(SNMP_CoarseLock); /* First, clean out the group table */ while ((group = SNMP_Group_Next_Group (NULL)) != NULL) { SNMP_Group_Deinstall (group); SNMP_Group_Destroy (group); } /* Then, remove the dynamically added node for the group table from the MIB tree. */ if ((rnode = Remove_Node_From_Root(&mib_root_node, &objid_v3vacm_group_root_node)) != &v3vacm_group_root_node) ; ENVOY_SNMP_RELEASE_WRITE_LOCK(SNMP_CoarseLock); } void snmpCleanAccessTable (void) { MIBNODE_T *rnode; SNMP_ACCESS_T *access; ENVOY_SNMP_GET_WRITE_LOCK(SNMP_CoarseLock); /* First, clean out the group table */ while ((access = SNMP_V3_Access_Next_Access (NULL)) != NULL) { SNMP_V3_Access_Deinstall (access); SNMP_V3_Access_Destroy (access); } /* Then, remove the dynamically added node for the access table from the MIB tree. */ if ((rnode = Remove_Node_From_Root(&mib_root_node, &objid_v3vacm_access_root_node)) != &v3vacm_access_root_node) ; ENVOY_SNMP_RELEASE_WRITE_LOCK(SNMP_CoarseLock); } void snmpCleanContextTable (void) { MIBNODE_T *rnode; SNMP_CONTEXT_T *context = v3_context_root; ENVOY_SNMP_GET_WRITE_LOCK(SNMP_CoarseLock); /* First, clean out the context table */ while (context != 0) { SNMP_V3_Context_Remove (context->name, context->length); context = v3_context_root; } /* Then, remove the dynamically added node for the context table from the MIB tree. */ if ((rnode = Remove_Node_From_Root(&mib_root_node, &objid_v3vacm_context_root_node)) != &v3vacm_context_root_node) ; ENVOY_SNMP_RELEASE_WRITE_LOCK(SNMP_CoarseLock); } void snmpCleanV3Tree (void) { MIBNODE_T *rnode; ENVOY_SNMP_GET_WRITE_LOCK(SNMP_CoarseLock); if ((rnode = Remove_Node_From_Root(&mib_root_node, &objid_v3snmp_engine_node)) != &v3snmp_engine_node) ; if ((rnode = Remove_Node_From_Root(&mib_root_node, &objid_v3snmp_mpdmib_node)) != &v3snmp_mpdmib_node) ; ENVOY_SNMP_RELEASE_WRITE_LOCK(SNMP_CoarseLock); ENVOY_SNMP_FREE_LOCK_TAG (SNMP_V3_Boots_Lock, ENVOY_V3BOOTSLOCK_TAG); SNMP_memory_free(v3_my_engine); v3_my_engine = 0; }#if INSTALL_ENVOY_SNMP_V3_TARGETvoid snmpCleanTargetTables (void) { MIBNODE_T *rnode; SNMP_TARGET_ADDR_T *target; SNMP_TARGET_PARAMS_T *params; ENVOY_SNMP_GET_WRITE_LOCK(SNMP_CoarseLock); /* First, clean out the target addr table */ while ((target = SNMP_Target_Addr_Next_Addr (NULL)) != NULL) { SNMP_Target_Addr_Deinstall (target); SNMP_Target_Addr_Destroy (target); } /* Then, clean out the target params table */ while ((params = SNMP_Target_Params_Next_Params (NULL)) != NULL) { SNMP_Target_Params_Deinstall (params); SNMP_Target_Params_Destroy (params); } /* Then, remove the dynamically added node for the target tables from the MIB tree. */ if ((rnode = Remove_Node_From_Root(&mib_root_node, &objid_v3snmp_targetmib_node)) != &v3snmp_targetmib_node) ; ENVOY_SNMP_RELEASE_WRITE_LOCK(SNMP_CoarseLock); }#if INSTALL_ENVOY_SNMP_V3_NOTIFYvoid snmpCleanNotifyTables (void) { MIBNODE_T *rnode; SNMP_NOTIFY_T *notify; SNMP_NOTIFY_FILTER_PROFILE_T *notify_profile; SNMP_NOTIFY_FILTER_T *notify_filter; ENVOY_SNMP_GET_WRITE_LOCK(SNMP_CoarseLock); /* First, clean out the notify table */ while ((notify = SNMP_Notify_Next_Notify (NULL)) != NULL) { SNMP_Notify_Deinstall (notify); SNMP_Notify_Destroy (notify); } /* Then, clean out the notify filter profile table */ while ((notify_profile = SNMP_Notify_Profile_Next_Profile (NULL)) != NULL) { SNMP_Notify_Profile_Deinstall (notify_profile); SNMP_Notify_Profile_Destroy (notify_profile); } /* Then, clean out the notify profile table */ while ((notify_filter = SNMP_Notify_Filter_Next_Filter (NULL)) != NULL) { SNMP_Notify_Filter_Deinstall (notify_filter); SNMP_Notify_Filter_Destroy (notify_filter); } /* Then, remove the dynamically added node for the notify tables from the MIB tree. */ if ((rnode = Remove_Node_From_Root(&mib_root_node, &objid_v3snmp_notifymib_node)) != &v3snmp_notifymib_node) ; ENVOY_SNMP_RELEASE_WRITE_LOCK(SNMP_CoarseLock); ENVOY_SNMP_FREE_LOCK_TAG (SNMP_V3_Retrans_Lock, ENVOY_V3RETRANSLOCK_TAG); }#endif /* #if INSTALL_ENVOY_SNMP_V3_NOTIFY */#if INSTALL_ENVOY_SNMP_COEXISTENCEvoid snmpCleanCommunityTable (void) { MIBNODE_T *rnode; SNMP_COMMUNITY_T *community; ENVOY_SNMP_GET_WRITE_LOCK(SNMP_CoarseLock); /* First, clean out the community table */ while ((community = SNMP_Community_Next_Community (NULL)) != NULL) { SNMP_Community_Deinstall (community); SNMP_Community_Destroy (community); } /* Then, remove the dynamically added node for the community table from the MIB tree. */ if ((rnode = Remove_Node_From_Root(&mib_root_node, &objid_v3snmp_communitymib_node)) != &v3snmp_communitymib_node) ; ENVOY_SNMP_RELEASE_WRITE_LOCK(SNMP_CoarseLock); }#endif /* #if INSTALL_ENVOY_SNMP_COEXISTENCE */#if INSTALL_ENVOY_SNMP_V3_PROXYvoid snmpCleanProxyTable (void) { MIBNODE_T *rnode; SNMP_PROXY_T *proxy; ENVOY_SNMP_GET_WRITE_LOCK(SNMP_CoarseLock); /* First, clean out the proxy table */ while ((proxy = SNMP_Proxy_Next_Proxy (NULL)) != NULL) { SNMP_Proxy_Deinstall (proxy); SNMP_Proxy_Destroy (proxy); } /* Then, remove the dynamically added node for the proxy table from the MIB tree. */ if ((rnode = Remove_Node_From_Root(&mib_root_node, &objid_v3snmp_proxymib_node)) != &v3snmp_proxymib_node) ; ENVOY_SNMP_RELEASE_WRITE_LOCK(SNMP_CoarseLock); }#endif /* #if INSTALL_ENVOY_SNMP_V3_PROXY */#endif /* #if INSTALL_ENVOY_SNMP_V3_TARGET */#if INSTALL_SNMP_V3_DIFFIE_HELLMAN/****************************************************************************NAME: SNMP_DH_randPURPOSE: This routine mixes a random value with the current pseudo- random number generator (PRNG) state, insuring some measure of unpredictability in random number generation.PARAMETERS: <None> RETURNS: 1 for success; 0 if error****************************************************************************/int snmpDHrand (void){ bits8_t *seed = 0; int seedSize, status = 0; BIGNUM *bn1, *bn2, *result; bn1 = BN_new(); bn2 = BN_new(); result = BN_new(); /* Calculate <tickCount> ^ <an arbitrary prime> to generate the seed */ if ((BN_set_word (bn1, tickGet()) == 0) || (BN_set_word (bn2, DH_SEED_PRIME) == 0)) goto EXIT; if (BN_exp (result, bn1, bn2, SNMP_DH_bnCtx) == 0) goto EXIT; /* Limit the size. Allocate the memory. Convert to bits. */ if ((seedSize = BN_num_bytes (result)) == 0) goto EXIT; if (seedSize > DH_MAX_SEED_BYTES) goto EXIT; seedSize = seedSize > DH_MAX_SEED_BYTES ? DH_MAX_SEED_BYTES : seedSize; if ((seed = SNMP_memory_alloc (seedSize)) == 0) goto EXIT; if ((BN_bn2bin (result, seed)) == 0) goto EXIT; RAND_seed (seed, seedSize); status = 1;EXIT: BN_free (bn1); BN_free (bn2); BN_clear (result); BN_free (result); if (seed) SNMP_memory_free (seed); return status;}#endif /* INSTALL_SNMP_V3_DIFFIE_HELLMAN */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -