Commit 4d770fb0 authored by Brickner_cp's avatar Brickner_cp

IPv6

parent 0bea8462
...@@ -50,6 +50,9 @@ namespace PcapDotNet.Packets.IpV6 ...@@ -50,6 +50,9 @@ namespace PcapDotNet.Packets.IpV6
{ {
buffer.Write(offset + Offset.NextHeader, (byte)NextHeader); buffer.Write(offset + Offset.NextHeader, (byte)NextHeader);
int length = Length; int length = Length;
// TODO: Remove this check.
if (length % 8 != 0)
throw new InvalidOperationException("Must be divided by 8.");
buffer.Write(offset + Offset.HeaderExtensionLength, (byte)((length / 8) - 1)); buffer.Write(offset + Offset.HeaderExtensionLength, (byte)((length / 8) - 1));
WriteData(buffer, offset + Offset.Data); WriteData(buffer, offset + Offset.Data);
offset += length; offset += length;
......
...@@ -262,12 +262,15 @@ namespace PcapDotNet.Packets.IpV6 ...@@ -262,12 +262,15 @@ namespace PcapDotNet.Packets.IpV6
{ {
if (messageDataMobilityOptionsOffset.HasValue) if (messageDataMobilityOptionsOffset.HasValue)
{ {
int mobilityOptionsExtraBytes = (messageDataMobilityOptionsOffset.Value - 2) % 8; int mobilityOptionsExtraBytes = (8 - (messageDataMobilityOptionsOffset.Value + 6) % 8) % 8;
if (mobilityOptions.BytesLength % 8 != mobilityOptionsExtraBytes) if (mobilityOptions.BytesLength % 8 != mobilityOptionsExtraBytes)
mobilityOptions = mobilityOptions.Pad((8 + mobilityOptionsExtraBytes - (mobilityOptions.BytesLength % 8)) % 8); mobilityOptions = mobilityOptions.Pad((8 + mobilityOptionsExtraBytes - (mobilityOptions.BytesLength % 8)) % 8);
} }
Checksum = checksum; Checksum = checksum;
MobilityOptions = mobilityOptions; MobilityOptions = mobilityOptions;
// TODO: Remove this.
if (Length % 8 != 0)
throw new InvalidOperationException("Must divide by 8");
} }
/// <summary> /// <summary>
...@@ -1834,7 +1837,7 @@ namespace PcapDotNet.Packets.IpV6 ...@@ -1834,7 +1837,7 @@ namespace PcapDotNet.Packets.IpV6
/// | 16 | MH Type | Reserved | /// | 16 | MH Type | Reserved |
/// +-----+-------------+-------------------------+ /// +-----+-------------+-------------------------+
/// | 32 | Checksum | /// | 32 | Checksum |
/// +-----+-------------+-------------------------+ /// +-----+---------------------------------------+
/// | 48 | Mobility Options | /// | 48 | Mobility Options |
/// | ... | | /// | ... | |
/// +-----+---------------------------------------+ /// +-----+---------------------------------------+
......
...@@ -82,7 +82,7 @@ namespace PcapDotNet.Packets.IpV6 ...@@ -82,7 +82,7 @@ namespace PcapDotNet.Packets.IpV6
Addresses = addresses.AsReadOnly(); Addresses = addresses.AsReadOnly();
PadSize = (byte)((8 - RoutingDataLength % 8) % 8); PadSize = (byte)((8 - Length % 8) % 8);
} }
public override IpV6RoutingType RoutingType public override IpV6RoutingType RoutingType
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment