diff mbox

iw: additional mac parameter for add interface primitive

Message ID 1357636648-4012-2-git-send-email-arend@broadcom.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Arend van Spriel Jan. 8, 2013, 9:17 a.m. UTC
When adding a P2P Device interface user-space may provide the
address for it. This should allow user-space to exchange P2P
messages over multiple radios using the same address.

Signed-off-by: Arend van Spriel <arend@broadcom.com>
---
 interface.c |   13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/interface.c b/interface.c
index 26e72dc..f03c079 100644
--- a/interface.c
+++ b/interface.c
@@ -168,6 +168,7 @@  static int handle_interface_add(struct nl80211_state *state,
 	char *name;
 	char *mesh_id = NULL;
 	enum nl80211_iftype type;
+	unsigned char mac_addr[ETH_ALEN];
 	int tpset;
 
 	if (argc < 1)
@@ -207,6 +208,14 @@  static int handle_interface_add(struct nl80211_state *state,
 				fprintf(stderr, "flags error\n");
 				return 2;
 			}
+		} else if (strcmp(argv[0], "mac") == 0) {
+			argc--;
+			argv++;
+			if (mac_addr_a2n(mac_addr, argv[0])) {
+				fprintf(stderr, "invalid mac address\n");
+				return 2;
+			}
+			NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr);
 		} else {
 			return 1;
 		}
@@ -224,14 +233,14 @@  static int handle_interface_add(struct nl80211_state *state,
  nla_put_failure:
 	return -ENOBUFS;
 }
-COMMAND(interface, add, "<name> type <type> [mesh_id <meshid>] [4addr on|off] [flags <flag>*]",
+COMMAND(interface, add, "<name> type <type> [mesh_id <meshid>] [4addr on|off] [flags <flag>*] [mac <MAC address>]",
 	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>] [4addr on|off] [flags <flag>*]",
+COMMAND(interface, add, "<name> type <type> [mesh_id <meshid>] [4addr on|off] [flags <flag>*] [mac <MAC address>]",
 	NL80211_CMD_NEW_INTERFACE, 0, CIB_NETDEV, handle_interface_add, NULL);
 
 static int handle_interface_del(struct nl80211_state *state,