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 __DIAMETER_API_H__
00035 #define __DIAMETER_API_H__
00036
00037 #include <diameter_parser_api.h>
00038
00042 #if defined (WIN32)
00043 # if defined (DIAMETERBASEPROTOCOL_EXPORTS)
00044 # define DIAMETERBASEPROTOCOL_EXPORT ACE_Proper_Export_Flag
00045 # define DIAMETERBASEPROTOCOL_EXPORT_ONLY ACE_Proper_Export_Flag
00046 # define DIAMETERBASEPROTOCOL_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T)
00047 # define DIAMETERBASEPROTOCOL_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
00048 # else
00049 # define DIAMETERBASEPROTOCOL_EXPORT ACE_Proper_Import_Flag
00050 # define DIAMETERBASEPROTOCOL_EXPORT_ONLY
00051 # define DIAMETERBASEPROTOCOL_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T)
00052 # define DIAMETERBASEPROTOCOL_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
00053 # endif
00054 #else
00055 # define DIAMETERBASEPROTOCOL_EXPORT
00056 # define DIAMETERBASEPROTOCOL_EXPORT_ONLY
00057 # define DIAMETERBASEPROTOCOL_SINGLETON_DECLARATION(T)
00058 # define DIAMETERBASEPROTOCOL_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
00059 #endif
00060
00061
00062 class AAAServerSessionFactory;
00063
00069 class AAAApplicationHandle : public AAA_JobData { };
00070
00075 typedef void* AAASessionPayload;
00076
00097 class DIAMETERBASEPROTOCOL_EXPORT AAAApplicationCore {
00098 public:
00102 AAAApplicationCore() { }
00103
00109 AAAApplicationCore(char *configFileName,
00110 AAA_Task *task = 0) {
00111 Open(configFileName, task);
00112 }
00113
00117 ~AAAApplicationCore() {
00118 Close();
00119 }
00120
00127 AAAReturnCode Open(char *configFileName = NULL,
00128 AAA_Task *task = 0);
00129
00135 AAAReturnCode Close();
00136
00153 AAAReturnCode RegisterServerSessionFactory
00154 (AAAServerSessionFactory *factory);
00155
00162 AAAReturnCode RemoveServerSessionFactory
00163 (AAAServerSessionFactory *factory);
00164
00168 AAAApplicationHandle &GetAppHandle() {
00169 return *handle;
00170 }
00171
00175 diameter_unsigned32_t GetNumActivePeerConnections();
00176
00180 AAA_Task& GetTask();
00181
00182
00183 private:
00192 boost::shared_ptr<AAAApplicationHandle> handle;
00193 };
00194
00206 class DIAMETERBASEPROTOCOL_EXPORT AAAEventHandler {
00207 public:
00214 AAAEventHandler(AAAApplicationCore &c) : core(c) {
00215 }
00216
00220 virtual ~AAAEventHandler() { }
00221
00235 virtual AAAReturnCode HandleMessage(AAAMessage &msg) {
00236 return (AAA_ERR_SUCCESS);
00237 }
00238
00252 virtual AAAReturnCode HandleDisconnect() {
00253 return (AAA_ERR_SUCCESS);
00254 }
00255
00261 virtual AAAReturnCode HandleTimeout() {
00262 return (AAA_ERR_SUCCESS);
00263 }
00264
00275 virtual AAAReturnCode HandleSessionTimeout() {
00276 return (AAA_ERR_SUCCESS);
00277 }
00278
00289 virtual AAAReturnCode HandleAuthLifetimeTimeout() {
00290 return (AAA_ERR_SUCCESS);
00291 }
00292
00303 virtual AAAReturnCode HandleAuthGracePeriodTimeout() {
00304 return (AAA_ERR_SUCCESS);
00305 }
00306
00318 virtual AAAReturnCode HandleAbort() {
00319 return (AAA_ERR_SUCCESS);
00320 }
00321
00325 const AAAApplicationCore &GetApplicationCore() {
00326 return core;
00327 }
00328
00329 protected:
00330 AAAApplicationCore &core;
00331 };
00332
00333
00334 class AAASessionMessageHandler;
00335
00401 class DIAMETERBASEPROTOCOL_EXPORT AAASession : public AAAEventHandler {
00402 public:
00406 typedef enum {
00407 EVENT_AUTH_REQUEST = 0,
00408 EVENT_AUTH_SUCCESS,
00409 EVENT_AUTH_CONTINUE,
00410 EVENT_AUTH_FAILED,
00411 EVENT_ACCT_SUCCESS,
00412 EVENT_NO_SERVICE,
00413 EVENT_PROC_ERROR
00414 } EVENT;
00415
00416 public:
00423 AAASession(AAAApplicationCore &appCore,
00424 diameter_unsigned32_t appId);
00425
00429 virtual ~AAASession();
00430
00436 virtual AAAReturnCode SetTimeout(time_t timeout);
00437
00447 virtual AAAReturnCode RegisterMessageHandler(AAASessionMessageHandler *handler);
00448
00454 virtual AAAReturnCode RemoveMessageHandler(AAASessionMessageHandler *handler);
00455
00462 virtual AAAReturnCode Update(AAASession::EVENT event) = 0;
00463
00468 const AAASessionHandle GetSessionHandle();
00469
00474 diameter_unsigned32_t GetApplicationId() { return id; }
00475
00480 void GetSessionId(diameter_octetstring_t &id);
00481
00482 protected:
00489 AAASessionHandle handle;
00490
00491 diameter_unsigned32_t id;
00492 };
00493
00504 class DIAMETERBASEPROTOCOL_EXPORT AAASessionMessageHandler : public AAAEventHandler {
00505 public:
00515 AAASessionMessageHandler(AAAApplicationCore &appCore,
00516 AAACommandCode cmdCode);
00517
00521 AAACommandCode GetCommandCode() { return code; }
00522
00523 private:
00524 AAACommandCode code;
00525 };
00526
00531 class DIAMETERBASEPROTOCOL_EXPORT AAAClientSession : public AAASession {
00532 public:
00539 AAAClientSession(AAAApplicationCore &appCore,
00540 diameter_unsigned32_t id);
00541
00545 virtual ~AAAClientSession();
00546
00551 AAAReturnCode Start();
00552
00557 AAAReturnCode SetOptionalSIDValue(std::string optVal);
00558
00565 AAAReturnCode Update(AAASession::EVENT event);
00566
00570 AAAReturnCode End();
00571 };
00572
00584 class DIAMETERBASEPROTOCOL_EXPORT AAAServerSession : public AAASession {
00585 public:
00592 AAAServerSession(AAAApplicationCore &appCore,
00593 diameter_unsigned32_t id);
00594
00598 virtual ~AAAServerSession();
00599
00606 AAAReturnCode Update(AAASession::EVENT event);
00607
00612 AAAReturnCode Abort();
00613 };
00614
00642 class DIAMETERBASEPROTOCOL_EXPORT AAAServerSessionFactory {
00643 public:
00650 AAAServerSessionFactory(diameter_unsigned32_t appId,
00651 AAASessionType type = AAA_STYPE_AUTHENTICATION);
00652
00659 virtual ~AAAServerSessionFactory();
00660
00664 diameter_unsigned32_t GetApplicationId() { return id; }
00665
00669 AAASessionType GetType() { return type; }
00670
00679 virtual AAASession *CreateInstance(AAAApplicationCore &core,
00680 diameter_unsigned32_t id) = 0;
00681
00682 private:
00683 diameter_unsigned32_t id;
00685 AAASessionType type;
00686 };
00687
00696 template<class SESSION_SERVER>
00697 class AAAServerSessionClassFactory : public AAAServerSessionFactory
00698 {
00699 public:
00708 AAAServerSessionClassFactory(diameter_unsigned32_t id,
00709 AAASessionType type = AAA_STYPE_AUTHENTICATION) :
00710 AAAServerSessionFactory(id, type) { };
00711
00720 AAASession *CreateInstance(AAAApplicationCore &core, diameter_unsigned32_t id) {
00721 return new SESSION_SERVER(core, id);
00722 }
00723 };
00724
00739 class DIAMETERBASEPROTOCOL_EXPORT AAAMessageControl {
00740 public:
00746 AAAMessageControl(AAASession *session);
00747
00751 ~AAAMessageControl();
00752
00762 AAAReturnCode SetResultCode(AAAMessage &response,
00763 AAAMessage &request,
00764 AAAResultCode resultCode);
00765
00774 AAAReturnCode Send(AAAMessage &msg);
00775
00776 protected:
00777 AAASession &session;
00778 };
00779
00868 class DIAMETERBASEPROTOCOL_EXPORT AAAAccountingSession : public AAASession
00869 {
00870 public:
00877 AAAAccountingSession(AAAApplicationCore &appCore,
00878 diameter_unsigned32_t id);
00879
00883 virtual ~AAAAccountingSession();
00884
00891 AAAReturnCode Send(AAAMessage &reqMsg);
00892
00898 AAAReturnCode Update(AAASession::EVENT event);
00899 };
00900
00907 class DIAMETERBASEPROTOCOL_EXPORT AAAAccountingClientSession : public AAAAccountingSession
00908 {
00909 public:
00913 typedef enum {
00914 RECTYPE_EVENT = 1,
00915 RECTYPE_START = 2,
00916 RECTYPE_INTERIM = 3,
00917 RECTYPE_STOP = 4
00918 } RECTYPE;
00919
00920 public:
00927 AAAAccountingClientSession(AAAApplicationCore &appCore,
00928 diameter_unsigned32_t id);
00929
00933 virtual ~AAAAccountingClientSession();
00934
00949 AAAReturnCode SetInterimRecordInterval(RECTYPE type,
00950 int interval = 0,
00951 AAASessionPayload payload = NULL);
00952
00962 virtual AAAReturnCode HandleInterimRecordEvent(RECTYPE type,
00963 AAASessionPayload payload);
00964 };
00965
00979 class DIAMETERBASEPROTOCOL_EXPORT AAAAccountingRecTransformer
00980 {
00981 public:
00985 AAAAccountingRecTransformer();
00986
00990 virtual ~AAAAccountingRecTransformer();
00991
00999 virtual AAAReturnCode Convert(AAAMessage *msg) = 0;
01000
01010 virtual AAAReturnCode OutputRecord(AAAMessage *originalMsg) = 0;
01011 };
01012
01048 class DIAMETERBASEPROTOCOL_EXPORT AAAAccountingXMLRecTransformer : public AAAAccountingRecTransformer
01049 {
01050 public:
01054 AAAAccountingXMLRecTransformer();
01055
01059 ~AAAAccountingXMLRecTransformer();
01060
01066 virtual AAAReturnCode Convert(AAAMessage *msg);
01067
01082 virtual AAAReturnCode OutputRecord(AAAMessage *originalMsg);
01083
01084 protected:
01085 AAASessionPayload record;
01087 ACE_UINT32 record_size;
01088 };
01089
01090 #if defined(AAA_ODBC_XFORMER)
01091
01092 class DIAMETERBASEPROTOCOL_EXPORT AAAAccountingODBCRecTransformer : public AAAAccountingXMLRecTransformer
01093 {
01094 public:
01098 AAAAccountingODBCRecTransformer();
01099
01103 ~AAAAccountingODBCRecTransformer();
01104
01117 virtual AAAReturnCode OutputRecord(AAAMessage *originalMsg);
01118 };
01119
01120 #endif
01121
01128 class DIAMETERBASEPROTOCOL_EXPORT AAAAccountingServerSession : public AAAAccountingSession
01129 {
01130 public:
01137 AAAAccountingServerSession(AAAApplicationCore &appCore,
01138 diameter_unsigned32_t id);
01139
01143 virtual ~AAAAccountingServerSession();
01144
01150 void SetTransformer(AAAAccountingRecTransformer *trns) { transformer = trns; }
01151
01155 AAAAccountingRecTransformer *GetTransformer() { return transformer; }
01156
01157 protected:
01158 AAAAccountingRecTransformer *transformer;
01159 };
01160
01161
01174 class DIAMETERBASEPROTOCOL_EXPORT AAAProxyServices
01175 {
01176 public:
01182 AAAProxyServices(AAAApplicationCore &appCore) :
01183 core(appCore) {
01184 }
01185
01189 virtual ~AAAProxyServices() { }
01190
01198 AAAReturnCode RegisterMessageHandler(diameter_unsigned32_t appId,
01199 AAAEventHandler *handler);
01200
01206 AAAReturnCode RemoveMessageHandler(diameter_unsigned32_t appId);
01207
01208 protected:
01209 AAAApplicationCore &core;
01210 };
01211
01212 #endif // __DIAMETER_API_H__
01213
01214
01215