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
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef __NASREQ_CLIENT_FSM_H__
00043 #define __NASREQ_CLIENT_FSM_H__
00044
00045 #include "framework.h"
00046 #include "diameter_nasreq_parser.hxx"
00047 #include "diameter_nasreq_authinfo.hxx"
00048
00052 #ifdef WIN32
00053 #if defined(DIAMETER_NASREQ_CLIENT_EXPORT)
00054 #define DIAMETER_NASREQ_CLIENT_EXPORTS __declspec(dllexport)
00055 #else
00056 #define DIAMETER_NASREQ_CLIENT_EXPORTS __declspec(dllimport)
00057 #endif
00058 #else
00059 #define DIAMETER_NASREQ_CLIENT_EXPORTS
00060 #define DIAMETER_NASREQ_CLIENT_EXPORTS
00061 #endif
00062
00063 typedef AAA_JobHandle<AAA_GroupedJob> DiameterJobHandle;
00064
00065 class DiameterNasreqClientSession;
00066
00072 class DIAMETER_NASREQ_CLIENT_EXPORTS DiameterNasreqClientStateMachine
00073 : public AAA_StateMachine<DiameterNasreqClientStateMachine>,
00074 public AAA_EventQueueJob
00075 {
00076 friend class DiameterJobMultiplexor;
00077
00078 public:
00080 DiameterNasreqClientStateMachine(DiameterNasreqClientSession& s,
00081 DiameterJobHandle &h);
00082
00083 ~DiameterNasreqClientStateMachine()
00084 {
00085 handle.Job().Remove(this);
00086 }
00087
00088 enum {
00089
00090 EvSgStart=-1,
00091 EvRxAuthInfo=-2,
00092 EvRxAA_Answer=-3,
00093 EvSgSessionTimeout=-4,
00094 EvSgAuthLifetimeTimeout=-5,
00095 EvSgAuthGracePeriodTimeout=-6,
00096 EvSgTimeout=-7,
00097 EvSgDisconnect=-8
00098 };
00099
00101 inline void Notify(AAA_Event ev) {
00102
00103 if (AAA_EventQueueJob::Enqueue(ev) <= 0)
00104 Abort();
00105
00106 if (handle.Job().Schedule(this) < 0)
00107 Abort();
00108 }
00109
00110 inline DiameterNasreqClientSession& Session() { return session; }
00111
00114 virtual void Abort()=0;
00115
00117 void SendAA_Request();
00118
00121 virtual void SignalContinue(DiameterNasreqAuthenticationInfo &authInfo)=0;
00122
00125 virtual void SignalSuccess()=0;
00126
00129 virtual void SignalFailure()=0;
00130
00133 void ForwardAuthenticationInfo
00134 (DiameterNasreqAuthenticationInfo &authenticationInfo);
00135
00139 virtual void SignalReauthentication()=0;
00140
00144 virtual void SignalDisconnect()=0;
00145
00146 inline AAA_JobData& JobData() { return *handle.Job().Data(); }
00147
00148 template <class T> inline T& JobData(Type2Type<T>)
00149 { return (T&)*handle.Job().Data(); }
00150
00151
00152
00155 virtual void SetDestinationRealm
00156 (AAA_ScholarAttribute<diameter_utf8string_t> &destinationRealm)
00157 {
00158 }
00159
00162 virtual void SetDestinationHost
00163 (AAA_ScholarAttribute<diameter_utf8string_t> &destinationHost)
00164 {
00165 }
00166
00170 virtual void SetAuthRequestType
00171 (AAA_ScholarAttribute<diameter_enumerated_t> &authRequestType)
00172 {
00173 authRequestType = AUTH_REQUEST_TYPE_AUTHORIZE_AUTHENTICATE;
00174 }
00175
00177 virtual void SetNasIdentifier
00178 (AAA_ScholarAttribute<diameter_utf8string_t> &nasIdentifier)
00179 {
00180 }
00181
00183 virtual void SetNasIpAddress
00184 (AAA_ScholarAttribute<diameter_octetstring_t> &nasIpAddress)
00185 {
00186 }
00187
00189 virtual void SetNasIpv6Address
00190 (AAA_ScholarAttribute<diameter_octetstring_t> &nasIpv6Address)
00191 {
00192 }
00193
00195 virtual void SetNasPort
00196 (AAA_ScholarAttribute<diameter_unsigned32_t> &nasPort)
00197 {
00198 }
00199
00201 virtual void SetNasPortType
00202 (AAA_ScholarAttribute<diameter_enumerated_t> &nasPortType)
00203 {
00204 }
00205
00207 virtual void SetNasPortId
00208 (AAA_ScholarAttribute<diameter_utf8string_t> &nasPortId)
00209 {
00210 }
00211
00213 virtual void SetOriginStateId
00214 (AAA_ScholarAttribute<diameter_unsigned32_t> &originStateId)
00215 {
00216 }
00217
00219 virtual void SetPortLimit
00220 (AAA_ScholarAttribute<diameter_unsigned32_t> &portLimit)
00221 {
00222 }
00223
00225 virtual void
00226 SetServiceType(AAA_ScholarAttribute<diameter_enumerated_t> &serviceType)
00227 {
00228 }
00229
00231 virtual void
00232 SetState(AAA_ScholarAttribute<diameter_octetstring_t> &state)
00233 {
00234 }
00235
00238 virtual void
00239 SetAuthorizationLifetime
00240 (AAA_ScholarAttribute<diameter_unsigned32_t> &authorizationLifetime)
00241 {
00242 }
00243
00246 virtual void
00247 SetAuthGracePeriod
00248 (AAA_ScholarAttribute<diameter_unsigned32_t> &authGracePeriod)
00249 {
00250 }
00251
00254 virtual void
00255 SetAuthSessionState
00256 (AAA_ScholarAttribute<diameter_enumerated_t> &authSessionState)
00257 {
00258 }
00259
00261 virtual void SetCallbackNumber
00262 (AAA_ScholarAttribute<diameter_utf8string_t> &callbackNumber)
00263 {
00264 }
00265
00268 virtual void SetCalledStationId
00269 (AAA_ScholarAttribute<diameter_utf8string_t> &calledStationId)
00270 {
00271 }
00272
00275 virtual void SetCallingStationId
00276 (AAA_ScholarAttribute<diameter_utf8string_t> &callingStationId)
00277 {
00278 }
00279
00282 virtual void SetOriginatingLineInfo
00283 (AAA_ScholarAttribute<diameter_octetstring_t> &originatingLineInfo)
00284 {
00285 }
00286
00288 virtual void SetConnectInfo
00289 (AAA_ScholarAttribute<diameter_utf8string_t> &connectInfo)
00290 {
00291 }
00292
00295 virtual void SetFramedCompression
00296 (AAA_VectorAttribute<diameter_enumerated_t> &framedCompression)
00297 {
00298 }
00299
00302 virtual void SetFramedInterfaceId
00303 (AAA_ScholarAttribute<diameter_unsigned64_t> &framedInterfaceId)
00304 {
00305 }
00306
00309 virtual void SetFramedIpAddress
00310 (AAA_ScholarAttribute<diameter_octetstring_t> &framedIpAddress)
00311 {
00312 }
00313
00316 virtual void SetFramedIpv6Prefix
00317 (AAA_VectorAttribute<diameter_octetstring_t> &framedIpv6Prefix)
00318 {
00319 }
00320
00323 virtual void SetFramedIpNetmask
00324 (AAA_ScholarAttribute<diameter_octetstring_t> &framedIpNetmask)
00325 {
00326 }
00327
00329 virtual void SetFramedMtu
00330 (AAA_ScholarAttribute<diameter_unsigned32_t> &framedMtu)
00331 {
00332 }
00333
00335 virtual void SetFramedProtocol
00336 (AAA_ScholarAttribute<diameter_enumerated_t> &framedProtocol)
00337 {
00338 }
00339
00341 virtual void SetLoginIpHost
00342 (AAA_VectorAttribute<diameter_octetstring_t> &loginIpHost)
00343 {
00344 }
00345
00347 virtual void SetLoginIpv6Host
00348 (AAA_VectorAttribute<diameter_octetstring_t> &loginIpv6Host)
00349 {
00350 }
00351
00353 virtual void SetLoginLatGroup
00354 (AAA_ScholarAttribute<diameter_octetstring_t> &loginLatGroup)
00355 {
00356 }
00357
00359 virtual void SetLoginLatNode
00360 (AAA_ScholarAttribute<diameter_octetstring_t> &loginLatNode)
00361 {
00362 }
00363
00365 virtual void SetLoginLatPort
00366 (AAA_ScholarAttribute<diameter_octetstring_t> &loginLatPort)
00367 {
00368 }
00369
00371 virtual void SetLoginLatService
00372 (AAA_ScholarAttribute<diameter_octetstring_t> &loginLatService)
00373 {
00374 }
00375
00377 virtual void SetTunneling
00378 (AAA_VectorAttribute<tunneling_t> &tunneling)
00379 {
00380 }
00381
00382
00383
00385 virtual void EnforceServiceType
00386 (const diameter_enumerated_t &serviceType)
00387 {
00388 }
00389
00392 virtual void EnforceConfigurationToken
00393 (const std::vector<diameter_octetstring_t> &Class)
00394 {
00395 }
00396
00398 virtual void EnforceClass
00399 (const std::vector<diameter_octetstring_t> &Class)
00400 {
00401 }
00402
00405 virtual void EnforceAcctInterimInterval
00406 (const diameter_unsigned32_t &acctInterimInterval)
00407 {
00408 }
00409
00412 virtual void EnforceIdleTimeout
00413 (const diameter_unsigned32_t &idleTimeout)
00414 {
00415 }
00416
00419 virtual void EnforceAuthorizationLifetime
00420 (const diameter_unsigned32_t &authorizationLifetime)
00421 {
00422 }
00423
00426 virtual void EnforceAuthGracePeriod
00427 (const diameter_unsigned32_t &authGracePeriod)
00428 {
00429 }
00430
00433 virtual void EnforceAuthSessionState
00434 (const diameter_enumerated_t &authSessionState)
00435 {
00436 }
00437
00440 virtual void EnforceReAuthRequestType
00441 (const diameter_enumerated_t &reAuthRequestType)
00442 {
00443 }
00444
00447 virtual void EnforceSessionTimeout
00448 (const diameter_unsigned32_t &sessionTimeout)
00449 {
00450 }
00451
00453 virtual void EnforceFilterId
00454 (const std::vector<diameter_utf8string_t> &filterId)
00455 {
00456 }
00457
00459 virtual void EnforcePortLimit
00460 (const diameter_unsigned32_t &portLimit)
00461 {
00462 }
00463
00465 virtual void EnforcePrompt
00466 (const diameter_enumerated_t &prompt)
00467 {
00468 }
00469
00471 virtual void EnforceCallbackId
00472 (const diameter_utf8string_t &callbackId)
00473 {
00474 }
00475
00477 virtual void EnforceCallbackNumber
00478 (const diameter_utf8string_t &callbackNumberInDEA)
00479 {
00480 }
00481
00484 virtual void EnforceFramedAppletalkLink
00485 (const diameter_unsigned32_t &framedAppletalkLink)
00486 {
00487 }
00488
00491 virtual void EnforceFramedAppletalkZone
00492 (const diameter_octetstring_t &framedAppletalkZone)
00493 {
00494 }
00495
00498 virtual void EnforceFramedAppletalkNetwork
00499 (const std::vector<diameter_unsigned32_t> &framedAppletalkNetwork)
00500 {
00501 }
00502
00505 virtual void EnforceFramedCompression
00506 (const std::vector<diameter_enumerated_t> &framedCompression)
00507 {
00508 }
00509
00512 virtual void EnforceFramedInterfaceId
00513 (const diameter_unsigned64_t &framedInterfaceId)
00514 {
00515 }
00516
00519 virtual void EnforceFramedIpAddress
00520 (const diameter_octetstring_t &framedIpAddress)
00521 {
00522 }
00523
00526 virtual void EnforceFramedIpv6Prefix
00527 (const std::vector<diameter_octetstring_t> &framedIpv6Prefix)
00528 {
00529 }
00530
00533 virtual void EnforceFramedIpv6Pool
00534 (const diameter_octetstring_t &framedIpv6Pool)
00535 {
00536 }
00537
00539 virtual void EnforceFramedPool
00540 (const diameter_octetstring_t &framedPool)
00541 {
00542 }
00543
00545 virtual void EnforceFramedIpv6Route
00546 (const std::vector<diameter_utf8string_t> &framedIpv6Route)
00547 {
00548 }
00549
00552 virtual void EnforceFramedIpNetmask
00553 (const diameter_octetstring_t &framedIpNetmaskInDEA)
00554 {
00555 }
00556
00559 virtual void EnforceFramedIpxNetwork
00560 (const diameter_utf8string_t &framedIpxNetwork)
00561 {
00562 }
00563
00565 virtual void EnforceFramedMtu
00566 (const diameter_unsigned32_t &framedMtu)
00567 {
00568 }
00569
00572 virtual void EnforceFramedProtocol
00573 (const diameter_enumerated_t &framedProtocol)
00574 {
00575 }
00576
00579 virtual void EnforceFramedRouting
00580 (const diameter_enumerated_t &framedRouting)
00581 {
00582 }
00583
00586 virtual void EnforceNasFilterRule
00587 (const std::vector<diameter_ipfilter_rule_t> &nasFilterRule)
00588 {
00589 }
00590
00593 virtual void EnforceLoginIpHost
00594 (const std::vector<diameter_octetstring_t> &loginIpHost)
00595 {
00596 }
00597
00600 virtual void EnforceLoginIpv6Host
00601 (const std::vector<diameter_octetstring_t> &loginIpv6Host)
00602 {
00603 }
00604
00607 virtual void EnforceLoginLatGroup
00608 (const diameter_octetstring_t &loginLatGroup)
00609 {
00610 }
00611
00614 virtual void EnforceLoginLatNode
00615 (const diameter_octetstring_t &loginLatNode)
00616 {
00617 }
00618
00621 virtual void EnforceLoginLatPort
00622 (const diameter_octetstring_t &loginLatPort)
00623 {
00624 }
00625
00628 virtual void EnforceLoginLatService
00629 (const diameter_octetstring_t &loginLatService)
00630 {
00631 }
00632
00635 virtual void EnforceLoginService
00636 (const diameter_enumerated_t &loginService)
00637 {
00638 }
00639
00642 virtual void EnforceLoginTcpPort
00643 (const diameter_unsigned32_t &loginTcpPort)
00644 {
00645 }
00646
00649 virtual void EnforceTunneling
00650 (const std::vector<tunneling_t> &tunneling)
00651 {
00652 }
00653
00654 inline DiameterNasreqAuthenticationInfo& AuthenticationInfo()
00655 { return *authenticationInfo; }
00656
00657 inline AA_RequestData& AA_Request() { return aaRequestData; }
00658 inline AA_AnswerData& AA_Answer() { return aaAnswerData; }
00659
00660 protected:
00661
00662 private:
00664 int Schedule(AAA_Job *job, size_t=1) { return (-1); }
00665
00667 inline int Serve()
00668 {
00669 if (!AAA_EventQueueJob::ExistBacklog())
00670 {
00671 AAA_LOG(LM_ERROR, "%N: no backlog to serve.");
00672 return 0;
00673 }
00674
00675
00676 AAA_Event ev;
00677 AAA_EventQueueJob::Dequeue(ev);
00678
00679 bool existBacklog = AAA_EventQueueJob::ExistBacklog();
00680
00681
00682 Event(ev);
00683 return existBacklog ? 1 : 0;
00684 }
00685
00686 DiameterNasreqClientSession &session;
00687
00688
00689 DiameterJobHandle handle;
00690
00691
00692 boost::shared_ptr<DiameterNasreqAuthenticationInfo> authenticationInfo;
00693
00694
00695 AA_RequestData aaRequestData;
00696 AA_AnswerData aaAnswerData;
00697 };
00698
00699 #endif