diff options
Diffstat (limited to 'busybox/libbb/interface.c')
-rw-r--r-- | busybox/libbb/interface.c | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/busybox/libbb/interface.c b/busybox/libbb/interface.c index fe2d0b4b2..c4aa032a4 100644 --- a/busybox/libbb/interface.c +++ b/busybox/libbb/interface.c | |||
@@ -888,6 +888,20 @@ static int sockets_open(int family) | |||
888 | return sfd; | 888 | return sfd; |
889 | } | 889 | } |
890 | 890 | ||
891 | #ifdef CONFIG_FEATURE_CLEAN_UP | ||
892 | static void sockets_close(void) | ||
893 | { | ||
894 | struct aftype **aft; | ||
895 | for (aft = aftypes; *aft != NULL; aft++) { | ||
896 | struct aftype *af = *aft; | ||
897 | if( af->fd != -1 ) { | ||
898 | close(af->fd); | ||
899 | af->fd = -1; | ||
900 | } | ||
901 | } | ||
902 | } | ||
903 | #endif | ||
904 | |||
891 | /* like strcmp(), but knows about numbers */ | 905 | /* like strcmp(), but knows about numbers */ |
892 | static int nstrcmp(const char *a, const char *b) | 906 | static int nstrcmp(const char *a, const char *b) |
893 | { | 907 | { |
@@ -1223,17 +1237,13 @@ static int if_fetch(struct interface *ife) | |||
1223 | } | 1237 | } |
1224 | #endif | 1238 | #endif |
1225 | 1239 | ||
1240 | #ifdef SIOCGIFMAP | ||
1226 | strcpy(ifr.ifr_name, ifname); | 1241 | strcpy(ifr.ifr_name, ifname); |
1227 | if (ioctl(skfd, SIOCGIFMAP, &ifr) < 0) | 1242 | if (ioctl(skfd, SIOCGIFMAP, &ifr) == 0) |
1228 | memset(&ife->map, 0, sizeof(struct ifmap)); | 1243 | ife->map = ifr.ifr_map; |
1229 | else | 1244 | else |
1230 | memcpy(&ife->map, &ifr.ifr_map, sizeof(struct ifmap)); | 1245 | #endif |
1231 | |||
1232 | strcpy(ifr.ifr_name, ifname); | ||
1233 | if (ioctl(skfd, SIOCGIFMAP, &ifr) < 0) | ||
1234 | memset(&ife->map, 0, sizeof(struct ifmap)); | 1246 | memset(&ife->map, 0, sizeof(struct ifmap)); |
1235 | else | ||
1236 | ife->map = ifr.ifr_map; | ||
1237 | 1247 | ||
1238 | #ifdef HAVE_TXQUEUELEN | 1248 | #ifdef HAVE_TXQUEUELEN |
1239 | strcpy(ifr.ifr_name, ifname); | 1249 | strcpy(ifr.ifr_name, ifname); |
@@ -1374,7 +1384,7 @@ static struct hwtype loop_hwtype = { | |||
1374 | #if HAVE_HWETHER | 1384 | #if HAVE_HWETHER |
1375 | #include <net/if_arp.h> | 1385 | #include <net/if_arp.h> |
1376 | 1386 | ||
1377 | #if __GLIBC__ >=2 && __GLIBC_MINOR >= 1 | 1387 | #if (__GLIBC__ >=2 && __GLIBC_MINOR >= 1) || defined(_NEWLIB_VERSION) |
1378 | #include <net/ethernet.h> | 1388 | #include <net/ethernet.h> |
1379 | #else | 1389 | #else |
1380 | #include <linux/if_ether.h> | 1390 | #include <linux/if_ether.h> |
@@ -2078,6 +2088,8 @@ int display_interfaces(char *ifname) | |||
2078 | 2088 | ||
2079 | /* Do we have to show the current setup? */ | 2089 | /* Do we have to show the current setup? */ |
2080 | status = if_print(ifname); | 2090 | status = if_print(ifname); |
2081 | close(skfd); | 2091 | #ifdef CONFIG_FEATURE_CLEAN_UP |
2092 | sockets_close(); | ||
2093 | #endif | ||
2082 | exit(status < 0); | 2094 | exit(status < 0); |
2083 | } | 2095 | } |