Example #1
0
 public SIPEventPresence(SIPURI entity)
 {
     Entity = entity.CopyOf();
 }
Example #2
0
 public static SIPDNSLookupResult Resolve(SIPURI sipURI, bool async)
 {
     // This assumes the input SIP URI has an IP address as the host!
     return(new SIPDNSLookupResult(sipURI, new SIPEndPoint(IPSocket.ParseSocketString(sipURI.Host))));
 }
Example #3
0
 public SIPParameterlessURI(SIPSchemesEnum scheme, string host, string user)
 {
     m_uri        = new SIPURI(user, host, null);
     m_uri.Scheme = scheme;
 }
Example #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 ParseFromXMLStringDialogWithParticipantsUnitTest()
            {
                Console.WriteLine("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name);

                string eventDialogInfoStr = "<?xml version='1.0' encoding='utf-16'?>" +
                                            "<dialog-info version='1' state='full' entity='sip:[email protected]' xmlns='urn:ietf:params:xml:ns:dialog-info'>" +
                                            " <dialog id='as7d900as8' call-id='a84b4c76e66710' local-tag='1928301774' direction='initiator'>" +
                                            "  <state event='remote-bye' code='486'>terminated</state>" +
                                            "  <duration>13</duration>" +
                                            "  <local>" +
                                            "   <identity>sip:[email protected];user=phone</identity>" +
                                            "   <cseq>2</cseq>" +
                                            "  </local>" +
                                            "  <remote>" +
                                            "   <identity display-name='Joe Bloggs'>sip:[email protected]</identity>" +
                                            "   <target uri='sip:[email protected]:5070' />" +
                                            "   <cseq>1</cseq>" +
                                            "  </remote>" +
                                            " </dialog>" +
                                            "</dialog-info>";

                SIPEventDialogInfo dialogInfo = SIPEventDialogInfo.Parse(eventDialogInfoStr);

                Assert.NotNull(dialogInfo.DialogItems[0].LocalParticipant, "The parsed event dialog local participant was not correct.");
                Assert.NotNull(dialogInfo.DialogItems[0].RemoteParticipant, "The parsed event dialog remote participant was not correct.");
                Assert.IsTrue(dialogInfo.DialogItems[0].LocalParticipant.URI == SIPURI.ParseSIPURI("sip:[email protected];user=phone"), "The local participant URI was incorrect.");
                Assert.IsTrue(dialogInfo.DialogItems[0].LocalParticipant.CSeq == 2, "The local participant CSeq was incorrect.");
                Assert.IsTrue(dialogInfo.DialogItems[0].RemoteParticipant.URI == SIPURI.ParseSIPURI("sip:[email protected]"), "The remote participant URI was incorrect.");
                Assert.IsTrue(dialogInfo.DialogItems[0].RemoteParticipant.DisplayName == "Joe Bloggs", "The remote participant display name was incorrect.");
                Assert.IsTrue(dialogInfo.DialogItems[0].RemoteParticipant.TargetURI == SIPURI.ParseSIPURI("sip:[email protected]:5070"), "The remote participant target URI was incorrect.");
                Assert.IsTrue(dialogInfo.DialogItems[0].RemoteParticipant.CSeq == 1, "The remote participant CSeq was incorrect.");

                Console.WriteLine(dialogInfo.ToXMLText());

                Console.WriteLine("-----------------------------------------");
            }
Example #6
0
 public SIPParameterlessURI(SIPURI sipURI)
 {
     m_uri = sipURI;
 }
 public SIPEventDialogInfo(int version, SIPEventDialogInfoStateEnum state, SIPURI entity)
 {
     Version = version;
     State   = state;
     Entity  = entity.CopyOf();
 }
            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("-----------------------------------------");
            }
Example #9
0
 public static bool AreEqual(SIPURI uri1, SIPURI uri2)
 {
     return(uri1 == uri2);
 }
Example #10
0
        public static SIPURI ParseSIPURI(string uri)
        {
            try
            {
                SIPURI sipURI = new SIPURI();

                if (uri == null || uri.Trim().Length == 0)
                {
                    throw new SIPValidationException(SIPValidationFieldsEnum.URI, "A SIP URI cannot be parsed from an empty string.");
                }
                else
                {
                    if (uri == m_sipRegisterRemoveAll)
                    {
                        sipURI.Host = m_sipRegisterRemoveAll;
                    }
                    else
                    {
                        int colonPosn = uri.IndexOf(SCHEME_ADDR_SEPARATOR);

                        if (colonPosn == -1)
                        {
                            throw new SIPValidationException(SIPValidationFieldsEnum.URI, "SIP URI did not contain compulsory colon");
                        }
                        else
                        {
                            try
                            {
                                sipURI.Scheme = SIPSchemesType.GetSchemeType(uri.Substring(0, colonPosn));
                            }
                            catch
                            {
                                throw new SIPValidationException(SIPValidationFieldsEnum.URI, SIPResponseStatusCodesEnum.UnsupportedURIScheme, "SIP scheme " + uri.Substring(0, colonPosn) + " was not understood");
                            }

                            string uriHostPortion  = uri.Substring(colonPosn + 1);
                            int    ampPosn         = uriHostPortion.IndexOf(USER_HOST_SEPARATOR);
                            int    paramHeaderPosn = -1;
                            if (ampPosn != -1)
                            {
                                paramHeaderPosn = uriHostPortion.IndexOfAny(new char[] { PARAM_TAG_DELIMITER, HEADER_START_DELIMITER }, ampPosn);
                            }
                            else
                            {
                                // Host only SIP URI.
                                paramHeaderPosn = uriHostPortion.IndexOfAny(new char[] { PARAM_TAG_DELIMITER, HEADER_START_DELIMITER });
                            }

                            if (ampPosn != -1 && paramHeaderPosn != -1)
                            {
                                sipURI.User = uriHostPortion.Substring(0, ampPosn);
                                sipURI.Host = uriHostPortion.Substring(ampPosn + 1, paramHeaderPosn - ampPosn - 1);
                                string paramsAndHeaders = uriHostPortion.Substring(paramHeaderPosn);

                                sipURI.ParseParamsAndHeaders(paramsAndHeaders);
                            }
                            else if (ampPosn == -1 && paramHeaderPosn == 0)
                            {
                                throw new SIPValidationException(SIPValidationFieldsEnum.URI, "No Host portion in SIP URI");
                            }
                            else if (ampPosn == -1 && paramHeaderPosn != -1)
                            {
                                sipURI.Host = uriHostPortion.Substring(0, paramHeaderPosn);

                                string paramsAndHeaders = uriHostPortion.Substring(paramHeaderPosn);

                                sipURI.ParseParamsAndHeaders(paramsAndHeaders);
                            }
                            else if (ampPosn != -1)
                            {
                                sipURI.User = uriHostPortion.Substring(0, ampPosn);
                                sipURI.Host = uriHostPortion.Substring(ampPosn + 1, uriHostPortion.Length - ampPosn - 1);
                            }
                            else
                            {
                                sipURI.Host = uriHostPortion;
                            }

                            if (sipURI.Host.IndexOfAny(m_invalidSIPHostChars) != -1)
                            {
                                throw new SIPValidationException(SIPValidationFieldsEnum.URI, "The SIP URI host portion contained an invalid character.");
                            }
                        }
                    }

                    return(sipURI);
                }
            }
            catch (SIPValidationException)
            {
                throw;
            }
            catch (Exception excp)
            {
                logger.Error("Exception ParseSIPURI (URI=" + uri + "). " + excp.Message);
                throw new SIPValidationException(SIPValidationFieldsEnum.URI, "Unknown error parsing SIP URI.");
            }
        }
        public bool Pending;                // If an aysnc lookup request is made this will be set to true if no immediate result is available.

        public SIPDNSLookupResult(SIPURI uri)
        {
            URI = uri;
        }
 public SIPDNSLookupResult(SIPURI uri, string lookupError)
 {
     URI         = uri;
     LookupError = lookupError;
 }
        private SIPProtocolsEnum GetRemoteTargetProtocol()
        {
            SIPURI dstURI = (RouteSet == null) ? RemoteTarget : RouteSet.TopRoute.URI;

            return(dstURI.Protocol);
        }