📄 siptransactioninviteserver.cxx
字号:
return false; }}/** If we receive the INVITE again from the TU, the response has been lost. We retransmit the response again without informing the TU. */bool SipTransactionInviteServer::a6_completed_completed_INVITE( const SipSMCommand &command){ if (transitionMatch("INVITE", command, SipSMCommand::transport_layer, SipSMCommand::transaction_layer)){ MRef<SipResponse*> resp = lastResponse; send(MRef<SipMessage*>(*resp), false); return true; }else{ return false; }}/** If we receive an ACK while in COMPLETED, we go to the "confirmed" state without informing the TU. Schedule for transaction termination using timer I. All other timers are cancelled. */bool SipTransactionInviteServer::a7_completed_confirmed_ACK( const SipSMCommand &command){ if (transitionMatch("ACK", command, SipSMCommand::transport_layer, SipSMCommand::transaction_layer)){ cancelTimeout("timerG");//response re-tx cancelTimeout("timerH"); //wait for ACK reception if( isUnreliable() ) requestTimeout(sipStack->getTimers()->getI(), "timerI"); else requestTimeout( 0, "timerI"); return true; }else{ return false; }}/** If timer G fires when in the "completed" state, we have not received an "ACK" to our response (3xx-6xx). Resend the response and hope for an "ACK" before a transaction timeout (timer H).*/bool SipTransactionInviteServer::a8_completed_completed_timerG( const SipSMCommand &command){ if (transitionMatch(command, "timerG", SipSMCommand::transaction_layer, SipSMCommand::transaction_layer)){ MRef<SipResponse*> resp = lastResponse; timerG *= 2; if( timerG > sipStack->getTimers()->getT2() ) timerG = sipStack->getTimers()->getT2(); requestTimeout( timerG, "timerG"); send(MRef<SipMessage*>(*resp), false); return true; }else{ return false; }}/** * If there is a transport error or if timerH fires, we failed to receive * an ACK after several re-sends. We inform the TU/Call and go to the * terminated state. */bool SipTransactionInviteServer::a9_completed_terminated_errOrTimerH( const SipSMCommand &command){ if ( transitionMatch(command, "timerH", SipSMCommand::transaction_layer, SipSMCommand::transaction_layer) || transitionMatch(command, SipCommandString::transport_error, SipSMCommand::transaction_layer, SipSMCommand::transaction_layer)){ cancelTimeout("timerG"); SipSMCommand cmd( CommandString(callId, SipCommandString::transport_error), SipSMCommand::transaction_layer, SipSMCommand::dialog_layer); dispatcher->enqueueCommand( cmd, HIGH_PRIO_QUEUE/*, PRIO_LAST_IN_QUEUE*/ ); SipSMCommand cmdterminated( CommandString( callId, SipCommandString::transaction_terminated), SipSMCommand::transaction_layer, SipSMCommand::dispatcher); dispatcher->enqueueCommand( cmdterminated, HIGH_PRIO_QUEUE/*, PRIO_FIRST_IN_QUEUE*/ ); return true; }else{ return false; }}/**When timer I fires, we stop absorbing ACKs.Move to TERMINATED and inform TU.*/bool SipTransactionInviteServer::a10_confirmed_terminated_timerI( const SipSMCommand &command){ if (transitionMatch(command, "timerI", SipSMCommand::transaction_layer, SipSMCommand::transaction_layer)){ SipSMCommand cmd( CommandString( callId, SipCommandString::transaction_terminated), SipSMCommand::transaction_layer, SipSMCommand::dispatcher); dispatcher->enqueueCommand( cmd, HIGH_PRIO_QUEUE/*, PRIO_FIRST_IN_QUEUE*/ ); return true; }else{ return false; }}bool SipTransactionInviteServer::a20_proceeding_proceeding_timerRel1xxResend( const SipSMCommand &command){ if (transitionMatch(command, "timerRel1xxResend", SipSMCommand::transaction_layer, SipSMCommand::transaction_layer)){ timerRel1xxResend*=2; requestTimeout(timerRel1xxResend, "timerRel1xxResend"); send(*lastResponse, false); // second parameter is "bool addVia" return true; }else{ return false; }}void SipTransactionInviteServer::setUpStateMachine(){ State<SipSMCommand,string> *s_start=new State<SipSMCommand,string>(this,"start"); addState(s_start); State<SipSMCommand,string> *s_proceeding=new State<SipSMCommand,string>(this,"proceeding"); addState(s_proceeding); State<SipSMCommand,string> *s_completed=new State<SipSMCommand,string>(this,"completed"); addState(s_completed); State<SipSMCommand,string> *s_confirmed=new State<SipSMCommand,string>(this,"confirmed"); addState(s_confirmed); State<SipSMCommand,string> *s_terminated=new State<SipSMCommand,string>(this,"terminated"); addState(s_terminated); ///Set up transitions to enable cancellation of this transaction new StateTransition<SipSMCommand,string>(this, "transition_cancel_transaction", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipTransaction::a1000_anyState_terminated_canceltransaction, StateMachine<SipSMCommand,string>::anyState, s_terminated); // new StateTransition<SipSMCommand,string>(this, "transition_start_proceeding_INVITE", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipTransactionInviteServer::a0_start_proceeding_INVITE, s_start, s_proceeding); new StateTransition<SipSMCommand,string>(this, "transition_proceeding_proceeding_INVITE", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipTransactionInviteServer::a1_proceeding_proceeding_INVITE, s_proceeding, s_proceeding); new StateTransition<SipSMCommand,string>(this, "transition_proceeding_proceeding_1xx", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipTransactionInviteServer::a2_proceeding_proceeding_1xx, s_proceeding, s_proceeding); new StateTransition<SipSMCommand,string>(this, "transition_proceeding_completed_resp36", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipTransactionInviteServer::a3_proceeding_completed_resp36, s_proceeding, s_completed); new StateTransition<SipSMCommand,string>(this, "transition_proceeding_terminated_Err", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipTransactionInviteServer::a4_proceeding_terminated_err, s_proceeding, s_terminated); new StateTransition<SipSMCommand,string>(this, "transition_proceeding_terminated_2xx", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipTransactionInviteServer::a5_proceeding_terminated_2xx, s_proceeding, s_terminated); new StateTransition<SipSMCommand,string>(this, "transition_completed_completed_INVITE", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipTransactionInviteServer::a6_completed_completed_INVITE, s_completed, s_completed); new StateTransition<SipSMCommand,string>(this, "transition_completed_confirmed_ACK", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipTransactionInviteServer::a7_completed_confirmed_ACK, s_completed, s_confirmed); new StateTransition<SipSMCommand,string>(this, "transition_completed_completed_timerG", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipTransactionInviteServer::a8_completed_completed_timerG, s_completed, s_completed); new StateTransition<SipSMCommand,string>(this, "transition_completed_terminated_errOrTimerH", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipTransactionInviteServer::a9_completed_terminated_errOrTimerH, s_completed, s_terminated); new StateTransition<SipSMCommand,string>(this, "transition_confirmed_terminated_timerI", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipTransactionInviteServer::a10_confirmed_terminated_timerI, s_confirmed, s_terminated); new StateTransition<SipSMCommand,string>(this, "a20_proceeding_proceeding_timerRel1xxResend", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipTransactionInviteServer::a20_proceeding_proceeding_timerRel1xxResend, s_proceeding, s_proceeding); setCurrentState(s_start);}SipTransactionInviteServer::SipTransactionInviteServer(MRef<SipStack*> stack, //MRef<SipDialog*> d, int seq_no, const string &cSeqMethod, const string &branch, const string &callid) : SipTransactionServer(stack, /*d,*/ seq_no, cSeqMethod, branch,callid), lastResponse(NULL), timerG(500){/* MRef<SipCommonConfig *> conf; if (dialog){ conf = dialog->getDialogConfig()->inherited; }else{ conf = sipStack->getStackConfig(); }*/ //toaddr = conf->sipIdentity->getSipProxy()->sipProxyIpAddr->clone(); //port = getConfig()->sipIdentity->getSipProxy()->sipProxyPort; setUpStateMachine();}SipTransactionInviteServer::~SipTransactionInviteServer(){} void SipTransactionInviteServer::setDialogRouteSet(MRef<SipRequest*> ) {#if 0 assert(dialog); if( dialog->dialogState.routeSet.size() == 0 ) { merr << "CESC: parent dialog has NO routeset" << end; /*SipMessage::getRouteSet returns the top-to-bottom ordered Record-Route headers. As a server, we can use this directly as route set (no reversing). */ dialog->dialogState.routeSet = inv->getRouteSet(); for( list<string>::iterator iter = dialog->dialogState.routeSet.begin(); iter!=dialog->dialogState.routeSet.end(); iter++ ) { //merr << "CESC: SipTransINVCli:setrouteset: " << (*iter) << end; } } else { //merr << "CESC: parent dialog already has a routeset" << end; }#endif }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -