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

📄 ax_ma.c

📁 wm PNE 3.3 source code, running at more than vxworks6.x version.
💻 C
📖 第 1 页 / 共 5 页
字号:
PARAMETERS: int * the registration index of the node to removeRETURNS: pointer to the remove node; calling function frees memory ****************************************************************************/static ENVOY_AX_MA_REGLIST_T *  ax_ma_reglist_remove (int reg_index){ENVOY_AX_MA_REGLIST_T **trp;ENVOY_AX_MA_REGLIST_T *thisptr;for (trp = &envoy_ax_registration_list;     *trp != NULL;      trp = &((*trp)->next)) {    thisptr = *trp;    if (thisptr->reg_index == reg_index) {        *trp = (*trp)->next;        return (thisptr);        }    }return (0);}/****************************************************************************\NOMANUALNAME: ax_session_releasePURPOSE: release the lock that was gotten when this session was acquiredPARAMETERS: ENVOY_AX_SESSION_T * the acquired session, basically ignoredRETURNS: void****************************************************************************/void  ax_session_release(ENVOY_AX_SESSION_T *sp){ENVOY_SNMP_RELEASE_WRITE_LOCK(SNMP_infrastructure_lock);}/****************************************************************************NAME: ax_session_freePURPOSE: release any resources held by the session, including indicating	 to the user that we are done with the send cookiePARAMETERS: ENVOY_AX_SESSION_T * the session to be cleaned upRETURNS: void****************************************************************************/static void  ax_session_free(ENVOY_AX_SESSION_T *sp){sp->error(sp->cookie, 0);Clean_Obj_ID(&sp->sub_id);EBufferClean(&sp->descr);SNMP_memory_free(sp);ENVOY_SNMP_RELEASE_WRITE_LOCK(SNMP_infrastructure_lock);return;}/****************************************************************************NAME: ax_session_createPURPOSE: Create a master agent session, the structure that contains	 the info about a "session" with a sub agent.  We try to fill	 it in and link it into the session list.PARAMETERS: ENVOY_AX_PKT_T     * packet to request opening a session            ENVOY_AX_SEND_T    * routine to send message to the sub agent	    ENVOY_AX_MA_FREE_T * routine to free the cookie structure	    ptr_t                cookie for use in sending messages to subs	    bits32_t             current sysuptimeRETURNS: ENVOY_AX_SESSION_T * pointer to the created session structure		              or 0 on errors.****************************************************************************/static ENVOY_AX_SESSION_T *  ax_session_create(ENVOY_AX_PKT_T   *ax_pkt,		    ENVOY_AX_SEND_T  *send_rtn,		    ENVOY_AX_ERROR_T *error_rtn,		    ptr_t             send_cookie,		    bits32_t          sysuptime){ENVOY_AX_SESSION_T *sp, **tptr;sp = (ENVOY_AX_SESSION_T *)SNMP_memory_alloc(sizeof(ENVOY_AX_SESSION_T));if (sp == 0)    return(0);MEMSET(sp, 0, sizeof(ENVOY_AX_SESSION_T));init_object_id(&sp->sub_id);EBufferInitialize(&sp->descr);sp->version   = ENVOY_AX_VERSION_1;sp->timeout   = ax_pkt->data.open_data.timeout;sp->flags     = ax_pkt->flags & ENVOY_AX_BIT_BYTE_ORDER;sp->send      = send_rtn;sp->error     = error_rtn;sp->cookie    = send_cookie;sp->timestamp = sysuptime;#if INSTALL_ENVOY_SNMP_LOCKif (ENVOY_SNMP_GET_WRITE_LOCK(SNMP_infrastructure_lock)) {    BUG(BUG_ENVOY_LOCKING, BUG_CONTINUABLE, 0,	(BUG_OUT, "ax_session_create: infrastructure lock is broken", 0));    SNMP_memory_free(sp);    return(0);    }#endif/* acquire some resources and make sure   we will have an id for the session */if ((clone_object_id(&ax_pkt->data.open_data.sub_id, &sp->sub_id))    || (EBufferClone(&ax_pkt->data.open_data.descr, &sp->descr))    || (envoy_ax_session_id == 0)) {    ENVOY_SNMP_RELEASE_WRITE_LOCK(SNMP_infrastructure_lock);    Clean_Obj_ID(&sp->sub_id);    EBufferClean(&sp->descr);    SNMP_memory_free(sp);    return(0);    }/* Save the session and connection IDs; in this context,   send_cookie is a pointer to the associated connection   structure). */sp->session_id = envoy_ax_session_id++;sp->connection_id = ENVOY_AX_GET_CONNID (send_cookie);for (tptr = &envoy_ax_session_list; *tptr != NULL; tptr = &((*tptr)->next))    /* do nothing, we're just finding the end of the list */    ;*tptr = sp;/* Note the the sysUpTime */axSessTblLastChg = ENVOY_GET_SYSUPTIME(0);return(sp);}/****************************************************************************\NOMANUALNAME: ax_session_find_indexPURPOSE: find the session named by the session id	 The session list is ordered so if we find	 a session id equal or greater than we are looking for	 we stop and decide what to returnPARAMETERS: bits32_t   session id we are looking for            int      * error status, 1 if we had a lock error RETURNS: ENVOY_AX_SESSION_T * a pointer to the session with the given id			         0 if there were no such session				 ****************************************************************************/ENVOY_AX_SESSION_T *  ax_session_find_index(bits32_t  session_id,			int      *err_stat){ENVOY_AX_SESSION_T *tptr;*err_stat = 0;#if INSTALL_ENVOY_SNMP_LOCKif (ENVOY_SNMP_GET_WRITE_LOCK(SNMP_infrastructure_lock)) {    BUG(BUG_ENVOY_LOCKING, BUG_CONTINUABLE, 0,	(BUG_OUT, "ax_session_find_index: infrastructure lock is broken", 0));    *err_stat = 1;    return(0);    }#endiffor (tptr = envoy_ax_session_list;     tptr && (tptr->session_id < session_id);     tptr = tptr->next)    ; /* empty for body */if (tptr && (tptr->session_id == session_id))    return(tptr);ENVOY_SNMP_RELEASE_WRITE_LOCK(SNMP_infrastructure_lock);return(0);}/****************************************************************************NAME: ax_session_find_handlePURPOSE: find the first session with the given cookie in the session listPARAMETERS: ptr_t send cookie to search for	    int   * error status, 1 if lock failedRETURNS: ENVOY_AX_SESSION_T * pointer to the session			      0 if there were no session****************************************************************************/static ENVOY_AX_SESSION_T *  ax_session_find_handle(ptr_t  handle,			 int   *err_stat){ENVOY_AX_SESSION_T *tptr;*err_stat = 0;#if INSTALL_ENVOY_SNMP_LOCKif (ENVOY_SNMP_GET_WRITE_LOCK(SNMP_infrastructure_lock)) {    BUG(BUG_ENVOY_LOCKING, BUG_CONTINUABLE, 0,	(BUG_OUT, "ax_session_find_handle: infrastructure lock is broken", 0));    *err_stat = 1;    return(0);    }#endiffor (tptr = envoy_ax_session_list; tptr; tptr = tptr->next)     if (ENVOY_AX_COOKIE_CMP(handle, tptr->cookie)) {        return(tptr);        }ENVOY_SNMP_RELEASE_WRITE_LOCK(SNMP_infrastructure_lock);return(0);}/****************************************************************************\NOMANUALNAME: ax_session_nextPURPOSE: find the first session after the named session	 The session list is ordered so we just search until	 we find an id greater than the request.  We start	 the ids at 1 so that we can always use 0 as the base	 id even if we didn't have an instance in the request.PARAMETERS: bits32_t session id we are looking for            int      * error status, 1 if we had a lock errorRETURNS: ENVOY_AX_SESSION_T * a pointer to the session with the given id			         0 if there were no such session****************************************************************************/ENVOY_AX_SESSION_T *  ax_session_next(bits32_t  session_id,		  int      *err_stat){ENVOY_AX_SESSION_T *tptr;*err_stat = 0;#if INSTALL_ENVOY_SNMP_LOCKif (ENVOY_SNMP_GET_WRITE_LOCK(SNMP_infrastructure_lock)) {    BUG(BUG_ENVOY_LOCKING, BUG_CONTINUABLE, 0,	(BUG_OUT, "ax_session_next: infrastructure lock is broken", 0));    *err_stat = 1;    return(0);    }#endiffor (tptr = envoy_ax_session_list; tptr; tptr = tptr->next)    if (tptr->session_id > session_id)        return(tptr);ENVOY_SNMP_RELEASE_WRITE_LOCK(SNMP_infrastructure_lock);return(0);}/****************************************************************************NAME: ax_session_removePURPOSE: remove the given session from the session list, this routine does	 not free the space for the session to do that use ax_session_freePARAMETERS: ENVOY_AX_SESSION_T * session to look forRETURNS: 0 if all normal, 1 if session wasn't in list****************************************************************************/static int  ax_session_remove(ENVOY_AX_SESSION_T *session)			  {ENVOY_AX_SESSION_T **tptrp;for (tptrp = &envoy_ax_session_list;     *tptrp && (*tptrp != session);     tptrp = &((*tptrp)->next))    /* do nothing, just searching the list */    ;if (*tptrp) {    *tptrp = session->next;    axSessTblLastChg = ENVOY_GET_SYSUPTIME(0);    return(0);    }return(1);}/****************************************************************************NAME: ax_context_createPURPOSE: Create a context block, this is the block used to hold the	 context name information as well as a pointer to the mib	 root node.  We also link the context into the context list.PARAMETERS: ENVOY_AX_PKT_T * agentx packet causing adding the context	    bits16_t       * error statusRETURNS: ENVOY_AX_CONTEXT_T * created context or 0 if we couldn't build it.****************************************************************************/static ENVOY_AX_CONTEXT_T *  ax_context_create(ENVOY_AX_PKT_T *ax_pkt,		    bits16_t       *err_stat){ENVOY_AX_CONTEXT_T *context;MIBNODE_T *mibroot;if ((mibroot = ENVOY_AX_FIND_MIB(&ax_pkt->context)) == 0) {    *err_stat = ENVOY_AX_UNSUPPORTED_CONTEXT;    return(0);    }/*sar may need to do soemthing about the gen_errs from here */if (context_list_id == 0) {    *err_stat = GEN_ERR;    return(0);    }  context = (ENVOY_AX_CONTEXT_T *)SNMP_memory_alloc(sizeof(ENVOY_AX_CONTEXT_T));if (context == 0) {    *err_stat = GEN_ERR;    return(0);    }if (EBufferClone(&ax_pkt->context, &context->context)) {    SNMP_memory_free(context);    *err_stat = GEN_ERR;    return(0);    }context->id        = context_list_id++;context->mibroot   = mibroot;context->next      = context_list;context->indexroot = 0;context_list       = context;return(context);}/****************************************************************************\NOMANUALNAME: ax_context_indexPURPOSE: find a context in the listPARAMETERS: bits32_t index of the context to findRETURNS: ENVOY_AX_CONTEXT_T * the context we found, 0 if none found****************************************************************************/ENVOY_AX_CONTEXT_T *  ax_context_index(bits32_t indx){ENVOY_AX_CONTEXT_T *context;for(context = context_list; context; context = context->next) {    if (context->id == indx)        return(context);    }return(0);}/****************************************************************************NAME: ax_context_namePURPOSE: find a context in the listPARAMETERS: EBUFFER_T * name of the context to findRETURNS: ENVOY_AX_CONTEXT_T * the context we found, 0 if none found****************************************************************************/static ENVOY_AX_CONTEXT_T *  ax_context_name(EBUFFER_T *cname){ENVOY_AX_CONTEXT_T *context;for(context = context_list; context; context = context->next) {    if (EBufferUsed(&context->context) != EBufferUsed(cname))        continue;    if ((EBufferUsed(&context->context) == 0) || 	(MEMCMP(EBufferStart(&context->context), EBufferStart(cname),		EBufferUsed(cname)) == 0))        return(context);    }return(0);}/****************************************************************************\NOMANUALNAME: ax_context_nextPURPOSE: get the next context in the listPARAMETERS: ENVOY_AX_CONTEXT_T * context to start from, if 0 start				 at the beginningRETURNS: ENVOY_AX_CONTEXT_T * context we found, 0 if none found****************************************************************************/ENVOY_AX_CONTEXT_T *  ax_context_next(ENVOY_AX_CONTEXT_T *context){if (context == 0)    return(context_list);return(context->next);}/****************************************************************************NAME: ax_ma_deregister_helperPURPOSE: attempt to deregister the given node or range of nodes          in the registration and mib trees.         we walk through the range of nodes twice,

⌨️ 快捷键说明

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