diff options
author | Rob Landley <rob@landley.net> | 2005-05-03 21:30:26 +0000 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2005-05-03 21:30:26 +0000 |
commit | 93983040c51ccbb2a19fc53f50498148edf98f65 (patch) | |
tree | 4b9e42e5b1afc817ea4ac853b4010d67ceb3cf43 | |
parent | 60158cb93eb0b3207dd1084cdf5bdd9226bd9e89 (diff) | |
download | busybox-w32-93983040c51ccbb2a19fc53f50498148edf98f65.tar.gz busybox-w32-93983040c51ccbb2a19fc53f50498148edf98f65.tar.bz2 busybox-w32-93983040c51ccbb2a19fc53f50498148edf98f65.zip |
Shaun Jackman said:
This patch adds a CONFIG_FEATURE_CLEAN_UP stanza, and also adds an
ifdef around the SIOCGIFMAP call.
-rw-r--r-- | libbb/interface.c | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/libbb/interface.c b/libbb/interface.c index 37a5f6405..65d7c4e71 100644 --- a/libbb/interface.c +++ b/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); |
@@ -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 | } |