⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aaa_session_auth_server_fsm.h

📁 Diameter协议栈
💻 H
📖 第 1 页 / 共 2 页
字号:
/* BEGIN_COPYRIGHT                                                        *//*                                                                        *//* Open Diameter: Open-source software for the Diameter and               *//*                Diameter related protocols                              *//*                                                                        *//* Copyright (C) 2002-2004 Open Diameter Project                          *//*                                                                        *//* This library is free software; you can redistribute it and/or modify   *//* it under the terms of the GNU Lesser General Public License as         *//* published by the Free Software Foundation; either version 2.1 of the   *//* License, or (at your option) any later version.                        *//*                                                                        *//* This library is distributed in the hope that it will be useful,        *//* but WITHOUT ANY WARRANTY; without even the implied warranty of         *//* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU      *//* Lesser General Public License for more details.                        *//*                                                                        *//* You should have received a copy of the GNU Lesser General Public       *//* License along with this library; if not, write to the Free Software    *//* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307    *//* USA.                                                                   *//*                                                                        *//* In addition, when you copy and redistribute some or the entire part of *//* the source code of this software with or without modification, you     *//* MUST include this copyright notice in each copy.                       *//*                                                                        *//* If you make any changes that are appeared to be useful, please send    *//* sources that include the changed part to                               *//* diameter-developers@lists.sourceforge.net so that we can reflect your  *//* changes to one unified version of this software.                       *//*                                                                        *//* END_COPYRIGHT                                                          */#ifndef __AAA_SESSION_AUTH_SERVER_FSM_H__#define __AAA_SESSION_AUTH_SERVER_FSM_H__#include "aaa_session_auth_fsm.h"class DIAMETERBASEPROTOCOL_EXPORT AAA_AuthSessionServerStateMachine :    public AAA_AuthSessionStateMachine<AAA_AuthSessionServerStateMachine>{     public:   public:      AAA_AuthSessionServerStateMachine(AAA_Task &t,                                        AAA_AuthSession &a);      virtual ~AAA_AuthSessionServerStateMachine() {      }      void TxASR();      void TxSTA(diameter_unsigned32_t rcode);      void TxRAR(diameter_unsigned32_t rcode);      void RxSTR(AAAMessage &msg);      void RxASA(AAAMessage &msg);      void RxRAA(AAAMessage &msg);      bool &ASRSent() {          return m_ASRSent;      }   protected:       bool m_ASRSent;};class AAA_SessAuthServer_RxSSAR_Discard :    public AAA_Action<AAA_AuthSessionServerStateMachine> {   public:      virtual void operator()(AAA_AuthSessionServerStateMachine &fsm) {          std::auto_ptr<AAAMessage> msg = fsm.PendingMsg();          AAA_LOG(LM_INFO, "(%P|%t) Message sent in invalid session state, discarding\n");          AAA_MsgDump::Dump(*msg);      }};class AAA_SessAuthServer_RxSSA :    public AAA_Action<AAA_AuthSessionServerStateMachine> {   public:      virtual void operator()(AAA_AuthSessionServerStateMachine &fsm) {          std::auto_ptr<AAAMessage> msg = fsm.PendingMsg();          fsm.Session().RxDelivery(msg);      }};class AAA_SessAuthServer_TxSSAA_Discard :    public AAA_Action<AAA_AuthSessionServerStateMachine> {   public:      virtual void operator()(AAA_AuthSessionServerStateMachine &fsm) {          std::auto_ptr<AAAMessage> msg = fsm.PendingMsg();          AAA_LOG(LM_INFO, "(%P|%t) Message received in invalid session state, discarding\n");          AAA_MsgDump::Dump(*msg);      }};class AAA_SessAuthServer_TxSSA :    public AAA_Action<AAA_AuthSessionServerStateMachine> {   public:      virtual void operator()(AAA_AuthSessionServerStateMachine &fsm) {          std::auto_ptr<AAAMessage> msg = fsm.PendingMsg();          fsm.Session().TxDelivery(msg);                    if (fsm.Attributes().AuthSessionState()() !=               AAA_SESSION_STATE_MAINTAINED) {              fsm.CancelAllTimer();              fsm.ScheduleTimer(AAA_SESSION_AUTH_EV_SESSION_TOUT_NOST,                  fsm.Attributes().SessionTimeout()() +                  AAA_AUTH_SESSION_GRACE_PERIOD,                  0, AAA_TIMER_TYPE_SESSION);                                AAA_LOG(LM_INFO, "(%P|%t) Server session in stateless mode, extending access time\n");              AAA_LOG(LM_INFO, "(%P|%t) Session Timeout: %d\n",                             fsm.Attributes().SessionTimeout()());              AAA_LOG(LM_INFO, "(%P|%t) Auth Lifetime  : %d\n",                            fsm.Attributes().AuthLifetime()());              AAA_LOG(LM_INFO, "(%P|%t) Grace Period   : %d\n",                            fsm.Attributes().AuthGrace()());              fsm.Session().Success();          }      }};class AAA_SessAuthServer_TxSSAA_GrantAccess :    public AAA_Action<AAA_AuthSessionServerStateMachine> {   public:      virtual void operator()(AAA_AuthSessionServerStateMachine &fsm) {          fsm.CancelAllTimer();          fsm.ScheduleTimer(AAA_SESSION_AUTH_EV_SESSION_TOUT_ST,              fsm.Attributes().SessionTimeout()() +              AAA_AUTH_SESSION_GRACE_PERIOD,              0, AAA_TIMER_TYPE_SESSION);          fsm.ScheduleTimer(AAA_SESSION_AUTH_EV_LIFETIME_TOUT,              fsm.Attributes().AuthLifetime()() +              fsm.Attributes().AuthGrace()() +              AAA_AUTH_SESSION_GRACE_PERIOD,              0, AAA_TIMER_TYPE_AUTH);                        AAA_LOG(LM_INFO, "(%P|%t) Server session in open state\n");          AAA_LOG(LM_INFO, "(%P|%t) Session Timeout: %d\n",                             fsm.Attributes().SessionTimeout()());          AAA_LOG(LM_INFO, "(%P|%t) Auth Lifetime  : %d\n",                            fsm.Attributes().AuthLifetime()());          AAA_LOG(LM_INFO, "(%P|%t) Grace Period   : %d\n",                            fsm.Attributes().AuthGrace()());          fsm.Session().Success();      }};class AAA_SessAuthServer_TxASR :    public AAA_Action<AAA_AuthSessionServerStateMachine> {   public:      virtual void operator()(AAA_AuthSessionServerStateMachine &fsm) {          fsm.CancelAllTimer();          fsm.TxASR();      }};class AAA_SessAuthServer_TxRAR :    public AAA_Action<AAA_AuthSessionServerStateMachine> {   public:      virtual void operator()(AAA_AuthSessionServerStateMachine &fsm) {          if (fsm.Attributes().ReAuthRequestValue().IsSet()) {              fsm.TxRAR                (fsm.Attributes().ReAuthRequestValue()().reAuthType);  	  }      }};class AAA_SessAuthServer_RxRAA :    public AAA_Action<AAA_AuthSessionServerStateMachine> {   public:      virtual void operator()(AAA_AuthSessionServerStateMachine &fsm) {          if (fsm.Attributes().ReAuthRequestValue().IsSet()) {              fsm.Session().ReAuthenticate                 (fsm.Attributes().ReAuthRequestValue()().resultCode);        	  }      }};class AAA_SessAuthServer_TxSTACleanup :    public AAA_Action<AAA_AuthSessionServerStateMachine> {   public:      virtual void operator()(AAA_AuthSessionServerStateMachine &fsm) {          fsm.CancelAllTimer();          fsm.TxSTA(AAA_AUTHORIZATION_REJECTED);          fsm.Session().Disconnect();          fsm.ASRSent() = false;          fsm.Session().Reset();      }};class AAA_SessAuthServer_TxSTACleanup_Idle :    public AAA_Action<AAA_AuthSessionServerStateMachine> {   public:      virtual void operator()(AAA_AuthSessionServerStateMachine &fsm) {          fsm.CancelAllTimer();          fsm.TxSTA(AAA_AUTHORIZATION_REJECTED);          fsm.ASRSent() = false;          fsm.Session().Reset();      }};class AAA_SessAuthServer_RxASA :    public AAA_Action<AAA_AuthSessionServerStateMachine> {   public:      virtual void operator()(AAA_AuthSessionServerStateMachine &fsm) {	  fsm.CancelTimer(AAA_TIMER_TYPE_ASR);          fsm.Session().AbortSession();      }};class AAA_SessAuthServer_AuthorizationTimeout :    public AAA_Action<AAA_AuthSessionServerStateMachine> {   public:      virtual void operator()(AAA_AuthSessionServerStateMachine &fsm) {          fsm.Session().AuthorizationTimeout();          fsm.CancelAllTimer();          fsm.ASRSent() = false;          fsm.Session().Reset();      }};class AAA_SessAuthServer_SessionTimeout :    public AAA_Action<AAA_AuthSessionServerStateMachine> {   public:      virtual void operator()(AAA_AuthSessionServerStateMachine &fsm) {          fsm.Session().SessionTimeout();          fsm.CancelAllTimer();          fsm.ASRSent() = false;          fsm.Session().Reset();      }};class AAA_SessAuthServer_Cleanup :    public AAA_Action<AAA_AuthSessionServerStateMachine> {   public:      virtual void operator()(AAA_AuthSessionServerStateMachine &fsm) {          fsm.CancelAllTimer();          fsm.Session().AbortSession();          fsm.ASRSent() = false;          fsm.Session().Reset();      }};class AAA_SessAuthServerStateTable :    public AAA_StateTable<AAA_AuthSessionServerStateMachine>{   public:      AAA_SessAuthServerStateTable() {        /*           State     Event                          Action     New State           -------------------------------------------------------------            Idle      Service-specific authorization Send       Open                      request received, and          successful                      user is authorized             serv.                                                     specific answer         */        AddStateTableEntry(AAA_SESSION_AUTH_ST_IDLE,                           AAA_SESSION_AUTH_EV_SSAR_OK,                           AAA_SESSION_AUTH_ST_OPEN,                           m_acGrantAccess);         /*           State     Event                          Action     New State           -------------------------------------------------------------            Idle      Service-specific authorization Send       Idle                      request received, and          failed serv.                      user is not authorized         specific answer,                                                     Cleanup         */        AddStateTableEntry(AAA_SESSION_AUTH_ST_IDLE,                           AAA_SESSION_AUTH_EV_SSAR_FAIL,                           AAA_SESSION_AUTH_ST_IDLE,                           m_acCleanup);        /*           State     Event                          Action     New State           -------------------------------------------------------------            Not       ASA Received                   None       No Change.            Discon         */        AddStateTableEntry(AAA_SESSION_AUTH_ST_IDLE,                           AAA_SESSION_AUTH_EV_RX_ASA_OK,                           AAA_SESSION_AUTH_ST_IDLE);        /*           State     Event                          Action     New State           -------------------------------------------------------------            Not       ASA Received                   None       No Change.            Discon         */        AddStateTableEntry(AAA_SESSION_AUTH_ST_IDLE,                           AAA_SESSION_AUTH_EV_RX_ASA_FAIL,                           AAA_SESSION_AUTH_ST_IDLE);        /*           State     Event                          Action     New State           -------------------------------------------------------------            Any       STR Received                   Send STA,  Idle                                                     Cleanup.         */        AddStateTableEntry(AAA_SESSION_AUTH_ST_IDLE,                           AAA_SESSION_AUTH_EV_RX_STR,                           AAA_SESSION_AUTH_ST_IDLE,                           m_acTxSTACleanupIdle);        /*           State     Event                          Action     New State           -------------------------------------------------------------           Idle      Service-specific authorization Send       Idle                     answer sent                    service                                                    specific                                                    auth answer         */        AddStateTableEntry(AAA_SESSION_AUTH_ST_IDLE,                           AAA_SESSION_AUTH_EV_TX_SSAA,                           AAA_SESSION_AUTH_ST_IDLE,                           m_acTxSSA);        /*           State     Event                          Action     New State           -------------------------------------------------------------           Idle      Service-specific authorization Accept     Idle                     request received               service                                                    specific                                                    auth req         */        AddStateTableEntry(AAA_SESSION_AUTH_ST_IDLE,                           AAA_SESSION_AUTH_EV_RX_SSAR,                           AAA_SESSION_AUTH_ST_IDLE,                           m_acRxSSA);        /*           State     Event                          Action     New State           -------------------------------------------------------------            Idle      Authorization-Lifetime (and    Cleanup    Idle                      Auth-Grace-Period) expires

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -