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

📄 ttmth.c

📁 wm PNE 3.3 source code, running at more than vxworks6.x version.
💻 C
字号:
/* $Header: /usr/cvsroot/target/src/wrn/wm/demo/snmptalk/ttmth.c,v 1.3 2003/01/15 14:04:57 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 1997 Epilogue Technology Corporation. *  Copyright 1998 Integrated Systems, Inc. *  All rights reserved. ****************************************************************************//* * $Log: ttmth.c,v $ * Revision 1.3  2003/01/15 14:04:57  josh * directory structure shifting * * Revision 1.2  2001/11/08 16:47:32  tneale * Updated for newset file layout * * Revision 1.1.1.1  2001/11/05 17:49:13  tneale * Tornado shuffle * * Revision 1.5  2001/01/19 22:24:52  paul * Update copyright. * * Revision 1.4  2000/03/17 00:14:37  meister * Update copyright message * * Revision 1.3  1998/02/25 15:21:59  sra * Finish moving types.h, bug.h, and bugdef.h to common/h/. * * Revision 1.2  1998/02/25 04:58:09  sra * Update copyrights. * * Revision 1.1  1997/10/16 02:18:05  sar * AgentX test routines. * agentx  - a sub agent using tcp to get to the master * ax_mast - master side code for use with snmptalk * ttmth   - some test routines for use with agentx and tt.mib * *//* [clearcase]modification history-------------------01a,19apr05,job  update copyright notices*/#include <wrn/wm/common/install.h>#include <snmptalk.h>#include <wrn/wm/common/types.h>#include <wrn/wm/snmp/engine/asn1.h>#include <wrn/wm/snmp/engine/snmp.h>#include <wrn/wm/snmp/engine/agentx.h>#include <wrn/wm/snmp/engine/objectid.h>#include <wrn/wm/snmp/engine/auxfuncs.h>typedef struct testtable_s {        OBJ_ID_T  index;	sbits32_t integer;	bits32_t  counter;	bits32_t  high64;	bits32_t  low64;	int       stringlen;	bits8_t  *string;	OBJ_ID_T  objectid;	} testtable_t;typedef struct iandp_s {        int          count;	bits8_t     *buf;	testtable_t *tab_entry;	        } iandp_t;#define LM_TT_INDEX     1#define LM_TT_INTEGER   2#define LM_TT_COUNTER   3#define LM_TT_COUNTER64 4#define LM_TT_STRING    5#define LM_TT_OBJECTID  6OIDC_T oidc1[] = {1, 1};OIDC_T oidc2[] = {1, 3};OIDC_T oidc3[] = {1, 5};OIDC_T oidc4[] = {2, 2};OIDC_T oidc5[] = {2, 4};OIDC_T oidc6[] = {2, 6};testtable_t testtable_list[] = {{{2, oidc1},          1,           0,           0,           0,  0, 0, {0, 0}},{{2, oidc2},         -1,           1,           0,           1,  0, 0, {0, 0}},{{2, oidc3},     0xFFFF,        0xFF,           0,      0xFFFF,  0, 0, {0, 0}},{{2, oidc4},    -0xFFFF,      0xFFFF,           0,  0xFFFFFFFFL, 0, 0, {0, 0}},{{2, oidc5}, 0x7FFFFFFFL,   0xFFFFFFL,     0xFFFF,           0,  0, 0, {0, 0}},{{2, oidc6}, 0xFFFFFFFFL, 0xFFFFFFFFL, 0xFFFFFFFFL, 0xFFFFFFFFL, 0, 0, {0, 0}}};int testtable_list_count = sizeof(testtable_list)/sizeof(testtable_t);testtable_t *  tt_find_entry(int     tcount,		OIDC_T *tlist){testtable_t *tab;int i;for(i = 0, tab = testtable_list; i < testtable_list_count; i++, tab++) {    if (oidcmp2(tcount, tlist, tab->index.num_components,		tab->index.component_list) == 0) {	return(tab);        }    }return(0);}void  tt_get_value(SNMP_PKT_T  *pktp,	       VB_T        *vbp,               testtable_t *tab_entry){switch(vbp->vb_ml.ml_last_match) {    case LM_TT_INTEGER:        getproc_got_int32(pktp, vbp, tab_entry->integer);        break;    case LM_TT_COUNTER:        getproc_got_uint32(pktp, vbp, tab_entry->counter, VT_COUNTER);        break;    case LM_TT_COUNTER64:        getproc_got_uint64_high_low(pktp, vbp, tab_entry->high64,				    tab_entry->low64);        break;    case LM_TT_STRING:        getproc_got_string(pktp, vbp, tab_entry->stringlen,			   tab_entry->string, 0, VT_STRING);        break;    case LM_TT_OBJECTID:        getproc_got_object_id(pktp, vbp, tab_entry->objectid.num_components,			      tab_entry->objectid.component_list, 0);        break;    }return;}void  tt_getproc(OIDC_T      last_match,	     int         tcount,	     OIDC_T     *tlist,	     SNMP_PKT_T *pktp,	     VB_T       *vbp){testtable_t *tab_entry;group_by_getproc_and_instance(pktp, vbp, tcount, tlist);tab_entry = tt_find_entry(tcount, tlist);if (tab_entry) {    for(; vbp; vbp = vbp->vb_link)        tt_get_value(pktp, vbp, tab_entry);    }else {    for(; vbp; vbp = vbp->vb_link)        getproc_nosuchins(pktp, vbp);    }    return;}void  tt_nextproc(OIDC_T      last_match,	      int         tcount,	      OIDC_T     *tlist,	      SNMP_PKT_T *pktp,	      VB_T       *vbp){testtable_t *tab_entry;int i;group_by_getproc_and_instance(pktp, vbp, tcount, tlist);for(i = 0, tab_entry = testtable_list;    i < testtable_list_count;    i++, tab_entry++) {    if (oidcmp2(tcount, tlist, tab_entry->index.num_components,		tab_entry->index.component_list) < 0) {        for(; vbp; vbp = vbp->vb_link) {	    nextproc_next_instance(pktp, vbp, tab_entry->index.num_components,				   tab_entry->index.component_list);	    tt_get_value(pktp, vbp, tab_entry);	    }	return;        }    }for(; vbp; vbp = vbp->vb_link)    nextproc_no_next(pktp, vbp);return;}void  tt_cleanup(ptr_t value){iandp_t *iandp;#if INSTALL_ENVOY_40_VB_FREE_COMPATiandp = (iandp_t *)value;#elseiandp = (iandp_t *)(((VB_T *)value)->vb_priv);#endifif (iandp) {    if (iandp->buf)        SNMP_memory_free(iandp->buf);    SNMP_memory_free(iandp);    }}void  tt_testproc(OIDC_T      last_match,	      int         tcount,	      OIDC_T     *tlist,	      SNMP_PKT_T *pktp,	      VB_T       *vbp){testtable_t *tab_entry;VB_T *tvbp;iandp_t *iandp;int str_flag = 0, oid_flag = 0, oneed;ALENGTH_T sneed;group_by_getproc_and_instance(pktp, vbp, tcount, tlist);testproc_good(pktp, vbp);for(tvbp = vbp->vb_link; tvbp; tvbp = tvbp->vb_link)    setproc_all_bits(pktp, tvbp);tab_entry = tt_find_entry(tcount, tlist);if (tab_entry == 0) {    testproc_error(pktp, vbp, NO_CREATION);    return;    }vbp->vb_free_priv = tt_cleanup;for(tvbp = vbp; tvbp; tvbp = tvbp->vb_link) {    switch(tvbp->vb_ml.ml_last_match) {        case LM_TT_STRING:            sneed = EBufferUsed(VB_GET_STRING(tvbp));            if (sneed > 255) {	        testproc_error(pktp, tvbp, WRONG_LENGTH);		return;	        }	    if (str_flag)	        continue;	    str_flag = 1;	    iandp = (iandp_t *)SNMP_memory_alloc(sizeof(iandp_t));	    if (iandp == 0) {	        testproc_error(pktp, tvbp, RESOURCE_UNAVAILABLE);		return;	        }	    if (sneed != 0) {	        iandp->buf = SNMP_memory_alloc(sneed);		if (iandp->buf == 0) {		    SNMP_memory_free(iandp);		    testproc_error(pktp, tvbp, RESOURCE_UNAVAILABLE);		    return;		    }		MEMCPY(iandp->buf, EBufferStart(VB_GET_STRING(tvbp)), sneed);	        }	    else	        iandp->buf = 0;	    iandp->count     = (int)(sneed & 0xff);	    iandp->tab_entry = tab_entry;	    tvbp->vb_priv    = (ptr_t)iandp;            break;	case LM_TT_OBJECTID:            oneed = (VB_GET_OBJECT_ID(tvbp))->num_components;            if (oneed > 128) {	        testproc_error(pktp, tvbp, WRONG_LENGTH);		return;	        }	    if (oid_flag)	        continue;	    oid_flag = 1;	    iandp = (iandp_t *)SNMP_memory_alloc(sizeof(iandp_t));	    if (iandp == 0) {	        testproc_error(pktp, tvbp, RESOURCE_UNAVAILABLE);		return;	        }	    if (oneed != 0) {	        iandp->buf = SNMP_memory_alloc(oneed * sizeof(OIDC_T));		if (iandp->buf == 0) {		    SNMP_memory_free(iandp);		    testproc_error(pktp, tvbp, RESOURCE_UNAVAILABLE);		    return;		    }		MEMCMP(iandp->buf, (VB_GET_OBJECT_ID(tvbp))->component_list,		       oneed * sizeof(OIDC_T));	        }	    else	        iandp->buf = 0;	    iandp->count     = (int)(oneed & 0xff);	    iandp->tab_entry = tab_entry;	    tvbp->vb_priv    = (ptr_t)iandp;             break;	}    }return;}void  tt_swap(VB_T *vbp){testtable_t *tab_entry;iandp_t *iandp;int str_flag = 0, oid_flag = 0, temp_count;bits8_t *temp_buf;for(; vbp; vbp = vbp->vb_link) {    iandp = (iandp_t *)vbp->vb_priv;    switch(vbp->vb_ml.ml_last_match) {        case LM_TT_STRING:	    if (str_flag)	        continue;	    str_flag = 1;	    tab_entry  = iandp->tab_entry;	    temp_count = tab_entry->stringlen;	    temp_buf   = tab_entry->string;	    tab_entry->stringlen = iandp->count;	    tab_entry->string    = iandp->buf;	    iandp->count = temp_count;	    iandp->buf   = temp_buf;            break;	case LM_TT_OBJECTID:	    if (oid_flag)	        continue;	    oid_flag = 1;	    tab_entry = iandp->tab_entry;	    temp_count = tab_entry->objectid.num_components;	    temp_buf   = (bits8_t *)tab_entry->objectid.component_list;	    tab_entry->objectid.num_components = iandp->count;	    tab_entry->objectid.component_list = (OIDC_T *)iandp->buf;	    iandp->count = temp_count;	    iandp->buf   = temp_buf;            break;	}    }return;}void  tt_undoproc(OIDC_T      last_match,	      int         tcount,	      OIDC_T     *tlist,	      SNMP_PKT_T *pktp,	      VB_T       *vbp){undoproc_good(pktp, vbp);tt_swap(vbp);return;}void  tt_setproc(OIDC_T      last_match,	     int         tcount,	     OIDC_T     *tlist,	     SNMP_PKT_T *pktp,	     VB_T       *vbp){setproc_good(pktp, vbp);undoproc_set(pktp, vbp, tt_undoproc);tt_swap(vbp);return;}

⌨️ 快捷键说明

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