示例#1
0
        public Boolean Stop()
        {
            Boolean ok        = false;
            Boolean oneFailed = false;

            if (!mRunning)
            {
                TSK_Debug.Warn("Stack not running");
                ok = true;
                goto bail;
            }
            /* Hangup all dialogs starting by REGISTER */
            if (!mLayerDialog.ShutdownAll())
            {
                TSK_Debug.Warn("Failed to hang-up all dialogs");
                oneFailed = true;
            }

            /* Stop the transport layer */
            if (!mLayerTransport.Stop())
            {
                TSK_Debug.Warn("Failed to stop the transport layer");
                oneFailed = true;
            }

            /* Signal to the end-user that the stack has been stopped
             * should be done before tsk_runnable_stop() which will stop the thread
             * responsible for the callbacks. The enqueued data have been marked as "important".
             * As both the timer manager and the transport layer have been stoped there is no
             * chance to got additional events */
            if (oneFailed)
            {
                TSIP_EventStack.Signal(TSIP_EventStack.tsip_stack_event_type_t.FailedToStop, "Stack failed to stop");
            }
            else
            {
                TSIP_EventStack.Signal(TSIP_EventStack.tsip_stack_event_type_t.Stopped, "Stack stopped");
            }

            /* reset AoR */
            mAoRIP   = null;
            mAoRPort = 0;

            ok = !oneFailed;
            if (ok)
            {
                mRunning = false;
            }
bail:
            return(ok);
        }
示例#2
0
        public Boolean Start()
        {
            Boolean ok = false;

            if (mRunning)
            {
                TSK_Debug.Warn("Stack already running");
                ok = true;
                goto bail;
            }

            /* === Transport Layer === */
            /* Adds the default transport to the transport Layer */
            if (!mLayerTransport.AddTransport(mLocalIP, mLocalPort, mProxyType, "SIP Transport"))
            {
                TSK_Debug.Error("Failed to add new transport");
                goto bail;
            }
            /* Starts the transport Layer */
            if (!mLayerTransport.Start())
            {
                TSK_Debug.Error("Failed to start SIP transport layer");
                goto bail;
            }
            // FIXME: Update local IP

            ok       = true;
            mRunning = true;
            TSIP_EventStack.Signal(TSIP_EventStack.tsip_stack_event_type_t.Started, "Stack started");
bail:
            if (!ok)
            {
                mLayerTransport.Stop();
            }
            return(ok);
        }