miniupnpd/getifaddr.c: check if interface is up
This commit is contained in:
parent
29e951c1e5
commit
f789a3bab7
|
@ -47,6 +47,19 @@ getifaddr(const char * ifname, char * buf, int len,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
|
strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
|
||||||
|
if(ioctl(s, SIOCGIFFLAGS, &ifr, &ifrlen) < 0)
|
||||||
|
{
|
||||||
|
syslog(LOG_DEBUG, "ioctl(s, SIOCGIFFLAGS, ...): %m");
|
||||||
|
close(s);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if ((ifr.ifr_flags & IFF_UP) == 0)
|
||||||
|
{
|
||||||
|
syslog(LOG_DEBUG, "network interface %s is down", ifname);
|
||||||
|
close(s);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
|
||||||
if(ioctl(s, SIOCGIFADDR, &ifr, &ifrlen) < 0)
|
if(ioctl(s, SIOCGIFADDR, &ifr, &ifrlen) < 0)
|
||||||
{
|
{
|
||||||
syslog(LOG_ERR, "ioctl(s, SIOCGIFADDR, ...): %m");
|
syslog(LOG_ERR, "ioctl(s, SIOCGIFADDR, ...): %m");
|
||||||
|
|
Loading…
Reference in New Issue