📄 snmptest.c
字号:
/* * Copyright 2000-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 1993-1997 Epilogue Technology Corporation. * Copyright 1998 Integrated Systems, Inc. * All rights reserved. *//* * $Log: snmptest.c,v $ * Revision 1.2 2001/11/06 21:20:38 josh * revised new path hacking * * Revision 1.1.1.1 2001/11/05 17:47:45 tneale * Tornado shuffle * * Revision 9.1 2000/03/17 00:19:53 meister * Update copyright message * * Revision 9.0 1998/10/16 22:12:56 sar * Update version stamp to match release * * Revision 8.2 1998/06/05 18:53:31 sra * "#include <foo.h>" => "#include <envoy/h/foo.h>". * * Revision 8.1 1998/02/25 04:53:25 sra * Update copyrights. * * Revision 8.0 1997/11/18 00:57:12 sar * Updated revision to 8.0 * * Revision 7.3 1997/03/20 06:49:40 sra * DFARS-safe copyright text. Zap! * * Revision 7.2 1997/02/25 10:49:26 sra * Update copyright notice, dust under the bed. * * Revision 7.1 1997/02/17 23:58:58 sar * Fix spelling of envoy_snmp_rfc1445_views * * Revision 7.0 1996/03/18 20:24:05 sar * Updated rev to 7.0 and copyright to 96 * * Revision 6.2 1996/01/23 18:41:43 sar * made install_envoy_rfc1445 be install_envoy_snmp_rfc1445 * * Revision 6.1 1995/11/01 00:38:58 sar * Changed version2_view_init to rfc1445_view_init and * changed the install option for view init * * Revision 6.0 1995/05/31 21:49:26 sra * Release 6.0. * * Revision 5.3 1995/05/05 23:08:18 sar * Cleaned up some compiler warnings. * * Revision 5.2 1994/10/28 19:40:47 sar * Split the v2 view stuff from the party stuff so the views may be used * in a v1 setting. * * Revision 5.1 1994/07/19 19:29:32 sar * Add a conditional call to version2_init, to set up the version 2 database * if needed. * * Revision 5.0 1994/05/16 17:21:18 sar * Updated revision to 5.0 and copyright to include 1994 * * Revision 4.0 1993/06/24 17:53:56 sar * Updated rev to 4.0 and copyright to 93 * *//* [clearcase]modification history-------------------01b,19apr05,job update copyright notices01a,24nov03,job update copyright information*/#include <stdio.h>#if defined(CORELEFT)#include <alloc.h>#endif#include <wrn/wm/snmp/engine/snmp.h>#include "snmpvars.h"#define TBSIZE 2048static unsigned char genbuff[TBSIZE] = {0,0};static unsigned char rcvbuff[TBSIZE];static SNMPADDR_T psrc = {0};static SNMPADDR_T pdst = {0};#if (INSTALL_ENVOY_SNMP_RFC1445_VIEWS)extern void rfc1445_view_init(void);#endifint main(argc, argv)int argc;char **argv;{FILE *infile;unsigned char *cp;int bufcnt;EBUFFER_T ebuff;int i;if (argc != 2) { printf("Usage: test input-file\n"); exit(1); }if ((infile = fopen(argv[1], "rb")) == NULL) { perror("Could not open input file"); exit(1); }for(bufcnt = 0, cp = rcvbuff; cp < &rcvbuff[TBSIZE]; bufcnt++, cp++) { *cp = (unsigned char) fgetc(infile); if (feof(infile) || ferror(infile)) break; }fclose(infile);#if (INSTALL_ENVOY_SNMP_RFC1445_VIEWS)rfc1445_view_init();#endif#if defined(MEMAVL)printf("Memavail=%u\n", _memavl());#endif#if defined(CORELEFT)printf("Memavail=%u\n", coreleft());#endifEBufferSetup(BFL_IS_STATIC, &ebuff, genbuff, sizeof(genbuff));if (Process_Received_SNMP_Packet((unsigned char *)rcvbuff, (int)bufcnt, (SNMPADDR_T *)&psrc, (SNMPADDR_T *)&pdst, (EBUFFER_T *)&ebuff) == -1) {#if defined(MEMAVL) printf("Memavail=%u\n", _memavl());#endif#if defined(CORELEFT) printf("Memavail=%u\n", coreleft());#endif printf("Decode failure\n"); exit(1); }#define PRBUFF#if defined(PRBUFF)if (ebuff.start_bp != genbuff) printf("Start not genbuff\n");printf("Buffer contains %d bytes.\n", EBufferUsed(&ebuff));for (i = 0, cp = ebuff.start_bp; cp != ebuff.next_bp; i++, cp++) { printf("%02.2X ", *cp); if (i > 23) { i = 0; putchar('\n'); } }putchar('\n');#endifEBufferClean(&ebuff);#if defined(MEMAVL)printf("Memavail=%u\n", _memavl());#endif#if defined(CORELEFT)printf("Memavail=%u\n", coreleft());#endifprintf("Default TTL = %d\n", ip_stats.ip_DefaultTTL);exit(0);return(0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -