mfontanini / libtins

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

IPv6 PDU/packet does not go through the interface specified in PacketSender::send() #394

Open gbappneta opened 4 years ago

gbappneta commented 4 years ago

In the code snippet below, the IPv6 packet is built and, although "eth0" is specified in the call to PacketSender::send(), the packet goes out "eth1". Is this a missing feature or a bug? If it is a missing feature, is there any intention of adding it in a near future? Looking at the documentation I found an example where an EthernetII+IPv6 PDU is used instead of an IPv6 PDU in order to send the packet through a particular interface. I have not tried the EthernetII+IPv6 PDU alternative as it presents an extra level of trouble (it seems to require that the source and destination MAC addresses to be populated)

IPv6 &UDPv6Probe::send() {
    PacketSender sender;
    IPv6* ipv6_pkt;
    // Forge just builds an IPv6 UDP packet
    ipv6_pkt = forge();
    sender.send(*ipv6_pkt, "eth0");
    return *ipv6_pkt;
}

OS = Debian Stretch

mfontanini commented 4 years ago

As the documentation states explicitly specifying an interface will only work if you're sending a packet that contains a link layer PDU. When you're sending a l3 packet, the kernel will decide which interface to use on its own.