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

📄 creatrap.c

📁 wm PNE 3.3 source code, running at more than vxworks6.x version.
💻 C
字号:
/* creatrap.c - creatrap.c routines *//* *  Copyright 2000-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. *//* *  Copyright 1988-1997 Epilogue Technology Corporation. *  Copyright 1998 Integrated Systems, Inc. *  All rights reserved. *//* * $Log: creatrap.c,v $ * Revision 1.2  2001/11/06 21:20:07  josh * revised new path hacking * * Revision 1.1.1.1  2001/11/05 17:47:42  tneale * Tornado shuffle * * Revision 9.2  2001/01/19 22:22:20  paul * Update copyright. * * Revision 9.1  2000/03/17 00:19:02  meister * Update copyright message * * Revision 9.0  1998/10/16 22:11:14  sar * Update version stamp to match release * * Revision 8.2  1998/06/05 18:53:11  sra * "#include <foo.h>" => "#include <envoy/h/foo.h>". * * Revision 8.1  1998/02/25 04:51:36  sra * Update copyrights. * * Revision 8.0  1997/11/18 00:56:46  sar * Updated revision to 8.0 * * Revision 7.2  1997/03/20 06:48:49  sra * DFARS-safe copyright text.  Zap! * * Revision 7.1  1997/02/25 10:49:26  sra * Update copyright notice, dust under the bed. * * Revision 7.0  1996/03/18 20:01:11  sar * Updated revision to 7.0 and copyright to 96 * * Revision 6.2  1995/11/01  00:46:48  sar * Added a version check, create_trap_request is only useable for version 1 * * Revision 6.1  1995/10/20  22:59:09  sar * removed no_pp stuff & casts of 0 * modified memcpy to MEMCPY * * Revision 6.0  1995/05/31  21:47:18  sra * Release 6.0. * * Revision 5.1  1994/10/12  20:20:28  sar * trap_time_ticks is now a uint so we don't have to cast timestamp to * an int. * * Revision 5.0  1994/05/16  15:42:42  sar * Updated revision to 5.0 and copyright to include 1994 * * Revision 4.0  1993/06/24  15:45:46  sar * Updated revision to 4.0 and copyright to 93 * * Revision 3.3  1993/06/02  23:09:24  dab * Changed #ifdef's to #if's for things from install.h * * Revision 3.2  1993/04/26  20:37:09  sar * Added ifdefs to allow clean makes of version 1 and 2, added bit strings, * arrange for deletion of acls with the party or context they refer to * is deleted. * * Revision 3.1  1993/04/22  20:06:36  sar * Much updating of macros and install options, mostly we now use * ISNTALL_ENVOY_SNMP_VERSION_1 or _2, VERSION_RFCXXXX is now SNMP_VERSION_2 * and other similiar items. * * Revision 3.0  1992/04/03  19:52:37  dab * Release 3.0 * * Revision 2.103  91/10/30  20:41:55  dab * Directly include asn1conf.h, snmpdefs.h, and snmpstat.h (if needed). *  * Revision 2.102  91/08/15  12:30:57  dab * Removed <libfuncs.h>. *  * Revision 2.101  91/08/12  12:47:37  dab * Cast arguments to memcpy() and memset() to PTR_T. *  * Revision 2.100  91/08/09  14:08:18  dab * Update version. *  * Revision 1.1  91/07/30  02:23:32  romkey * Initial revision *  *  *    Rev 2.0   31 Mar 1990 15:06:42 * Release 2.00 *  *    Rev 1.1   17 Mar 1989 21:41:50 * Calls to memcpy/memset protected against zero lengths *  *    Rev 1.0   11 Jan 1989 12:11:22 * Initial revision. * * Separated from buildpkt.c on January 11, 1989.*//* [clearcase]modification history-------------------01d,12may05,job  fix apigen comments01c,18apr05,job  update copyright notices01b,16feb05,job  apigen for documented APIs01a,24nov03,job  update copyright information*//*DESCRIPTIONThis library contains creatrap.c routines.INCLUDE FILES: snmp.h*/#include <wrn/wm/snmp/engine/asn1conf.h>#include <wrn/wm/snmp/engine/asn1.h>#include <wrn/wm/snmp/engine/buffer.h>#include <wrn/wm/snmp/engine/snmpdefs.h>#include <wrn/wm/snmp/engine/snmp.h>#include <wrn/wm/snmp/engine/objectid.h>#include <wrn/wm/snmp/engine/buildpkt.h>#if INSTALL_ENVOY_SNMP_VERSION_1/******************************************************************************** SNMP_Create_Trap - allocate a packet structure for a SNMPv1 'TRAP' PDU* SYNOPSIS* * \cs* SNMP_PKT_T * SNMP_Create_Trap *     ( *     int           version, *     int           commleng, *     char       *  community, *     int           enterprz_c, *     OIDC_T     *  enterprz_l, *     OCTET_T    *  agent_ip, *     int           generic, *     INT_32_T      specific, *     UINT_32_T     timestamp, *     int           num_vb *     )* \ce* * DESCRIPTION* * This routine allocates and initializes a new packet structure of type 'SNMP_PKT_T' for a SNMPv1 'TRAP' PDU.* If you are building a multi-lingual agent, you may also need to call SNMP_Create_Request2() and SNMP_Create_Request_V3() to build appropriate SNMPv2 'TRAP' PDUs, or use SNMP_Send_Notify_Name().* * \&NOTE: After you have created this structure, call the appropriate bind procedures to bind specific entries into the 'VarBindList' before calling SNMP_Encode_Packet() to encode the packet for transmission.* * PARAMETERS* \is* \i <version>* Specify the SNMP protocol version as 'SNMP_VERSION_1'. The constants 'VERSION_RFC1067', 'VERSION_RFC1098' and 'VERSION_RFC1157' are equivalent to 'SNMP_VERSION_1'.* \i <commleng>* Specify the length in bytes of the SNMP community name.* \i <*community>* Specify the SNMP community name.* \i <enterprz_c>* Specify the number of components referenced by <enterprz_l>* \i <*enterprz_l>* Specify a list of values that comprise the enterprise object identifier to be incorporated into the 'TRAP' PDU.* \i <*agent_ip>* Specify the agent\抯 IP address as a four-byte value in standard network order.* \i <generic>* Specify the generic 'TRAP' type value.* \i <specific>* Specify the specific 'TRAP' type value.* \i <timestamp>* Specify the time of the 'TRAP' in units of 1/100th of a second based on the time of the last system initialization.* \i <num_vb>* Indicate how many 'VarBind' entries to place in the 'VarBindList'.* \ie* * RETURNS: If successful, this routine returns a pointer to the newly created packet. Otherwise, it returns 0.* * ERRNO: N/A* * SEE ALSO: SNMP_Create_Request2(), SNMP_Create_Request_V3(), SNMP_Encode_Packet()*/SNMP_PKT_T *  SNMP_Create_Trap(int	      version,		   int	      commleng,		   char	     *community,		   int	      enterprz_c,		   OIDC_T    *enterprz_l,		   OCTET_T   *agent_ip,		   int	      generic,		   INT_32_T   specific,		   UINT_32_T  timestamp,		   int	      num_vb){SNMP_PKT_T	*rp;if (version != SNMP_VERSION_1)    return 0;if ((rp = SNMP_Allocate()) == 0)    return 0;rp->pdu_type = TRAP_PDU;rp->snmp_version = SNMP_VERSION_1;if (build_object_id(enterprz_c, enterprz_l,		    &(rp->pdu.trap_pdu.enterprise_objid)) == -1) {    SNMP_Free(rp);    return 0;    }MEMCPY((PTR_T)rp->pdu.trap_pdu.net_address, (PTR_T)agent_ip, 4);rp->pdu.trap_pdu.generic_trap = generic;rp->pdu.trap_pdu.specific_trap = specific;rp->pdu.trap_pdu.trap_time_ticks = timestamp;EBufferPreLoad(BFL_IS_STATIC, &(rp->community), community, commleng);if ((rp->pdu.trap_pdu.trap_vbl.vbl_count = num_vb) == 0) {    /* Handle case where the VarBindList is empty */    rp->pdu.trap_pdu.trap_vbl.vblist = 0;    }else { /* The VarBindList has contents */    if ((rp->pdu.trap_pdu.trap_vbl.vblist = VarBindList_Allocate(num_vb))          == 0) {	SNMP_Free(rp);	return 0;	}    }return rp;}#endif /* INSTALL_ENVOY_SNMP_VERSION_1 */

⌨️ 快捷键说明

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