📄 aaa_session_server.cxx
字号:
} SetAuthLifetimeTimeout(authLifetime); if (authLifetime.IsSet()) { Attributes().AuthLifetime() = authLifetime(); } if (tout) { if (*tout < Attributes().AuthLifetime()()) { Attributes().AuthLifetime() = *tout; AAA_LOG(LM_INFO, "(%P|%t) Accepted client auth lifetime hint: %d\n", Attributes().AuthLifetime()()); } } // sanity checks if (Attributes().AuthLifetime()() > Attributes().SessionTimeout()()) { int holder = Attributes().SessionTimeout()() - 1; Attributes().AuthLifetime() = (holder >= 0) ? holder : holder + 1; AAA_LOG(LM_INFO, "(%P|%t) !!! WARNING !!! application sets authorization lifetime\n"); AAA_LOG(LM_INFO, "(%P|%t) to be greater than session timeout, overriding to %d\n", Attributes().AuthLifetime()()); } } // check for grace period if (! Attributes().AuthGrace().IsNegotiated()) { AAA_ScholarAttribute<diameter_unsigned32_t> authGrace; SetAuthGracePeriodTimeout(authGrace); if (authGrace.IsSet()) { Attributes().AuthGrace() = authGrace(); } } m_Fsm.Notify(AAA_SESSION_AUTH_EV_RX_SSAR, msg);}void AAA_ServerAuthSession::RxAnswer(std::auto_ptr<AAAMessage> msg){ // base protocol answer message filters if ((msg->hdr.code == AAA_MSGCODE_ABORTSESSION) && (Attributes().AuthSessionState() == AAA_SESSION_STATE_MAINTAINED)) { if (m_Fsm.ASRSent()) { m_Fsm.RxASA(*msg); AAA_MsgResultCode rcode(*msg); if (rcode.InterpretedResultCode() == AAA_MsgResultCode::RCODE_SUCCESS) { m_Fsm.Notify(AAA_SESSION_AUTH_EV_RX_ASA_OK); } else { m_Fsm.Notify(AAA_SESSION_AUTH_EV_RX_ASA_FAIL); } } else { AAA_LOG(LM_DEBUG,"(%P|%t) *** ASA received with no ASR sent, discarding\n"); } } else if (msg->hdr.code == AAA_MSGCODE_SESSIONTERMINATION) { AAA_LOG(LM_DEBUG,"(%P|%t) *** STA received in server session, discarding\n"); } else if (msg->hdr.code == AAA_MSGCODE_REAUTH) { m_Fsm.RxRAA(*msg); AAA_UInt32AvpContainerWidget rcodeAvp(msg->acl); diameter_unsigned32_t *rcode = rcodeAvp.GetAvp(AAA_AVPNAME_RESULTCODE); if (rcode) { AAA_ReAuthValue value = { *rcode, 0 }; Attributes().ReAuthRequestValue() = value; m_Fsm.Notify(AAA_SESSION_AUTH_EV_RX_RAA); } else { AAA_LOG(LM_INFO, "(%P|%t) Re-Auth answer received with no result-code\n"); Attributes().ReAuthRequestValue().Clear(); } } else { m_Fsm.Notify(AAA_SESSION_AUTH_EV_RX_SSAA, msg); }}void AAA_ServerAuthSession::RxError(std::auto_ptr<AAAMessage> msg){ ErrorMsg(*msg);}AAAReturnCode AAA_ServerAuthSession::TxDelivery(std::auto_ptr<AAAMessage> msg){ // filter auth session state and negotiate AAA_EnumAvpContainerWidget sessionStateAvp(msg->acl); diameter_enumerated_t *state = sessionStateAvp.GetAvp (AAA_AVPNAME_AUTHSESSIONSTATE); if (! state) { sessionStateAvp.AddAvp(AAA_AVPNAME_AUTHSESSIONSTATE) = Attributes().AuthSessionState()(); } else if (Attributes().AuthSessionState()() != *state) { AAA_LOG(LM_INFO, "(%P|%t) !!! WARNING !!! application sending auth state\n"); AAA_LOG(LM_INFO, "(%P|%t) not matching base protocol, overriding\n"); *state = Attributes().AuthSessionState()(); } // dictate the session timeout if (! Attributes().SessionTimeout().IsNegotiated()) { AAA_UInt32AvpContainerWidget timeoutAvp(msg->acl); diameter_unsigned32_t *tout = timeoutAvp.GetAvp (AAA_AVPNAME_SESSIONTIMEOUT); if (! tout) { timeoutAvp.AddAvp(AAA_AVPNAME_SESSIONTIMEOUT) = Attributes().SessionTimeout()(); } else if (Attributes().SessionTimeout()() < *tout) { AAA_LOG(LM_INFO, "(%P|%t) !!! WARNING !!! application sending session timeout\n"); AAA_LOG(LM_INFO, "(%P|%t) greater than configuration or callback, overriding\n"); *tout = Attributes().SessionTimeout()(); } else { AAA_LOG(LM_INFO, "(%P|%t) Using applications session timeout settings\n"); Attributes().SessionTimeout() = *tout; } Attributes().SessionTimeout().IsNegotiated() = true; } // dictate the auth lifetime if (! Attributes().AuthLifetime().IsNegotiated()) { AAA_UInt32AvpContainerWidget timeoutAvp(msg->acl); diameter_unsigned32_t *tout = timeoutAvp.GetAvp (AAA_AVPNAME_AUTHLIFETIME); if (! tout) { timeoutAvp.AddAvp(AAA_AVPNAME_AUTHLIFETIME) = Attributes().AuthLifetime()(); } else if (Attributes().AuthLifetime()() < *tout) { AAA_LOG(LM_INFO, "(%P|%t) !!! WARNING !!! application sending auth lifetime \n"); AAA_LOG(LM_INFO, "(%P|%t) greater than configuration or callback, overriding\n"); *tout = Attributes().AuthLifetime()(); } else { AAA_LOG(LM_INFO, "(%P|%t) Using applications auth lifetime settings\n"); Attributes().AuthLifetime() = *tout; } Attributes().AuthLifetime().IsNegotiated() = true; } // dictate the grace period if (! Attributes().AuthGrace().IsNegotiated()) { AAA_UInt32AvpContainerWidget timeoutAvp(msg->acl); diameter_unsigned32_t *tout = timeoutAvp.GetAvp (AAA_AVPNAME_AUTHGRACE); if (! tout) { timeoutAvp.AddAvp(AAA_AVPNAME_AUTHGRACE) = Attributes().AuthGrace()(); } else if (Attributes().AuthGrace()() < *tout) { AAA_LOG(LM_INFO, "(%P|%t) !!! WARNING !!! application sending grace period \n"); AAA_LOG(LM_INFO, "(%P|%t) greater than configuration or callback, overriding\n"); *tout = Attributes().AuthGrace()(); } else { AAA_LOG(LM_INFO, "(%P|%t) Using applications auth grace period settings\n"); Attributes().AuthGrace() = *tout; } Attributes().AuthGrace().IsNegotiated() = true; } return AAA_AuthSession::TxDelivery(msg);}AAAReturnCode AAA_ServerAuthSession::RxDelivery(std::auto_ptr<AAAMessage> msg){ Attributes().MsgIdRxMessage(*msg); AAAReturnCode rc = (msg->hdr.flags.r) ? RequestMsg(*msg) : AnswerMsg(*msg); if (Attributes().AuthSessionState()() == AAA_SESSION_STATE_MAINTAINED) { AAA_Event ev = 0; if (rc == AAA_ERR_SUCCESS) { ev = (msg->hdr.flags.r) ? AAA_SESSION_AUTH_EV_SSAR_OK : AAA_SESSION_AUTH_EV_SSAA_OK; } else if (rc != AAA_ERR_INCOMPLETE) { ev = (msg->hdr.flags.r) ? AAA_SESSION_AUTH_EV_SSAR_FAIL : AAA_SESSION_AUTH_EV_SSAA_FAIL; } m_Fsm.Notify(ev); } return (AAA_ERR_SUCCESS);}AAAReturnCode AAA_ServerAuthSession::Reset(){ AAA_AuthSession::Reset(); AAA_SESSION_DB().Remove(Attributes().SessionId()); m_Fsm.Stop(); // WARNING!!!: schedule this object for destruction AAA_AUTH_SESSION_GC().ScheduleForDeletion(*this); return (AAA_ERR_SUCCESS);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -