📄 xgcpcoreobjectstable.c
字号:
/* minimal include directives */#include "xgcpCoreObjectsTable.h"/* * xgcpCoreObjectsTable_variables_oid: * this is the top level oid that we want to register under. This * is essentially a prefix, with the suffix appearing in the * variable below. */oid xgcpCoreObjectsTable_variables_oid[] = { 1,3,6,1,4,1,5738,3,90,1,1 };/* * variable2 xgcpCoreObjectsTable_variables: * this variable defines function callbacks and type return information * for the xgcpCoreObjectsTable mib section */struct variable2 xgcpCoreObjectsTable_variables[] = {/* magic number , variable type , ro/rw , callback fn , L, oidsuffix */ { xgcpInBadVersions , ASN_COUNTER , RONLY , var_xgcpCoreObjectsTable, 1, { 2 } }, { xgcpInitialRequestTimeOut , ASN_INTEGER , RWRITE , var_xgcpCoreObjectsTable, 1, { 3 } }, { xgcpRequestTimeOutCap , ASN_INTEGER , RWRITE , var_xgcpCoreObjectsTable, 1, { 4 } }, { xgcpAdminStatus , ASN_INTEGER , RWRITE , var_xgcpCoreObjectsTable, 1, { 5 } }, { xgcpOperStatus , ASN_INTEGER , RONLY , var_xgcpCoreObjectsTable, 1, { 6 } }, { xgcpUnRecognizedPackets , ASN_COUNTER , RONLY , var_xgcpCoreObjectsTable, 1, { 7 } },};/* (L = length of the oidsuffix) *//* * init_xgcpCoreObjectsTable(): * Initialization routine. This is called when the agent starts up. * At a minimum, registration of your variables should take place here. */void init_xgcpCoreObjectsTable(void) { /* register ourselves with the agent to handle our mib tree */ REGISTER_MIB("xgcpCoreObjectsTable", xgcpCoreObjectsTable_variables, variable2, xgcpCoreObjectsTable_variables_oid);}/* * var_xgcpCoreObjectsTable(): * This function is called every time the agent gets a request for * a scalar variable that might be found within your mib section * registered above. It is up to you to do the right thing and * return the correct value. * You should also correct the value of "var_len" if necessary. * * Please see the documentation for more information about writing * module extensions, and check out the examples in the examples * and mibII directories. */unsigned char *var_xgcpCoreObjectsTable(struct variable *vp, oid *name, size_t *length, int exact, size_t *var_len, WriteMethod **write_method){ /* variables we may use later */ static long long_ret; static unsigned char string[SPRINT_MAX_LEN]; static oid objid[MAX_OID_LEN]; static struct counter64 c64; int index, mgcpPort; index = header_xgcp_table(vp,name,length,exact,var_len,write_method, 13); if( index == MATCH_FAILED ) return NULL; mgcpPort = TrapAgent_GetStackPortFromIndex((void *)trapAgent, index); if (mgcpPort == 0){ return NULL; } /* * this is where we do the value assignments for the mib results. */ switch(vp->magic) { case xgcpInBadVersions: if (requestXgcpCounter(vp->magic, &long_ret, mgcpPort) != voSuccess) { return NULL; } return (unsigned char *) &long_ret; case xgcpInitialRequestTimeOut: *write_method = write_xgcpInitialRequestTimeOut; if (requestXgcpCounter(vp->magic, &long_ret, mgcpPort) != voSuccess) { return NULL; } return (unsigned char *) &long_ret; case xgcpRequestTimeOutCap: *write_method = write_xgcpRequestTimeOutCap; if (requestXgcpCounter(vp->magic, &long_ret, mgcpPort) != voSuccess) { return NULL; } return (unsigned char *) &long_ret; case xgcpAdminStatus: *write_method = write_xgcpAdminStatus; if (requestXgcpCounter(vp->magic, &long_ret, mgcpPort) != voSuccess) { return NULL; } return (unsigned char *) &long_ret; case xgcpOperStatus: /* The requestXgcpCounter is being used because the values of this * variable can just be one of the following integers:- * up (1), * down (2), * shutDownInProgress (3) */ if (requestXgcpCounter(vp->magic, &long_ret, mgcpPort) != voSuccess) { return NULL; } return (unsigned char *) &long_ret; case xgcpUnRecognizedPackets: if (requestXgcpCounter(vp->magic, &long_ret, mgcpPort) != voSuccess) { return NULL; } return (unsigned char *) &long_ret; default: ERROR_MSG("Invalid request in xgcpCoreObjectsTable"); } return NULL;}intwrite_xgcpInitialRequestTimeOut(int action, u_char *var_val, u_char var_val_type, size_t var_val_len, u_char *statP, oid *name, size_t name_len){ static long *long_ret; int size; switch ( action ) { case RESERVE1: if (var_val_type != ASN_INTEGER){ fprintf(stderr, "write to xgcpInitialRequestTimeOut not ASN_INTEGER\n"); return SNMP_ERR_WRONGTYPE; } if (var_val_len > sizeof(long_ret)){ fprintf(stderr,"write to xgcpInitialRequestTimeOut: bad length\n"); return SNMP_ERR_WRONGLENGTH; } break; case RESERVE2: size = var_val_len; long_ret = (long *) var_val; break; case FREE: /* Release any resources that have been allocated */ break; case ACTION: /* The variable has been stored in long_ret for you to use, and you have just been asked to do something with it. Note that anything done here must be reversable in the UNDO case */ break; case UNDO: /* Back out any changes made in the ACTION case */ break; case COMMIT: /* Things are working well, so it's now safe to make the change permanently. Make sure that anything done here can't fail! */ break; } return SNMP_ERR_NOERROR;}intwrite_xgcpRequestTimeOutCap(int action, u_char *var_val, u_char var_val_type, size_t var_val_len, u_char *statP, oid *name, size_t name_len){ static long *long_ret; int size; switch ( action ) { case RESERVE1: if (var_val_type != ASN_INTEGER){ fprintf(stderr, "write to xgcpRequestTimeOutCap not ASN_INTEGER\n"); return SNMP_ERR_WRONGTYPE; } if (var_val_len > sizeof(long_ret)){ fprintf(stderr,"write to xgcpRequestTimeOutCap: bad length\n"); return SNMP_ERR_WRONGLENGTH; } break; case RESERVE2: size = var_val_len; long_ret = (long *) var_val; break; case FREE: /* Release any resources that have been allocated */ break; case ACTION: /* The variable has been stored in long_ret for you to use, and you have just been asked to do something with it. Note that anything done here must be reversable in the UNDO case */ break; case UNDO: /* Back out any changes made in the ACTION case */ break; case COMMIT: /* Things are working well, so it's now safe to make the change permanently. Make sure that anything done here can't fail! */ break; } return SNMP_ERR_NOERROR;}intwrite_xgcpAdminStatus(int action, u_char *var_val, u_char var_val_type, size_t var_val_len, u_char *statP, oid *name, size_t name_len){ static long *long_ret; int size; switch ( action ) { case RESERVE1: if (var_val_type != ASN_INTEGER){ fprintf(stderr, "write to xgcpAdminStatus not ASN_INTEGER\n"); return SNMP_ERR_WRONGTYPE; } if (var_val_len > sizeof(long_ret)){ fprintf(stderr,"write to xgcpAdminStatus: bad length\n"); return SNMP_ERR_WRONGLENGTH; } break; case RESERVE2: size = var_val_len; long_ret = (long *) var_val; break; case FREE: /* Release any resources that have been allocated */ break; case ACTION: /* The variable has been stored in long_ret for you to use, and you have just been asked to do something with it. Note that anything done here must be reversable in the UNDO case */ break; case UNDO: /* Back out any changes made in the ACTION case */ break; case COMMIT: /* Things are working well, so it's now safe to make the change permanently. Make sure that anything done here can't fail! */ break; } return SNMP_ERR_NOERROR;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -