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

📄 snmptalk.c

📁 wm PNE 3.3 source code, running at more than vxworks6.x version.
💻 C
📖 第 1 页 / 共 4 页
字号:
/* $Header: /usr/cvsroot/target/src/wrn/wm/demo/snmptalk/snmptalk.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. ****************************************************************************//* an interactive, command driven program for accessing the SNMP */static char snmptalk_version_string[] = "$Revision: 1.4 $";int snmptalk_major_version = 0;int snmptalk_minor_version = 0;/* * $Log: snmptalk.c,v $ * Revision 1.4  2003/01/15 14:04:56  josh * directory structure shifting * * Revision 1.3  2002/03/11 19:17:11  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.20  2001/01/19 22:24:50  paul * Update copyright. * * Revision 7.19  2000/03/17 00:14:36  meister * Update copyright message * * Revision 7.18  1999/10/29 21:41:00  paul * Minor printf format fix. * * Revision 7.17  1999/10/21 20:32:21  josh * test code for the sending and receiving of notifies * * Revision 7.16  1998/11/25 03:38:20  sra * "timeout" => "snmp_timeout" to fix OpEN symbol conflict. * * Revision 7.15  1998/08/04 19:25:14  sar * Remove some some code that was accidently committed * * Revision 7.14  1998/08/04 03:56:33  sar * Added key change code in key_chg.c and calls in snmptalk.c * * Revision 7.13  1998/06/23 20:56:45  sar * Moved parse.h to snark/h/parse.h * * Revision 7.12  1998/06/04 15:13:49  sar * Cleaned up some installation options to allow v3 to work if v2 isn't * installed * * Revision 7.11  1998/06/03 21:50:28  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:29:38  sar * Added routines for use with v3 code * * Revision 7.9  1998/03/09 16:49:00  paul * Fixed build problem in banner: sty_puts should have been sty_printf. * * Revision 7.8  1998/02/25 04:58:07  sra * Update copyrights. * * Revision 7.7  1997/10/22 03:03:31  sar * Updated makefile.cfg to use AGENTX_MASTER & AGENTX_SUB * * Added agentx_init() to snmptalk & agentx and envoy_init to sockets * * Revision 7.6  1997/03/20 06:53:58  sra * DFARS-safe copyright text.  Zap! * * Revision 7.5  1997/02/25 10:58:16  sra * Update copyright notice, dust under the bed. * * Revision 7.4  1997/02/19 08:10:29  sra * More fun merging snmptalk into snark, general snark cleanup. * * Revision 7.3  1997/01/09 22:44:19  sar * Modified the command calling sequence again, this time to mathc * what snark was using. * * Revision 7.2  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.1  1997/01/08  02:00:57  sar * use the snark sty driver code, this included changing the arg lsits * of the commands and updating the dispatch routine. * * Revision 7.0  1996/03/18  20:19:20  sar * Updated rev to 7.0 and copyright to 96 * * Revision 6.4  1996/01/10  16:41:40  sar * Usec updates * * Revision 6.3  1995/11/11  00:09:41  sar * removed rfc1445_view_routines * * Revision 6.2  1995/10/20  22:39:59  sar * removed no_pp stuff * removed command info for dparty, sparty, context, ppc and sync * * Revision 6.1  1995/06/12  20:55:45  dab * Updated the help text to indicate that the GET and NEXT commands * can take multiple arguments. * * Revision 6.0  1995/05/31  21:50:25  sra * Release 6.0. * * Revision 5.6  1995/04/28  22:23:34  sar * Added the ppc (party party context) command. * * Revision 5.5  1995/03/21  00:50:48  sar * Added a packet_dump option to snmptalk, this allows the user to trun * packet dumping on & off while snmptalk is running. * * Revision 5.4  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.3  1994/10/28  19:49:28  sar * updated printed copyright string. * * 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.4  1994/05/12  17:20:45  sar * added some commas in one of the array declarations to make the compilers * happy (around find_node and remove_node). * * Revision 4.3  1994/05/10  20:19:13  sar * Added a master_agent clause to the reasons to do view_init. * * Revision 4.2  1994/05/09  20:59:43  sar * Removed Add_Node. * * Revision 4.1  1994/02/01  23:36:27  sar * Added some test routines for use with Find, Add and Remove_Node * routines. * * Revision 4.0  1993/06/24  17:14:56  sar * Updated rev to 4.0 and copyright to 93 * * Revision 3.18  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.17  1993/06/02  23:10:22  dab * Changed #ifdef's to #if's for things from install.h * * Revision 3.16  1993/05/31  19:07:48  sar * moved mib init to be before v2 config so we can use the string2oid * routines on symbolic names. * * Revision 3.15  1993/05/19  20:38:22  sar * Added procedure prototypes to some of the routines. (#if !defined(NO_PP)...) * * Revision 3.14  1993/05/17  20:36:13  sar * Added <install.h> and "stdf.h" to include string routiens that zortech * didn't have. * * Revision 3.13  1993/05/13  19:08:06  sar * Added code to use a file implementation of nv memory * * Revision 3.12  1993/04/26  20:30:09  sar * Added ifdefs (and corrected code) to allow clean makes of version 1 or 2 * * Revision 3.11  1993/04/22  20:17:59  sar * Update macros and defines.  For example we now use INSTALL_ENVOY_SNMP_VERSION_1 * * Revision 3.10  1993/03/02  18:21:23  dab * Call read_config_defaults() to use config file and fix up * help message. * * Revision 3.9  1993/02/26  17:25:38  dab * include snmpint.h to get declaration of SNMPTalk_Party_Init * * Revision 3.8  1993/02/23  19:03:12  dab * Call SNMPTalk_Party_Init() if we're doing secure snmp. * Fixed return values from do_dparty, do_sparty, and do_context. * * Revision 3.7  1993/02/22  20:56:25  dab * Added version command.  Fixed status command to print out party * information too. * * Revision 3.6  1993/02/19  19:29:35  dab * Call read_mib to get the manager's mib. * * Revision 3.5  1993/02/17  21:24:18  sar * Added knowledge of do_sync and do_bulk so they may be called. * Added do_sparty, do_dparty, and do_context which gateher a string and * translate it to an oid then install it in the correct global var * for later use (source party, dest partyn and context resp). * * Revision 3.2  92/06/17  12:55:28  dab * Added the ability to look at a single IP route or a subset of the routes. *  * Revision 3.1  92/06/16  16:05:48  dab * Added batch mode *  * Revision 3.0  92/04/03  19:53:14  dab * Release 3.0 *  * Revision 2.114  92/02/27  16:50:29  dab * Added the 'drt' command. *  * Revision 2.113  92/02/14  10:48:22  dab * Changed help message for tset comand. *  * Revision 2.112  92/02/04  15:06:32  dab * I put the RCS revision string in the sscanf so it was updated by RCS and * then sscanf didn't do quite what I expected. *  * Revision 2.111  92/02/04  15:01:46  dab * Added the variables snmptalk_major_version and snmptalk_minor_version. * Also fixed a bug wiht the dest command where it wouldn't allow the * next command if there was an error parsing the IP address. *  * Revision 2.110  91/11/07  17:25:06  dab * Fixed set command's help. *  * Revision 2.109  91/11/06  13:55:08  dab * Added function prototypes for internal functions and other fixups so * pickier compilers would be happy. *  * Revision 2.108  91/11/05  11:21:13  dab * Fixed usage string fro 'set' command. *  * Revision 2.107  91/11/04  16:15:14  dab * Improved for use with higher warning levels on the compiler. *  * Revision 2.106  91/11/03  10:07:17  dab * Check for error return from parse_opts(). *  * Revision 2.105  91/10/30  09:22:54  dab * Many changes to support async interface to md_hostname_to_addr. *  * Revision 2.104  91/10/01  14:01:21  dab * Print version on startup. *  * Revision 2.103  91/09/30  14:10:06  dab * Setup() again returns int. * Added ARP command. *  * Revision 2.102  91/09/17  11:56:35  dab * Have setup() return void instead of int.  In the case of an error or * a command on the command line it just exits directly. *  * Revision 2.101  91/09/12  13:25:51  dab * Changed to support asynchronous environments. *  * Revision 2.100  91/08/09  14:05:26  dab * Update version number.  This is just before the work to upgrade to * release 3.0. *  * Revision 1.3  91/07/26  00:05:39  romkey * changed vars command to use mibt_entries to figure out how many * entries in mibt to search *  * Revision 1.2  91/07/11  18:41:11  romkey * added new vars command to list variables matching a regular expression *  * Revision 1.1  91/07/11  18:13:33  romkey * Initial revision *  *//* [clearcase]modification history-------------------01b,19apr05,job  update copyright notices01a,25mar05,job  add an alternate display mode to snmptalk*/#include <wrn/wm/common/install.h>#include <wrn/wm/common/config.h>#include <snmptalk.h>#include <stdio.h>#include <wrn/wm/snmp/engine/asn1.h>#include <wrn/wm/snmp/engine/localio.h>#include <wrn/wm/snmp/engine/buffer.h>#include <wrn/wm/snmp/engine/objectid.h>#include <wrn/wm/snmp/engine/snmp.h>#include <wrn/wm/snmp/engine/wkobj.h>#include "snmpint.h"#include "md.h"#include "readmib.h"#include "mibutils.h"#include <wrn/wm/demo/snarklib.h>#include <wrn/wm/demo/snmpconf.h>#include <wrn/wm/demo/strdup.h>#include <wrn/wm/common/glue.h>#if INSTALL_ENVOY_AGENTX_MASTERextern void agentx_init(void);#endifextern int alt_display;enum help_level { help_none, help_short, help_long };static char *prompt = 0;static boolean_t quit_flag = 0;static int null_cmd = 1;/* The commands understood by snmptalk. */boolean_t    do_quit        (struct sty *, enum help_level, int, char **),    do_short_help  (struct sty *, enum help_level, int, char **),    do_help        (struct sty *, enum help_level, int, char **),    do_status      (struct sty *, enum help_level, int, char **),    do_dest        (struct sty *, enum help_level, int, char **),#if INSTALL_SNMP_DEMO_AGENT_IPV6    do_destv6      (struct sty *, enum help_level, int, char **),    do_scopev6     (struct sty *, enum help_level, int, char **),#endif    do_port        (struct sty *, enum help_level, int, char **),     do_read_comm   (struct sty *, enum help_level, int, char **),    do_write_comm  (struct sty *, enum help_level, int, char **),    do_packet_dump (struct sty *, enum help_level, int, char **),    do_remove      (struct sty *, enum help_level, int, char **),    do_find        (struct sty *, enum help_level, int, char **),#if INSTALL_ENVOY_SNMP_VERSION_3    do_v3_tos      (struct sty *, enum help_level, int, char **),    do_v3_con_name (struct sty *, enum help_level, int, char **),    do_v3_con_id   (struct sty *, enum help_level, int, char **),    do_v3_sec_name (struct sty *, enum help_level, int, char **),    do_v3_sec_id   (struct sty *, enum help_level, int, char **),    do_v3_key_change (struct sty *, enum help_level, int, char **),    do_v3_own_key_change (struct sty *, enum help_level, int, char **),#endif#if INSTALL_ENVOY_SNMP_VERSION_USEC    do_qos         (struct sty *, enum help_level, int, char **),    do_agent       (struct sty *, enum help_level, int, char **),    do_context     (struct sty *, enum help_level, int, char **),#endif#if defined(RECOMP)    do_vars        (struct sty *, enum help_level, int, char **),#endif    do_set         (struct sty *, enum help_level, int, char **),    do_tset        (struct sty *, enum help_level, int, char **),    do_get         (struct sty *, enum help_level, int, char **),    do_next        (struct sty *, enum help_level, int, char **),    do_bulk        (struct sty *, enum help_level, int, char **),    do_walk        (struct sty *, enum help_level, int, char **),    do_snmp_version (struct sty *, enum help_level, int, char **),    do_arp         (struct sty *, enum help_level, int, char **),    do_drt         (struct sty *, enum help_level, int, char **),    do_ifstat      (struct sty *, enum help_level, int, char **);#if (INSTALL_ENVOY_SNMP_V3_NOTIFY) && (INSTALL_ATTACHE)extern boolean_t    do_sendtrap    (struct sty *, enum help_level, int, char **);#endifstruct cmd {  char *name;  boolean_t (*rtn) (struct sty *, enum help_level, int, char **);} commands[] = {  { "?",           do_short_help, },  { "help",        do_help        },  { "quit",        do_quit        },  { "status",      do_status      },   { "dest",        do_dest        },#if INSTALL_SNMP_DEMO_AGENT_IPV6  { "destv6",      do_destv6      },  { "scopev6",     do_scopev6     },#endif  { "port",        do_port        },  { "version",     do_snmp_version },  { "read-comm",   do_read_comm   },  { "write-comm",  do_write_comm  },  { "packet-dump", do_packet_dump },   { "set",         do_set         },  { "get",         do_get         },  { "next",        do_next        },  { "walk",        do_walk        },  { "tset",        do_tset        },   { "ifstat",      do_ifstat      },  { "arp",         do_arp         },  { "drt",         do_drt         },#if defined(RE_COMP)  { "vars",        do_vars        }, #endif  { "bulk",        do_bulk        },   { "remove",      do_remove      },  { "find",        do_find        },#if INSTALL_ENVOY_SNMP_VERSION_3

⌨️ 快捷键说明

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