There's more wierdness to this than reported, but this will be fine for now

ospfquery is written using the older CMU (Carnegie Mellon University) [1] SNMP (Simple Network Management Protocol) library. I want to update it to use the currently maintained Net SNMP [2] library, but I've been having problems getting it to work. The problematic bit of code seems to be:

netsnmp_session session;
int r;
init_snmp("snmpapp");
snmp_enable_stderrlog();
snmp_sess_init(&session);
session.version = SNMP_VERSION_1;
session.peername = "XXXXXXXXXXXXXXXXXXXXXXX";
session.community = "XXXXXXXXX";
session.community_len = strlen(session.community);
gss = snmp_open(&session);

Everytime I try to run it (and by “it” I mean a small test program that just queries the system id), I get “snmpget: Too long”. Yet, if I change the above to:

netsnmp_session session;
int r;
snmp_parse_args(argc,argv,&session,"",NULL);
gss = snmp_open(&session);

it (and by “it” I mean a small test program that just queries the system id) works fine. And as far as I can tell, all that snmp_parse_args() is doing is the code in the first example, distilled down to just what's required to initialize session (so why don't I just use snmp_parse_args() and be done with it? snmp_parse_args() exists to parse the command line for the various tools like snmpget and snmpwalk which I don't need—ospfquery has its own command line that doesn't need replacing).

So, I recompiled Net SNMP to include debugging information so I could trace down into the various calls, and for some reason, the debugging information isn't being generated (or else there's some other problem with gdb that I don't know about).

Okay, so I decided to just link directly against the object files that make up Net SNMP, and that's when things got wierd:

[spc]royal-oak:~/source/snmp>gcc -o sysid3 sysid3.c -lnetsnmp -lcrypto
[spc]royal-oak:~/source/snmp>./sysid3
snmpget: Too long
XXXXXXXXXXXXXXXXXXXXXXX is unknown
[spc]royal-oak:~/source/snmp>gcc -o sysid3 sysid3.c \
~/apps/net-snmp-5.2.1/snmplib/*.o -lcrypto
[spc]royal-oak:~/source/snmp>./sysid3
XXXXXXXXXXXXXXXXXXXXXXX is a riverstone
[spc]royal-oak:~/source/snmp>

So let me get this straight: I link against the library, and the program doesn't work. I link against the object files, and it works just fine.

Okay.

Anybody care to explain?

Update on Friday, February 16^th, 2007

Mark [3] sent a reply [4].

=> [1] http://www.cmu.edu/ | [2] http://www.net-snmp.org/ | [3] http://www.gladesoft.com/ | [4] /boston/2007/02/16.3

=> Gemini Mention this post | Contact the author

Proxy Information
Original URL
gemini://gemini.conman.org/boston/2007/02/15.1
Status Code
Success (20)
Meta
text/gemini
Capsule Response Time
565.102294 milliseconds
Gemini-to-HTML Time
1.851837 milliseconds

This content has been proxied by September (3851b).