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

📄 creatint.c

📁 wm PNE 3.3 source code, running at more than vxworks6.x version.
💻 C
字号:
/* *  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 1996-1997 Epilogue Technology Corporation. *  Copyright 1998 Integrated Systems, Inc. *  All rights reserved. *//* * $Log: creatint.c,v $ * Revision 1.4  2003/01/15 14:05:02  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.2.4.1  2001/10/12 18:02:58  josh * adding comments to attempt to dissuade customers from using * internal request API * * Revision 9.2  2001/01/19 22:22:19  paul * Update copyright. * * Revision 9.1  2000/03/17 00:19:02  meister * Update copyright message * * Revision 9.0  1998/10/16 22:11:13  sar * Update version stamp to match release * * Revision 8.3  1998/06/05 18:53:11  sra * "#include <foo.h>" => "#include <envoy/h/foo.h>". * * Revision 8.2  1998/02/25 15:21:29  sra * Finish moving types.h, bug.h, and bugdef.h to common/h/. * * Revision 8.1  1998/02/25 04:51:35  sra * Update copyrights. * * Revision 8.0  1997/11/18 00:56:46  sar * Updated revision to 8.0 * * Revision 7.5  1997/11/01 01:25:36  sar * In the packet we are processing save a pointer to the coarse lock we * are using so that we can free it later without needing to know which * lock it was. * * Revision 7.4  1997/10/16 00:45:49  sar * Updated for agentx support, with most of the work in mibutils.c to deal * with interior leaves and the pdu processors to deal with agentx leaves, * especially their reference counts. * * Add a bug macro into the get_{read write}_lock calls to give the user * a chance if things start going wrong. * * Fixed a potential problem int the proxy code where we were trying to * stuff a 32 bit quantity into a pointer which may or may not work depending * on the platform. * * Revision 7.3  1997/03/20 06:48:48  sra * DFARS-safe copyright text.  Zap! * * Revision 7.2  1997/02/25 10:49:26  sra * Update copyright notice, dust under the bed. * * Revision 7.1  1996/10/18 21:33:02  sar * Free the packet if validate community fails * * Revision 7.0  1996/10/15  14:52:09  sar * Initial version * *//* [clearcase]modification history-------------------01b,18apr05,job  update copyright notices01a,24nov03,job  update copyright information*/#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/snmp/engine/snmpstat.h>#include <wrn/wm/common/bug.h>/****************************************************************************NAME:  SNMP_Create_Internal_RequestWARNING: This is an intentionally undocumented, internal API.  It is not         intended for customer use.          PURPOSE:  Build a snmp request packet for use with	  Process_Internal_SNMP_Packet().  This routine will	  allocate a snmp_pkt_t structure and fill in the appropriate	  header pieces as if a byte string had been decoded.  The	  caller is still responsible for attaching any desired varbinds	  via bind calls.  Note that we call the validate_community	  routine to actually validate the community and gather the	  mib view type information.PARAMETERS:        int             Packet type:                        For version 1 GET_REQUEST_PDU, GET_NEXT_REQUEST_PDU or                                      SET_REQUEST_PDU                        For version 2 GET_REQUEST_PDU, GET_NEXT_REQUEST_PDU,                                      SET_REQUEST_PDU, GET_BULK_REQUEST_PDU,                        as defined in snmpdefs.h        int             Protocol version -- SNMP_VERSION_1 or SNMP_VERSION_2                        as defined in snmpdefs.h        int             Community name length        sbits8_t *      Community name 	unsigned short int Dynamic or static flag for community name        INT_32_T        Request ID        int             Number of VarBindList elements needed (may be 0)        int             nonreps - for use with getbulk, number of non repeaters        int             maxreps - for use with getbulk, max repetitions        SNMPADDR_T *    Source of the packet        SNMPADDR_T *    Destination of the packet (most likely                        the address of the machine on which this                        code is running.)        ALENGTH_T       the maximum size of the outgoing packet        void (*)(SNMPADDR_T *,  The io completion routine,                 SNMPADDR_T *,  The args are dst, src and packet                 EBUFFER_T  *)        void (*)(SNMPADDR_T *,  The io error routine,                 SNMPADDR_T *,  The args are dst, src and error code                 int)        PTR_T           Cookie to be handed to the completion routines.RETURNS:  SNMP_PKT_T *  SNMP Packet structure, 0 on failure****************************************************************************/SNMP_PKT_T *  SNMP_Create_Internal_Request(int             ptype,			       int             version,			       int             commleng,			       sbits8_t       *community,			       unsigned short int cflags,			       INT_32_T        request_id,			       int             num_vb,			       int             nonreps,			       int             maxreps,			       ALENGTH_T       pktsize,			       IO_COMPLETE_T  *io_complete,			       ERR_COMPLETE_T *error_complete,			       PTR_T           complete_cookie){SNMP_PKT_T *rp;SNMPADDR_T dummy_addr;MEMSET(&dummy_addr, 0, sizeof(SNMPADDR_T));/* check the pdu type, but only for options allowed   by snmp_create_request2 but not by this routine.   We leave most of the version and ptype checking to    snmp_create_request2. */if ((ptype == INFORM_REQUEST_PDU) || (ptype == TRAP2_PDU))    return(0);/* create the packet structure */rp = SNMP_Create_Request2(ptype, version, commleng, (char *)community,			  request_id, num_vb, nonreps, maxreps);if (rp == 0)    return(0);/* If the lock code is installed acquire the generic read lock */#if INSTALL_ENVOY_SNMP_LOCKif (ENVOY_SNMP_GET_READ_LOCK(SNMP_CoarseLock)) {    BUG(BUG_ENVOY_LOCKING, BUG_CONTINUABLE, 0,	(BUG_OUT, "SNMP_Create_Internal_Request: coarse lock broken", 0));    SNMP_Free(rp);    return(0);    }rp->lockflags = LOCK_READ;rp->coarse_lock = &SNMP_CoarseLock;#endifswitch(SNMP_validate_community(rp, &dummy_addr, &dummy_addr)) {    case 0:        break;    case 1:    default:        SNMP_Free(rp);	return(0);    case 2:        SNMP_Free(rp);	SGRPv1v2_INC_COUNTER(snmp_stats.snmpInBadCommunityNames);	return(0);    case 3:        SNMP_Free(rp);	SGRPv1v2_INC_COUNTER(snmp_stats.snmpInBadCommunityUses);	return(0);    }/* If necessary reload the community string, create_req2 thinks it should   always be static, we give people an option, we do this after the   validate step so that the community string isn't freed if we return   an empty packet */if (cflags != BFL_IS_STATIC)    EBufferPreLoad(BFL_IS_DYNAMIC, &(rp->community), community, commleng);/* reset the maximum packet size, note that we ignore the default   so that the default can be used for wire based snmp while this   is being used internally */rp->maxpkt = pktsize;/* Attach the completion routines to the packet structure */rp->io_complete = io_complete;rp->error_complete = error_complete;rp->async_cookie = complete_cookie;return(rp);}

⌨️ 快捷键说明

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