]> git.ipfire.org Git - thirdparty/iw.git/commitdiff
iw: add support for setting the wds/4-address flag when creating an interface
authorFelix Fietkau <nbd@openwrt.org>
Wed, 11 Nov 2009 12:20:40 +0000 (13:20 +0100)
committerJohannes Berg <johannes@sipsolutions.net>
Wed, 11 Nov 2009 13:42:40 +0000 (14:42 +0100)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
interface.c
nl80211.h

index bf1335adb1a5c8e8e7227b593d62ac7bafc4d242..c092aa2b272ca1689511830fe4cbae2c9b7dafff 100644 (file)
@@ -137,6 +137,20 @@ static int get_if_type(int *argc, char ***argv, enum nl80211_iftype *type,
        return 2;
 }
 
+static int parse_4addr_flag(const char *value, struct nl_msg *msg)
+{
+       if (strcmp(value, "on") == 0)
+               NLA_PUT_U8(msg, NL80211_ATTR_4ADDR, 1);
+       else if (strcmp(value, "off") == 0)
+               NLA_PUT_U8(msg, NL80211_ATTR_4ADDR, 0);
+       else
+               return 1;
+       return 0;
+
+nla_put_failure:
+       return 1;
+}
+
 static int handle_interface_add(struct nl80211_state *state,
                                struct nl_cb *cb,
                                struct nl_msg *msg,
@@ -168,6 +182,15 @@ static int handle_interface_add(struct nl80211_state *state,
                        mesh_id = argv[0];
                        argc--;
                        argv++;
+               } else if (strcmp(argv[0], "4addr") == 0) {
+                       argc--;
+                       argv++;
+                       if (parse_4addr_flag(argv[0], msg)) {
+                               fprintf(stderr, "4addr error\n");
+                               return 2;
+                       }
+                       argc--;
+                       argv++;
                } else if (strcmp(argv[0], "flags") == 0) {
                        argc--;
                        argv++;
@@ -192,14 +215,14 @@ static int handle_interface_add(struct nl80211_state *state,
  nla_put_failure:
        return -ENOBUFS;
 }
-COMMAND(interface, add, "<name> type <type> [mesh_id <meshid>] [flags <flag>*]",
+COMMAND(interface, add, "<name> type <type> [mesh_id <meshid>] [4addr on|off] [flags <flag>*]",
        NL80211_CMD_NEW_INTERFACE, 0, CIB_PHY, handle_interface_add,
        "Add a new virtual interface with the given configuration.\n"
        IFACE_TYPES "\n\n"
        "The flags are only used for monitor interfaces, valid flags are:\n"
        VALID_FLAGS "\n\n"
        "The mesh_id is used only for mesh mode.");
-COMMAND(interface, add, "<name> type <type> [mesh_id <meshid>] [flags <flag>*]",
+COMMAND(interface, add, "<name> type <type> [mesh_id <meshid>] [4addr on|off] [flags <flag>*]",
        NL80211_CMD_NEW_INTERFACE, 0, CIB_NETDEV, handle_interface_add, NULL);
 
 static int handle_interface_del(struct nl80211_state *state,
index a8d71ed43a0e80a8608dadebe343c61379cd88ef..09a98ce5992ec10fb120924101285f7fa00052f9 100644 (file)
--- a/nl80211.h
+++ b/nl80211.h
@@ -584,6 +584,8 @@ enum nl80211_commands {
  *     changed then the list changed and the dump should be repeated
  *     completely from scratch.
  *
+ * @NL80211_ATTR_4ADDR: Use 4-address frames on a virtual interface
+ *
  * @NL80211_ATTR_MAX: highest attribute number currently defined
  * @__NL80211_ATTR_AFTER_LAST: internal use
  */
@@ -714,6 +716,8 @@ enum nl80211_attrs {
 
        NL80211_ATTR_PID,
 
+       NL80211_ATTR_4ADDR,
+
        /* add attributes here, update the policy in nl80211.c */
 
        __NL80211_ATTR_AFTER_LAST,