Giter Club home page Giter Club logo

Comments (5)

perdisci avatar perdisci commented on June 2, 2024 2

Ah yes, you are right, this seems like a duplicate of #657. Apologies for not noticing that.

My 2 cents: I think the correct behavior is what suggested by @weyrick in #657. For VLAN layers and similar cases at the link layer, can't you look at the header's EtherType field (or other header fields for link layers other than Ethernet) to determine the type of the next layer and decide if you do need to parse it or not, depending on the value of parseUntilLayer?
https://en.wikipedia.org/wiki/IEEE_802.1Q

Also, the transport layer is well defined. If one asks to stop parsing there (and not parse the application layer payload), I think it should be feasible to honor that request. But I don't know the pcpp code base well enough to make more detailed suggestions.

For my use case (do not parse application layer) using < parseUntilLayer instead of <= is sufficient, so I fixed it in my local fork, but as you mentioned this may not generalize to all cases/layers without further changes.

Thanks for looking into this.

from pcapplusplus.

tigercosmos avatar tigercosmos commented on June 2, 2024

could you provide more detail? such as the pcap file of the packet that you tried to parse.

from pcapplusplus.

perdisci avatar perdisci commented on June 2, 2024

I found this bug when trying to parse packets containing malformed DNS messages:
20180203-dns.zip

pcpp::Packet packet(&rawPacket, pcpp::OsiModelTransportLayer); still causes a DNS parsing error message, indicating that parsing goes beyond the transport layer (UDP, in this case) and continues to the next layer.

The DNS parsing error is DNS layer contains more than 300 resources, probably a bad packet. Skipping parsing DNS resources, which is caused because DnsLayer::parseResources() is called, although it should not be, if parsing actually stopped at the UDP layer.

from pcapplusplus.

seladb avatar seladb commented on June 2, 2024

@perdisci I think it's a duplicate of #657, am I missing something?

Please see my response here on why an "extra layer" is being parsed: #657 (comment)

The issue is that there might be several layers of the same OSI layer. The most trivial example I can think of is multiple VLAN layers. If we change <= to < only the first VLAN layer will be parsed.
The only way to know what the next layer would be is to parse it. Maybe we can introduce "partial parsing" or "detect layer" functionality that does the minimum work needed to detect what is the next layer 🤔

from pcapplusplus.

seladb avatar seladb commented on June 2, 2024

Thanks @perdisci ! yes, I think @weyrick 's idea is a nice way to fix it with minimum API changes. #657 is still open so anyone interested can make these changes.
If that's ok with you, I think we can close this issue to avoid duplicates

from pcapplusplus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.