📄 libfuncs.c
字号:
/* $Header: /usr/cvsroot/target/src/wrn/wm/demo/unxagent/sun/libfuncs.c,v 1.2 2001/11/09 21:49:02 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: libfuncs.c,v $ * Revision 1.2 2001/11/09 21:49:02 josh * unxagent demo path adjustment, first pass * * Revision 1.1.1.1 2001/11/05 17:49:17 tneale * Tornado shuffle * * Revision 7.9 2001/01/19 22:25:02 paul * Update copyright. * * Revision 7.8 2000/03/17 00:15:26 meister * Update copyright message * * Revision 7.7 1998/06/23 22:07:30 sar * Add some include files to keep compilers happy * * Revision 7.6 1998/06/07 02:58:59 sar * Moved the validate routines to snark library * leaving proxy_send_rtn here * * Revision 7.5 1998/06/03 22:07:41 sar * add v3 validation routine * * Revision 7.4 1998/02/25 04:58:21 sra * Update copyrights. * * Revision 7.3 1997/03/20 06:54:12 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.3 1996/01/23 16:25:06 sar * Changed the install view option to install rfc1445 views * * Revision 6.2 1995/11/14 22:46:31 sar * Added proxy handling code. * * Revision 6.1 1995/11/01 01:03:00 sar * changed memcpy to MEMCPY * removed casts of 0 * removed validate_address * * Revision 6.0 1995/05/31 21:49:35 sra * Release 6.0. * * Revision 5.1 1995/03/21 19:37:43 sar * Updated method routines to use new api & scheme * * Revision 5.0 1994/05/16 16:20:43 sar * Updated revision to 5.0 and copyright to include 1994 * * Revision 4.1 1994/05/04 22:33:56 sar * while validating the snmp_community we now set the view_index to 1 * for use with the sub agent and use_v2_views options. * * Revision 4.0 1993/06/24 17:31:48 sar * Updated rev to 4.0 copyright to 93 * and made the if defined(install..) checks be if install * * Revision 3.7 1993/05/14 15:11:42 sar * renamed private field in packet structure to be user_private * * Revision 3.6 1993/05/13 22:22:28 sar * Added some defines, includes (<sysent.h> <errno.h> <libc.h>), casts * (struct sockaddr *) and changed memfoo to MEMFOO and objidcmp to * llist_cmp to get rid of warnings from the compiler. * * Revision 3.5 1993/04/26 20:20:12 sar * Added ifdefs to allow clean version 1 and version 2 makes. * * Revision 3.4 1993/04/22 20:23:42 sar * Updated macros and defines to use the naming scheme. * For example we now use INSTALL_ENVOY_SNMP_VERSION_1 or _2. * * Revision 3.3 1993/02/18 20:29:44 sar * Updated check on SGRP to be either a check on SGRPv1 or (SGRPv1 || SGRPv2) * * Revision 3.2 1993/02/17 20:42:20 sar * Added validate_SNMP_address. Currently this function copies the * source and dest addresses into the received packet. Eventually it * should check that the addresses match those in the parties being used. * * Revision 3.1 92/09/01 11:37:56 dab * Fixed up for Mach386 * * Revision 3.0 92/04/03 19:53:44 dab * Release 3.0 * * Revision 2.101 92/02/04 10:46:51 dab * Updated for release 3.0 of SNMP. * * Revision 2.100 92/02/03 16:46:12 dab * Generic unix SNMP agent. * * * Rev 2.0 31 Mar 1990 15:34:12 * Initial revision. * * Rev 1.6 27 Apr 1989 15:56:36 * Removed unused variables * * Rev 1.5 17 Mar 1989 22:50:16 * Memory allocation now fails if an attempt is made to allocate zero bytes. * * Rev 1.4 17 Mar 1989 21:41:38 * Calls to memcpy/memset protected against zero lengths * * Rev 1.3 11 Jan 1989 13:24:32 * * Rev 1.2 10 Oct 1988 21:49:36 * Source reorganization * * Rev 1.1 14 Sep 1988 17:57:10 * Moved includes of system include files into libfuncs.h. * * Rev 1.0 12 Sep 1988 10:47:00 * Initial revision.*//* [clearcase]modification history-------------------01a,19apr05,job update copyright notices*/#if defined(MEM_TRACE)#include <stdio.h>#endif#include <sys/param.h>#include <sys/types.h>#include <sys/socket.h>#include <netinet/in.h>#include <wrn/wm/snmp/engine/asn1.h>#include <wrn/wm/snmp/engine/snmp.h>#include <wrn/wm/snmp/engine/snmpstat.h>#include <wrn/wm/snmp/engine/auxfuncs.h>#include <wrn/wm/snmp/engine/proxy_tr.h>#include "snmpvars.h"#include <wrn/wm/demo/snmpfunc.h>void gen_auth_fail_trap __((void));extern void send_traps __((int, int));extern int name_to_ulong __((char *tname, u_long *tlong));/**************************************************************************** This module contains user provided/modifiable procedures.****************************************************************************/#if (INSTALL_ENVOY_SNMP_PROXY)/****************************************************************************NAME: proxy_send_rtnPURPOSE: Routine to attempt to transmit a byte string for proxiesPARAMETERS: EBUFFER_T * The buffer to send ptr_t Information as to where to send the buffer.RETURNS: sbits32_t A reasonable timeout period for this transport ****************************************************************************/sbits32_t proxy_send_rtn(EBUFFER_T *ebuf, ptr_t cookie){struct sockaddr_in to;TRANS_STUFF_T *tstuff = (TRANS_STUFF_T *)cookie;to.sin_family = AF_INET;to.sin_port = htons(tstuff->port);if (name_to_ulong(tstuff->addr_str, &(to.sin_addr.s_addr))) return(0);/* snmp_socket is a global varialbe for the socket we receive/transmit on */ (void)sendto(snmp_socket, ebuf->start_bp, EBufferUsed(ebuf), 0, (struct sockaddr *)&to, sizeof(to));return(100);}#endif /* (INSTALL_ENVOY_SNMP_PROXY) *//********************************************************************** gen_auth_fail_trap -- Issue an authentication failure trap. **********************************************************************/void gen_auth_fail_trap(){if (snmp_auth_traps == 0) return;send_traps(snmp_socket, AUTH_FAILURE);}/****************************************************************************NAME: get_snmpEnableAuthTrapsPURPOSE: Assign the info about authentication traps to the vb.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_snmpEnableAuthTraps(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, (INT_32_T)(snmp_auth_traps ? 1 : 2));return;}/****************************************************************************NAME: set_snmpEnableAuthTrapsPURPOSE: Set the value for the enable auth trap 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 set_snmpEnableAuthTraps(OIDC_T last_match, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp){if (vbp->value_u.v_number == 1) snmp_auth_traps = 1;else snmp_auth_traps = 0;setproc_good(pktp, vbp);return;}/****************************************************************************NAME: test_snmpEnableAuthTrapsPURPOSE: Determine if the instance and value inforamtion are acceptable (for setting enable authentication traps).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_snmpEnableAuthTraps(OIDC_T last_match, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp){/* test the value we are being asked to set */if ((vbp->value_u.v_number != 1) && (vbp->value_u.v_number != 2)) { testproc_error(pktp, vbp, WRONG_VALUE); 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); return; }testproc_good(pktp, vbp);return;}int libfuncs_init(){return 0;}/****************************************************************************NAME: get_async_cookiePURPOSE: Get the int32 that has been stashed into the cookie field. This tests the instance information and is useful for scalar objects (instance has 1 subid of value 0).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_async_cookie(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, (INT_32_T)(VB_TO_COOKIE(vbp)));return;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -