]> git.ipfire.org Git - thirdparty/iw.git/commitdiff
Revert "magically set interface up for connect/join"
authorJohannes Berg <johannes@sipsolutions.net>
Sun, 16 Aug 2009 14:02:15 +0000 (16:02 +0200)
committerJohannes Berg <johannes@sipsolutions.net>
Sun, 16 Aug 2009 14:02:15 +0000 (16:02 +0200)
This reverts commit ded1f078ef5283e49f1863e9160a6650566c0954.

I decided that doing things magically isn't a good idea.

Conflicts:

iw.h

connect.c
ibss.c
iw.c
iw.h
util.c

index a4ea0f6dcc1063f6c875d7572b09a50bbe619cbb..91be62ac16af68556eeadb2cfdb48573a758c955 100644 (file)
--- a/connect.c
+++ b/connect.c
@@ -14,7 +14,7 @@ static int iw_conn(struct nl80211_state *state, struct nl_cb *cb,
 {
        char *end;
        unsigned char bssid[6];
-       int freq, err;
+       int freq;
 
        if (argc < 1)
                return 1;
@@ -43,20 +43,16 @@ static int iw_conn(struct nl80211_state *state, struct nl_cb *cb,
                }
        }
 
-       if (argc) {
-               if (strcmp(*argv, "key") != 0 && strcmp(*argv, "keys") != 0)
-                       return 1;
-
-               argv++;
-               argc--;
+       if (!argc)
+               return 0;
 
-               err = parse_keys(msg, argv, argc);
-               if (err)
-                       return err;
-       }
+       if (strcmp(*argv, "key") != 0 && strcmp(*argv, "keys") != 0)
+               return 1;
 
-       return set_interface_up(state->ifname);
+       argv++;
+       argc--;
 
+       return parse_keys(msg, argv, argc);
  nla_put_failure:
        return -ENOSPC;
 }
diff --git a/ibss.c b/ibss.c
index ee0732868838225992f666b7e874174b0cfb5f42..8785e7acaffd68fa0767f00e48f2cb500ae74b53 100644 (file)
--- a/ibss.c
+++ b/ibss.c
@@ -16,7 +16,6 @@ static int join_ibss(struct nl80211_state *state,
 {
        char *end;
        unsigned char abssid[6];
-       int err;
 
        if (argc < 2)
                return 1;
@@ -48,20 +47,16 @@ static int join_ibss(struct nl80211_state *state,
                }
        }
 
-       if (argc) {
-               if (strcmp(*argv, "key") != 0 && strcmp(*argv, "keys") != 0)
-                       return 1;
-
-               argv++;
-               argc--;
+       if (!argc)
+               return 0;
 
-               err = parse_keys(msg, argv, argc);
-               if (err)
-                       return err;
-       }
+       if (strcmp(*argv, "key") != 0 && strcmp(*argv, "keys") != 0)
+               return 1;
 
-       return set_interface_up(state->ifname);
+       argv++;
+       argc--;
 
+       return parse_keys(msg, argv, argc);
  nla_put_failure:
        return -ENOSPC;
 }
diff --git a/iw.c b/iw.c
index 347d87c8b30a25efc278d9f0c11f9ddf0402e551..d0d5286fd24d4fe9fc6c99f5e2186b2dae14bedc 100644 (file)
--- a/iw.c
+++ b/iw.c
@@ -255,8 +255,6 @@ static int __handle_cmd(struct nl80211_state *state, enum id_input idby,
        o_argc = argc;
        o_argv = argv;
 
-       state->ifname = NULL;
-
        switch (idby) {
        case II_PHY_IDX:
                command_idby = CIB_PHY;
@@ -274,7 +272,6 @@ static int __handle_cmd(struct nl80211_state *state, enum id_input idby,
                break;
        case II_NETDEV:
                command_idby = CIB_NETDEV;
-               state->ifname = *argv;
                devidx = if_nametoindex(*argv);
                if (devidx == 0)
                        devidx = -1;
diff --git a/iw.h b/iw.h
index 10bde358f05eafad7ae70c3db736230e8108103a..94948ec9646b32a7fdf4129f515513d17bc82be8 100644 (file)
--- a/iw.h
+++ b/iw.h
@@ -19,8 +19,6 @@ struct nl80211_state {
        struct nl_sock *nl_sock;
        struct nl_cache *nl_cache;
        struct genl_family *nl80211;
-
-       const char *ifname;
 };
 
 enum command_identify_by {
@@ -117,8 +115,6 @@ char *reg_initiator_to_string(__u8 initiator);
 const char *get_reason_str(uint16_t reason);
 const char *get_status_str(uint16_t status);
 
-int set_interface_up(const char *ifname);
-
 enum print_ie_type {
        PRINT_SCAN,
        PRINT_LINK,
diff --git a/util.c b/util.c
index f66d479f748f79f196ce99f64bfc7f183e0b0ada..1968526decabfc20f6d6a9d02cb8ba4f75943a05 100644 (file)
--- a/util.c
+++ b/util.c
@@ -2,10 +2,6 @@
 #include <netlink/attr.h>
 #include <errno.h>
 #include <stdbool.h>
-#include <net/if.h>
-#include <string.h>
-#include <sys/ioctl.h>
-#include <unistd.h>
 #include "iw.h"
 #include "nl80211.h"
 
@@ -233,31 +229,3 @@ int parse_keys(struct nl_msg *msg, char **argv, int argc)
                        "for example: d:2:6162636465 is the same as d:2:abcde\n");
        return 2;
 }
-
-int set_interface_up(const char *ifname)
-{
-       struct ifreq ifr;
-       int fd = socket(PF_INET, SOCK_DGRAM, 0);
-       int err = 0;
-
-       if (fd < 0)
-               return -errno;
-
-       memset(&ifr, 0, sizeof(ifr));
-       strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
-       if (ioctl(fd, SIOCGIFFLAGS, &ifr)) {
-               err = -errno;
-               goto out;
-       }
-
-       if (ifr.ifr_flags & IFF_UP)
-               goto out;
-
-       ifr.ifr_flags |= IFF_UP;
-       if (ioctl(fd, SIOCSIFFLAGS, &ifr))
-               err = -errno;
-
- out:
-       close(fd);
-       return err;
-}