示例#1
0
 internal override bool EqualsData(IpV6Option other)
 {
     return(EqualsData(other as IpV6OptionIdentifierLocatorNetworkProtocolNonce));
 }
 internal override bool EqualsData(IpV6Option other)
 {
     return(EqualsData(other as IpV6OptionUnknown));
 }
示例#3
0
 internal override bool EqualsData(IpV6Option other)
 {
     return EqualsData(other as IpV6OptionUnknown);
 }
        private void CompareOptions(XElement field, ref int optionsIndex, IpV6Datagram ipV6Datagram, IpV6ExtensionHeaderOptions header)
        {
            foreach (var headerField in field.Fields())
            {
                switch (headerField.Name())
                {
                case "ipv6.nxt":
                    headerField.AssertNoFields();
                    headerField.AssertShowDecimal((byte)header.NextHeader);
                    break;

                case "ipv6.opt.length":
                    headerField.AssertNoFields();
                    headerField.AssertShowDecimal((header.Length - 8) / 8);
                    break;

                case "ipv6.opt":
                    foreach (XElement headerSubfield in headerField.Fields())
                    {
                        IpV6Option option           = header.Options[optionsIndex];
                        var        optionCalipso    = option as IpV6OptionCalipso;
                        var        optionQuickStart = option as IpV6OptionQuickStart;
                        switch (headerSubfield.Name())
                        {
                        case "ipv6.opt.type":
                            headerSubfield.AssertNoFields();
                            headerSubfield.AssertShowDecimal((byte)option.OptionType);
                            break;

                        case "ipv6.opt.length":
                            headerSubfield.AssertNoFields();
                            headerSubfield.AssertShowDecimal(option.Length - 2);
                            break;

                        case "ipv6.opt.tel":
                            headerSubfield.AssertNoFields();
                            IpV6OptionTunnelEncapsulationLimit optionTunnelEncapsulationLimit = (IpV6OptionTunnelEncapsulationLimit)option;
                            headerSubfield.AssertShowDecimal(optionTunnelEncapsulationLimit.TunnelEncapsulationLimit);
                            ++optionsIndex;
                            break;

                        case "ipv6.opt.rpl.flag":
                            IpV6OptionRoutingProtocolLowPowerAndLossyNetworks optionRoutingProtocolLowPowerAndLossyNetworks =
                                (IpV6OptionRoutingProtocolLowPowerAndLossyNetworks)option;
                            foreach (XElement optionSubfield in headerSubfield.Fields())
                            {
                                optionSubfield.AssertNoFields();
                                switch (optionSubfield.Name())
                                {
                                case "ipv6.opt.rpl.flag.o":
                                    optionSubfield.AssertShowDecimal(optionRoutingProtocolLowPowerAndLossyNetworks.Down);
                                    break;

                                case "ipv6.opt.rpl.flag.r":
                                    optionSubfield.AssertShowDecimal(optionRoutingProtocolLowPowerAndLossyNetworks.RankError);
                                    break;

                                case "ipv6.opt.rpl.flag.f":
                                    optionSubfield.AssertShowDecimal(optionRoutingProtocolLowPowerAndLossyNetworks.ForwardingError);
                                    break;

                                case "ipv6.opt.rpl.flag.rsv":
                                    optionSubfield.AssertShowDecimal(0);
                                    break;

                                case "ipv6.opt.rpl.instance_id":
                                    optionSubfield.AssertShowDecimal(
                                        optionRoutingProtocolLowPowerAndLossyNetworks.RoutingProtocolLowPowerAndLossyNetworksInstanceId);
                                    break;

                                case "ipv6.opt.rpl.sender_rank":
                                    optionSubfield.AssertShowDecimal(optionRoutingProtocolLowPowerAndLossyNetworks.SenderRank);
                                    break;

                                default:
                                    throw new InvalidOperationException("Invalid ipv6 option subfield " + optionSubfield.Name());
                                }
                            }
                            ++optionsIndex;
                            // TODO: change to break; after https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=10559 is fixed.
                            return;

                        case "ipv6.opt.calipso.doi":
                            headerSubfield.AssertNoFields();
                            headerSubfield.AssertShowDecimal((uint)optionCalipso.DomainOfInterpretation);
                            break;

                        case "ipv6.opt.calipso.cmpt.length":
                            headerSubfield.AssertNoFields();
                            headerSubfield.AssertShowDecimal(optionCalipso.CompartmentLength);
                            break;

                        case "ipv6.opt.calipso.sens_level":
                            headerSubfield.AssertNoFields();
                            headerSubfield.AssertShowDecimal(optionCalipso.SensitivityLevel);
                            break;

                        case "ipv6.opt.calipso.checksum":
                            headerSubfield.AssertNoFields();
                            headerSubfield.AssertShowDecimal(optionCalipso.Checksum);
                            break;

                        case "ipv6.opt.calipso.cmpt_bitmap":
                            headerSubfield.AssertNoFields();
                            headerSubfield.AssertValue(optionCalipso.CompartmentBitmap);
                            ++optionsIndex;
                            break;

                        case "ipv6.opt.router_alert":
                            headerSubfield.AssertNoFields();
                            var optionRouterAlert = (IpV6OptionRouterAlert)option;
                            headerSubfield.AssertShowDecimal((ushort)optionRouterAlert.RouterAlertType);
                            ++optionsIndex;
                            break;

                        case "ipv6.opt.padn":
                            headerSubfield.AssertNoFields();
                            var optionPadN = (IpV6OptionPadN)option;
                            headerSubfield.AssertValue(new byte[optionPadN.PaddingDataLength]);
                            ++optionsIndex;
                            break;

                        case "ipv6.opt.qs_func":
                            headerSubfield.AssertNoFields();
                            headerSubfield.AssertShowDecimal((byte)optionQuickStart.QuickStartFunction);
                            break;

                        case "ipv6.opt.qs_rate":
                            headerSubfield.AssertNoFields();
                            headerSubfield.AssertShowDecimal(optionQuickStart.Rate);
                            break;

                        case "ipv6.opt.qs_ttl":
                            headerSubfield.AssertNoFields();
                            headerSubfield.AssertShowDecimal(optionQuickStart.Ttl);
                            break;

                        case "ipv6.opt.qs_ttl_diff":
                            headerSubfield.AssertNoFields();
                            headerSubfield.AssertShowDecimal((256 + ipV6Datagram.HopLimit - optionQuickStart.Ttl) % 256);
                            break;

                        case "ipv6.opt.qs_unused":
                            headerSubfield.AssertNoFields();
                            headerSubfield.AssertShowDecimal(optionQuickStart.Ttl);
                            break;

                        case "ipv6.opt.qs_nonce":
                            headerSubfield.AssertNoFields();
                            headerSubfield.AssertShowDecimal(optionQuickStart.Nonce);
                            break;

                        case "ipv6.opt.qs_reserved":
                            headerSubfield.AssertNoFields();
                            headerSubfield.AssertShowDecimal(0);
                            ++optionsIndex;
                            break;

                        case "ipv6.opt.pad1":
                            headerSubfield.AssertNoFields();
                            headerSubfield.AssertShow("");
                            Assert.IsTrue(option is IpV6OptionPad1);
                            ++optionsIndex;
                            break;

                        case "ipv6.opt.jumbo":
                            headerSubfield.AssertNoFields();
                            headerSubfield.AssertShowDecimal(((IpV6OptionJumboPayload)option).JumboPayloadLength);
                            ++optionsIndex;
                            break;

                        case "ipv6.mipv6_home_address":
                            headerSubfield.AssertNoFields();
                            headerSubfield.AssertShow(((IpV6OptionHomeAddress)option).HomeAddress.GetWiresharkString());
                            ++optionsIndex;
                            break;

                        case "ipv6.opt.unknown":
                            headerSubfield.AssertNoFields();
                            Assert.IsTrue(new[]
                            {
                                IpV6OptionType.LineIdentification,
                                IpV6OptionType.IdentifierLocatorNetworkProtocolNonce,
                                IpV6OptionType.SimplifiedMulticastForwardingDuplicatePacketDetection,
                                IpV6OptionType.EndpointIdentification,
                            }.Contains(option.OptionType),
                                          option.OptionType.ToString());
                            ++optionsIndex;
                            break;

                        default:
                            throw new InvalidOperationException("Invalid ipv6 header subfield " + headerSubfield.Name());
                        }
                    }
                    break;

                default:
                    throw new InvalidOperationException("Invalid ipv6 options field " + headerField.Name());
                }
            }
        }
 internal override bool EqualsData(IpV6Option other)
 {
     return EqualsData(other as IpV6OptionIdentifierLocatorNetworkProtocolNonce);
 }
示例#6
0
 internal sealed override bool EqualsData(IpV6Option other)
 {
     return(true);
 }