]> git.ipfire.org Git - thirdparty/iw.git/commitdiff
iw: add support for mfp
authorEmmanuel Grumbach <emmanuel.grumbach@intel.com>
Thu, 10 Aug 2017 07:50:30 +0000 (10:50 +0300)
committerJohannes Berg <johannes.berg@intel.com>
Tue, 12 Dec 2017 11:03:43 +0000 (12:03 +0100)
Allow to add a paramater to require MFP in the connect command.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
connect.c
util.c

index 56771249e234bc14bd5234a68b5565f08688eb14..339fc736819fe1a18fc96b5741c9946837c475dc 100644 (file)
--- a/connect.c
+++ b/connect.c
@@ -16,6 +16,7 @@ static int iw_conn(struct nl80211_state *state,
        char *end;
        unsigned char bssid[6];
        int freq;
+       int ret;
 
        if (argc < 1)
                return 1;
@@ -53,7 +54,27 @@ static int iw_conn(struct nl80211_state *state,
        argv++;
        argc--;
 
-       return parse_keys(msg, argv, argc);
+       ret = parse_keys(msg, argv, argc);
+       if (ret)
+               return ret;
+
+       argc -= 4;
+       argv += 4;
+
+       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;
 }
@@ -139,7 +160,7 @@ static int iw_connect(struct nl80211_state *state,
        __do_listen_events(state, 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.");
diff --git a/util.c b/util.c
index 7fd6153bac1d9e2a719c79289d2893b813d1d802..f60d49bf75802ca30c6170fefc62e6ce1858f277 100644 (file)
--- a/util.c
+++ b/util.c
@@ -429,7 +429,7 @@ int parse_keys(struct nl_msg *msg, char **argv, int argc)
                char psk_keybuf[32];
                int cipher_suite, akm_suite;
 
-               if (argc != 4)
+               if (argc < 4)
                        goto explain;
 
                pos+=3;