]> git.ipfire.org Git - thirdparty/iw.git/blobdiff - connect.c
scan: wps: remove useless string length checks
[thirdparty/iw.git] / connect.c
index fb3b2fe2fc1cb8137a129eea10e42ac89bd20e98..3237a277dca3579c9135fa6429c1538fd78f5dc4 100644 (file)
--- a/connect.c
+++ b/connect.c
@@ -9,13 +9,14 @@
 #include "nl80211.h"
 #include "iw.h"
 
-static int iw_conn(struct nl80211_state *state, struct nl_cb *cb,
+static int iw_conn(struct nl80211_state *state,
                   struct nl_msg *msg, int argc, char **argv,
                   enum id_input id)
 {
        char *end;
        unsigned char bssid[6];
        int freq;
+       int ret;
 
        if (argc < 1)
                return 1;
@@ -53,13 +54,29 @@ static int iw_conn(struct nl80211_state *state, struct nl_cb *cb,
        argv++;
        argc--;
 
-       return parse_keys(msg, argv, argc);
+       ret = parse_keys(msg, &argv, &argc);
+       if (ret)
+               return ret;
+
+       if (!argc)
+               return 0;
+
+       if (!strcmp(*argv, "mfp:req"))
+               NLA_PUT_U32(msg, NL80211_ATTR_USE_MFP, NL80211_MFP_REQUIRED);
+       else if (!strcmp(*argv, "mfp:opt"))
+               NLA_PUT_U32(msg, NL80211_ATTR_USE_MFP, NL80211_MFP_OPTIONAL);
+       else if (!strcmp(*argv, "mfp:no"))
+               NLA_PUT_U32(msg, NL80211_ATTR_USE_MFP, NL80211_MFP_NO);
+       else
+               return -EINVAL;
+
+       return 0;
+
  nla_put_failure:
        return -ENOSPC;
 }
 
 static int disconnect(struct nl80211_state *state,
-                     struct nl_cb *cb,
                      struct nl_msg *msg,
                      int argc, char **argv,
                      enum id_input id)
@@ -70,7 +87,7 @@ TOPLEVEL(disconnect, NULL,
        NL80211_CMD_DISCONNECT, 0, CIB_NETDEV, disconnect,
        "Disconnect from the current network.");
 
-static int iw_connect(struct nl80211_state *state, struct nl_cb *cb,
+static int iw_connect(struct nl80211_state *state,
                      struct nl_msg *msg, int argc, char **argv,
                      enum id_input id)
 {
@@ -137,16 +154,19 @@ static int iw_connect(struct nl80211_state *state, struct nl_cb *cb,
         * Alas, the kernel doesn't do that (yet).
         */
 
-       __do_listen_events(state, ARRAY_SIZE(cmds), cmds, &printargs);
+       __do_listen_events(state,
+                          ARRAY_SIZE(cmds), cmds,
+                          ARRAY_SIZE(cmds), cmds,
+                          &printargs);
        return 0;
 }
-TOPLEVEL(connect, "[-w] <SSID> [<freq in MHz>] [<bssid>] [key 0:abcde d:1:6162636465]",
+TOPLEVEL(connect, "[-w] <SSID> [<freq in MHz>] [<bssid>] [key 0:abcde d:1:6162636465] [mfp:req/opt/no]",
        0, 0, CIB_NETDEV, iw_connect,
        "Join the network with the given SSID (and frequency, BSSID).\n"
        "With -w, wait for the connect to finish or fail.");
 HIDDEN(connect, establish, "", NL80211_CMD_CONNECT, 0, CIB_NETDEV, iw_conn);
 
-static int iw_auth(struct nl80211_state *state, struct nl_cb *cb,
+static int iw_auth(struct nl80211_state *state,
                   struct nl_msg *msg, int argc, char **argv,
                   enum id_input id)
 {
@@ -208,7 +228,7 @@ static int iw_auth(struct nl80211_state *state, struct nl_cb *cb,
        argv++;
        argc--;
 
-       return parse_keys(msg, argv, argc);
+       return parse_keys(msg, &argv, &argc);
  nla_put_failure:
        return -ENOSPC;
 }