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

📄 valcomm.c

📁 wm PNE 3.3 source code, running at more than vxworks6.x version.
💻 C
字号:
/* $Header: /usr/cvsroot/target/src/wrn/wm/demo/winagent/valcomm.c,v 1.2 2001/11/09 21:29:37 josh Exp $ *//* * Copyright (C) 1999-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: valcomm.c,v $ * Revision 1.2  2001/11/09 21:29:37  josh * winagent path retooling * * Revision 1.1.1.1  2001/11/05 17:49:18  tneale * Tornado shuffle * * Revision 1.8  2001/01/19 22:25:11  paul * Update copyright. * * Revision 1.7  2000/03/17 00:15:52  meister * Update copyright message * * Revision 1.6  1998/10/08 19:33:50  paul * don't assume RFC1445 views * * Revision 1.5  1998/02/25 04:58:33  sra * Update copyrights. * * Revision 1.4  1997/03/20 06:53:39  sra * DFARS-safe copyright text.  Zap! * * Revision 1.3  1997/02/25 16:34:43  mrf * Added RCS log and copyright notice * *//* [clearcase]modification history-------------------01a,19apr05,job  update copyright notices*//*---------------------------------------------------------  VALCOMM.C () --  		Contains a rudimentary SNMP_validate_community user		exit routine called validate_SNMP_community.  ---------------------------------------------------------*/#include "wsagent.h"#include <sys\types.h>#include <wrn/wm/snmp/engine/snmp.h>#include <wrn/wm/snmp/engine/snmpdefs.h>/* define community names.  should be user configurable */char Get_Community[] = "public";char Set_Community[] = "private";/*---------------------------------------------------------    validate_SNMP_community() --		This function checks the community string and returns		0 if is valid, 1 if it is not.  This rudimentary		version of an "SNMP_validate_community()" function		only accepts two possible community strings:		Get_Community for read access and Set_Community for		read/write access.  ---------------------------------------------------------*/int validate_SNMP_community(SNMP_PKT_T *rp, SNMPADDR_T *pktsrc,									SNMPADDR_T *pktdst){	unsigned int	commlen;	commlen = EBufferUsed(&(rp->community));#if (DEBUG > 1)	MsgBox (NULL,			MB_OK,			"Entering validate_community. commlen = %d",			commlen);#endif /* DEBUG > 1 *//* initialize user information fields.  we don't use them. */	rp->lcl_ident = 0;	rp->user_private = (char *)0;/* * copy over address information as originally passed into * Process_Rcvd_SNMP_Packet_Async() routine. this will later * get used by our I/O completion routine to send a response * packet. */	(void)memcpy((char*)&(rp->pkt_src), (char*)pktsrc, sizeof(SNMPADDR_T));	(void)memcpy((char*)&(rp->pkt_dst), (char*)pktdst, sizeof(SNMPADDR_T));/* * set default mib view information. this won't ever get used if * we return an error because packet processing will stop. * mib_view is used for V1 views, view_index for V2, but it * can't hurt to just set both. */	rp->mib_view = 0x10;#if (INSTALL_ENVOY_SNMP_RFC1445_VIEWS)	rp->view_index = 1;#endif/* * for get or getnext PDUs, check against both Get_Community and * Set_Community.  for set PDU, only check against Set_Community. */ 	if (rp->pdu_type != SET_REQUEST_PDU)	{		if ((strlen(Get_Community) == commlen) && (MEMCMP(Get_Community,							rp->community.start_bp, commlen) == 0))			return 0;	}	if ((strlen(Set_Community) == commlen) && (MEMCMP(Set_Community,						rp->community.start_bp, commlen) == 0))		return 0;/* the community is not valid */#if DEBUG	MsgBox (NULL,			MB_OK,			"Invalid SNMP community string!");#endif /* DEBUG */return 1;} 

⌨️ 快捷键说明

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