📄 xgcpcommon.c
字号:
#include "xgcpCommon.h"/* this function will set the counterVal to the correct * value and return proper error status based on the * input mib object reqObject (AgentApiMibT) */enum voReturnStatusrequestXgcpCounter(int reqObject, ulong *counterVal, int port){ ipcMessage message; enum voReturnStatus retVal; retVal = ipcRequest((actionT)Get, (AgentApiMibVarT) reqObject, port, &message); if (retVal == voSuccess) { memcpy(counterVal, message.parm2, sizeof (ulong)); } else { *counterVal = (ulong) VO_NA_INT; } return retVal;}/* this function will return the value of a string * IN reqObject, the object to get defined in AgentApiMibT * IN/OUT outBuff the buffer to write the string into. * IN the size of the buffer in bytes */enum voReturnStatusrequestXgcpString(int reqObject, char *outBuff, int strLen, int port){ ipcMessage message; enum voReturnStatus retVal; memset(outBuff, 0, strLen/4); retVal = ipcRequest((actionT)Get, (AgentApiMibVarT) reqObject, port, &message); if (retVal == voSuccess) { strncpy(outBuff, message.parm2, min(strLen, PARM2SIZE)); } else { strncpy(outBuff, VO_NA_STRING, min(strLen, strlen(VO_NA_STRING))); } return retVal;} /* returns 0 on match_failure * returns index on success * vp is the oid not including index we should be looking for * name is the oid requested by the user, or what we returned from the * previous getnext request * length is the number of "digits" (snmp gurus are going to kill) in the oid * exact = true for snmpGet, false for snmpGetnext * **write_method isn't used since these are read only * maxOidLen is the length of a full oid in this specific table */ulongheader_xgcp_table(struct variable *vp, oid *name, size_t *length, int exact, size_t *var_len, WriteMethod **write_method, int maxOidLen){ oid newname[MAX_OID_LEN]; int result, getIndex = 0, nextIndex = 0; int indexPosition = maxOidLen - 1; applInfoT appl; if (exact) { if ((*length == indexPosition + 1) && (snmp_oid_compare(vp->name, indexPosition - 1, name, *length) <= 0 )) { appl = TrapAgent_GetApplication((void *)trapAgent, name[indexPosition]); if (appl.index != 0 && appl.type == MgcpStack) { *var_len = sizeof(long); /* default to 'long' results */ return appl.index; } } return MATCH_FAILED; } memcpy( (char *)newname,(char *)vp->name, (int)vp->namelen * sizeof(oid)); if (*length > indexPosition) // already within the table result = snmp_oid_compare(name, *length - 1, newname, (int)vp->namelen); else // before/after the table result = snmp_oid_compare(name, *length, newname, (int)vp->namelen - 1); if (result > 0) /* past end of table */ return MATCH_FAILED; /* first entry into table || first of new oid */ if (result < 0) { getIndex = 0; } else { getIndex = name[indexPosition]; } nextIndex = TrapAgent_GetNextIndex((void *)trapAgent, getIndex, MgcpStack);/* The index is the last of this row. Go onto next row */ if( nextIndex == 0) { return MATCH_FAILED; } memcpy( (char *)name,(char *)newname, ((int)vp->namelen) * sizeof(oid)); *length = vp->namelen + 1; name[indexPosition] = nextIndex; *write_method = 0; *var_len = sizeof(long); /* default to 'long' results */ return nextIndex;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -