📄 eap_standalone_authfsm.cxx
字号:
{ EAP_LOG(LM_DEBUG, "Standalone: 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 EapStandAloneAuthSwitchAction { void operator()(EapStandAloneAuthSwitchStateMachine &sm) { AAAMessageBlock *msg=sm.GetRxMessage(); EAP_LOG(LM_DEBUG, "Standalone: 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, "Standalone: Update policy on Nak.\n"); sm.Policy().Update(nak.TypeList()); sm.Event(EvUCT); } }; class AcRetransmit : public EapStandAloneAuthSwitchAction { void operator()(EapStandAloneAuthSwitchStateMachine &sm) { if (sm.RetransmissionCount() < sm.MaxRetransmissionCount()) { EAP_LOG(LM_DEBUG, "Standalone: 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 // cb->Send(msg); sm.Send(msg); } else { EAP_LOG(LM_ERROR, "Standalone: Reach max retransmission count.\n"); sm.CancelTimer(); sm.Event(EvSgMaxRetransmission); } } }; class AcReceiveMsg : public EapStandAloneAuthSwitchAction { void operator()(EapStandAloneAuthSwitchStateMachine &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; AcInitialize acInitialize; 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, EvRxMethodResp, EvRxNak, EvTo, EvSgMaxRetransmission, EvElse, }; enum state { StBegin, StDisabled, StInitialize, StSelectAction, StProposeMethod, StIdle, StIntegrityCheck, StMethodRequest, StMethodResponse, StSendRequest, StNak, StRetransmit, StDiscard, StSuccess, StFailure, StTimeoutFailure, StReceived }; EapStandAloneAuthSwitchStateTable_S() { AddStateTableEntry(StBegin, EapAuthSwitchStateMachine::EvSgRestart, StDisabled, acDisable); AddStateTableEntry(StDisabled, EapAuthSwitchStateMachine::EvSgPortEnabled, StInitialize, acInitialize); AddStateTableEntry(StInitialize, EvUCT, StSelectAction, acDoPolicyCheck); 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); AddWildcardStateTableEntry(StIntegrityCheck, StIntegrityCheck); 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); } ~EapStandAloneAuthSwitchStateTable_S() {}};typedef ACE_Singleton<EapStandAloneAuthSwitchStateTable_S, ACE_Recursive_Thread_Mutex> EapStandAloneAuthSwitchStateTable;EapStandAloneAuthSwitchStateMachine::EapStandAloneAuthSwitchStateMachine(ACE_Reactor &r, EapJobHandle &h) : EapAuthSwitchStateMachine(r, h), EapStateMachine<EapStandAloneAuthSwitchStateMachine> (*this, *EapStandAloneAuthSwitchStateTable::instance(), r, *this, "standalone"){}EapStandAloneAuthSwitchStateMachine::~EapStandAloneAuthSwitchStateMachine() {}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -