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

Sending packets over 'file' through descriptor? #378

Open lattice0 opened 4 years ago

lattice0 commented 4 years ago

I've read the documentation and some classes on doxygen and there's no way to either send a packet through a file descriptor as if I were writing directly to /dev/net/tun or there's no option to dump the packet into a simple uint8_t* buffer so I can do the write manually. I also found no way of creating my own PacketSender that writes to an interface. The closest I found was PDU's serialize but it is protected so I don't know exactly what it's for.

Am I rigth?

I need this because I'm creating a way to send an IP packet through OpenVPN and I need to write to a virtual file from which it reads and sends my packet

lattice0 commented 4 years ago

Sorry, I just found that serialize() returns an std::vector. However, the serialization of

Tins::IP pkt = Tins::IP("192.168.0.1") /
                 Tins::TCP(13, 15) /
                 Tins::RawPDU("I'm a payload!");

gives me a full ethernet packet, not an IP packet! Shouldn't it serialize to an IP packet? Why the ethernet?