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

EthrnetPacket.PayloadPacket.ParentPacket is always null. Is that right? #115

Open
badmadbug opened this issue Nov 29, 2020 · 3 comments
Open

Comments

@badmadbug
Copy link

badmadbug commented Nov 29, 2020

Hello?

When I try to parse udp packet like this:

Packet packet = Packet.ParsePacket( LinkLayers.Ethernet, raw_capture.Data ) ;
Debug.Assert( packet is EthernetPacket ) ; // OK.
Debug.Assert( packet.PayloadPacket is IPv4Packet ) ; // OK
Debug.Assert( packet.PayloadPacket.ParentPacket != null ) ; // Nop. it is always null.

In my thought, packet.PayloadPacket should be IPv4Packet, and packet.PayloadPacket.ParentPacket must be packet itself. Isn't it?
But, in my code, packet.PayloadPacket is IPv4Packet, but packet.PayloadPacket.ParentPacket is always null.

It is null even I try with ARP packet.

What should I do or check?

My PacketDotNet is downloaded from nuget.org and its version is v1.1.1.

@lovejotd
Copy link

Is there a strong reason you want to do this? Just not sure the rationale here. I tested it as well, and see the same behavior that you see.

@PhyxionNL
Copy link
Collaborator

Parent packet isn't passed down here:
https://github.com/chmorgan/packetnet/blob/2775ea7f8fef4edee445ef7087eaa04a3612c920/PacketDotNet/EthernetPacket.cs#L215
This can be improved I think, but I don't have time to look into this right now. Although the use case is probably limited, I suggest always passing down EthernetPacket or just the contained packet if you only need that.

@badmadbug
Copy link
Author

badmadbug commented Dec 20, 2020

Is there a strong reason you want to do this? Just not sure the rationale here. I tested it as well, and see the same behavior that you see.

For example, when I work with UdpPacket, I will create List<UdpPacket>. I don't want create List<Packet>, because Packet.Extract() must be used whenever I need to access UdpPacket.

In this situation, UdpPacket.ParentPacket and/or UdpPacket.ParentPacket.ParentPacket is null. So I cannot get IpPacket or EthernetPacket from UdpPacket to find source ip or mac address.

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

No branches or pull requests

3 participants