From: Johannes Berg Date: Sun, 16 Aug 2009 13:17:38 +0000 (+0200) Subject: mark a key default if none is marked manually X-Git-Tag: v0.9.16~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=041581ce06b30b2194a0151559abd71d67bee529;p=thirdparty%2Fiw.git mark a key default if none is marked manually --- diff --git a/util.c b/util.c index 3496c6a..f66d479 100644 --- a/util.c +++ b/util.c @@ -152,6 +152,7 @@ int parse_keys(struct nl_msg *msg, char **argv, int argc) { struct nlattr *keys; int i = 0; + bool have_default = false; char keybuf[13]; if (!argc) @@ -177,6 +178,7 @@ int parse_keys(struct nl_msg *msg, char **argv, int argc) pos++; if (arg[pos] == ':') pos++; + have_default = true; } if (!isdigit(arg[pos])) @@ -207,9 +209,14 @@ int parse_keys(struct nl_msg *msg, char **argv, int argc) NLA_PUT(msg, NL80211_KEY_DATA, keylen, keydata); - nla_nest_end(msg, key); argv++; argc--; + + /* one key should be TX key */ + if (!have_default && !argc) + NLA_PUT_FLAG(msg, NL80211_KEY_DEFAULT); + + nla_nest_end(msg, key); } while (argc); nla_nest_end(msg, keys);