mfontanini / libtins

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

Exception using PacketSender with IPv6 PDU #166

Closed sluser closed 7 years ago

sluser commented 7 years ago

When using PacketSender with an IPv6 PDU, the call to PacketSender::open_l3_socket() throws on the call to setsockopt, corresponding to an ERRON value OF ENOPROTOOPT.

This is because the "level" parameter of setsockopt is always IPPROTO_IP. For an IPv6 PDU this should be IPPROTO_IPV6.

Suggest adding, just before the call, something like:

const int level = (type == IPV6_SOCKET) ? IPPROTO_IPV6 : IPPROTO_IP;

Thanks!

mfontanini commented 7 years ago

Thanks!