Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Bart-Baekelandt opened this issue Nov 13, 2021 · 1 comment

Comments

@Bart-Baekelandt
Copy link
Contributor

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()
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
.

@PhyxionNL
Copy link
Collaborator

Feel free to submit a PR for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants