本文整理汇总了C#中DataSegment.ReadIpV6Address方法的典型用法代码示例。如果您正苦于以下问题:C# DataSegment.ReadIpV6Address方法的具体用法?C# DataSegment.ReadIpV6Address怎么用?C# DataSegment.ReadIpV6Address使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataSegment
的用法示例。
在下文中一共展示了DataSegment.ReadIpV6Address方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateInstance
internal override IpV6Option CreateInstance(DataSegment data)
{
if (data.Length != OptionDataLength)
return null;
IpV6Address homeAddress = data.ReadIpV6Address(0, Endianity.Big);
return new IpV6OptionHomeAddress(homeAddress);
}
示例2: CreateInstance
internal override IpV6MobilityOption CreateInstance(DataSegment data)
{
if (data.Length < OptionDataMinimumLength)
return null;
IpV6LocalMobilityAnchorAddressCode code = (IpV6LocalMobilityAnchorAddressCode)data[Offset.Code];
switch (code)
{
case IpV6LocalMobilityAnchorAddressCode.IpV6:
{
if (data.Length != Offset.LocalMobilityAnchorAddress + IpV6Address.SizeOf)
return null;
IpV6Address localMobilityAnchorAddress = data.ReadIpV6Address(Offset.LocalMobilityAnchorAddress, Endianity.Big);
return new IpV6MobilityOptionLocalMobilityAnchorAddress(localMobilityAnchorAddress);
}
case IpV6LocalMobilityAnchorAddressCode.IpV4:
{
if (data.Length != Offset.LocalMobilityAnchorAddress + IpV4Address.SizeOf)
return null;
IpV4Address localMobilityAnchorAddress = data.ReadIpV4Address(Offset.LocalMobilityAnchorAddress, Endianity.Big);
return new IpV6MobilityOptionLocalMobilityAnchorAddress(localMobilityAnchorAddress);
}
default:
return null;
}
}
示例3: ParseRoutingData
internal static IpV6ExtensionHeaderRoutingHomeAddress ParseRoutingData(IpV4Protocol nextHeader, byte segmentsLeft, DataSegment routingData)
{
if (routingData.Length != RoutingDataLength)
return null;
IpV6Address homeAddress = routingData.ReadIpV6Address(RoutingDataOffset.HomeAddress, Endianity.Big);
return new IpV6ExtensionHeaderRoutingHomeAddress(nextHeader, segmentsLeft, homeAddress);
}
示例4: 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 != OptionDataLength)
return null;
IpV6Address homeAddress = data.ReadIpV6Address(0, Endianity.Big);
return new IpV6OptionHomeAddress(homeAddress);
}
示例5: CreateInstance
internal override IpV6MobilityOption CreateInstance(DataSegment data)
{
if (data.Length != OptionDataLength)
return null;
if (data[Offset.AddressLength] != AddressLength)
return null;
return new IpV6MobilityOptionMobileAccessGatewayIpV6Address(data.ReadIpV6Address(Offset.Address, Endianity.Big));
}
示例6: Read
internal static bool Read(DataSegment data, out IpV6Address address)
{
if (data.Length != OptionDataLength)
{
address = IpV6Address.Zero;
return false;
}
address = data.ReadIpV6Address(0, Endianity.Big);
return true;
}
示例7: ParseRoutingData
internal static IpV6ExtensionHeaderRoutingSourceRoute ParseRoutingData(IpV4Protocol nextHeader, byte segmentsLeft, DataSegment routingData)
{
if (routingData.Length < RoutingDataMinimumLength)
return null;
if ((routingData.Length - RoutingDataMinimumLength) % IpV6Address.SizeOf != 0)
return null;
int numAddresses = (routingData.Length - RoutingDataMinimumLength) / 8;
IpV6Address[] addresses = new IpV6Address[numAddresses];
for (int i = 0; i != numAddresses; ++i)
addresses[i] = routingData.ReadIpV6Address(RoutingDataOffset.Addresses + i * IpV6Address.SizeOf, Endianity.Big);
return new IpV6ExtensionHeaderRoutingSourceRoute(nextHeader, segmentsLeft, addresses);
}
示例8: ParseMessageData
internal static IpV6ExtensionHeaderMobilityBindingError ParseMessageData(IpV4Protocol nextHeader, ushort checksum, DataSegment messageData)
{
if (messageData.Length < MinimumMessageDataLength)
return null;
IpV6BindingErrorStatus status = (IpV6BindingErrorStatus)messageData[MessageDataOffset.Status];
IpV6Address homeAddress = messageData.ReadIpV6Address(MessageDataOffset.HomeAddress, Endianity.Big);
IpV6MobilityOptions options = new IpV6MobilityOptions(messageData.Subsegment(MessageDataOffset.Options, messageData.Length - MessageDataOffset.Options));
return new IpV6ExtensionHeaderMobilityBindingError(nextHeader, checksum, status, homeAddress, options);
}
示例9: CreateInstance
internal override IpV6MobilityOption CreateInstance(DataSegment data)
{
if (data.Length < OptionDataMinimumLength)
return null;
bool isIpV4 = data.ReadBool(Offset.IsIpV4, Mask.IsIpV4);
bool isIpV6 = data.ReadBool(Offset.IsIpV6, Mask.IsIpV6);
if (isIpV4 && !isIpV6)
{
if (data.Length != OptionDataMinimumLength + IpV4Address.SizeOf)
return null;
IpV4Address localMobilityAddress = data.ReadIpV4Address(Offset.LocalMobilityAddress, Endianity.Big);
return new IpV6MobilityOptionRedirect(localMobilityAddress);
}
if (isIpV6 && !isIpV4)
{
if (data.Length != OptionDataMinimumLength + IpV6Address.SizeOf)
return null;
IpV6Address localMobilityAddress = data.ReadIpV6Address(Offset.LocalMobilityAddress, Endianity.Big);
return new IpV6MobilityOptionRedirect(localMobilityAddress);
}
return null;
}
示例10: CreateSpecificInstance
internal static IpV6OptionSmfDpdSequenceBased CreateSpecificInstance(DataSegment data)
{
IpV6TaggerIdType taggerIdType = (IpV6TaggerIdType)((data[Offset.TaggerIdType] & Mask.TaggerIdType) >> Shift.TaggerIdType);
int taggerIdLength = (taggerIdType == IpV6TaggerIdType.Null ? 0 : (data[Offset.TaggerIdLength] & Mask.TaggerIdLength) + 1);
if (data.Length < Offset.TaggerId + taggerIdLength)
return null;
DataSegment identifier = data.Subsegment(Offset.TaggerId + taggerIdLength, data.Length - Offset.TaggerId - taggerIdLength);
switch (taggerIdType)
{
case IpV6TaggerIdType.Null:
return new IpV6OptionSmfDpdNull(identifier);
case IpV6TaggerIdType.Default:
return new IpV6OptionSmfDpdDefault(data.Subsegment(Offset.TaggerId, taggerIdLength), identifier);
case IpV6TaggerIdType.IpV4:
if (taggerIdLength != IpV4Address.SizeOf)
return null;
IpV4Address ipV4Address = data.ReadIpV4Address(0, Endianity.Big);
return new IpV6OptionSmfDpdIpV4(ipV4Address, identifier);
case IpV6TaggerIdType.IpV6:
if (taggerIdLength != IpV6Address.SizeOf)
return null;
IpV6Address ipV6Address = data.ReadIpV6Address(0, Endianity.Big);
return new IpV6OptionSmfDpdIpV6(ipV6Address, identifier);
default:
return null;
}
}
示例11: Read
internal static bool Read(DataSegment data, out byte prefixLength, out IpV6Address networkPrefix)
{
if (data.Length != OptionDataLength)
{
prefixLength = 0;
networkPrefix = IpV6Address.Zero;
return false;
}
prefixLength = data[Offset.PrefixLength];
networkPrefix = data.ReadIpV6Address(Offset.NetworkPrefix, Endianity.Big);
return true;
}
示例12: CreateInstance
internal override IpV6MobilityOption CreateInstance(DataSegment data)
{
if (data.Length != OptionDataLength)
return null;
IpV6MobilityIpV6AddressPrefixCode code = (IpV6MobilityIpV6AddressPrefixCode)data[Offset.Code];
byte prefixLength = data[Offset.PrefixLength];
IpV6Address addressOrPrefix = data.ReadIpV6Address(Offset.AddressOrPrefix, Endianity.Big);
return new IpV6MobilityOptionIpV6AddressPrefix(code, prefixLength, addressOrPrefix);
}
示例13: CreateInstance
internal override IpV6MobilityOption CreateInstance(DataSegment data)
{
if (data.Length < OptionDataMinimumLength)
return null;
ushort bindingId = data.ReadUShort(Offset.BindingId, Endianity.Big);
IpV6BindingAcknowledgementStatus status = (IpV6BindingAcknowledgementStatus)data[Offset.Status];
bool simultaneousHomeAndForeignBinding = data.ReadBool(Offset.SimultaneousHomeAndForeignBinding, Mask.SimultaneousHomeAndForeignBinding);
byte priority = (byte)(data[Offset.Priority] & Mask.Priority);
if (data.Length == OptionDataMinimumLength)
return new IpV6MobilityOptionBindingIdentifier(bindingId, status, simultaneousHomeAndForeignBinding, priority);
if (data.Length == OptionDataMinimumLength + IpV4Address.SizeOf)
{
IpV4Address careOfAddress = data.ReadIpV4Address(Offset.CareOfAddress, Endianity.Big);
return new IpV6MobilityOptionBindingIdentifier(bindingId, status, simultaneousHomeAndForeignBinding, priority, careOfAddress);
}
if (data.Length == OptionDataMinimumLength + IpV6Address.SizeOf)
{
IpV6Address careOfAddress = data.ReadIpV6Address(Offset.CareOfAddress, Endianity.Big);
return new IpV6MobilityOptionBindingIdentifier(bindingId, status, simultaneousHomeAndForeignBinding, priority, careOfAddress);
}
return null;
}
示例14: ParseMessageData
internal static IpV6ExtensionHeaderMobilityHomeAgentSwitchMessage ParseMessageData(IpV4Protocol nextHeader, ushort checksum, DataSegment messageData)
{
if (messageData.Length < MinimumMessageDataLength)
return null;
byte numberOfAddresses = messageData[MessageDataOffset.NumberOfAddresses];
int homeAgentAddressesSize = numberOfAddresses * IpV6Address.SizeOf;
if (messageData.Length < MinimumMessageDataLength + homeAgentAddressesSize)
return null;
IpV6Address[] homeAgentAddresses = new IpV6Address[numberOfAddresses];
for (int i = 0; i != numberOfAddresses; ++i)
homeAgentAddresses[i] = messageData.ReadIpV6Address(MessageDataOffset.HomeAgentAddresses + i * IpV6Address.SizeOf, Endianity.Big);
int optionsOffset = MessageDataOffset.HomeAgentAddresses + homeAgentAddressesSize;
IpV6MobilityOptions options = new IpV6MobilityOptions(messageData.Subsegment(optionsOffset, messageData.Length - optionsOffset));
return new IpV6ExtensionHeaderMobilityHomeAgentSwitchMessage(nextHeader, checksum, homeAgentAddresses, options);
}