SNMP_structFiller(3)

πŸ“¦ version 0.9, in ubuntu jammy

πŸŽ€ 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 empty SNMP_structFiller object; 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 was NULL; 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 β€” the SNMP_structFiller object 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 (not 0xa2).
  • 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 an unsigned long data 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