📄 vmth2275.c
字号:
SNMP_View_Delete(newview); testproc_error(pktp, vbp, ptret); return; } newview->lexinext = view; vbp->vb_free_priv = viewtable_update_cleanup; }if (cago) SNMP_View_Set_Status(newview, ETC_RS_CAGO);vbp->vb_priv = (PTR_T)newview;return;}/****************************************************************************NAME: viewtable_setPURPOSE: Perform the set of the view, by the time we get here the viewleaf has been built and filled in by the test function. If the tree node points to the viewleaf then, this was a creation request and we already installed the leaf. We do need to reset the vb_priv and vb_free_priv pointers so we won't free the data later. Otherwise we need to install the new leaf and save a pointer to the old leaf in case an undo is required.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 viewtable_set(OIDC_T last_match, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp){VIEWLEAF_T *old_view, *new_view;bits16_t temp_value;EBUFFER_T temp_ebuf;new_view = (VIEWLEAF_T *)vbp->vb_priv;if (vbp->vb_free_priv == viewtable_destroy_cleanup) { SNMP_VIEW_2275_DESTROY_SET(pktp, vbp, new_view, 0); SNMP_View_2275_Deinstall(new_view); vbp->vb_free_priv = viewtable_set_cleanup; undoproc_set(pktp, vbp, viewtable_destroy_undo); }else if (vbp->vb_free_priv == viewtable_create_cleanup) { if (SNMP_View_Get_Status(new_view) == ETC_RS_CAGO) SNMP_View_Set_Status(new_view, ETC_RS_ACTIVE); SNMP_VIEW_2275_CREATE_SET(pktp, vbp, 0, new_view); undoproc_set(pktp, vbp, viewtable_create_undo); }else { old_view = new_view->lexinext; SNMP_VIEW_2275_UPDATE_SET(pktp, vbp, old_view, new_view); /* deal with type, status and storage information */ temp_value = SNMP_View_Get_Type(old_view); SNMP_View_Set_Type(old_view, SNMP_View_Get_Type(new_view)); SNMP_View_Set_Type(new_view, temp_value); temp_value = SNMP_View_Get_Status(old_view); SNMP_View_Set_Status(old_view, SNMP_View_Get_Status(new_view)); SNMP_View_Set_Status(new_view, temp_value); temp_value = SNMP_View_Get_StorageType(old_view); SNMP_View_Set_StorageType(old_view, SNMP_View_Get_StorageType(new_view)); SNMP_View_Set_StorageType(new_view, temp_value); /* deal with the string info, if the two pointers are equal we don't need to do anything, otherwise we need to copy the buffer info around */ if (EBufferStart(&old_view->mask) != EBufferStart(&new_view->mask)) { MEMCPY(&temp_ebuf, &old_view->mask, sizeof(EBUFFER_T)); MEMCPY(&old_view->mask, &new_view->mask, sizeof(EBUFFER_T)); MEMCPY(&new_view->mask, &temp_ebuf, sizeof(EBUFFER_T)); } undoproc_set(pktp, vbp, viewtable_update_undo); }vbp->vb_free_priv = viewtable_set_cleanup;setproc_good(pktp, vbp);return;}/****************************************************************************NAME: get_view_dataPURPOSE: install data into a series of vbps. this routine will be called from viewtable_get and viewtable_next, they will have already found the proper view we just find the right field in that view and stuff it into the vbpPARAMETERS: SNMP_PKT_T * SNMP packet currently being processed. VB_T * Variable being processed. VIEWLEAF_T * the view to extract inforamtion fromRETURNS: void****************************************************************************/static void get_view_data(SNMP_PKT_T *pktp, VB_T *vbp, VIEWLEAF_T *view){for(; vbp; vbp = vbp->vb_link) { switch(vbp->vb_ml.ml_last_match) { case LM_viewMask: getproc_got_string(pktp, vbp, SNMP_View_Get_MaskLen(view), SNMP_View_Get_Mask(view), 0, VT_STRING); break; case LM_viewType: getproc_got_int32(pktp, vbp, SNMP_View_Get_Type(view)); break; case LM_viewStorageType: getproc_got_int32(pktp, vbp, SNMP_View_Get_StorageType(view)); break; case LM_viewStatus: getproc_got_int32(pktp, vbp, SNMP_View_Get_Status(view)); break; } }return;}/****************************************************************************NAME: viewtable_getPURPOSE: Find the appropriate entry in the view table and attach information from it to the vbp using the getproc_got_* functions. If we can't find an entry indicate that by calling getproc_nosuchins.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 viewtable_get(OIDC_T last_match, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp){VIEWLEAF_T *view = 0; bits8_t name[ETC_VIEW_NAME_MAX];ALENGTH_T namelen = ETC_VIEW_NAME_MAX;int oidclen;group_by_getproc_and_instance(pktp, vbp, tcount, tlist);/* The index will be of the form <len> <name> <len> <subtree> first we see if the name will work then we try and find the view */if ((tcount > 1) && (oid_to_string((int)(tlist[0] + 1), tlist, &namelen, name, 0) == 0)) { oidclen = (int) tlist[namelen+1]; if ((OIDC_T)oidclen + (OIDC_T)namelen + 2 == (OIDC_T)tcount) view = SNMP_View_2275_Lookup(name, namelen, tlist + namelen + 2, oidclen); }if (view == 0) for(; vbp; vbp = vbp->vb_link) getproc_nosuchins(pktp, vbp);else get_view_data(pktp, vbp, view);return;}/****************************************************************************NAME: viewtable_nextPURPOSE: Find the appropriate entry in the view table and attach information from it to the vbp using the getproc_got_* functions. If we can't find an entry indicate that by calling nextproc_no_next.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 viewtable_next(OIDC_T last_match, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp){VIEWLEAF_T *view = 0;VIEWINDEX_T *vindex;OIDC_T *rlist, namereq, namelen, len, *namelist, oidreq, *oidlist, *tempoid; int rcount, oidlen, i;bits8_t *name;/* get all the vbs for this row */group_by_getproc_and_instance(pktp, vbp, tcount, tlist);/* try to pull any indexing information from tcount & tlist if we don't have any we start at the beginning of the list */if (tcount == 0) { view = SNMP_View_Next(0); } else if (tlist[0] > ETC_VIEW_NAME_MAX) { /* if the name length is larger than the max possible we won't have any views so we are done */ view = 0; }else { /* we have a potential name, split the info out name first, then subtree */ namereq = *tlist++; tcount--; namelist = tlist; namelen = min(namereq, (OIDC_T)tcount); tcount -= (int)namereq; tlist += (int)namereq; if (tcount > 0) { oidreq = *tlist++; tcount--; oidlist = tlist; if (oidreq >= (OIDC_T)tcount) oidlen = tcount; else oidlen = (int)oidreq; } else { oidreq = 0; oidlist = 0; oidlen = 0; } /* step over any names that are shorter than what we want */ for(vindex = viewroot; vindex && (vindex->name_len < namereq); vindex = vindex->next) ; /* no body for for loop */ /* search through the names, because we have explicit name and oid lengths in the instance id we need to do some extra checking. If the name is longer than required we return the first view, if it is shorter we go to the next name structure. If it equals what we require then we compare it to the subids that were actually in the instance. The number of subids may be less than or equal to the required length. If we find a mismatch while comparing subids we either continue if the name subid was greater or setup the view and break if the instance subid was greater. If all the subids are the same we check the number of subids we compared against what we have in the name, if they are equal then we need to compare oids. */ for(; vindex; vindex = vindex->next) { if (vindex->name_len > namereq) { view = vindex->lexilist; break; } name = vindex->name; tempoid = namelist; for(len = namelen; len && (*name == *tempoid); len--, name++, tempoid++) ; /* no body for for loop */ if (len) { if (*name < *tempoid) continue; view = vindex->lexilist; break; } if (namereq != namelen) { view = vindex->lexilist; break; } /* if we made it here we need to check on the sub tree start by getting rid of any sub trees shorter than what we want. */ for (view = vindex->lexilist; view && ((OIDC_T)view->subtree.num_components < oidreq); view = view->lexinext) ; /* no body for for loop */ for (; view; view = view->lexinext) { if ((OIDC_T)view->subtree.num_components != oidreq) break; i = oidcmp2(oidlen, oidlist, oidlen, view->subtree.component_list); if ((i < 0) || ((i == 0) && (oidreq != (OIDC_T)oidlen))) break; } /* if we found a valid view break out */ if (view) break; } }if (view == 0) for(; vbp; vbp = vbp->vb_link) nextproc_no_next(pktp, vbp);else { rcount = SNMP_View_2275_Full_Name(view, 0, 0); if ((rcount == 0) || ((rlist = (OIDC_T *)SNMP_memory_alloc((unsigned int) (rcount * sizeof(OIDC_T)))) == 0)) nextproc_error(pktp, vbp, GEN_ERR); else { (void) SNMP_View_2275_Full_Name(view, rlist, rcount); get_view_data(pktp, vbp, view); for(; vbp; vbp = vbp->vb_link) { nextproc_next_instance(pktp, vbp, rcount, rlist); } SNMP_memory_free(rlist); } }return;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -