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

📄 v3_eng.c

📁 wm PNE 3.3 source code, running at more than vxworks6.x version.
💻 C
📖 第 1 页 / 共 2 页
字号:
                  tdomain->component_list,                  sizeof(snmpUDPDomainV6)/sizeof(OIDC_T),                  snmpUDPDomainV6) == 1) &&          (MEMCMP(EBufferStart(taddress),                  EBufferStart(&(engine->taddress)),                  16) == 0))))                break;    }if (engine) {    *engine_id = engine->id;    *engine_id_len = engine->id_len;    }}/********************************************************************************* SNMP_Engine_Set_Address - manually set the target engine ID in an agent* SYNOPSIS** \cs* int SNMP_Engine_Set_Address *     ( *     bits8_t     *  eng_id, *     ALENGTH_T      eng_id_len, *     OIDC_T      *  tlist, *     int            tcount, *     bits8_t     *  taddress, 	*     ALENGTH_T      taddress_len *     )* \ce** DESCRIPTION** This routine associates a 'TAddress' and a 'TDomain' with an engine ID. The * format of these objects is defined in RFC 1904. This routine is useful if you * send 'INFORMS' and do not want to wait until you get a response from the * agent to obtain an engine ID. The macro ENVOY_ADD_ENGINE_ADDRESS() calls * this routine to add an engine ID to the engine table. Two other related * macros that are useful for converting between formats are: * ENVOY_TADDRESS_TO_SNMPADDR() and ENVOY_SNMPADDR_TO_TADDRESS().** PARAMETERS* \is* \i <*eng_id>* Reference the engine ID of a foreign engine.* \i <eng_id_len>* Specify the length in bytes of the engine ID.* \i <*tlist>* Point to an array of subids that is an object ID.* \i <tcount>* Specify the number of subids in <tlist>.* \i <*taddress>* Specify the 'TAddress'.* \i <taddress_len>* Specify the length in bytes of the 'TAddress'.* \ie** RETURNS: If successful, this routine returns 0. If the engine does not exist, * it returns 1. If there is an allocation error, it returns -1.** ERRNO: N/A** SEE ALSO: SNMP_Engine_Get_Boots(), SNMP_Engine_Get_Time(), * SNMP_Engine_Install(), 'ENVOY_ADD_ENGINE_ADDRESS(),' * 'ENVOY_SNMPADDR_TO_TADDRESS(),' 'ENVOY_TADDRESS_TO_SNMPADDR(),' * SNMP_Engine_Lookup(), SNMP_Engine_Set_Info(), SNMP_Engine_Set_My_Info()*/int  SNMP_Engine_Set_Address(bits8_t     *eng_id,			  ALENGTH_T    eng_id_len,			  OIDC_T      *tlist,			  int          tcount,			  bits8_t     *taddress,			  ALENGTH_T    taddress_len){ENGINE_LEAF_T *engine, *engine_chk;if ((engine = SNMP_Engine_Lookup(eng_id, eng_id_len)) == 0)    return(1);/* Check to make sure that the new taddress/tdomain * don't match an existing taddress/tdomain, and clean up  * whatever's there if necessary. */if ((EBufferUsed(&engine->taddress) > 0) &&     (oidcmp(tcount, tlist, engine->tdomain.num_components, 	    engine->tdomain.component_list) == 1) &&    (MEMCMP(taddress, EBufferStart(&engine->taddress),	    min(taddress_len, EBufferUsed(&engine->taddress))) == 0))    return(0);else     Clean_Obj_ID(&(engine->tdomain));/* Check to make sure that no other engine has this address.  Remove * it if it does.   */for (engine_chk = root_engine; engine_chk; engine_chk = engine_chk->next) {    if (engine == engine_chk)        continue;    if ((EBufferUsed(&engine->taddress) > 0) && 	(oidcmp(tcount, tlist, engine_chk->tdomain.num_components,		engine_chk->tdomain.component_list) == 1) &&	(MEMCMP(taddress, EBufferStart(&engine_chk->taddress),		min(taddress_len, EBufferUsed(&engine_chk->taddress))) == 0)) {        Clean_Obj_ID(&(engine_chk->tdomain));	EBufferClean(&engine_chk->taddress);        }    }/* Actually add the address... */if (build_object_id(tcount, tlist, &(engine->tdomain)))    return(-1);if (EBufferAllocateLoad(BFL_IS_ALLOC, &(engine->taddress), 			taddress, taddress_len)) {    Clean_Obj_ID(&(engine->tdomain));    return(-1);    }return(0);}#endif /* INSTALL_ENVOY_SNMP_V3_TARGET *//********************************************************************************* SNMP_Engine_Install - add a foreign engine ID to the list the engine maintains* SYNOPSIS** \cs* int SNMP_Engine_Install *     ( *     bits8_t   *  id, *     ALENGTH_T    id_length, *     bits32_t     boots, *     sbits32_t    timestamp *     ) * \ce** DESCRIPTION** This routine adds a foreign engine ID to the list the engine is maintaining. * Envoy creates an entry and allocates an 'ENGINE_LEAF_T' for the new engine. * You can use <boots> and <timestamp> to store information across reboots, or * set these values to 0 to allow automatic time synchronization to update them * as necessary.** PARAMETERS* \is* \i <*id>* Specify the engine ID of the foreign engine* \i <id_length>* Specify the length of the foreign engine\抯 engine id.* \i <boots>* Indicate the number of times the agent has been rebooted since the engine ID * was set.* \i <timestamp>* Indicate the number of seconds since the agent\抯 last reboot. If you update * the boots field, set the value of timestamp to zero.* \ie** RETURNS: If successful, this routine returns 0. If <engine id> that already * exists, it returns 1. If it is unable to allocate memory, it returns -1.** ERRNO: N/A** SEE ALSO: SNMP_Engine_Get_Boots(), SNMP_Engine_Get_Time(), * SNMP_Engine_Lookup(), SNMP_Engine_Set_Address(), SNMP_Engine_Set_Info(), * SNMP_Engine_Set_My_Info()*/int  SNMP_Engine_Install(bits8_t   *id,		      ALENGTH_T  len,		      bits32_t   boots,		      sbits32_t  offset){ENGINE_LEAF_T *engine, **temp_eng;if ((len == 0) || (len > ETC_ENGINE_ENGINE_MAX) || SNMP_Engine_Lookup(id, len))    return(1);engine = (ENGINE_LEAF_T *)SNMP_memory_alloc_lt(sizeof(ENGINE_LEAF_T) + len);if (engine == 0)    return(-1);engine->id     = ((bits8_t *)engine) + sizeof(ENGINE_LEAF_T);engine->id_len = len;MEMCPY(engine->id, id, len);engine->boots    = boots;engine->offset   = ENVOY_TIME() - offset;engine->lasttime = 0;#if INSTALL_ENVOY_SNMP_V3_TARGETengine->tdomain.num_components = 0;engine->tdomain.component_list = 0;EBufferInitialize(&engine->taddress);#endiffor(temp_eng = &root_engine; *temp_eng; temp_eng = &(*temp_eng)->next) {    if ((*temp_eng)->id_len >= len)       break;    }   engine->next = *temp_eng;*temp_eng = engine;return(0);}/* MIB method routines *//****************************************************************************\NOMANUALNAME:  get_snmpEngineIDPURPOSE:  get our engine idPARAMETERS:	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 processsed.	VB_T	   *	Variable being processed.RETURNS:  void****************************************************************************/void  get_snmpEngineID (OIDC_T      last_match,		    int         tcount,		    OIDC_T     *tlist,		    SNMP_PKT_T *pktp,		    VB_T       *vbp){/* Test the instance qualifier, we must have one subid with a value of 0 */if ((tcount != 1) || (*tlist != 0))    getproc_nosuchins(pktp, vbp);else {    getproc_got_string(pktp, vbp, SNMP_Engine_Get_My_ID_Length(),		       SNMP_Engine_Get_My_ID(), 0, 		       vbp->vb_ml.ml_leaf->expected_tag);    }return;}/****************************************************************************\NOMANUALNAME:  get_snmpEngineBootsPURPOSE:  get our engine bootsPARAMETERS:	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 processsed.	VB_T	   *	Variable being processed.RETURNS:  void****************************************************************************/void  get_snmpEngineBoots(OIDC_T      last_match,		      int         tcount,		      OIDC_T     *tlist,		      SNMP_PKT_T *pktp,		      VB_T       *vbp){/* Test the instance qualifier, we must have one subid with a value of 0 */if ((tcount != 1) || (*tlist != 0))    getproc_nosuchins(pktp, vbp);else {    getproc_got_int32(pktp, vbp, (sbits32_t)SNMP_Engine_Get_My_Boots());    }return;}/****************************************************************************\NOMANUALNAME:  get_snmpEngineTimePURPOSE:  get our engine timePARAMETERS:	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 processsed.	VB_T	   *	Variable being processed.RETURNS:  void****************************************************************************/void  get_snmpEngineTime(OIDC_T      last_match,		     int         tcount,		     OIDC_T     *tlist,		     SNMP_PKT_T *pktp,		     VB_T       *vbp){/* Test the instance qualifier, we must have one subid with a value of 0 */if ((tcount != 1) || (*tlist != 0))    getproc_nosuchins(pktp, vbp);else {    getproc_got_int32(pktp, vbp, SNMP_Engine_Get_My_Time());    }return;}

⌨️ 快捷键说明

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