packages/lang/python-ifconfig/patches/002-checkflags-up.patch
hcg a266acc54c [packages/python-ifconfig] Add package python-ifconfig
git-svn-id: svn://svn.openwrt.org/openwrt/packages@24543 3c298f89-4303-0410-b956-a3cf2f4a3e73
2010-12-13 12:27:11 +00:00

40 lines
1.4 KiB
Diff

--- a/ifconfig.old 2010-12-10 12:14:12.026329707 +0100
+++ b/ifconfig.c 2010-12-10 12:15:18.374672352 +0100
@@ -64,20 +64,22 @@
sprintf(hwaddr, "%02x:%02x:%02x:%02x:%02x:%02x",
*hw, *(hw + 1), *(hw + 2), *(hw + 3), *(hw + 4), *(hw + 5));
- /* address */
- ioctl(fd, SIOCGIFADDR, &ifreq);
- sin = (struct sockaddr_in *)&ifreq.ifr_broadaddr;
- sprintf(addr, "%s", inet_ntoa(sin->sin_addr));
-
- /* broadcast */
- ioctl(fd, SIOCGIFBRDADDR, &ifreq);
- sin = (struct sockaddr_in *)&ifreq.ifr_broadaddr;
- sprintf(brdaddr, "%s", inet_ntoa(sin->sin_addr));
-
- /* netmask */
- ioctl(fd, SIOCGIFNETMASK, &ifreq);
- sin = (struct sockaddr_in *)&ifreq.ifr_broadaddr;
- sprintf(netmask, "%s", inet_ntoa(sin->sin_addr));
+ if (flags & IFF_UP) {
+ /* address */
+ ioctl(fd, SIOCGIFADDR, &ifreq);
+ sin = (struct sockaddr_in *)&ifreq.ifr_broadaddr;
+ sprintf(addr, "%s", inet_ntoa(sin->sin_addr));
+
+ /* broadcast */
+ ioctl(fd, SIOCGIFBRDADDR, &ifreq);
+ sin = (struct sockaddr_in *)&ifreq.ifr_broadaddr;
+ sprintf(brdaddr, "%s", inet_ntoa(sin->sin_addr));
+
+ /* netmask */
+ ioctl(fd, SIOCGIFNETMASK, &ifreq);
+ sin = (struct sockaddr_in *)&ifreq.ifr_broadaddr;
+ sprintf(netmask, "%s", inet_ntoa(sin->sin_addr));
+ }
}
close(fd);