本文整理汇总了C#中DataSegment.ReadIpV4Address方法的典型用法代码示例。如果您正苦于以下问题:C# DataSegment.ReadIpV4Address方法的具体用法?C# DataSegment.ReadIpV4Address怎么用?C# DataSegment.ReadIpV4Address使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataSegment
的用法示例。
在下文中一共展示了DataSegment.ReadIpV4Address方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateInstance
internal override IpV6MobilityOption CreateInstance(DataSegment data)
{
if (data.Length != OptionDataLength)
return null;
return new IpV6MobilityOptionAlternateIpV4CareOfAddress(data.ReadIpV4Address(0, Endianity.Big));
}
示例2: 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;
}
示例3: Read
internal static bool Read(DataSegment data, out IpV4Address address)
{
if (data.Length != OptionDataLength)
{
address = IpV4Address.Zero;
return false;
}
address = data.ReadIpV4Address(Offset.Address, Endianity.Big);
return true;
}
示例4: CreateInstance
internal override IpV6MobilityOption CreateInstance(DataSegment data)
{
if (data.Length != OptionDataLength)
return null;
byte prefixLength = (byte)((data[Offset.PrefixLength] & Mask.PrefixLength) >> Shift.PrefixLength);
bool requestPrefix = data.ReadBool(Offset.RequestPrefix, Mask.RequestPrefix);
IpV4Address homeAddress = data.ReadIpV4Address(Offset.HomeAddress, Endianity.Big);
return new IpV6MobilityOptionIpV4HomeAddress(prefixLength, requestPrefix, homeAddress);
}
示例5: 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;
}
}
示例6: 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;
}
示例7: CreateInstance
internal override IpV6MobilityOption CreateInstance(DataSegment data)
{
if (data.Length != OptionDataLength)
return null;
IpV6AddressAcknowledgementStatus status = (IpV6AddressAcknowledgementStatus)data[Offset.Status];
byte prefixLength = (byte)((data[Offset.PrefixLength] & Mask.PrefixLength) >> Shift.PrefixLength);
IpV4Address homeAddress = data.ReadIpV4Address(Offset.HomeAddress, Endianity.Big);
return new IpV6MobilityOptionIpV4AddressAcknowledgement(status, prefixLength, homeAddress);
}
示例8: 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;
}
}