📄 sipcommon.c
字号:
/* This file was generated by mib2c and is intended for use as a mib module for the ucd-snmp snmpd agent. *//* This should always be included first before anything else */#include <config.h>/* minimal include directives */#include "mibincl.h"#include "util_funcs.h"#include <AgentApi.hxx>#include "VovidaSnmpUtil.h"#include "sipCommon.h"/* * sipCommon_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 sipCommon_variables_oid[] = { 1,3,6,1,4,1,5738,3,42,1,1 };/* * variable7 sipCommon_variables: * this variable defines function callbacks and type return information * for the sipCommon mib section */struct variable7 sipCommon_variables[] = {/* magic number , variable type , ro/rw , callback fn , L, oidsuffix */// i removed the #defines that were generated by mib2c and replaced them with the enum// defined in AgentApiMibVars. This will allow the same number to be used throuh// the entire system including the network manager, snmpd, SipAgent { sipProtocolVersion , ASN_OCTET_STR , RONLY , var_sipCommon, 2, { 1,1 } }, { sipServiceOperStatus , ASN_INTEGER , RONLY , var_sipCommon, 2, { 1,2 } }, { sipServiceAdminStatus, ASN_INTEGER , RWRITE, var_sipCommon, 2, { 1,3 } }, { sipServiceStartTime , ASN_TIMETICKS , RONLY , var_sipCommon, 2, { 1,4 } }, { sipServiceLastChange , ASN_TIMETICKS , RONLY , var_sipCommon, 2, { 1,5 } }, { sipTransport , ASN_INTEGER , RWRITE, var_sipPortTable, 4, { 1,6,1,2 } }, { sipPortStatus , ASN_INTEGER , RWRITE, var_sipPortTable, 4, { 1,6,1,3 } }, { sipUriSupported , ASN_OCTET_STR , RONLY , var_sipUriSupportedTable, 4, { 1,7,1,2 } }, { sipFtrSupported , ASN_OCTET_STR , RONLY , var_sipFtrSupportedTable, 4, { 1,8,1,2 } }, { sipOrganization , ASN_OCTET_STR , RWRITE, var_sipCommon, 2, { 1,9 } }, { sipMaxTransactions , ASN_GAUGE , RONLY , var_sipCommon, 2, { 1,10 } }, { sipRequestDfltExpires , ASN_GAUGE , RWRITE, var_sipCommon, 2, { 1,11 } }, { sipHideOperation , ASN_INTEGER , RWRITE, var_sipCommon, 2, { 1,12 } }, { sipUserLocationServerAddr , ASN_OCTET_STR , RWRITE, var_sipCommon, 2, { 1,13 } }, { sipSummaryInRequests, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,1,1 } }, { sipSummaryOutRequests, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,1,2 } }, { sipSummaryInResponses, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,1,3 } }, { sipSummaryOutResponses, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,1,4 } }, { sipSummaryTotalTransactions, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,1,5 } }, { sipStatsInviteIns , ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,2,1 } }, { sipStatsInviteOuts , ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,2,2 } }, { sipStatsAckIns , ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,2,3 } }, { sipStatsAckOuts , ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,2,4 } }, { sipStatsByeIns , ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,2,5 } }, { sipStatsByeOuts , ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,2,6 } }, { sipStatsCancelIns , ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,2,7 } }, { sipStatsCancelOuts , ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,2,8 } }, { sipStatsOptionsIns , ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,2,9 } }, { sipStatsOptionsOuts , ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,2,10 } }, { sipStatsRegisterIns , ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,2,11 } }, { sipStatsRegisterOuts, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,2,12 } }, { sipStatsInfoIns , ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,2,13 } }, { sipStatsInfoOuts , ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,2,14 } }, { sipStatsInfoTryingIns, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,3,1 } }, { sipStatsInfoTryingOuts, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,3,2 } }, { sipStatsInfoRingingIns, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,3,3 } }, { sipStatsInfoRingingOuts, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,3,4 } }, { sipStatsInfoForwardedIns, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,3,5 } }, { sipStatsInfoForwardedOuts, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,3,6 } }, { sipStatsInfoQueuedIns, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,3,7 } }, { sipStatsInfoQueuedOuts, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,3,8 } }, { sipStatsInfoSessionProgIns, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,3,9 } }, { sipStatsInfoSessionProgOuts, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,3,10 } }, { sipStatsSuccessOkIns, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,4,1 } }, { sipStatsSuccessOkOuts, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,4,2 } }, { sipStatsRedirMultipleChoiceIns, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,5,1 } }, { sipStatsRedirMultipleChoiceOuts, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,5,2 } }, { sipStatsRedirMovedPermIns, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,5,3 } }, { sipStatsRedirMovedPermOuts, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,5,4 } }, { sipStatsRedirMovedTempIns, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,5,5 } }, { sipStatsRedirMovedTempOuts, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,5,6 } }, { sipStatsRedirSeeOtherIns, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,5,7 } }, { sipStatsRedirSeeOtherOuts, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,5,8 } }, { sipStatsRedirUseProxyIns, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,5,9 } }, { sipStatsRedirUseProxyOuts, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,5,10 } }, { sipStatsRedirAltServiceIns, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,5,11 } }, { sipStatsRedirAltServiceOuts, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,5,12 } }, { sipStatsClientBadRequestIns, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,6,1 } }, { sipStatsClientBadRequestOuts, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,6,2 } }, { sipStatsClientUnauthorizedIns, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,6,3 } }, { sipStatsClientUnauthorizedOuts, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,6,4 } }, { sipStatsClientPaymentReqdIns, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,6,5 } }, { sipStatsClientPaymentReqdOuts, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,6,6 } }, { sipStatsClientForbiddenIns, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,6,7 } }, { sipStatsClientForbiddenOuts, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,6,8 } }, { sipStatsClientNotFoundIns, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,6,9 } }, { sipStatsClientNotFoundOuts, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,6,10 } }, { sipStatsClientMethNotAllowedIns, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,6,11 } }, { sipStatsClientMethNotAllowedOuts, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,6,12 } }, { sipStatsClientNotAcceptableIns, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,6,13 } }, { sipStatsClientNotAcceptableOuts, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,6,14 } }, { sipStatsClientProxyAuthReqdIns, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,6,15 } }, { sipStatsClientProxyAuthReqdOuts, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,6,16 } }, { sipStatsClientReqTimeoutIns, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,6,17 } }, { sipStatsClientReqTimeoutOuts, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,6,18 } }, { sipStatsClientConflictIns, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,6,19 } }, { sipStatsClientConflictOuts, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,6,20 } }, { sipStatsClientGoneIns, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,6,21 } }, { sipStatsClientGoneOuts, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,6,22 } }, { sipStatsClientLengthRequiredIns, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,6,23 } }, { sipStatsClientLengthRequiredOuts, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,6,24 } }, { sipStatsClientReqEntTooLargeIns, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,6,25 } }, { sipStatsClientReqEntTooLargeOuts, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,6,26 } }, { sipStatsClientReqURITooLargeIns, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,6,27 } }, { sipStatsClientReqURITooLargeOuts, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,6,28 } }, { sipStatsClientNoSupMediaTypeIns, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,6,29 } }, { sipStatsClientNoSupMediaTypeOuts, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,6,30 } }, { sipStatsClientBadExtensionIns, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,6,31 } }, { sipStatsClientBadExtensionOuts, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,6,32 } }, { sipStatsClientTempNotAvailIns, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,6,33 } }, { sipStatsClientTempNotAvailOuts, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,6,34 } }, { sipStatsClientCallLegNoExistIns, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,6,35 } }, { sipStatsClientCallLegNoExistOuts, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,6,36 } }, { sipStatsClientLoopDetectedIns, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,6,37 } }, { sipStatsClientLoopDetectedOuts, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,6,38 } }, { sipStatsClientTooManyHopsIns, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,6,39 } }, { sipStatsClientTooManyHopsOuts, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,6,40 } }, { sipStatsClientAddrIncompleteIns, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,6,41 } }, { sipStatsClientAddrIncompleteOuts, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,6,42 } }, { sipStatsClientAmbiguousIns, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,6,43 } }, { sipStatsClientAmbiguousOuts, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,6,44 } }, { sipStatsClientBusyHereIns, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,6,45 } }, { sipStatsClientBusyHereOuts, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,6,46 } }, { sipStatsServerIntErrorIns, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,7,1 } }, { sipStatsServerIntErrorOuts, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,7,2 } }, { sipStatsServerNotImplementedIns, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,7,3 } }, { sipStatsServerNotImplementedOuts, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,7,4 } }, { sipStatsServerBadGatewayIns, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,7,5 } }, { sipStatsServerBadGatewayOuts, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,7,6 } }, { sipStatsServerServiceUnavailIns, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,7,7 } }, { sipStatsServerServiceUnavailOuts, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,7,8 } }, { sipStatsServerGatewayTimeoutIns, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,7,9 } }, { sipStatsServerGatewayTimeoutOuts, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,7,10 } }, { sipStatsServerBadSipVersionIns, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,7,11 } }, { sipStatsServerBadSipVersionOuts, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,7,12 } }, { sipStatsGlobalBusyEverywhereIns, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,8,1 } }, { sipStatsGlobalBusyEverywhereOuts, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,8,2 } }, { sipStatsGlobalDeclineIns, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,8,3 } }, { sipStatsGlobalDeclineOuts, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,8,4 } }, { sipStatsGlobalNotAnywhereIns, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,8,5 } }, { sipStatsGlobalNotAnywhereOuts, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,8,6 } }, { sipStatsGlobalNotAcceptableIns, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,8,7 } }, { sipStatsGlobalNotAcceptableOuts, ASN_COUNTER , RONLY , var_sipCommon, 3, { 2,8,8 } }, { sipCurrentTransactions, ASN_GAUGE , RONLY , var_sipCommon, 3, { 2,9,1 } }, { sipTransTo , ASN_OCTET_STR , RONLY , var_sipTransactionTable, 5, { 2,9,2,1,2 } }, { sipTransFrom , ASN_OCTET_STR , RONLY , var_sipTransactionTable, 5, { 2,9,2,1,3 } }, { sipTransCallId , ASN_OCTET_STR , RONLY , var_sipTransactionTable, 5, { 2,9,2,1,4 } }, { sipTransCSeq , ASN_GAUGE , RONLY , var_sipTransactionTable, 5, { 2,9,2,1,5 } }, { sipTransState , ASN_INTEGER , RONLY , var_sipTransactionTable, 5, { 2,9,2,1,6 } }, { sipTransOutstandingBranches, ASN_INTEGER , RONLY , var_sipTransactionTable, 5, { 2,9,2,1,7 } }, { sipTransExpiry , ASN_OCTET_STR , RONLY , var_sipTransactionTable, 5, { 2,9,2,1,8 } }, { sipTransCallingPartyContentType, ASN_OCTET_STR , RONLY , var_sipTransactionTable, 5, { 2,9,2,1,9 } }, { sipTransCalledPartyContentType, ASN_OCTET_STR , RONLY , var_sipTransactionTable, 5, { 2,9,2,1,10 } }, { sipNumUnsupportedUris, ASN_COUNTER , RONLY , var_sipCommon, 2, { 2,10 } },};/* (L = length of the oidsuffix) *//* * init_sipCommon(): * Initialization routine. This is called when the agent starts up. * At a minimum, registration of your variables should take place here. */void init_sipCommon(void) { /* register ourselves with the agent to handle our mib tree */ REGISTER_MIB("sipCommon", sipCommon_variables, variable7, sipCommon_variables_oid); /* place any other initialization junk you need here */}// this function will set the counterVal to the correct// value and return proper error status based on the// input mib object reqObject (AgentApiMibT)enum voReturnStatusrequestSipCounter(int reqObject, ulong *counterVal){ ipcMessage message; enum voReturnStatus retVal; retVal = ipcRequest((actionT)Get, (AgentApiMibVarT) reqObject, SIPSTACKPORT, &message); if (retVal == voSuccess) { *counterVal = (unsigned long) message.parm2[0]; } 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 bytesenum voReturnStatusrequestSipString(int reqObject, char *outBuff, int *strLen){ ipcMessage message; enum voReturnStatus retVal; memset(outBuff, 0, *strLen/4); retVal = ipcRequest((actionT)Get, (AgentApiMibVarT) reqObject, SIPSTACKPORT, &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;}/* * var_sipCommon(): * 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_sipCommon(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 tmpStrLen; if (header_generic(vp,name,length,exact,var_len,write_method) == MATCH_FAILED ) return NULL; /* * this is where we do the value assignments for the mib results. */ if (vp->magic >= sipSummaryInRequests && vp->magic <= sipNumUnsupportedUris) { if (requestSipCounter(vp->magic, &long_ret) != voSuccess) { return NULL; } return (unsigned char *) &long_ret; } switch(vp->magic) { case sipProtocolVersion : tmpStrLen = SPRINT_MAX_LEN; if (requestSipString(vp->magic, string, &tmpStrLen ) != voSuccess) { return NULL; } *var_len = strlen(string); return (unsigned char *) string; case sipServiceOperStatus : case sipServiceStartTime : case sipServiceLastChange : case sipMaxTransactions : if (requestSipCounter(vp->magic, &long_ret) != voSuccess) { return NULL; } return (unsigned char *) &long_ret; case sipServiceAdminStatus : *write_method = write_sipServiceAdminStatus; long_ret = 0; return (unsigned char *) &long_ret; case sipOrganization : *write_method = write_sipOrganization; *string = 0; *var_len = strlen(string); return (unsigned char *) string; case sipRequestDfltExpires : *write_method = write_sipRequestDfltExpires; long_ret = 0; return (unsigned char *) &long_ret; case sipHideOperation : *write_method = write_sipHideOperation; long_ret = 0; return (unsigned char *) &long_ret; case sipUserLocationServerAddr : *write_method = write_sipUserLocationServerAddr; *string = 0; *var_len = strlen(string); return (unsigned char *) string; default: ERROR_MSG(""); } return NULL;}/* * var_sipTransactionTable(): * Handle this table separately from the scalar value case. * The workings of this are basically the same as for var_sipCommon above. */unsigned char *var_sipTransactionTable(struct variable *vp, oid *name, size_t *length,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -