private void ValidateExtensionHeaderUnnamedField(IpV6ExtensionHeader header, XElement headerField, ref int optionsIndex) { IpV6ExtensionHeaderOptions headerOptions = header as IpV6ExtensionHeaderOptions; string[] headerFieldShowParts = headerField.Show().Split(':'); string headerFieldShowName = headerFieldShowParts[0]; string headerFieldShowValue = headerFieldShowParts[1]; switch (headerFieldShowName) { case "Next header": headerField.AssertValue((byte)header.NextHeader.Value); break; case "Length": if (header.IsValid) { Assert.IsTrue(headerFieldShowValue.EndsWith(" (" + header.Length + " bytes)")); } break; case "Router alert": IpV6OptionRouterAlert routerAlert = (IpV6OptionRouterAlert)headerOptions.Options[optionsIndex++]; switch (headerFieldShowValue) { case " MLD (4 bytes)": Assert.AreEqual(IpV6RouterAlertType.MulticastListenerDiscovery, routerAlert.RouterAlertType); break; case " RSVP (4 bytes)": Assert.AreEqual(IpV6RouterAlertType.Rsvp, routerAlert.RouterAlertType); break; case " Unknown (4 bytes)": MoreAssert.IsInRange((ushort)IpV6RouterAlertType.ActiveNetwork, (ushort)IpV6RouterAlertType.NextStepsInSignalingNatFirewallLayerProtocol, (ushort)routerAlert.RouterAlertType); headerField.AssertValueInRange(0x05020002, 0x05020044); break; default: throw new InvalidOperationException("Invalid ipv6 header route Router alert value " + headerFieldShowValue); } break; case "Jumbo payload": IpV6OptionJumboPayload jumboPayload = (IpV6OptionJumboPayload)headerOptions.Options[optionsIndex++]; Assert.AreEqual(" " + jumboPayload.JumboPayloadLength + " (6 bytes)", headerFieldShowValue); break; default: throw new InvalidOperationException("Invalid ipv6 header unnamed field show name " + headerFieldShowName); } }
public static IpV6ExtensionHeaders NextIpV6ExtensionHeaders(this Random random, int count, IpV4Protocol?nextHeader, bool allowEncapsulatingSecurityPayload) { if (count == 0) { return(IpV6ExtensionHeaders.Empty); } IpV6ExtensionHeader[] headers = new IpV6ExtensionHeader[count]; for (int i = headers.Length - 1; i >= 0; --i) { headers[i] = random.NextIpV6ExtensionHeader(nextHeader, allowEncapsulatingSecurityPayload && i == headers.Length - 1); nextHeader = headers[i].Protocol; } return(new IpV6ExtensionHeaders(headers)); }
private void ValidateExtensionHeaderUnnamedField(IpV6ExtensionHeader header, XElement headerField) { int optionIndex = -1; ValidateExtensionHeaderUnnamedField(header, headerField, ref optionIndex); }