⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 v3mt_com.c

📁 wm PNE 3.3 source code, running at more than vxworks6.x version.
💻 C
📖 第 1 页 / 共 3 页
字号:
	    switch (value) {		case ETC_RS_ACTIVE:		case ETC_RS_NIS:		    if (create_row) {			testproc_error(pktp, tvbp, INCONSISTENT_VALUE);			return;			}		    break;		case ETC_RS_CAGO:		    if (create_row == 0) {			testproc_error(pktp, tvbp, INCONSISTENT_VALUE);			return;			}		    value = ETC_RS_ACTIVE;		    cago = 1;		    break;		case ETC_RS_CAWAIT:		    if (create_row == 0) {			testproc_error(pktp, tvbp, INCONSISTENT_VALUE);			return;			}		    value = ETC_RS_NREADY;		    break;		case ETC_RS_DESTROY:                    if (SNMP_Community_Get_Storage(&tempcommunity) >=                        ETC_STO_PERM) {                        testproc_error(pktp, tvbp, WRONG_VALUE);                        return;                        }		    break;		default:		    testproc_error(pktp, tvbp, WRONG_VALUE);		    return;	        }	    if (SNMP_Community_Get_Status(&tempcommunity) != ETC_RS_DESTROY) {	        SNMP_Community_Set_Status(&tempcommunity, (bits16_t)value);		rs_vbp = tvbp;                }	    break;        default:	    testproc_error(pktp, tvbp, GEN_ERR);	    return;        }    }/* The values are ok  */if (SNMP_Community_Get_Status(&tempcommunity) == ETC_RS_DESTROY) {    if (community != 0) {	ptret = SNMP_V3_COMM_DESTROY_TEST(pktp, vbp, community, 0);	if (ptret != NO_ERROR) {	    testproc_error(pktp, vbp, ptret);	    }	else {	    vbp->vb_priv	 = (PTR_T)community;	    vbp->vb_free_priv = commtable_destroy_cleanup;	    }        }    else {        /* We have a destroy request, but no target_addr so we don't	   have to do anything during the set and, if necessary, the	   undo phases so we mark vbp as set and undone */        setproc_all_bits(pktp, vbp);        }    return;    }/* do consistency checks */if (cn_vbp)    tempcommunity.flags |= ETC_COMM_NAME;if (sn_vbp)    tempcommunity.flags |= ETC_COMM_SEC_NAME;/* check on status */if ((rs_vbp) && (rs_vbp->value_u.v_number != ETC_RS_CAWAIT)) {    if ((((cago) ||          ((community) &&           (SNMP_Community_Get_Status(community) == ETC_RS_NREADY))) &&         ((tempcommunity.flags & ETC_COMM_ALL_FLAGS) != ETC_COMM_ALL_FLAGS))) {        testproc_error(pktp, rs_vbp, INCONSISTENT_VALUE);	return;        }    }else {    /* This check tries to advance a row's status of notReady to       notInService, provided the required conditions have been met:       1) CommunityName and SecurityName must both be set */        if ((SNMP_Community_Get_Status(&tempcommunity) == ETC_RS_NREADY) &&	((tempcommunity.flags & ETC_COMM_ALL_FLAGS) == ETC_COMM_ALL_FLAGS))        SNMP_Community_Set_Status(&tempcommunity, ETC_RS_NIS);    }/* See if anything actually changed, if it didn't we can mark   the vbp as done and not have to do any more work. */if (community) {    if ((SNMP_Community_Get_Name(community) !=         SNMP_Community_Get_Name(&tempcommunity)) &&        ((SNMP_Community_Get_Name_Len(community) !=          SNMP_Community_Get_Name_Len(&tempcommunity)) ||         MEMCMP_NULLOK(SNMP_Community_Get_Name(community),                       SNMP_Community_Get_Name(&tempcommunity),                       SNMP_Community_Get_Name_Len(community)))) {        cn_chg = 1;        }    if ((SNMP_Community_Get_Sec_Name(community) !=         SNMP_Community_Get_Sec_Name(&tempcommunity)) &&        ((SNMP_Community_Get_Sec_Name_Len(community) !=          SNMP_Community_Get_Sec_Name_Len(&tempcommunity)) ||         MEMCMP_NULLOK(SNMP_Community_Get_Sec_Name(community),                       SNMP_Community_Get_Sec_Name(&tempcommunity),                       SNMP_Community_Get_Sec_Name_Len(community)))) {        sn_chg = 1;        }    if ((SNMP_Community_Get_Con_ID(community) !=         SNMP_Community_Get_Con_ID(&tempcommunity)) &&        ((SNMP_Community_Get_Con_ID_Len(community) !=          SNMP_Community_Get_Con_ID_Len(&tempcommunity)) ||         MEMCMP_NULLOK(SNMP_Community_Get_Con_ID(community),                       SNMP_Community_Get_Con_ID(&tempcommunity),                       SNMP_Community_Get_Con_ID_Len(community)))) {        cid_chg = 1;        }    if ((SNMP_Community_Get_Con_Name(community) !=         SNMP_Community_Get_Con_Name(&tempcommunity)) &&        ((SNMP_Community_Get_Con_Name_Len(community) !=          SNMP_Community_Get_Con_Name_Len(&tempcommunity)) ||         MEMCMP_NULLOK(SNMP_Community_Get_Con_Name(community),                       SNMP_Community_Get_Con_Name(&tempcommunity),                       SNMP_Community_Get_Con_Name_Len(community)))) {        nm_chg = 1;        }    if ((SNMP_Community_Get_Tag(community) !=         SNMP_Community_Get_Tag(&tempcommunity)) &&        ((SNMP_Community_Get_Tag_Len(community) !=          SNMP_Community_Get_Tag_Len(&tempcommunity)) ||         MEMCMP_NULLOK(SNMP_Community_Get_Tag(community),                       SNMP_Community_Get_Tag(&tempcommunity),                       SNMP_Community_Get_Tag_Len(community)))) {        ct_chg = 1;        }        if ((cn_chg == 0) && (sn_chg == 0) &&	(cid_chg == 0) && (nm_chg == 0) &&        (ct_chg == 0) &&        (SNMP_Community_Get_Storage(community) ==         SNMP_Community_Get_Storage(&tempcommunity)) &&        (SNMP_Community_Get_Status(community) ==         SNMP_Community_Get_Status(&tempcommunity))) {        setproc_all_bits(pktp, vbp);	return;        }    }else {    cn_chg = 1;    sn_chg = 1;    cid_chg = 1;    nm_chg = 1;    ct_chg = 1;    }/* Because of how we do the backout stuff we always allocate a new   community and set it up */newcommunity = SNMP_Community_Create();if (newcommunity == 0) {    testproc_error(pktp, vbp, RESOURCE_UNAVAILABLE);    return;    }SNMP_Community_Set_Flags(newcommunity, SNMP_Community_Get_Flags(&tempcommunity));SNMP_Community_Set_Status(newcommunity,                          SNMP_Community_Get_Status(&tempcommunity));SNMP_Community_Set_Storage(newcommunity,                            SNMP_Community_Get_Storage(&tempcommunity));if (cn_chg) {    if (EBufferClone(&tempcommunity.comm_name, &newcommunity->comm_name) != 0) {        SNMP_Community_Destroy(newcommunity);	testproc_error(pktp, vbp, RESOURCE_UNAVAILABLE);	return;        }    }else{    EBufferPreLoad(BFL_IS_STATIC, &newcommunity->comm_name,		   SNMP_Community_Get_Name(community),		   SNMP_Community_Get_Name_Len(community));    }if (sn_chg) {    if (EBufferClone(&tempcommunity.comm_sec_name,                     &newcommunity->comm_sec_name) != 0) {        SNMP_Community_Destroy(newcommunity);	testproc_error(pktp, vbp, RESOURCE_UNAVAILABLE);	return;        }    }else{    EBufferPreLoad(BFL_IS_STATIC, &newcommunity->comm_sec_name,		   SNMP_Community_Get_Sec_Name(community),		   SNMP_Community_Get_Sec_Name_Len(community));    }EBufferClean(&newcommunity->comm_con_id);if (cid_chg) {    if (EBufferClone(&tempcommunity.comm_con_id,                     &newcommunity->comm_con_id) != 0) {        SNMP_Community_Destroy(newcommunity);	testproc_error(pktp, vbp, RESOURCE_UNAVAILABLE);	return;        }    }else{    EBufferPreLoad(BFL_IS_STATIC, &newcommunity->comm_con_id,		   SNMP_Community_Get_Con_ID(community),		   SNMP_Community_Get_Con_ID_Len(community));    }if (nm_chg) {    if (EBufferClone(&tempcommunity.comm_con_name,                     &newcommunity->comm_con_name) != 0) {        SNMP_Community_Destroy(newcommunity);	testproc_error(pktp, vbp, RESOURCE_UNAVAILABLE);	return;        }    }else{    EBufferPreLoad(BFL_IS_STATIC, &newcommunity->comm_con_name,		   SNMP_Community_Get_Con_Name(community),		   SNMP_Community_Get_Con_Name_Len(community));    }if (ct_chg) {    if (EBufferClone(&tempcommunity.comm_tag, &newcommunity->comm_tag) != 0) {        SNMP_Community_Destroy(newcommunity);	testproc_error(pktp, vbp, RESOURCE_UNAVAILABLE);	return;        }    }else{    EBufferPreLoad(BFL_IS_STATIC, &newcommunity->comm_tag,		   SNMP_Community_Get_Tag(community),		   SNMP_Community_Get_Tag_Len(community));    }/* if we are creating a new community we need to install it and run   the create test, if we are updating an old community we just run   the update test */if (community == 0) {    if (SNMP_Community_Install(newcommunity, comm_index, index_len) !=        ENVOY_ERR_NOERR) {	SNMP_Community_Destroy(newcommunity);	testproc_error(pktp, vbp, RESOURCE_UNAVAILABLE);	return;	}    ptret = SNMP_V3_COMM_CREATE_TEST(pktp, vbp, 0, newcommunity);    if (ptret != NO_ERROR) {        SNMP_Community_Deinstall(newcommunity);	SNMP_Community_Destroy(newcommunity);	testproc_error(pktp, vbp, ptret);	return;        }    vbp->vb_free_priv = commtable_create_cleanup;    }else {    ptret = SNMP_V3_COMM_UPDATE_TEST(pktp, vbp, community, newcommunity);    if (ptret != NO_ERROR) {	SNMP_Community_Destroy(newcommunity);	testproc_error(pktp, vbp, ptret);	return;	}    newcommunity->next = community;    vbp->vb_free_priv = commtable_update_cleanup;    }if (cago)    SNMP_Community_Set_Status(newcommunity, ETC_RS_CAGO);vbp->vb_priv = (PTR_T)newcommunity;return;}void  snmpCommunityEntry_set(OIDC_T      lastmatch,                         int         tcount,                         OIDC_T     *tlist,                         SNMP_PKT_T *pktp,                         VB_T       *vbp){SNMP_COMMUNITY_T *old_community, *new_community;bits16_t temp_value;EBUFFER_T temp_ebuf;new_community = (SNMP_COMMUNITY_T *)vbp->vb_priv;if (vbp->vb_free_priv == commtable_destroy_cleanup) {    SNMP_V3_COMM_DESTROY_SET(pktp, vbp, new_community, 0);    SNMP_Community_Deinstall(new_community);    vbp->vb_free_priv = commtable_set_cleanup;    undoproc_set(pktp, vbp, commtable_destroy_undo);    }else if (vbp->vb_free_priv == commtable_create_cleanup) {    if (SNMP_Community_Get_Status(new_community) == ETC_RS_CAGO)        SNMP_Community_Set_Status(new_community, ETC_RS_ACTIVE);    SNMP_V3_COMM_CREATE_SET(pktp, vbp, 0, new_community);    undoproc_set(pktp, vbp, commtable_create_undo);    }else {    old_community = new_community->next;    SNMP_V3_COMM_UPDATE_SET(pktp, vbp, old_community, new_community);    /* deal with status, storage and prefix information */    temp_value = SNMP_Community_Get_Flags(old_community);    SNMP_Community_Set_Flags(old_community,                              SNMP_Community_Get_Flags(new_community));    SNMP_Community_Set_Flags(new_community, temp_value);    temp_value = SNMP_Community_Get_Status(old_community);    SNMP_Community_Set_Status(old_community,                               SNMP_Community_Get_Status(new_community));    SNMP_Community_Set_Status(new_community, temp_value);    temp_value = SNMP_Community_Get_Storage(old_community);    SNMP_Community_Set_Storage(old_community,                                SNMP_Community_Get_Storage(new_community));    SNMP_Community_Set_Storage(new_community, temp_value);    if (SNMP_Community_Get_Tag(new_community) !=        SNMP_Community_Get_Tag(old_community)) {        MEMCPY(&temp_ebuf, &old_community->comm_tag, sizeof(EBUFFER_T));        MEMCPY(&old_community->comm_tag, &new_community->comm_tag,               sizeof(EBUFFER_T));        MEMCPY(&new_community->comm_tag, &temp_ebuf, sizeof(EBUFFER_T));        }    if (SNMP_Community_Get_Con_Name(new_community) !=        SNMP_Community_Get_Con_Name(old_community)) {        MEMCPY(&temp_ebuf, &old_community->comm_con_name, sizeof(EBUFFER_T));        MEMCPY(&old_community->comm_con_name, &new_community->comm_con_name,               sizeof(EBUFFER_T));        MEMCPY(&new_community->comm_con_name, &temp_ebuf, sizeof(EBUFFER_T));        }    if (SNMP_Community_Get_Con_ID(new_community) !=        SNMP_Community_Get_Con_ID(old_community)) {        MEMCPY(&temp_ebuf, &old_community->comm_con_id, sizeof(EBUFFER_T));        MEMCPY(&old_community->comm_con_id, &new_community->comm_con_id,               sizeof(EBUFFER_T));        MEMCPY(&new_community->comm_con_id, &temp_ebuf, sizeof(EBUFFER_T));        }    if (SNMP_Community_Get_Sec_Name(new_community) !=        SNMP_Community_Get_Sec_Name(old_community)) {        MEMCPY(&temp_ebuf, &old_community->comm_sec_name, sizeof(EBUFFER_T));        MEMCPY(&old_community->comm_sec_name, &new_community->comm_sec_name,               sizeof(EBUFFER_T));        MEMCPY(&new_community->comm_sec_name, &temp_ebuf, sizeof(EBUFFER_T));        }    if (SNMP_Community_Get_Name(new_community) !=        SNMP_Community_Get_Name(old_community)) {        MEMCPY(&temp_ebuf, &old_community->comm_name, sizeof(EBUFFER_T));        MEMCPY(&old_community->comm_name, &new_community->comm_name,               sizeof(EBUFFER_T));        MEMCPY(&new_community->comm_name, &temp_ebuf, sizeof(EBUFFER_T));        }    undoproc_set(pktp, vbp, commtable_update_undo);    }vbp->vb_free_priv = commtable_set_cleanup;setproc_good(pktp, vbp);return;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -