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

📄 eap_standalone_authfsm.cxx

📁 Diameter协议栈
💻 CXX
📖 第 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                                                          */// $Id: eap_standalone_authfsm.cxx,v 1.16 2004/08/10 16:41:06 vfajardo Exp $// eap_standalone_authfsm.cxx:  StandAlone Authenticator state machine// Written by Yoshihiro Ohba#include <ace/Basic_Types.h>#include <ace/Singleton.h>#include "eap.hxx"#include "eap_authfsm.hxx"#include "eap_policy.hxx"#include "eap_log.hxx"#include "eap_parser.hxx"/// Action class for EAP. class EapStandAloneAuthSwitchAction :   public AAA_Action<EapStandAloneAuthSwitchStateMachine>{ public:  virtual void operator()(EapStandAloneAuthSwitchStateMachine&) {} protected:  EapStandAloneAuthSwitchAction() {}  virtual ~EapStandAloneAuthSwitchAction() {}};/// State table used by EapAuthSwitchStateMachine.class EapStandAloneAuthSwitchStateTable_S   : public AAA_StateTable<EapStandAloneAuthSwitchStateMachine>{  friend class ACE_Singleton<EapStandAloneAuthSwitchStateTable_S, 			     ACE_Recursive_Thread_Mutex>;private:  class AcDisable : public EapStandAloneAuthSwitchAction  {    void operator()(EapStandAloneAuthSwitchStateMachine &sm)    {      sm.Event(EapAuthSwitchStateMachine::EvSgPortEnabled);    }  };  class AcInitialize : public EapStandAloneAuthSwitchAction  {    void operator()(EapStandAloneAuthSwitchStateMachine &sm)    {      sm.CurrentIdentifier() = 0;  // Initilize the identifier      sm.Event(EvUCT);    }  };  class AcSendSuccess : public EapStandAloneAuthSwitchAction  {    void operator()(EapStandAloneAuthSwitchStateMachine &sm)    {      AAAMessageBlock *msg = AAAMessageBlock::Acquire(4);      EAP_LOG(LM_DEBUG, "Standalone: Composing Success message.\n");      // Compose the PDU.      EapHeaderParser parser;      EapHeader header;      header.code = Success;      header.identifier = sm.CurrentIdentifier();      header.length = 4;      parser.setAppData(&header);      parser.setRawData(msg);      parser.parseAppToRaw();      // Stop retransmission timer and reset retransmission counter.      sm.CancelTimer();      sm.RetransmissionCount()=0;      // Make the key available. (not specified in the state machine document.)      if (sm.KeyData().size()>0)	sm.KeyAvailable() = true;	      // Call Success callback function.      sm.Success(msg);      msg->release();    }  };  class AcSendFailure : public EapStandAloneAuthSwitchAction  {    void operator()(EapStandAloneAuthSwitchStateMachine &sm)    {      AAAMessageBlock *msg = AAAMessageBlock::Acquire(4);      EAP_LOG(LM_DEBUG, "Standalone: Composing Failure message.\n");      // Compose the PDU.      EapHeaderParser parser;      EapHeader header;      header.code = Failure;      header.identifier = sm.CurrentIdentifier();      header.length = 4;      parser.setAppData(&header);      parser.setRawData(msg);      parser.parseAppToRaw();      // Stop retransmission timer and reset retransmission counter.      sm.CancelTimer();      sm.RetransmissionCount()=0;      // Call Failure callback function.      sm.Failure(msg);      msg->release();    }  };  class AcMethodResponse : public EapStandAloneAuthSwitchAction  {    void operator()(EapStandAloneAuthSwitchStateMachine &sm)    {      EapMethodStateMachine &msm = sm.MethodStateMachine();      if (msm.IsDone())	{	  if (msm.KeyAvailable())	    sm.KeyData() = msm.KeyData();	  sm.MethodState() = EapAuthSwitchStateMachine::END;	  sm.Event(EapAuthSwitchStateMachine::EvSgEndMethod);	}      else	{	  sm.MethodState() = EapAuthSwitchStateMachine::CONT;	  sm.Event(EvElse);	}    }  };  class AcBuildRequest : public EapStandAloneAuthSwitchAction  {    void operator()(EapStandAloneAuthSwitchStateMachine &sm)    {      // Calculate the next Identifier for the new request.      ACE_Byte id = sm.CurrentIdentifier() = 	sm.MethodStateMachine().GetNextIdentifier(sm.CurrentIdentifier());      AAAMessageBlock *msg = sm.GetTxMessage();      // Compose the PDU.      EapHeaderParser headerParser;      EapHeader header;      header.code = Request;      header.identifier = id;      header.length = msg->length();      headerParser.setAppData(&header);      headerParser.setRawData(msg);      headerParser.parseAppToRaw();      // Set the wr_ptr to the tail of the message.      msg->wr_ptr(msg->base()+header.length);      sm.Event(EvUCT);    }  };  class AcSendRequest : public EapStandAloneAuthSwitchAction  {    void operator()(EapStandAloneAuthSwitchStateMachine &sm)    {      // Stop retransmission timer and reset retransmission counter.      sm.CancelTimer();      sm.RetransmissionCount()=0;      AAAMessageBlock *msg = sm.GetTxMessage();      // Call Send callback function.      // Increment the retransmission count.      sm.RetransmissionCount()++;      // Schedule retransmssion timer      EAP_LOG(LM_DEBUG, 	      "Standalone: Request sent and timer started.\n");      if (sm.RetransmissionEnabled())	sm.ScheduleTimer(EvTo, sm.RetransmissionInterval());      sm.Notify(EvUCT);      // Send the messsage.      //      cb->Send(msg);      sm.Send(msg);    }  };  class AcDoIntegrityCheck : public EapStandAloneAuthSwitchAction  {    void operator()(EapStandAloneAuthSwitchStateMachine &sm)    {      EAP_LOG(LM_DEBUG, "Standalone: Integrity Check.\n");      sm.MethodStateMachine().Notify	(EapMethodStateMachine::EvSgIntegrityCheck);    }  };  class AcProposeMethod : public EapStandAloneAuthSwitchAction  {    void operator()(EapStandAloneAuthSwitchStateMachine &sm)    {      EapType type = sm.Policy().CurrentMethod();      if (!type.IsVSE())	EAP_LOG(LM_DEBUG, "Standalone: Trying a legacy method.\n");      else	EAP_LOG(LM_DEBUG, "Standalone: Trying an extended method.\n");      sm.DeleteMethodStateMachine();      sm.CurrentMethod() = type;      sm.CreateMethodStateMachine(type, Authenticator);      sm.MethodStateMachine().Start();      if (type == EapType(1) || type == EapType(1)) // Identity or Notification	sm.MethodState() = EapAuthSwitchStateMachine::CONT;      else	sm.MethodState() = EapAuthSwitchStateMachine::PROPOSED;      // Notify method      sm.MethodStateMachine().Notify	(EapMethodStateMachine::EvSgIntegrityCheck);    }  };  class AcDoPolicyCheck : public EapStandAloneAuthSwitchAction  {    void operator()(EapStandAloneAuthSwitchStateMachine &sm)    {      EapAuthSwitchStateMachine::EapAuthDecision decision = sm.Decision();      if (decision == EapAuthSwitchStateMachine::DecisionSuccess)	sm.Event(EvSgPolicySat);      else if (decision == EapAuthSwitchStateMachine::DecisionFailure)	sm.Event(EvSgPolicyNotSat_EndSess);	      else // continue	sm.Event(EvElse);    }  };  class AcDiscard : public EapStandAloneAuthSwitchAction  {    void operator()(EapStandAloneAuthSwitchStateMachine &sm)    {      EAP_LOG(LM_DEBUG, "Standalone: Message Discarded.\n");      sm.DiscardCount()++;      sm.Event(EvUCT);    }  };  class AcDiscard2 : public EapStandAloneAuthSwitchAction  {    void operator()(EapStandAloneAuthSwitchStateMachine &sm)

⌨️ 快捷键说明

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