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

📄 sys.c

📁 wm PNE 3.3 source code, running at more than vxworks6.x version.
💻 C
字号:
/* $Header: /usr/cvsroot/target/src/wrn/wm/demo/unxagent/sun/sys.c,v 1.4 2003/01/15 14:05:00 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: sys.c,v $ * Revision 1.4  2003/01/15 14:05:00  josh * directory structure shifting * * Revision 1.3  2002/05/23 19:42:43  josh * updates to support the entity MIB * * Revision 1.2  2001/11/09 21:49:04  josh * unxagent demo path adjustment, first pass * * Revision 1.1.1.1  2001/11/05 17:49:17  tneale * Tornado shuffle * * Revision 7.8  2001/01/19 22:25:03  paul * Update copyright. * * Revision 7.7  2000/07/10 15:55:17  mrf * Add configuration for Cygnus NT environment with associated changes. * * Revision 7.6  2000/03/17 00:15:35  meister * Update copyright message * * Revision 7.5  1998/06/23 22:07:31  sar * Add some include files to keep compilers happy * * Revision 7.4  1998/02/25 04:58:24  sra * Update copyrights. * * Revision 7.3  1997/03/20 06:54:16  sra * DFARS-safe copyright text.  Zap! * * Revision 7.2  1997/02/25 10:58:16  sra * Update copyright notice, dust under the bed. * * Revision 7.1  1997/01/08 23:01:49  sar * Updated copyright and modified include files to use envoy/h as * appropriate * * Revision 7.0  1996/03/15  22:07:57  sar * Updated revision to 7.0 and copyright to 96 * * Revision 6.0  1995/05/31  21:49:50  sra * Release 6.0. * * Revision 5.1  1995/03/21  19:37:43  sar * Updated method routines to use new api & scheme * Turned get_sysUpTime into a glue function, with sysuptime as the * data gatherer.  This allows us to use sysuptime internally instead * of trying to fake out get_sysUpTime's argument list * * Revision 5.0  1994/05/16  16:20:43  sar * Updated revision to 5.0 and copyright to include 1994 * * Revision 4.0  1993/06/24  17:34:02  sar * Updated rev to 4.0 copyright to 93 * * Revision 3.3  1993/06/13  02:53:35  sar * Removed sysent.h and libc.h and moved them into envoy.h * for mach386. * * Revision 3.2  1993/05/28  17:57:05  sar * modified get_sysuptime to have the correct argument list. * * Revision 3.1  1993/05/13  22:20:00  sar * Added defines, includes (<sysent.h>, <errno.h>, <libc.h>) and casts * (struct sockaddr *) as well as changed memfoo to MEMFOO and objidcmp * to llist_cmp to get rid of warnings. * * Revision 3.0  1992/04/03  19:53:44  dab * Release 3.0 * * Revision 2.101  92/02/04  10:47:31  dab * Updated for release 3.0 of SNMP. *  * Revision 2.100  92/02/03  16:46:18  dab * Generic unix SNMP agent. *  *  *    Rev 2.1   23 May 1990 10:52:56 * Removed the routine to set sysLocation -- it is a read-only variable. *  *    Rev 2.0   31 Mar 1990 15:34:24 * Initial revision. * *//* [clearcase]modification history-------------------01a,19apr05,job  update copyright notices*/#include <wrn/wm/common/config.h>#include <stdio.h>#include <sys/time.h>#include <sys/types.h>#include <sys/socket.h>#include <netinet/in.h>#include <net/if.h>#if !INSTALL_on_ntgcc#include <netinet/if_ether.h>#endif#include <unistd.h>#include <wrn/wm/snmp/engine/asn1.h>#include <wrn/wm/snmp/engine/snmp.h>#include <wrn/wm/snmp/engine/auxfuncs.h>#include "snmpvars.h"#include "general.h"UINT_32_T  sysuptime(void){struct timeval now_is;(void) gettimeofday(&now_is, 0);return((UINT_32_T)(((now_is.tv_sec - boot_at.tv_sec) * 100) +		   (now_is.tv_usec / 10000)));}  #if (INSTALL_ENVOY_ENTITY_MIB)bits32_t    envoy_get_sysuptime(){return(sysuptime());}#endif /* #if (INSTALL_ENVOY_ENTITY_MIB) *//****************************************************************************NAME:  get_sysUpTimePURPOSE:  Get the system uptime object PARAMETERS:	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 processed.	VB_T *		Variable being processed.RETURNS: void****************************************************************************//*ARGSUSED*/void  get_sysUpTime(OIDC_T		 last_match,		int		 tcount,		OIDC_T		*tlist,		SNMP_PKT_T	*pktp,		VB_T		*vbp){      /* test that the instance information is correct,   we should have a sinlge oid of value 0 */if ((tcount != 1) || (*tlist != 0))    getproc_nosuchins(pktp, vbp);else    getproc_got_uint32(pktp, vbp, sysuptime(), VT_TIMETICKS);return;}/****************************************************************************NAME:  get_sysNamePURPOSE:  Get the system namePARAMETERS:	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 processed.	VB_T *		Variable being processed.RETURNS: void****************************************************************************//*ARGSUSED*/void  get_sysName(OIDC_T		 last_match,	      int		 tcount,	      OIDC_T		*tlist,	      SNMP_PKT_T	*pktp,	      VB_T		*vbp){static int nm_length = 0;/* test that the instance information is correct,   we should have a sinlge oid of value 0 */if ((tcount != 1) || (*tlist != 0))    getproc_nosuchins(pktp, vbp);else {    /* The address returned *MUST* reference a static location */    if (nm_length == 0) {	(void)gethostname(snmp_sysName, MAX_SYSNAME);	nm_length = strlen(snmp_sysName);	}    getproc_got_string(pktp, vbp, nm_length, snmp_sysName, 0, VT_STRING);    }return;}#if 0/*ARGSUSED*/voidset_sysLocation(lastmatch, compc, compl, cookie, cp, length)	OIDC_T	lastmatch;	int	compc;	OIDC_T	*compl;	char	*cookie;	char	*cp;	int	length;{int lngth;if (length != 0)  {  lngth = min(MAX_SYSLOCATION-1, length);  void memcpy(cookie, cp, min(MAX_SYSLOCATION, lngth));  cookie[lngth] = '\0';  }}#endif/****************************************************************************NAME:  set_sysContactPURPOSE:  set the given value into the contact name areaPARAMETERS:	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 processed.	VB_T *		Variable being processed.RETURNS: void****************************************************************************//*ARGSUSED*/void  set_sysContact(OIDC_T		 last_match,		 int		 tcount,		 OIDC_T		*tlist,		 SNMP_PKT_T	*pktp,		 VB_T		*vbp){int lngth;OCTET_T *cp;lngth = EBufferUsed(&vbp->value_u.v_string);cp = (OCTET_T *)(VB_TO_COOKIE(vbp));if (lngth) {    MEMCPY(cp, EBufferStart(&vbp->value_u.v_string), lngth);    cp[lngth] = '\0';    }setproc_good(pktp, vbp);return;}/****************************************************************************NAME:  test_sysContactPURPOSE:  Test the instance information and values to be set.PARAMETERS:	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 processed.	VB_T *		Variable being processed.RETURNS: void****************************************************************************//*ARGSUSED*/void  test_sysContact(OIDC_T	 last_match,		  int		 tcount,		  OIDC_T	*tlist,		  SNMP_PKT_T	*pktp,		  VB_T		*vbp){int lngth;lngth = EBufferUsed(&vbp->value_u.v_string);if (lngth > (MAX_SYSCONTACT - 1)) {    testproc_error(pktp, vbp, WRONG_LENGTH);    return;    }/* test that the instance information is correct,   we should have a sinlge oid of value 0 */if ((tcount != 1) || (*tlist != 0))    testproc_error(pktp, vbp, NO_CREATION);else     testproc_good(pktp, vbp);return;}/****************************************************************************NAME:  get_sysServicesPURPOSE:  Get the system servicesPARAMETERS:	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 processed.	VB_T *		Variable being processed.RETURNS: void****************************************************************************//*ARGSUSED*/void  get_sysServices(OIDC_T	 last_match,		  int		 tcount,		  OIDC_T	*tlist,		  SNMP_PKT_T	*pktp,		  VB_T		*vbp){/* test that the instance information is correct,   we should have a sinlge oid of value 0 */if ((tcount != 1) || (*tlist != 0))    getproc_nosuchins(pktp, vbp);else    getproc_got_int32(pktp, vbp, 0x4F);return;}intsys_init(){return 0;}

⌨️ 快捷键说明

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