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 __EAP_CLIENT_FSM_H__
00043 #define __EAP_CLIENT_FSM_H__
00044
00045 #include "framework.h"
00046 #include "diameter_eap_parser.hxx"
00047
00051 #ifdef WIN32
00052 #if defined(DIAMETER_EAP_CLIENT_EXPORT)
00053 #define DIAMETER_EAP_CLIENT_EXPORTS __declspec(dllexport)
00054 #else
00055 #define DIAMETER_EAP_CLIENT_EXPORTS __declspec(dllimport)
00056 #endif
00057 #else
00058 #define DIAMETER_EAP_CLIENT_EXPORTS
00059 #define DIAMETER_EAP_CLIENT_EXPORTS
00060 #endif
00061
00062 typedef AAA_JobHandle<AAA_GroupedJob> DiameterJobHandle;
00063
00064 class DiameterEapClientSession;
00065
00071 class DIAMETER_EAP_CLIENT_EXPORTS DiameterEapClientStateMachine
00072 : public AAA_StateMachine<DiameterEapClientStateMachine>,
00073 public AAA_EventQueueJob
00074 {
00075 friend class DiameterJobMultiplexor;
00076
00077 public:
00079 DiameterEapClientStateMachine(DiameterEapClientSession& s,
00080 DiameterJobHandle &h);
00081
00082 ~DiameterEapClientStateMachine()
00083 {
00084 handle.Job().Remove(this);
00085 }
00086
00087 enum {
00088
00089 EvSgStart=-1,
00090 EvRxEapResponse=-2,
00091 EvRxDEA=-3,
00092 EvRxAA_Answer=-4,
00093 EvSgSessionTimeout=-5,
00094 EvSgAuthLifetimeTimeout=-6,
00095 EvSgAuthGracePeriodTimeout=-7,
00096 EvSgTimeout=-8,
00097 EvSgDisconnect=-9
00098 };
00099
00101
00102
00104 inline void Notify(AAA_Event ev) {
00105
00106 if (AAA_EventQueueJob::Enqueue(ev) <= 0)
00107 Abort();
00108
00109 if (handle.Job().Schedule(this) < 0)
00110 Abort();
00111 }
00112
00113 inline DiameterEapClientSession& Session() { return session; }
00114
00117 virtual void Abort()=0;
00118
00121 void SendDER();
00122
00125 virtual void SignalContinue(std::string &eapMsg)=0;
00126
00130 virtual void SignalSuccess(std::string &eapMsg)=0;
00131
00135 virtual void SignalFailure(std::string &eapMsg)=0;
00136
00139 void ForwardResponse(std::string &eapMsg);
00140
00143 virtual void SendAA_Request() {}
00144
00148 virtual void SignalReauthentication()=0;
00149
00153 virtual void SignalDisconnect()=0;
00154
00155 inline AAA_JobData& JobData() { return *handle.Job().Data(); }
00156
00157 template <class T> inline T& JobData(Type2Type<T>)
00158 { return (T&)*handle.Job().Data(); }
00159
00160
00161
00164 virtual void SetDestinationRealm
00165 (AAA_ScholarAttribute<diameter_utf8string_t> &destinationRealm)
00166 {
00167 }
00168
00171 virtual void SetDestinationHost
00172 (AAA_ScholarAttribute<diameter_utf8string_t> &destinationHost)
00173 {
00174 }
00175
00178 virtual void SetAuthRequestType
00179 (AAA_ScholarAttribute<diameter_enumerated_t> &authRequestType)
00180 {
00181 authRequestType = AUTH_REQUEST_TYPE_AUTHORIZE_AUTHENTICATE;
00182 }
00183
00185 virtual void SetNasPort
00186 (AAA_ScholarAttribute<diameter_unsigned32_t> &nasPort)
00187 {
00188 }
00189
00191 virtual void SetNasPortId
00192 (AAA_ScholarAttribute<diameter_utf8string_t> &nasPortId)
00193 {
00194 }
00195
00197 virtual void SetOriginStateId
00198 (AAA_ScholarAttribute<diameter_unsigned32_t> &originStateId)
00199 {
00200 }
00201
00203 virtual void SetNasIdentifier
00204 (AAA_ScholarAttribute<diameter_utf8string_t> &nasIdentifier)
00205 {
00206 }
00207
00209 virtual void SetNasIpAddress
00210 (AAA_ScholarAttribute<diameter_octetstring_t> &nasIpAddress)
00211 {
00212 }
00213
00215 virtual void SetNasIpv6Address
00216 (AAA_ScholarAttribute<diameter_octetstring_t> &nasIpv6Address)
00217 {
00218 }
00219
00221 virtual void
00222 SetUserName(AAA_ScholarAttribute<diameter_utf8string_t> &userName)
00223 {
00224 }
00225
00227 virtual void
00228 SetServiceType(AAA_ScholarAttribute<diameter_enumerated_t> &serviceType)
00229 {
00230 }
00231
00233 virtual void
00234 SetIdleTimeout(AAA_ScholarAttribute<diameter_unsigned32_t> &idleTimeout)
00235 {
00236 }
00237
00239 virtual void
00240 SetState(AAA_ScholarAttribute<diameter_octetstring_t> &state)
00241 {
00242 }
00243
00246 virtual void
00247 SetAuthorizationLifetime
00248 (AAA_ScholarAttribute<diameter_unsigned32_t> &authorizationLifetime)
00249 {
00250 }
00251
00254 virtual void
00255 SetAuthGracePeriod
00256 (AAA_ScholarAttribute<diameter_unsigned32_t> &authGracePeriod)
00257 {
00258 }
00259
00262 virtual void
00263 SetAuthSessionState
00264 (AAA_ScholarAttribute<diameter_enumerated_t> &authSessionState)
00265 {
00266 }
00267
00269 virtual void
00270 SetSessionTimeout
00271 (AAA_ScholarAttribute<diameter_unsigned32_t> &sessionTimeout)
00272 {
00273 }
00274
00276 virtual void SetClass
00277 (AAA_VectorAttribute<diameter_octetstring_t> &classInDER)
00278 {
00279 }
00280
00282 virtual void
00283 SetPortLimit(AAA_ScholarAttribute<diameter_unsigned32_t> &portLimit)
00284 {
00285 }
00286
00288 virtual void SetCallbackNumber
00289 (AAA_ScholarAttribute<diameter_utf8string_t> &callbackNumber)
00290 {
00291 }
00292
00295 virtual void SetCalledStationId
00296 (AAA_ScholarAttribute<diameter_utf8string_t> &calledStationId)
00297 {
00298 }
00299
00302 virtual void SetCallingStationId
00303 (AAA_ScholarAttribute<diameter_utf8string_t> &callingStationId)
00304 {
00305 }
00306
00309 virtual void SetOriginatingLineInfo
00310 (AAA_ScholarAttribute<diameter_octetstring_t> &originatingLineInfo)
00311 {
00312 }
00313
00315 virtual void SetConnectInfo
00316 (AAA_ScholarAttribute<diameter_utf8string_t> &connectInfo)
00317 {
00318 }
00319
00322 virtual void SetFramedCompression
00323 (AAA_VectorAttribute<diameter_enumerated_t> &framedCompression)
00324 {
00325 }
00326
00329 virtual void SetFramedInterfaceId
00330 (AAA_ScholarAttribute<diameter_unsigned64_t> &framedInterfaceId)
00331 {
00332 }
00333
00336 virtual void SetFramedIpAddress
00337 (AAA_ScholarAttribute<diameter_octetstring_t> &framedIpAddress)
00338 {
00339 }
00340
00343 virtual void SetFramedIpv6Prefix
00344 (AAA_VectorAttribute<diameter_octetstring_t> &framedIpv6Prefix)
00345 {
00346 }
00347
00350 virtual void SetFramedIpNetmask
00351 (AAA_ScholarAttribute<diameter_octetstring_t> &framedIpNetmask)
00352 {
00353 }
00354
00356 virtual void SetFramedMtu
00357 (AAA_ScholarAttribute<diameter_unsigned32_t> &framedMtu)
00358 {
00359 }
00360
00362 virtual void SetFramedProtocol
00363 (AAA_ScholarAttribute<diameter_enumerated_t> &framedProtocol)
00364 {
00365 }
00366
00368 virtual void SetTunneling
00369 (AAA_VectorAttribute<tunneling_t> &tunneling)
00370 {
00371 }
00372
00373
00374
00377 virtual void EnforceMultiRoundTimeOut
00378 (const diameter_unsigned32_t &multiRoundTimeout)
00379 {
00380 }
00381
00383 virtual void EnforceServiceType
00384 (const diameter_enumerated_t &serviceTypeInDEA)
00385 {
00386 }
00387
00389 virtual void EnforceClass
00390 (const std::vector<diameter_octetstring_t> &classInDEA)
00391 {
00392 }
00393
00396 virtual void EnforceAcctInterimInterval
00397 (const diameter_unsigned32_t &acctInterimInterval)
00398 {
00399 }
00400
00403 virtual void EnforceIdleTimeout
00404 (const diameter_unsigned32_t &idleTimeout)
00405 {
00406 }
00407
00410 virtual void EnforceAuthorizationLifetime
00411 (const diameter_unsigned32_t &authorizationLifetime)
00412 {
00413 }
00414
00417 virtual void EnforceAuthGracePeriod
00418 (const diameter_unsigned32_t &authGracePeriod)
00419 {
00420 }
00421
00424 virtual void EnforceAuthSessionState
00425 (const diameter_enumerated_t &authSessionState)
00426 {
00427 }
00428
00431 virtual void EnforceReAuthRequestType
00432 (const diameter_enumerated_t &reAuthRequestType)
00433 {
00434 }
00435
00438 virtual void EnforceSessionTimeout
00439 (const diameter_unsigned32_t &sessionTimeout)
00440 {
00441 }
00442
00444 virtual void EnforceFilterId
00445 (const std::vector<diameter_utf8string_t> &filterId)
00446 {
00447 }
00448
00450 virtual void EnforcePortLimit
00451 (const diameter_unsigned32_t &portLimit)
00452 {
00453 }
00454
00456 virtual void EnforceCallbackId
00457 (const diameter_utf8string_t &callbackId)
00458 {
00459 }
00460
00462 virtual void EnforceCallbackNumber
00463 (const diameter_utf8string_t &callbackNumberInDEA)
00464 {
00465 }
00466
00469 virtual void EnforceFramedAppletalkLink
00470 (const diameter_unsigned32_t &framedAppletalkLink)
00471 {
00472 }
00473
00476 virtual void EnforceFramedAppletalkZone
00477 (const diameter_octetstring_t &framedAppletalkZone)
00478 {
00479 }
00480
00483 virtual void EnforceFramedAppletalkNetwork
00484 (const std::vector<diameter_unsigned32_t> &framedAppletalkNetwork)
00485 {
00486 }
00487
00490 virtual void EnforceFramedCompression
00491 (const std::vector<diameter_enumerated_t> &framedCompression)
00492 {
00493 }
00494
00497 virtual void EnforceFramedInterfaceId
00498 (const diameter_unsigned64_t &framedInterfaceId)
00499 {
00500 }
00501
00504 virtual void EnforceFramedIpAddress
00505 (const diameter_octetstring_t &framedIpAddress)
00506 {
00507 }
00508
00511 virtual void EnforceFramedIpv6Prefix
00512 (const std::vector<diameter_octetstring_t> &framedIpv6Prefix)
00513 {
00514 }
00515
00518 virtual void EnforceFramedIpv6Pool
00519 (const diameter_octetstring_t &framedIpv6Pool)
00520 {
00521 }
00522
00524 virtual void EnforceFramedPool
00525 (const diameter_octetstring_t &framedPool)
00526 {
00527 }
00528
00530 virtual void EnforceFramedIpv6Route
00531 (const std::vector<diameter_utf8string_t> &framedIpv6Route)
00532 {
00533 }
00534
00537 virtual void EnforceFramedIpNetmask
00538 (const diameter_octetstring_t &framedIpNetmaskInDEA)
00539 {
00540 }
00541
00544 virtual void EnforceFramedIpxNetwork
00545 (const diameter_utf8string_t &framedIpxNetwork)
00546 {
00547 }
00548
00550 virtual void EnforceFramedMtu
00551 (const diameter_unsigned32_t &framedMtu)
00552 {
00553 }
00554
00557 virtual void EnforceFramedProtocol
00558 (const diameter_enumerated_t &framedProtocol)
00559 {
00560 }
00561
00564 virtual void EnforceFramedRouting
00565 (const diameter_enumerated_t &framedRouting)
00566 {
00567 }
00568
00571 virtual void EnforceNasFilterRule
00572 (const std::vector<diameter_ipfilter_rule_t> &nasFilterRule)
00573 {
00574 }
00575
00578 virtual void EnforceTunneling
00579 (const std::vector<tunneling_t> &tunneling)
00580 {
00581 }
00582
00585 virtual void EnforceEapMasterSessionKey
00586 (const diameter_octetstring_t &eapMasterSessionKey)
00587 {
00588 }
00589
00592 virtual void EnforceAccountingEapAuthMethod
00593 (const std::vector<diameter_unsigned64_t> &accountingEapAuthMethodInDEA)
00594 {
00595 }
00596
00597 DER_Data& DER() { return derData; }
00598 DEA_Data& DEA() { return deaData; }
00599
00600 protected:
00601
00602 private:
00604 int Schedule(AAA_Job *job, size_t=1) { return (-1); }
00605
00607 inline int Serve()
00608 {
00609 if (!AAA_EventQueueJob::ExistBacklog())
00610 {
00611 AAA_LOG(LM_ERROR, "%N: no backlog to serve.");
00612 return 0;
00613 }
00614
00615
00616 AAA_Event ev;
00617 AAA_EventQueueJob::Dequeue(ev);
00618
00619 bool existBacklog = AAA_EventQueueJob::ExistBacklog();
00620
00621
00622 Event(ev);
00623 return existBacklog ? 1 : 0;
00624 }
00625
00626 DiameterEapClientSession &session;
00627
00629 DiameterJobHandle handle;
00630
00632 DER_Data derData;
00633 DEA_Data deaData;
00634
00635
00636 };
00637
00638 #endif