Exemplo n.º 1
0
        public SIPUserField(string name, SIPURI uri, string paramsAndHeaders)
        {
            Name = name;
            URI = uri;

            Parameters = new SIPParameters(paramsAndHeaders, PARAM_TAG_DELIMITER);
        }
Exemplo n.º 2
0
        public SIPParameters CopyOf()
        {
            SIPParameters copy = new SIPParameters();

            copy.TagDelimiter = this.TagDelimiter;
            copy.m_dictionary = (this.m_dictionary != null) ? new Dictionary <string, string>(this.m_dictionary) : new Dictionary <string, string>();
            return(copy);
        }
Exemplo n.º 3
0
            public void GetHashCodeDiffOrderEqualityUnittest()
            {
                Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name);

                string        testParamStr1 = ";lr;server=hippo;ftag=12345";
                SIPParameters testParam1    = new SIPParameters(testParamStr1, ';');

                string        testParamStr2 = "ftag=12345;lr;server=hippo;";
                SIPParameters testParam2    = new SIPParameters(testParamStr2, ';');

                Assert.IsTrue(testParam1.GetHashCode() == testParam2.GetHashCode(), "The parameters had different hashcode values.");
            }
Exemplo n.º 4
0
            public void EmptyValueParametersUnittest()
            {
                Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name);

                string        testParamStr1 = ";emptykey;Server=hippo;FTag=12345";
                SIPParameters testParam1    = new SIPParameters(testParamStr1, ';');

                Console.WriteLine("Parameter 1:" + testParam1.ToString());

                Assert.IsTrue(testParam1.Has("emptykey"), "The empty parameter \"emptykey\" was not correctly extracted from the paramter string.");
                Assert.IsTrue(Regex.Match(testParam1.ToString(), "emptykey").Success, "The emptykey name was not in the output parameter string.");
            }
Exemplo n.º 5
0
            public void RouteParamExtractTest()
            {
                Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name);

                string        routeParam       = ";lr;server=hippo";
                SIPParameters serverParam      = new SIPParameters(routeParam, ';');
                string        serverParamValue = serverParam.Get("server");

                Console.WriteLine("Parameter string=" + serverParam.ToString() + ".");
                Console.WriteLine("The server parameter is=" + serverParamValue + ".");

                Assert.IsTrue(serverParamValue == "hippo", "The server parameter was not correctly extracted.");
            }
Exemplo n.º 6
0
            public void QuotedStringParamExtractTest()
            {
                Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name);

                string        methodsParam      = ";methods=\"INVITE, MESSAGE, INFO, SUBSCRIBE, OPTIONS, BYE, CANCEL, NOTIFY, ACK, REFER\"";
                SIPParameters serverParam       = new SIPParameters(methodsParam, ';');
                string        methodsParamValue = serverParam.Get("methods");

                Console.WriteLine("Parameter string=" + serverParam.ToString() + ".");
                Console.WriteLine("The methods parameter is=" + methodsParamValue + ".");

                Assert.IsTrue(methodsParamValue == "\"INVITE, MESSAGE, INFO, SUBSCRIBE, OPTIONS, BYE, CANCEL, NOTIFY, ACK, REFER\"", "The method parameter was not correctly extracted.");
            }
Exemplo n.º 7
0
            public void GetHashCodeDiffValueCaseEqualityUnittest()
            {
                Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name);

                string        testParamStr1 = ";LR;Server=hippo;FTag=12345";
                SIPParameters testParam1    = new SIPParameters(testParamStr1, ';');

                Console.WriteLine("Parameter 1:" + testParam1.ToString());

                string        testParamStr2 = "ftag=12345;lr;server=HiPPo;";
                SIPParameters testParam2    = new SIPParameters(testParamStr2, ';');

                Console.WriteLine("Parameter 2:" + testParam2.ToString());

                Assert.IsTrue(testParam1.GetHashCode() != testParam2.GetHashCode(), "The parameters had different hashcode values.");
            }
Exemplo n.º 8
0
        private void ParseParamsAndHeaders(string paramsAndHeaders)
        {
            if (paramsAndHeaders != null && paramsAndHeaders.Trim().Length > 0)
            {
                int headerDelimPosn = paramsAndHeaders.IndexOf(HEADER_START_DELIMITER);

                if (headerDelimPosn == -1)
                {
                    Parameters = new SIPParameters(paramsAndHeaders, PARAM_TAG_DELIMITER);
                }
                else
                {
                    Parameters = new SIPParameters(paramsAndHeaders.Substring(0, headerDelimPosn), PARAM_TAG_DELIMITER);
                    Headers    = new SIPParameters(paramsAndHeaders.Substring(headerDelimPosn + 1), HEADER_TAG_DELIMITER);
                }
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Reverses The SIPEndPoint.ToString() method.
        /// </summary>
        /// <param name="serialisedSIPEndPoint">The serialised SIP end point MUST be in the form protocol:socket[;connid=abcd].
        /// Valid examples are udp:10.0.0.1:5060 and ws:10.0.0.1:5060;connid=abcd. An invalid example is 10.0.0.1:5060.</param>
        private static SIPEndPoint ParseSerialisedSIPEndPoint(string serialisedSIPEndPoint)
        {
            string channelID    = null;
            string connectionID = null;
            string endPointStr  = null;
            string protcolStr   = serialisedSIPEndPoint.Substring(0, serialisedSIPEndPoint.IndexOf(':'));

            if (serialisedSIPEndPoint.Contains(";"))
            {
                endPointStr = serialisedSIPEndPoint.Slice(':', ';');
                var paramsStr = serialisedSIPEndPoint.Substring(serialisedSIPEndPoint.IndexOf(';') + 1)?.Trim();

                var endPointParams = new SIPParameters(paramsStr, ';');

                if (endPointParams.Has(CHANNELID_ATTRIBUTE_NAME))
                {
                    channelID = endPointParams.Get(CHANNELID_ATTRIBUTE_NAME);
                }

                if (endPointParams.Has(CONNECTIONID_ATTRIBUTE_NAME))
                {
                    connectionID = endPointParams.Get(CONNECTIONID_ATTRIBUTE_NAME);
                }
            }
            else
            {
                endPointStr = serialisedSIPEndPoint.Substring(serialisedSIPEndPoint.IndexOf(':') + 1);
            }

            if (!IPSocket.TryParseIPEndPoint(endPointStr, out var endPoint))
            {
                throw new ApplicationException($"Could not parse SIPEndPoint host {endPointStr} as an IP end point.");
            }

            return(new SIPEndPoint(SIPProtocolsType.GetProtocolType(protcolStr), endPoint, channelID, connectionID));
        }
Exemplo n.º 10
0
        private void ParseParamsAndHeaders(string paramsAndHeaders)
        {
            if (paramsAndHeaders != null && paramsAndHeaders.Trim().Length > 0)
            {
                int headerDelimPosn = paramsAndHeaders.IndexOf(HEADER_START_DELIMITER);

                if (headerDelimPosn == -1)
                {
                    Parameters = new SIPParameters(paramsAndHeaders, PARAM_TAG_DELIMITER);
                }
                else
                {
                    Parameters = new SIPParameters(paramsAndHeaders.Substring(0, headerDelimPosn), PARAM_TAG_DELIMITER);
                    Headers = new SIPParameters(paramsAndHeaders.Substring(headerDelimPosn + 1), HEADER_TAG_DELIMITER);
                }
            }
        }
Exemplo n.º 11
0
 public static bool AreEqual(SIPParameters params1, SIPParameters params2)
 {
     return(params1 == params2);
 }
Exemplo n.º 12
0
        public SIPParameters CopyOf()
        {
            SIPParameters copy = new SIPParameters(ToString(), TagDelimiter);

            return(copy);
        }
        public SIPRegistrationUserAgent(
    SIPTransport sipTransport,
    SIPEndPoint outboundProxy,
    SIPEndPoint localEndPoint,
    SIPURI sipAccountAOR,
    string authUsername,
    string password,
    string realm,
    string registrarHost,
    SIPContactHeader contactHeader,
    int expiry,
    string owner,
    string adminMemberID,
    SIPMonitorLogDelegate logDelegate)
        {
            m_sipTransport = sipTransport;
            m_outboundProxy = outboundProxy;
            m_localEndPoint = localEndPoint;
            m_sipAccountAOR = sipAccountAOR;
            m_authUsername = authUsername;
            m_password = password;
            m_realm = realm;
            m_registrarHost = registrarHost;
            m_contactURI = contactHeader.ContactURI;
            m_contactParams = contactHeader.ContactParameters;
            m_expiry = (expiry >= REGISTER_MINIMUM_EXPIRY && expiry <= MAX_EXPIRY) ? expiry : DEFAULT_REGISTER_EXPIRY;
            m_owner = owner;
            m_adminMemberID = adminMemberID;
            m_callID = Guid.NewGuid().ToString();

            Log_External = logDelegate;
        }
Exemplo n.º 14
0
 public SIPParameters CopyOf()
 {
     SIPParameters copy = new SIPParameters(ToString(), TagDelimiter);
     return copy;
 }
Exemplo n.º 15
0
            public void EmptyValueParametersUnittest()
            {
                Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name);

                string testParamStr1 = ";emptykey;Server=hippo;FTag=12345";
                SIPParameters testParam1 = new SIPParameters(testParamStr1, ';');
                Console.WriteLine("Parameter 1:" + testParam1.ToString());

                Assert.IsTrue(testParam1.Has("emptykey"), "The empty parameter \"emptykey\" was not correctly extracted from the paramter string.");
                Assert.IsTrue(Regex.Match(testParam1.ToString(), "emptykey").Success, "The emptykey name was not in the output parameter string.");
            }
Exemplo n.º 16
0
            public void GetHashCodeDiffValueCaseEqualityUnittest()
            {
                Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name);

                string testParamStr1 = ";LR;Server=hippo;FTag=12345";
                SIPParameters testParam1 = new SIPParameters(testParamStr1, ';');
                Console.WriteLine("Parameter 1:" + testParam1.ToString());

                string testParamStr2 = "ftag=12345;lr;server=HiPPo;";
                SIPParameters testParam2 = new SIPParameters(testParamStr2, ';');
                Console.WriteLine("Parameter 2:" + testParam2.ToString());

                Assert.IsTrue(testParam1.GetHashCode() != testParam2.GetHashCode(), "The parameters had different hashcode values.");
            }
Exemplo n.º 17
0
            public void GetHashCodeEqualityUnittest()
            {
                Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name);

                string testParamStr1 = ";lr;server=hippo;ftag=12345";
                SIPParameters testParam1 = new SIPParameters(testParamStr1, ';');

                string testParamStr2 = ";lr;server=hippo;ftag=12345";
                SIPParameters testParam2 = new SIPParameters(testParamStr2, ';');

                Assert.IsTrue(testParam1.GetHashCode() == testParam2.GetHashCode(), "The parameters had different hashcode values.");
            }
Exemplo n.º 18
0
 public SIPReplacesHeader(string callid, string fromTag, string toTag, bool earlyOnly)
 {
     if (String.IsNullOrWhiteSpace(callid))
     {
         throw new SIPValidationException(SIPValidationFieldsEnum.ReplacesHeader, "The SIP Replaces header could not be initialized because given callId was null or empty.");
     }
     else
     {
         m_callId = callid;
         m_parameters = new SIPParameters("",PARAM_SEPARATOR);
         m_parameters.Set(FROM_TAG, fromTag);
         m_parameters.Set(TO_TAG, toTag);
         if (earlyOnly) m_parameters.Set(EARLY_FLAG, null);
     }
 }
Exemplo n.º 19
0
            public void QuotedStringParamExtractTest()
            {
                Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name);

                string methodsParam = ";methods=\"INVITE, MESSAGE, INFO, SUBSCRIBE, OPTIONS, BYE, CANCEL, NOTIFY, ACK, REFER\"";
                SIPParameters serverParam = new SIPParameters(methodsParam, ';');
                string methodsParamValue = serverParam.Get("methods");

                Console.WriteLine("Parameter string=" + serverParam.ToString() + ".");
                Console.WriteLine("The methods parameter is=" + methodsParamValue + ".");

                Assert.IsTrue(methodsParamValue == "\"INVITE, MESSAGE, INFO, SUBSCRIBE, OPTIONS, BYE, CANCEL, NOTIFY, ACK, REFER\"", "The method parameter was not correctly extracted.");
            }
Exemplo n.º 20
0
            public void RouteParamExtractTest()
            {
                Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name);

                string routeParam = ";lr;server=hippo";
                SIPParameters serverParam = new SIPParameters(routeParam, ';');
                string serverParamValue = serverParam.Get("server");

                Console.WriteLine("Parameter string=" + serverParam.ToString() + ".");
                Console.WriteLine("The server parameter is=" + serverParamValue + ".");

                Assert.IsTrue(serverParamValue == "hippo", "The server parameter was not correctly extracted.");
            }