4 //=============================================================================
10 * @author Michael R. MacFaden port to ACE / use Reactor pattern
12 //=============================================================================
15 #include "ace/Event_Handler.h"
17 #if !defined (ACE_LACKS_PRAGMA_ONCE)
19 #endif /* ACE_LACKS_PRAGMA_ONCE */
21 #include "asnmp/target.h"
22 #include "asnmp/pdu.h"
23 #include "asnmp/transaction_result.h"
24 #include "asnmp/wpdu.h" // cmu adapter class
25 #include "ace/SOCK_Dgram.h"
30 * @brief Used to manage the details of a particular transaction between
31 * two SNMP agents. Uses SnmpTarget class to implement retry/timeout
33 class ASNMP_Export transaction
: public ACE_Event_Handler
36 transaction_result
* result_
;
41 transaction(const Pdu
& pdu
, const UdpTarget
& target
, ACE_SOCK_Dgram
& io
);
42 transaction(ACE_SOCK_Dgram
& io
);
45 /// begin polling for values
47 int run(transaction_result
*r
); // Async interface, with callback object
49 /// return pdu with result from agent after run() is completed rc = 0
50 /// optionally get community str
51 int result(Pdu
& pdu
, char *comm_str
= 0, ACE_INET_Addr
*from_addr
= 0);
53 /// called by reactor when data is ready to be read in from OS memory
54 /// used for resend in asynchronous run()
55 virtual int handle_input (ACE_HANDLE fd
);
56 virtual int handle_timeout (const ACE_Time_Value
&, const void *);
58 /// transmit buffer command to network...
61 /// pre: handle_input called
62 /// retrieve the sender's from address from the last pkt
63 const ACE_INET_Addr
& get_from_addr() const;
65 /// Return session_ handle.
66 ACE_HANDLE
get_handle () const;
69 /// disallow copy construction
70 transaction(const transaction
&);
73 UdpTarget params_
; // params
74 ACE_INET_Addr addr_
; // to address
75 ACE_SOCK_Dgram session_
; // io object
76 iovec receive_iovec_
; // receive buffer
77 ACE_INET_Addr receive_addr_
; // from address
80 #endif // TRANSACTION_