libsnmpkit(3)

πŸ“¦ version 0.9, in ubuntu jammy

✨ libsnmpkit(3) ✨

okay bestie, welcome to the libsnmpkit manual page πŸ’– this is the library functions manual for snmpkit, and it's lowkey one of the most underrated little toolkits out there. grab a boba, we're doing SNMP πŸ§‹


NAME πŸŽ€

snmpkit β€” SNMP communication library


SYNOPSIS πŸ¦‹

#include <snmpkit.h>

SNMPSTRUCTFILLER *new_snmpstructfiller(SNMPSESSION *session);
void delete_snmpstructfiller(SNMPSTRUCTFILLER *doomed);
void snmpstructfiller_append(SNMPSTRUCTFILLER *sf, const char *oidstr,Tags tag, unsigned int offset);
void snmpstructfiller_remove(SNMPSTRUCTFILLER *sf,const char *oidstr);
void *snmpstructfiller_get(SNMPSTRUCTFILLER *sf,void *tobefilled);
void *snmpstructfiller_get_next(SNMPSTRUCTFILLER *sf, void *tobefilled);

SNMPTABLE *new_snmptable(SNMPSESSION *session,unsigned int structlen);
void delete_snmptable(SNMPTABLE *doomed);
void snmptable_append(SNMPTABLE *st,const char *oidstr,Tags tag, unsigned int offset);
void snmptable_remove(SNMPTABLE *st,const char *oidstr);
void *snmptable_get(SNMPTABLE *st,unsigned int *len);

DESCRIPTION πŸ’…

so like… snmpkit is a toolkit for doing SNMP queries of network connected devices. simple. iconic. but the way it's designed? genuinely different from every other snmp library you've met, like the ones published by CMU and UC Davis. those libraries? they largely preserve the OSI model in their programming interfaces. which is a choice. in other words, they expect that applications are going to request objects by name from the MIBs. and that introduces quite a lot of overhead, because the objects get translated in and out of their textual representations each and every single time a request is done 😭 they also assume they're communicating with only one host. one. singular. bestie.

snmpkit is different, because it assumes your program is going to be querying a few well known objects on a large number of hosts. in other words, the design of the library is exactly the opposite of the traditional SNMP libraries. it doesn't bother with all the MIB processing. it figures that the objects the programmer wants to query are well known at the time of application development, and therefore it is worth the time to read the MIB by hand, figure out what the OID for the object is, and hard code that into the application. and since it assumes you're going to be communicating with a large number of hosts, it provides a mechanism to allow many sessions on one socket. periodt. πŸ”₯

for example β€” say you want to find out the page count on all the printers you have enterprise wide. this amounts to 3500 different printers. πŸ’€ one approach would be to have a script sequentially go through each and every printer and query its page count. this would take a very long time, because out of those 3500 printers there would be a handful which are either turned off, broken, or for which you have incorrect information. the queries would be reasonably fast right up until the point where you hit one which didn't respond, and then your script would pause for quite some time before giving up and going on to the next one. not the vibe. πŸ™ˆ

one solution to this problem would be to parallelize the task so that you start up several of the processes at once. in this case, the problem is that each one of those queries would consume one process as well as one socket per host. care would have to be exercised so as not to forkbomb the computer or run out of open file descriptors. not it. this approach β€” snmpkit's approach β€” allows you to multiplex all the SNMP queries on one socket. slay. πŸ‘‘

the third thing that is different about snmpkit is that it is optimized to fill structures with information. if you're fetching individual objects, you basically specify the objects that you want in a structure and tell the structure filler where within the structure to put the object, and then call one of the get functions. if you want to fetch all the rows in a table it is very similar: you specify what objects you want and their offsets into the structure, then you specify the structure length, and it will fetch all the rows within the structure and return a vector of all the structures and the number of structures that are fetched. that's it, that's the whole thing, and honestly? it ate. πŸ“


AUTHOR 🫢

Ben Woodard <ben@users.sourceforge.net>


BUGS 😭

Interface bug β€” the method of filling structures is really nasty code. it does all sorts of really evil futzing with pointers. it should probably be rewritten to call a function which puts the variable in place. the thing is, it took a long time to get right, but now it works and it is very efficient. so like… it's a mess and it's also serving, and we're keeping it πŸ’€
Interface bug β€” the snmptable functions return a pointer to a dynamically allocated vector of structures. it should probably return some type of container instead. iykyk.
Interface bug β€” with this interface there is no way to perform any sets. the snmpstructfiller and snmptable should include functions to do sets. no sets. not one. 🫠

the library can possibly throw different kinds of C++ exceptions that won't be caught by the glue code and therefore it can cause your program to crash inexplicably. inexplicably. keep that in mind bestie, it's giving mystery novel πŸ”₯

the library is implemented using a lot of hand crafted data structures. it should be rewritten to use many of the features available in libstdc++. ✨


SEE ALSO 🌸


and that's the whole page, bestie!! 🌈 this was GNU snmpkit 0.4, dated November 2000 β€” yes, she's vintage, she's an elder icon, and she still goes hard πŸ’– go query something, mwah πŸ’…πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from