示例#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));
 }