📄 namingscopes.c
字号:
* Parameters: * * <searchCommunity> - community to search for * <viewType> - type of view to search for, get or set * <viewName> - view name to be returned * * RETURNS: return value from viewFindIntern * */bits32_t communityStringFind ( EBUFFER_T searchCommunity, bits8_t viewType, EBUFFER_T * viewName ) { return (viewFindIntern (communityStringHead, searchCommunity, viewType, viewName)); }#if INSTALL_ENVOY_SNMP_VERSION_3/* SNMPv3 Context Name functions *//****************************************************************************** * * defaultContextNamesRegister - function to register default contexts * * This function is an example of the function that can be called when this * module gets initialised. In envoy.h there is a #define for * DEFAULT_CONTEXTS_REGISTER that, by default gets defined to this function. * If the user does not want or need the default contexts added in this * function when this module is used then DEFAULT_CONTEXTS_REGISTER must be * defined to a user function or NULL for no default contexts. * * Parameters: * * <defaultVsNum> - the vsnum of VS to use for the default context names * * RETURNS: N/A * */void defaultContextNamesRegister ( bits32_t defaultVsNum ) { contextNameRegister ((bits8_t *) "", 0, VIEW_TYPE_GET | VIEW_TYPE_SET, (bits8_t *) "two", 3, defaultVsNum); }/****************************************************************************** * * contextNameInit - Initialisation function for context name functions * * This function must be called before any other of the context name * functions in this file are called. This function initialises the list * of context names and calls a function pointer to add the default * context names if the function pointer has been initialised. * * Parameters: * * <defaultVsNum> - the vsnum of VS to use for the default context names * * RETURNS: N/A * */void contextNameInit ( bits32_t defaultVsNum ) { contextNameHead.first = NULL; contextNameHead.listType = CONTEXT_LIST; contextNameLastMatch = NULL; /* register the default context names */ DEFAULT_CONTEXTS_REGISTER (defaultVsNum); }/****************************************************************************** * * contextNameRegister - Register a context name * * This function will be called when a new context name is to be added * to the list of acceptable context names. This function passes it's * parameters to the internal registration function along with the head of * the context names list. * * Parameters: * * <newContextName> - the new context name to register * <stringLen> - the length of <newContextName> * <viewType> - type of view, get, set, get/set * <viewName> - view name for this context name * <indexLen> - length of <viewIndex> * <vsNum> - the vsnum for the new context name * * RETURNS: return value from viewRegisterIntern * */STATUS contextNameRegister ( bits8_t * newContextName, bits32_t stringLen, bits8_t viewType, bits8_t * viewName, bits32_t indexLen, bits32_t vsNum ) { return (viewRegisterIntern (&contextNameHead, newContextName, stringLen, viewType, viewName, indexLen, vsNum)); }/****************************************************************************** * * contextNameDeregister - Deregister a context name * * This function will be called when a new context name is to be removed * from the list of acceptable context names. This function passes it's * parameters to the internal deregistration function along with the head of * the context names list. * * Parameters: * * <contextName> - the context name to deregister * <stringLen> - length of <contextName> * <viewType> - type of view to deregister, get, set, get/set * <vsNum> - the vsnum associated with <contextName> * * RETURNS: return value from viewDeregisterIntern * */STATUS contextNameDeregister ( bits8_t * contextName, bits32_t stringLen, bits8_t viewType, bits32_t vsNum ) { return (viewDeregisterIntern (&contextNameHead, contextName, stringLen, viewType, vsNum)); }/****************************************************************************** * * contextNameFind - Search for a valid context * * This function will be called to find a valid context name from * the list of acceptable context names. This function passes it's * parameters to the internal search function along with the head of * the context names list. * * Parameters: * * <searchContext> - context to search for * <viewType> - type of view to search for, get or set * <viewName> - view name to be returned * * RETURNS: return value from viewFindIntern * */bits32_t contextNameFind ( EBUFFER_T searchContext, bits8_t viewType, EBUFFER_T * viewName ) { return (viewFindIntern (contextNameHead, searchContext, viewType, viewName)); }#endif /* INSTALL_ENVOY_SNMP_VERSION_3 *//* * Debug functions, used for testing */#if NAMING_SCOPE_DEBUGvoid viewSearch ( VIEW_LIST_HEAD_T viewListHead, bits8_t * commOrCon, bits32_t stringLen, bits8_t type ) { bits32_t returnVal; EBUFFER_T stringEbuff; EBUFFER_T nameEbuff; char * name; EBufferInitialize (&nameEbuff); EBufferInitialize (&stringEbuff); if ((EBufferAllocateLoad (BFL_IS_ALLOC, &stringEbuff, commOrCon, stringLen)) != 0) { printf ("EBufferAllocateLoad failed!\n"); return; } if (viewListHead.listType == COMMUNITY_LIST) returnVal = communityStringFind (stringEbuff, type, &nameEbuff);#if INSTALL_ENVOY_SNMP_VERSION_3 else if (viewListHead.listType == CONTEXT_LIST) returnVal = contextNameFind (stringEbuff, type, &nameEbuff);#endif /* INSTALL_ENVOY_SNMP_VERSION_3 */ else { printf ("\nUnknown list type!\n"); return; } if (returnVal == -1) { printf ("Search returned an ERROR!\n"); EBufferClean (&stringEbuff); return; } name = (char *) SNMP_memory_alloc (EBufferUsed (&nameEbuff) +1); snprintf (name, EBufferUsed (&nameEbuff) +1, "%s", EBufferStart (&nameEbuff)); printf ("vsNum: %d name: %s\n", returnVal, name); EBufferClean (&stringEbuff); SNMP_memory_free (name); EBufferClean (&nameEbuff); }void communitySearch ( bits8_t * community, bits32_t communityLen, bits8_t type ) { viewSearch (communityStringHead, community, communityLen, type); }#if INSTALL_ENVOY_SNMP_VERSION_3void contextSearch ( bits8_t * context, bits32_t contextLen, bits8_t type ) { viewSearch (contextNameHead, context, contextLen, type); }#endif /* INSTALL_ENVOY_SNMP_VERSION_3 */void printViews (VIEW_LIST_HEAD_T viewListHead) { VIEW_LIST_T * current; char * type, * string; char * name; if (viewListHead.listType == COMMUNITY_LIST) printf ("\nValid Communities...\n");#if INSTALL_ENVOY_SNMP_VERSION_3 else if (viewListHead.listType == CONTEXT_LIST) printf ("\nValid Contexts...\n");#endif /* INSTALL_ENVOY_SNMP_VERSION_3 */ else { printf ("\nUnknown list type, sorry!\n"); return; } for (current = viewListHead.first; current != NULL; current = current->next) { switch (current->viewType) { case (VIEW_TYPE_GET | VIEW_TYPE_SET): type = "get/set"; break; case VIEW_TYPE_GET: type = "get"; break; case VIEW_TYPE_SET: type = "set"; break; default: type = "unknown"; } string = (char *) SNMP_memory_alloc (EBufferUsed (¤t->commOrCon) +1); snprintf (string, EBufferUsed (¤t->commOrCon) +1, "%s", EBufferStart (¤t->commOrCon)); name = (char *) SNMP_memory_alloc (EBufferUsed (¤t->viewName) +1); snprintf (name, EBufferUsed (¤t->viewName) +1, "%s", EBufferStart (¤t->viewName)); printf ("CommOrCon: %s Type: %s Name: %s" " vsNum: %d\n", string, type, name, current->vsNum); SNMP_memory_free (string); SNMP_memory_free (name); } }void printCommunities () { printViews (communityStringHead); }#if INSTALL_ENVOY_SNMP_VERSION_3void printContexts () { printViews (contextNameHead); }#endif /* INSTALL_ENVOY_SNMP_VERSION_3 */#endif /* NAMING_SCOPE_DEBUG */#endif /* INSTALL_SNMP_VXWORKS_VIRTUAL_STACK */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -