本文整理汇总了C#中DataSegment.ReadUShort方法的典型用法代码示例。如果您正苦于以下问题:C# DataSegment.ReadUShort方法的具体用法?C# DataSegment.ReadUShort怎么用?C# DataSegment.ReadUShort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataSegment
的用法示例。
在下文中一共展示了DataSegment.ReadUShort方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateInstance
internal override IpV6MobilityOption CreateInstance(DataSegment data)
{
if (data.Length != OptionDataLength)
return null;
ushort homeNonceIndex = data.ReadUShort(Offset.HomeNonceIndex, Endianity.Big);
ushort careOfNonceIndex = data.ReadUShort(Offset.CareOfNonceIndex, Endianity.Big);
return new IpV6MobilityOptionNonceIndexes(homeNonceIndex, careOfNonceIndex);
}
示例2: CreateInstance
internal override IpV6Option CreateInstance(DataSegment data)
{
if (data.Length != OptionDataLength)
return null;
return new IpV6OptionRouterAlert((IpV6RouterAlertType)data.ReadUShort(0, Endianity.Big));
}
示例3: CreateInstance
internal override IpV6MobilityOption CreateInstance(DataSegment data)
{
if (data.Length != OptionDataLength)
return null;
return new IpV6MobilityOptionBindingRefreshAdvice(data.ReadUShort(0, Endianity.Big));
}
示例4: CreateInstance
/// <summary>
/// Parses the given data to create a router alert IPv6 option.
/// </summary>
/// <param name="data">The data to parse to create the option.</param>
/// <returns>Router alert IPv6 option according to the data parsed.</returns>
public IpV6Option CreateInstance(DataSegment data)
{
if (data == null)
throw new ArgumentNullException("data");
if (data.Length != OptionDataLength)
return null;
return new IpV6OptionRouterAlert((IpV6RouterAlertType)data.ReadUShort(0, Endianity.Big));
}
示例5: CreateInstance
internal override IpV6FlowIdentificationSubOption CreateInstance(DataSegment data)
{
if (data.Length % sizeof(ushort) != 0)
return null;
ushort[] bindingIds = new ushort[data.Length / sizeof(ushort)];
for (int i = 0; i != bindingIds.Length; ++i)
bindingIds[i] = data.ReadUShort(i * sizeof(ushort), Endianity.Big);
return new IpV6FlowIdentificationSubOptionBindingReference(bindingIds);
}
示例6: ParseData
internal static IpV6ExtensionHeaderFragmentData ParseData(IpV4Protocol nextHeader, DataSegment data)
{
if (data.Length != DataLength)
return null;
ushort fragmentOffset = (ushort)((data.ReadUShort(DataOffset.FragmentOffset, Endianity.Big) & DataMask.FragmentOffset) >> DataShift.FragmentOffset);
bool moreFragments = data.ReadBool(DataOffset.MoreFragments, DataMask.MoreFragments);
uint identification = data.ReadUInt(DataOffset.Identification, Endianity.Big);
return new IpV6ExtensionHeaderFragmentData(nextHeader, fragmentOffset, moreFragments, identification);
}
示例7: 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;
IpV6CalipsoDomainOfInterpretation domainOfInterpretation = (IpV6CalipsoDomainOfInterpretation)data.ReadUInt(Offset.DomainOfInterpretation,
Endianity.Big);
byte compartmentLength = data[Offset.CompartmentLength];
int compartmentLengthInBytes = compartmentLength * sizeof(int);
if (OptionDataMinimumLength + compartmentLengthInBytes > data.Length)
return null;
byte sensitivityLevel = data[Offset.SensitivityLevel];
ushort checksum = data.ReadUShort(Offset.Checksum, Endianity.Big);
DataSegment compartmentBitmap = data.Subsegment(Offset.CompartmentBitmap, compartmentLengthInBytes);
return new IpV6OptionCalipso(domainOfInterpretation, sensitivityLevel, checksum, compartmentBitmap);
}
示例8: ParseMessageData
internal static IpV6ExtensionHeaderMobilityBindingRevocationMessage ParseMessageData(IpV4Protocol nextHeader, ushort checksum, DataSegment messageData)
{
if (messageData.Length < MinimumMessageDataLength)
return null;
IpV6MobilityBindingRevocationType bindingRevocationType = (IpV6MobilityBindingRevocationType)messageData[MessageDataOffset.BindingRevocationType];
byte revocationTriggerOrStatus = messageData[MessageDataOffset.RevocationTriggerOrStatus];
ushort sequenceNumber = messageData.ReadUShort(MessageDataOffset.SequenceNumber, Endianity.Big);
bool proxyBinding = messageData.ReadBool(MessageDataOffset.ProxyBinding, MessageDataMask.ProxyBinding);
bool ipV4HomeAddressBindingOnly = messageData.ReadBool(MessageDataOffset.IpV4HomeAddressBindingOnly, MessageDataMask.IpV4HomeAddressBindingOnly);
bool global = messageData.ReadBool(MessageDataOffset.Global, MessageDataMask.Global);
IpV6MobilityOptions options =
new IpV6MobilityOptions(messageData.Subsegment(MessageDataOffset.Options, messageData.Length - MessageDataOffset.Options));
switch (bindingRevocationType)
{
case IpV6MobilityBindingRevocationType.BindingRevocationIndication:
return new IpV6ExtensionHeaderMobilityBindingRevocationIndicationMessage(nextHeader, checksum, (Ipv6MobilityBindingRevocationTrigger)revocationTriggerOrStatus, sequenceNumber,
proxyBinding, ipV4HomeAddressBindingOnly, global, options);
case IpV6MobilityBindingRevocationType.BindingRevocationAcknowledgement:
return new IpV6ExtensionHeaderMobilityBindingRevocationAcknowledgementMessage(nextHeader, checksum,
(Ipv6MobilityBindingRevocationStatus)revocationTriggerOrStatus,
sequenceNumber, proxyBinding, ipV4HomeAddressBindingOnly,
global, options);
default:
return null;
}
}
示例9: ReadTotalLength
private static ushort ReadTotalLength(DataSegment ipV4Datagram)
{
return ipV4Datagram.ReadUShort(Offset.TotalLength, Endianity.Big);
}
示例10: ParseMessageData
internal static IpV6ExtensionHeaderMobilityHandoverInitiateMessage ParseMessageData(IpV4Protocol nextHeader, ushort checksum, DataSegment messageData)
{
if (messageData.Length < MinimumMessageDataLength)
return null;
ushort sequenceNumber = messageData.ReadUShort(MessageDataOffset.SequenceNumber, Endianity.Big);
bool assignedAddressConfiguration = messageData.ReadBool(MessageDataOffset.AssignedAddressConfiguration,
MessageDataMask.AssignedAddressConfiguration);
bool buffer = messageData.ReadBool(MessageDataOffset.Buffer, MessageDataMask.Buffer);
IpV6HandoverInitiateMessageCode code = (IpV6HandoverInitiateMessageCode)messageData[MessageDataOffset.Code];
IpV6MobilityOptions options = new IpV6MobilityOptions(messageData.Subsegment(MessageDataOffset.Options, messageData.Length - MessageDataOffset.Options));
return new IpV6ExtensionHeaderMobilityHandoverInitiateMessage(nextHeader, checksum, sequenceNumber, assignedAddressConfiguration, buffer, code, options);
}
示例11: CreateInstance
internal override IpV6Option CreateInstance(DataSegment data)
{
if (data.Length < OptionDataMinimumLength)
return null;
bool down = data.ReadBool(Offset.Down, Mask.Down);
bool rankError = data.ReadBool(Offset.RankError, Mask.RankError);
bool forwardingError = data.ReadBool(Offset.ForwardingError, Mask.ForwardingError);
byte rplInstanceId = data[Offset.RplInstanceId];
ushort senderRank = data.ReadUShort(Offset.SenderRank, Endianity.Big);
DataSegment subTlvs = data.Subsegment(Offset.SubTlvs, data.Length - Offset.SubTlvs);
return new IpV6OptionRoutingProtocolLowPowerAndLossyNetworks(down, rankError, forwardingError, rplInstanceId, senderRank, subTlvs);
}
示例12: ParseMessageData
internal static IpV6ExtensionHeaderMobilityBindingAcknowledgement ParseMessageData(IpV4Protocol nextHeader, ushort checksum, DataSegment messageData)
{
if (messageData.Length < MinimumMessageDataLength)
return null;
IpV6BindingAcknowledgementStatus status = (IpV6BindingAcknowledgementStatus)messageData[MessageDataOffset.Status];
bool keyManagementMobilityCapability = messageData.ReadBool(MessageDataOffset.KeyManagementMobilityCapability,
MessageDataMask.KeyManagementMobilityCapability);
ushort sequenceNumber = messageData.ReadUShort(MessageDataOffset.SequenceNumber, Endianity.Big);
ushort lifetime = messageData.ReadUShort(MessageDataOffset.Lifetime, Endianity.Big);
IpV6MobilityOptions options = new IpV6MobilityOptions(messageData.Subsegment(MessageDataOffset.Options, messageData.Length - MessageDataOffset.Options));
return new IpV6ExtensionHeaderMobilityBindingAcknowledgement(nextHeader, checksum, status, keyManagementMobilityCapability, sequenceNumber, lifetime,
options);
}
示例13: ParseData
internal static IpV6ExtensionHeaderMobility ParseData(IpV4Protocol nextHeader, DataSegment data)
{
if (data.Length < MinimumDataLength)
return null;
IpV6MobilityHeaderType mobilityHeaderType = (IpV6MobilityHeaderType)data[DataOffset.MobilityHeaderType];
ushort checksum = data.ReadUShort(DataOffset.Checksum, Endianity.Big);
DataSegment messageData = data.Subsegment(DataOffset.MessageData, data.Length - DataOffset.MessageData);
switch (mobilityHeaderType)
{
case IpV6MobilityHeaderType.BindingRefreshRequest: // 0
return IpV6ExtensionHeaderMobilityBindingRefreshRequest.ParseMessageData(nextHeader, checksum, messageData);
case IpV6MobilityHeaderType.HomeTestInit: // 1
return IpV6ExtensionHeaderMobilityHomeTestInit.ParseMessageData(nextHeader, checksum, messageData);
case IpV6MobilityHeaderType.CareOfTestInit: // 2
return IpV6ExtensionHeaderMobilityCareOfTestInit.ParseMessageData(nextHeader, checksum, messageData);
case IpV6MobilityHeaderType.HomeTest: // 3
return IpV6ExtensionHeaderMobilityHomeTest.ParseMessageData(nextHeader, checksum, messageData);
case IpV6MobilityHeaderType.CareOfTest: // 4
return IpV6ExtensionHeaderMobilityCareOfTest.ParseMessageData(nextHeader, checksum, messageData);
case IpV6MobilityHeaderType.BindingUpdate: // 5
return IpV6ExtensionHeaderMobilityBindingUpdate.ParseMessageData(nextHeader, checksum, messageData);
case IpV6MobilityHeaderType.BindingAcknowledgement: // 6
return IpV6ExtensionHeaderMobilityBindingAcknowledgement.ParseMessageData(nextHeader, checksum, messageData);
case IpV6MobilityHeaderType.BindingError: // 7
return IpV6ExtensionHeaderMobilityBindingError.ParseMessageData(nextHeader, checksum, messageData);
case IpV6MobilityHeaderType.FastBindingUpdate: // 8
return IpV6ExtensionHeaderMobilityFastBindingUpdate.ParseMessageData(nextHeader, checksum, messageData);
case IpV6MobilityHeaderType.FastBindingAcknowledgement: // 9
return IpV6ExtensionHeaderMobilityFastBindingAcknowledgement.ParseMessageData(nextHeader, checksum, messageData);
case IpV6MobilityHeaderType.FastNeighborAdvertisement: // 10
return IpV6ExtensionHeaderMobilityFastNeighborAdvertisement.ParseMessageData(nextHeader, checksum, messageData);
case IpV6MobilityHeaderType.Experimental: // 11
return IpV6ExtensionHeaderMobilityExperimental.ParseMessageData(nextHeader, checksum, messageData);
case IpV6MobilityHeaderType.HomeAgentSwitchMessage: // 12
return IpV6ExtensionHeaderMobilityHomeAgentSwitchMessage.ParseMessageData(nextHeader, checksum, messageData);
case IpV6MobilityHeaderType.HeartbeatMessage: // 13
return IpV6ExtensionHeaderMobilityHeartbeatMessage.ParseMessageData(nextHeader, checksum, messageData);
case IpV6MobilityHeaderType.HandoverInitiateMessage: // 14
return IpV6ExtensionHeaderMobilityHandoverInitiateMessage.ParseMessageData(nextHeader, checksum, messageData);
case IpV6MobilityHeaderType.HandoverAcknowledgeMessage: // 15
return IpV6ExtensionHeaderMobilityHandoverAcknowledgeMessage.ParseMessageData(nextHeader, checksum, messageData);
case IpV6MobilityHeaderType.BindingRevocationMessage: // 16
return IpV6ExtensionHeaderMobilityBindingRevocationMessage.ParseMessageData(nextHeader, checksum, messageData);
case IpV6MobilityHeaderType.LocalizedRoutingInitiation: // 17
return IpV6ExtensionHeaderMobilityLocalizedRoutingInitiation.ParseMessageData(nextHeader, checksum, messageData);
case IpV6MobilityHeaderType.LocalizedRoutingAcknowledgement: // 18
return IpV6ExtensionHeaderMobilityLocalizedRoutingAcknowledgement.ParseMessageData(nextHeader, checksum, messageData);
default:
return null;
}
}
示例14: Read
internal static DnsOptionLongLivedQuery Read(DataSegment data)
{
if (data.Length != ConstDataLength)
return null;
ushort version = data.ReadUShort(Offset.Version, Endianity.Big);
DnsLongLivedQueryOpCode opCode = (DnsLongLivedQueryOpCode)data.ReadUShort(Offset.OpCode, Endianity.Big);
DnsLongLivedQueryErrorCode errorCode = (DnsLongLivedQueryErrorCode)data.ReadUShort(Offset.ErrorCode, Endianity.Big);
ulong id = data.ReadULong(Offset.Id, Endianity.Big);
uint leaseLife = data.ReadUInt(Offset.LeaseLife, Endianity.Big);
return new DnsOptionLongLivedQuery(version, opCode, errorCode, id, leaseLife);
}
示例15: Read
internal static DnsOptionClientSubnet Read(DataSegment data)
{
if (data.Length < MinimumDataLength)
return null;
AddressFamily family = (AddressFamily)data.ReadUShort(Offset.Family, Endianity.Big);
byte sourceNetmask = data[Offset.SourceNetmask];
byte scopeNetmask = data[Offset.ScopeNetmask];
DataSegment address = data.Subsegment(Offset.Address, data.Length - Offset.Address);
return new DnsOptionClientSubnet(family, sourceNetmask, scopeNetmask, address);
}