📄 diameter_nasreq_client_fsm.cxx
字号:
if (aaAnswer.AuthorizationLifetime.IsSet()) sm.EnforceAuthorizationLifetime(aaAnswer.AuthorizationLifetime()); if (aaAnswer.AuthGracePeriod.IsSet()) sm.EnforceAuthGracePeriod(aaAnswer.AuthGracePeriod()); if (aaAnswer.AuthSessionState.IsSet()) sm.EnforceAuthSessionState(aaAnswer.AuthSessionState()); if (aaAnswer.ReAuthRequestType.IsSet()) sm.EnforceReAuthRequestType(aaAnswer.ReAuthRequestType()); if (aaAnswer.SessionTimeout.IsSet()) sm.EnforceSessionTimeout(aaAnswer.SessionTimeout()); if (aaAnswer.State.IsSet()) aaRequest.State = aaAnswer.State(); if (aaAnswer.FilterId.IsSet()) sm.EnforceFilterId(aaAnswer.FilterId); if (aaAnswer.PortLimit.IsSet()) { aaRequest.PortLimit = aaAnswer.PortLimit(); sm.EnforcePortLimit(aaAnswer.PortLimit()); } if (aaAnswer.CallbackId.IsSet()) sm.EnforceCallbackId(aaAnswer.CallbackId()); if (aaAnswer.CallbackNumber.IsSet()) sm.EnforceCallbackNumber(aaAnswer.CallbackNumber()); if (aaAnswer.FramedAppletalkLink.IsSet()) sm.EnforceFramedAppletalkLink(aaAnswer.FramedAppletalkLink()); if (aaAnswer.FramedAppletalkZone.IsSet()) sm.EnforceFramedAppletalkZone(aaAnswer.FramedAppletalkZone()); if (aaAnswer.FramedAppletalkNetwork.IsSet()) sm.EnforceFramedAppletalkNetwork(aaAnswer.FramedAppletalkNetwork); if (aaAnswer.FramedCompression.IsSet()) { aaRequest.FramedCompression = aaAnswer.FramedCompression; sm.EnforceFramedCompression(aaAnswer.FramedCompression); } if (aaAnswer.FramedIpAddress.IsSet()) { aaRequest.FramedIpAddress = aaAnswer.FramedIpAddress(); sm.EnforceFramedIpAddress(aaAnswer.FramedIpAddress()); } if (aaAnswer.FramedIpv6Prefix.IsSet()) { aaRequest.FramedIpv6Prefix = aaAnswer.FramedIpv6Prefix; sm.EnforceFramedIpv6Prefix(aaAnswer.FramedIpv6Prefix); } if (aaAnswer.FramedPool.IsSet()) sm.EnforceFramedPool(aaAnswer.FramedPool()); if (aaAnswer.FramedIpv6Pool.IsSet()) sm.EnforceFramedIpv6Pool(aaAnswer.FramedIpv6Pool()); if (aaAnswer.FramedIpv6Route.IsSet()) sm.EnforceFramedIpv6Route(aaAnswer.FramedIpv6Route); if (aaAnswer.FramedIpNetmask.IsSet()) { aaRequest.FramedIpNetmask = aaAnswer.FramedIpNetmask(); sm.EnforceFramedIpNetmask(aaAnswer.FramedIpNetmask()); } if (aaAnswer.FramedIpxNetwork.IsSet()) sm.EnforceFramedIpxNetwork(aaAnswer.FramedIpxNetwork()); if (aaAnswer.FramedMtu.IsSet()) { aaRequest.FramedMtu = aaAnswer.FramedMtu(); sm.EnforceFramedMtu(aaAnswer.FramedMtu()); } if (aaAnswer.FramedProtocol.IsSet()) { aaRequest.FramedProtocol = aaAnswer.FramedProtocol(); sm.EnforceFramedProtocol(aaAnswer.FramedProtocol()); } if (aaAnswer.FramedRouting.IsSet()) sm.EnforceFramedRouting(aaAnswer.FramedRouting()); if (aaAnswer.NasFilterRule.IsSet()) sm.EnforceNasFilterRule(aaAnswer.NasFilterRule); if (aaAnswer.LoginIpHost.IsSet()) { aaRequest.LoginIpHost = aaAnswer.LoginIpHost(); sm.EnforceLoginIpHost(aaAnswer.LoginIpHost); } if (aaAnswer.LoginIpv6Host.IsSet()) { aaRequest.LoginIpv6Host = aaAnswer.LoginIpv6Host(); sm.EnforceLoginIpv6Host(aaAnswer.LoginIpv6Host); } if (aaAnswer.LoginIpv6Host.IsSet()) { aaRequest.LoginIpv6Host = aaAnswer.LoginIpv6Host(); sm.EnforceLoginIpv6Host(aaAnswer.LoginIpv6Host); } if (aaAnswer.LoginLatGroup.IsSet()) { aaRequest.LoginLatGroup = aaAnswer.LoginLatGroup(); sm.EnforceLoginLatGroup(aaAnswer.LoginLatGroup()); } if (aaAnswer.LoginLatNode.IsSet()) { aaRequest.LoginLatNode = aaAnswer.LoginLatNode(); sm.EnforceLoginLatNode(aaAnswer.LoginLatNode()); } if (aaAnswer.LoginLatPort.IsSet()) { aaRequest.LoginLatPort = aaAnswer.LoginLatPort(); sm.EnforceLoginLatPort(aaAnswer.LoginLatPort()); } if (aaAnswer.LoginLatService.IsSet()) { aaRequest.LoginLatService = aaAnswer.LoginLatService(); sm.EnforceLoginLatService(aaAnswer.LoginLatService()); } if (aaAnswer.LoginTcpPort.IsSet()) { sm.EnforceLoginTcpPort(aaAnswer.LoginTcpPort()); } aaRequest.Tunneling = aaAnswer.Tunneling; if (aaAnswer.Tunneling.size()>0) sm.EnforceTunneling(aaAnswer.Tunneling); } }; class AcAccessReject : public DiameterNasreqClientAction { void operator()(DiameterNasreqClientStateMachine& sm) { sm.SignalFailure(); sm.Session().Update(AAASession::EVENT_AUTH_FAILED); } }; class AcReauthenticate : public DiameterNasreqClientAction { void operator()(DiameterNasreqClientStateMachine& sm) { AAA_LOG(LM_DEBUG, "[%N] Reauthentication issued.\n"); sm.SignalReauthentication(); } }; class AcDisconnect : public DiameterNasreqClientAction { void operator()(DiameterNasreqClientStateMachine& sm) { AAA_LOG(LM_DEBUG, "[%N] Disconnect issued.\n"); sm.SignalDisconnect(); } }; enum state { StInitialize, StWaitAA_Answer, StCheckResultCode, StAccepted, StRejected, StWaitAuthInfo, StTerminated }; enum { EvSgSuccess, EvSgFailure, EvSgContinue }; AcSendAA_Request acSendAA_Request; AcContinueAuthentication acContinueAuthentication; AcCheckAA_AnswerResultCode acCheckAA_AnswerResultCode; AcAccessAccept acAccessAccept; AcAccessReject acAccessReject; AcReauthenticate acReauthenticate; AcDisconnect acDisconnect; // Defined as a leaf class DiameterNasreqClientStateTable_S() { AddStateTableEntry(StInitialize, DiameterNasreqClientStateMachine::EvRxAuthInfo, StWaitAA_Answer, acSendAA_Request); AddStateTableEntry(StInitialize, DiameterNasreqClientStateMachine::EvSgDisconnect, StTerminated); AddWildcardStateTableEntry(StInitialize, StInitialize); AddStateTableEntry(StWaitAA_Answer, DiameterNasreqClientStateMachine::EvRxAA_Answer, StCheckResultCode, acCheckAA_AnswerResultCode); AddStateTableEntry(StWaitAA_Answer, DiameterNasreqClientStateMachine::EvSgDisconnect, StTerminated); AddWildcardStateTableEntry(StWaitAA_Answer, StTerminated); AddStateTableEntry(StCheckResultCode, EvSgSuccess, StAccepted, acAccessAccept); AddStateTableEntry(StCheckResultCode, EvSgFailure, StRejected, acAccessReject); AddStateTableEntry(StCheckResultCode, EvSgContinue, StWaitAuthInfo, acContinueAuthentication); AddStateTableEntry(StAccepted, DiameterNasreqClientStateMachine::EvSgDisconnect, StTerminated, acDisconnect); AddStateTableEntry (StAccepted, DiameterNasreqClientStateMachine::EvSgSessionTimeout, StTerminated, acDisconnect); AddStateTableEntry (StAccepted, DiameterNasreqClientStateMachine::EvSgAuthGracePeriodTimeout, StTerminated, acDisconnect); AddStateTableEntry(StAccepted, DiameterNasreqClientStateMachine ::EvSgAuthLifetimeTimeout, StInitialize, acReauthenticate); AddWildcardStateTableEntry(StAccepted, StAccepted); AddWildcardStateTableEntry(StRejected, StTerminated); AddStateTableEntry(StWaitAuthInfo, DiameterNasreqClientStateMachine::EvRxAuthInfo, StWaitAA_Answer, acSendAA_Request); AddStateTableEntry(StWaitAuthInfo, DiameterNasreqClientStateMachine::EvSgDisconnect, StTerminated); AddWildcardStateTableEntry(StWaitAuthInfo, StTerminated); AddWildcardStateTableEntry(StTerminated, StTerminated); InitialState(StInitialize); } ~DiameterNasreqClientStateTable_S() {}};typedef ACE_Singleton<DiameterNasreqClientStateTable_S, ACE_Recursive_Thread_Mutex> DiameterNasreqClientStateTable;DiameterNasreqClientStateMachine::DiameterNasreqClientStateMachine(DiameterNasreqClientSession& s, DiameterJobHandle &h) : AAA_StateMachine<DiameterNasreqClientStateMachine> (*this, *DiameterNasreqClientStateTable::instance(), "AAA_NASREQ_CLIENT"), session(s), handle(h), authenticationInfo (boost::shared_ptr<DiameterNasreqAuthenticationInfo>()){}void DiameterNasreqClientStateMachine::SendAA_Request(){ AAAMessage msg; AA_RequestData aaRequest = aaRequestData; AA_RequestParser parser; parser.setAppData(&aaRequest); parser.setRawData(&msg); aaRequest.AuthApplicationId = NasreqApplicationId; try { parser.parseAppToRaw(); } catch (DiameterParserError) { AAA_LOG(LM_ERROR, "[%N] Parsing error.\n"); return; } AAAMessageControl msgControl(Session().Self()); if (msgControl.Send(msg) != AAA_ERR_SUCCESS) { AAA_LOG(LM_ERROR, "Failed sending message.\n"); } else { AAA_LOG(LM_DEBUG, "Sent AA-Request Message.\n"); }}void DiameterNasreqClientStateMachine::ForwardAuthenticationInfo(DiameterNasreqAuthenticationInfo &authInfo){ AAA_LOG(LM_ERROR, "[%N] Authinfo received from the application.\n"); if (authInfo.AuthenticationType() == NASREQ_AUTHENTICATION_TYPE_NONE) { AAA_LOG(LM_ERROR, "Failed to set authinfo type.\n"); return; } if (authInfo.AuthenticationType() == NASREQ_AUTHENTICATION_TYPE_PAP) { AAA_LOG(LM_DEBUG, "PAP info.\n"); authenticationInfo = boost::shared_ptr<PAP_Info> (new PAP_Info((PAP_Info&)authInfo)); } else if (authInfo.AuthenticationType() == NASREQ_AUTHENTICATION_TYPE_CHAP) { AAA_LOG(LM_DEBUG, "CHAP info.\n"); authenticationInfo = boost::shared_ptr <CHAP_Info>(new CHAP_Info((CHAP_Info&)authInfo)); } else { AAA_LOG(LM_DEBUG, "ARAP info.\n"); authenticationInfo = boost::shared_ptr<ARAP_Info> (new ARAP_Info((ARAP_Info&)authInfo)); } Notify(EvRxAuthInfo);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -