NetBurner 3.5.7
PDF Version
SnmpServlet Class Reference

SNMP agent servlet that listens for and processes SNMP requests. More...

#include <snmp.h>

Inherits servlet.

Public Member Functions

 SnmpServlet (int port=161)
 Construct an SnmpServlet and bind to the specified UDP port.
 

Protected Member Functions

virtual int AddToSelectSet (fd_set &rd_set, fd_set &wr_set, fd_set &er_set)
 Register the SNMP socket with the select read set.
 
virtual void ProcessSelectResult (fd_set &rd_set, fd_set &wr_set, fd_set &er_set)
 Process incoming SNMP requests when the socket is readable.
 

Protected Attributes

int m_fd
 UDP socket file descriptor for SNMP communication.
 
int m_port
 UDP port number the SNMP agent listens on.
 

Detailed Description

SNMP agent servlet that listens for and processes SNMP requests.

SnmpServlet integrates the SNMP agent into the system servlet select loop. It creates a UDP socket bound to the specified port (default 161) and handles incoming SNMP GET, GET-NEXT, and SET requests.

To enable SNMP in your application, create a global instance of this class. The servlet automatically registers itself with the system select loop.


Expand for Example Usage

Examples

Creating an SNMP Agent on the Default Port
#include <snmp.h>
const char *SYSDESC = "My SNMP Device";
const char *SYSOID = "1.3.6.1.4.1.8174.2.40";
// Create SNMP servlet on default port 161
SnmpServlet TheSnmpServer;
SNMP agent servlet that listens for and processes SNMP requests.
Definition snmp.h:196
const char * SYSDESC
Application-defined system description string for MIB-II sysDescr.
Definition snmp/CustomMIB/src/main.cpp:44
const char * SYSOID
Application-defined system object identifier string for MIB-II sysObjectID.
Definition snmp/CustomMIB/src/main.cpp:45
Creating an SNMP Agent on a Custom Port
// Create SNMP servlet on a non-standard port
SnmpServlet TheSnmpServer(10161);

Constructor & Destructor Documentation

◆ SnmpServlet()

SnmpServlet::SnmpServlet ( int port = 161)

Construct an SnmpServlet and bind to the specified UDP port.

Creates a UDP socket and registers the servlet with the system select loop to begin processing SNMP requests.

Parameters
portThe UDP port to listen on (default: 161, the standard SNMP port).

Member Function Documentation

◆ AddToSelectSet()

virtual int SnmpServlet::AddToSelectSet ( fd_set & rd_set,
fd_set & wr_set,
fd_set & er_set )
protectedvirtual

Register the SNMP socket with the select read set.

Parameters
rd_setRead file descriptor set.
wr_setWrite file descriptor set.
er_setError file descriptor set.
Returns
Timeout value in seconds.

◆ ProcessSelectResult()

virtual void SnmpServlet::ProcessSelectResult ( fd_set & rd_set,
fd_set & wr_set,
fd_set & er_set )
protectedvirtual

Process incoming SNMP requests when the socket is readable.

Parameters
rd_setRead file descriptor set.
wr_setWrite file descriptor set.
er_setError file descriptor set.

The documentation for this class was generated from the following file: