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

📄 print.c

📁 wm PNE 3.3 source code, running at more than vxworks6.x version.
💻 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 1988-1997 Epilogue Technology Corporation. *  Copyright 1998 Integrated Systems, Inc. *  All rights reserved. *//* * $Log: print.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:54  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:20  sra * Update copyrights. * * Revision 8.0  1997/11/18 00:57:11  sar * Updated revision to 8.0 * * Revision 7.2  1997/03/20 06:49:38  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.1  1995/11/01  00:38:58  sar * Removed no_pp stuff and definition of then * removed localio.h decode.h * repaginated * * Revision 6.0  1995/05/31  21:49:24  sra * Release 6.0. * * Revision 5.1  1994/10/25  20:05:33  sar * Removed old code that dealt with 16 bit oidc_ts. * * 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 * * Revision 3.0  1992/04/03  19:54:08  dab * Release 3.0 * * Revision 1.1  92/03/31  16:43:41  dab * Initial revision *  *  *    Rev 2.0   31 Mar 1990 15:06:52 * Release 2.00 *  *    Rev 1.4   23 Aug 1989 23:42:00 * Corrected printf format strings to match data types in VB list. *  *    Rev 1.3   27 Apr 1989 15:56:04 * Removed unused variables *  *    Rev 1.2   19 Sep 1988 17:26:40 * Made changes to make the Sun C compiler happy. *  *    Rev 1.1   14 Sep 1988 17:57:18 * Moved includes of system include files into libfuncs.h. *  *    Rev 1.0   12 Sep 1988 10:47:04 * Initial revision.*//* [clearcase]modification history-------------------01b,19apr05,job  update copyright notices01a,24nov03,job  update copyright information*/#include <stdio.h>#include <wrn/wm/snmp/engine/asn1.h>#include <wrn/wm/snmp/engine/buffer.h>#include <wrn/wm/snmp/engine/snmp.h>#include <wrn/wm/snmp/engine/objectid.h>/****************************************************************************This module contains various utility routines that print things****************************************************************************/void  print_obj_id_list(int	    obj_cnt,		    OIDC_T *objp){(void)printf("OBJ_ID: ");for(; obj_cnt > 1; obj_cnt--) (void)printf("%lu.", *objp++);(void)printf("%lu", *objp);(void)printf("\n");}void  print_obj_id(OBJ_ID_T *objp){print_obj_id_list(objp->num_components, objp->component_list);}void  print_ebuffer(EBUFFER_T *ebp){char *cp;for (cp = (char *)(ebp->start_bp); cp != (char *)(ebp->next_bp); cp++)  {    (void)putchar(*cp);    }(void)putchar('\n');}void  print_ipaddress(unsigned char * ipa){(void)printf("IP Address: %d.%d.%d.%d\n", ipa[0], ipa[1], ipa[2], ipa[3]);}void  print_vblist(VBL_T *vblp){VB_T	*vbp;(void)printf("VBLlen=%d, ", vblp->vbl_length);(void)printf("VBcount=%d\n", vblp->vbl_count);if ((vbp = vblp->vblist) != 0) {    int i;    (void)printf("VarBindList:\n");    for (i = 0; i < vblp->vbl_count; i++, vbp++) {        (void)printf("VarBind #%d, content size=%d, ",		     i, vbp->vb_seq_size);	(void)printf("Flags & type=0x%02.2X, encoded length=%d\n",		     vbp->vb_data_flags_n_type, vbp->vb_data_length);	print_obj_id(&(vbp->vb_obj_id));	switch (vbp->vb_data_flags_n_type) {	    case VT_NUMBER:	        (void)printf("Number: %ld\n", (long)(vbp->value_u.v_number));		break;	    case VT_COUNTER:		(void)printf("Counter: %lu\n",			     (unsigned long)(vbp->value_u.v_counter));		break;	    case VT_GAUGE:		(void)printf("Gauge: %lu\n",			     (unsigned long)(vbp->value_u.v_gauge));		break;	    case VT_TIMETICKS:		(void)printf("Time Ticks: %lu\n",			     (unsigned long)(vbp->value_u.v_timeticks));		break;	    case VT_STRING:		(void)printf("String: Length=%d\n",			     EBufferUsed(&(vbp->value_u.v_string)));		print_ebuffer(&(vbp->value_u.v_string));		break;	    case VT_OPAQUE:		(void)printf("Opaque: Length=%d\n",			     EBufferUsed(&(vbp->value_u.v_string)));		print_ebuffer(&(vbp->value_u.v_opaque));		break;	    case VT_OBJECT:		(void)printf("Object ID: ");		print_obj_id(&(vbp->value_u.v_object));		break;	    case VT_EMPTY:		(void)printf("Empty\n");		break;	    case VT_IPADDRESS:		print_ipaddress(vbp->value_u.v_network_address);		break;	    default:		(void)printf("UNKNOWN\n");		break;	    }#ifdef GRUNGUS	{	  OBJ_ID_T	nxt_objid;	  nxt_objid.num_components = 0;	  nxt_objid.component_list = (unsigned int *)0;	  (void)printf("Finding next...");	  if (find_next_object(&(vbp->vb_obj_id), &nxt_objid) <= 0)	    (void)printf("Find next failed\n");	  else	    print_obj_id(&nxt_objid);	}#endif        }    }}void  print_pkt(SNMP_PKT_T *rp){(void)printf("Packet Length=%d, Version=%ld, ",	rp->overall_length, rp->snmp_version);(void)printf("Community: Length=%d, Value=", EBufferUsed(&(rp->community)));print_ebuffer(&(rp->community));(void)printf("PDU Type=0x%02.2X Length=%d, ", rp->pdu_type, rp->pdu_length);if (rp->pdu_type != TRAP_PDU) { /* Its a non-trap form of pdu */    (void)printf("RQ_ID=%ld, Err_stat=%ld, Err_ndx=%ld\n",		 (INT_32_T)rp->pdu.std_pdu.request_id,		 (INT_32_T)rp->pdu.std_pdu.error_status,		 (INT_32_T)rp->pdu.std_pdu.error_index);    print_vblist(&(rp->pdu.std_pdu.std_vbl));    }else { /* It's a trap pdu */    (void)printf("Enterprise id: \n");    print_obj_id(&(rp->pdu.trap_pdu.enterprise_objid));    print_ipaddress(rp->pdu.trap_pdu.net_address);    (void)printf("Generic trap=%ld (%lX), specific trap=%ld (%lX), ",		 rp->pdu.trap_pdu.generic_trap,		 rp->pdu.trap_pdu.generic_trap,		 rp->pdu.trap_pdu.specific_trap,		 rp->pdu.trap_pdu.specific_trap);    (void)printf("Trap time=%ld (%lX)\n",		 rp->pdu.trap_pdu.trap_time_ticks,		 rp->pdu.trap_pdu.trap_time_ticks);    print_vblist(&(rp->pdu.trap_pdu.trap_vbl));    }}

⌨️ 快捷键说明

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