📄 entlogic.c
字号:
/* * Copyright 2002-2005 Wind River Systems, Inc. * All rights reserved. Provided under license only. * Distribution or other use of this software is only * permitted pursuant to the terms of a license agreement * from Wind River Systems (and is otherwise prohibited). * Refer to that license agreement for terms of use. *//* entlogic.c - object manipulation routines for the entLogicalTable *//*modification history--------------------01b,18apr05,job update copyright notices01a,24nov03,job update copyright information$Log: entlogic.c,v $Revision 1.2 2002/05/23 20:00:25 joshquick fix to make call to ENVOY_GET_SYSUPTIME() properlyRevision 1.1 2002/05/23 18:47:31 joshsupport for the entLogicalTable from RFC 2737*//*DESCRIPTIONThis module contains the object manipulation routines for thelogical entity object.INCLUDE FILES: asn1.h, snmp.h, buffer.h, objectid.h, snmpdefs.h, entlogic.h *//* includes */#include <wrn/wm/snmp/engine/asn1.h>#include <wrn/wm/snmp/engine/snmp.h>#include <wrn/wm/snmp/engine/buffer.h>#include <wrn/wm/snmp/engine/objectid.h>#include <wrn/wm/snmp/engine/snmpdefs.h>#include <wrn/wm/snmp/engine/entlogic.h>/***************************************************************************** entLogicalFindBefore - find the where the previous entLogical object* would be in the entLogical list.** Search through the list until we find the entLogical structure we are* looking for. We return a pointer to the pointer that would point to the* requested entLogical if it were to exist. The calling routine is* responsible for determining if the requested entLogical exists. This* construction allows us to reuse this code for all of the find routines* (lookup and install).** RETURNS: ENT_LOGICAL_T ** pointer to pointer that would point to the* entLogical object if it were to exist.*/static ENT_LOGICAL_T ** entLogicalFindBefore ( bits32_t entLogicalIndex ) { ENT_LOGICAL_T ** ppEntLogical; /* pointer for walking the list */ for(ppEntLogical = &root_ent_logical; *ppEntLogical; ppEntLogical = &(*ppEntLogical)->next) { if (Ent_Logical_Get_Index (*ppEntLogical) >= entLogicalIndex) break; } return(ppEntLogical); }/**************************************************************************** Ent_Logical_Lookup - look up a logical entity object by name** Find the logical entity with the given name.** RETURNS: ENT_LOGICAL_T * pointer to the logical entity* 0 if no logical entity found*/ENT_LOGICAL_T * Ent_Logical_Lookup ( bits32_t entLogicalIndex ) { ENT_LOGICAL_T ** ppEntLogical; /* pointer for walking the list */ ppEntLogical = entLogicalFindBefore (entLogicalIndex); if ((*ppEntLogical != 0) && (Ent_Logical_Get_Index (*ppEntLogical) == entLogicalIndex)) return (*ppEntLogical); return (0); }/***************************************************************************** Ent_Logical_Next - Find the next logical entity after this instance** This routine takes instance information as input and attempts to find the* lexicographically next logical entity object in the logical entity list.* * the indexing information is of the form:* <entLogicalIndex>* * RETURNS: ENT_LOGICAL_T * pointer to logical entity* 0 if none found*/ENT_LOGICAL_T * Ent_Logical_Next ( int tcount, OIDC_T * tlist ) { ENT_LOGICAL_T * pEntLogical; /* pointer for walking the list */ if (tcount == 0) return (root_ent_logical); for (pEntLogical = root_ent_logical; pEntLogical; pEntLogical = pEntLogical->next) { if (Ent_Logical_Get_Index (pEntLogical) > *tlist) return (pEntLogical); } return (0); }/**************************************************************************** Ent_Logical_Next_Ent - find the logical entity object immediately after* this one** This routine takes a logical entity object and returns the next object in* the logical entity list.** RETURNS: ENT_LOGICAL_T * logical entity after the input argument* 0 if none*/ENT_LOGICAL_T * Ent_Logical_Next_Ent ( ENT_LOGICAL_T * pEntLogical ) { if (pEntLogical) return (pEntLogical->next); return (root_ent_logical); }/***************************************************************************** Ent_Logical_Destroy - Destroy the current logical entity object** Clean up any memory associated with a logical entity. Note that this* doesn't touch the indexing information -- that will be handled by the* install and deinstall routines.** RETURNS: N/A*/void Ent_Logical_Destroy ( ENT_LOGICAL_T * pEntLogical ) { EBufferClean (&pEntLogical->entLogicalDescr); Clean_Obj_ID (&pEntLogical->entLogicalType); EBufferClean (&pEntLogical->entLogicalCommunity); EBufferClean (&pEntLogical->entLogicalTAddress); Clean_Obj_ID (&pEntLogical->entLogicalTDomain); EBufferClean (&pEntLogical->entLogicalContextEngineID); EBufferClean (&pEntLogical->entLogicalContextName); SNMP_memory_free_lt (pEntLogical); }/***************************************************************************** Ent_Logical_Create - create and initialize a logical entity object** Allocate memory for a new logical entity and fill in the defaults. Note* that this doesn't include indexing information, that will be added by the* install routine.** RETURNS: ENT_LOGICAL_T * the logical entity that was created* 0 on error*/ENT_LOGICAL_T * Ent_Logical_Create (void) { ENT_LOGICAL_T * pEntLogical; pEntLogical = (ENT_LOGICAL_T *) SNMP_memory_alloc_lt (sizeof (ENT_LOGICAL_T)); if (pEntLogical == 0) return(0); Ent_Logical_Set_Defaults (pEntLogical); return (pEntLogical); }/***************************************************************************** Ent_Logical_Install - install a logical entity into the logical entity list ** Install the given logical entity into the logical entity list as specified* by the indexing information. Once installed a logical entity should be* deinstalled before being destroyed.** It is an error if a logical entity is already installed with the given* indexing information.** RETURNS: ENVOY_ERR_NOERR if successful* ENVOY_ERR_BAD_INSTANCE if the instance information is incorrect* ENVOY_ERR_EXISTS if an object already exists with that instance*/envoy_err_t Ent_Logical_Install ( ENT_LOGICAL_T * inEntLogical, bits32_t entLogicalIndex ) { ENT_LOGICAL_T ** ppEntLogical; /* see if the index information is reasonable */ if (entLogicalIndex > ETC_ENT_LOGICAL_MAX_INDEX) return (ENVOY_ERR_BAD_INSTANCE); /* see if the logical entity already exists */ ppEntLogical = entLogicalFindBefore (entLogicalIndex); if ((*ppEntLogical != 0) && (Ent_Logical_Get_Index (*ppEntLogical) == entLogicalIndex)) return (ENVOY_ERR_EXISTS); Ent_Logical_Set_Index (inEntLogical, entLogicalIndex); Ent_General_Set_Last_Change_Time (Ent_General_Group_Lookup(), ENVOY_GET_SYSUPTIME(0)); /* insert the proxy into the list */ inEntLogical->next = *ppEntLogical; *ppEntLogical = inEntLogical; return (ENVOY_ERR_NOERR); }/***************************************************************************** Ent_Logical_Deinstall - deinstall the logical entity object from the list** Unhook a logical entity from the logical entity list. The logical entity is* not destroyed but is no longer useable by the engine. To destroy the* logical entity use the destroy routine.*** RETURNS: N/A*/void Ent_Logical_Deinstall ( ENT_LOGICAL_T * inEntLogical ) { ENT_LOGICAL_T ** ppEntLogical; for(ppEntLogical = &root_ent_logical; *ppEntLogical; ppEntLogical = &(*ppEntLogical)->next) if (*ppEntLogical == inEntLogical) { *ppEntLogical = inEntLogical->next; Ent_Logical_Set_Index (inEntLogical, 0); inEntLogical->next = 0; Ent_General_Set_Last_Change_Time (Ent_General_Group_Lookup(), ENVOY_GET_SYSUPTIME(0)); return; } return; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -