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

📄 v3mt_com.c

📁 wm PNE 3.3 source code, running at more than vxworks6.x version.
💻 C
📖 第 1 页 / 共 3 页
字号:
community = (SNMP_COMMUNITY_T *)(((VB_T *)commptr)->vb_priv);SNMP_V3_COMM_UPDATE_BACKOUT(community->next, community);SNMP_Community_Destroy(community);}/****************************************************************************NAME:  commtable_destroy_undoPURPOSE: This routine attempts to undo a previous destroy set.  It	  expects the old information to be pointed to by vb_priv and	  tries to reinstall it.  If we can't reinstall the	  community we leave the cleanup routine alone in order to	  get the FINISHED macro to run.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 processsed.	VB_T	   *	Variable being processed.RETURNS:  void****************************************************************************//*ARGSUSED*/static void  commtable_destroy_undo(OIDC_T 	 last_match,                         int		 tcount,                         OIDC_T	        *tlist,                         SNMP_PKT_T 	*pktp,                         VB_T		*vbp){SNMP_COMMUNITY_T *community;bits8_t name[ETC_COMMUNITY_MAX];ALENGTH_T name_len = ETC_COMMUNITY_MAX;/* assume things will go well and mark the vbp as done */undoproc_good(pktp, vbp);/* get the name info, no need to check as it's already been validated */oid_to_string(tcount, tlist, &name_len, name, 1);/* find the state block we saved and then reset the vb_priv info   so we don't have any accidents later */community      = (SNMP_COMMUNITY_T *)vbp->vb_priv;vbp->vb_priv = 0;if (SNMP_Community_Install(community, name, name_len) == ENVOY_ERR_NOERR) {#if defined(SNMP_V3_COMM_DESTROY_UNDO)    if (SNMP_V3_COMM_DESTROY_UNDO(pktp, vbp, 0, community) == 0) {        vbp->vb_free_priv = 0;	return;        }    else        SNMP_Community_Deinstall(community);#else    vbp->vb_free_priv = 0;    return;#endif    }SNMP_Community_Destroy(community);undoproc_error(pktp, vbp, UNDO_FAILED);return;}/****************************************************************************NAME:  commtable_create_undoPURPOSE:  This routine attempts to undo a previous create set.  It expects	  the new information to be pointed to by vb_priv and tries	  to deinstall and destroy the entry.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 processsed.	VB_T	   *	Variable being processed.RETURNS:  void****************************************************************************//*ARGSUSED*/static void  commtable_create_undo(OIDC_T	 	 last_match,			 int		 tcount,			 OIDC_T		*tlist,			 SNMP_PKT_T 	*pktp,			 VB_T		*vbp){SNMP_COMMUNITY_T *community;/* assume things will go well */undoproc_good(pktp, vbp);/* find the state block we saved and then reset the vb_priv info   so we don't have any accidents later */community = (SNMP_COMMUNITY_T *)vbp->vb_priv;vbp->vb_priv	  = 0;vbp->vb_free_priv = 0;#if defined(SNMP_V3_COMM_CREATE_UNDO)if (SNMP_V3_COMM_CREATE_UNDO(pktp, vbp, community, 0)) {    undoproc_error(pktp, vbp, UNDO_FAILED);    return;    }#endifSNMP_Community_Deinstall(community);SNMP_Community_Destroy(community);return;}/****************************************************************************NAME:  commtable_update_undoPURPOSE:  This routine attempts to undo a previous update set.  It expects	  the struct pointed to by vb_priv to contain the old information	  and a pointer to the new (installed) 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 processsed.	VB_T	   *	Variable being processed.RETURNS:  void****************************************************************************//*ARGSUSED*/static void  commtable_update_undo(OIDC_T		 last_match,                        int		 tcount,                        OIDC_T		*tlist,                        SNMP_PKT_T 	*pktp,                        VB_T		*vbp){SNMP_COMMUNITY_T *cur_community, *sav_community;/* assume things will go well */undoproc_good(pktp, vbp);/* find the state block we saved and then reset the vb_priv info   so we don't have any accidents later */sav_community = (SNMP_COMMUNITY_T *)vbp->vb_priv;vbp->vb_priv	  = 0;vbp->vb_free_priv = 0;cur_community = sav_community->next;#if defined(SNMP_V3_COMM_UPDATE_UNDO)if (SNMP_V3_COMM_UPDATE_UNDO(pktp, vbp, cur_community, sav_community)) {    undoproc_error(pktp, vbp, UNDO_FAILED);    SNMP_Community_Destroy(sav_community);    return;    }#endif/* swap the info from saved community back into current community,   we only need to move strings if the names are different finally   free the saved block */if (SNMP_Community_Get_Name(cur_community) !=    SNMP_Community_Get_Name(sav_community)) {    EBufferClean(&cur_community->comm_name);    MEMCPY(&cur_community->comm_name, &sav_community->comm_name,           sizeof(EBUFFER_T));    EBufferInitialize(&sav_community->comm_name);    }if (SNMP_Community_Get_Sec_Name(cur_community) !=    SNMP_Community_Get_Sec_Name(sav_community)) {    EBufferClean(&cur_community->comm_sec_name);    MEMCPY(&cur_community->comm_sec_name, &sav_community->comm_sec_name,           sizeof(EBUFFER_T));    EBufferInitialize(&sav_community->comm_sec_name);    }if (SNMP_Community_Get_Con_ID(cur_community) !=    SNMP_Community_Get_Con_ID(sav_community)) {    EBufferClean(&cur_community->comm_con_id);    MEMCPY(&cur_community->comm_con_id, &sav_community->comm_con_id,           sizeof(EBUFFER_T));    EBufferInitialize(&sav_community->comm_con_id);    }if (SNMP_Community_Get_Con_Name(cur_community) !=    SNMP_Community_Get_Con_Name(sav_community)) {    EBufferClean(&cur_community->comm_con_name);    MEMCPY(&cur_community->comm_con_name, &sav_community->comm_con_name,           sizeof(EBUFFER_T));    EBufferInitialize(&sav_community->comm_con_name);    }if (SNMP_Community_Get_Tag(cur_community) !=    SNMP_Community_Get_Tag(sav_community)) {    EBufferClean(&cur_community->comm_tag);    MEMCPY(&cur_community->comm_tag, &sav_community->comm_tag,           sizeof(EBUFFER_T));    EBufferInitialize(&sav_community->comm_tag);    }SNMP_Community_Set_Status(cur_community,                           SNMP_Community_Get_Status(sav_community));SNMP_Community_Set_Storage(cur_community,                            SNMP_Community_Get_Storage(sav_community));SNMP_Community_Set_Flags(cur_community,                          SNMP_Community_Get_Flags(sav_community));SNMP_Community_Destroy(sav_community);return;}/****************************************************************************NAME: commtable_set_cleanupPURPOSE: Free the saved community object and indicate that we are finished.PARAMETERS: 	ptr_t   A pointer to the vb that points to the community	        object that contained the update information,		cast as a ptr_tRETURNS: Nothing****************************************************************************/static void  commtable_set_cleanup(ptr_t commptr){if (((VB_T *)commptr)->vb_priv) {    if (((VB_T *)commptr)->undoproc == commtable_create_undo)        ((VB_T *)commptr)->vb_priv = 0;    else        SNMP_Community_Destroy(((VB_T *)commptr)->vb_priv);    }SNMP_V3_COMM_FINISHED();}void  snmpCommunityEntry_test(OIDC_T      lastmatch,                          int         tcount,                          OIDC_T     *tlist,                          SNMP_PKT_T *pktp,                          VB_T       *vbp){SNMP_COMMUNITY_T *community, tempcommunity, *newcommunity;sbits32_t value, ptret;int cago = 0, create_row = 0, cn_chg = 0, sn_chg = 0, cid_chg = 0;int nm_chg = 0, ct_chg = 0;ALENGTH_T nlen = 0;VB_T *tvbp, *cn_vbp = 0, *sn_vbp = 0, *rs_vbp = 0;bits8_t comm_index[ETC_COMMUNITY_MAX];bits8_t *tp;ALENGTH_T index_len = ETC_COMMUNITY_MAX;/* get the list of var binds that may go into this structure   then mark all the vbs except the first one as having been   tested, set and done.  This means that vbp is taking   responsibility for all of the other vbs in the row.  Then   mark vbp as having it's test started & done so we don't   have to worry about it later.  We can do this because   the routine will run to completion */group_by_getproc_and_instance(pktp, vbp, tcount, tlist);for(tvbp = vbp->vb_link; tvbp; tvbp = tvbp->vb_link)    setproc_all_bits(pktp, tvbp);testproc_good(pktp, vbp);/* gather the indexing information, the index will be of the form:   <index>   first we do some minor checks then we attempt to find the community */if ((tcount > ETC_COMMUNITY_MAX)                     ||    oid_to_string(tcount, tlist, &index_len, comm_index, 1)   ||    (index_len == 0) || ((bits32_t)index_len != (bits32_t) tcount)) {    testproc_error(pktp, vbp, NO_CREATION);    return;    }community = SNMP_Community_Lookup(comm_index, index_len);/* is the leaf writable, (if it's read only it isn't writable) */if (community != 0) {    if (SNMP_Community_Get_Storage(community) == ETC_STO_RONLY) {	testproc_error(pktp, vbp, NOT_WRITABLE);      	return;	}    MEMCPY(&tempcommunity, community, sizeof(SNMP_COMMUNITY_T));    }else {    SNMP_Community_Set_Defaults(&tempcommunity);    EBufferClean(&tempcommunity.comm_con_id);    EBufferPreLoad(BFL_IS_STATIC, &tempcommunity.comm_con_id,                   v3_my_engine->id, v3_my_engine->id_len);    create_row = 1;    }    for (tvbp = vbp; tvbp; tvbp = tvbp->vb_link) {    switch(tvbp->vb_ml.ml_last_match) {        case LEAF_snmpCommunityName:            nlen = EBufferUsed(&tvbp->value_u.v_string);            EBufferPreLoad(BFL_IS_STATIC, &tempcommunity.comm_name,                           EBufferStart(&tvbp->value_u.v_string), nlen);            cn_vbp = tvbp;            break;        case LEAF_snmpCommunitySecurityName:            nlen = EBufferUsed(&tvbp->value_u.v_string);            if ((nlen < MINSIZE_snmpCommunitySecurityName) ||                (nlen > MAXSIZE_snmpCommunitySecurityName)) {                testproc_error(pktp, tvbp, WRONG_LENGTH);                return;                }            EBufferPreLoad(BFL_IS_STATIC, &tempcommunity.comm_sec_name,                           EBufferStart(&tvbp->value_u.v_string), nlen);            sn_vbp = tvbp;            break;        case LEAF_snmpCommunityContextEngineID:            nlen = EBufferUsed(&tvbp->value_u.v_string);            if ((nlen < MINSIZE_snmpCommunityContextEngineID) ||                (nlen > MAXSIZE_snmpCommunityContextEngineID)) {                testproc_error(pktp, tvbp, WRONG_LENGTH);                return;                }            EBufferPreLoad(BFL_IS_STATIC, &tempcommunity.comm_con_id,                           EBufferStart(&tvbp->value_u.v_string), nlen);            break;        case LEAF_snmpCommunityContextName:            nlen = EBufferUsed(&tvbp->value_u.v_string);            if (nlen > MAXSIZE_snmpCommunityContextName) {                testproc_error(pktp, tvbp, WRONG_LENGTH);                return;                }            EBufferPreLoad(BFL_IS_STATIC, &tempcommunity.comm_con_name,                           EBufferStart(&tvbp->value_u.v_string), nlen);            break;        case LEAF_snmpCommunityTransportTag:            nlen = EBufferUsed(&tvbp->value_u.v_string);            if (nlen > MAXSIZE_snmpCommunityTransportTag) {                testproc_error(pktp, tvbp, WRONG_LENGTH);                return;                }            for (tp = EBufferStart(&tvbp->value_u.v_string);                 tp < EBufferNext(&tvbp->value_u.v_string);                 tp++) {                if (tag_whitespace(*tp)) {                    testproc_error(pktp, vbp, WRONG_VALUE);                    return;                    }                }            EBufferPreLoad(BFL_IS_STATIC, &tempcommunity.comm_tag,                           EBufferStart(&tvbp->value_u.v_string), nlen);            break;        case LEAF_snmpCommunityStorageType:	    value = tvbp->value_u.v_number;	    if ((value < ETC_STO_OTHER) ||		(value > ETC_STO_RONLY) ||                ((community != 0) && (value > ETC_STO_NONVOL)) ||		(SNMP_Community_Get_Storage(&tempcommunity) >                 ETC_STO_NONVOL)) {	        testproc_error(pktp, tvbp, WRONG_VALUE);		return;	        }	    SNMP_Community_Set_Storage(&tempcommunity, (bits16_t)value);	    break;        case LEAF_snmpCommunityStatus:	    value = tvbp->value_u.v_number;

⌨️ 快捷键说明

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