当前位置: 首页>>代码示例>>C#>>正文


C# DataSegment.Subsegment方法代码示例

本文整理汇总了C#中DataSegment.Subsegment方法的典型用法代码示例。如果您正苦于以下问题:C# DataSegment.Subsegment方法的具体用法?C# DataSegment.Subsegment怎么用?C# DataSegment.Subsegment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataSegment的用法示例。


在下文中一共展示了DataSegment.Subsegment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateInstance

        internal override IpV6Option CreateInstance(DataSegment data)
        {
            if (data.Length < OptionDataMinimumLength)
                return null;
            
            int sourceEndpointIdentifierLength = data[Offset.SourceEndpointIdentifierLength];
            int destinationEndpointIdentifierLength = data[Offset.DestinationEndpointIdentifierLength];
            if (data.Length != OptionDataMinimumLength + sourceEndpointIdentifierLength + destinationEndpointIdentifierLength)
                return null;

            DataSegment sourceEndpointIdentifier = data.Subsegment(Offset.SourceEndpointIdentifier, sourceEndpointIdentifierLength);
            int destinationEndpointIdentifierOffset = Offset.SourceEndpointIdentifier + sourceEndpointIdentifierLength;
            DataSegment destinationEndpointIdentifier = data.Subsegment(destinationEndpointIdentifierOffset, destinationEndpointIdentifierLength);
            return new IpV6OptionEndpointIdentification(sourceEndpointIdentifier, destinationEndpointIdentifier);
        }
开发者ID:shrknt35,项目名称:sonarlint-vs,代码行数:15,代码来源:IpV6OptionEndpointIdentification.cs

示例2: ParseData

        internal static IpV6ExtensionHeaderRouting ParseData(IpV4Protocol nextHeader, DataSegment data)
        {
            if (data.Length < DataMinimumLength)
                return null;
            IpV6RoutingType routingType = (IpV6RoutingType)data[DataOffset.RoutingType];
            byte segmentsLeft = data[DataOffset.SegmentsLeft];
            DataSegment routingData = data.Subsegment(DataOffset.TypeSpecificData, data.Length - DataOffset.TypeSpecificData);
            switch (routingType)
            {
                case IpV6RoutingType.SourceRoute:
                    return IpV6ExtensionHeaderRoutingSourceRoute.ParseRoutingData(nextHeader, segmentsLeft, routingData);

                case IpV6RoutingType.Nimrod:
                    // Unused.
                    return null;

                case IpV6RoutingType.Type2RoutingHeader:
                    return IpV6ExtensionHeaderRoutingHomeAddress.ParseRoutingData(nextHeader, segmentsLeft, routingData);

                case IpV6RoutingType.RplSourceRouteHeader:
                    return IpV6ExtensionHeaderRoutingRpl.ParseRoutingData(nextHeader, segmentsLeft, routingData);

                default:
                    return null;
            }
        }
开发者ID:shrknt35,项目名称:sonarlint-vs,代码行数:26,代码来源:IpV6ExtensionHeaderRouting.cs

示例3: CreateStandardInstance

        private static IpV6ExtensionHeader CreateStandardInstance(IpV4Protocol nextHeader, DataSegment extensionHeaderData, out int numBytesRead)
        {
            numBytesRead = 0;
            if (extensionHeaderData.Length < MinimumLength)
                return null;
            IpV4Protocol nextNextHeader = (IpV4Protocol)extensionHeaderData[Offset.NextHeader];
            int length = (extensionHeaderData[Offset.HeaderExtensionLength] + 1) * 8;
            if (extensionHeaderData.Length < length)
                return null;

            DataSegment data = extensionHeaderData.Subsegment(Offset.Data, length - Offset.Data);
            numBytesRead = data.Length;

            switch (nextHeader)
            {
                case IpV4Protocol.IpV6HopByHopOption: // 0
                    return IpV6ExtensionHeaderHopByHopOptions.ParseData(nextNextHeader, data);

                case IpV4Protocol.IpV6Route: // 43
                    return IpV6ExtensionHeaderRouting.ParseData(nextNextHeader, data);

                case IpV4Protocol.FragmentHeaderForIpV6: // 44
                    return IpV6ExtensionHeaderFragmentData.ParseData(nextNextHeader, data);
                
                case IpV4Protocol.IpV6Opts:                     // 60
                    return IpV6ExtensionHeaderDestinationOptions.ParseData(nextNextHeader, data);

                case IpV4Protocol.MobilityHeader:        // 135
                    return IpV6ExtensionHeaderMobility.ParseData(nextNextHeader, data);

                default:
                    throw new InvalidOperationException("Invalid nextHeader value" + nextHeader);
            }
        }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:34,代码来源:IpV6ExtensionHeader.cs

示例4: ParseMessageData

        internal static IpV6ExtensionHeaderMobilityFastNeighborAdvertisement ParseMessageData(IpV4Protocol nextHeader, ushort checksum, DataSegment messageData)
        {
            if (messageData.Length < MinimumMessageDataLength)
                return null;

            IpV6MobilityOptions options = new IpV6MobilityOptions(messageData.Subsegment(MessageDataOffset.Options, messageData.Length - MessageDataOffset.Options));
            return new IpV6ExtensionHeaderMobilityFastNeighborAdvertisement(nextHeader, checksum, options);
        }
开发者ID:amitla,项目名称:Pcap.Net,代码行数:8,代码来源:IpV6ExtensionHeaderMobilityFastNeighborAdvertisement.cs

示例5: CreateInstance

        internal override IpV6MobilityOption CreateInstance(DataSegment data)
        {
            if (data.Length < OptionDataMinimumLength)
                return null;

            DataSegment linkLayerIdentifier = data.Subsegment(Offset.LinkLayerIdentifier, data.Length - Offset.LinkLayerIdentifier);
            return new IpV6MobilityOptionMobileNodeLinkLayerIdentifier(linkLayerIdentifier);
        }
开发者ID:JackWangCUMT,项目名称:WiFiSpy,代码行数:8,代码来源:IpV6MobilityOptionMobileNodeLinkLayerIdentifier.cs

示例6: CreateInstance

        internal override IpV6FlowIdentificationSubOption CreateInstance(DataSegment data)
        {
            if (data.Length < OptionDataMinimumLength)
                return null;

            IpV6FlowIdentificationTrafficSelectorFormat trafficSelectorFormat = (IpV6FlowIdentificationTrafficSelectorFormat)data[Offset.TrafficSelectorFormat];
            DataSegment trafficSelector = data.Subsegment(Offset.TrafficSelector, data.Length - Offset.TrafficSelector);
            return new IpV6FlowIdentificationSubOptionTrafficSelector(trafficSelectorFormat, trafficSelector);
        }
开发者ID:JackWangCUMT,项目名称:WiFiSpy,代码行数:9,代码来源:IpV6FlowIdentificationSubOptionTrafficSelector.cs

示例7: CreateInstance

        internal override IpV6MobilityOption CreateInstance(DataSegment data)
        {
            if (data.Length < OptionDataMinimumLength)
                return null;

            IpV6MobilityLinkLayerAddressCode code = (IpV6MobilityLinkLayerAddressCode)data[Offset.OptionCode];
            DataSegment linkLayerAddress = data.Subsegment(Offset.LinkLayerAddress, data.Length - Offset.LinkLayerAddress);

            return new IpV6MobilityOptionLinkLayerAddress(code, linkLayerAddress);
        }
开发者ID:amitla,项目名称:Pcap.Net,代码行数:10,代码来源:IpV6MobilityOptionLinkLayerAddress.cs

示例8: CreateInstance

        internal override IpV6AccessNetworkIdentifierSubOption CreateInstance(DataSegment data)
        {
            if (data.Length < OptionDataMinimumLength)
                return null;

            IpV6AccessNetworkIdentifierOperatorIdentifierType identifierType = (IpV6AccessNetworkIdentifierOperatorIdentifierType)data[Offset.IdentifierType];
            DataSegment identifier = data.Subsegment(Offset.Identifier, data.Length - Offset.Identifier);

            return new IpV6AccessNetworkIdentifierSubOptionOperatorIdentifier(identifierType, identifier);
        }
开发者ID:amitla,项目名称:Pcap.Net,代码行数:10,代码来源:IpV6AccessNetworkIdentifierSubOptionOperatorIdentifier.cs

示例9: CreateInstance

        internal override IpV6MobilityOption CreateInstance(DataSegment data)
        {
            if (data.Length < OptionDataMinimumLength)
                return null;

            uint vendorId = data.ReadUInt(Offset.VendorId, Endianity.Big);
            byte subType = data[Offset.SubType];
            DataSegment vendorSpecificData = data.Subsegment(Offset.Data, data.Length - Offset.Data);
            return new IpV6MobilityOptionVendorSpecific(vendorId, subType, vendorSpecificData);
        }
开发者ID:amitla,项目名称:Pcap.Net,代码行数:10,代码来源:IpV6MobilityOptionVendorSpecific.cs

示例10: ReadString

        internal static DataSegment ReadString(DataSegment data, ref int offset)
        {
            if (data.Length <= offset)
                return null;
            int stringLength = data[offset++];
            if (data.Length < offset + stringLength)
                return null;
            DataSegment str = data.Subsegment(ref offset, stringLength);

            return str;
        }
开发者ID:amitla,项目名称:Pcap.Net,代码行数:11,代码来源:DnsResourceData.cs

示例11: CreateInstance

        internal override IpV6MobilityOption CreateInstance(DataSegment data)
        {
            if (data.Length < OptionDataMinimumLength)
                return null;

            IpV6AuthenticationSubtype subtype = (IpV6AuthenticationSubtype)data[Offset.Subtype];
            uint mobilitySecurityParameterIndex = data.ReadUInt(Offset.MobilitySecurityParameterIndex, Endianity.Big);
            DataSegment authenticationData = data.Subsegment(Offset.AuthenticationData, data.Length - Offset.AuthenticationData);

            return new IpV6MobilityOptionAuthentication(subtype, mobilitySecurityParameterIndex, authenticationData);
        }
开发者ID:amitla,项目名称:Pcap.Net,代码行数:11,代码来源:IpV6MobilityOptionAuthentication.cs

示例12: CreateInstance

        internal override IpV6Option CreateInstance(DataSegment data)
        {
            if (data.Length < OptionDataMinimumLength)
                return null;

            int lineIdentificationLegnth = data[Offset.LineIdentificationLength];
            if (data.Length != OptionDataMinimumLength + lineIdentificationLegnth)
                return null;

            DataSegment lineIdentification = data.Subsegment(Offset.LineIdentification, data.Length - Offset.LineIdentification);
            return new IpV6OptionLineIdentificationDestination(lineIdentification);
        }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:12,代码来源:IpV6OptionLineIdentificationDestination.cs

示例13: CreateInstance

        internal override IpV6MobilityOption CreateInstance(DataSegment data)
        {
            if (data.Length < OptionDataMinimumLength)
                return null;

            IpV6MobileNodeIdentifierSubtype subtype = (IpV6MobileNodeIdentifierSubtype)data[Offset.Subtype];
            DataSegment identifier = data.Subsegment(Offset.Identifier, data.Length - Offset.Identifier);
            if (subtype == IpV6MobileNodeIdentifierSubtype.NetworkAccessIdentifier && identifier.Length < MinNetworkAccessIdentifierLength)
                return null;

            return new IpV6MobilityOptionMobileNodeIdentifier(subtype, identifier);
        }
开发者ID:amitla,项目名称:Pcap.Net,代码行数:12,代码来源:IpV6MobilityOptionMobileNodeIdentifier.cs

示例14: CreateInstance

        /// <summary>
        /// Parses an option from the given data.
        /// </summary>
        /// <param name="data">The data to parse.</param>
        /// <returns>The option if parsing was successful, null otherwise.</returns>
        public IpV6Option CreateInstance(DataSegment data)
        {
            if (data == null) 
                throw new ArgumentNullException("data");
            if (data.Length < OptionDataMinimumLength)
                return null;

            int lineIdentificationLegnth = data[Offset.LineIdentificationLength];
            if (data.Length != OptionDataMinimumLength + lineIdentificationLegnth)
                return null;

            DataSegment lineIdentification = data.Subsegment(Offset.LineIdentification, data.Length - Offset.LineIdentification);
            return new IpV6OptionLineIdentificationDestination(lineIdentification);
        }
开发者ID:amitla,项目名称:Pcap.Net,代码行数:19,代码来源:IpV6OptionLineIdentificationDestination.cs

示例15: ParseRoutingData

        internal static IpV6ExtensionHeaderRoutingRpl ParseRoutingData(IpV4Protocol nextHeader, byte segmentsLeft, DataSegment routingData)
        {
            if (routingData.Length < RoutingDataMinimumLength)
                return null;

            byte commonPrefixLengthForNonLastAddresses =
                (byte)((routingData[RoutingDataOffset.CommonPrefixLengthForNonLastAddresses] & RoutingDataMask.CommonPrefixLengthForNonLastAddresses) >>
                       RoutingDataShift.CommonPrefixLengthForNonLastAddresses);
            if (commonPrefixLengthForNonLastAddresses >= MaxCommonPrefixLength)
                return null;

            byte commonPrefixLengthForLastAddress =
                (byte)(routingData[RoutingDataOffset.CommonPrefixLengthForLastAddress] & RoutingDataMask.CommonPrefixLengthForLastAddress);
            if (commonPrefixLengthForLastAddress > MaxCommonPrefixLength)
                return null;

            byte padSize = (byte)((routingData[RoutingDataOffset.PadSize] & RoutingDataMask.PadSize) >> RoutingDataShift.PadSize);
            if (padSize > MaxPadSize)
                return null;

            int numAddresses = (routingData.Length - RoutingDataOffset.Addresses - padSize - (IpV6Address.SizeOf - commonPrefixLengthForLastAddress)) /
                               (IpV6Address.SizeOf - commonPrefixLengthForNonLastAddresses) + 1;
            if (numAddresses < 0)
                return null;

            IpV6Address[] addresses = new IpV6Address[numAddresses];
            if (numAddresses > 0)
            {
                byte[] addressBytes = new byte[IpV6Address.SizeOf];
                for (int i = 0; i < numAddresses - 1; ++i)
                {
                    DataSegment addressSegment =
                        routingData.Subsegment(RoutingDataOffset.Addresses + i * (IpV6Address.SizeOf - commonPrefixLengthForNonLastAddresses),
                                               commonPrefixLengthForNonLastAddresses);
                    addressSegment.Write(addressBytes, 0);
                    addresses[i] = addressBytes.ReadIpV6Address(0, Endianity.Big);
                }

                addressBytes = new byte[IpV6Address.SizeOf];
                DataSegment lastAddressSegment =
                    routingData.Subsegment(RoutingDataOffset.Addresses + (numAddresses - 1) * (IpV6Address.SizeOf - commonPrefixLengthForNonLastAddresses),
                                           commonPrefixLengthForLastAddress);
                lastAddressSegment.Write(addressBytes, 0);
                addresses[numAddresses - 1] = addressBytes.ReadIpV6Address(0, Endianity.Big);
            }
            return new IpV6ExtensionHeaderRoutingRpl(nextHeader, segmentsLeft, commonPrefixLengthForNonLastAddresses, commonPrefixLengthForLastAddress, padSize,
                                                     addresses);
        }
开发者ID:shrknt35,项目名称:sonarlint-vs,代码行数:48,代码来源:IpV6ExtensionHeaderRoutingRpl.cs


注:本文中的DataSegment.Subsegment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。