📄 rvsnmpif.h
字号:
#if (0)
******************************************************************************
Filename : rvsnmpif.h
Description: rv snmp interface module
******************************************************************************
Copyright (c) 1999 RADVision Inc.
******************************************************************************
NOTICE:
This document contains information that is proprietary to RADVision LTD.
No part of this publication may be reproduced in any form whatsoever
without written prior approval by RADVision LTD..
RADVision LTD. reserves the right to revise this publication and make
changes without obligation to notify any person of such revisions or
changes.
******************************************************************************
$Revision:$
$Date:$
$Author:$
******************************************************************************
#endif
#ifndef RVSNMPIF_H
#define RVSNMPIF_H
#include <stddef.h>
#include "rvtypes.h"
#if defined (RV_SNMP) && (defined(RV_OS_WIN32) || defined(RV_OS_SOLARIS))
#define RV_SNMP_SUBAGENT
#endif
/*$
{package:
{name: Snmpif}
{superpackage: Core}
{include: rvsnmpif.h}
{description:
{p: This package provides core SNMP functions.}
}
{nested_types:
{nested_type: RvSnmpStatus}
{nested_type: RvSnmpType}
}
{callbacks:
{method: void RvSnmpTrapCB(RvUint* oid, size_t oidLen, int type, char* value, size_t len);}
}
{methods:
{method: void rvSnmpIfRegisterTrap(RvSnmpTrapCB trapFn, void* data);}
{method: RvSnmpStatus rvSnmpIfGet(RvUint* oid, size_t oidLen, RvSnmpType* type, void* value, size_t* len);}
{method: RvSnmpStatus rvSnmpIfGetNext(RvUint* oid, size_t* oidLen, RvSnmpType* type, void* value, size_t* len);}
{method: RvSnmpStatus rvSnmpIfSet(RvUint* oid, size_t oidLen, RvSnmpType type, void* value, size_t len);}
}
}
$*/
/*$
{type:
{name: RvSnmpType}
{superpackage: Snmpif}
{include: rvsnmpif.h}
{description:
{p: Describes SNMP data types.}
}
{enumeration:
{value: {n:RV_SNMPTYPE_INTEGER} {d:A signed whole number, the value limit is not specified by ASN.1}}
{value: {n:RV_SNMPTYPE_BITS} {d:Bits}}
{value: {n:RV_SNMPTYPE_OCTETSTRING} {d:A sequence of octets. It can be printable characters or binary data.}}
{value: {n:RV_SNMPTYPE_NULL} {d:A Null value.}}
{value: {n:RV_SNMPTYPE_OBJECTIDENTIFIER} {d:An Object Identifier}}
{value: {n:RV_SNMPTYPE_INTEGER32} {d:A 32-bit Integer}}
{value: {n:RV_SNMPTYPE_IPADDRESS} {d:IP Address}}
{value: {n:RV_SNMPTYPE_COUNTER32} {d:An unsigned 32-bit counter}}
{value: {n:RV_SNMPTYPE_GAUGE32} {d:An unsigned 32-bit integer Gauge}}
{value: {n:RV_SNMPTYPE_TIMETICKS} {d:An unsigned 32-bit integer containing an interval of time.}}
{value: {n:RV_SNMPTYPE_OPAQUE} {d:Opaque}}
{value: {n:RV_SNMPTYPE_COUNTER64} {d:A 64-bit Counter}}
{value: {n:RV_SNMPTYPE_UNSIGNED32} {d:A 32-bit Unsigned Integer}}
}
}
$*/
typedef int RvSnmpType;
/*$
{type:
{name: RvSnmpStatus}
{superpackage: Snmpif}
{include: rvsnmpif.h}
{description:
{p: Describes SNMP return status}
}
{enumeration:
{value: {n:RV_SNMPSTATUS_NOERROR} {d:No error.}}
{value: {n:RV_SNMPSTATUS_TOOBIG} {d:Too big.}}
{value: {n:RV_SNMPSTATUS_NOSUCHNAME } {d:No such name.}}
{value: {n:RV_SNMPSTATUS_BADVALUE } {d:Bad value.}}
{value: {n:RV_SNMPSTATUS_READONLY } {d:Read only.}}
{value: {n:RV_SNMPSTATUS_GENERR } {d:General error.}}
{value: {n:RV_SNMPSTATUS_NOACCESS } {d:No access.}}
{value: {n:RV_SNMPSTATUS_WRONGTYPE } {d:Wrong type.}}
{value: {n:RV_SNMPSTATUS_WRONGLENGTH } {d:Wrong length.}}
{value: {n:RV_SNMPSTATUS_WRONGENCODING } {d:Wrong encoding.}}
{value: {n:RV_SNMPSTATUS_WRONGVALUE } {d:Wrong value.}}
{value: {n:RV_SNMPSTATUS_NOCREATION } {d:No creation.}}
{value: {n:RV_SNMPSTATUS_INCONSISTENTVALUE } {d:Inconsistent value.}}
{value: {n:RV_SNMPSTATUS_RESOURCEUNAVAILABLE } {d:Resource unavailable.}}
{value: {n:RV_SNMPSTATUS_COMMITFAILED } {d:Commit failed.}}
{value: {n:RV_SNMPSTATUS_UNDOFAILED } {d:Un-do failed.}}
{value: {n:RV_SNMPSTATUS_AUTHORIZATIONERROR } {d:Authorization error.}}
{value: {n:RV_SNMPSTATUS_NOTWRITABLE } {d:Not writable.}}
{value: {n:RV_SNMPSTATUS_INCONSISTENTNAME } {d:Inconsistent name.}}
}
}
$*/
typedef unsigned int RvSnmpStatus;
/*$
{callback:
{name: RvSnmpTrapCB}
{superpackage: Snmpif}
{include: rvsnmpif.h}
{description:
{p: This callback is called when a new trap message is received. Use the
rvSnmpIfRegisterTrap method to register this callback.}
}
{proto: void RvSnmpTrapCB(RvUint* oid, size_t oidLen, int type, char* value, size_t len);}
{params:
{param: {n: oid} {d: The OID of the MIB entry as an array of unsigned integers.}}
{param: {n: oidLen} {d: The number of elements in the OID array.}}
{param: {n: type} {d: The value data type.}}
{param: {n: value } {d: The value received.}}
{param: {n: len} {d: The value length in bytes.}}
}
{see_also:
{n: void rvSnmpIfRegisterTrap(RvSnmpTrapCB trapFn, void* data);}
}
}
$*/
typedef void (*RvSnmpTrapCB)(RvUint*, size_t, int, char*, size_t);
typedef RvSnmpStatus (*RvSnmpStackCB)(RvUint rvIndex, void *rvValue);
#define RV_SNMP_UNIVERSAL 0x00
#define RV_SNMP_APPLICATION 0x40
#define RV_SNMP_CONTEXT 0x80
#define RV_SNMP_PRIVATE 0xC0
#define RV_SNMP_PRIMITIVE 0x00
#define RV_SNMP_CONSTRUCTOR 0x20
#define RV_SNMPTYPE_INTEGER (RV_SNMP_UNIVERSAL | RV_SNMP_PRIMITIVE | 0x02)
#define RV_SNMPTYPE_BITS (RV_SNMP_UNIVERSAL | RV_SNMP_PRIMITIVE | 0x03)
#define RV_SNMPTYPE_OCTETSTRING (RV_SNMP_UNIVERSAL | RV_SNMP_PRIMITIVE | 0x04)
#define RV_SNMPTYPE_NULL (RV_SNMP_UNIVERSAL | RV_SNMP_PRIMITIVE | 0x05)
#define RV_SNMPTYPE_OBJECTIDENTIFIER (RV_SNMP_UNIVERSAL | RV_SNMP_PRIMITIVE | 0x06)
#define RV_SNMPTYPE_OBJECTID (RV_SNMP_UNIVERSAL | RV_SNMP_PRIMITIVE | 0x06)
#define RV_SNMPTYPE_INTEGER32 RV_SNMP_INTEGER
#define RV_SNMPTYPE_IPADDRESS (RV_SNMP_APPLICATION | RV_SNMP_PRIMITIVE | 0x00)
#define RV_SNMPTYPE_COUNTER32 (RV_SNMP_APPLICATION | RV_SNMP_PRIMITIVE | 0x01)
#define RV_SNMPTYPE_GAUGE32 (RV_SNMP_APPLICATION | RV_SNMP_PRIMITIVE | 0x02)
#define RV_SNMPTYPE_TIMETICKS (RV_SNMP_APPLICATION | RV_SNMP_PRIMITIVE | 0x03)
#define RV_SNMPTYPE_OPAQUE (RV_SNMP_APPLICATION | RV_SNMP_PRIMITIVE | 0x04)
#define RV_SNMPTYPE_COUNTER64 (RV_SNMP_APPLICATION | RV_SNMP_PRIMITIVE | 0x06)
#define RV_SNMPTYPE_UNSIGNED32 (RV_SNMP_APPLICATION | RV_SNMP_PRIMITIVE | 0x07)
/* MIB request actions */
#define RV_SNMP_MIBACTION_GET (RV_SNMP_CONTEXT | RV_SNMP_CONSTRUCTOR | 0x0)
#define RV_SNMP_MIBACTION_GETNEXT (RV_SNMP_CONTEXT | RV_SNMP_CONSTRUCTOR | 0x1)
#define RV_SNMP_MIBACTION_SET (RV_SNMP_CONTEXT | RV_SNMP_CONSTRUCTOR | 0x3)
#define RV_SNMP_MIBACTION_ALIVE (RV_SNMP_CONTEXT | RV_SNMP_CONSTRUCTOR | 0x4)
#define RV_SNMP_MIBACTION_STACK (RV_SNMP_CONTEXT | RV_SNMP_CONSTRUCTOR | 0x5)
/* SNMP Error Codes */
#define RV_SNMPSTATUS_NOERROR 0
#define RV_SNMPSTATUS_TOOBIG 1
#define RV_SNMPSTATUS_NOSUCHNAME 2
#define RV_SNMPSTATUS_BADVALUE 3
#define RV_SNMPSTATUS_READONLY 4
#define RV_SNMPSTATUS_GENERR 5
#define RV_SNMPSTATUS_NOACCESS 6
#define RV_SNMPSTATUS_WRONGTYPE 7
#define RV_SNMPSTATUS_WRONGLENGTH 8
#define RV_SNMPSTATUS_WRONGENCODING 9
#define RV_SNMPSTATUS_WRONGVALUE 10
#define RV_SNMPSTATUS_NOCREATION 11
#define RV_SNMPSTATUS_INCONSISTENTVALUE 12
#define RV_SNMPSTATUS_RESOURCEUNAVAILABLE 13
#define RV_SNMPSTATUS_COMMITFAILED 14
#define RV_SNMPSTATUS_UNDOFAILED 15
#define RV_SNMPSTATUS_AUTHORIZATIONERROR 16
#define RV_SNMPSTATUS_NOTWRITABLE 17
#define RV_SNMPSTATUS_INCONSISTENTNAME 18
#define RVSIZEOID( rvOid ) (sizeof (rvOid) / sizeof(RvUint))
/* Stack Type */
#define RV_STACKTYPE_MG 1
#define RV_STACKTYPE_MGC 2
#define RV_STACKTYPE_MEGACOMG 3
#define RV_STACKTYPE_MEGACOMGC 4
/* oid variable entry definition */
typedef struct RvOidVars_s
{
RvUint *rvOid; /* MIB variable OID */
size_t rvOidLen; /* mib oid length */
RvUint8 bType; /* ASN.1 data type of variable */
RvSnmpStatus (*getFunc)( RvUint rvIndex, void *rvValue);
RvSnmpStatus (*setFunc)( RvUint rvIndex, void *rvValue);
size_t (*getTableFunc)(void);
} RvOidVars;
/* registration mib table */
typedef struct
{
RvUint *oidPrefix; /* oid prefix */
size_t oidPrefixLen; /* oid prefix length */
struct RvOidVars_s *rvOidPtr; /* oid array pointer */
RvUint rvOidNums; /* oid array number */
} RvRegMib;
/* Snmp Trap */
typedef struct {
RvSnmpTrapCB func;
void* data;
} RvSnmpIfTrap;
/* Snmp Stack */
typedef struct {
RvSnmpStackCB func;
void * data;
} RvSnmpIfStack;
#if defined(__cplusplus)
extern "C" {
#endif
/* Radvision Snmp function prototypes */
RvBool rvSnmpIfInit(void);
void rvSnmpIfEnd(void);
void rvSnmpIfRegisterMib(RvUint *oidPrefix, /* group oid prefix */
size_t oidPrefixLen, /* group oid length */
RvOidVars *rvOidPtr, /* group oid array pointer */
RvUint rvOidNums); /* group oid total size */
RvSnmpStatus rvSnmpIfGet(RvUint *rvOid, /* IN, mib oid */
size_t rvOidLen, /* IN, oid length */
OUT RvSnmpType *dataType, /* OUT, data Type */
OUT void *rvValue, /* OUT, data value */
OUT size_t *dataLen); /* OUT, data length */
RvSnmpStatus rvSnmpIfSet(RvUint *rvOid, /* in, oid */
size_t rvOidLen, /* in, oid length */
RvSnmpType dataType, /* in, data type */
void *rvValue, /* in, set value */
size_t dataLen); /* in, data length */
RvSnmpStatus rvSnmpIfGetNext(INOUT RvUint *rvOid, /* INOUT, mib oid */
INOUT size_t *rvOidLen, /* INOUT, oid length */
OUT RvSnmpType *dataType, /* OUT, data type */
OUT void *dataValue, /* OUT, data value */
OUT size_t *dataLen ); /* OUT, data length */
RvSnmpStatus rvSnmpIfGetFnc(int offset1,
int offset2,
int index,
RvSnmpType *dataType,
OUT void *rvValue,
OUT size_t *dataLen);
RvSnmpStatus rvSnmpIfSetFnc(int offset1,
int offset2,
int index,
RvSnmpType dataType,
OUT void *rvValue,
OUT size_t dataLen);
/* Trap */
extern RvSnmpIfTrap rvSnmpIfTrap;
void rvSnmpIfRegisterTrap(RvSnmpTrapCB func, void* data);
/* Stack */
void rvSnmpIfRegisterGetActiveStack(RvSnmpStackCB func, void* data);
void rvSnmpIfRegisterSetActiveStack(RvSnmpStackCB func, void* data);
void rvSnmpIfRegisterGetStackSize(RvSnmpStackCB func, void* data);
void rvSnmpIfRegisterGetStackType(RvSnmpStackCB func, void* data);
void rvSnmpIfRegisterGetStackName(RvSnmpStackCB func, void* data);
RvSnmpStatus rvSnmpGetActiveStack(RvUint rvIndex, void *rvValue);
RvSnmpStatus rvSnmpSetActiveStack(RvUint rvIndex, void *rvValue);
RvSnmpStatus rvSnmpGetStackSize(RvUint rvIndex, void *rvValue);
RvSnmpStatus rvSnmpGetStackType(RvUint rvIndex, void *rvValue);
RvSnmpStatus rvSnmpGetStackName(RvUint rvIndex, void *rvValue);
#if defined(__cplusplus)
}
#endif
#endif /* RVSNMPIF_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -