📄 sipdialogp2tuser.cxx
字号:
return true; }else{ return false; }}bool SipDialogP2Tuser::a7_callingnoauth_termwait_CANCEL(// State<SipSMCommand, string> *fromState,// State<SipSMCommand, string> *toState, const SipSMCommand &command){ if (transitionMatch(command, SipCancel::type, SipSMCommand::remote, IGN)){ //MRef<SipDialogP2Tuser *> vc = (SipDialogP2Tuser *)sipStateMachine;// /*vc->*/setCurrentState(toState); MRef<SipTransaction*> cancelresp( new SipTransactionNonInviteServer( getSipStack(), MRef<SipDialog*>(/* *vc */ this), command.getCommandPacket()->getCSeq(), command.getCommandPacket()->getLastViaBranch(), dialogState.callId )); /*vc->*/registerTransaction(cancelresp); SipSMCommand cmd(command); cmd.setSource(SipSMCommand::TU); cmd.setDestination(SipSMCommand::transaction); /*vc->*/getDialogContainer()->enqueueCommand(cmd, HIGH_PRIO_QUEUE, PRIO_LAST_IN_QUEUE); /*vc->*/getP2TDialog()->removeUser(/*vc->*/dialogState.remoteUri, "cancel_received",/*vc->*/getCallId()); /*vc->*/signalIfNoTransactions(); return true; }else{ return false; }}bool SipDialogP2Tuser::a8_callingnoauth_termwait_cancel(// State<SipSMCommand, string> *fromState,// State<SipSMCommand, string> *toState, const SipSMCommand &command){ if (transitionMatch(command, SipCommandString::cancel) || transitionMatch(command, SipCommandString::hang_up)){ //MRef<SipDialogP2Tuser *> vc = (SipDialogP2Tuser *)sipStateMachine;// /*vc->*/setCurrentState(toState); MRef<SipTransaction*> canceltrans( new SipTransactionNonInviteClient(getSipStack(), MRef<SipDialog*>(/* *vc */ this), /*vc->*/dialogState.seqNo, dialogState.callId)); /*vc->*/registerTransaction(canceltrans); /*vc->*/sendCancel(canceltrans->getBranch()); /*vc->*/signalIfNoTransactions(); //vc->getP2TDialog()->removeUser(vc->getDialogConfig().uri_foreign, "local_cancelled",vc->getCallId()); return true; }else{ return false; }}//Note: This is also used as: callingauth_terminated_36bool SipDialogP2Tuser::a9_callingnoauth_termwait_36( const SipSMCommand &command){ if (transitionMatch(command, SipResponse::type, IGN, SipSMCommand::TU, "3**\n4**\n5**\n6**")){ //MRef<SipDialogP2Tuser *> vc = (SipDialogP2Tuser *)sipStateMachine; MRef<LogEntry *> rejectedLog( new LogEntryCallRejected() ); rejectedLog->start = time( NULL ); rejectedLog->peerSipUri = /*vc->*/dialogState.remoteUri; dynamic_cast<LogEntryFailure *>(*rejectedLog)->error = "Remote user rejected the call"; /*vc->*/setLogEntry( rejectedLog ); rejectedLog->handle(); string reason=""; if (sipResponseFilterMatch(MRef<SipResponse*>((SipResponse*)*command.getCommandPacket()),"404")){ CommandString cmdstr(/*vc->*/getCallId(), SipCommandString::remote_user_not_found); /*vc->*/getDialogContainer()->getCallback()->sipcb_handleCommand( cmdstr); reason=SipCommandString::remote_user_not_found; }else if (sipResponseFilterMatch(MRef<SipResponse*>((SipResponse*)*command.getCommandPacket()),"606")){ CommandString cmdstr( /*vc->*/getCallId(), SipCommandString::remote_unacceptable); /*vc->*/getDialogContainer()->getCallback()->sipcb_handleCommand( cmdstr ); reason=SipCommandString::remote_unacceptable; } else if (sipResponseFilterMatch(MRef<SipResponse*>((SipResponse*)*command.getCommandPacket()),"4**")){ CommandString cmdstr( /*vc->*/getCallId(), SipCommandString::remote_reject); /*vc->*/getDialogContainer()->getCallback()->sipcb_handleCommand( cmdstr ); reason=SipCommandString::remote_reject; } else{ merr << "ERROR: received response in SipDialogP2Tuser" " that could not be handled (unimplemented)"<< end; reason="unexpected_response"; } /*vc->*/signalIfNoTransactions(); /*vc->*/getP2TDialog()->removeUser(dialogState.remoteUri,reason,/*vc->*/getCallId()); return true; }else{ return false; }}bool SipDialogP2Tuser::a10_start_ringing_INVITE( const SipSMCommand &command){ if (transitionMatch(command, SipInvite::type, IGN, SipSMCommand::TU)){ //MRef<SipDialogP2Tuser *> vc= (SipDialogP2Tuser *)sipStateMachine; dialogState.remoteUri = command.getCommandPacket()->getHeaderValueFrom()->getUri().getUserName()+"@"+ command.getCommandPacket()->getHeaderValueFrom()->getUri().getIp(); //vc->getDialogConfig().inherited->userUri = command.getCommandPacket()->getHeaderTo()->getUri().getUserIpString().substr(4); /*vc->*/getDialogConfig()->inherited->sipIdentity->setSipUri( command.getCommandPacket()->getHeaderValueTo()->getUri().getUserIpString() ); /*vc->*/ /*setSeqNo(command.getCommandPacket()->getCSeq() );*/ dialogState.seqNo = command.getCommandPacket()->getCSeq(); /*vc->*/dialogState.remoteTag = command.getCommandPacket()->getHeaderValueFrom()->getParameter("tag"); /*vc->*/setLocalCalled(true); /*vc->*/setLastInvite(MRef<SipInvite*>((SipInvite *)*command.getCommandPacket()));#if 0 KeyAgreement * ka = vc->getDialogContainer()->getPrecomputedKa(); if( !ResponderAuthenticate( ((SdpPacket*)*command.getCommandPacket()->getContent())->getKeyMgmt(), ka, vc->getDialogConfig() ) ){ // Authentication failed#ifdef DEBUG_OUTPUT merr << "Authentication of the incoming MIKEY message failed" << end;#endif return false; } vc->setKeyAgreement(ka);#endif MRef<SipTransaction*> ir( new SipTransactionInviteServerUA( getSipStack(), MRef<SipDialog*>(/* *vc */), command.getCommandPacket()->getCSeq(), command.getCommandPacket()->getLastViaBranch(), dialogState.callId) ); /*vc->*/registerTransaction(ir); // command.setSource(SipSMCommand::TU); // command.setDestination(SipSMCommand::transaction); // mdbg << "^^^^ SipDialogP2Tuser: re-handling packet for transaction to catch:"<<command<<end; SipSMCommand cmd(command); cmd.setDestination(SipSMCommand::transaction); /*vc->*/getDialogContainer()->enqueueCommand(cmd, HIGH_PRIO_QUEUE, PRIO_LAST_IN_QUEUE); CommandString cmdstr(/* vc->*/getCallId(), "p2tAddUser", /*vc->*/dialogState.remoteUri, #if 0 (/*vc->*/getDialogConfig()->inherited->secured?"secure":"unprotected")#else "unprotected"#endif ); //vc->getDialogContainer()->getCallback()->sipcb_handleCommand( cmdstr ); /*vc->*/sendRinging(ir->getBranch()); return true; }else{ return false; }}bool SipDialogP2Tuser::a11_ringing_incall_accept( const SipSMCommand &command){ if (transitionMatch(command, SipCommandString::accept_invite)){#ifndef _MSC_VER ts.save(USER_ACCEPT);#endif //MRef<SipDialogP2Tuser *>vc= (SipDialogP2Tuser *)sipStateMachine;#if 0 if( vc->getDialogConfig().inherited->secured ){ KeyAgreement * ka = vc->getKeyAgreement(); int32_t kam = vc->getDialogConfig().inherited->ka_type; string responseMessage = ResponderParse( ((SdpPacket*)*vc->getLastInvite()->getContent())->getKeyMgmt(), ka, vc->getDialogConfig().inherited->secured, kam ); vc->setKeyManagementMessage( "mikey " + responseMessage ); if( !vc->getDialogConfig().inherited->secured ){ /* An error occured when parsing the key agreement message */ return false; } }#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 ); assert( !/*vc->*/getLastInvite().isNull() ); /*vc->*/sendInviteOk(/*vc->*/getLastInvite()->getDestinationBranch() );#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 ( !/*vc->*/getLastInvite()->getContent().isNull() ){ /*vc->*/handleSdp(MRef<SdpPacket*>((SdpPacket*) * /*vc->*/getLastInvite()->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: INVITE did not contain any session description"<< end; } return true; }else{ return false; }}bool SipDialogP2Tuser::a12_ringing_termwait_CANCEL( const SipSMCommand &command){ if (transitionMatch(command, SipCancel::type, IGN, IGN)){ //MRef<SipDialogP2Tuser *> vc= (SipDialogP2Tuser *)sipStateMachine; //FIXME: is this correct - this should probably be handled //in the already existing transaction. MRef<SipTransaction*> cr( new SipTransactionNonInviteServer(getSipStack(), MRef<SipDialog*>(/* *vc */ this), command.getCommandPacket()->getCSeq(), command.getCommandPacket()->getLastViaBranch(), dialogState.callId) ); /*vc->*/registerTransaction(cr); SipSMCommand cmd(command); cmd.setDestination(SipSMCommand::transaction); // mdbg << "^^^^ SipDialogP2Tuser: re-handling packet for transaction to catch."<<end; /*vc->*/getDialogContainer()->enqueueCommand(cmd, HIGH_PRIO_QUEUE, PRIO_LAST_IN_QUEUE); // mdbg << "^^^^ SipDialogP2Tuser: sending ok to cancel packet"<<end; /* Tell the GUI */ CommandString cmdstr(/*vc->*/getCallId(), SipCommandString::remote_cancelled_invite,""); /*vc->*/getDialogContainer()->getCallback()->sipcb_handleCommand( cmdstr ); /*vc->*/sendInviteOk(cr->getBranch() ); /*vc->*/signalIfNoTransactions(); /*vc->*/getP2TDialog()->removeUser(/*vc->*/dialogState.remoteUri, SipCommandString::remote_cancelled_invite,/*vc->*/getCallId()); return true; }else{ return false; }}bool SipDialogP2Tuser::a13_ringing_termwait_reject( const SipSMCommand &command){ if (transitionMatch(command, SipCommandString::reject_invite) || transitionMatch(command,SipCommandString::hang_up)){ //MRef<SipDialogP2Tuser *> vc= (SipDialogP2Tuser *)sipStateMachine; /*vc->*/sendReject( /*vc->*/getLastInvite()->getDestinationBranch() ); /*vc->*/signalIfNoTransactions(); /*vc->*/getP2TDialog()->removeUser(/*vc->*/dialogState.remoteUri, SipCommandString::reject_invite,/*vc->*/getCallId()); return true; }else{ return false; }}bool SipDialogP2Tuser::a16_start_termwait_INVITE( const SipSMCommand &command){ if (transitionMatch(command, SipInvite::type, SipSMCommand::remote, SipSMCommand::TU)){ //MRef<SipDialogP2Tuser *> vc= (SipDialogP2Tuser *)sipStateMachine; /*vc->*/setLastInvite(MRef<SipInvite*>((SipInvite *)*command.getCommandPacket())); MRef<SipTransaction*> ir( new SipTransactionInviteServerUA(getSipStack(), MRef<SipDialog*>( /* *vc */ this), command.getCommandPacket()->getCSeq(), command.getCommandPacket()->getLastViaBranch(), dialogState.callId )); /*vc->*/registerTransaction(ir); SipSMCommand cmd(command); cmd.setDestination(SipSMCommand::transaction); /*vc->*/getDialogContainer()->enqueueCommand(cmd, HIGH_PRIO_QUEUE, PRIO_LAST_IN_QUEUE); /*vc->*/sendNotAcceptable( command.getCommandPacket()->getDestinationBranch() ); /*vc->*/signalIfNoTransactions(); /*vc->*/getP2TDialog()->removeUser(/*vc->*/dialogState.remoteUri, "send_notacceptable",/*vc->*/getCallId()); return true; }else{ return false; }}bool SipDialogP2Tuser::a20_callingnoauth_callingauth_40X( const SipSMCommand &command){ if (transitionMatch(command,SipResponse::type, IGN, SipSMCommand::TU, "407\n401")){ //MRef<SipDialogP2Tuser *> vc= (SipDialogP2Tuser *)sipStateMachine; MRef<SipResponse*> resp( (SipResponse*)*command.getCommandPacket() ); /*vc->*/dialogState.remoteTag = command.getCommandPacket()->getHeaderValueTo()->getParameter("tag"); //int seqNo = /*vc->*/requestSeqNo(); ++dialogState.seqNo; MRef<SipTransaction*> trans( new SipTransactionInviteClientUA(getSipStack(), MRef<SipDialog*>(/* *vc */ this), dialogState.seqNo, dialogState.callId)); /*vc->*/registerTransaction(trans); /*vc->*/setRealm( resp->getRealm() ); /*vc->*/setNonce( resp->getNonce() ); /*vc->*/sendAuthInvite(trans->getBranch()); return true; }else{ return false; }}bool SipDialogP2Tuser::a21_callingauth_callingauth_18X( const SipSMCommand &command){ if (transitionMatch(command, SipResponse::type, IGN, SipSMCommand::TU, "18*")){ MRef<SipResponse*> resp ( (SipResponse*)*command.getCommandPacket() ); //MRef<SipDialogP2Tuser *> vc= (SipDialogP2Tuser *)sipStateMachine;#ifndef _MSC_VER ts.save( RINGING );#endif CommandString cmdstr(/*vc->*/getCallId(), SipCommandString::remote_ringing); /*vc->*/getDialogContainer()->getCallback()->sipcb_handleCommand( cmdstr ); /*vc->*/dialogState.remoteTag = command.getCommandPacket()->getHeaderValueTo()->getParameter("tag"); if ( !resp->getContent().isNull()){ /*vc->*/handleSdp(MRef<SdpPacket*>((SdpPacket*)*resp->getContent()) ); } // else{ // merr << "WARNING: 200 OK did not contain any session description"<< end; // } return true; }else{ return false; }}bool SipDialogP2Tuser::a22_callingauth_callingauth_1xx( const SipSMCommand &command){ if (transitionMatch(command, SipResponse::type, IGN, SipSMCommand::TU, "1**")){ //SipDialogP2Tuser *vc= (SipDialogP2Tuser *)sipStateMachine; /*vc->*/dialogState.remoteTag= command.getCommandPacket()->getHeaderValueTo()->getParameter("tag"); return true; }else{ return false; }}bool SipDialogP2Tuser::a23_callingauth_incall_2xx( const SipSMCommand &command){
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -