00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #ifndef __PANA_PAA_FACTORY_H__
00035 #define __PANA_PAA_FACTORY_H__
00036
00037 #include "pana_node.h"
00038 #include "pana_session.h"
00039 #include "pana_paa_fsm.h"
00040 #include "pana_message.h"
00041 #include "callback_patterns.h"
00042
00043 typedef PANA_SessionTree<PANA_PaaSession> PANA_PendingSessionDb;
00044
00045 class PANA_EXPORT PANA_PaaSessionFactory : public PANA_PaaSessionChannel
00046 {
00047 public:
00048 PANA_PaaSessionFactory(PANA_Node &n) : PANA_PaaSessionChannel(n) {
00049
00050 AAA_SCSIAdapter1<PANA_PaaSessionFactory,
00051 void(PANA_PaaSessionFactory::*)(PANA_Message&),
00052 PANA_Message&>
00053 msgHandler(*this, &PANA_PaaSessionFactory::Receive);
00054 AAA_SCSIAdapter1<PANA_PaaSessionFactory,
00055 void(PANA_PaaSessionFactory::*)(int),
00056 int>
00057 errHandler(*this, &PANA_PaaSessionFactory::Error);
00058
00059 PANA_PaaSessionChannel::RegisterHandler(msgHandler);
00060 PANA_PaaSessionChannel::RegisterHandler(errHandler);
00061 }
00062 virtual PANA_PaaSessionFactory::~PANA_PaaSessionFactory() {
00063 PANA_PaaSessionChannel::RemoveHandler();
00064 }
00065 virtual PANA_PaaSession *Create() = 0;
00066
00067 protected:
00068 virtual void Receive(PANA_Message &msg);
00069 virtual void Error(int err);
00070
00071 private:
00072 virtual void ReceiveDiscover(PANA_Message &msg);
00073 virtual void SendStartRequest(PANA_Message &msg,
00074 diameter_octetstring_t &cookie);
00075 virtual void ReceiveStartAnswer(PANA_Message &msg);
00076
00077 PANA_PendingSessionDb m_PendingDb;
00078 };
00079
00080 template<class PAA_SESSION, class ARG>
00081 class PANA_PaaSessionFactoryAdapter : public PANA_PaaSessionFactory
00082 {
00083 public:
00084 PANA_PaaSessionFactoryAdapter(ARG &arg) : m_arg(arg) { }
00085 PANA_PaaSession *Create() {
00086 return (new PAA_SESSION(m_Node, m_Udp, m_arg));
00087 }
00088 protected:
00089 ARG &m_arg;
00090 };
00091
00092 #endif
00093