📄 snmpint.c
字号:
/* $Header: /usr/cvsroot/target/src/wrn/wm/demo/snmptalk/snmpint.c,v 1.4 2003/01/15 14:04:56 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 1991-1997 Epilogue Technology Corporation. * Copyright 1998 Integrated Systems, Inc. * All rights reserved. ****************************************************************************//* interface routines to the SNMP for snmptalk *//* * $Log: snmpint.c,v $ * Revision 1.4 2003/01/15 14:04:56 josh * directory structure shifting * * Revision 1.3 2002/03/11 19:17:10 josh * snmptalk's destination address is now stored and passed around * as an ipaddr_t. This required changes to a lot of internal function * calls that used to expect an inaddr_t to be passed around. Also, * snmptalk is now capable of using IPv6 sockets * * Revision 1.2 2001/11/08 16:47:31 tneale * Updated for newset file layout * * Revision 1.1.1.1 2001/11/05 17:49:12 tneale * Tornado shuffle * * Revision 7.19 2001/01/19 22:24:50 paul * Update copyright. * * Revision 7.18 2000/03/17 00:14:35 meister * Update copyright message * * Revision 7.17 1998/07/20 01:51:08 sar * removed the dynamic/static flag from the v3 packet creation routine * * Revision 7.16 1998/06/23 20:56:44 sar * Moved parse.h to snark/h/parse.h * * Revision 7.15 1998/06/16 05:36:38 sar * clean up some type info, cast some strings * * Revision 7.14 1998/06/08 19:46:46 sar * Changed the installation option we check on for the snmp stats * to envoy_need_stats, to make it easier to change in the future. * * Revision 7.13 1998/06/07 02:51:40 sar * Move the validate routines to snark library, leaving * a proxy_send_rtn and envoy_now stubs that either do the * right thing or point to the right routine. * * Revision 7.12 1998/06/04 15:13:50 sar * Cleaned up some installation options to allow v3 to work if v2 isn't * installed * * Revision 7.11 1998/06/03 21:50:30 sar * Moved nvutils and nvviews to snark/lib so we can have one copy shared * amongst the demos * Moved the common string functions from stdf to common/lib and created * a series of macros for this code to use * Moved strdup to snark/lib and renamed it to etc_strdup to avoid * needing one from the system libraries * * Revision 7.10 1998/05/23 18:03:48 sar * Added code to handle v3 options, also moved the rfc1445 code * around some to mesh it with the rfc2275 code * * Revision 7.9 1998/02/25 04:58:05 sra * Update copyrights. * * Revision 7.8 1997/10/16 23:48:29 sar * allow tset to use ipaddress * * Revision 7.7 1997/03/20 06:53:56 sra * DFARS-safe copyright text. Zap! * * Revision 7.6 1997/02/25 10:58:16 sra * Update copyright notice, dust under the bed. * * Revision 7.5 1997/02/19 08:10:29 sra * More fun merging snmptalk into snark, general snark cleanup. * * Revision 7.4 1997/01/09 22:44:19 sar * Modified the command calling sequence again, this time to mathc * what snark was using. * * Revision 7.3 1997/01/08 23:26:53 sar * Updated include files to use envoy/h as appropriate after * move from envoy/utils to snark/snmptalk * * Revision 7.2 1997/01/08 01:55:00 sar * Modified to use the snark sty driver for in/output * * Revision 7.1 1996/10/30 22:06:39 sar * Added a stub proxy_release_private routine so that the code matches * the include files * * Revision 7.0 1996/03/18 20:19:20 sar * Updated rev to 7.0 and copyright to 96 * * Revision 6.5 1996/02/27 00:01:57 sar * removed parse_bitstring * * Revision 6.4 1996/01/15 20:08:00 sar * added validate_SNMP_address as a shell routine that calls * validate_SNMP_community, so that older envoy.h files will * still work. * * Revision 6.3 1996/01/10 16:41:40 sar * Usec updates * * Revision 6.2 1995/10/20 22:39:59 sar * removed no_pp stuff * removed command info for dparty, sparty, context, ppc and sync * added ansi pp stuff for some functions * * Revision 6.1 1995/06/12 20:54:03 dab * Updated the GET and NEXT commands to take multiple arguments. * * Revision 6.0 1995/05/31 21:50:23 sra * Release 6.0. * * Revision 5.5 1994/11/09 01:43:52 sar * Read the nv config file if/when we need to. If the master_agent or * v2_view options are installed we always read it, if they aren't vut * v2 is installed we check the snmptalk_version flag if it is 2 we read * the file if it is 1 we don't. The first time we switch to v2 we * try and read the file and complain if one doesn't exist. If we only * have v1 installed we never read the config file. * * Revision 5.4 1994/10/28 19:50:09 sar * Modifed error flags, authorization error shouldn't have vbs. * Also added a test in the error print routine so that we don't try and * print out vbs < 1 (1 is the lowest index). * * Revision 5.3 1994/09/29 18:33:21 sar * Only include & use v2 types if necessary (v2 or use_v2_types installed). * * Revision 5.2 1994/09/23 19:29:50 sar * Removed the old non volatile scheme and added a new one that is hopefully * easier to use and allows for some new options such as a read only * flag to prohibit creating a new config file. The config stuff will * only be included if needed. * In snmptalk and snmpint added a next function. * * Revision 5.1 1994/07/24 15:41:03 dab * Added ability to set UDP port used by manager and the set command can * now specify enumerated integer values by symbolic name. * * Revision 5.0 1994/05/16 15:57:40 sar * Updated revision to 5.0 and copyright to include 1994 * * Revision 4.8 1994/05/13 21:52:39 sar * When writing out the version stamp for party database config files use * a long as the version is 32 bits. * * Revision 4.7 1994/05/12 17:20:45 sar * We were doing snmp_view_config twice in some cases so I removed one of * the calls. * * Revision 4.6 1994/05/11 17:57:30 sar * added master_agent as a reason to include snmptalk_view_init. * * Revision 4.5 1994/05/09 20:59:43 sar * Added SNMPTalk_View_Init for use with USE_V2_VIEWS option (so we can * install a v2 view without installing the rest of the v2 database. * * Revision 4.4 1994/04/29 20:21:12 sar * Added a line to set the view_index to 1 while validating the community. * This probably should be upgraded at some time to allow a dynamic choice. * * Revision 4.3 1993/11/12 19:41:28 sar * Removed some unnecessary & from in front of the set_state->bstring var. * * Revision 4.2 1993/10/06 19:45:35 sar * Added more flags to snmp_errors_flags to handle the snmp v2 cases. * * Revision 4.1 1993/10/05 17:13:12 sar * Modified the handling of parsing a bit string to check for char 1 instead * of int 1. Also adjusted the argument counter and pointers in tset to * get the right info to parse_bitstring. * * Revision 4.0 1993/06/24 17:14:56 sar * Updated rev to 4.0 and copyright to 93 * * Revision 3.38 1993/06/17 23:28:53 sar * Modified sync_print routine to handle exceptions and parties not * being there. * * Revision 3.37 1993/06/13 02:48:16 sar * moved inclusion of stdf.h to be after asn1.h so that NO_PP will be defined * if desired. * * Revision 3.36 1993/06/02 23:10:22 dab * Changed #ifdef's to #if's for things from install.h * * Revision 3.35 1993/05/31 19:07:48 sar * use fprintf rather than fwrite to output the version stamps for * the v2 config files. Also changed the call to acl_nvwrite to have * the source, dest in the correct order. * * Revision 3.34 1993/05/29 00:18:57 sar * swapped the sparty and dparty args to snmp_acl_install * * Revision 3.33 1993/05/25 18:27:42 sar * replaced the static define of partyauthclock with a call to string2oid with * partyauthclock as the string. * * Revision 3.32 1993/05/22 01:09:35 sar * Cleaned up some ifdefs of snmpstats and bulk usage so we can compile * with out stats and in v1 mode. * * Revision 3.31 1993/05/20 20:34:22 sar * tidied up some fprintf commands. * * Revision 3.30 1993/05/19 20:38:22 sar * Added procedure prototypes to some of the routines. (#if !defined(NO_PP)...) * * Revision 3.29 1993/05/17 20:36:13 sar * added <install.h> and "stdf.h" to include string routines that zortech * didn't have. * * Revision 3.28 1993/05/17 14:04:46 sar * changed SNMP_Create_Party_Request to be SNMP_Create_V2_Request * * Revision 3.27 1993/05/14 19:01:01 sar * Removed variable object from sync * * Revision 3.26 1993/05/14 15:12:21 sar * renamed private field in packet structure to be user_private * * Revision 3.25 1993/05/13 19:08:06 sar * Added code to use a file implementation of nv memory * * Revision 3.24 1993/05/05 14:59:14 sar * Added des option to etc.ini file * * Revision 3.23 1993/05/03 17:08:45 sar * modified do_bulk to allocate the memory it needs for oids rather than using * stack based area. This makes the stack smaller and avoided a stack overflow * condition elsewhere. * * Revision 3.22 1993/04/30 23:01:50 sar * modified the sync_print routine to use the lockable version of timestamp * routines. * * Revision 3.21 1993/04/26 20:30:09 sar * Added ifdefs (and corrected code) to allow clean makes of version 1 or 2 * * Revision 3.20 1993/04/23 23:37:54 sar * Collected objectid defines in one file (wkobj.h) and modified do_bulk * so it will do the right thing if it's parties don't exist. Modified * response_walk so it can handle a zero length varbind field. * * Revision 3.19 1993/04/22 20:21:34 sar * Update macros and defines to use the general naming scheme * * Revision 3.18 1993/04/19 18:25:26 sar * added some static tags * * Revision 3.17 1993/04/07 21:48:05 sar * added creation of a transport domain. * * Revision 3.16 1993/03/20 00:20:35 sar * Updated to look for views in the init file. * * Revision 3.15 1993/03/05 04:22:20 sar * added capability of setting object ids. * * Revision 3.14 1993/03/04 18:21:34 sar * We now look for (and require) the view to be set for contexts. * * Revision 3.13 1993/03/03 20:27:13 dab * Made ACL priviledges settable from the config file. * * Revision 3.12 1993/03/03 20:05:36 dab * Rewrote SNMPTalk_Party_Init() to read the party information from a config * file. * * Revision 3.11 1993/02/26 22:34:49 sar * Added new strings to be printed out if error status != 0 * * Revision 3.10 1993/02/26 17:16:43 dab * Added version 2 style check for end-of-mib in walks. * * Revision 3.9 1993/02/24 23:39:11 sar * Updated use of (party, context, create)_calls and setting of the appropriate * fields to have the creates generate basically the defval information. * Also finished moving the creates/installs from sockets.c to snmpint.c * * Revision 3.8 1993/02/24 01:07:50 sar * Updated to use the new OIDC_T/length version of the SNMP_(Party, Context)_* * calls. Also updated to use the new acl routines. * * Revision 3.7 1993/02/23 19:02:01 dab * Check for error return from SNMPTalk_Create_Request. * Added SNMPTalk_Party_Init(). * * Revision 3.6 1993/02/22 20:56:25 dab * Added SNMPTalk_Create_Request() so the code would more easily do * both v1 and v2. * * Revision 3.5 1993/02/18 20:42:13 sar * Removed init of snmpstats. We were initing to zero which the compilers * should do for us and now we don't have to change it whenever we add a * new counter. * * Revision 3.4 1993/02/17 21:26:44 sar * Items not included in the log for 3.3 * Added validate_SNMP_address as a stub routine to copy addresses into the * packet. * Updated the do_set, do_tset, do_get, response_walk and do_walk commands * to use the v2 mechanisims. This should be updated to allow the user * to choose which version to use instead of hardwiring it as curretnly. * * Revision 3.3 1993/02/17 21:21:53 sar * Updated the stats for use with v1 and v2. * Added do_sync to get a timestamp for the specified party. It then * calls sync_print to update the party if necessary. * Added sync_print to update a party's timestamp according to the * value in the received packet. * Added do_bulk to test the get_bulk pdu. It takes as arguments the * number of non-repeaters, the max reps and some oids to form into a pkt. * * Revision 3.1 92/06/16 16:05:44 dab * Added batch mode * * Revision 3.0 92/04/03 19:53:14 dab * Release 3.0 * * Revision 2.116 92/02/14 10:48:16 dab * Added tset command. * * Revision 2.115 92/02/11 10:56:23 dab * Casts to make Microsoft C happier. * * Revision 2.114 91/12/12 09:40:58 dab * Changed to use "nprint.h" instead of <print.h>. * * Revision 2.113 91/12/10 10:50:43 dab * Errors now print which varbind got the error. * * Revision 2.112 91/11/07 09:29:52 dab * New validate_SNMP_community and removed user_auth_encode. * * Revision 2.111 91/11/06 13:55:06 dab * Added function prototypes for internal functions and other fixups so * pickier compilers would be happy. * * Revision 2.110 91/11/05 09:41:32 dab * Had a test backwards in the set routine so printed an extra (NULL) * if there were no errors and didn't print the error if there was. * * Revision 2.109 91/11/04 18:56:36 dab * Improved the set command to take multiple arguments to set in a * single packet. Also fixed the setting of IP addresses which was * broken when md_hostname_to_addr went async. * * Revision 2.108 91/11/04 16:15:08 dab * Improved for use with higher warning levels on the compiler. * * Revision 2.107 91/11/03 10:19:45 dab * Include snmpstat.h as well. * * Revision 2.106 91/10/30 09:40:47 dab * Disabled setting of IP addresses for now because of change of * interface of md_hostname_to_addr to an async one. * * Revision 2.105 91/10/30 09:22:10 dab * Don't do commands if destination isn't set. * * Revision 2.104 91/09/30 14:09:51 dab * added print_snmp_error() * * Revision 2.102 91/09/12 13:46:14 dab * No, this contains the changes for asynchronous environments. * * Revision 2.100 91/08/09 14:05:25 dab * Update version number. This is just before the work to upgrade to * release 3.0. * * Revision 1.1 91/07/11 18:13:32 romkey * Initial revision * *//* [clearcase]modification history-------------------01b,19apr05,job update copyright notices01a,25mar05,job add support for octet strings*/#include <wrn/wm/common/install.h>#include <wrn/wm/common/config.h>#include <snmptalk.h>#include <snark.h>#include <stdio.h>#include <ctype.h>#include <wrn/wm/snmp/engine/asn1.h>#include <wrn/wm/snmp/engine/localio.h>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -