Skip navigation.
Home
The QNX Community Portal

View topic - Hello Friends.

Hello Friends.

Discussion about the QNX6 OS.

Hello Friends.

Postby gopyan » Fri Dec 20, 2013 1:54 pm

Please, help me out.

I try to connect to snmp agent, but unsuccessfully. My code

Code: Select all
   struct snmp_session sss;
   struct snmp_session* sss1;
   struct snmp_pdu * pdu = NULL;
   oid src_par[] = {1,3,6,1,2,1,1};
   oid dst_par[] = {1,3,6,1,2,1,1,9};
   oid cont[] = {1,3,6,1,2,1,1,1};
   sss.community = (u_char*)"public";
   sss.community_len = strlen("public");
   sss.retries = 2;
   sss.timeout = 500000;
   sss.peername = "192.168.123.187";
   sss.remote_port = 161;
   sss.local_port = 0;
   sss.authenticator = NULL;
   sss.callback = snmp_callback;
   sss.version = SNMP_VERSION_2;
   sss.srcParty = src_par;
   sss.srcPartyLen = 7;
   sss.dstParty = dst_par;
   sss.dstPartyLen = 8;
   sss.context = cont;
   sss.contextLen = 8;
   
         
   
   
   sss1 = snmp_open(&sss);
   
   pdu = snmp_pdu_create(GET_REQ_MSG);
   snmp_send( sss1, pdu );
   
   
   return EXIT_SUCCESS;


After snmp_send call I get error "Error building packet".
gopyan
Active Member
 
Posts: 64
Joined: Tue Mar 02, 2010 1:39 pm

Re: Hello Friends.

Postby maschoen » Sat Dec 21, 2013 12:53 am

You don't seem to be setting up a variable to retrieve in the pdu, eg.

oid oid[MAX_OID_LEN];
size_t oid_len;

...


pdu = snmp_pdu_create(GET_REQ_MSG);

read_objid(OID_NAME, oid, &oid_len);
snmp_add_null_var(pdu, oid, oid_len);

snmp_send(...)
maschoen
QNX Master
 
Posts: 2640
Joined: Wed Jun 25, 2003 5:18 pm

Re: Hello Friends.

Postby gopyan » Mon Dec 23, 2013 9:40 am

maschoen wrote:You don't seem to be setting up a variable to retrieve in the pdu, eg.

oid oid[MAX_OID_LEN];
size_t oid_len;
pdu = snmp_pdu_create(GET_REQ_MSG);

read_objid(OID_NAME, oid, &oid_len);
snmp_add_null_var(pdu, oid, oid_len);

snmp_send(...)


Hello Maschoen. Thanks for your help. I try to use your suggestion, but unsuccessfully. This is code.

struct snmp_session sss;
struct snmp_session* sss1;
struct snmp_pdu * pdu = NULL;

oid oid_sys[MAX_OID_LEN];
int oid_len;


oid src_par[] = {1,3,6,1,2,1,1};
oid dst_par[] = {1,3,6,1,2,1,1,9};
oid cont[] = {1,3,6,1,2,1,1,1};
sss.community = (u_char*)"public";
sss.community_len = strlen("public");
sss.retries = 2;
sss.timeout = 500000;
sss.peername = "192.168.123.187";
sss.remote_port = 161;
sss.local_port = 0;
sss.authenticator = NULL;
sss.callback = snmp_callback;
sss.version = SNMP_VERSION_2;
sss.srcParty = src_par;
sss.srcPartyLen = 7;
sss.dstParty = dst_par;
sss.dstPartyLen = 8;
sss.context = cont;
sss.contextLen = 8;


init_mib();I add this lines


sss1 = snmp_open(&sss);

pdu = snmp_pdu_create(GET_REQ_MSG);
read_objid(".1.3.6.1.2.1.1.1.0", oid_sys, &oid_len);
snmp_add_null_var(pdu, oid_sys, oid_len); I add this lines

snmp_send( sss1, pdu );



But error still remain - "Error building packet"
gopyan
Active Member
 
Posts: 64
Joined: Tue Mar 02, 2010 1:39 pm

Re: Hello Friends.

Postby gopyan » Mon Dec 23, 2013 11:14 am

And what is the purpose of the srcParty,dstParty, context vars and what is difference between this vars??????
gopyan
Active Member
 
Posts: 64
Joined: Tue Mar 02, 2010 1:39 pm

Re: Hello Friends.

Postby gopyan » Thu Dec 26, 2013 1:18 pm

Machoen , where are you????
gopyan
Active Member
 
Posts: 64
Joined: Tue Mar 02, 2010 1:39 pm

Re: Hello Friends.

Postby maschoen » Thu Dec 26, 2013 6:23 pm

gopyan wrote:Machoen , where are you????

I don't have anything to add. I don't know why your code isn't working.
maschoen
QNX Master
 
Posts: 2640
Joined: Wed Jun 25, 2003 5:18 pm

Re: Hello Friends.

Postby gopyan » Sun Dec 29, 2013 3:37 pm

Maybe, someone have working snmp source code or part of the code , where PDU being initialized?????????????????
gopyan
Active Member
 
Posts: 64
Joined: Tue Mar 02, 2010 1:39 pm


Return to QNX6 - OS

Who is online

Users browsing this forum: Exabot [Bot] and 2 guests