當前位置: 首頁>>代碼示例>>C#>>正文


C# XElement.Show方法代碼示例

本文整理匯總了C#中System.Xml.Linq.XElement.Show方法的典型用法代碼示例。如果您正苦於以下問題:C# XElement.Show方法的具體用法?C# XElement.Show怎麽用?C# XElement.Show使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Xml.Linq.XElement的用法示例。


在下文中一共展示了XElement.Show方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CompareField

        protected override bool CompareField(XElement field, Datagram parentDatagram, Datagram datagram)
        {
            IpDatagram ipDatagram = (IpDatagram)parentDatagram;
            UdpDatagram udpDatagram = (UdpDatagram)datagram;

            switch (field.Name())
            {
                case "udp.srcport":
                    field.AssertShowDecimal(udpDatagram.SourcePort);
                    break;

                case "udp.dstport":
                    field.AssertShowDecimal(udpDatagram.DestinationPort);
                    break;

                case "udp.port":
                    Assert.IsTrue(ushort.Parse(field.Show()) == udpDatagram.SourcePort ||
                                  ushort.Parse(field.Show()) == udpDatagram.DestinationPort);
                    break;

                case "udp.length":
                    field.AssertShowDecimal(udpDatagram.TotalLength);
                    break;

                case "udp.checksum":
                    field.AssertShowDecimal(udpDatagram.Checksum);
                    if (udpDatagram.Checksum != 0)
                    {
                        foreach (var checksumField in field.Fields())
                        {
                            switch (checksumField.Name())
                            {
                                case "udp.checksum_good":
                                    checksumField.AssertShowDecimal(ipDatagram.IsTransportChecksumCorrect);
                                    break;

                                case "udp.checksum_bad":
                                    if (checksumField.Show() == "1")
                                        Assert.IsFalse(ipDatagram.IsTransportChecksumCorrect);
                                    else
                                        checksumField.AssertShowDecimal(0);
                                    break;
                            }
                        }
                    }
                    break;

                case "udp.checksum_coverage":
                    field.AssertShowDecimal(udpDatagram.TotalLength);
                    break;

                case "udp.stream":
                    break;

                default:
                    throw new InvalidOperationException("Invalid udp field " + field.Name());
            }

            return true;
        }
開發者ID:amitla,項目名稱:Pcap.Net,代碼行數:60,代碼來源:WiresharkDatagramComparerUdp.cs

示例2: CompareField

        protected override bool CompareField(XElement field, Datagram datagram)
        {
            IpV6Datagram ipV6Datagram = datagram as IpV6Datagram;
            if (ipV6Datagram == null)
                return true;
            while (_count > 0)
            {
                do
                {
                    ++_currentExtensionHeaderIndex;
                    if (_currentExtensionHeaderIndex >= ipV6Datagram.ExtensionHeaders.Headers.Count)
                    {
                        Assert.IsFalse(ipV6Datagram.ExtensionHeaders.IsValid);
                        return false;
                    }
                } while (ipV6Datagram.ExtensionHeaders[_currentExtensionHeaderIndex].Protocol != IpV4Protocol.AuthenticationHeader);
                --_count;
            }
            IpV6ExtensionHeaderAuthentication authenticationHeader = (IpV6ExtensionHeaderAuthentication)ipV6Datagram.ExtensionHeaders[_currentExtensionHeaderIndex];

            switch (field.Name())
            {
                case "":
                    string[] headerFieldShowParts = field.Show().Split(':');
                    string headerFieldShowName = headerFieldShowParts[0];
                    string headerFieldShowValue = headerFieldShowParts[1];
                    switch (headerFieldShowName)
                    {
                        case "Next Header":
                            field.AssertValue((byte)authenticationHeader.NextHeader.Value);
                            break;

                        case "Length":
                            Assert.AreEqual(string.Format(" {0}", authenticationHeader.Length), headerFieldShowValue);
                            break;

                        default:
                            throw new InvalidOperationException("Invalid ipv6 authentication header unnamed field show name " + headerFieldShowName);
                    }
                    break;

                case "ah.spi":
                    field.AssertShowDecimal(authenticationHeader.SecurityParametersIndex);
                    break;

                case "ah.sequence":
                    field.AssertShowDecimal(authenticationHeader.SequenceNumber);
                    break;

                case "ah.icv":
                    field.AssertValue(authenticationHeader.AuthenticationData);
                    break;

                default:
                    throw new InvalidOperationException(string.Format("Invalid ipv6 authentication header field {0}", field.Name()));
            }

            return true;
        }
開發者ID:JackWangCUMT,項目名稱:WiFiSpy,代碼行數:59,代碼來源:WiresharkDatagramComparerIpV6AuthenticationHeader.cs

示例3: CompareField


//.........這裏部分代碼省略.........
                            protocol == IpV4Protocol.InternetworkPacketExchangeInIp ||
                            protocol == IpV4Protocol.IntermediateSystemToIntermediateSystemOverIpV4 ||
                            protocol == IpV4Protocol.ComputerProtocolNetworkExecutive ||
                            protocol == IpV4Protocol.EncapsulationHeader ||
                            protocol == IpV4Protocol.GatewayToGateway ||
                            protocol == IpV4Protocol.SatMon ||
                            protocol == IpV4Protocol.VersatileMessageTransactionProtocol ||
                            protocol == IpV4Protocol.ReliableDatagramProtocol ||
                            protocol == IpV4Protocol.InternetReliableTransactionProtocol ||
                            protocol == IpV4Protocol.MeritInternodalProtocol ||
                            protocol == IpV4Protocol.Skip ||
                            protocol == IpV4Protocol.BurroughsNetworkArchitecture ||
                            protocol == IpV4Protocol.InterDomainRoutingProtocol ||
                            protocol == IpV4Protocol.ActiveNetworks ||
                            protocol == IpV4Protocol.SpectraLinkRadioProtocol ||
                            protocol == IpV4Protocol.MobileAdHocNetwork ||
                            protocol == IpV4Protocol.DissimilarGatewayProtocol ||
                            protocol == IpV4Protocol.SpriteRpc ||
                            protocol == IpV4Protocol.CombatRadioUserDatagram ||
                            protocol == IpV4Protocol.Gmtp ||
                            protocol == IpV4Protocol.MobileHostRoutingProtocol ||
                            protocol == IpV4Protocol.Shim6 ||  // TODO: Implement Shim6.
                            protocol == IpV4Protocol.RemoteVirtualDiskProtocol))
                return false;

            int currentExtensionHeaderIndex = ipV6Datagram.ExtensionHeaders.TakeWhile(extensionHeader => extensionHeader.Protocol != IpV4Protocol.MobilityHeader).Count();
            if (currentExtensionHeaderIndex >= ipV6Datagram.ExtensionHeaders.Headers.Count && !ipV6Datagram.IsValid)
                return false;
            IpV6ExtensionHeaderMobility mobilityHeader = (IpV6ExtensionHeaderMobility)ipV6Datagram.ExtensionHeaders[currentExtensionHeaderIndex];

            switch (field.Name())
            {
                case "mip6.proto":
                    field.AssertShowDecimal((byte)mobilityHeader.NextHeader);
                    field.AssertNoFields();
                    break;

                case "mip6.hlen":
                    if (mobilityHeader.IsValid)
                        field.AssertShowDecimal(mobilityHeader.Length / 8 - 1);
                    field.AssertNoFields();
                    break;

                case "mip6.mhtype":
                    field.AssertShowDecimal((byte)mobilityHeader.MobilityHeaderType);
                    break;

                case "mip6.reserved":
                    field.AssertShowDecimal(0);
                    field.AssertNoFields();
                    break;

                case "mip6.csum":
                    field.AssertShowDecimal(mobilityHeader.Checksum);
                    break;

                case "mip6.em.data":
                    IpV6ExtensionHeaderMobilityExperimental experimentalHeader = (IpV6ExtensionHeaderMobilityExperimental)mobilityHeader;
                    field.AssertValue(experimentalHeader.MessageData);
                    break;

                case "":
                    switch (field.Show())
                    {
                        case "Binding Refresh Request":
                            Assert.AreEqual(IpV6MobilityHeaderType.BindingRefreshRequest, mobilityHeader.MobilityHeaderType);
開發者ID:yanggis,項目名稱:Pcap.Net,代碼行數:67,代碼來源:WiresharkDatagramComparerIpV6MobilityHeader.cs

示例4: CompareResourceRecordData

        private bool CompareResourceRecordData(XElement dataField, DnsResourceRecord resourceRecord)
        {
            var data = resourceRecord.Data;
            string dataFieldName = dataField.Name();
            string dataFieldShow = dataField.Show();
            string dataFieldShowUntilColon = dataFieldShow.Split(':')[0];
            switch (resourceRecord.DnsType)
            {
                case DnsType.A:
                    dataField.AssertNoFields();
                    switch (dataFieldName)
                    {
                        case "dns.a":
                            dataField.AssertShow(((DnsResourceDataIpV4)data).Data.ToString());
                            break;

                        default:
                            throw new InvalidOperationException("Invalid DNS data field name " + dataFieldName);
                    }
                    break;

                case DnsType.Ns:
                    dataField.AssertNoFields();
                    switch (dataFieldName)
                    {
                        case "dns.ns":
                            dataField.AssertShow(GetWiresharkDomainName(((DnsResourceDataDomainName)data).Data));
                            break;

                        default:
                            throw new InvalidOperationException("Invalid DNS data field name " + dataFieldName);
                    }
                    break;

                case DnsType.Mailbox:
                    dataField.AssertName("dns.mb");
                    dataField.AssertNoFields();
                    dataField.AssertShow(GetWiresharkDomainName(((DnsResourceDataDomainName)data).Data));
                    break;

                case DnsType.Md:
                    dataField.AssertName("dns.md");
                    dataField.AssertNoFields();
                    dataField.AssertShow(GetWiresharkDomainName(((DnsResourceDataDomainName)data).Data));
                    break;

                case DnsType.MailForwarder: 
                    dataField.AssertName("dns.mf");
                    dataField.AssertNoFields();
                    dataField.AssertShow(GetWiresharkDomainName(((DnsResourceDataDomainName)data).Data));
                    break;

                case DnsType.MailGroup:     // 8.
                    dataField.AssertName("dns.mg");
                    dataField.AssertShow(GetWiresharkDomainName(((DnsResourceDataDomainName)data).Data));
                    dataField.AssertNoFields();
                    break;

                case DnsType.MailRename:    // 9.
                    dataField.AssertName("dns.mr");
                    dataField.AssertShow(GetWiresharkDomainName(((DnsResourceDataDomainName)data).Data));
                    dataField.AssertNoFields();
                    break;

                case DnsType.CName:
                    dataField.AssertName("dns.cname");
                    dataField.AssertShow(GetWiresharkDomainName(((DnsResourceDataDomainName)data).Data));
                    dataField.AssertNoFields();
                    break;

                case DnsType.StartOfAuthority:
                    var startOfAuthority = (DnsResourceDataStartOfAuthority)data;
                    dataField.AssertNoFields();
                    switch (dataField.Name())
                    {
                        case "dns.soa.mname":
                            dataField.AssertShow(GetWiresharkDomainName(startOfAuthority.MainNameServer));
                            break;

                        case "dns.soa.rname":
                            dataField.AssertShow(GetWiresharkDomainName(startOfAuthority.ResponsibleMailbox));
                            break;

                        case "dns.soa.serial_number":
                            dataField.AssertShowDecimal(startOfAuthority.Serial.Value);
                            break;

                        case "dns.soa.refresh_interval":
                            dataField.AssertShowDecimal(startOfAuthority.Refresh);
                            break;

                        case "dns.soa.retry_interval":
                            dataField.AssertShowDecimal(startOfAuthority.Retry);
                            break;

                        case "dns.soa.expire_limit":
                            dataField.AssertShowDecimal(startOfAuthority.Expire);
                            break;

                        case "dns.soa.mininum_ttl":
//.........這裏部分代碼省略.........
開發者ID:amitla,項目名稱:Pcap.Net,代碼行數:101,代碼來源:WiresharkDatagramComparerDns.cs

示例5: CompareField

        protected override bool CompareField(XElement field, Datagram datagram)
        {
            DnsDatagram dnsDatagram = (DnsDatagram)datagram;

            switch (field.Name())
            {
                case "dns.id":
                    field.AssertShowDecimal(dnsDatagram.Id);
                    break;

                case "dns.flags":
                    field.AssertShowDecimal(dnsDatagram.Subsegment(2, 2).ToArray().ReadUShort(0, Endianity.Big));
                    foreach (var flagField in field.Fields())
                    {
                        switch (flagField.Name())
                        {
                            case "dns.flags.response":
                                flagField.AssertShowDecimal(dnsDatagram.IsResponse);
                                break;

                            case "dns.flags.opcode":
                                flagField.AssertShowDecimal((byte)dnsDatagram.OpCode);
                                break;

                            case "dns.flags.conflict": // TODO: Support LLMNR.
                            case "dns.flags.authoritative":
                                flagField.AssertShowDecimal(dnsDatagram.IsAuthoritativeAnswer);
                                break;

                            case "dns.flags.truncated":
                                flagField.AssertShowDecimal(dnsDatagram.IsTruncated);
                                break;

                            case "dns.flags.tentative": // TODO: Support LLMNR.
                            case "dns.flags.recdesired":
                                flagField.AssertShowDecimal(dnsDatagram.IsRecursionDesired);
                                break;

                            case "dns.flags.recavail":
                                flagField.AssertShowDecimal(dnsDatagram.IsRecursionAvailable);
                                break;

                            case "dns.flags.z":
                                flagField.AssertShowDecimal(dnsDatagram.FutureUse);
                                break;

                            case "dns.flags.authenticated":
                                flagField.AssertShowDecimal(dnsDatagram.IsAuthenticData);
                                break;

                            case "dns.flags.checkdisable":
                                flagField.AssertShowDecimal(dnsDatagram.IsCheckingDisabled);
                                break;

                            case "dns.flags.rcode":
                                flagField.AssertShowDecimal((ushort)dnsDatagram.ResponseCode);
                                break;

                            default:
                                throw new InvalidOperationException("Invalid DNS flag field " + flagField.Name());
                        }
                    }
                    break;

                case "dns.count.queries":
                case "dns.count.zones":
                    field.AssertShowDecimal(dnsDatagram.QueryCount);
                    break;

                case "dns.count.answers":
                case "dns.count.prerequisites":
                    field.AssertShowDecimal(dnsDatagram.AnswerCount);
                    break;

                case "dns.count.auth_rr":
                case "dns.count.updates":
                    field.AssertShowDecimal(dnsDatagram.AuthorityCount);
                    break;

                case "dns.count.add_rr":
                    field.AssertShowDecimal(dnsDatagram.AdditionalCount);
                    break;

                case "":
                    var resourceRecordsFields = field.Fields();
                    switch (field.Show())
                    {
                        case "Queries":
                        case "Zone":
                            CompareResourceRecords(resourceRecordsFields, dnsDatagram.Queries);
                            break;

                        case "Answers":
                        case "Prerequisites":
                            CompareResourceRecords(resourceRecordsFields, dnsDatagram.Answers);
                            break;

                        case "Authoritative nameservers":
                        case "Updates":
                            CompareResourceRecords(resourceRecordsFields, dnsDatagram.Authorities);
//.........這裏部分代碼省略.........
開發者ID:amitla,項目名稱:Pcap.Net,代碼行數:101,代碼來源:WiresharkDatagramComparerDns.cs

示例6: CompareField

        protected override bool CompareField(XElement field, Datagram datagram)
        {
            IcmpDatagram icmpDatagram = (IcmpDatagram)datagram;
            switch (field.Name())
            {
                case "icmp.type":
                    field.AssertShowDecimal((byte)icmpDatagram.MessageType);
                    field.AssertNoFields();
                    break;

                case "icmp.code":
                    field.AssertShowDecimal(icmpDatagram.Code);
                    field.AssertNoFields();
                    break;

                case "icmp.checksum_bad":
                    field.AssertShowDecimal(!icmpDatagram.IsChecksumCorrect);
                    field.AssertNoFields();
                    break;

                case "icmp.checksum":
                    field.AssertShowDecimal(icmpDatagram.Checksum);
                    field.AssertNoFields();
                    break;

                case "data":
                    var icmpIpV4PayloadDatagram = icmpDatagram as IcmpIpV4PayloadDatagram;
                    if (icmpIpV4PayloadDatagram != null)
                    {
                        if (!new[]
                                 {
                                     IpV4Protocol.IpComp, // TODO: Support IpComp.
                                     IpV4Protocol.Ax25, // TODO: Support Ax25.
                                     IpV4Protocol.FibreChannel, // TODO: Support FibreChannel.
                                 }.Contains(icmpIpV4PayloadDatagram.IpV4.Protocol))
                        {
                            if (icmpIpV4PayloadDatagram.IpV4.Protocol == IpV4Protocol.Udp)
                            {
                                // Uncomment this when https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=10990 is fixed.
                                //                                field.AssertDataField(casted1.IpV4.Udp.Payload);
                            }
                            else
                            {
                                // TODO: Remove this condition when https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=10991 and https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=10992 are fixed.
                                if (!(icmpIpV4PayloadDatagram is IcmpParameterProblemDatagram || icmpIpV4PayloadDatagram is IcmpRedirectDatagram))
                                    field.AssertDataField(icmpIpV4PayloadDatagram.IpV4.Payload);
                            }
                        }
                    }
                    else
                    {
                        field.AssertDataField(icmpDatagram.Payload);
                    }
                    break;

                case "":
                    switch (icmpDatagram.MessageType)
                    {
                        case IcmpMessageType.ParameterProblem:
                            if (field.Show() != "Unknown session type")
                                field.AssertShow("Pointer: " + ((IcmpParameterProblemDatagram)icmpDatagram).Pointer);
                            break;

                        case IcmpMessageType.RouterAdvertisement:
                            IcmpRouterAdvertisementDatagram routerAdvertisementDatagram = (IcmpRouterAdvertisementDatagram)icmpDatagram;
                            string fieldName = field.Show().Split(':')[0];
                            switch (fieldName)
                            {
                                case "Number of addresses":
                                    field.AssertShow(fieldName + ": " + routerAdvertisementDatagram.NumberOfAddresses);
                                    break;

                                case "Address entry size":
                                    field.AssertShow(fieldName + ": " + routerAdvertisementDatagram.AddressEntrySize);
                                    break;

                                case "Lifetime":
                                    TimeSpan actualLifetime = routerAdvertisementDatagram.Lifetime;
                                    StringBuilder actualLifetimeString = new StringBuilder(fieldName + ": ");
                                    if (actualLifetime.Hours != 0)
                                    {
                                        actualLifetimeString.Append(actualLifetime.Hours + " hour");
                                        if (actualLifetime.Hours != 1)
                                            actualLifetimeString.Append('s');
                                    }
                                    if (actualLifetime.Minutes != 0)
                                    {
                                        if (actualLifetime.Hours != 0)
                                            actualLifetimeString.Append(", ");
                                        actualLifetimeString.Append(actualLifetime.Minutes + " minute");
                                        if (actualLifetime.Minutes != 1)
                                            actualLifetimeString.Append('s');
                                    }
                                    if (actualLifetime.Seconds != 0)
                                    {
                                        if (actualLifetime.Hours != 0 || actualLifetime.Minutes != 0)
                                            actualLifetimeString.Append(", ");
                                        actualLifetimeString.Append(actualLifetime.Seconds + " second");
                                        if (actualLifetime.Seconds != 1)
                                            actualLifetimeString.Append('s');
//.........這裏部分代碼省略.........
開發者ID:JackWangCUMT,項目名稱:WiFiSpy,代碼行數:101,代碼來源:WiresharkDatagramComparerIcmp.cs

示例7: CompareField

        protected override bool CompareField(XElement field, Datagram datagram)
        {
            IpV4Datagram ipV4Datagram = (IpV4Datagram)datagram;
            switch (field.Name())
            {
                case "ip.version":
                    field.AssertShowDecimal(ipV4Datagram.Version);
                    field.AssertNoFields();
                    break;

                case "ip.hdr_len":
                    field.AssertShowDecimal(ipV4Datagram.HeaderLength);
                    field.AssertNoFields();
                    break;

                case "ip.dsfield":
                    field.AssertShowDecimal((int)ipV4Datagram.TypeOfService);
                    // TODO: Parse TypeOfService to Differentiated Services and ECN.
                    break;

                case "ip.len":
                    field.AssertShowDecimal(ipV4Datagram.TotalLength);
                    field.AssertNoFields();
                    break;

                case "ip.id":
                    field.AssertShowDecimal(ipV4Datagram.Identification);
                    field.AssertNoFields();
                    break;

                case "ip.flags":
                    field.AssertShowDecimal(((ushort)ipV4Datagram.Fragmentation.Options >> 13));
                    foreach (XElement subfield in field.Fields())
                    {
                        subfield.AssertNoFields();
                        switch (subfield.Name())
                        {
                            case "ip.flags.rb":
                                break;

                            case "ip.flags.df":
                                subfield.AssertShowDecimal((ipV4Datagram.Fragmentation.Options & IpV4FragmentationOptions.DoNotFragment) ==
                                                           IpV4FragmentationOptions.DoNotFragment);
                                break;

                            case "ip.flags.mf":
                                subfield.AssertShowDecimal((ipV4Datagram.Fragmentation.Options & IpV4FragmentationOptions.MoreFragments) ==
                                                           IpV4FragmentationOptions.MoreFragments);
                                break;

                            default:
                                throw new InvalidOperationException(string.Format("Invalid ip flags subfield {0}", subfield.Name()));
                        }
                    }
                    break;

                case "ip.frag_offset":
                    field.AssertShowDecimal(ipV4Datagram.Fragmentation.Offset);
                    field.AssertNoFields();
                    break;

                case "ip.ttl":
                    field.AssertShowDecimal(ipV4Datagram.Ttl);
                    foreach (XElement subfield in field.Fields())
                    {
                        switch (subfield.Name())
                        {
                            case "_ws.expert":
                                break;

                            default:
                                subfield.AssertNoFields();
                                throw new InvalidOperationException(string.Format("Invalid ip subfield {0}", subfield.Name()));
                        }
                    }
                    break;

                case "ip.proto":
                    field.AssertShowDecimal((byte)ipV4Datagram.Protocol);
                    field.AssertNoFields();
                    break;

                case "ip.checksum":
                    field.AssertShowDecimal(ipV4Datagram.HeaderChecksum);
                    if (field.Showname().EndsWith(" [not all data available]"))
                    {
                        Assert.IsFalse(ipV4Datagram.IsValid);
                        break;
                    }
                    foreach (var checksumField in field.Fields())
                    {
                        switch (checksumField.Name())
                        {
                            case "ip.checksum_good":
                                checksumField.AssertNoFields();
                                // TODO: Remove this case when https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=10579 is fixed.
                                if (field.Showname().EndsWith(" [in ICMP error packet]"))
                                    break;
                                checksumField.AssertShowDecimal(ipV4Datagram.IsHeaderChecksumCorrect);
                                break;
//.........這裏部分代碼省略.........
開發者ID:amitla,項目名稱:Pcap.Net,代碼行數:101,代碼來源:WiresharkDatagramComparerIpV4.cs

示例8: CompareField

        protected override bool CompareField(XElement field, Datagram parentDatagram, Datagram datagram)
        {
            IpV4Datagram ipV4Datagram = (IpV4Datagram)parentDatagram;
            TcpDatagram tcpDatagram = (TcpDatagram)datagram;

            switch (field.Name())
            {
                case "tcp.len":
                    if (tcpDatagram.Payload == null)
                    {
                        // todo seems like a bug in tshark https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=5235
                        break;
//                            field.AssertShowDecimal(tcpDatagram.Length);
                    }
                    else
                        field.AssertShowDecimal(tcpDatagram.Payload.Length);
                    field.AssertNoFields();
                    break;

                case "tcp.srcport":
                    field.AssertShowDecimal(tcpDatagram.SourcePort);
                    field.AssertNoFields();
                    break;

                case "tcp.dstport":
                    field.AssertShowDecimal(tcpDatagram.DestinationPort);
                    field.AssertNoFields();
                    break;

                case "tcp.port":
                    Assert.IsTrue(ushort.Parse(field.Show()) == tcpDatagram.SourcePort ||
                                  ushort.Parse(field.Show()) == tcpDatagram.DestinationPort);
                    field.AssertNoFields();
                    break;


                case "tcp.seq":
                    field.AssertShowDecimal(tcpDatagram.SequenceNumber);
                    field.AssertNoFields();
                    break;

                case "tcp.nxtseq":
                    field.AssertShowDecimal(tcpDatagram.NextSequenceNumber);
                    field.AssertNoFields();
                    break;

                case "tcp.ack":
                    field.AssertShowDecimal(tcpDatagram.AcknowledgmentNumber);
                    field.AssertNoFields();
                    break;

                case "tcp.hdr_len":
                    field.AssertShowDecimal(tcpDatagram.HeaderLength);
                    field.AssertNoFields();
                    break;

                case "tcp.flags":
                    ushort flags =
                        (ushort)((tcpDatagram.Reserved << 9) |
                                 (((tcpDatagram.ControlBits & TcpControlBits.NonceSum) == TcpControlBits.NonceSum ? 1 : 0) << 8) |
                                 (byte)tcpDatagram.ControlBits);
                    field.AssertShow("0x" + flags.ToString("x" + 4 * sizeof(byte)));
                    foreach (var flagField in field.Fields())
                    {
                        switch (flagField.Name())
                        {
                            case "tcp.flags.cwr":
                                flagField.AssertShowDecimal(tcpDatagram.IsCongestionWindowReduced);
                                break;

                            case "tcp.flags.ecn":
                                flagField.AssertShowDecimal(tcpDatagram.IsExplicitCongestionNotificationEcho);
                                break;

                            case "tcp.flags.urg":
                                flagField.AssertShowDecimal(tcpDatagram.IsUrgent);
                                break;

                            case "tcp.flags.ack":
                                flagField.AssertShowDecimal(tcpDatagram.IsAcknowledgment);
                                break;

                            case "tcp.flags.push":
                                flagField.AssertShowDecimal(tcpDatagram.IsPush);
                                break;

                            case "tcp.flags.reset":
                                flagField.AssertShowDecimal(tcpDatagram.IsReset);
                                break;

                            case "tcp.flags.syn":
                                flagField.AssertShowDecimal(tcpDatagram.IsSynchronize);
                                break;

                            case "tcp.flags.fin":
                                flagField.AssertShowDecimal(tcpDatagram.IsFin);
                                break;
                        }
                        flagField.AssertNoFields();
                    }
//.........這裏部分代碼省略.........
開發者ID:shrknt35,項目名稱:sonarlint-vs,代碼行數:101,代碼來源:WiresharkDatagramComparerTcp.cs

示例9: CompareResourceRecordData

        private void CompareResourceRecordData(XElement dataField, DnsResourceRecord resourceRecord)
        {
            var data = resourceRecord.Data;
            string dataFieldName = dataField.Name();
            string dataFieldShow = dataField.Show();
            string dataFieldShowUntilColon = dataFieldShow.Split(':')[0];
            switch (resourceRecord.DnsType)
            {
                case DnsType.A:
                    switch (dataFieldName)
                    {
                        case "dns.resp.addr":
                            dataField.AssertShow(((DnsResourceDataIpV4)data).Data.ToString());
                            break;

                        default:
                            throw new InvalidOperationException("Invalid DNS data field name " + dataFieldName);
                    }
                    break;

                case DnsType.Ns:
                    dataField.AssertName("dns.resp.ns");
                    dataField.AssertShow(GetWiresharkDomainName(((DnsResourceDataDomainName)data).Data));
                    dataField.AssertNoFields();
                    break;

                case DnsType.Md:            // 3.
                case DnsType.MailForwarder: // 4.
                case DnsType.Mailbox:       // 7.
                case DnsType.MailGroup:     // 8.
                case DnsType.MailRename:    // 9.
                    dataField.AssertName("");
                    dataField.AssertShow("Host: " + GetWiresharkDomainName(((DnsResourceDataDomainName)data).Data));
                    dataField.AssertNoFields();
                    break;

                case DnsType.CName:
                    dataField.AssertName("dns.resp.primaryname");
                    dataField.AssertShow(GetWiresharkDomainName(((DnsResourceDataDomainName)data).Data));
                    dataField.AssertNoFields();
                    break;

                case DnsType.StartOfAuthority:
                    dataField.AssertName("");
                    var soaData = (DnsResourceDataStartOfAuthority)data;
                    switch (dataFieldShowUntilColon)
                    {
                        case "Primary name server":
                            dataField.AssertShow(dataFieldShowUntilColon + ": " + GetWiresharkDomainName(soaData.MainNameServer));
                            break;

                        case "Responsible authority's mailbox":
                            dataField.AssertShow(dataFieldShowUntilColon + ": " + GetWiresharkDomainName(soaData.ResponsibleMailbox));
                            break;

                        case "Serial number":
                            dataField.AssertShow(dataFieldShowUntilColon + ": " + soaData.Serial);
                            break;

                        case "Refresh interval":
                            dataField.AssertValue(soaData.Refresh);
                            break;

                        case "Retry interval":
                            dataField.AssertValue(soaData.Retry);
                            break;

                        case "Expiration limit":
                            dataField.AssertValue(soaData.Expire);
                            break;

                        case "Minimum TTL":
                            dataField.AssertValue(soaData.MinimumTtl);
                            break;

                        default:
                            throw new InvalidOperationException("Invalid DNS data field " + dataFieldShow);
                    }
                    dataField.AssertNoFields();
                    break;
                    
                case DnsType.Wks:
                    dataField.AssertName("");
                    var wksData = (DnsResourceDataWellKnownService)data;
                    switch (dataFieldShowUntilColon)
                    {
                        case "Addr":
                            dataField.AssertShow(dataFieldShowUntilColon + ": " + wksData.Address);
                            break;

                        case "Protocol":
                            dataField.AssertValue((byte)wksData.Protocol);
                            break;

                        case "Bits":
                            while (wksData.Bitmap[_wksBitmapIndex] == 0x00)
                                ++_wksBitmapIndex;
                            dataField.AssertValue(wksData.Bitmap[_wksBitmapIndex++]);
                            break;

//.........這裏部分代碼省略.........
開發者ID:shrknt35,項目名稱:sonarlint-vs,代碼行數:101,代碼來源:WiresharkDatagramComparerDns.cs

示例10: CompareField

        protected override bool CompareField(XElement field, Datagram parentDatagram, Datagram datagram)
        {
            IpDatagram ipDatagram = (IpDatagram)parentDatagram;
            TcpDatagram tcpDatagram = (TcpDatagram)datagram;

            switch (field.Name())
            {
                case "tcp.len":
                    field.AssertShowDecimal(tcpDatagram.Length - tcpDatagram.HeaderLength);
                    field.AssertNoFields();
                    break;

                case "tcp.srcport":
                    field.AssertShowDecimal(tcpDatagram.SourcePort);
                    field.AssertNoFields();
                    break;

                case "tcp.dstport":
                    field.AssertShowDecimal(tcpDatagram.DestinationPort);
                    field.AssertNoFields();
                    break;

                case "tcp.port":
                    Assert.IsTrue(ushort.Parse(field.Show()) == tcpDatagram.SourcePort ||
                                  ushort.Parse(field.Show()) == tcpDatagram.DestinationPort);
                    field.AssertNoFields();
                    break;


                case "tcp.seq":
                    field.AssertShowDecimal(tcpDatagram.SequenceNumber);
                    field.AssertNoFields();
                    break;

                case "tcp.nxtseq":
                    field.AssertShowDecimal(tcpDatagram.NextSequenceNumber);
                    field.AssertNoFields();
                    break;

                case "tcp.ack":
                    field.AssertShowDecimal(tcpDatagram.AcknowledgmentNumber);
                    foreach (XElement subfield in field.Fields())
                    {
                        switch (subfield.Name())
                        {
                            case "_ws.expert":
                                break;

                            default:
                                subfield.AssertNoFields();
                                throw new InvalidOperationException("Invalid TCP subfield name " + subfield.Name());
                        }
                    }
                    break;

                case "tcp.hdr_len":
                    field.AssertShowDecimal(tcpDatagram.HeaderLength);
                    field.AssertNoFields();
                    break;

                case "tcp.flags":
                    ushort flags =
                        (ushort)((tcpDatagram.Reserved << 9) |
                                 (((tcpDatagram.ControlBits & TcpControlBits.NonceSum) == TcpControlBits.NonceSum ? 1 : 0) << 8) |
                                 (byte)tcpDatagram.ControlBits);
                    field.AssertShowDecimal(flags);
                    foreach (var flagField in field.Fields())
                    {
                        switch (flagField.Name())
                        {
                            case "tcp.flags.res":
                                flagField.AssertNoFields();
                                break;

                            case "tcp.flags.ns":
                                flagField.AssertNoFields();
                                flagField.AssertShowDecimal(tcpDatagram.IsNonceSum);
                                break;

                            case "tcp.flags.cwr":
                                flagField.AssertNoFields();
                                flagField.AssertShowDecimal(tcpDatagram.IsCongestionWindowReduced);
                                break;

                            case "tcp.flags.ecn":
                                flagField.AssertNoFields();
                                flagField.AssertShowDecimal(tcpDatagram.IsExplicitCongestionNotificationEcho);
                                break;

                            case "tcp.flags.urg":
                                flagField.AssertNoFields();
                                flagField.AssertShowDecimal(tcpDatagram.IsUrgent);
                                break;

                            case "tcp.flags.ack":
                                flagField.AssertNoFields();
                                flagField.AssertShowDecimal(tcpDatagram.IsAcknowledgment);
                                break;

                            case "tcp.flags.push":
//.........這裏部分代碼省略.........
開發者ID:amitla,項目名稱:Pcap.Net,代碼行數:101,代碼來源:WiresharkDatagramComparerTcp.cs

示例11: CompareField

        protected override bool CompareField(XElement field, Datagram datagram)
        {
            HttpDatagram httpDatagram = (HttpDatagram)datagram;

            if (field.Name() == "data" || field.Name() == "data.data")
            {
                if (field.Name() == "data")
                    field.AssertNoShow();

                MoreAssert.AreSequenceEqual(httpDatagram.Subsegment(0, _data.Length / 2), HexEncoding.Instance.GetBytes(_data.ToString()));
                // TODO: Uncomment once https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=10707 is fixed.
            //                field.AssertValue(httpDatagram.Subsegment(_data.Length / 2 + 2, httpDatagram.Length - _data.Length / 2 - 2));
                return false;
            }

            string fieldShow = field.Show();
            string httpFieldName;
            switch (field.Name())
            {
                case "http.request":
                    field.AssertShowDecimal(httpDatagram.IsRequest);
                    break;

                case "http.response":
                    field.AssertShowDecimal(httpDatagram.IsResponse);
                    break;

                case "":
                    if (fieldShow == "HTTP chunked response")
                        throw new InvalidOperationException("HTTP chunked response");
                    if (fieldShow == @"\r\n" || fieldShow == "HTTP response 1/1" || fieldShow == "HTTP request 1/1")
                        break;

                    _data.Append(field.Value());

                    if (_isFirstEmptyName)
                    {
                        CompareHttpFirstLine(field, httpDatagram);
                        _isFirstEmptyName = false;
                    }
                    else if (fieldShow.StartsWith("Content-encoded entity body"))
                    {
                        break;
                    }
                    else
                    {
                        fieldShow = EncodingExtensions.Iso88591.GetString(HexEncoding.Instance.GetBytes(field.Value()));
                        fieldShow = fieldShow.Substring(0, fieldShow.Length - 2);
                        int colonIndex = fieldShow.IndexOf(':');
                        MoreAssert.IsBiggerOrEqual(0, colonIndex, "Can't find colon in field with empty name");

                        if (httpDatagram.Header == null)
                        {
                            if (httpDatagram.IsRequest)
                                Assert.IsNull(httpDatagram.Version);
                            else
                                Assert.IsTrue(IsBadHttp(httpDatagram));
                            break;
                        }
                        httpFieldName = fieldShow.Substring(0, colonIndex);
                        if (!field.Value().EndsWith("0d0a"))
                            Assert.IsNull(httpDatagram.Header[httpFieldName]);
                        else
                        {
                            string fieldValue = fieldShow.Substring(colonIndex + 1).SkipWhile(c => c == ' ').TakeWhile(c => c != '\\').SequenceToString();
                            string expectedFieldValue = httpDatagram.Header[httpFieldName].ValueString;
                            Assert.IsTrue(expectedFieldValue.Contains(fieldValue),
                                          string.Format("{0} <{1}> doesn't contain <{2}>", field.Name(), expectedFieldValue, fieldValue));
                        }
                    }
                    break;

                case "data.len":
                    field.AssertShowDecimal(httpDatagram.Length - _data.Length / 2);
                    break;

                case "http.host":
                case "http.user_agent":
                case "http.accept":
                case "http.accept_language":
                case "http.accept_encoding":
                case "http.connection":
                case "http.cookie":
                case "http.cache_control":
                case "http.content_encoding":
                case "http.date":
                case "http.referer":
                case "http.last_modified":
                case "http.server":
                case "http.set_cookie":
                case "http.location":
                    _data.Append(field.Value());
                    httpFieldName = field.Name().Substring(5).Replace('_', '-');
                    HttpField httpField = httpDatagram.Header[httpFieldName];
                    if (!field.Value().EndsWith("0d0a"))
                        Assert.IsNull(httpField);
                    else
                    {
                        string fieldValue = field.Show().Replace("\\\"", "\"");
                        string expectedFieldValue = httpField.ValueString;
//.........這裏部分代碼省略.........
開發者ID:JackWangCUMT,項目名稱:WiFiSpy,代碼行數:101,代碼來源:WiresharkDatagramComparerHttp.cs

示例12: CompareField

        protected override bool CompareField(XElement field, Datagram datagram)
        {
            IpV4Datagram ipV4Datagram = (IpV4Datagram)datagram;
            switch (field.Name())
            {
                case "ip.version":
                    field.AssertShowDecimal(ipV4Datagram.Version);
                    break;

                case "ip.hdr_len":
                    field.AssertShowDecimal(ipV4Datagram.HeaderLength);
                    break;

                case "ip.dsfield":
                    field.AssertShowDecimal((int)ipV4Datagram.TypeOfService);
                    break;

                case "ip.len":
                    field.AssertShowDecimal(ipV4Datagram.TotalLength);
                    break;

                case "ip.id":
                    field.AssertShowHex(ipV4Datagram.Identification);
                    break;

                case "ip.flags":
                    field.AssertShowHex((byte)((ushort)ipV4Datagram.Fragmentation.Options >> 13));
                    break;

                case "ip.frag_offset":
                    field.AssertShowDecimal(ipV4Datagram.Fragmentation.Offset);
                    break;

                case "ip.ttl":
                    field.AssertShowDecimal(ipV4Datagram.Ttl);
                    break;

                case "ip.proto":
                    field.AssertShowDecimal((byte)ipV4Datagram.Protocol);
                    break;

                case "ip.checksum":
                    field.AssertShowHex(ipV4Datagram.HeaderChecksum);
                    foreach (var checksumField in field.Fields())
                    {
                        switch (checksumField.Name())
                        {
                            case "ip.checksum_good":
                                checksumField.AssertShowDecimal(ipV4Datagram.IsHeaderChecksumCorrect);
                                break;

                            case "ip.checksum_bad":
                                if (ipV4Datagram.Length < IpV4Datagram.HeaderMinimumLength ||
                                    ipV4Datagram.Length < ipV4Datagram.HeaderLength)
                                    break;

                                checksumField.AssertShowDecimal(!ipV4Datagram.IsHeaderChecksumCorrect);
                                break;
                        }
                    }
                    break;

                case "ip.src":
                case "ip.src_host":
                    field.AssertShow(ipV4Datagram.Source.ToString());
                    break;

                case "ip.dst":
                case "ip.dst_host":
                    if (field.Show() != ipV4Datagram.Destination.ToString())
                    {
                        // TODO: Remove this fallback once https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7043 is fixed.
                        field.AssertShow(ipV4Datagram.CurrentDestination.ToString());
                        Assert.IsTrue(ipV4Datagram.Options.IsBadForWireshark(),
                                      string.Format("Expected destination: {0}. Destination: {1}. Current destination: {2}.", field.Show(),
                                                    ipV4Datagram.Destination, ipV4Datagram.CurrentDestination));
                    }
                    break;

                case "ip.addr":
                case "ip.host":
                    Assert.IsTrue(field.Show() == ipV4Datagram.Source.ToString() ||
                                  field.Show() == ipV4Datagram.Destination.ToString() ||
                                  // TODO: Remove this fallback once https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7043 is fixed.
                                  field.Show() == ipV4Datagram.CurrentDestination.ToString() && ipV4Datagram.Options.IsBadForWireshark(),
                                  string.Format("Expected ip: {0}. ", field.Show()) +
                                  (ipV4Datagram.IsValid
                                       ? string.Format("Source: {0}. Destination: {1}. Current destination: {2}.", ipV4Datagram.Source,
                                                       ipV4Datagram.Destination, ipV4Datagram.CurrentDestination)
                                       : ""));
                    break;

                case "":
                    CompareIpV4Options(field, ipV4Datagram.Options);
                    break;

                default:
                    throw new InvalidOperationException("Invalid ip field " + field.Name());
            }

//.........這裏部分代碼省略.........
開發者ID:shrknt35,項目名稱:sonarlint-vs,代碼行數:101,代碼來源:WiresharkDatagramComparerIpV4.cs

示例13: ValidateExtensionHeaderUnnamedField

        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);
            }
        }
開發者ID:JackWangCUMT,項目名稱:WiFiSpy,代碼行數:49,代碼來源:WiresharkDatagramComparerIpV6.cs

示例14: CompareField

        protected override bool CompareField(XElement field, Datagram datagram)
        {
            IpV6Datagram ipV6Datagram = (IpV6Datagram)datagram;
            SkipAuthenticationHeaders(ipV6Datagram);
            int optionsIndex = 0;
            switch (field.Name())
            {
                case "ipv6.version":
                    // TODO: Remove this when https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=10706 is fixed.
                    if (field.Show() != ipV6Datagram.Version.ToString())
                        return false;
                    field.AssertShowDecimal(ipV6Datagram.Version);
                    foreach (XElement subfield in field.Fields())
                    {
                        switch (subfield.Name())
                        {
                            case "ip.version":
                                subfield.AssertShowDecimal(ipV6Datagram.Version);
                                break;

                            default:
                                throw new InvalidOperationException(string.Format("Invalid ipv6 version subfield {0}", subfield.Name()));
                        }
                    }
                    break;

                case "ipv6.class":
                    field.AssertShowDecimal(ipV6Datagram.TrafficClass);
                    break;

                case "ipv6.flow":
                    field.AssertShowDecimal(ipV6Datagram.FlowLabel);
                    field.AssertNoFields();
                    break;

                case "ipv6.plen":
                    field.AssertShowDecimal(ipV6Datagram.PayloadLength);
                    field.AssertNoFields();
                    break;

                case "ipv6.nxt":
                    field.AssertShowDecimal((byte)ipV6Datagram.NextHeader);
                    field.AssertNoFields();
                    break;

                case "ipv6.hlim":
                    field.AssertShowDecimal(ipV6Datagram.HopLimit);
                    field.AssertNoFields();
                    break;

                case "ipv6.src":
                case "ipv6.src_host":
                    field.AssertShow(ipV6Datagram.Source.GetWiresharkString());
                    field.AssertNoFields();
                    break;

                case "ipv6.src_6to4_gw_ipv4":
                case "ipv6.src_6to4_sla_id":
                case "ipv6.6to4_gw_ipv4":
                case "ipv6.6to4_sla_id":
                    field.AssertNoFields();
                    break;

                case "ipv6.dst":
                case "ipv6.dst_host":
                    field.AssertShow(ipV6Datagram.CurrentDestination.GetWiresharkString());
                    field.AssertNoFields();
                    break;

                case "ipv6.addr":
                case "ipv6.host":
                    Assert.IsTrue(field.Show() == ipV6Datagram.Source.GetWiresharkString() ||
                                  field.Show() == ipV6Datagram.CurrentDestination.GetWiresharkString());
                    field.AssertNoFields();
                    break;

                case "ipv6.hop_opt":
                    if (_currentExtensionHeaderIndex >= ipV6Datagram.ExtensionHeaders.Headers.Count)
                    {
                        Assert.IsFalse(ipV6Datagram.ExtensionHeaders.IsValid);
                        int maxLength = ipV6Datagram.Length - IpV6Datagram.HeaderLength - ipV6Datagram.ExtensionHeaders.BytesLength;
                        if (field.Fields().Any(subfield => subfield.Name() == "ipv6.opt.length"))
                        {
                            int length = int.Parse(field.Fields().First(subfield => subfield.Name() == "ipv6.opt.length").Show());
                            MoreAssert.IsBigger(maxLength, length);
                        }
                        else
                        {
                            Assert.AreEqual(6, maxLength);
                        }
                    }
                    else
                    {
                        IpV6ExtensionHeaderHopByHopOptions hopByHopOptions =
                            (IpV6ExtensionHeaderHopByHopOptions)ipV6Datagram.ExtensionHeaders[_currentExtensionHeaderIndex];
                        IncrementCurrentExtensionHeaderIndex(ipV6Datagram);
                        CompareOptions(field, ref optionsIndex, ipV6Datagram, hopByHopOptions);
                    }
                    break;

//.........這裏部分代碼省略.........
開發者ID:JackWangCUMT,項目名稱:WiFiSpy,代碼行數:101,代碼來源:WiresharkDatagramComparerIpV6.cs

示例15: CompareField

        protected override bool CompareField(XElement field, Datagram datagram)
        {
            IgmpDatagram igmpDatagram = (IgmpDatagram)datagram;
            switch (field.Name())
            {
                case "igmp.version":
                    if (field.Show() == "0")
                        return false; // TODO: support IGMP version 0.

                    field.AssertShowDecimal(igmpDatagram.Version);
                    break;

                case "igmp.type":
                    field.AssertShowHex((byte)igmpDatagram.MessageType);
                    break;

                case "igmp.checksum":
                    field.AssertShowHex(igmpDatagram.Checksum);
                    break;

                case "igmp.maddr":
                    field.AssertShow(igmpDatagram.GroupAddress.ToString());
                    break;

                case "igmp.max_resp":
                    field.AssertShowDecimal((int)((igmpDatagram.MaxResponseTime.TotalSeconds + 0.05) * 10));
                    break;

                case "igmp.checksum_bad":
                    field.AssertShowDecimal(!igmpDatagram.IsChecksumCorrect);
                    break;

                case "igmp.num_grp_recs":
                    field.AssertShowDecimal(igmpDatagram.NumberOfGroupRecords);
                    break;

                case "":
                    switch (igmpDatagram.MessageType)
                    {
                        case IgmpMessageType.MembershipReportVersion3:
                            CompareIgmpGroupRecord(field, igmpDatagram.GroupRecords[_groupRecordIndex++]);
                            break;

                        case IgmpMessageType.MembershipQuery:
                            CompareDatagram(field, null, igmpDatagram);
                            break;

                        case IgmpMessageType.MulticastTraceRouteResponse:
                            // todo support IGMP traceroute http://www.ietf.org/proceedings/48/I-D/idmr-traceroute-ipm-07.txt.
                            break;

                        default:
                            if (typeof(IgmpMessageType).GetEnumValues<IgmpMessageType>().Contains(igmpDatagram.MessageType))
                                throw new InvalidOperationException("Invalid message type " + igmpDatagram.MessageType);

                            field.AssertValue(igmpDatagram.Skip(1));
//                                field.AssertShow(igmpDatagram.Skip(1));
                            break;
                    }

                    break;

                case "igmp.s":
                    field.AssertShowDecimal(igmpDatagram.IsSuppressRouterSideProcessing);
                    break;

                case "igmp.qrv":
                    field.AssertShowDecimal(igmpDatagram.QueryRobustnessVariable);
                    break;

                case "igmp.qqic":
                    field.AssertShowDecimal(igmpDatagram.QueryIntervalCode);
                    break;

                case "igmp.num_src":
                    field.AssertShowDecimal(igmpDatagram.NumberOfSources);
                    break;

                case "igmp.saddr":
                    field.AssertShow(igmpDatagram.SourceAddresses[_sourceAddressIndex++].ToString());
                    break;

                case "igmp.identifier":
                    // todo support IGMP version 0 and IGMP identifier.
                    break;

                case "igmp.mtrace.max_hops":
                case "igmp.mtrace.saddr":
                case "igmp.mtrace.raddr":
                case "igmp.mtrace.rspaddr":
                case "igmp.mtrace.resp_ttl":
                case "igmp.mtrace.q_id":
                    // todo support IGMP traceroute http://www.ietf.org/proceedings/48/I-D/idmr-traceroute-ipm-07.txt.
                    Assert.AreEqual(IgmpMessageType.MulticastTraceRouteResponse, igmpDatagram.MessageType);
                    break;

                default:
                    throw new InvalidOperationException("Invalid igmp field " + field.Name());
            }

//.........這裏部分代碼省略.........
開發者ID:shrknt35,項目名稱:sonarlint-vs,代碼行數:101,代碼來源:WiresharkDatagramComparerIgmp.cs


注:本文中的System.Xml.Linq.XElement.Show方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。