From 2e013847d90af4d710a16b3bed5646ebbaf1a371 Mon Sep 17 00:00:00 2001 From: Matias Fontanini Date: Fri, 21 Oct 2016 07:34:20 -0700 Subject: [PATCH] Use proper IPv6 flag when opening l3 socket Fixes #166 --- src/packet_sender.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/packet_sender.cpp b/src/packet_sender.cpp index 0e2b34d..7955f66 100644 --- a/src/packet_sender.cpp +++ b/src/packet_sender.cpp @@ -263,7 +263,8 @@ void PacketSender::open_l3_socket(SocketType type) { #else typedef const char* option_ptr; #endif - if (setsockopt(sockfd, IPPROTO_IP, IP_HDRINCL, (option_ptr)&on, sizeof(on)) != 0) { + const int level = (type == IPV6_SOCKET) ? IPPROTO_IPV6 : IPPROTO_IP; + if (setsockopt(sockfd, level, IP_HDRINCL, (option_ptr)&on, sizeof(on)) != 0) { throw socket_open_error(make_error_string()); }