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

📄 creatreq.c

📁 wm PNE 3.3 source code, running at more than vxworks6.x version.
💻 C
字号:
/* creatreq.c - creatreq.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: creatreq.c,v $ * Revision 1.4  2003/01/15 14:05:03  josh * directory structure shifting * * Revision 1.3  2001/11/06 21:50:45  josh * second (and hopefully final) pass of new path hacking * * 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.5.4.2  2001/08/07 21:53:31  meister * reworked to use dynamic component configuration macros, to allow * separate vxworks agentx components * * Revision 9.5.4.1  2001/08/07 18:36:59  meister * Break out SNMP_Create_Request_V3{,_Lockable}() out of creatreq.c into * v3_creq.c. Change static create_request() into non-static _snmp_create_request() * * Revision 9.5  2001/01/19 22:22:20  paul * Update copyright. * * Revision 9.4  2000/03/17 00:19:03  meister * Update copyright message * * Revision 9.3  2000/03/09 13:51:32  josh * a shell function has been created to allow SNMPv3 requests * to be created while we're holding the coarse lock. * * Revision 9.2  2000/02/04 21:56:14  josh * functions which are clearly static have been declared as such. * this makes the vxWorks compiler happy. * * Revision 9.1  1999/04/09 20:37:06  josh * Obsoleting ENVOY_SNMP_VERSON_USEC and ENVOY_40_VB_FREE_COMPAT * * Revision 9.0  1998/10/16 22:11:20  sar * Update version stamp to match release * * Revision 8.12  1998/08/01 17:35:03  sar * Removed the check_id flag from the user lookup call * * Revision 8.11  1998/07/20 02:01:23  sar * Removed dynamic/static tags from v3 packet creation routine * * Revision 8.10  1998/07/03 16:51:32  sar * Removed the many engine option and moved this engine's boots and time * informtaion into an engine entry * * Revision 8.9  1998/06/18 04:32:32  sar * Update the type info for bflags in an ebuffer and make * everybody match it. * * Revision 8.8  1998/06/01 20:41:52  sar * Removed the msg_con_name field from SNMP_PKT_T and used the community * field instead. * * Revision 8.7  1998/05/30 03:20:04  sar * Modified the names for the max string length macros for clarity * Update user_lookup * * Revision 8.6  1998/05/29 04:16:20  sar * Switch to using read locks instead of write locks. * Corrected spelling of the locks * Moved the use of coarse lock around to include the user list * * Revision 8.5  1998/05/29 04:13:42  sar * *** empty log message *** * * Revision 8.4  1998/05/28 04:01:51  sar * Get the coarse lock to protect the engine list * before getting the boots lock for the boot info * * Revision 8.3  1998/05/28 03:43:52  sar * Added a lock to protect the engine boots and time values * * Revision 8.2  1998/05/24 04:29:00  sar * Added create function for use with v3 packets * * Revision 8.1  1998/02/25 04:51:37  sra * Update copyrights. * * Revision 8.0  1997/11/18 00:56:47  sar * Updated revision to 8.0 * * Revision 7.2  1997/03/20 06:48:50  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  1996/01/10  16:34:47  sar * usec updates * * Revision 6.1  1995/10/20  23:02:48  sar * removed no_pp stuff * removed create_v2_request & create_half_trap * * Revision 6.0  1995/05/31  21:47:19  sra * Release 6.0. * * Revision 5.2  1995/03/21  00:25:01  sar * Use the new party names (for & loc instaead of src & dst) * * Revision 5.1  1994/10/03  21:22:28  sar * Added the function SNMP_Create_V2_Half_Trap.  This routine * create a v2 type snmp_pkt_t set up for a v2 trap but without * any party or context information.  This packet is for use with * the create_and_send_traps routines. * * 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.9  1993/06/02  23:09:24  dab * Changed #ifdef's to #if's for things from install.h * * Revision 3.8  1993/05/17  14:03:35  sar * changed SNMP_Create_Party_Request to be SNMP_Create_V2_Request * * Revision 3.7  1993/05/03  17:16:12  sar * Added routines for local time, removed {party context} oids from packet * structure, added asn1len to {party context} structures and * SNMP_{Party Context}_Name where needed to lookup the name for a given * {Party Context}. * * Revision 3.6  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.5  1993/04/19  18:28:34  sar * cleanup, mostly some correcting some non-ansi misspellings and adding * static defs. * * Revision 3.4  1993/03/03  03:17:00  sar * Updated to deal with shadow rows.  I have defined a new enumeration for * row status (RS_RSNE = 0) which means that row status doesn't exist yet. * Most routines now check to see if the row is active before using it. * Also added SNMP_SILLY_MARKETING_MACRO as per Rob's request. * * Revision 3.3  1993/02/24  01:02:41  sar * Changed many call to use OIDC_T/lenght pairs instead of OBJ_ID_T as now * we don't need to specifically allocate the OBJ_ID_T. * Removed the name objid from the PARTYLEAF_T as the name may be determined from * the tree itself.  For efficiency purposes put the dest/src party names into * the pkt so we don't have to look them up frequently. * * Revision 3.2  1993/02/17  21:02:06  sar * Added SNMP_Create_Party_Request to create and fill in packet structures * for v2.  Moved some of the common code between v1 and v2 into a seperate * routine to shrink code size. * * Revision 3.1  92/04/28  10:37:08  dab * Fixed comments to reference snmpdefs.h instead of snmp.h *  * Revision 3.0  92/04/03  19:52:37  dab * Release 3.0 *  * Revision 2.102  91/10/30  20:41:56  dab * Directly include asn1conf.h, snmpdefs.h, and snmpstat.h (if needed). *  * Revision 2.101  91/08/15  12:30:57  dab * Removed <libfuncs.h>. *  * Revision 2.100  91/08/09  14:08:19  dab * Update version. *  * Revision 1.1  91/07/30  02:23:33  romkey * Initial revision *  *  *    Rev 2.0   31 Mar 1990 15:06:42 * Release 2.00 *  *    Rev 1.0   11 Jan 1989 12:11:20 * 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 creatreq.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/buildpkt.h>#include <wrn/wm/common/bug.h>#if INSTALL_ENVOY_SNMP_VERSION_3#include <wrn/wm/snmp/engine/v3_eng.h>#include <wrn/wm/snmp/engine/v3_user.h>#include <wrn/wm/snmp/engine/v3_auth.h>#include <wrn/wm/snmp/engine/v3_priv.h>#endif /* #if INSTALL_ENVOY_SNMP_VERSION_3 *//****************************************************************************\NOMANUALNAME:  create_requestPURPOSE:  Allocate an SNMP request packet and the vbl list for it.PARAMETERS:	int		Number of VarBindList elements needed (may be 0)RETURNS:  SNMP_PKT_T *	SNMP Packet structure, 0 on failure****************************************************************************/SNMP_PKT_T *   _snmp_create_request(int num_vb){SNMP_PKT_T	*rp;if ((rp = SNMP_Allocate()) == 0)    return 0;/* Is the VarBindList empty ? */if ((rp->pdu.std_pdu.std_vbl.vbl_count = num_vb) == 0) /* yes */    rp->pdu.std_pdu.std_vbl.vblist = 0;else { /* No, the VarBindList has contents */    if ((rp->pdu.std_pdu.std_vbl.vblist = VarBindList_Allocate(num_vb))	== 0) {        SNMP_Free(rp);	return 0;        }    }return rp;}/********************************************************************************* SNMP_Create_Request2 - build SNMPv2c packets and SNMPv1 packets* SYNOPSIS** \cs* SNMP_PKT_T * SNMP_Create_Request2 *     ( *     int          ptype, *     int          version, *     int          commleng, *     char      *  community, *    INT_32_T     request_id, *     int          num_vb, *     int          nonreps, *     int          maxreps *     )* \ce** DESCRIPTION** This routine builds SNMPv2c packets and all SNMPv1 packets except SNMPv1 * 'TRAP' PDUs. Use SNMP_Create_Request2() for SNMP managers. If you plan to * implement agents, use it for SMNPv2 'TRAP' and 'INFORM' PDUs instead.* SNMP_Create_Request2() allocates and initializes a new packet structure of * type 'SNMP_PKT_T' for a SNMP message.* If you are building a multi-lingual agent, you need to call * SNMP_Create_Request2() and SNMP_Create_Trap() to build appropriate SNMPv1 and * SNMPv2 'TRAP' PDUs.** \&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 <ptype>* Indicate the SNMP PDU type. The following types are available to both SNMPv1 * and SNMPv2: 'GET_REQUEST_PDU', 'GET_NEXT_REQUEST_PDU' and 'SET_REQUEST_PDU' * types. The following PDU types are available only to SNMPv2: 'TRAP2_PDU', * 'INFORM_REQUEST_PDU', and 'GET_BULK_REQUEST_PDU' types.* \i <version>* Specify the SNMP protocol version as either 0 ('SNMP_VERSION_1') or 1 * ('SNMP_VERSION_2.)' 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 <request_id>* Contain the transaction identifier for the packet.* \i <num_vb>* Indicate how many 'VarBind' entries will be placed into the 'VarBindList'.* \i <nonreps>* Specify number to put into the non-repeaters field in PDUs of type 'GET BULK * REQUEST'.* \i <maxreps>* Specify number to put into the max-repetitions field in PDUs of type 'GET * BULK REQUEST'.* \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_Request_V3(), SNMP_Create_Trap(), SNMP_Encode_Packet()*/SNMP_PKT_T *  SNMP_Create_Request2(int	  ptype,		       int	  version,		       int	  commleng,		       char      *community,		       sbits32_t  request_id,		       int	  num_vb,		       int	  nonreps,		       int	  maxreps){SNMP_PKT_T *rp;/* Deteremine if the pdu type is acceptable for the requested version */switch (version) {#if INSTALL_ENVOY_SNMP_VERSION_1    case SNMP_VERSION_1:        if ((ptype != GET_REQUEST_PDU) &&	    (ptype != GET_NEXT_REQUEST_PDU) &&	    (ptype != SET_REQUEST_PDU))	    return 0;	break;#endif /* INSTALL_ENVOY_SNMP_VERSION_1 */#if INSTALL_ENVOY_SNMP_VERSION_2    case SNMP_VERSION_2:	if ((ptype != GET_REQUEST_PDU)      &&	    (ptype != GET_NEXT_REQUEST_PDU) &&	    (ptype != SET_REQUEST_PDU)      && 	    (ptype != GET_BULK_REQUEST_PDU) &&	    (ptype != INFORM_REQUEST_PDU)   &&	    (ptype != TRAP2_PDU))	    return 0;	break;#endif /* INSTALL_ENVOY_SNMP_VERSION_2 */    default: /* unknown version number */	return(0);    }if ((rp = _snmp_create_request(num_vb)) == 0)    return 0;rp->snmp_version 		= version;rp->pdu_type 			= (ATVALUE_T)ptype;rp->pdu.std_pdu.request_id 	= request_id;if (ptype == GET_BULK_REQUEST_PDU) {    rp->pdu.std_pdu.error_status = nonreps;    rp->pdu.std_pdu.error_index  = maxreps;    }else {    rp->pdu.std_pdu.error_status = 0;    rp->pdu.std_pdu.error_index  = 0;    }EBufferPreLoad(BFL_IS_STATIC, &(rp->community), community, commleng);return rp;}

⌨️ 快捷键说明

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