summaryrefslogtreecommitdiff
path: root/ASNMP
diff options
context:
space:
mode:
authormrm <mrm@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-09-04 23:47:57 +0000
committermrm <mrm@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-09-04 23:47:57 +0000
commit50e6e4f479db17f8242c76ee32a3294b87390649 (patch)
treee3da7c04a8fc77bd12bf8e01f1f743f38b3f0639 /ASNMP
parent6b79ca4b5485f4eaa3319f6af19ee72e10ab468f (diff)
downloadATCD-50e6e4f479db17f8242c76ee32a3294b87390649.tar.gz
updated for agent work
Diffstat (limited to 'ASNMP')
-rw-r--r--ASNMP/asnmp/transaction.cpp22
-rw-r--r--ASNMP/asnmp/transaction.h26
2 files changed, 31 insertions, 17 deletions
diff --git a/ASNMP/asnmp/transaction.cpp b/ASNMP/asnmp/transaction.cpp
index 9c09836ff82..8e9146efdbc 100644
--- a/ASNMP/asnmp/transaction.cpp
+++ b/ASNMP/asnmp/transaction.cpp
@@ -94,8 +94,15 @@ int transaction::handle_input (ACE_HANDLE fd)
return rc;
}
+
+const ACE_INET_Addr& transaction::get_from_addr() const
+{
+ return receive_addr_;
+}
+
+
// return pdu to caller
-int transaction::result(Pdu& pdu)
+int transaction::result(Pdu& pdu, char *comm_str, ACE_INET_Addr *from) const
{
// TODO: check to see the sender matches the receiver address..
@@ -107,11 +114,16 @@ int transaction::result(Pdu& pdu)
return -1;
wpdu tmp(receive_iovec_);
+
snmp_version ver;
- if (tmp.get_pdu(pdu, ver) == 0)
- return 0;
- else
- return -1;
+
+ // return comm str and from address of incomming pdu if requested
+ int rc = tmp.get_pdu(pdu, ver);
+ if (comm_str)
+ ACE_OS::strcpy(comm_str, (char *)tmp.get_community());
+ if (from)
+ *from = receive_addr_;
+ return rc;
}
int transaction::send()
diff --git a/ASNMP/asnmp/transaction.h b/ASNMP/asnmp/transaction.h
index d94cc6798ea..87c9654be3b 100644
--- a/ASNMP/asnmp/transaction.h
+++ b/ASNMP/asnmp/transaction.h
@@ -34,6 +34,7 @@ class ACE_Export transaction : public ACE_Event_Handler
{
public:
transaction(const Pdu& pdu, const UdpTarget& target, ACE_SOCK_Dgram& io);
+ transaction(ACE_SOCK_Dgram& io):session_(io) { }
// constructor
~transaction();
@@ -42,29 +43,30 @@ class ACE_Export transaction : public ACE_Event_Handler
int run();
// begin polling for values
- int result(Pdu& pdu);
+ int result(Pdu& pdu, char *comm_str = 0, ACE_INET_Addr *from_addr = 0) const;
// return pdu with result from agent after run() is completed rc = 0
+ // optionally get community str
virtual int handle_input (ACE_HANDLE fd);
- // called by reactor when data read on session_
+ // called by reactor when data is ready to be read in from OS memory
int send();
// transmit buffer command to network...
+ const ACE_INET_Addr& get_from_addr() const;
+ // pre: handle_input called
+ // retrieve the sender's from address from the last pkt
+
private:
transaction(const transaction&);
// disallow copy construction
- wpdu wp_;
- UdpTarget params_;
- ACE_INET_Addr addr_;
- ACE_SOCK_Dgram session_;
- // io object
-
- iovec receive_iovec_; // receive buffer
- // incomming msg details
- ACE_Addr receive_addr_;
- // address msg received from
+ wpdu wp_; // wire pdu
+ UdpTarget params_; // params
+ ACE_INET_Addr addr_; // to address
+ ACE_SOCK_Dgram session_; // io object
+ iovec receive_iovec_; // receive buffer
+ ACE_INET_Addr receive_addr_; // from address
};
#endif // TRANSACTION_