mfontanini / libtins

High-level, multiplatform C++ network packet sniffing and crafting library.
http://libtins.github.io/
BSD 2-Clause "Simplified" License
1.91k stars 375 forks source link

how to extract data packet from PDU object? #363

Open DarrenSong opened 5 years ago

DarrenSong commented 5 years ago

i can get the IP though IP &ip = pdu.rfind_pdu();but i don't know how to extract data? could you help me?

hawake commented 5 years ago

Hi, in order to extract data you could try to rfind the RawPDU (or whatever else it is) inside the IP PDU and use the payload() getter method. Something like this, for example:

auto a = pkt.rfind_pdu<Tins::RawPDU>().payload();

Hope it could be useful.