snmpstructfiller(3)
π snmpstructfiller(3) π
okay so this is the snmpstructfiller(3) page, straight out of the Library Functions Manual, and it's all about the snmpkit functions that make snmp requests based on a structure. grab a strawberry π and let's go.
β¨ NAME β¨
snmpstrucfiller β snmpkit functions for taking making snmp requests based upon a structure.
(yes bestie, that's the exact name on the page, and yes we are keeping it exactly as it is π )
πΈ 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);
π¦ DESCRIPTION π¦
A snmpstructfiller is an opaque data structure whose whole job is filling C structures with data from snmp requests. that's the assignment. that's the vibe.
so here's the thing about SNMP β the protocol is built in a way where encoding and exchanging a packet has significant overhead. which means sending a million separate little request packets for a million separate variables is genuinely inefficient and time consuming. the way around it? bulk up a bunch of snmp requests into one single packet. β¨ and since you're most frequently fetching info that's related, the snmp structure filler is designed to associate the snmp objects and data types with the offsets into the structure. so when you do a get or a get_next, boom β you get back a completely filled in structure. iconic.
The new_snmpstructfiller() function creates a new structfiller. you need one of these for every different set of objects you want to fetch, no sharing, no cap. it starts out not having any requests associated with it. to add requests to this structure, use the snmpstructfiller_append() function. and to actually do the request, use snmpstructfiller_get() or snmpstructfiller_get_next(). π
The delete_snmpstructfiller() function is the opposite of the new function β it frees all the resources used by the structfiller structure. clean up after yourself bestie, the doomed pointer is literally named that for a reason π.
The snmpstructfiller_append() function appends a new snmp object to the structure filler. it requires the oidstring. heads up: this snmp library doesn't bother attempting to read MIBS. you must specify the snmp object in dotted decimal notation. for example, system.sysDesc is "1.3.6.1.2.1.1.1.0". which means you have to look up the object ID's beforehand. sounds like a lot of work? the author says he's found that when writing an application it's really not that much of a problem. π«Ά
The tag is the type of data the object is supposed to have, as defined in the MIB, and it cooresponds directly to the space used in the structure you're filling. the tag can be one of these:
INT_TAGβ lands in alongSTRING_TAGβ lands in achar*IPADDR_TAGβ lands in anunsigned long. you get the IPADDR back in binary format, so you must translate it byte for byte to get an IPADDR in the format that's usually expected.COUNTER_TAGβ lands in along. this could concievably be anunsigned long, but enough implementations of MIBS are fouled up in such 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. (yes, we're keeping the double period, it's part of the lore β¨)TIME_TICK_TAGβ lands in along
The final parameter is the 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
and look β the author straight up says I know that this is a very bad way of doing things and that he intends to change it in the future. probably what he'll do is change this to a function pointer which, when called, takes the pointer to the structure it's supposed to insert the data in as well as the value of the data, and it'll insert the data into the structure. so like, noted, it's giving "works but we know" π.
π AUTHOR π
Ben Woodard <ben@users.sourceforge.net>
π BUGS π
- 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. not the cute kind of mystery bestie, watch out. π
- There is no support for SNMP sets.
- There is no support for getting back an OID.
- There is no support for
okay the last one literally just trails off mid-sentence in the original. we are not finishing that sentence for it, we are respecting the author's cliffhanger π§
π SEE ALSO π
libsnmpkit(3)snmpsession(3)snmpsock(3)snmptable(3)
GNU snmpkit 0.4 πΈ November 2000 πΈ and that's the snmpstructfiller(3) footer energy right there. periodt. π
β¨
π¦ 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