3internal static class IPv6AddressHelper
12 int item = tuple.longestSequenceStart;
13 int item2 = tuple.longestSequenceLength;
18 for (
int i = 0; i < 8; i++)
24 bool flag2 = (span[i] >> 8).TryFormat(span2.
Slice(num), out charsWritten);
27 flag2 = (span[i] & 0xFF).TryFormat(span2.
Slice(num), out charsWritten);
30 flag2 = (span[i + 1] >> 8).TryFormat(span2.
Slice(num), out charsWritten);
33 flag2 = (span[i + 1] & 0xFF).TryFormat(span2.
Slice(num), out charsWritten);
41 if (
item <= i && item2 == 8)
46 if (
item > i || i >= item2)
52 bool flag2 = span[i].TryFormat(span2.
Slice(num), out charsWritten,
"x");
62 if (numbers[0] == 0 && numbers[1] == 0 && numbers[2] == 0 && numbers[3] == 0 && numbers[4] == 0)
64 if (numbers[5] != 0 || numbers[6] != 0 || numbers[7] != 1)
66 if (numbers[6] == 32512 && numbers[7] == 1)
70 return numbers[5] == ushort.MaxValue;
95 for (i =
start; i < end; i++)
108 num3 = name[i] <=
'9';
181 if (i > 0 && name[i - 1] ==
':')
199 if (validateStrictAddress)
203 if (num == 0 || flag3)
217 if (flag3 && (num2 < 1 || num2 > 2))
221 int num4 = 8 + (flag3 ? 1 : 0);
222 if (!flag4 && num2 <= 4 && (flag ? (num < num4) : (num == num4)))
234 internal unsafe
static bool IsValid(
char* name,
int start, ref
int end)
244 for (
int i = 0; i < numbers.
Length; i++)
269 if (numbers[0] == 0 && numbers[1] == 0 && numbers[2] == 0 && numbers[3] == 0 && numbers[6] != 0)
271 if (numbers[4] == 0 && (numbers[5] == 0 || numbers[5] == ushort.MaxValue))
275 if (numbers[4] == ushort.MaxValue && numbers[5] == 0)
282 return numbers[5] == 24318;
294 if (address[
start] ==
'[')
299 while (i < address.
Length && address[i] !=
']')
306 numbers[num2++] = (ushort)num;
310 for (i++; i < address.Length && address[i] !=
']' && address[i] !=
'/'; i++)
314 for (; i < address.Length && address[i] !=
']'; i++)
320 numbers[num2++] = (ushort)num;
323 if (address[i] ==
':')
328 else if (num3 < 0 && num2 < 6)
332 for (
int j = i; j < address.Length && address[j] !=
']' && address[j] !=
':' && address[j] !=
'%' && address[j] !=
'/' && j < i + 4; j++)
334 if (address[j] ==
'.')
336 for (; j < address.Length && address[j] !=
']' && address[j] !=
'/' && address[j] !=
'%'; j++)
340 numbers[num2++] = (ushort)(num >> 16);
341 numbers[num2++] = (ushort)num;
353 numbers[num2++] = (ushort)num;
356 for (i++; address[i] !=
']'; i++)
358 num4 = num4 * 10 + (address[i] - 48);
368 numbers[num2++] = (ushort)num;
378 for (
int num7 = num2 - num3; num7 > 0; num7--)
380 numbers[num5--] = numbers[num6];
static unsafe bool IsValid(char *name, int start, ref int end, bool allowIPv6, bool notImplicitFile, bool unknownScheme)
static int ParseHostNumber(ReadOnlySpan< char > str, int start, int end)
static string ParseCanonicalName(string str, int start, ref bool isLoopback, ref string scopeId)
static unsafe bool InternalIsValid(char *name, int start, ref int end, bool validateStrictAddress)
static void Parse(ReadOnlySpan< char > address, Span< ushort > numbers, int start, ref string scopeId)
static bool IsLoopback(ReadOnlySpan< ushort > numbers)
static unsafe bool IsValid(char *name, int start, ref int end)
static int longestSequenceStart
static bool ShouldHaveIpv4Embedded(ReadOnlySpan< ushort > numbers)
static int int longestSequenceLength FindCompressionRange(ReadOnlySpan< ushort > numbers)
static int FromHex(char digit)
static bool IsHexDigit(char character)
ReadOnlySpan< T > Slice(int start)
Span< T > Slice(int start)