blob: d220c3ed4592d2a456d256690b9de16a7e06ddcc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
/* -*-C++-*- */
#ifndef SAGENT_CLS_
#define SAGENT_CLS_
//=============================================================================
/**
* @file sagent.h
*
* $Id$
*
* SNMP agent class defintion. The sagent class provides an object oriented
* approach for creating SNMP Agents. The sagent class is an encapsulation of SNMP
* sessions, gets, sets, etc.
*
* @author Michael R. MacFaden
*/
//=============================================================================
#include "ace/Reactor.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#include "ace/SOCK_Dgram.h"
#include "asnmp/oid.h" // snmp++ oid class
#include "asnmp/vb.h" // snbmp++ vb class
#include "asnmp/target.h" // snmp++ target class
#include "asnmp/pdu.h" // snmp++ pdu class
#include "asnmp/snmperrs.h" // error macros and strings
#include "asnmp/address.h" // snmp++ address class defs
#include "asnmp/snmp.h" // snmp interface
// sagent - supports Version 1 operations in blocking mode
#define DEF_AGENT_PORT (161)
/**
* @class sagent
*
* @brief Concrete class sagent defines the session and interface to
* communicate with another SNMP Version 1 manager
*/
class ASNMP_Export sagent : public ACE_Event_Handler, private Snmp
{
public:
// override the next three methods (callbacks) to implment your agent
//
/// retrieve data from a peer agent for a given list of oid values
virtual int handle_get( Pdu &pdu, UdpTarget &target) = 0;
/// retrieve data lexically adjacent to the oids specified in the pdu
/// from the peer agent
virtual int handle_get_next( Pdu &pdu, UdpTarget &target) = 0;
/// set data in the agent from the list of oids in the pdu
virtual int handle_set( Pdu &pdu, UdpTarget &target) = 0;
/// new pdu received from mgr (reactor calls this)
virtual int handle_input(ACE_HANDLE);
/// retrieve io descriptor (reactor uses this)
virtual ACE_HANDLE get_handle() const;
/// send a response pdu to the mgr
int respond(Pdu& pdu, UdpTarget& tgt);
protected:
sagent(unsigned short port = DEF_AGENT_PORT);
virtual ~sagent();
private:
sagent(const sagent&);
Pdu pdu_; // current input pdu
UdpTarget tgt_; // addr & com strs
};
#endif //SAGENT_CLS_
|