Related to developing a SNMP extension agent DLL?
I am following the tutorial below to create an extension agent DLL. I am following the tutorial below: http://www.codeproject.com/KB/IP/SNMP_Agent_DLL__Part1_.aspx
According to the tutorial, I am required to use these 1 of method signatures at a minimum among others:
BOOL SNMP_FUNC_TYPE SnmpExtensionQuery(BYTE bPduType,
SnmpVarBindList *pVarBindList,
AsnInteger32 *pErrorStatus,
AsnInteger32 *pErrorIndex)
The issue is with SnmpVarBindList *pVarBindList parameter. I am suppossed to insert the following data e.g ("About", "Name", "Age") into the SnmpVarBindList datatype and t开发者_如何学Gohan pass it into the method above...
but I am not sure how to create the list of SnmpVarBindList datatype and insert the following data e.g ("About", "Name", "Age") into the list??
MIB_ENTRY g_MyMibTable[] = {
{
{OID_SIZEOF(g_unAboutOid),g_unAboutOid},
&g_szAbout,
"About",
ASN_OCTETSTRING,
SNMP_ACCESS_READ_ONLY,
&g_MyMibTable[1]
},
{
{OID_SIZEOF(g_unNameOid),g_unNameOid},
&g_szName,
"Name",
ASN_OCTETSTRING,
SNMP_ACCESS_READ_WRITE,
&g_MyMibTable[2]
},
{
{OID_SIZEOF(g_unAgeOid),g_unAgeOid},
&g_asnIntAge,
"Age",
ASN_INTEGER,
SNMP_ACCESS_READ_WRITE,
NULL
}
};
========================================================================================== // struct definations for your reference:
typedef struct {
AsnObjectName name;
AsnObjectSyntax value;
} SnmpVarBind;
typedef struct {
SnmpVarBind * list;
UINT len;
} SnmpVarBindList;
Any guidance or code example provided will be much appreciated, I am new to C++
Sincerely,
Here is what you need.
/* Définitions of vars leaves.
Terminal zero is needed
*/
UINT MIB_About[] = { 2, 1, 0 };
UINT MIB_Name[] = { 2, 2, 0 };
UINT MIB_Age[] = { 2, 3, 0 };
/* Physical (Har-coded) data of the MIB
*/
char MIB_AboutStor[] = "The about text";
char MIB_NameStor[] = "The Name text";
AsnInteger MIB_AgeStor = 20;
extern MIB_ENTRY Mib[];
extern UINT MIB_num_variables;
/* initialisation du modèle d'accès aux variables de la MIB
*/
MIB_ENTRY Mib[] = {
{ { OID_SIZEOF(MIB_About), MIB_About },
&MIB_AboutStor, ASN_RFC1213_DISPSTRING,
MIB_ACCESS_READ, MIB_leaf_func, &Mib[1] },
{ { OID_SIZEOF(MIB_Name), MIB_Name },
&MIB_NameStor, ASN_RFC1213_DISPSTRING,
MIB_ACCESS_READ, MIB_leaf_func, &Mib[2] },
{ { OID_SIZEOF(MIB_Age), MIB_Age },
&MIB_AgeStor, ASN_INTEGER,
MIB_ACCESS_READWRITE, MIB_control_func, NULL }
};
UINT MIB_num_variables = sizeof Mib / sizeof( MIB_ENTRY );
You can finf MIB_leaf_func
and MIB_control_func
in Microsoft Example.
精彩评论