SNMP_structFiller(3)
π NAME π
SNMP_structFiller β a C++ object to contain data for SNMP queries π
β¨ SYNOPSIS β¨
#include <snmpkit>
SNMP_structFiller::SNMP_structFiller(SNMP_session &sess);
SNMP_structFiller::~SNMP_structFiller();
void SNMP_structFiller::append_int(const string &oidstr,void
(*fp)(void*,long));
void SNMP_structFiller::append_counter(const string &oidstr, void
(*fp)(void*,long));
void SNMP_structFiller::append_timetick(const string &oidstr, void
(*fp)(void*,unsigned long));
void SNMP_structFiller::append_ipaddr(const string &oidstr, void
(*fp)(void*,const unsigned char *));
void SNMP_structFiller::append_string(const string &oidstr, void
(*fp)(void*,const char *));
void SNMP_structFiller::remove(const string &oidstr);
void *SNMP_structFiller::get(void *tobefilled);
void *SNMP_structFiller::get_next(void *tobefilled);
πΈ DESCRIPTION πΈ
okay so bestie, picture this: a SNMP_structFiller object is holding a whole lil list of SNMP objects, and it goes and queries the SNMP_session(3) and then fills in your structure based on whatever info comes back. it's giving personal assistant energy, no cap. π
here's the tea on why this exists. the SNMP protocol is built in a way where encoding and exchanging a packet has significant overhead. so like, exchanging a bunch of variables in individual request packets is super inefficient and time consuming. the way around it? bulk up a bunch of SNMP requests into one packet. and since you're most likely gonna be frequently fetching info that's related anyway, SNMP_structFiller 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, you get back a completely filled in structure. iconic behaviour honestly. β¨
π«Ά SNMP_structFiller::SNMP_structFiller(SNMP_session);
you're gonna need to create a new SNMP_structFiller instance for each different set of SNMP objects you wish to fetch. the SNMP data structure starts out initially empty. you can add request information via the SNMP_structFiller::append() method.
π ~SNMP_structFiller::~SNMP_structFiller();
destructor for an SNMP_structFiller object. say bye bestie π«Ά
π¦ the append methods
void SNMP_structFiller::append_int(const string &oidstr,void
(*fp)(void*,long));
void SNMP_structFiller::append_counter (const string &oidstr, void
(*fp)(void*,long));
void SNMP_structFiller::append_timetick (const string &oidstr, void
(*fp)(void*,unsigned long));
void SNMP_structFiller::append_ipaddr (const string &oidstr, void
(*fp)(void*,const unsigned char *));
void SNMP_structFilleri::append_string(const string &oidstr, void
(*fp)(void*,const char *));
all of the various append methods add an SNMP object to the end of the SNMP_structFiller instance. each method needs two things: the OID of the SNMP object you're adding, and a function that will insert it into the associated structure.
π¨ this library does not attempt to read MIBs. that means you will need to look up the OID string beforehand and hard code the OID string into your program. yes fr, manually. iykyk. π
the job of the function pointer is to insert whatever data it gets back into the data structure. this lets you do any kind of munging around you want with the data you get, which means you can have a much more complicated receiving structure. go off, honestly π
see the example programs included with the SNMPkit documentation (snmptest*.C) for examples of various uses of this.
π Exceptions
BerOidBadSubOidExceptionβ one of the OIDs could not be converted to a number.BerNoOidsExceptionβ no OIDs were specified.
π void SNMP_structFiller::remove(const string &oidstr);
delete an SNMP object from the SNMP_structFiller instance. bye felicia βοΈ
π Exceptions
FillerRemoveEmptyExceptionβ an attempt was made to remove from an emptySNMP_structFillerobject; results from a programming error.FillerRemoveNotFoundExceptionβ an attempt was made to remove an item not currently in the container; results from a programming error.FillerCorruptExceptionβ the SNMP table entry was successfully removed, however the OID sequence wasNULL; results from a programming error in the library.OidSeqRemoveNotFoundExceptionβ a programming error resulted in the attempt to remove something that was not there.OidSeqBadLayoutExceptionβ the BER sequence did not follow the layout of an OID sequence.
π₯ void *SNMP_structFiller::get(void *tobefilled);
send the SNMP get request to the SNMP Agent and fill the structure tobefilled with the data returned, using the previously defined inserter functions. main character energy fr fr π
π Exceptions
SNMPNoResponseExceptionβ theSNMP_structFillerobject did not receive a response from the remote SNMP Agent. this can be caused by many things: no agent running on destination, a firewall between you and the destination.SNMPPacketNotSequenceExceptionβ the response received was not a valid SNMP response.SNMPRespNotSequenceExceptionβ the packet received was a valid SNMP response but the payload of the packet wasn't a sequence type.SNMPNotResponseTagExceptionβ the type of the SNMP response received was invalid (not0xa2).SNMPSeqnoNotIntExceptionβ the sequence number of the response was not a classified as a number.SNMPStateNotIntExceptionβ the SNMP device sent back an improperly constructed response packet and the status was not classified as an integer.SNMPFaultOidNotIntExceptionβ a response was returned with an error but the index to the problem OID was not classified as an integer.OidSeqBadLayoutExceptionβ within a SNMP packet there is a substructure which is an OID sequence. if the packet was supposed to have an OID sequence in a particular locaion but for some reason one of the elements was not of the correct type, then this exception will be thrown.SNMPBadOidExceptionβ an OID in the SNMP response packet was invalid.SocketSendShortExecptionβ an error occurred while sending the SNMP request resulting in an incomplete transmission of the query.BerSequenceTagException,BerIntTagException,BerCounterTagException,BerStringTagException,BerNullTagException,BerOidTagException,BerTimeTickTagExceptionβ although this will result from a encoding error, it is caused by calling a BER object constructor on an invalid piece of data.BerLengthException,BerIntLengthExecption,BerCounterLengthExecption,BerNullLengthExecption,BerTimeTickLengthExecption,BerIPAddrLengthExecptionβ the size of the data to be encoded (BER) will not fit into anunsigned longdata type.
π§ void *SNMP_structFiller::get_next(void *tobefilled);
query the object which is next in the list of available objects from the SNMP Agent. β¨
π Exceptions
same as the SNMP_structFiller::get() method. periodt. π
π SEE ALSO π
SNMP_structFiller(3), SNMP_table(3)
π AUTHOR π
the SNMPkit C/C++ library was originally developed by Ben Woodard <ben@users.sourceforge.net>. this man page was written by Gerald Carter <gcarter@valinux.com>.
and that's the whole vibe check bestie β this page is from GNU snmpkit 0.4, dated November 2000. slay, go fill some structures ππ¦β¨
π¦ 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