Computing.Net > Forums > Programming > SnmpSendMsg and Pdu

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

SnmpSendMsg and Pdu

Reply to Message Icon

Name: Chi Happens
Date: February 18, 2005 at 11:44:33 Pacific
OS: WiNXP
CPU/Ram: N/A
Comment:

Does anyone have an example of how to use SnmpSendMsg? All i need to do is create a simple Pdu and send it, but I have no idea how to add my message into the Pdu and so, SnmpSendMsg does nothing.

I have searched google and msdn to no avail, i can get all the documentation from MSDN, but there are no bloody examples.

Any help is appreciated.

PS. I AM USING C#

ah and here is my code so far:


SnmpCB = new SnmpAPI.SnmpCallback(OnSnmpMessage);

string LocalAddr = System.Net.Dns.GetHostName();
string RemoteAddr = System.Net.Dns.GetHostByName("Alarm").AddressList[0].ToString();

int major, minor, level, translate, retran;

SNMPAPI_STATUS rc = SnmpAPI.SnmpStartup(out major, out minor, out level, out translate, out retran);
if (rc != SNMPAPI_STATUS.SNMPAPI_SUCCESS)
throw new Exception("SNMP Initialization Error");

IntPtr hSnmp = SnmpAPI.SnmpCreateSession(IntPtr.Zero, 0, SnmpCB, IntPtr.Zero);

IntPtr Src = SnmpAPI.SnmpStrToEntity(hSnmp,LocalAddr);
IntPtr Dest = SnmpAPI.SnmpStrToEntity(hSnmp,RemoteAddr);

WinSnmp.SMIOCTETS Octets = new SMIOCTETS();
WinSnmp.SMIVALUE Value = new SMIVALUE();
IntPtr Context = SnmpAPI.SnmpStrToContext(hSnmp,ref Octets);

WinSnmp.SMIOID Name = new SMIOID();
IntPtr VbList = SnmpAPI.SnmpCreateVbl(hSnmp,ref Name,ref Value);

IntPtr Pdu = SnmpAPI.SnmpCreatePdu(hSnmp,WinSnmp.SNMPAPI_PDU.SNMP_PDU_SET,null,null,null,VbList);
SnmpAPI.SnmpSendMsg(hSnmp,Src,Dest,Context,Pdu);
SnmpAPI.SnmpFreePdu(Pdu);


TIA,
Chi

They mostly come at night...mostly



Sponsored Link
Ads by Google

Response Number 1
Name: Chi Happens
Date: February 22, 2005 at 09:56:13 Pacific
Reply:

see next message.

lol
Chi

They mostly come at night...mostly


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: SnmpSendMsg and Pdu

Snmp module using Winsnmp www.computing.net/answers/programming/snmp-module-using-winsnmp/12339.html

Vista borland c++ compiler (bcc55) www.computing.net/answers/programming/vista-borland-c-compiler-bcc55/18172.html

how to read and write the disk www.computing.net/answers/programming/how-to-read-and-write-the-disk-/11804.html