---
name: "SNMP_table"
section: "3"
platform: "linux"
package: "libsnmpkit-dev"
version: "0.9-16"
release: "Debian 8 (Jessie)"
platforms: ["linux"]
url: "https://new.carta.tech/SNMP_table"
---

# SNMP\_table(3)

C++ object for requesting and storing a table of SNMP settings

## NAME

SNMP\_table - C++ object for requesting and storing a table of SNMP settings

## SYNOPSIS

**#include \<snmpkit\>**

**SNMP\_table(SNMP\_session &session, unsigned int slen);**

**void get(list\<void\*\> &dest);**

**unsigned int stlen();**

## DESCRIPTION

A **SNMP\_table** is a derivation of the **[SNMP\_structFiller(3)](/SNMP_structFiller/3.md)** class whose purpose is to automate fetching all the rows within a SNMP table. It does this by doing multiple get\_next requests of a group of objects until it falls off the end of the table.

### SNMP\_table::SNMP\_table(SNMP\_session &session, void \*(new\_funct)());

Create a new SNMP\_table object.  The **session** parameter  defines the SNMP enabled device to query and the **new\_funct** is a function that allocate and initializes the underlying data structure returns a void\* to it.

### 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 underlying SNMP\_structFiller instance.  Each method requires the OID of the SNMP object to add and a function that will insert it into the associated structure.

**This library does not attempt to read MIBs. This means that youwill need to look up the OID string before hand and hard code the OIDstring into your program.**

The job of the function pointer is to insert whatever data it gets back  into the the data structure. This allows you to do any kind of munging  around you want with the data you get and therefore you can have much  more complicated receiving structure.  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 underlying SNMP\_structFiller instance.

**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\_table::get(list\<void\*\> &dest);

Method to read multiple rows of information from an SNMP device and insert them into the destination list.

**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.

## SEE ALSO

[SNMP\_structFiller(3)](/SNMP_structFiller/3.md), [SNMP\_table(3)](/SNMP_table/3.md)

## AUTHOR

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\>
