351 Error(aSignalHandler, err, MSocketNotify::EErrorConnect); |
351 Error(aSignalHandler, err, MSocketNotify::EErrorConnect); |
352 } |
352 } |
353 } |
353 } |
354 |
354 |
355 |
355 |
356 void TL2CAPSigStateClosed::CloseChannelRequest(CL2CapSAPSignalHandler& aSignalHandler) const |
356 void TL2CAPSigStateClosed::CloseChannel(CL2CapSAPSignalHandler& aSignalHandler) const |
357 { |
357 { |
358 LOG_FUNC |
358 LOG_FUNC |
359 // Detach from the Mux. Inform the SAP that disconnection is complete. |
359 // Detach from the Mux. Inform the SAP that disconnection is complete. |
360 aSignalHandler.DetachFromMux(); |
360 aSignalHandler.DetachFromMux(); |
361 aSignalHandler.SAP()->ChannelClosed(); |
361 aSignalHandler.SAP()->ChannelClosed(); |
379 void TL2CAPSigStateClosed::Enter(CL2CapSAPSignalHandler& aSignalHandler) const |
379 void TL2CAPSigStateClosed::Enter(CL2CapSAPSignalHandler& aSignalHandler) const |
380 { |
380 { |
381 LOG_FUNC |
381 LOG_FUNC |
382 // Cancel the configuration timer. |
382 // Cancel the configuration timer. |
383 aSignalHandler.CancelTimer(); |
383 aSignalHandler.CancelTimer(); |
|
384 |
|
385 aSignalHandler.iOpenChannelRequestAwaitingPeerEntityConfig = EFalse; |
384 |
386 |
385 // If Park mode has been overridden during either channel establishment or |
387 // If Park mode has been overridden during either channel establishment or |
386 // channel disconnect, remove the override. |
388 // channel disconnect, remove the override. |
387 // NB It is safe to call this method multiple times. |
389 // NB It is safe to call this method multiple times. |
388 aSignalHandler.UndoOverrideParkMode(); |
390 aSignalHandler.UndoOverrideParkMode(); |
444 // response. This can happen when the response arrives after the rtx has |
446 // response. This can happen when the response arrives after the rtx has |
445 // expired but we haven't yet resent the connect request. |
447 // expired but we haven't yet resent the connect request. |
446 } |
448 } |
447 |
449 |
448 // Events from the Mux |
450 // Events from the Mux |
449 void TL2CAPSigStateWaitConnectRsp::CloseChannelRequest(CL2CapSAPSignalHandler& aSignalHandler) const |
451 void TL2CAPSigStateWaitConnectRsp::CloseChannel(CL2CapSAPSignalHandler& aSignalHandler) const |
450 { |
452 { |
451 // Disconnect the channel. |
453 // Disconnect the channel. |
452 HandleSAPDisconnect(aSignalHandler); |
454 HandleSAPDisconnect(aSignalHandler); |
453 } |
455 } |
454 |
456 |
455 void TL2CAPSigStateWaitConnectRsp::Enter(CL2CapSAPSignalHandler& aSignalHandler) const |
457 void TL2CAPSigStateWaitConnectRsp::Enter(CL2CapSAPSignalHandler& aSignalHandler) const |
456 { |
458 { |
457 LOG_FUNC |
459 LOG_FUNC |
458 //set the remote CID to 0 |
460 //set the remote CID to 0 |
459 aSignalHandler.SetRemotePort(TL2CAPPort(0)); |
461 aSignalHandler.SetRemotePort(TL2CAPPort(0)); |
|
462 aSignalHandler.iAwaitConfigureChannelRequest = ETrue; |
460 } |
463 } |
461 |
464 |
462 /****************************************************************************/ |
465 /****************************************************************************/ |
463 // |
466 // |
464 // Waiting for the SAP to indicate that the connection can be established. |
467 // Waiting for the SAP to indicate that the connection can be established. |
487 aSignalHandler.SetState(iFactory.GetState(CL2CAPSignalStateFactory::EWaitConfig)); |
490 aSignalHandler.SetState(iFactory.GetState(CL2CAPSignalStateFactory::EWaitConfig)); |
488 if(!aSignalHandler.DelayConfigRequest()) |
491 if(!aSignalHandler.DelayConfigRequest()) |
489 // We should never get in here! The timer, which allows the delay |
492 // We should never get in here! The timer, which allows the delay |
490 // should have been started on entry to the state "WaitConfig". |
493 // should have been started on entry to the state "WaitConfig". |
491 { |
494 { |
492 aSignalHandler.ConfigureChannelRequest(); |
495 aSignalHandler.ConfigureChannel(); |
493 } |
496 } |
494 } |
497 } |
495 } // Success Response |
498 } // Success Response |
496 else |
499 else |
497 { |
500 { |
514 Error(aSignalHandler, sendErr, MSocketNotify::EErrorConnect); |
517 Error(aSignalHandler, sendErr, MSocketNotify::EErrorConnect); |
515 } |
518 } |
516 } |
519 } |
517 |
520 |
518 // Events from the Mux |
521 // Events from the Mux |
519 void TL2CAPSigStateWaitConnect::CloseChannelRequest(CL2CapSAPSignalHandler& aSignalHandler) const |
522 void TL2CAPSigStateWaitConnect::CloseChannel(CL2CapSAPSignalHandler& aSignalHandler) const |
520 { |
523 { |
521 LOG_FUNC |
524 LOG_FUNC |
522 |
525 |
523 // Tell the peer that there has been a security error |
526 // Tell the peer that there has been a security error |
524 TInt err = aSignalHandler.ConstructConnectionResponse(aSignalHandler.GetOutstandingRequestID(), |
527 TInt err = aSignalHandler.ConstructConnectionResponse(aSignalHandler.GetOutstandingRequestID(), |
565 LOG_FUNC |
568 LOG_FUNC |
566 // Call a common helper function to handle the Disconnect Request. |
569 // Call a common helper function to handle the Disconnect Request. |
567 HandleDisconnectRequest(aSignalHandler, aId); |
570 HandleDisconnectRequest(aSignalHandler, aId); |
568 } |
571 } |
569 |
572 |
|
573 void TL2CAPSigStateWaitConnect::Enter(CL2CapSAPSignalHandler& aSignalHandler) const |
|
574 { |
|
575 LOG_FUNC |
|
576 aSignalHandler.iAwaitConfigureChannelRequest = EFalse; |
|
577 } |
|
578 |
570 |
579 |
571 /**************************************************************************/ |
580 /**************************************************************************/ |
572 // Implementation of TL2CAPSigStateConfigBase |
581 // Implementation of TL2CAPSigStateConfigBase |
573 // |
582 // |
574 // This represents a SAP that is currently undergoing |
583 // This represents a SAP that is currently undergoing |
604 // Call the base class error method. |
613 // Call the base class error method. |
605 TL2CAPSigState::Error(aSignalHandler, aErrorCode, aErrorAction); |
614 TL2CAPSigState::Error(aSignalHandler, aErrorCode, aErrorAction); |
606 } |
615 } |
607 |
616 |
608 // Events from the SAP |
617 // Events from the SAP |
609 void TL2CAPSigStateConfigBase::CloseChannelRequest(CL2CapSAPSignalHandler& aSignalHandler) const |
618 void TL2CAPSigStateConfigBase::CloseChannel(CL2CapSAPSignalHandler& aSignalHandler) const |
610 { |
619 { |
611 LOG_FUNC |
620 LOG_FUNC |
612 // Disconnect the channel. |
621 // Disconnect the channel. |
613 HandleSAPDisconnect(aSignalHandler); |
622 HandleSAPDisconnect(aSignalHandler); |
614 } |
623 } |
622 |
631 |
623 // Timer Events |
632 // Timer Events |
624 void TL2CAPSigStateConfigBase::ConfigurationTimerExpiry(CL2CapSAPSignalHandler& aSignalHandler) const |
633 void TL2CAPSigStateConfigBase::ConfigurationTimerExpiry(CL2CapSAPSignalHandler& aSignalHandler) const |
625 { |
634 { |
626 LOG_FUNC |
635 LOG_FUNC |
627 CloseChannelRequest(aSignalHandler); |
636 CloseChannel(aSignalHandler); |
628 } |
637 } |
629 |
638 |
630 // Common handling of Config Request and Response commands. |
639 // Common handling of Config Request and Response commands. |
631 void TL2CAPSigStateConfigBase::ConfigRequest(CL2CapSAPSignalHandler& aSignalHandler, |
640 void TL2CAPSigStateConfigBase::ConfigRequest(CL2CapSAPSignalHandler& aSignalHandler, |
632 HConfigureRequest* aConfigRequest, |
641 HConfigureRequest* aConfigRequest, |
667 switch(result) |
676 switch(result) |
668 { |
677 { |
669 case EConfigSuccess: |
678 case EConfigSuccess: |
670 // Move to next state. |
679 // Move to next state. |
671 aSignalHandler.SetState(iFactory.GetState(aConfigSuccessState)); |
680 aSignalHandler.SetState(iFactory.GetState(aConfigSuccessState)); |
|
681 |
|
682 if (!configRequestSent && !aSignalHandler.iAwaitConfigureChannelRequest) |
|
683 { |
|
684 // The delay timer is there so that we don't send a |
|
685 // Config Req before receiving one from the remote |
|
686 // (as a workaround for some broken carkits, see |
|
687 // DelayConfigRequest()). Since we've just received a |
|
688 // ConfigReq from the remote, we can stop the delay |
|
689 // timer and send our request if this is passive open |
|
690 // or remotely-initiated reconfiguration. |
|
691 // If it's an active open scenario then we need to wait |
|
692 // for security access request to get completed. |
|
693 aSignalHandler.CancelTimer(); |
|
694 aSignalHandler.StartConfigurationTimer(); |
|
695 aSignalHandler.ConfigureChannel(); |
|
696 } |
672 break; |
697 break; |
673 |
698 |
674 case EConfigUnacceptableParams: |
699 case EConfigUnacceptableParams: |
675 case EConfigRejected: |
700 case EConfigRejected: |
676 // Stay in current state. |
701 // Stay in current state. |
677 break; |
702 break; |
678 |
703 |
679 case EConfigUnknownOption: // impossible on this path |
704 case EConfigUnknownOption: // impossible on this path |
680 default: |
705 default: |
681 __ASSERT_DEBUG(EFalse, PanicInState(EL2CAPInvalidConfigResponseCodeGenerated)); |
706 __ASSERT_DEBUG(EFalse, PanicInState(EL2CAPInvalidConfigResponseCodeGenerated)); |
682 break; |
707 break; |
683 } |
708 } |
834 { |
859 { |
835 LOG_FUNC |
860 LOG_FUNC |
836 } |
861 } |
837 |
862 |
838 // Events from the SAP |
863 // Events from the SAP |
839 void TL2CAPSigStateWaitConfig::ConfigureChannelRequest(CL2CapSAPSignalHandler& aSignalHandler) const |
864 void TL2CAPSigStateWaitConfig::ConfigureChannel(CL2CapSAPSignalHandler& aSignalHandler) const |
840 { |
865 { |
841 LOG_FUNC |
866 LOG_FUNC |
842 // Local config can now be initiated. The local config requirements must |
867 // Local config can now be initiated. The local config requirements must |
843 // take into account the peer entity capabilities. |
868 // take into account the peer entity capabilities. |
844 __ASSERT_DEBUG(aSignalHandler.ChannelConfig().IsPeerInfoDefined(), |
869 __ASSERT_DEBUG(aSignalHandler.ChannelConfig().IsPeerInfoDefined(), |
849 // Send our config request. |
874 // Send our config request. |
850 TInt err = SendConfigRequest(aSignalHandler); |
875 TInt err = SendConfigRequest(aSignalHandler); |
851 if(err == KErrNone) |
876 if(err == KErrNone) |
852 { |
877 { |
853 aSignalHandler.SetState(iFactory.GetState(CL2CAPSignalStateFactory::EWaitConfigReqRsp)); |
878 aSignalHandler.SetState(iFactory.GetState(CL2CAPSignalStateFactory::EWaitConfigReqRsp)); |
854 } |
879 } |
855 else |
880 else |
856 { |
881 { |
857 Error(aSignalHandler, KErrCouldNotConnect, MSocketNotify::EErrorAllOperations); |
882 Error(aSignalHandler, KErrCouldNotConnect, MSocketNotify::EErrorAllOperations); |
858 } |
883 } |
859 } |
884 } |
860 // Else wait until the delay timer expires. |
885 // Else wait until the delay timer expires. |
861 } |
886 } |
862 |
887 |
863 // L2CAP commands received from the peer. |
888 // L2CAP commands received from the peer. |
864 void TL2CAPSigStateWaitConfig::ConfigRequest(CL2CapSAPSignalHandler& aSignalHandler, |
889 void TL2CAPSigStateWaitConfig::ConfigRequest(CL2CapSAPSignalHandler& aSignalHandler, |
865 HConfigureRequest* aConfigRequest) const |
890 HConfigureRequest* aConfigRequest) const |
866 { |
891 { |
867 LOG_FUNC |
892 LOG_FUNC |
868 // Call the config base class helper method to process this command. |
893 // Call the config base class helper method to process this command. |
869 TL2CAPSigStateConfigBase::ConfigRequest(aSignalHandler, aConfigRequest, CL2CAPSignalStateFactory::EWaitSendConfig); |
894 TL2CAPSigStateConfigBase::ConfigRequest(aSignalHandler, aConfigRequest, CL2CAPSignalStateFactory::EWaitSendConfig); |
870 } |
895 } |
871 |
896 |
872 // Change of state events |
897 // Change of state events |
873 void TL2CAPSigStateWaitConfig::Enter(CL2CapSAPSignalHandler& aSignalHandler) const |
898 void TL2CAPSigStateWaitConfig::Enter(CL2CapSAPSignalHandler& aSignalHandler) const |
874 { |
899 { |
875 LOG_FUNC |
900 LOG_FUNC |
876 aSignalHandler.StartConfigurationTimer(); |
901 // First start the ConfigReq sending delay timer (see DelayConfigRequest() for why). |
|
902 // It's short lived, we'll start the proper L2CAP config timer when it expires. |
|
903 aSignalHandler.StartConfigRequestDelayTimer(); |
877 } |
904 } |
878 |
905 |
879 /**************************************************************************/ |
906 /**************************************************************************/ |
880 // Implementation of EWaitSendConfig |
907 // Implementation of EWaitSendConfig |
881 // |
908 // |
888 { |
915 { |
889 LOG_FUNC |
916 LOG_FUNC |
890 } |
917 } |
891 |
918 |
892 // Events from the SAP |
919 // Events from the SAP |
893 void TL2CAPSigStateWaitSendConfig::ConfigureChannelRequest(CL2CapSAPSignalHandler& aSignalHandler) const |
920 void TL2CAPSigStateWaitSendConfig::ConfigureChannel(CL2CapSAPSignalHandler& aSignalHandler) const |
894 { |
921 { |
895 LOG_FUNC |
922 LOG_FUNC |
896 // Local config can now be initiated. The local config requirements must |
923 // Local config can now be initiated. The local config requirements must |
897 // take into account the peer entity capabilities. |
924 // take into account the peer entity capabilities. |
898 __ASSERT_DEBUG(aSignalHandler.ChannelConfig().IsPeerInfoDefined(), |
925 __ASSERT_DEBUG(aSignalHandler.ChannelConfig().IsPeerInfoDefined(), |
1003 |
1030 |
1004 // Inform the data plane [via the SAP] that reconfig is in progress and data |
1031 // Inform the data plane [via the SAP] that reconfig is in progress and data |
1005 // should not be sent until it completes. |
1032 // should not be sent until it completes. |
1006 aSignalHandler.ReconfiguringChannel(); |
1033 aSignalHandler.ReconfiguringChannel(); |
1007 static_cast<void>(aSignalHandler.HandleConfigureRequest(aConfigRequest)); |
1034 static_cast<void>(aSignalHandler.HandleConfigureRequest(aConfigRequest)); |
1008 |
|
1009 // Start local reconfiguration. |
|
1010 aSignalHandler.ConfigureChannelRequest(); |
|
1011 } |
1035 } |
1012 |
1036 |
1013 TInt TL2CAPSigStateOpen::UpdateChannelConfig(CL2CapSAPSignalHandler& aSignalHandler, const TL2CapConfig& aAPIConfig) const |
1037 TInt TL2CAPSigStateOpen::UpdateChannelConfig(CL2CapSAPSignalHandler& aSignalHandler, const TL2CapConfig& aAPIConfig) const |
1014 { |
1038 { |
1015 LOG_FUNC |
1039 LOG_FUNC |
1017 TInt rerr = aSignalHandler.ChannelConfig().UpdateConfigAPIChange(aAPIConfig, reconfigRequired); |
1041 TInt rerr = aSignalHandler.ChannelConfig().UpdateConfigAPIChange(aAPIConfig, reconfigRequired); |
1018 if (reconfigRequired && rerr == KErrNone) |
1042 if (reconfigRequired && rerr == KErrNone) |
1019 { |
1043 { |
1020 aSignalHandler.ReconfiguringChannel(); |
1044 aSignalHandler.ReconfiguringChannel(); |
1021 aSignalHandler.SetState(iFactory.GetState(CL2CAPSignalStateFactory::EWaitConfig)); |
1045 aSignalHandler.SetState(iFactory.GetState(CL2CAPSignalStateFactory::EWaitConfig)); |
1022 aSignalHandler.ConfigureChannelRequest(); |
1046 aSignalHandler.ConfigureChannel(); |
1023 rerr = KErrL2CAPConfigPending; |
1047 rerr = KErrL2CAPConfigPending; |
1024 } |
1048 } |
1025 return rerr; |
1049 return rerr; |
1026 } |
1050 } |
1027 |
1051 |
1028 |
1052 |
1029 void TL2CAPSigStateOpen::CloseChannelRequest(CL2CapSAPSignalHandler& aSignalHandler) const |
1053 void TL2CAPSigStateOpen::CloseChannel(CL2CapSAPSignalHandler& aSignalHandler) const |
1030 { |
1054 { |
1031 LOG_FUNC |
1055 LOG_FUNC |
1032 // Disconnect the channel. |
1056 // Disconnect the channel. |
1033 HandleSAPDisconnect(aSignalHandler); |
1057 HandleSAPDisconnect(aSignalHandler); |
1034 } |
1058 } |
1058 else if (downgrade) |
1082 else if (downgrade) |
1059 { |
1083 { |
1060 LOG(_L("CL2CapSigStateOpen::Enter doing reconfig")); |
1084 LOG(_L("CL2CapSigStateOpen::Enter doing reconfig")); |
1061 // now get reconfiguring |
1085 // now get reconfiguring |
1062 aSignalHandler.SetState(iFactory.GetState(CL2CAPSignalStateFactory::EWaitConfig)); |
1086 aSignalHandler.SetState(iFactory.GetState(CL2CAPSignalStateFactory::EWaitConfig)); |
1063 aSignalHandler.ConfigureChannelRequest(); |
1087 aSignalHandler.ConfigureChannel(); |
1064 } |
1088 } |
1065 else |
1089 else |
1066 { |
1090 { |
1067 // Remove and park override. |
1091 // Remove and park override. |
1068 aSignalHandler.UndoOverrideParkMode(); |
1092 aSignalHandler.UndoOverrideParkMode(); |
1069 |
1093 |
1070 // Cancel the configuration timer. |
1094 // Cancel the configuration timer. |
1071 aSignalHandler.CancelTimer(); |
1095 aSignalHandler.CancelTimer(); |
1072 |
1096 |
1073 // Inform the SAP that the channel is now configured and ready to use. |
1097 // Inform the SAP that the channel is now configured and ready to use. |
1074 aSignalHandler.SAP()->ChannelConfigured(aSignalHandler.ChannelConfig(), |
1098 aSignalHandler.SAP()->ChannelConfigured(aSignalHandler.ChannelConfig(), |
1075 aSignalHandler.Mux(), |
1099 aSignalHandler.Mux(), |
1076 aSignalHandler.LocalPort(), |
1100 aSignalHandler.LocalPort(), |
1077 aSignalHandler.RemotePort()); |
1101 aSignalHandler.RemotePort()); |
1199 { |
1223 { |
1200 LOG_FUNC |
1224 LOG_FUNC |
1201 // Could well be in this state - just drop. |
1225 // Could well be in this state - just drop. |
1202 } |
1226 } |
1203 |
1227 |
1204 void TL2CAPSigStateWaitDisconnect::ConfigureChannelRequest(CL2CapSAPSignalHandler& /*aSignalHandler*/) const |
1228 void TL2CAPSigStateWaitDisconnect::ConfigureChannel(CL2CapSAPSignalHandler& /*aSignalHandler*/) const |
1205 { |
1229 { |
1206 LOG_FUNC |
1230 LOG_FUNC |
1207 // This may be called if an Information Request times out |
1231 // This may be called if an Information Request times out |
1208 // waiting for an Information Response, and we have since |
1232 // waiting for an Information Response, and we have since |
1209 // moved into the Wait Disconnect state. Therefore don't |
1233 // moved into the Wait Disconnect state. Therefore don't |