Re: Problems with async

2014-03-21 Thread Niels Baggesen
On Thu, Mar 20, 2014 at 03:01:21PM +, Pentasuglia, Corey wrote:
 Thanks again for the response Niels. I hope you don't mind me throwing
 one more at you. Is there a good way to take the value/values that are
 returned and convert them into strings (if they are of different snmp
 types)? Given the example below it seems like I'd have to have a case
 statement, but is there an easier way?

man netsnmp_varbind_api

You probably want snprint_variable or snprint_value.

/Niels

-- 
Niels Baggesen - @home - Århus - Denmark - n...@users.sourceforge.net
The purpose of computing is insight, not numbers   ---   R W Hamming

--
Learn Graph Databases - Download FREE O'Reilly Book
Graph Databases is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
___
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders


RE: Problems with async

2014-03-20 Thread Pentasuglia, Corey
Thanks again for the response Niels. I hope you don't mind me throwing one more 
at you. Is there a good way to take the value/values that are returned and 
convert them into strings (if they are of different snmp types)? Given the 
example below it seems like I'd have to have a case statement, but is there an 
easier way?

-Original Message-
From: Niels Baggesen [mailto:n...@users.sourceforge.net]
Sent: Wednesday, March 19, 2014 4:18 PM
To: Pentasuglia, Corey
Cc: net-snmp-coders
Subject: Re: Problems with async

Den 19-03-2014 20:27, Pentasuglia, Corey skrev:
 Say I get the system description:
 SNMPv2-MIB::sysDescr.0 = STRING: Linux system.name kernel#...so on How
 can I just retrieve what comes have STRING: and store it off in I a string?

if (vars-type == ASN_OCTET_STR) {
char *str = malloc(vars-val_len+1);
memcpy(str, vars-val.string, vars-val_len);
str[vars-val_len] = '\0';
...

/Niels

--
Niels Baggesen - @home - Århus - Denmark - n...@users.sourceforge.net
The purpose of computing is insight, not numbers   ---   R W Hamming
This message is intended only for the addressee and may contain information 
that is company confidential or privileged. Any technical data in this message 
may be exported only in accordance with the U.S. International Traffic in Arms 
Regulations (22 CFR Parts 120-130) or the Export Administration Regulations (15 
CFR Parts 730-774). Unauthorized use is strictly prohibited and may be 
unlawful. If you are not the intended recipient, or the person responsible for 
delivering to the intended recipient, you should not read, copy, disclose or 
otherwise use this message. If you have received this email in error, please 
delete it, and advise the sender immediately.

--
Learn Graph Databases - Download FREE O'Reilly Book
Graph Databases is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
___
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders


RE: Problems with async

2014-03-19 Thread Pentasuglia, Corey
Thanks for the response Niels! I was actually missing that entire loop as I 
thought it wasn't necessary for my case. I added in the loop as shown in the 
async example and now everything works! Would you happen to know the best way 
to get the value of the response?

Right now I am using print_variable to see the results.

Ex.
Say I get the system description:
SNMPv2-MIB::sysDescr.0 = STRING: Linux system.name kernel#...so on
How can I just retrieve what comes have STRING: and store it off in I a string?


Thanks!
Corey

-Original Message-
From: Niels Baggesen [mailto:n...@users.sourceforge.net]
Sent: Tuesday, March 18, 2014 5:40 PM
To: Pentasuglia, Corey; net-snmp-coders@lists.sourceforge.net
Subject: Re: Problems with async

Den 17-03-2014 12:54, Pentasuglia, Corey skrev:
 Is there anything I'm missing here? This app is in c++, so the
 callback is the only method that is declared with extern C. If this
 is incorrect please let me know. I am not setting the void*, because I
 don't need to send any data to the callback. As a starting point I
 have a debug point on the callback method that doesn't get hit. The
 snmp_async_send does not show any errors being sent.

What is there looks OK, but I am missing the select loop that detects that 
responses have been received and calls snmp_read to handle them?

Have you checked with tcpdump/wireshark that the packets are flowing?

/Niels

--
Niels Baggesen - @home - Århus - Denmark - n...@users.sourceforge.net
The purpose of computing is insight, not numbers   ---   R W Hamming
This message is intended only for the addressee and may contain information 
that is company confidential or privileged. Any technical data in this message 
may be exported only in accordance with the U.S. International Traffic in Arms 
Regulations (22 CFR Parts 120-130) or the Export Administration Regulations (15 
CFR Parts 730-774). Unauthorized use is strictly prohibited and may be 
unlawful. If you are not the intended recipient, or the person responsible for 
delivering to the intended recipient, you should not read, copy, disclose or 
otherwise use this message. If you have received this email in error, please 
delete it, and advise the sender immediately.

--
Learn Graph Databases - Download FREE O'Reilly Book
Graph Databases is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
___
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders


Re: Problems with async

2014-03-19 Thread Niels Baggesen
Den 19-03-2014 20:27, Pentasuglia, Corey skrev:
 Say I get the system description:
 SNMPv2-MIB::sysDescr.0 = STRING: Linux system.name kernel#...so on
 How can I just retrieve what comes have STRING: and store it off in I a 
 string?

if (vars-type == ASN_OCTET_STR) {
char *str = malloc(vars-val_len+1);
memcpy(str, vars-val.string, vars-val_len);
str[vars-val_len] = '\0';
...

/Niels

-- 
Niels Baggesen - @home - Århus - Denmark - n...@users.sourceforge.net
The purpose of computing is insight, not numbers   ---   R W Hamming

--
Learn Graph Databases - Download FREE O'Reilly Book
Graph Databases is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
___
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders


Re: Problems with async

2014-03-18 Thread Niels Baggesen
Den 17-03-2014 12:54, Pentasuglia, Corey skrev:
 Is there anything I’m missing here? This app is in c++, so the callback
 is the only method that is declared with extern “C”. If this is
 incorrect please let me know. I am not setting the void*, because I
 don’t need to send any data to the callback. As a starting point I have
 a debug point on the callback method that doesn’t get hit. The
 snmp_async_send does not show any errors being sent.

What is there looks OK, but I am missing the select loop that detects 
that responses have been received and calls snmp_read to handle them?

Have you checked with tcpdump/wireshark that the packets are flowing?

/Niels

-- 
Niels Baggesen - @home - Århus - Denmark - n...@users.sourceforge.net
The purpose of computing is insight, not numbers   ---   R W Hamming

--
Learn Graph Databases - Download FREE O'Reilly Book
Graph Databases is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
___
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders