📄 snmptasy.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 1995-1997 Epilogue Technology Corporation. * Copyright 1998 Integrated Systems, Inc. * All rights reserved. *//* * $Log: snmptasy.c,v $ * Revision 1.2 2001/11/06 21:20:37 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:52 meister * Update copyright message * * Revision 9.0 1998/10/16 22:12:55 sar * Update version stamp to match release * * Revision 8.2 1998/06/05 18:53:30 sra * "#include <foo.h>" => "#include <envoy/h/foo.h>". * * Revision 8.1 1998/02/25 04:53:23 sra * Update copyrights. * * Revision 8.0 1997/11/18 00:57:12 sar * Updated revision to 8.0 * * Revision 7.2 1997/03/20 06:49:39 sra * DFARS-safe copyright text. Zap! * * Revision 7.1 1997/02/25 10:49:26 sra * Update copyright notice, dust under the bed. * * 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:25 sra * Release 6.0. * * Revision 1.1 1995/05/05 23:04:09 sar * Initial revision * * *//* [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);#endifvoid test_error_routine(SNMPADDR_T *for_addr, SNMPADDR_T *loc_addr, int ecode, PTR_T cookie){printf("Decode failure\n");return;}void test_io_routine(SNMPADDR_T *for_addr, SNMPADDR_T *loc_addr, PTR_T pktp, ALENGTH_T need, PTR_T cookie){EBUFFER_T ebuff;int i;unsigned char *cp;EBufferSetup(BFL_IS_STATIC, &ebuff, genbuff, sizeof(genbuff));if (SNMP_Process_Finish((SNMP_PKT_T *)pktp, &ebuff, need) == 0) { 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'); EBufferClean(&ebuff); printf("Default TTL = %d\n", ip_stats.ip_DefaultTTL); return; }printf("Encode failure\n");return;}int main(argc, argv)int argc;char **argv;{FILE *infile;unsigned char *cp;int bufcnt;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());#endifProcess_Rcvd_SNMP_Packet_Async((size_t)bufcnt, (bits8_t *)rcvbuff, (SNMPADDR_T *)&psrc, (SNMPADDR_T *)&pdst, TBSIZE, test_io_routine, test_error_routine, 0);#if defined(MEMAVL)printf("Memavail=%u\n", _memavl());#endif#if defined(CORELEFT)printf("Memavail=%u\n", coreleft());#endifreturn(0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -