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

📄 eap_backend_authfsm.cxx

📁 Diameter协议栈
💻 CXX
📖 第 1 页 / 共 2 页
字号:
	sm.Event(EvSgPolicyNotSat_EndSess);	      else // continue	sm.Event(EvElse);    }  };  class AcDiscard : public EapBackendAuthSwitchAction  {    void operator()(EapBackendAuthSwitchStateMachine &sm)    {      EAP_LOG(LM_DEBUG, "Backend: Message Discarded.\n");      sm.DiscardCount()++;      sm.Event(EvUCT);    }  };  class AcDiscard2 : public EapBackendAuthSwitchAction  {    void operator()(EapBackendAuthSwitchStateMachine &sm)    {      EAP_LOG(LM_DEBUG, "Backend: Message discarded without parsing.\n");      sm.DiscardCount()++;      AAAMessageBlock *msg;      EapMessageQueue &q = sm.RxQueue();      // Dequeue a message from receiving queue.      q.dequeue_head((ACE_Message_Block*&)msg);      // Release it.      msg->release();    }  };  class AcResetMethod : public EapBackendAuthSwitchAction  {    void operator()(EapBackendAuthSwitchStateMachine &sm)    {        AAAMessageBlock *msg=sm.GetRxMessage();      EAP_LOG(LM_DEBUG, "Backend: Reset method due to receiving Nak.\n");      // Parse the nak      EapNakParser parser;      EapNak nak;      parser.setDictData(NULL);      parser.setAppData(&nak);      parser.setRawData(msg);      parser.parseRawToApp();      sm.DeleteRxMessage();      // Update policy based on type list.      EAP_LOG(LM_DEBUG, "Backend: Update policy on Nak.\n");      sm.Policy().Update(nak.TypeList());      sm.Event(EvUCT);    }  };  class AcRetransmit : public EapBackendAuthSwitchAction  {    void operator()(EapBackendAuthSwitchStateMachine &sm)    {      if (sm.RetransmissionCount() < sm.MaxRetransmissionCount())	{	  EAP_LOG(LM_DEBUG, "Backend: Retransmitting Request.\n");	  // Get the message to retransmit.	  AAAMessageBlock *msg = sm.GetTxMessage();	  // Call Send callback function.	  // Increment the retransmission count	  sm.RetransmissionCount()++;	  sm.Notify(EvElse);	  // Execute the callback function for sending the messsage	  sm.Send(msg);	}      else	{	  EAP_LOG(LM_DEBUG, "Backend: Reach max retransmission count.\n");	  sm.CancelTimer();	  sm.Event(EvSgMaxRetransmission);	}    }  };  class AcReceiveMsg : public EapBackendAuthSwitchAction  {    void operator()(EapBackendAuthSwitchStateMachine &sm)    {      AAAMessageBlock *msg;      // Dequeue a message from receiving queue.      sm.RxQueue().dequeue_head((ACE_Message_Block*&)msg);      // Set the read pointer to the message head.      msg->rd_ptr(msg->base());      // Set msg to rxMessage.      sm.SetRxMessage(msg);      // Parse the header      EapHeaderParser hp;      EapHeader header;      hp.setAppData(&header);      hp.setRawData(msg);      hp.parseRawToApp();      // Check code      unsigned code = header.code;      unsigned id = header.identifier;      // Check code & identifier      if ((code != Response) || (id != sm.CurrentIdentifier()))	{	  sm.DeleteRxMessage();	  sm.Notify(EvElse);	  return;	}      // Parse the response      EapResponseParser parser;      EapResponse resp;      parser.setAppData(&resp);      parser.setRawData(msg);      parser.parseRawToApp();      EapType type = sm.CurrentMethod();      // Check response type.  If this is a Nak message and the current      // method is not a pass-through method, then generate a Nak      // reception event.      if (resp.GetType() == EapType(3))	{	  if (sm.MethodState() == EapAuthSwitchStateMachine::PROPOSED)	    {	      sm.Event(EvRxNak);	    }	  else	    {	      sm.DeleteRxMessage();	      sm.Event(EvElse);	    }	}      else // Normal method	{	  if (resp.GetType() != type)	    {	      sm.DeleteRxMessage();	      sm.Event(EvElse);	    }	  else	    {	      sm.Event(EvRxMethodResp);	    }	}    }  };  AcDisable acDisable;  AcBackendInitialize acBackendInitialize;  AcPickUpMethod acPickUpMethod;  AcProposeMethod acProposeMethod;  AcBuildRequest acBuildRequest;  AcMethodResponse acMethodResponse;  AcSendSuccess acSendSuccess;  AcSendFailure acSendFailure;  AcSendRequest acSendRequest;  AcDoIntegrityCheck acDoIntegrityCheck;  AcDoPolicyCheck acDoPolicyCheck;  AcDiscard acDiscard;  AcDiscard2 acDiscard2;  AcResetMethod acResetMethod;  AcRetransmit acRetransmit;  AcReceiveMsg acReceiveMsg;  enum event {    EvUCT,    EvSgPolicySat,    EvSgPolicyNotSat_EndSess,    EvSgPolicyNotSat_ContSess,    EvSgNoMethod,    EvRxMethodResp,    EvRxNonResp,    EvRxNak,    EvTo,    EvSgMaxRetransmission,    EvElse,  };  enum state {    StBegin,    StDisabled,    StInitialize,    StPickUpMethod,    StSelectAction,    StProposeMethod,    //    StGetMethod,    StIdle,    StIntegrityCheck,    StMethodRequest,    StMethodResponse,    //    StMethod,    StSendRequest,    StNak,    StRetransmit,    StDiscard,    StSuccess,    StFailure,    StTimeoutFailure,    StReceived  };  EapBackendAuthSwitchStateTable_S()  {    AddStateTableEntry(StBegin, EapAuthSwitchStateMachine::EvSgRestart,		       StDisabled, acDisable);    AddStateTableEntry(StDisabled, 		       EapAuthSwitchStateMachine::EvSgPortEnabled,  		       StInitialize, acBackendInitialize);    AddStateTableEntry(StInitialize, EvRxNonResp, 		       StSelectAction, acDoPolicyCheck);    AddStateTableEntry(StInitialize, EvElse, 		       StPickUpMethod, acPickUpMethod);    AddStateTableEntry(StPickUpMethod, EvSgNoMethod, 		       StSelectAction, acDoPolicyCheck);    AddStateTableEntry(StPickUpMethod, EvElse, 		       StIntegrityCheck, acDoIntegrityCheck);    AddStateTableEntry(StInitialize, EvRxNak,		       StNak, acResetMethod);    AddStateTableEntry(StSelectAction, EvSgPolicySat,		       StSuccess, acSendSuccess);    AddStateTableEntry(StSelectAction, EvSgPolicyNotSat_EndSess,		       StFailure, acSendFailure);    AddStateTableEntry(StSelectAction, EvElse, 		       StProposeMethod, acProposeMethod);    AddStateTableEntry(StProposeMethod, 		       EapAuthSwitchStateMachine::EvSgValidResp,		       StMethodRequest, acBuildRequest);    AddStateTableEntry(StMethodRequest, EvUCT, 		       StSendRequest, acSendRequest);    AddStateTableEntry(StIntegrityCheck, 		       EapAuthSwitchStateMachine::EvSgValidResp,		       StMethodResponse, acMethodResponse);    AddStateTableEntry(StIntegrityCheck, 		       EapAuthSwitchStateMachine::EvSgInvalidResp,		       StDiscard, acDiscard);    // This state table entry is needed for queueing incoming requests.    AddStateTableEntry(StIntegrityCheck, EapAuthSwitchStateMachine::EvRxMsg,		       StIntegrityCheck, acDiscard2);    AddStateTableEntry(StMethodResponse, 		       EapAuthSwitchStateMachine::EvSgEndMethod,		       StSelectAction, acDoPolicyCheck);    AddStateTableEntry(StMethodResponse, EvElse,		       StMethodRequest, acBuildRequest);    AddStateTableEntry(StSendRequest, EvUCT, StIdle);    AddStateTableEntry(StIdle, EvTo, StRetransmit, acRetransmit);    AddStateTableEntry(StIdle, EapAuthSwitchStateMachine::EvRxMsg,		       StReceived, acReceiveMsg);    AddStateTableEntry(StReceived, EvRxMethodResp,		       StIntegrityCheck, acDoIntegrityCheck);    AddStateTableEntry(StReceived, EvRxNak,		       StNak, acResetMethod);    AddStateTableEntry(StReceived, EvElse, 		       StDiscard, acDiscard);    AddStateTableEntry(StRetransmit, EvSgMaxRetransmission, StTimeoutFailure);    AddStateTableEntry(StRetransmit, EvElse, StIdle);    AddStateTableEntry(StNak, EvUCT, StSelectAction, acDoPolicyCheck);    AddStateTableEntry(StDiscard, EvUCT, StIdle);    AddStateTableEntry(StSuccess, EapAuthSwitchStateMachine::EvRxMsg,		       StSuccess, acDiscard2);    AddWildcardStateTableEntry(StSuccess, StSuccess);    AddStateTableEntry(StFailure, EapAuthSwitchStateMachine::EvRxMsg,		       StFailure, acDiscard2);    AddWildcardStateTableEntry(StFailure, StFailure);    InitialState(StBegin);  }  ~EapBackendAuthSwitchStateTable_S() {}};typedef ACE_Singleton<EapBackendAuthSwitchStateTable_S, 		      ACE_Recursive_Thread_Mutex> EapBackendAuthSwitchStateTable;EapBackendAuthSwitchStateMachine::EapBackendAuthSwitchStateMachine(ACE_Reactor &r, EapJobHandle &h) :  EapAuthSwitchStateMachine(r, h),  EapStateMachine<EapBackendAuthSwitchStateMachine>  (*this, *EapBackendAuthSwitchStateTable::instance(), r, *this, "backend"){  retransmissionInterval = 0;  // Disable retransmission}EapBackendAuthSwitchStateMachine::~EapBackendAuthSwitchStateMachine() {}voidEapBackendAuthSwitchStateMachine::Start(AAAMessageBlock *msg){  // Set the current policy element to point to the initial policy  // element.  policy.CurrentPolicyElement(policy.InitialPolicyElement());  if (msg)    SetRxMessage(AAAMessageBlock::Acquire(msg));  EapStateMachine<EapBackendAuthSwitchStateMachine>::Start();  Notify(EapAuthSwitchStateMachine::EvSgRestart); // XXX When this Notify						  // does not exist,						  // there is an error						  // event in						  // passthrough. Should						  // be fixed.}

⌨️ 快捷键说明

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