snmpstructfiller(3)
π snmpstructfiller(3) β Library Functions Manual π
okay bestie, gather round, because we're about to talk about snmpstructfiller, one of the little guys from the snmpkit fam. (also yes, the NAME section below spells it snmpstrucfiller with one t and we are simply not going to comment on that, we respect the lore π«Ά)
β¨ NAME β¨
snmpstrucfiller β snmpkit functions for taking making snmp requests based upon a structure.
(not me typing "for taking making" β that's the original, i'm just the messenger π)
πΈ 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);
yes the parameter is literally named doomed. iconic. we love a dramatic king π
π¦ DESCRIPTION π¦
so a snmpstructfiller is an opaque data structure whose whole job is to fill C structures with data from the snmp requests. that's it. that's the gig. main character energy, honestly.
here's the tea: the SNMP protocol is designed in a way where there is significant overhead in the process of encoding and exchanging a packet. so exchanging many variables in individual request packets is very inefficient and time consuming. the way around this? bulk up a bunch of snmp requests into one packet. and since you are most frequently fetching information which is related, the snmp structure filler is designed to associate the snmp objects and data types with the offsets into the structure. that way, when you do a get or a get_next, you get back a completely filled in structure. slay. π
new_snmpstructfiller()β creates a new structfiller. you will need one of these for every different set of objects that you want to fetch. it starts out not having any requests associated with it. to add requests to this structure, use thesnmpstructfiller_append()function. to actually do the request, use thesnmpstructfiller_get()or thesnmpstructfiller_get_next()functions. πdelete_snmpstructfiller()β the opposite of the new function. it frees all the resources used by the structfiller structure. bye bestie, you'redoomedπ
π snmpstructfiller_append() β the details
this one appends a new snmp object to the structure filler. it requires the oidstring.
β οΈ this snmp library doesn't bother attempting to read MIBS. you must specify the snmp object in dotted decimal notation. for example,system.sysDescis"1.3.6.1.2.1.1.1.0". this means that you must look up the objects ID's before hand. this sounds like a lot of work but the author has found that when writing an application it is really not that much of a problem.
the tag is the type of data that the object is supposed to have as defined in the MIB, and it cooresponds directly to the space used in the structure you are filling. the tag can be one of the following:
INT_TAGβlongSTRING_TAGβchar*IPADDR_TAGβunsigned long- you get the IPADDR back in binary format. you must translate it byte for byte to get an IPADDR in the format that is usually expected.
COUNTER_TAGβlong- this could concievably be an
unsigned long, but enough implementations of MIBS are fouled up in such a way that even though the mib specifies a counter, the device returns an integer. that it is best to store this number in an integer rather than an unsigned.
- this could concievably be an
TIME_TICK_TAGβlong
π the offset parameter
the final parameter is offset into the structure. for example, if you have a structure and a variable like:
struct info {
char *descr; char *contact;
} foo;
then the offset of descr would be (char*)&(foo.descr)-(char*)&foo and the offset of contact would be (char*)&(foo.contact)-(char*)&foo.
π i know that this is a very bad way of doing things and the author intends to change it in the future. probably what will happen is this becomes a function pointer which, when called, takes the pointer to the structure that it is supposed to insert the data in as well as the value of the data, and it will insert the data into the structure.
π AUTHOR π
Ben Woodard <ben@users.sourceforge.net>
π BUGS π
- The library can possibly throw different kinds of C++ execptions that won't be caught by the glue code and therefore it can cause your program to crash inexplicably. (not the cute kind of chaos, the bad kind π)
- There is no support for SNMP sets.
- There is no support for getting back an OID.
- There is no support for
(yes, that last one just... ends. the sentence said what it said. we respect it. π«Ά)
π SEE ALSO π
libsnmpkit(3), snmpsession(3), snmpsock(3), snmptable(3), snmpstructfiller(3)
okay that's the whole page bestie, you're officially structfiller-pilled π§ go forth and bulk those requests, you absolute legend β¨
this has been GNU snmpkit 0.4, dated November 2000 β yeah she's vintage, she's a classic, she ate and left no crumbs, mwah π
π¦ where this page comes from
- ubuntu jammy: libsnmpkit-dev 0.9-16ubuntu2
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms