I had to make some changes in the old OpenDiameter 1.0.7g version.
Despite this version is outdated, maybe someone finds the
changes useful. So, I provide them as patch. The description of
the patch is attached (see at bottom right fo this page).
--------------------------------------------------------------------
/**
* The PeerFsmStaticUserEventInterface permits the user of the
* OpenDiameter library to get informed when a Diameter peer connects,
* disconnects or causes some errors. This UserEventInterface
* is static. That is you register one instance and that
* instance will be called for each and every peer.
* The Identity of the peer and its IP port number will be
* provided to the methods of the PeerFsmStaticUserEventInterface
* as arguments.
*
* The original OpenDiameter method \c (AAA_PeerFsmUserEventInterface)
* does exactly the same. Yet, the user must register a
* \c AAA_PeerFsmUserEventInterface with every peer.
*
* There exists exactly one callback hook for one
* \c AAA_PeerFsmStaticUserEventInterface. Thus, the user can only set
* one single PeerFsmStaticUserEventInterface. Moreover, the
* functions of the \c AAA_PeerFsmStaticUserEventInterface are called
* by the \c AAA_PeerStateMachine while there is a lock on the state
* machine. The user must provide an implementation of
* \c AAA_PeerFsmStaticUserEventInterface and set it using
* setPeerFsmStaticUserEventInterface(). An argument value of \c NULL
* removes the registered \c AAA_PeerFsmStaticUserEventInterface object.
*
* It is possible to set the \c AAA_PeerFsmStaticUserEventInterface
* before the DiameterCore is running. The following is a usage
* example for a server (based on libdiameter/test/sample_server2.cxx):
*
* \verbatim
* class MyStaticPeerHandler :
* public AAA_PeerFsmStaticUserEventInterface
* {
* public:
* virtual void PeerConnected( const std::string &peerName, int
port ) {
* std::cout << "**** peer is now connected: " << peerName << "
port = " << port << "\n" << std::endl;
* }
* virtual void PeerDisconnected( const std::string &peerName, int
port, int cause ) {
* std::cout << "**** peer is now disconnected: " << peerName
<< " port = " << port << " cause = " << cause << "\n" << std::endl;
* }
* virtual void PeerError( const std::string &peerName, int port,
PFSM_EV_ERR err ) {
* std::cout << "**** peer has error: " << peerName << " port =
" << port << " err = " << err << "\\n" << std::endl;
* }
* };
*
* int main(int argc, char *argv[])
* {
* AAA_Task task;
* task.Start(5);
*
* AAA_Application appCore( task );
* appCore.setPeerFsmStaticUserEventInterface( new
MyStaticPeerHandler() );
* appCore.Open( "config/isp.local.xml" );
*
* SampleServerAllocator allocator(task, 10000);
* appCore.RegisterServerSessionFactory(allocator);
*
* while (true) {
* std::cout << "Just wait here and let factory take care of new
sessions" << std::endl;
* ACE_OS::sleep(10);
* }
*
* delete appCore.setPeerFsmStaticUserEventInterface( NULL );
* appCore.Close();
* task.Stop();
*
* return EXIT_SUCCESS;
* }
* \endverbatim
*
* \note
*
* If AAA_PeerFsmStaticUserEventInterface::PeerDisconnected()
* is called with an \c AAA_DISCONNECT_TRANSPORT value as cause,
* the TCP/IP link has been disconnected. (I think that is what
* most users want to detect.)
*
* Closing the Diameter application core will unregister this
* callback. Moreover, you should refrain from calling
* \c setPeerFsmStaticUserEventInterface() once you invoked
* <tt>appCore.Close()</tt> (or the Diameter library will crash).
*
* @param[in] newUserEventInterface
* @return A pointer to the old \c AAA_PeerFsmStaticUserEventInterface
* or \c NULL if none was set.
*
* \sa AAA_Peer::RegisterUserEventHandler(AAA_PeerFsmUserEventInterface &)
* \sa AAA_PeerFsmUserEventInterface
* \sa AAA_PeerFsmStaticUserEventInterface
*/
To apply this patch you have to do something like this:
patch -d opendiameter-1.0.7-g/libdiameter -p1 <diameter-static-handler.patch
This is the static UserEventInterface patch for 1.0.7g.