Skip to content

Commit 06c2cf0

Browse files
rovo89ClemensElflein
authored andcommitted
Fix "Error getting index for interface eth0"
errno is only set on error, it's not reset to 0 on success. So instead check the returned index, which would be > 0 on success.
1 parent 730ab56 commit 06c2cf0

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ inline std::string IpIntToString(const uint32_t ip) {
3939
int SetupRawSocket(const std::string &interface, uint8_t *mac_address) {
4040
// Find the index of the interface
4141
unsigned int idx = if_nametoindex(interface.c_str());
42-
if (errno) {
42+
if (idx == 0) {
4343
spdlog::error("Error getting index for interface {}: {}", interface, strerror(errno));
4444
return -1;
4545
}

0 commit comments

Comments
 (0)