Esempio n. 1
0
        internal static void TestMessageParser()
        {
            TSIP_Message message = TSIP_ParserMessage.Parse(Encoding.UTF8.GetBytes(SIP_MESSAGE), true);

            if (message != null)
            {
                TSK_Debug.Info("Request = {0}", message);
            }
        }
Esempio n. 2
0
        //++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        //				== STATE MACHINE END ==
        //++++++++++++++++++++++++++++++++++++++++++++++++++++++++


        private Boolean OnTerminated()
        {
            TSK_Debug.Info("=== NICT terminated ===");

            this.TimerE.Stop();
            this.TimerF.Stop();
            this.TimerK.Stop();
            base.Running = false;

            return(base.RemoveFromLayer());
        }
Esempio n. 3
0
        private Boolean OnTerminated()
        {
            TSK_Debug.Info("=== REGISTER Dialog terminated ===");

            /* Cleanup IPSec SAs */
            //if (TSIP_DIALOG_GET_STACK(self)->security.secagree_mech && tsk_striequals(TSIP_DIALOG_GET_STACK(self)->security.secagree_mech, "ipsec-3gpp"))
            //{
            //    tsip_transport_cleanupSAs(TSIP_DIALOG_GET_STACK(self)->layer_transport);
            //}

            /* alert the user */
            TSIP_EventDialog.Signal(TSIP_EventDialog.tsip_dialog_event_type_t.Terminated,
                                    base.SipSession, String.IsNullOrEmpty(base.LastErrorPhrase) ? "Dialog terminated" : base.LastErrorPhrase, base.LastErrorMessage);

            /* Remove from the dialog layer. */
            base.RemoveFromLayer();
            return(true);
        }
Esempio n. 4
0
        internal static void TestUriParser()
        {
            int i;

            for (i = 0; i < __Uris.Length; i++)
            {
                TSIP_Uri uri = TSIP_ParserUri.Parse(__Uris[i]);

                TSK_Debug.Info("\n== Parsing {{ {0} }} ==\n", __Uris[i]);

                if (uri != null)
                {
                    TSK_Debug.Info("scheme: {0}", uri.Scheme);
                    TSK_Debug.Info("user-name: {0}", uri.UserName);
                    TSK_Debug.Info("password: {0}", uri.Password);
                    TSK_Debug.Info("host: {0}", uri.Host);
                    TSK_Debug.Info("port: {0}", uri.Port);
                    TSK_Debug.Info("host-type: {0}", uri.HostType == tsip_host_type_t.IPv4 ? "IPv4" : (uri.HostType == tsip_host_type_t.IPv6 ? "IPv6" : (uri.HostType == tsip_host_type_t.Hostname ? "HOSTNAME" : "UNKNOWN")));

                    TSK_Debug.Info("---PARAMS---");

                    /* dump all parameters */
                    foreach (TSK_Param param in uri.Params)
                    {
                        TSK_Debug.Info("-->{0}={1}", param.Name, param.Value);
                    }

                    TSK_Debug.Info("Is-secure: {0}", uri.IsSecure ? "YES" : "NO");

                    TestToString(uri);

                    uri.Dispose();
                }
                else
                {
                    TSK_Debug.Error("INVALID SIP URI");
                }

                TSK_Debug.Info("\n\n");
            }
        }
Esempio n. 5
0
 internal static void TestToString(TSIP_Uri uri)
 {
     TSK_Debug.Info("uri_to_string={0}", uri);
 }
Esempio n. 6
0
 static Boolean test_fsm_onterminated()
 {
     TSK_Debug.Info("FSM in terminal state.");
     return(true);
 }
Esempio n. 7
0
        public TNET_Socket(String host, ushort port, tnet_socket_type_t type, Boolean nonblocking, Boolean bindsocket)
        {
            mId          = ++sUniqueId;
            mType        = type;
            mHost        = host;
            mPort        = port;
            mSocketEvent = new ManualResetEvent(false);

            mSendSocketEventArgs            = new SocketAsyncEventArgs();
            mSendSocketEventArgs.Completed += delegate(object sender, SocketAsyncEventArgs e)
            {
                if (e.SocketError != SocketError.Success)
                {
                    mSocketEvent.Set();
                    return;
                }

                // On WP7 Socket.ReceiveFromAsync() will only works after at least ONE SendTo()
                if (e.LastOperation == SocketAsyncOperation.SendTo)
                {
                    if (mRecvSocketEventArgs == null && RecvSocketCompleted != null)
                    {
                        mRecvSocketEventArgs = new SocketAsyncEventArgs();

                        // setting the remote endpoint will not filter on the remote host:port
                        // => will continue to work even if the remote port is different than 5060
                        // IPEndPoint is not serializable => create new one
                        mRecvSocketEventArgs.RemoteEndPoint = new IPEndPoint(IPAddress.Any, 5060); // e.RemoteEndPoint
                        mRecvSocketEventArgs.Completed     += this.RecvSocketCompleted;

                        mRecvSocketEventArgs.SetBuffer(buffers, 0, buffers.Length);
                        mRecvSocketEventArgs.UserToken = e.UserToken;
                        (mRecvSocketEventArgs.UserToken as TNET_Socket).Socket.ReceiveFromAsync(mRecvSocketEventArgs);
                    }
                }

                mSocketEvent.Set();
            };

            AddressFamily addressFamily = TNET_Socket.IsIPv6Type(type) ? AddressFamily.InterNetworkV6 : AddressFamily.InterNetwork;
            SocketType    socketType    = TNET_Socket.IsStreamType(type) ? SocketType.Stream : SocketType.Dgram;

#if WINDOWS_PHONE
            ProtocolType protocolType = TNET_Socket.IsStreamType(type) ? ProtocolType.Tcp : ProtocolType.Udp;
#else
            ProtocolType protocolType = TNET_Socket.IsIPv6Type(type) ? ProtocolType.IP : ProtocolType.IP; // Leave it like this
#endif
            mSocket = new Socket(addressFamily, socketType, protocolType);
#if !WINDOWS_PHONE
            mSocket.Blocking            = !nonblocking;
            mSocket.UseOnlyOverlappedIO = true;
#endif

            mSendSocketEventArgs.UserToken = this;

            if (bindsocket)
            {
                IPAddress ipAddress = TNET_Utils.GetBestLocalIPAddress(host, type);
                TSK_Debug.Info("Local address={0}", ipAddress);
                mHost = ipAddress.ToString();
                if (bindsocket)
                {
                    ushort     localPort = (port == TNET_SOCKET_PORT_ANY) ? (ushort)0 : port;
                    IPEndPoint localIEP  = new IPEndPoint(ipAddress, localPort);
#if !WINDOWS_PHONE
                    mSocket.Bind(localIEP);
#endif
                    if (TNET_Socket.IsDatagramType(type))
                    {
 #if !WINDOWS_PHONE
                        mPort = (ushort)(mSocket.LocalEndPoint as IPEndPoint).Port;
#endif
                    }
                }
            }
        }