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

📄 view_rts.c

📁 wm PNE 3.3 source code, running at more than vxworks6.x version.
💻 C
📖 第 1 页 / 共 2 页
字号:
	OIDC_T      *   Space for the returned name	int             length of the space	  RETURNS: int   the number of ids in the name 0 on failure****************************************************************************/int  SNMP_View_Name(VIEWLEAF_T *view,		 bits16_t   *indx,		 OIDC_T     *oidc,		 int         len){int i;if (view == 0)    return(0);*indx = view->index;if (view->subtree.num_components <= len) {    for (i = view->subtree.num_components - 1; i >= 0; i--)        oidc[i] = view->subtree.component_list[i];    }return(view->subtree.num_components);}/****************************************************************************\NOMANUALNAME: SNMP_View_DeinstallPURPOSE: Given an index and subtree remove the named view from the area.PARAMETERS: 	 bits16_t   index	 OIDC_T   * component list of the subtree	 int	    length of the component listRETURNS: int	Success = 0, failure = 1****************************************************************************/int  SNMP_View_Deinstall(bits16_t   indx,		      OIDC_T    *oidc,		      int        oidclen){VIEWINDEX_T *vindex, **ipp;VIEWLEAF_T  **vpp;/* step through the index list until we find the correct one, they are    ordered so if we find an index greater than ours, ours doesn't exist   and we are done */ipp = &viewroot;while(1) {    if ((*ipp == 0) || ((*ipp)->index > indx))	return(-1);    if ((*ipp)->index == indx)        break;    ipp = &((*ipp)->next);    }vindex = *ipp;/* find the requested view in the mask list and remove it */if (remove_view_from_masks(vindex, oidc, oidclen))    return(-1);/* find the requested view in the lexi list.  the lexi list is ordered by   oid in standard lexi order. */for (vpp = &(vindex->lexilist);    oidcmp2(oidclen, oidc, (*vpp)->subtree.num_components,	    (*vpp)->subtree.component_list) != 0;     vpp = &((*vpp)->lexinext))    /* no body to the for loop */    ;/* unlink the view */*vpp = (*vpp)->lexinext;/* if there are no more views for this index we remove it as well */if (vindex->masklist == 0) {    *ipp = vindex->next;    SNMP_memory_free(vindex);    }return(0);}/****************************************************************************\NOMANUALNAME: SNMP_View_LookupPURPOSE: Given a view index and id (object id) find the corresponding	 VIEWLEAF_TPARAMETERS: 	bits16_t	The index for the view.	OIDC_T    *	The id to find a VIEWLEAF_T for.	int		The length of the nameRETURNS: VIEWLEAF_T *   The view structure corresponding to the name.			On error (VIEWLEAF_T *) 0;****************************************************************************/VIEWLEAF_T *  SNMP_View_Lookup(bits16_t  indx,		   OIDC_T   *oidc,		   int	     oidclen){VIEWINDEX_T *vindex;VIEWLEAF_T *view;vindex = viewroot;while(1) {    if ((vindex == 0) || (vindex->index > indx))	return(0);    if (vindex->index == indx)	break;    vindex = vindex->next;    }view = vindex->masklist;while((view != 0) && (oidclen <= view->subtree.num_components)){    if (oidcmp2(oidclen, oidc, view->subtree.num_components,	       view->subtree.component_list) == 0)	return(view);    view = view->masknext;    }return(0);}#endif /* #if (INSTALL_ENVOY_SNMP_RFC1445_VIEWS) */#if (INSTALL_ENVOY_SNMP_RFC2275_VIEWS)/* We use these functions if rfc2275 is installed, we   have another set for use with rfc14455, see above *//********************************************************************************* SNMP_View_2275_Install - install the specified <view> in the view database* SYNOPSIS** \cs* int SNMP_View_2275_Install *     (*     VIEWLEAF_T *  view, *     bits8_t    *  name, *     ALENGTH_T    length *     )* \ce** DESCRIPTION** This routine installs the specified <view> in the view database with the * specified index. specified by name which is <length> bytes long.** \&NOTE: This routine applies only to RFC 2275 view tables.** Parameters:* \is* \i <*view>* Specify a 'VIEWLEAF_T' structure.* \i <*name>* Specify the index.* \i <length>* Specify the length in bytes of the index.* \ie** RETURNS: If successful, this routine returns 0. If an allocation failure * occurs, if the length is 0, if the length exceeds the maximum, or if the call * to SNMP_View_2275_Install() fails, it returns -1.** ERRNO: N/A** SEE ALSO: SNMP_View_Create(), SNMP_View_Delete(), SNMP_View_2275_Deinstall(), * SNMP_View_2275_Install(), SNMP_View_2275_Lookup(), SNMP_View_2275_Name()*/int  SNMP_View_2275_Install(VIEWLEAF_T *view,			 bits8_t    *view_name,			 ALENGTH_T   vlen){VIEWINDEX_T **ipp, *vindex;VIEWLEAF_T **vpp;int order;if ((vlen == 0) || (vlen > ETC_VIEW_NAME_MAX))    return(-1);/* walk through the index list, trying to find our index name */for(ipp = &viewroot; *ipp; ipp = &((*ipp)->next)) {    if ((*ipp)->name_len >= vlen)        break;    }for(; *ipp; ipp = &((*ipp)->next)) {    if (((*ipp)->name_len != vlen) ||        (MEMCMP((*ipp)->name, view_name, vlen) >= 0))        break;    }if ((*ipp == 0) || ((*ipp)->name_len != vlen) ||    MEMCMP((*ipp)->name, view_name, vlen)) {    /* if we didn't find an index create one, link it into       the index list, and attache the view to it. */    vindex = (VIEWINDEX_T *)SNMP_memory_alloc(sizeof(VIEWINDEX_T) + vlen);    if (vindex == 0)        return(-1);    vindex->name = ((bits8_t *)vindex) + sizeof(VIEWINDEX_T);    MEMCPY(vindex->name, view_name, vlen);    vindex->name_len = vlen;	    vindex->next = *ipp;    *ipp = vindex;        vindex->lexilist  = view;    vindex->masklist  = view;    }else {    /* the index already exists, just link the view into the       mask & lexi lists */    vindex = *ipp;    /* install the view in the masklist */    if (install_view_in_masks(vindex, view))        return(-1);    /* install the view in the lexilist */    for(vpp = &(vindex->lexilist); *vpp; vpp = &((*vpp)->lexinext)) {        if (view->subtree.num_components > (*vpp)->subtree.num_components)	    continue;	if (view->subtree.num_components < (*vpp)->subtree.num_components)	    break;	order = oidcmp2(view->subtree.num_components,			view->subtree.component_list,			(*vpp)->subtree.num_components,			(*vpp)->subtree.component_list);	if (order == -1)	    break;	if (order == 0)	    return(-1);        }    view->lexinext = *vpp;    *vpp = view;    }/* attach the backpointer to the index leaf for admin purposes */view->parent = vindex;return(0);}/********************************************************************************* SNMP_View_2275_Name - extract the name from indexing information for a view* SYNOPSIS** \cs* void SNMP_View_2275_Name *     (*     VIEWLEAF_T *  view, *     bits8_t    *  name, *     ALENGTH_T  *  length*     )* \ce** DESCRIPTION** This routine extracts the name portion from a view\抯 indexing information. * After this routine completes, check the values in the name and length fields.** \&NOTE: This routine applies only to RFC 2275 view tables.** Parameters:* \is* \i <*view>* Specify a 'VIEWLEAF_T' structure.* \i <*name>* Specify the index of a 'VIEWLEAF_T' structure.* \i <*length>* On input, specifies the length in bytes of the available space in <name>. On * output, specifies the length required for the name.* \ie** RETURNS: None.** ERRNO: N/A** SEE ALSO: SNMP_View_2275_Lookup(), SNMP_View_2275_Name(), SNMP_View_Next()*/void  SNMP_View_2275_Name(VIEWLEAF_T *view,		      bits8_t    *name,		      ALENGTH_T  *name_len){if (view->parent) {    if (*name_len >= view->parent->name_len) {        MEMCPY(name, view->parent->name, view->parent->name_len);        }    *name_len = view->parent->name_len;    }else    *name_len = 0;return;}/****************************************************************************\NOMANUALNAME: SNMP_View_2275_Full_NamePURPOSE: Given a view get it's full name (<len> <name> <len> <oidc>)PARAMETERS: 	VIEWEAF_T   *   A pointer to the view	OIDC_T      *   Space for the returned name	int             length of the space	  RETURNS: int   the number of ids in the name 0 on failure****************************************************************************/int  SNMP_View_2275_Full_Name(VIEWLEAF_T *view,			   OIDC_T     *oidc,			   int         len){int i, j, k;bits8_t *bufp;OIDC_T *name_oid;if ((view == 0) || (view->parent == 0))    return(0);i = view->parent->name_len;j = view->subtree.num_components;k = 2 + i + j;if (k <= len) {    bufp = view->parent->name;    *oidc++ = i;    for(; i; i--)        *oidc++ = *bufp++;    name_oid = view->subtree.component_list;    *oidc++ = j;    for(; j; j--)        *oidc++ = *name_oid++;    }return(k);}/********************************************************************************* SNMP_View_2275_Deinstall - remove a specified <view> from the view database* SYNOPSIS** \cs* void SNMP_View_2275_Deinstall*     (*     VIEWLEAF_T *  view *     )* \ce** DESCRIPTION** This routine removes a specified view from the view database. Afterward, the * view is no longer be visible to Envoy. When you delete a view, call * SNMP_View_Delete() to free any space associated with <view>.** \&NOTE: This routine applies only to RFC 2275 view tables.** Parameters:* \is* \i <*view>* Specify a 'VIEWLEAF_T' structure.* \ie** RETURNS: None.** ERRNO: N/A** SEE ALSO: SNMP_View_Delete(), SNMP_View_2275_Install(), * SNMP_View_2275_Lookup(), SNMP_View_2275_Name()*/void  SNMP_View_2275_Deinstall(VIEWLEAF_T *in_view){VIEWINDEX_T *our_index, **ipp;VIEWLEAF_T  **vpp;our_index = in_view->parent;if (our_index == 0)    return;/* if our structure is in the mask list clean it up */for(vpp = &(our_index->masklist); *vpp; vpp = &(*vpp)->masknext) {    if (*vpp == in_view) {        *vpp = in_view->masknext;	break;        }    }/* if our structure is in the lexi list clean it up */for(vpp = &(our_index->lexilist); *vpp; vpp = &(*vpp)->lexinext) {    if (*vpp == in_view) {        *vpp = in_view->lexinext;	break;        }    }/* clear the parent info */in_view->parent = 0;/* see if we need to remove the index as well, as we add or remove   items from both mask and lexi lists at the same time the two   lists must contain the same views only the order is different   so only need to check one list to see if this index is empty */if (our_index->masklist == 0){    for(ipp = &viewroot; *ipp; ipp = &(*ipp)->next){        if (*ipp == our_index) {	    *ipp = our_index->next;	    SNMP_memory_free(our_index);	    break;	    }        }    }return;}/********************************************************************************* SNMP_View_2275_Lookup - find the specified view* SYNOPSIS** \cs* VIEWLEAF_T * SNMP_View_2275_Lookup *     (*     bits8_t      *  name, *     ALENGTH_T       v_length, *     OIDC_T       *  subtree, *     int             s_length *     )* \ce** DESCRIPTION** This routine finds the specified view by name.** \&NOTE: This routine applies only to RFC 2275 view tables.** Parameters:* \is* \i <*name>* Specify the index of a 'VIEWLEAF_T' structure.* \i <v_length>* Specify the length in bytes of the name.* \i <*subtree>* Specify the subtree.* \i <s_length>* Specify the length in bytes of the subtree.* \ie** RETURNS: If successful, this routine returns a pointer to the view. * Otherwise, it returns a 0 pointer.** ERRNO: N/A** SEE ALSO: SNMP_View_2275_Install(), SNMP_View_2275_Name(), * SNMP_View_2275_Name()*/VIEWLEAF_T *  SNMP_View_2275_Lookup(bits8_t   *view_name,			ALENGTH_T  vlen,			OIDC_T    *oidc,			int	   oidclen){VIEWINDEX_T *vindex;VIEWLEAF_T *view;for(vindex = viewroot; ; vindex = vindex->next) {    if ((vindex == 0) || (vindex->name_len > vlen))        return(0);    if ((vindex->name_len == vlen) &&	(MEMCMP(view_name, vindex->name, vlen) == 0))        break;    }view = vindex->masklist;while((view != 0) && (oidclen <= view->subtree.num_components)){    if (oidcmp2(oidclen, oidc, view->subtree.num_components,	       view->subtree.component_list) == 0)	return(view);    view = view->masknext;    }return(0);}#endif /* #if (INSTALL_ENVOY_SNMP_RFC2275_VIEWS) */

⌨️ 快捷键说明

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