Пример #1
0
        private bool TryReadQuotedValue(out int startIndex, out int length)
        {
            startIndex = -1;
            length     = 0;

            if (remainingChars == StringSegment.Empty)
            {
                return(false);
            }

            startIndex = SipCharacters.IndexOfNonWhitespace(remainingChars);

            if (startIndex < 0)
            {
                return(false);
            }

            if (remainingChars[startIndex] != QuoteChar)
            {
                return(false);
            }

            var endQuoteCharIndex = SipCharacters.IndexOfNonEscaped(remainingChars, QuoteChar, startIndex + 1);

            if (endQuoteCharIndex < 0)
            {
                return(false);
            }

            length = endQuoteCharIndex - startIndex;
            return(true);
        }
        private static bool TryReadQuotedDisplayName(StringSegment chars, out int startIndex, out int length)
        {
            startIndex = -1;
            length     = 0;

            if (chars == StringSegment.Empty)
            {
                return(false);
            }

            startIndex = SipCharacters.IndexOfNonWhitespace(chars);

            if (startIndex < 0)
            {
                return(false);
            }

            if (chars[startIndex] != QuoteChar)
            {
                return(false);
            }

            var endQuoteCharIndex = SipCharacters.IndexOfNonEscaped(chars, QuoteChar, startIndex + 1);

            if (endQuoteCharIndex < 0)
            {
                return(false);
            }

            length = endQuoteCharIndex - startIndex;
            return(true);
        }
Пример #3
0
        private static StringSegment ReadSequenceNumber(StringSegment chars)
        {
            var separatorIndex = SipCharacters.IndexOfWhitespace(chars);

            if (separatorIndex < 0)
            {
                return(chars);
            }

            return(chars.Subsegment(0, separatorIndex));
        }
        private static bool IsUriValid(StringSegment chars)
        {
            var uri = chars;

            if (IsInUriBrackets(chars))
            {
                uri = chars.Subsegment(1, chars.Length - 2);
            }

            return(uri != StringSegment.Empty && SipCharacters.IsValidUri(uri));
        }
Пример #5
0
        private static StringSegment ReadProtocol(StringSegment chars)
        {
            var spaceIndex = SipCharacters.IndexOfWhitespace(chars);

            if (spaceIndex == -1)
            {
                return(chars);
            }

            return(chars.Subsegment(0, spaceIndex));
        }
Пример #6
0
        private static bool IsProtocolValid(StringSegment protocol)
        {
            if (protocol == StringSegment.Empty)
            {
                return(false);
            }

            if (!SipCharacters.IsValidToken(protocol))
            {
                return(false);
            }

            return(true);
        }
Пример #7
0
        private bool IsValidName()
        {
            if (currentName == StringSegment.Empty)
            {
                return(false);
            }

            if (!SipCharacters.IsValidToken(currentName))
            {
                return(false);
            }

            return(true);
        }
        private static bool IsDisplayNameValid(StringSegment chars)
        {
            if (chars == StringSegment.Empty)
            {
                return(true);
            }

            if (SipCharacters.IsValidQuoted(chars))
            {
                return(true);
            }

            if (SipCharacters.IsValidTokenExcludeWhitespase(chars))
            {
                return(true);
            }

            return(false);
        }
Пример #9
0
        private bool IsValidValue()
        {
            if (isSingleName)
            {
                return(true);
            }

            if (currentValue == StringSegment.Empty)
            {
                return(false);
            }

            if (SipCharacters.IsValidQuoted(currentValue))
            {
                return(true);
            }

            if (!SipCharacters.IsValidToken(currentValue))
            {
                return(false);
            }

            return(true);
        }
Пример #10
0
 private static bool IsMethodValid(ReadOnlyMemory <char> chars)
 {
     return(!chars.IsEmpty && SipCharacters.IsValidToken(chars.Span));
 }
Пример #11
0
 private static bool IsSequenceNumberValid(StringSegment chars)
 {
     return(chars.Length > 0 && SipCharacters.IsDigits(chars));
 }
Пример #12
0
 private static bool IsHeaderNameValid(ReadOnlyMemory <char> chars)
 {
     return(!chars.IsEmpty && SipCharacters.IsValidField(chars.Span));
 }
Пример #13
0
 private static bool IsUriValid(ReadOnlyMemory <byte> bytes)
 {
     return(!bytes.IsEmpty && SipCharacters.IsValidUri(bytes.Span));
 }
Пример #14
0
 private static bool IsReasonPhraseValid(ReadOnlyMemory <byte> bytes)
 {
     return(!SipCharacters.HasCROrLF(bytes.Span));
 }
Пример #15
0
 private static bool IsStatusCodeValid(ReadOnlyMemory <byte> bytes)
 {
     return(bytes.Length == StatusCodeLenght && SipCharacters.IsDigits(bytes.Span));
 }
Пример #16
0
 private static bool IsMethodValid(ReadOnlyMemory <byte> bytes)
 {
     return(!bytes.IsEmpty && SipCharacters.IsValidToken(bytes.Span));
 }
Пример #17
0
 private static bool IsHostValid(StringSegment host)
 {
     return(host != StringSegment.Empty && SipCharacters.IsValidHost(host));
 }
Пример #18
0
 private static bool IsMethodValid(StringSegment chars)
 {
     return(chars.Length > 0 && SipCharacters.IsValidToken(chars));
 }
Пример #19
0
 private static bool IsUriValid(ReadOnlyMemory <char> chars)
 {
     return(!chars.IsEmpty && SipCharacters.IsValidUri(chars.Span));
 }