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

📄 axapi.c

📁 wm PNE 3.3 source code, running at more than vxworks6.x version.
💻 C
📖 第 1 页 / 共 2 页
字号:
/* *  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. *//* * $Log: axapi.c,v $ * Revision 1.12  2003/01/15 14:05:02  josh * directory structure shifting * * Revision 1.11  2002/07/11 21:54:32  josh * clean up a memory leak in AgentX method routines * * Revision 1.10  2002/05/16 21:00:21  tneale * Changed comment and removed wrongly placed "last changed" update * * Revision 1.9  2002/04/09 14:16:56  tneale * AgentX registration changed from tree to list to better store ranges * * Revision 1.8  2002/04/04 15:25:19  andre * Change ENVOY_AX_TRANSPORT to ENVOY_AX_CONN_ENTRY. * * Revision 1.6  2002/03/22 17:59:40  josh * moved declaration of axConnTblLastChg, axSessTblLastChg, and * axRegTblLastChg to ax_maini.c to prevent master agent code * from being sucked into subagent builds * * Revision 1.5  2002/03/18 20:18:52  tneale * Changed declarations to conform to correct tcount type * * Revision 1.4  2002/03/18 16:27:44  tneale * Added support for Agentx Session table * * Revision 1.3  2002/03/12 15:50:32  tneale * Added the Registration table of the Agentx MIB * * Revision 1.2  2002/02/26 18:38:58  josh * cleanup and nits * * *//* [clearcase]modification history-------------------01b,18apr05,job  update copyright notices01a,24nov03,job  update copyright information*/#include <wrn/wm/common/types.h>#include <wrn/wm/snmp/engine/agentx.h>#include <wrn/wm/snmp/engine/asn1conf.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/auxfuncs.h>#include <wrn/wm/snmp/engine/axapi.h>#include <wrn/wm/common/bug.h>/* Globals *//* these globals are declared in ax_maini.c to keep down the number *//* of files that declare globals.*/extern bits32_t axConnTblLastChg;extern bits32_t axSessTblLastChg;extern bits32_t axRegTblLastChg;/*****************//***  SCALARS  ***//*****************/boolean_t AxGetScalar (int scalarCode, bits32_t *value)/*****  NAME****      AxGetScalar() - Retrieves the timeout value and protocol version.****  PARAMETERS****      **      scalarCode -- An integer representing the code for the scalar to retrieve**      value      -- Pointer to a bits32_t that will hold the value****  DESCRIPTION****      This routine retrieves any one of five AgentX MIB scalar values.****  RETURNS****      TRUE  -- Normal/Success**      FALSE -- Error/Failure; also "scalar code not valid"*/{    /* Try to get the infrastructure lock */#if INSTALL_ENVOY_SNMP_LOCK    if (ENVOY_SNMP_GET_WRITE_LOCK(SNMP_infrastructure_lock))     {        BUG(BUG_ENVOY_LOCKING, BUG_CONTINUABLE, 0,        (BUG_OUT, "AxGetScalar: infrastructure lock is broken", 0));        return(0);    }#endif    switch (scalarCode)    {    case AX_GEN_DEFTO:      /* agentxDefaultTimeout  (0..255) */        *value = ENVOY_AX_DEFAULT_TIMEOUT;        break;    case AX_GEN_VER:        /* agentxMasterAgentXVer (0..255) */        *value = ENVOY_AX_VERSION_1;        break;    case AX_CONN_LASTCHG:   /* agentxConnTableLastChange (0..4294967295) */        *value = axConnTblLastChg;        break;    case AX_SESS_LASTCHG:   /* agentxSessionTableLastChange (0..4294967295) */        *value = axSessTblLastChg;        break;    case AX_REG_LASTCHG:    /* agentxRegistrationTableLastChange (0..4294967295) */        *value = axRegTblLastChg;        break;    default:                /* Invalid scalar code */        *value = 0;        ENVOY_SNMP_RELEASE_WRITE_LOCK(SNMP_infrastructure_lock);        return FALSE;        break;    }    ENVOY_SNMP_RELEASE_WRITE_LOCK(SNMP_infrastructure_lock);    return TRUE;}/**************************//***  CONNECTION GROUP  ***//**************************/AX_CONNENT_T *AxConnGetEntry (int tcount, OIDC_T *tlist)/***  NAME****      AxConnGetEntry() - Retrieves information for a specific AgentX transport connection.****  PARAMETERS****      tcount -- Count of sub-ids**      tlist  -- Pointer to an array of bits32_ts representing an instance****  DESCRIPTION****      An agentxConnectionEntry describes a single AgentX transport connection.****  RETURNS****      Success -- Pointer to a Connection Entry structure**      Failure -- Zero (0)*/{    AX_CONNENT_T *pConnEntry = 0;    if  (tcount != 1)  return 0;    /*    **  Allocate memory for the structure.  Fetch the information    **  and return it via the connection structure.    */    if  (!(pConnEntry = SNMP_memory_alloc (sizeof (AX_CONNENT_T))))  return 0;    memset (pConnEntry, 0, sizeof (AX_CONNENT_T));    if (!ENVOY_AX_CONN_ENTRY (tlist[0], AX_MATCH_GET, pConnEntry))    {        SNMP_memory_free (pConnEntry);        return 0;    }    return pConnEntry;}AX_CONNENT_T *AxConnGetNext (int tcount, OIDC_T *tlist)/***  NAME****      AxConnGetNext() - Retrieves the next connection table entry****  PARAMETERS****      tcount -- Count of sub-ids**      tlist  -- Pointer to an array of bits32_ts representing an instance****  DESCRIPTION****      An agentxConnectionEntry describes a single AgentX transport connection.****  RETURNS****      Success -- Pointer to a Connection Entry structure**      Failure -- Zero (0)*/{    AX_CONNENT_T *pConnEntry = 0;    /*    **  Allocate memory for the structure.  Fetch the information    **  and return it via the connection structure.    */    if  (!(pConnEntry = SNMP_memory_alloc (sizeof (AX_CONNENT_T))))  return 0;    memset (pConnEntry, 0, sizeof (AX_CONNENT_T));    if (!ENVOY_AX_CONN_ENTRY (tlist ? tlist[0] : 0, AX_MATCH_NEXT, pConnEntry))    {        SNMP_memory_free (pConnEntry);        return 0;    }    return pConnEntry;}void setAxConnTblLastChg (bits32_t timeStamp)/***  NAME****      setAxConnTblLastChg - Sets the global representing agentxConnTableLastChange.****  PARAMETERS****      timeStamp -- Integer value representing time as some number of centiseconds.****  DESCRIPTION****      Sets the global representing agentxConnTableLastChange.****  RETURNS****      <Nothing>*/{    axConnTblLastChg = timeStamp;}/***********************//***  SESSION GROUP  ***//***********************/static AX_SESSENT_T *create_sessentry (ENVOY_AX_SESSION_T *slptr)/***  NAME****      create_sessentry() - Retrieves a session table entry****  PARAMETERS****      slptr  -- Pointer to an element of the session list****  DESCRIPTION****      Copies information from a SESSION structure to a new SESSENT****  RETURNS****      Pointer to the new structure of type AX_SESSENT_T, or 0 if failure.*/{    AX_SESSENT_T          *septr;    if (!(septr = SNMP_memory_alloc (sizeof (AX_SESSENT_T))))        return 0;    septr->agentxConnIndex = (int)(slptr->connection_id);     septr->agentxSessIndex = (int)(slptr->session_id);     /*      * Check if there are any components before cloning -      * it is OK for there to be none and this shouldn't cause an error.     */    if (slptr->sub_id.num_components)    {        if (clone_object_id (&slptr->sub_id, &septr->agentxSessObjectID))         {            SNMP_memory_free (septr);            return 0;        }    }    else    {        septr->agentxSessObjectID.num_components = 0;        septr->agentxSessObjectID.component_list = 0;    }    if (EBufferClone(&slptr->descr, &septr->agentxSessDescr))     {        SNMP_memory_free (septr->agentxSessObjectID.component_list);        SNMP_memory_free (septr);        return 0;    }

⌨️ 快捷键说明

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