📄 sipdialogp2tuser.cxx
字号:
if (transitionMatch(command, SipResponse::type, IGN, SipSMCommand::TU, "2**")){ //SipDialogP2Tuser *vc= (SipDialogP2Tuser *)sipStateMachine; MRef<SipResponse*> resp( (SipResponse*)*command.getCommandPacket() ); /*vc->*/setLogEntry( new LogEntryOutgoingCompletedCall() ); /*vc->*/getLogEntry()->start = time( NULL ); /*vc->*/getLogEntry()->peerSipUri = resp->getFrom().getString(); /*vc->*/dialogState.remoteTag = command.getCommandPacket()->getHeaderValueTo()->getParameter("tag"); #if 0 /* Key Agreement response message treatment */ if( vc->getDialogConfig().inherited->secured ){ KeyAgreement * ka = vc->getKeyAgreement(); int32_t kam = vc->getDialogConfig().inherited->ka_type; if( !InitiatorAuthenticate( ((SdpPacket*)*command.getCommandPacket()->getContent())->getKeyMgmt(), ka, vc->getDialogConfig()) ){ merr << "KeyAgreement Response message authentication failed" << end; return false; } /* TODO: send that error message */ string error_message = InitiatorParse( ((SdpPacket*)*command.getCommandPacket()->getContent())->getKeyMgmt(), ka, vc->getDialogConfig().inherited->secured, kam ); vc->getDialogConfig().inherited->ka_type = kam; if( !vc->getDialogConfig().inherited->secured ){ // Some error occured in the key agreement parsing return false; } /* At this point, we can compute the tgk */ //vc->getKeyAgreement()->compute_tgk(); }#endif CommandString cmdstr(/*vc->*/getCallId(), SipCommandString::invite_ok, "",#if 0 (/*vc->*/getDialogConfig()->inherited->secured?"secure":"unprotected")#else "unprotected"#endif ); /*vc->*/getDialogContainer()->getCallback()->sipcb_handleCommand( cmdstr );#if 0 if( vc->getDialogConfig().inherited->secured && vc->getDialogConfig().inherited->ka_type == KEY_MGMT_METHOD_MIKEY_DH ){ ts.save( TGK_START ); ((KeyAgreementDH *)vc->getKeyAgreement())->computeTgk(); ts.save( TGK_END ); }#endif if ( !resp->getContent().isNull()){ /*vc->*/handleSdp(MRef<SdpPacket*>((SdpPacket*)*resp->getContent())); //vc->openSoundCard(); //vc->getSoundSender()->initCrypto(); //vc->getSoundReceiver()->initCrypto(); //vc->getSoundReceiver()->start(); //vc->getSoundSender()->start(); //vc->getSoundReceiver()->flush(); /*vc->*/reportSipDialogP2T(P2T::STATUS_CONNECTED); }else{ merr << "WARNING: 200 OK did not contain any session description"<< end; } return true; }else{ return false; }}bool SipDialogP2Tuser::a24_calling_termwait_2xx(// State<SipSMCommand, string> *fromState,// State<SipSMCommand, string> *toState, const SipSMCommand &command){ if (transitionMatch(command, SipResponse::type, IGN, SipSMCommand::TU, "2**")){ //MRef<SipDialogP2Tuser *> vc = (SipDialogP2Tuser *)sipStateMachine; //int bye_seq_no= /*vc->*/requestSeqNo(); ++dialogState.seqNo;// /*vc->*/setCurrentState(toState); MRef<SipTransaction*> byetrans = new SipTransactionNonInviteClient(getSipStack(), MRef<SipDialog*>(/* *vc */), /*vc->*/dialogState.seqNo, dialogState.callId); /*vc->*/registerTransaction(byetrans); /*vc->*/sendBye(byetrans->getBranch(), dialogState.seqNo); CommandString cmdstr(/*vc->*/getCallId(), SipCommandString::security_failed); /*vc->*/getDialogContainer()->getCallback()->sipcb_handleCommand(cmdstr); /*vc->*/signalIfNoTransactions(); /*vc->*/getP2TDialog()->removeUser(/*vc->*/dialogState.remoteUri, SipCommandString::security_failed,/*vc->*/getCallId()); return true; } else{ return false; }}bool SipDialogP2Tuser::a25_termwait_terminated_notransactions( const SipSMCommand &command){ if (transitionMatch(command, SipCommandString::no_transactions) ){ //MRef<SipDialogP2Tuser *> vc= (SipDialogP2Tuser *)sipStateMachine; /*vc->*/setLastInvite(NULL); SipSMCommand cmd( CommandString( /*vc->*/this->getCallId(), SipCommandString::call_terminated), SipSMCommand::TU, SipSMCommand::DIALOGCONTAINER); /*vc->*/getDialogContainer()->enqueueCommand( cmd, HIGH_PRIO_QUEUE, PRIO_LAST_IN_QUEUE ); //vc->getSoundSender()->setDialog(NULL); //vc->getSoundReceiver()->setDialog(NULL); return true; }else{ return false; }}bool SipDialogP2Tuser::a26_callingnoauth_termwait_transporterror( const SipSMCommand &command){ if (transitionMatch(command, SipCommandString::transport_error )){ //MRef<SipDialogP2Tuser *> vc= (SipDialogP2Tuser *)sipStateMachine; CommandString cmdstr(/*vc->*/getCallId(), SipCommandString::transport_error); /*vc->*/getDialogContainer()->getCallback()->sipcb_handleCommand(cmdstr); /*vc->*/getP2TDialog()->removeUser(/*vc->*/dialogState.remoteUri, SipCommandString::transport_error,/*vc->*/getCallId()); return true; }else{ return false; }}void SipDialogP2Tuser::setUpStateMachine(){ State<SipSMCommand,string> *s_start=new State<SipSMCommand,string>(this,"start"); addState(s_start); State<SipSMCommand,string> *s_callingnoauth=new State<SipSMCommand,string>(this,"callingnoauth"); addState(s_callingnoauth); State<SipSMCommand,string> *s_callingauth=new State<SipSMCommand,string>(this,"callingauth"); addState(s_callingauth); State<SipSMCommand,string> *s_incall=new State<SipSMCommand,string>(this,"incall"); addState(s_incall); State<SipSMCommand,string> *s_termwait=new State<SipSMCommand,string>(this,"termwait"); addState(s_termwait); State<SipSMCommand,string> *s_terminated=new State<SipSMCommand,string>(this,"terminated"); addState(s_terminated); State<SipSMCommand,string> *s_ringing=new State<SipSMCommand,string>(this,"ringing"); addState(s_ringing);// StateTransition<SipSMCommand,string> *transition_start_callingnoauth_invite= new StateTransition<SipSMCommand,string>(this, "transition_start_callingnoauth_invite", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogP2Tuser::a0_start_callingnoauth_invite, s_start, s_callingnoauth );// StateTransition<SipSMCommand,string> *transition_callingnoauth_callingnoauth_18X= new StateTransition<SipSMCommand,string>(this, "transition_callingnoauth_callingnoauth_18X", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogP2Tuser::a1_callingnoauth_callingnoauth_18X, s_callingnoauth, s_callingnoauth );// StateTransition<SipSMCommand,string> *transition_callingnoauth_callingnoauth_1xx= new StateTransition<SipSMCommand,string>(this, "transition_callingnoauth_callingnoauth_1xx", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogP2Tuser::a2_callingnoauth_callingnoauth_1xx, s_callingnoauth, s_callingnoauth );// StateTransition<SipSMCommand,string> *transition_callingnoauth_incall_2xx= new StateTransition<SipSMCommand,string>(this, "transition_callingnoauth_incall_2xx", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogP2Tuser::a3_callingnoauth_incall_2xx, s_callingnoauth, s_incall );// StateTransition<SipSMCommand,string> *transition_callingnoauth_termwait_2xx= new StateTransition<SipSMCommand,string>(this, "transition_callingauth_termwait_2xx", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogP2Tuser::a24_calling_termwait_2xx, s_callingnoauth, s_termwait );// StateTransition<SipSMCommand,string> *transition_incall_termwait_BYE= new StateTransition<SipSMCommand,string>(this, "transition_incall_termwait_BYE", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogP2Tuser::a5_incall_termwait_BYE, s_incall, s_termwait );// StateTransition<SipSMCommand,string> *transition_incall_termwait_hangup= new StateTransition<SipSMCommand,string>(this, "transition_incall_termwait_hangup", (bool (StateMachine<SipSMCommand,string>::*)(/*State<SipSMCommand, string> *,State<SipSMCommand, string> *,*/const SipSMCommand&)) &SipDialogP2Tuser::a6_incall_termwait_hangup, s_incall, s_termwait );// StateTransition<SipSMCommand,string> *transition_callingnoauth_termwait_CANCEL= new StateTransition<SipSMCommand,string>(this, "transition_callingnoauth_termwait_CANCEL", (bool (StateMachine<SipSMCommand,string>::*)(/*State<SipSMCommand, string> *,State<SipSMCommand, string> *,*/const SipSMCommand&)) &SipDialogP2Tuser::a7_callingnoauth_termwait_CANCEL, s_callingnoauth, s_termwait );// StateTransition<SipSMCommand,string> *transition_callingnoauth_termwait_cancel= new StateTransition<SipSMCommand,string>(this, "transition_callingnoauth_termwait_cancel", (bool (StateMachine<SipSMCommand,string>::*)(/*State<SipSMCommand, string> *,State<SipSMCommand, string> *,*/const SipSMCommand&)) &SipDialogP2Tuser::a8_callingnoauth_termwait_cancel, s_callingnoauth, s_termwait ); // StateTransition<SipSMCommand,string> *transition_callingnoauth_callingauth_40X= new StateTransition<SipSMCommand,string>(this, "transition_callingnoauth_callingauth_40X", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogP2Tuser::a20_callingnoauth_callingauth_40X, s_callingnoauth, s_callingauth ); // StateTransition<SipSMCommand,string> *transition_callingnoauth_termwait_36= new StateTransition<SipSMCommand,string>(this, "transition_callingnoauth_termwait_36", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogP2Tuser::a9_callingnoauth_termwait_36, s_callingnoauth, s_termwait );// StateTransition<SipSMCommand,string> *transition_start_ringing_INVITE= new StateTransition<SipSMCommand,string>(this, "transition_start_ringing_INVITE", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogP2Tuser::a10_start_ringing_INVITE, s_start, s_ringing );// StateTransition<SipSMCommand,string> *transition_ringing_incall_accept= new StateTransition<SipSMCommand,string>(this, "transition_ringing_incall_accept", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogP2Tuser::a11_ringing_incall_accept, s_ringing, s_incall ); // StateTransition<SipSMCommand,string> *transition_ringing_termwait_CANCEL= new StateTransition<SipSMCommand,string>(this, "transition_ringing_termwait_CANCEL", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogP2Tuser::a12_ringing_termwait_CANCEL, s_ringing, s_termwait ); // StateTransition<SipSMCommand,string> *transition_ringing_termwait_reject= new StateTransition<SipSMCommand,string>(this, "transition_ringing_termwait_reject", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogP2Tuser::a13_ringing_termwait_reject, s_ringing, s_termwait );// StateTransition<SipSMCommand,string> *transition_start_termwait_INVITE= new StateTransition<SipSMCommand,string>(this, "transition_start_termwait_INVITE", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogP2Tuser::a16_start_termwait_INVITE, s_start, s_termwait );// StateTransition<SipSMCommand,string> *transition_callingauth_callingauth_18X= new StateTransition<SipSMCommand,string>(this, "transition_callingauth_callingauth_18X", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogP2Tuser::a21_callingauth_callingauth_18X, s_callingauth, s_callingauth );// StateTransition<SipSMCommand,string> *transition_callingauth_callingauth_1xx= new StateTransition<SipSMCommand,string>(this, "transition_callingauth_callingauth_1xx", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogP2Tuser::a22_callingauth_callingauth_1xx, s_callingauth, s_callingauth );// StateTransition<SipSMCommand,string> *transition_callingauth_incall_2xx= new StateTransition<SipSMCommand,string>(this, "transition_callingauth_incall_2xx", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogP2Tuser::a23_callingauth_incall_2xx, s_callingauth, s_incall ); // StateTransition<SipSMCommand,string> *transition_callingauth_termwait_2xx= new StateTransition<SipSMCommand,string>(this, "transition_callingauth_termwait_2xx", (bool (StateMachine<SipSMCommand,string>::*)(/*State<SipSMCommand, string> *,State<SipSMCommand, string> *,*/const SipSMCommand&)) &SipDialogP2Tuser::a24_calling_termwait_2xx, s_callingauth, s_termwait ); // StateTransition<SipSMCommand,string> *transition_callingauth_termwait_resp36= new StateTransition<SipSMCommand,string>(this, "transition_callingauth_termwait_resp36", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogP2Tuser::a9_callingnoauth_termwait_36, s_callingauth, s_termwait );// StateTransition<SipSMCommand,string> *transition_termwait_terminated_notransactions= new StateTransition<SipSMCommand,string>(this, "transition_termwait_terminated_notransactions", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogP2Tuser::a25_termwait_terminated_notransactions, s_termwait, s_terminated ); // StateTransition<SipSMCommand,string> *transition_callingnoauth_termwait_transporterror= new StateTransition<SipSMCommand,string>(this, "transition_callingnoauth_termwait_transporterror", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogP2Tuser::a26_callingnoauth_termwait_transporterror, s_callingnoauth, s_termwait ); setCurrentState(s_start);}SipDialogP2Tuser::SipDialogP2Tuser(MRef<SipStack*> stack, MRef<SipDialogConfig*> callconfig, MRef<SipSoftPhoneConfiguration*> pconf, MRef<SipDialogP2T*>p2tDialog) : SipDialog(stack,callconfig), lastInvite(NULL), phoneconf(pconf){ /* soundReceiver = new SoundReceiver(getPhoneConfig()->soundcard, NULL, getPhoneConfig()); soundSender = new SoundSender(soundReceiver->getSocket(), getPhoneConfig()->soundcard, getPhoneConfig()->inherited->codecs[0], //FIXME NULL); soundSender->setDialog(this); soundReceiver->setDialog(this); */ // getDialogConfig().callId = itoa(rand())+"@"+getDialogConfig().inherited->localIpString; /*getDialogConfig().callId*/ dialogState.callId = itoa(rand())+"@"+getDialogConfig()->inherited->externalContactIP; dialogState.localTag=itoa(rand()); /* We will fill that later, once we know if that succeeded */ logEntry = NULL;// setKeyAgreement( getDialogContainer()->getPrecomputedKa() );//// getDialogContainer()->setPrecomputedKa( NULL ); //set p2tDialog this->p2tDialog=p2tDialog; //initialize private variable this->myIp=NULL; this->myRTPport=0; this->myRTCPport=0; this->myCodec=NULL; //start state machine
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -