Пример #1
0
 public void Load(DataRow cdrRow)
 {
     m_sipCDR               = new SIPCDR();
     m_sipCDR.CDRId         = new Guid(cdrRow["id"] as string);
     m_sipCDR.Owner         = cdrRow["owner"] as string;
     m_sipCDR.AdminMemberId = cdrRow["adminmemberid"] as string;
     Inserted               = DateTimeOffset.Parse(cdrRow["inserted"] as string);
     m_sipCDR.CallDirection = (cdrRow["direction"] as string == SIPCallDirection.In.ToString()) ? SIPCallDirection.In : SIPCallDirection.Out;
     Created = DateTimeOffset.Parse(cdrRow["created"] as string);
     m_sipCDR.Destination      = SIPURI.ParseSIPURI(cdrRow["dsturi"] as string);
     m_sipCDR.From             = SIPFromHeader.ParseFromHeader(cdrRow["fromheader"] as string);
     m_sipCDR.CallId           = cdrRow["callid"] as string;
     m_sipCDR.LocalSIPEndPoint = (!(cdrRow["localsocket"] as string).IsNullOrBlank()) ? SIPEndPoint.ParseSIPEndPoint(cdrRow["localsocket"] as string) : null;
     m_sipCDR.RemoteEndPoint   = (!(cdrRow["remotesocket"] as string).IsNullOrBlank()) ? SIPEndPoint.ParseSIPEndPoint(cdrRow["remotesocket"] as string) : null;
     m_sipCDR.BridgeId         = (!(cdrRow["bridgeid"] as string).IsNullOrBlank()) ? new Guid(cdrRow["bridgeid"] as string) : Guid.Empty;
     if (cdrRow["inprogresstime"] != DBNull.Value && cdrRow["inprogresstime"] != null && !(cdrRow["inprogresstime"] as string).IsNullOrBlank())
     {
         InProgressTime = DateTimeOffset.Parse(cdrRow["inprogresstime"] as string);
     }
     else
     {
         InProgressTime = null;
     }
     m_sipCDR.ProgressStatus       = (cdrRow["inprogressstatus"] != null && cdrRow["inprogressstatus"] != DBNull.Value) ? Convert.ToInt32(cdrRow["inprogressstatus"]) : 0;
     m_sipCDR.ProgressReasonPhrase = cdrRow["inprogressreason"] as string;
     if (cdrRow["answeredtime"] != DBNull.Value && cdrRow["answeredtime"] != null && !(cdrRow["answeredtime"] as string).IsNullOrBlank())
     {
         AnsweredTime = DateTimeOffset.Parse(cdrRow["answeredtime"] as string);
     }
     else
     {
         AnsweredTime = null;
     }
     m_sipCDR.AnswerStatus       = (cdrRow["answeredstatus"] != DBNull.Value && cdrRow["answeredstatus"] != null) ? Convert.ToInt32(cdrRow["answeredstatus"]) : 0;
     m_sipCDR.AnswerReasonPhrase = cdrRow["answeredreason"] as string;
     if (cdrRow["hunguptime"] != DBNull.Value && cdrRow["hunguptime"] != null && !(cdrRow["hunguptime"] as string).IsNullOrBlank())
     {
         HungupTime = DateTimeOffset.Parse(cdrRow["hunguptime"] as string);
     }
     else
     {
         HungupTime = null;
     }
     m_sipCDR.HangupReason = cdrRow["hungupreason"] as string;
     m_sipCDR.InProgress   = (m_sipCDR.ProgressTime != null);
     m_sipCDR.IsAnswered   = (m_sipCDR.AnswerTime != null);
     m_sipCDR.IsHungup     = (m_sipCDR.HangupTime != null);
     if (cdrRow["answeredat"] != DBNull.Value && cdrRow["answeredat"] != null)
     {
         AnsweredAt = (DateTime)cdrRow["answeredat"];
     }
     m_sipCDR.DialPlanContextID = (!(cdrRow["dialplancontextid"] as string).IsNullOrBlank()) ? new Guid(cdrRow["dialplancontextid"] as string) : Guid.Empty;
 }
Пример #2
0
        public void LongUserUnitTest()
        {
            logger.LogDebug("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name);
            logger.BeginScope(System.Reflection.MethodBase.GetCurrentMethod().Name);

            SIPURI sipURI = SIPURI.ParseSIPURI("sip:[email protected]:5060");

            Assert.True("EhZgKgLM9CwGqYDAECqDpL5MNrM_sKN5NurN5q_pssAk4oxhjKEMT4" == sipURI.User, "SIP user portion parsed incorrectly.");
            Assert.True("10.0.0.1:5060" == sipURI.Host, "SIP host portion parsed incorrectly.");

            logger.LogDebug("-----------------------------------------");
        }
Пример #3
0
        private SIPRequest GetInviteRequest(string callURI, SIPCallDescriptor sipCallDescriptor)
        {
            SIPFromHeader fromHeader = sipCallDescriptor.GetFromHeader();

            SIPRequest inviteRequest = new SIPRequest(SIPMethodsEnum.INVITE, SIPURI.ParseSIPURI(callURI))
            {
                LocalSIPEndPoint = m_blackhole
            };

            SIPHeader inviteHeader = new SIPHeader(fromHeader, new SIPToHeader(null, inviteRequest.URI, null), 1, CallProperties.CreateNewCallId());

            inviteHeader.From.FromTag = CallProperties.CreateNewTag();

            // For incoming calls forwarded via the dial plan the username needs to go into the Contact header.
            inviteHeader.Contact = new List <SIPContactHeader>()
            {
                new SIPContactHeader(null, new SIPURI(inviteRequest.URI.Scheme, m_blackhole))
            };
            inviteHeader.CSeqMethod = SIPMethodsEnum.INVITE;
            inviteRequest.Header    = inviteHeader;

            SIPViaHeader viaHeader = new SIPViaHeader(m_blackhole, CallProperties.CreateBranchId());

            inviteRequest.Header.Vias.PushViaHeader(viaHeader);

            try
            {
                if (sipCallDescriptor.CustomHeaders != null && sipCallDescriptor.CustomHeaders.Count > 0)
                {
                    foreach (string customHeader in sipCallDescriptor.CustomHeaders)
                    {
                        if (customHeader.IsNullOrBlank())
                        {
                            continue;
                        }
                        else if (customHeader.Trim().StartsWith(SIPHeaders.SIP_HEADER_USERAGENT))
                        {
                            inviteRequest.Header.UserAgent = customHeader.Substring(customHeader.IndexOf(":") + 1).Trim();
                        }
                        else
                        {
                            inviteRequest.Header.UnknownHeaders.Add(customHeader);
                        }
                    }
                }
            }
            catch (Exception excp)
            {
                logger.Error("Exception Parsing CustomHeader for GetInviteRequest. " + excp.Message + sipCallDescriptor.CustomHeaders);
            }

            return(inviteRequest);
        }
Пример #4
0
            public void GetAsXMLStringUnitTest()
            {
                Console.WriteLine("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name);

                SIPEventPresence presence = new SIPEventPresence(SIPURI.ParseSIPURI("sip:[email protected]"));

                presence.Tuples.Add(new SIPEventPresenceTuple("1234", SIPEventPresenceStateEnum.open, SIPURI.ParseSIPURIRelaxed("*****@*****.**"), 0.8M));

                Console.WriteLine(presence.ToXMLText());

                Console.WriteLine("-----------------------------------------");
            }
        public void ParseSIPUserFieldNoAnglesUnitTest()
        {
            logger.LogDebug("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name);
            logger.BeginScope(System.Reflection.MethodBase.GetCurrentMethod().Name);

            var userField = SIPUserField.ParseSIPUserField("sip:[email protected]");

            Assert.Null(userField.Name);
            Assert.Equal(SIPURI.ParseSIPURI("sip:[email protected]"), userField.URI);

            logger.LogDebug("-----------------------------------------");
        }
Пример #6
0
        public void ParseIPv4MappedAddressUnitTest()
        {
            logger.LogDebug("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name);

            SIPURI ipv6Uri = new SIPURI(SIPSchemesEnum.sip, IPAddress.IPv6Loopback, 6060);

            var uri = SIPURI.ParseSIPURI("sip:[::ffff:127.0.0.1]");

            Assert.Equal("[::ffff:127.0.0.1]", uri.Host);

            logger.LogDebug("-----------------------------------------");
        }
Пример #7
0
        public void KnownSchemesUnitTest()
        {
            logger.LogDebug("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name);
            logger.BeginScope(System.Reflection.MethodBase.GetCurrentMethod().Name);

            foreach (var value in System.Enum.GetValues(typeof(SIPSchemesEnum)))
            {
                Assert.True(SIPURI.ParseSIPURI(value.ToString() + ":1234565").Scheme == (SIPSchemesEnum)value);
            }

            logger.LogDebug("-----------------------------------------");
        }
Пример #8
0
        public void ParseReplacesHeaderUriUnitTest()
        {
            logger.LogDebug("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name);
            logger.BeginScope(System.Reflection.MethodBase.GetCurrentMethod().Name);

            SIPURI referToUri = SIPURI.ParseSIPURI("sip:[email protected]?Replaces=84929ZTg0Zjk1Y2UyM2Q1OWJjYWNlZmYyYTI0Njg1YjgwMzI%3Bto-tag%3D8787f9cc94bb4bb19c089af17e5a94f7%3Bfrom-tag%3Dc2b89404");

            Assert.NotNull(referToUri);
            Assert.Equal("sip:[email protected]", referToUri.ToParameterlessString());

            logger.LogDebug("-----------------------------------------");
        }
Пример #9
0
 public void Load(DataRow row)
 {
     SIPDialogue                 = new SIPDialogue();
     SIPDialogue.Id              = new Guid(row["id"] as string);
     SIPDialogue.Owner           = row["owner"] as string;
     SIPDialogue.AdminMemberId   = row["adminmemberid"] as string;
     SIPDialogue.LocalTag        = row["localtag"] as string;
     SIPDialogue.RemoteTag       = row["remotetag"] as string;
     SIPDialogue.LocalUserField  = SIPUserField.ParseSIPUserField(row["localuserfield"] as string);
     SIPDialogue.RemoteUserField = SIPUserField.ParseSIPUserField(row["remoteuserfield"] as string);
     SIPDialogue.CallId          = row["callid"] as string;
     SIPDialogue.CSeq            = Convert.ToInt32(row["cseq"]);
     SIPDialogue.BridgeId        = new Guid(row["bridgeid"] as string);
     SIPDialogue.RemoteTarget    = SIPURI.ParseSIPURI(row["remotetarget"] as string);
     SIPDialogue.RouteSet        =
         (row["routeset"] != null && row["routeset"] != DBNull.Value &&
          !(row["routeset"] as string).IsNullOrBlank())
             ? SIPRouteSet.ParseSIPRouteSet(row["routeset"] as string)
             : null;
     SIPDialogue.ProxySendFrom = (row["proxysipsocket"] != null && row["proxysipsocket"] != DBNull.Value)
         ? row["proxysipsocket"] as string
         : null;
     SIPDialogue.CDRId             = new Guid(row["cdrid"] as string);
     SIPDialogue.CallDurationLimit =
         (row["calldurationlimit"] != null && row["calldurationlimit"] != DBNull.Value)
             ? Convert.ToInt32(row["calldurationlimit"])
             : 0;
     SIPDialogue.Direction = (row["direction"] != null)
         ? (SIPCallDirection)Enum.Parse(typeof(SIPCallDirection), row["direction"] as string, true)
         : SIPCallDirection.None;
     Inserted     = DateTimeOffset.Parse(row["inserted"] as string);
     TransferMode = row["transfermode"] as string;
     SDP          = row["sdp"] as string;
     RemoteSDP    = row["remotesdp"] as string;
     //SIPDialogue.SwitchboardCallerDescription = (row["switchboardcallerdescription"] != null && row["switchboardcallerdescription"] != DBNull.Value) ? row["switchboardcallerdescription"] as string : null;
     //SIPDialogue.SwitchboardDescription = (row["switchboarddescription"] != null && row["switchboarddescription"] != DBNull.Value) ? row["switchboarddescription"] as string : null;
     SIPDialogue.SwitchboardOwner = (row["switchboardowner"] != null && row["switchboardowner"] != DBNull.Value)
         ? row["switchboardowner"] as string
         : null;
     SIPDialogue.SwitchboardLineName =
         (row["switchboardlinename"] != null && row["switchboardlinename"] != DBNull.Value)
             ? row["switchboardlinename"] as string
             : null;
     SIPDialogue.CRMPersonName = (row["crmpersonname"] != null && row["crmpersonname"] != DBNull.Value)
         ? row["crmpersonname"] as string
         : null;
     SIPDialogue.CRMCompanyName = (row["crmcompanyname"] != null && row["crmcompanyname"] != DBNull.Value)
         ? row["crmcompanyname"] as string
         : null;
     SIPDialogue.CRMPictureURL = (row["crmpictureurl"] != null && row["crmpictureurl"] != DBNull.Value)
         ? row["crmpictureurl"] as string
         : null;
 }
Пример #10
0
        public void DefaultSecureWebSocketPortUnitTest()
        {
            logger.LogDebug("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name);
            logger.BeginScope(System.Reflection.MethodBase.GetCurrentMethod().Name);

            SIPURI uri = SIPURI.ParseSIPURI("sip:user@[2001:730:3ec2::10]:443;transport=wss?Replaces=xyz");

            Assert.Equal(SIPProtocolsEnum.wss, uri.Protocol);
            Assert.True(uri.IsDefaultPort());

            logger.LogDebug("-----------------------------------------");
        }
Пример #11
0
        public void NonDefaultUdpPortUnitTest()
        {
            logger.LogDebug("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name);
            logger.BeginScope(System.Reflection.MethodBase.GetCurrentMethod().Name);

            SIPURI uri = SIPURI.ParseSIPURI("sip:user@[2001:730:3ec2::10]:5080?Replaces=xyz");

            Assert.Equal(SIPProtocolsEnum.udp, uri.Protocol);
            Assert.False(uri.IsDefaultPort());

            logger.LogDebug("-----------------------------------------");
        }
Пример #12
0
        public void InvalidIPv6UriThrowUnitTest()
        {
            logger.LogDebug("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name);
            logger.BeginScope(System.Reflection.MethodBase.GetCurrentMethod().Name);

            SIPURI ipv6Uri = new SIPURI(SIPSchemesEnum.sip, IPAddress.IPv6Loopback, 6060);

            Assert.Throws <SIPValidationException>(() => SIPURI.ParseSIPURI("sip:user1@2a00:1450:4005:800::2004"));
            Assert.Throws <SIPValidationException>(() => SIPURI.ParseSIPURI("sip:user1@:::ffff:127.0.0.1"));

            logger.LogDebug("-----------------------------------------");
        }
Пример #13
0
            public void AckRecognitionUnitTest()
            {
                SIPTransport clientTransport = null;
                SIPTransport serverTransport = null;

                try
                {
                    SIPTransactionEngine clientEngine   = new SIPTransactionEngine();   // Client side of the INVITE.
                    SIPEndPoint          clientEndPoint = new SIPEndPoint(SIPProtocolsEnum.udp, new IPEndPoint(IPAddress.Loopback, 12013));
                    clientTransport = new SIPTransport(MockSIPDNSManager.Resolve, clientEngine, new SIPUDPChannel(clientEndPoint.GetIPEndPoint()), false);
                    SetTransportTraceEvents(clientTransport);

                    SIPTransactionEngine serverEngine      = new SIPTransactionEngine(); // Server side of the INVITE.
                    UASInviteTransaction serverTransaction = null;
                    SIPEndPoint          serverEndPoint    = new SIPEndPoint(new IPEndPoint(IPAddress.Loopback, 12014));
                    serverTransport = new SIPTransport(MockSIPDNSManager.Resolve, serverEngine, new SIPUDPChannel(serverEndPoint.GetIPEndPoint()), false);
                    SetTransportTraceEvents(serverTransport);
                    serverTransport.SIPTransportRequestReceived += (localEndPoint, remoteEndPoint, sipRequest) =>
                    {
                        Console.WriteLine("Server Transport Request In: " + sipRequest.Method + ".");
                        serverTransaction = serverTransport.CreateUASTransaction(sipRequest, remoteEndPoint, localEndPoint, null);
                        SetTransactionTraceEvents(serverTransaction);
                        serverTransaction.GotRequest(localEndPoint, remoteEndPoint, sipRequest);
                    };

                    SIPURI     dummyURI      = SIPURI.ParseSIPURI("sip:dummy@" + serverEndPoint);
                    SIPRequest inviteRequest = GetDummyINVITERequest(dummyURI);
                    inviteRequest.LocalSIPEndPoint = clientTransport.GetDefaultTransportContact(SIPProtocolsEnum.udp);

                    // Send the invite to the server side.
                    UACInviteTransaction clientTransaction = new UACInviteTransaction(clientTransport, inviteRequest, serverEndPoint, clientEndPoint, null);
                    SetTransactionTraceEvents(clientTransaction);
                    clientEngine.AddTransaction(clientTransaction);
                    clientTransaction.SendInviteRequest(serverEndPoint, inviteRequest);

                    Thread.Sleep(500);

                    Assert.IsTrue(clientTransaction.TransactionState == SIPTransactionStatesEnum.Completed, "Client transaction in incorrect state.");
                    Assert.IsTrue(serverTransaction.TransactionState == SIPTransactionStatesEnum.Confirmed, "Server transaction in incorrect state.");
                }
                finally
                {
                    if (clientTransport != null)
                    {
                        clientTransport.Shutdown();
                    }

                    if (serverTransport != null)
                    {
                        serverTransport.Shutdown();
                    }
                }
            }
Пример #14
0
        public void NoMangleSameAddressUnitTest()
        {
            logger.LogDebug("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name);
            logger.BeginScope(System.Reflection.MethodBase.GetCurrentMethod().Name);

            SIPURI uri     = SIPURI.ParseSIPURI("sip:[email protected]:5060?Replaces=xyz");
            SIPURI mangled = SIPURI.Mangle(uri, IPSocket.Parse("192.168.0.50:5060"));

            Assert.Null(mangled);

            logger.LogDebug("-----------------------------------------");
        }
Пример #15
0
        public void ParamsInUserPortionURITest()
        {
            logger.LogDebug("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name);
            logger.BeginScope(System.Reflection.MethodBase.GetCurrentMethod().Name);

            SIPURI sipURI = SIPURI.ParseSIPURI("sip:C=on;[email protected]:5060;lr");

            Assert.True("C=on;t=DLPAN" == sipURI.User, "SIP user portion parsed incorrectly.");
            Assert.True("10.0.0.1:5060" == sipURI.Host, "SIP host portion parsed incorrectly.");

            logger.LogDebug("-----------------------------------------");
        }
Пример #16
0
        public void ParseHostOnlyURIUnitTest()
        {
            logger.LogDebug("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name);
            logger.BeginScope(System.Reflection.MethodBase.GetCurrentMethod().Name);

            SIPURI sipURI = SIPURI.ParseSIPURI("sip:sip.domain.com");

            Assert.True(sipURI.User == null, "The SIP URI User was not parsed correctly.");
            Assert.True(sipURI.Host == "sip.domain.com", "The SIP URI Host was not parsed correctly.");

            logger.LogDebug("-----------------------------------------");
        }
Пример #17
0
        public void UriWithSameParamsInDifferentOrderURIUnitTest()
        {
            logger.LogDebug("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name);
            logger.BeginScope(System.Reflection.MethodBase.GetCurrentMethod().Name);

            SIPURI sipURI1 = SIPURI.ParseSIPURI("sip:[email protected];key2=value2;key1=value1");
            SIPURI sipURI2 = SIPURI.ParseSIPURI("sip:[email protected];key1=value1;key2=value2");

            Assert.Equal(sipURI1, sipURI2);

            logger.LogDebug("-----------------------------------------");
        }
Пример #18
0
        public void NotEqualOneNullURIUnitTest()
        {
            logger.LogDebug("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name);
            logger.BeginScope(System.Reflection.MethodBase.GetCurrentMethod().Name);

            SIPURI sipURI1 = SIPURI.ParseSIPURI("sip:[email protected]");
            SIPURI sipURI2 = null;

            Assert.False(sipURI1 == sipURI2, "The SIP URIs were incorrectly found as equal.");

            logger.LogDebug("-----------------------------------------");
        }
Пример #19
0
        public void AreEqualWithHeadersURIUnitTest()
        {
            logger.LogDebug("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name);
            logger.BeginScope(System.Reflection.MethodBase.GetCurrentMethod().Name);

            SIPURI sipURI1 = SIPURI.ParseSIPURI("sip:[email protected];key1=value1;key2=value2?header1=value1&header2=value2");
            SIPURI sipURI2 = SIPURI.ParseSIPURI("sip:[email protected];key2=value2;key1=value1?header2=value2&header1=value1");

            Assert.True(sipURI1 == sipURI2, "The SIP URIs were not correctly identified as equal.");

            logger.LogDebug("-----------------------------------------");
        }
Пример #20
0
        public void UriWithParameterEqualityURIUnitTest()
        {
            logger.LogDebug("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name);
            logger.BeginScope(System.Reflection.MethodBase.GetCurrentMethod().Name);

            SIPURI sipURI1 = SIPURI.ParseSIPURI("sip:[email protected];key1=value1");
            SIPURI sipURI2 = SIPURI.ParseSIPURI("sip:[email protected];key1=value1");

            Assert.True(sipURI1 == sipURI2, "The SIP URIs did not have equal hash codes.");

            logger.LogDebug("-----------------------------------------");
        }
Пример #21
0
        public void ContactAsteriskURIUnitTest()
        {
            logger.LogDebug("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name);
            logger.BeginScope(System.Reflection.MethodBase.GetCurrentMethod().Name);

            SIPURI sipURI = SIPURI.ParseSIPURI("*");

            Assert.True(sipURI.User == null, "The SIP URI User was not parsed correctly.");
            Assert.True(sipURI.Host == "*", "The SIP URI Host was not parsed correctly.");

            logger.LogDebug("-----------------------------------------");
        }
Пример #22
0
        public void AreEqualIPAddressNoParamsURIUnitTest()
        {
            logger.LogDebug("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name);
            logger.BeginScope(System.Reflection.MethodBase.GetCurrentMethod().Name);

            SIPURI sipURI1 = SIPURI.ParseSIPURI("sip:[email protected]");
            SIPURI sipURI2 = SIPURI.ParseSIPURI("sip:[email protected]");

            Assert.True(sipURI1 == sipURI2, "The SIP URIs were not correctly found as equal.");

            logger.LogDebug("-----------------------------------------");
        }
Пример #23
0
        public static SIPRequest ParseSIPRequest(SIPMessage sipMessage)
        {
            string uriStr = null;

            try
            {
                SIPRequest sipRequest = new SIPRequest();
                sipRequest.LocalSIPEndPoint  = sipMessage.LocalSIPEndPoint;
                sipRequest.RemoteSIPEndPoint = sipMessage.RemoteSIPEndPoint;

                string statusLine = sipMessage.FirstLine;

                int firstSpacePosn = statusLine.IndexOf(" ");

                string method = statusLine.Substring(0, firstSpacePosn).Trim();
                sipRequest.Method = SIPMethods.GetMethod(method);
                if (sipRequest.Method == SIPMethodsEnum.UNKNOWN)
                {
                    sipRequest.UnknownMethod = method;
                    logger.Warn("Unknown SIP method received " + sipRequest.UnknownMethod + ".");
                }

                statusLine = statusLine.Substring(firstSpacePosn).Trim();
                int secondSpacePosn = statusLine.IndexOf(" ");

                if (secondSpacePosn != -1)
                {
                    uriStr = statusLine.Substring(0, secondSpacePosn);

                    sipRequest.URI        = SIPURI.ParseSIPURI(uriStr);
                    sipRequest.SIPVersion = statusLine.Substring(secondSpacePosn, statusLine.Length - secondSpacePosn)
                                            .Trim();
                    sipRequest.Header = SIPHeader.ParseSIPHeaders(sipMessage.SIPHeaders);
                    sipRequest.Body   = sipMessage.Body;

                    return(sipRequest);
                }
                else
                {
                    throw new SIPValidationException(SIPValidationFieldsEnum.Request, "URI was missing on Request.");
                }
            }
            catch (SIPValidationException)
            {
                throw;
            }
            catch (Exception excp)
            {
                logger.Error("Exception parsing SIP Request. " + excp.Message);
                logger.Error(sipMessage.RawMessage);
                throw new SIPValidationException(SIPValidationFieldsEnum.Request, "Unknown error parsing SIP Request");
            }
        }
Пример #24
0
        public void ParseWithHeaderURIUnitTest()
        {
            Console.WriteLine("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name);

            SIPURI sipURI = SIPURI.ParseSIPURI("sip:[email protected]?header=1234");

            Assert.IsTrue(sipURI.User == "user", "The SIP URI User was not parsed correctly.");
            Assert.IsTrue(sipURI.Host == "sip.domain.com", "The SIP URI Host was not parsed correctly.");
            Assert.IsTrue(sipURI.Headers.Get("header") == "1234", "The SIP URI Header was not parsed correctly.");

            Console.WriteLine("-----------------------------------------");
        }
Пример #25
0
        public void SwitchTagParameterUnitTest()
        {
            Console.WriteLine("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name);

            SIPURI sipURI = SIPURI.ParseSIPURI("sip:[email protected];switchtag=119651");

            Assert.IsTrue("joebloggs" == sipURI.User, "SIP user portion parsed incorrectly.");
            Assert.IsTrue("sip.mysipswitch.com" == sipURI.Host, "SIP host portion parsed incorrectly.");
            Assert.IsTrue("119651" == sipURI.Parameters.Get("switchtag"), "switchtag parameter parsed incorrectly.");

            Console.WriteLine("-----------------------------------------");
        }
Пример #26
0
        public void NoMangleIPv6UnitTest()
        {
            logger.LogDebug("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name);
            logger.BeginScope(System.Reflection.MethodBase.GetCurrentMethod().Name);

            SIPURI uri     = SIPURI.ParseSIPURI("sip:user@[2001:730:3ec2::10]:5060?Replaces=xyz");
            SIPURI mangled = SIPURI.Mangle(uri, IPSocket.Parse("67.222.131.147:5060"));

            Assert.Null(mangled);

            logger.LogDebug("-----------------------------------------");
        }
Пример #27
0
        public void ParseWithHeaderURIUnitTest()
        {
            logger.LogDebug("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name);
            logger.BeginScope(System.Reflection.MethodBase.GetCurrentMethod().Name);

            SIPURI sipURI = SIPURI.ParseSIPURI("sip:[email protected]?header=1234");

            Assert.True(sipURI.User == "user", "The SIP URI User was not parsed correctly.");
            Assert.True(sipURI.Host == "sip.domain.com", "The SIP URI Host was not parsed correctly.");
            Assert.True(sipURI.Headers.Get("header") == "1234", "The SIP URI Header was not parsed correctly.");

            logger.LogDebug("-----------------------------------------");
        }
Пример #28
0
        public void ParseWithParamURIUnitTest()
        {
            Console.WriteLine("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name);

            SIPURI sipURI = SIPURI.ParseSIPURI("sip:[email protected];param=1234");

            Assert.True(sipURI.User == "user", "The SIP URI User was not parsed correctly.");
            Assert.True(sipURI.Host == "sip.domain.com", "The SIP URI Host was not parsed correctly.");
            Assert.True(sipURI.Parameters.Get("PARAM") == "1234", "The SIP URI Parameter was not parsed correctly.");
            Assert.True(sipURI.ToString() == "sip:[email protected];param=1234", "The SIP URI was not correctly to string'ed.");

            Console.WriteLine("-----------------------------------------");
        }
Пример #29
0
            public void GetAsXMLStringUnitTest()
            {
                Console.WriteLine("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name);

                SIPEventDialogInfo dialogInfo =
                    new SIPEventDialogInfo(0, SIPEventDialogInfoStateEnum.full, SIPURI.ParseSIPURI("sip:[email protected]"));

                dialogInfo.DialogItems.Add(new SIPEventDialog("abcde", "terminated", 487, SIPEventDialogStateEvent.Cancelled, 2));

                Console.WriteLine(dialogInfo.ToXMLText());

                Console.WriteLine("-----------------------------------------");
            }
Пример #30
0
            public void DuplicateTransactionUnitTest()
            {
                SIPTransactionEngine clientEngine = new SIPTransactionEngine();

                SIPURI     dummyURI      = SIPURI.ParseSIPURI("sip:[email protected]");
                SIPRequest inviteRequest = GetDummyINVITERequest(dummyURI);

                SIPEndPoint          dummySIPEndPoint  = new SIPEndPoint(new IPEndPoint(IPAddress.Loopback, 1234));
                UACInviteTransaction clientTransaction = new UACInviteTransaction(new SIPTransport(MockSIPDNSManager.Resolve, null), inviteRequest, dummySIPEndPoint, dummySIPEndPoint, null);

                clientEngine.AddTransaction(clientTransaction);
                clientEngine.AddTransaction(clientTransaction);
            }