#include <uxsnmp.h>
Inheritance diagram for Snmp:
The Snmp class provides an object oriented approach to SNMP. The SNMP class is an encapsulation of SNMP sessions, gets, sets and get nexts. The class manages all SNMP resources and provides complete retry and timeout capability.
This class is thread save.
Call srand() before creating the first Snmp object.
Definition at line 106 of file uxsnmp.h.
Public Member Functions | |
| virtual int | cancel (const unsigned long rid) |
| Cancel a pending request. | |
| virtual int | send_raw_data (unsigned char *send_buf, size_t send_len, UdpAddress &address, int fd=0) |
| Send raw UDP data. | |
| const IpAddress & | get_listen_address () const |
Constructors and Destructor | |
| Snmp (int &status, const unsigned short port=0, const bool bind_ipv6=false) | |
| Construct a new SNMP session using the given UDP port. | |
| Snmp (int &status, const UdpAddress &addr) | |
| Construct a new SNMP session using the given UDP address. | |
| Snmp (int &status, const UdpAddress &addr_v4, const UdpAddress &addr_v6) | |
| Construct a new SNMP session using the given UDP addresses. | |
| virtual | ~Snmp () |
| Destructor. | |
Sending SNMP Pdus | |
| virtual int | get (Pdu &pdu, const SnmpTarget &target) |
| Send a blocking SNMP-GET request. | |
| virtual int | get (Pdu &pdu, const SnmpTarget &target, const snmp_callback callback, const void *callback_data=0) |
| Send a async SNMP-GET request. | |
| virtual int | get_next (Pdu &pdu, const SnmpTarget &target) |
| Send a blocking SNMP-GETNEXT request. | |
| virtual int | get_next (Pdu &pdu, const SnmpTarget &target, const snmp_callback callback, const void *callback_data=0) |
| Send a async SNMP-GETNEXT request. | |
| virtual int | set (Pdu &pdu, const SnmpTarget &target) |
| Send a blocking SNMP-SET request. | |
| virtual int | set (Pdu &pdu, const SnmpTarget &target, const snmp_callback callback, const void *callback_data=0) |
| Send a async SNMP-SET request. | |
| virtual int | get_bulk (Pdu &pdu, const SnmpTarget &target, const int non_repeaters, const int max_reps) |
| Send a blocking SNMP-GETBULK request. | |
| virtual int | get_bulk (Pdu &pdu, const SnmpTarget &target, const int non_repeaters, const int max_reps, const snmp_callback callback, const void *callback_data=0) |
| Send a async SNMP-GETBULK request. | |
| virtual int | trap (Pdu &pdu, const SnmpTarget &target) |
| Send a SNMP-TRAP. | |
| virtual int | report (Pdu &pdu, const SnmpTarget &target) |
| Send a SNMPv3-REPORT. | |
| virtual int | inform (Pdu &pdu, const SnmpTarget &target) |
| Send a blocking INFORM-REQ. | |
| virtual int | inform (Pdu &pdu, const SnmpTarget &target, const snmp_callback callback, const void *callback_data=0) |
| Send a async INFORM-REQ. | |
| virtual int | response (Pdu &pdu, const SnmpTarget &target) |
| Send a RESPONSE. | |
| virtual int | broadcast_discovery (UdpAddressCollection &addresses, const int timeout_sec, const UdpAddress &addr, const snmp_version version, const OctetStr *community=0) |
| Send a SNMP Broadcast message. | |
Trap and Inform handling | |
| virtual int | notify_register (const OidCollection &trapids, const TargetCollection &targets, const snmp_callback callback, const void *callback_data=0) |
| Register to get traps and informs. | |
| virtual int | notify_register (const OidCollection &trapids, const TargetCollection &targets, const AddressCollection &listen_addresses, const snmp_callback callback, const void *callback_data=0) |
| Register to get traps and informs. | |
| virtual int | notify_unregister () |
| Unregister to get traps and informs. | |
| virtual int | get_notify_filter (OidCollection &trapids, TargetCollection &targets) |
| Get notify register info. | |
| virtual int | get_notify_filter (OidCollection &trapids, TargetCollection &targets, AddressCollection &listen_addresses) |
| Get notify register info. | |
| snmp_callback | get_notify_callback () |
| Get a pointer to the callback function used for trap reception. | |
| void * | get_notify_callback_data () |
| Get a pointer to the data that is passed to the callback function. | |
Static Public Member Functions | |
| const char * | get_version () |
| Get the version of the snmp++ library. | |
| const char * | error_msg (const int c) |
| Returns a human readable error string. | |
| const char * | error_msg (const Oid &v3Oid) |
| Returns a human readable error string. | |
| void | socket_startup () |
| Initialize the Winsock library (WSAStartup). | |
| void | socket_cleanup () |
| Shut down the Winsock library (WSACleanup). | |
Public Attributes | |
| EventListHolder * | eventListHolder |
Static Public Attributes | |
| SnmpSynchronized | v3Lock |
Protected Member Functions | |
| long | MyMakeReqId () |
| Generate a unique (for this Snmp obect) request id. | |
| int | snmp_engine (Pdu &pdu, long int non_reps, long int max_reps, const SnmpTarget &target, const snmp_callback cb, const void *cbd) |
| gets, sets and get nexts go through here.... | |
| void | map_action (unsigned short action, unsigned short &pdu_action) |
| void | init (int &status, IpAddress *[2], const unsigned short port_v4, const unsigned short port_v6) |
| void | check_notify_timestamp (Pdu &pdu) |
| Set the notify timestamp of a trap pdu if the user did not set it. | |
Protected Attributes | |
| SNMPHANDLE | iv_snmp_session |
| SNMPHANDLE | iv_snmp_session_ipv6 |
| IpAddress | listen_address |
| int | iv_notify_fd |
| SNMPHANDLE | pdu_handler |
| SNMPHANDLE | pdu_handler_ipv6 |
| int | construct_status |
| int | construct_status_ipv6 |
| long | current_rid |
| snmp_callback | notifycallback |
| void * | notifycallback_data |
Friends | |
| void | v3CallBack (int reason, Snmp *snmp, Pdu &pdu, SnmpTarget &target, void *v3cd) |
|
||||||||||||||||
|
Construct a new SNMP session using the given UDP port.
|
|
||||||||||||
|
Construct a new SNMP session using the given UDP address. Thus, binds the session on a specific IPv4 or IPv6 address.
|
|
||||||||||||||||
|
Construct a new SNMP session using the given UDP addresses. Using this constructor will bind to both IPv4 and IPv6 ports.
|
|
|
Destructor.
|
|
||||||||||||||||||||||||
|
Send a SNMP Broadcast message. This member function sends out a valid SNMP message to a broadcast address and waits for responses. The source addresses of the response messages are added to the collection. The message is sent only once.
|
|
|
Cancel a pending request.
|
|
|
Set the notify timestamp of a trap pdu if the user did not set it.
|
|
|
Returns a human readable error string. If a report message is returned, then the contained Oid can be used to get a error string.
|
|
|
Returns a human readable error string.
|
|
||||||||||||||||||||
|
Send a async SNMP-GET request.
|
|
||||||||||||
|
Send a blocking SNMP-GET request.
|
|
||||||||||||||||||||||||||||
|
Send a async SNMP-GETBULK request.
|
|
||||||||||||||||||||
|
Send a blocking SNMP-GETBULK request.
|
|
|
|
|
||||||||||||||||||||
|
Send a async SNMP-GETNEXT request.
|
|
||||||||||||
|
Send a blocking SNMP-GETNEXT request.
|
|
|
Get a pointer to the callback function used for trap reception.
Definition at line 499 of file uxsnmp.h. References snmp_callback. |
|
|
Get a pointer to the data that is passed to the callback function.
|
|
||||||||||||||||
|
Get notify register info.
|
|
||||||||||||
|
Get notify register info.
|
|
|
Get the version of the snmp++ library.
|
|
||||||||||||||||||||
|
Send a async INFORM-REQ.
|
|
||||||||||||
|
Send a blocking INFORM-REQ.
|
|
||||||||||||||||||||
|
|
|
||||||||||||
|
|
|
|
Generate a unique (for this Snmp obect) request id.
|
|
||||||||||||||||||||||||
|
Register to get traps and informs.
|
|
||||||||||||||||||||
|
Register to get traps and informs.
|
|
|
Unregister to get traps and informs. Undo the call to notify_register().
|
|
||||||||||||
|
Send a SNMPv3-REPORT.
|
|
||||||||||||
|
Send a RESPONSE.
|
|
||||||||||||||||||||
|
Send raw UDP data. This method may be used to send any data to the recepient.
|
|
||||||||||||||||||||
|
Send a async SNMP-SET request.
|
|
||||||||||||
|
Send a blocking SNMP-SET request.
|
|
||||||||||||||||||||||||||||
|
gets, sets and get nexts go through here.... This mf does all snmp sending and reception except for traps which are sent using trap().
|
|
|
Shut down the Winsock library (WSACleanup).
|
|
|
Initialize the Winsock library (WSAStartup).
|
|
||||||||||||
|
Send a SNMP-TRAP.
|
|
||||||||||||||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1.3.2