diff options
author | Yuri Sevatz <yuri_sevatz@hotmail.com> | 2020-12-17 04:52:58 -0500 |
---|---|---|
committer | Yuri Sevatz <yuri_sevatz@hotmail.com> | 2020-12-17 04:53:41 -0500 |
commit | 4bd4d2b2927c87b65de915d42ebd7c082ae13ff8 (patch) | |
tree | 904c8514498c88467bfa17a05552deda0baddc08 | |
parent | 8b0d75750543453cdc8680bc52d4240eb4de2636 (diff) | |
download | netifaces-git-4bd4d2b2927c87b65de915d42ebd7c082ae13ff8.tar.gz |
Fix gateway detection when gateway in routing table with all null's
-rw-r--r-- | netifaces.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/netifaces.c b/netifaces.c index bf18c80..ffaf8c8 100644 --- a/netifaces.c +++ b/netifaces.c @@ -1894,8 +1894,14 @@ gateways (PyObject *self) attr = RTA_NEXT(attr, len); } + static const unsigned char ipv4_default[4] = {}; + static const unsigned char ipv6_default[16] = {}; + /* We're looking for gateways with no destination */ - if (!dst && gw && ifndx >= 0) { + if ((!dst + || (pmsg->rt.rtm_family == AF_INET && !memcmp(dst, ipv4_default, sizeof(ipv4_default))) + || (pmsg->rt.rtm_family == AF_INET6 && !memcmp(dst, ipv6_default, sizeof(ipv6_default))) + ) && gw && ifndx >= 0) { char buffer[256]; char ifnamebuf[IF_NAMESIZE]; char *ifname; |