The Boston Diaries

The ongoing saga of a programmer who doesn't live in Boston, nor does he even like Boston, but yet named his weblog/journal “The Boston Diaries.”

Go figure.

Thursday, February 15, 2007

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

ospfquery is written using the older CMU SNMP library. I want to update it to use the currently maintained Net SNMP 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 16th, 2007

Mark sent a reply.

Obligatory Picture

[The future's so bright, I gotta wear shades]

Obligatory Contact Info

Obligatory Feeds

Obligatory Links

Obligatory Miscellaneous

You have my permission to link freely to any entry here. Go ahead, I won't bite. I promise.

The dates are the permanent links to that day's entries (or entry, if there is only one entry). The titles are the permanent links to that entry only. The format for the links are simple: Start with the base link for this site: https://boston.conman.org/, then add the date you are interested in, say 2000/08/01, so that would make the final URL:

https://boston.conman.org/2000/08/01

You can also specify the entire month by leaving off the day portion. You can even select an arbitrary portion of time.

You may also note subtle shading of the links and that's intentional: the “closer” the link is (relative to the page) the “brighter” it appears. It's an experiment in using color shading to denote the distance a link is from here. If you don't notice it, don't worry; it's not all that important.

It is assumed that every brand name, slogan, corporate name, symbol, design element, et cetera mentioned in these pages is a protected and/or trademarked entity, the sole property of its owner(s), and acknowledgement of this status is implied.

Copyright © 1999-2024 by Sean Conner. All Rights Reserved.