Merge pull request #59 from calanor/master

Fixes get_interface_index.  Issue #57
This commit is contained in:
Andrea Bondavalli 2021-12-30 10:25:45 +01:00 committed by GitHub
commit 9f01d97635
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -102,7 +102,7 @@ int get_interface_index(const std::string& interface_name) {
struct ifreq ifr;
ifr.ifr_addr.sa_family = AF_INET;
strncpy(ifr.ifr_name, interface_name.c_str(), IFNAMSIZ - 1);
if (ioctl(fd, SIOCGIFADDR, &ifr) < 0) {
if (ioctl(fd, SIOCGIFINDEX, &ifr) < 0) {
close(fd);
BOOST_LOG_TRIVIAL(warning)
<< "Cannot retrieve index for interface " << interface_name;