Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

@Bart-Baekelandt

Description

@Bart-Baekelandt

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
.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions