Hi
I need help with programming snmp. How can I make this program to say HELLO?
When I’m trying
snmpget -d 172.16.1.11 -p 16001 manager_party agent_part agent_context .1
mi program gets the packet and on the stdout is writen message something
like:
Unknown destination party: .1.3.6.1.6.3.3.1.3.10.0.0.59.5
Unrecognizable or unauthentic packet received.
I have standard snmp-configuration unchanged files from standard
instalation.
Please help me, I need functional examle. I need to see how does it work.
The standart documentation about snmp-api included
in qnx is very brief and it’s buggy.
Thanks
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/time.h>
#include <sys/select.h>
#include <sys/types.h>
#include <snmp/snmp.h>
#include <snmp/asn1.h>
#include <snmp/snmp_api.h>
extern int snmp_error;
struct snmp_session ses;
int cback(int operation, struct snmp_session *ses, int reqid, struct
snmp_pdu *pdu, void *magic)
{
printf(“HELLO\n”);
return 0;
}
int main(int argc, char **argv)
{
oid context[]= { 1, 3, 6, 1, 6, 3, 3, 1, 4, 10, 0, 0, 70, 1 };
oid dstparty[]= { 1, 3, 6, 1, 6, 3, 3, 1, 3, 0, 0, 0, 0, 5 };
oid srcparty[]= { 1, 3, 6, 1, 6, 3, 3, 1, 3, 127, 0, 0, 1, 1 };
fd_set fdset;
int numfds = 0;
struct timeval timeout;
struct snmp_session *ss;
FD_ZERO(&fdset);
bzero((char *)&ses, sizeof(struct snmp_session));
ses.remote_port = 161;
ses.local_port = 16001;
ses.callback = cback;
ses.peername = “172.16.1.11”;
ses.version = SNMP_VERSION_2;
ses.dstParty = dstparty;
ses.dstPartyLen = sizeof(dstparty) / sizeof(dstparty);
ses.srcParty = srcparty;
ses.srcPartyLen = sizeof(srcparty) / sizeof(dstparty);
ses.context = context;
timerclear(&timeout);
snmp_select_info(&numfds, &fdset, &timeout, 0);
snmp_read(&fdset);
return 0;
}