packetnet icon indicating copy to clipboard operation
packetnet copied to clipboard

OSPF V2 packet with link-local signaling (LLS) data not handled correctly

Open Bart-Baekelandt opened this issue 4 years ago • 1 comments

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 .

Bart-Baekelandt avatar Nov 13 '21 15:11 Bart-Baekelandt

Feel free to submit a PR for this.

PhyxionNL avatar Nov 16 '21 09:11 PhyxionNL