Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/get_gateway-linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,8 @@ int get_default_gw(struct in_addr *gw, char *iface)
"The specified network (\"%s\") does not match "
"the interface associated with the default gateway (%s). You will "
"need to manually specify the MAC address of your gateway using "
"the \"--gateway-mac\" flag.",
"the \"--gateway-mac\" flag or use \"--iplayer\" to send IP packets and "
"let the kernel take care of ethernet frame creation.",
iface, _iface);
}
return EXIT_SUCCESS;
Expand Down
8 changes: 8 additions & 0 deletions src/send-linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,21 @@ int send_run_init(sock_t s)
zconf.iface);
return EXIT_FAILURE;
}
// If we're sending IP packets (ie our socket is a AF_INET type, then we need to use the socket's SO_BINDTODEVICE option, only available for AF_INET sockets)
if (zconf.send_ip_pkts && setsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE, zconf.iface, strlen(zconf.iface)) < 0) {
log_error("send", "cannot bind to socket: %s", strerror(errno));
return EXIT_FAILURE;
}


strncpy(if_idx.ifr_name, zconf.iface, IFNAMSIZ - 1);
if (ioctl(sock, SIOCGIFINDEX, &if_idx) < 0) {
log_error("send", "%s", "SIOCGIFINDEX");
return EXIT_FAILURE;
}
int ifindex = if_idx.ifr_ifindex;


// destination address for the socket
memset((void *)&sockaddr, 0, sizeof(struct sockaddr_ll));
sockaddr.sll_ifindex = ifindex;
Expand Down
Loading