OSPF V2 packet with link-local signaling (LLS) data not handled correctly
OSPF V2 packet with link-local signaling (LLS) data is not extracted correctly. The length of the LLS data is not determined by the OSPF header but by the IP header.
See RFC for this : https://datatracker.ietf.org/doc/html/rfc5613#section-2
The problem is that when an OSPF V2 packet is extracted Extract<OspfV2Packet>() then the length of the resulting packet does not include the LLS data. This is because the OspfV2Packet constructor does not contain a payload part.
Proposed solution :
protected OspfV2Packet(byte[] bytes, int offset) { Log.Debug(""); Header = new ByteArraySegment(bytes, offset, OspfV2Fields.HeaderLength); Version = OspfVersion.OspfV2;
// ==== BEGIN ADDITIONAL CODE =====
// Add payload
ushort OspfPacketLength = (ushort)(bytes.Length - offset);
ushort OspfDataLength = (ushort)(PacketLength - OspfV2Fields.HeaderLength); ;
if (OspfPacketLength > PacketLength)
{
OspfDataLength = (ushort)(OspfPacketLength - OspfV2Fields.HeaderLength);
}
PayloadPacketOrData = new LazySlim<PacketOrByteArraySegment>(() =>
{
var result = new PacketOrByteArraySegment();
// store the payload bytes
result.ByteArraySegment = new ByteArraySegment(bytes, offset + OspfV2Fields.HeaderLength, OspfDataLength, bytes.Length); ;
return result;
});
// ==== END ADDITIONAL CODE =====
}
Example trace added ospf_lls.zip .
Feel free to submit a PR for this.