All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] Add mpp get/dump commands
@ 2014-09-12  6:59 Henning Rogge
  2014-10-09 14:36 ` Johannes Berg
  0 siblings, 1 reply; 4+ messages in thread
From: Henning Rogge @ 2014-09-12  6:59 UTC (permalink / raw)
  To: linux-wireless @ vger . kernel . org
  Cc: Henning Rogge, Johannes Berg, Yeoh Chun-Yeow

Add the "mpp get" and "mpp dump" command to query to mac80211s mesh
proxy path table through nl80211.

Signed-off-by: Henning Rogge <henning.rogge@fkie.fraunhofer.de>
---
 Makefile  |  2 +-
 mpp.c     | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 nl80211.h | 11 +++++++++
 3 files changed, 96 insertions(+), 1 deletion(-)
 create mode 100644 mpp.c

diff --git a/Makefile b/Makefile
index f042e30..c05b2c4 100644
--- a/Makefile
+++ b/Makefile
@@ -14,7 +14,7 @@ CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing
 
 OBJS = iw.o genl.o event.o info.o phy.o \
 	interface.o ibss.o station.o survey.o util.o \
-	mesh.o mpath.o scan.o reg.o version.o \
+	mesh.o mpath.o mpp.o scan.o reg.o version.o \
 	reason.o status.o connect.o link.o offch.o ps.o cqm.o \
 	bitrate.o wowlan.o coalesce.o roc.o p2p.o
 OBJS += sections.o
diff --git a/mpp.c b/mpp.c
new file mode 100644
index 0000000..2d20d6b
--- /dev/null
+++ b/mpp.c
@@ -0,0 +1,84 @@
+#include <net/if.h>
+#include <errno.h>
+#include <string.h>
+
+#include <netlink/genl/genl.h>
+#include <netlink/genl/family.h>
+#include <netlink/genl/ctrl.h>
+#include <netlink/msg.h>
+#include <netlink/attr.h>
+
+#include "nl80211.h"
+#include "iw.h"
+
+SECTION(mpp);
+
+static int print_mpp_handler(struct nl_msg *msg, void *arg)
+{
+	struct nlattr *tb[NL80211_ATTR_MAX + 1];
+	struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
+	char dst[20], next_hop[20], dev[20];
+
+	nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
+		  genlmsg_attrlen(gnlh, 0), NULL);
+
+	/*
+	 * TODO: validate the interface and mac address!
+	 * Otherwise, there's a race condition as soon as
+	 * the kernel starts sending mpath notifications.
+	 */
+
+	mac_addr_n2a(dst, nla_data(tb[NL80211_ATTR_MAC]));
+	mac_addr_n2a(next_hop, nla_data(tb[NL80211_ATTR_MPATH_NEXT_HOP]));
+	if_indextoname(nla_get_u32(tb[NL80211_ATTR_IFINDEX]), dev);
+	printf("%s %s %s\n", dst, next_hop, dev);
+
+	return NL_SKIP;
+}
+
+static int handle_mpp_get(struct nl80211_state *state,
+			  struct nl_cb *cb,
+			  struct nl_msg *msg,
+			  int argc, char **argv,
+			  enum id_input id)
+{
+	unsigned char dst[ETH_ALEN];
+
+	if (argc < 1)
+		return 1;
+
+	if (mac_addr_a2n(dst, argv[0])) {
+		fprintf(stderr, "invalid mac address\n");
+		return 2;
+	}
+	argc--;
+	argv++;
+
+	if (argc)
+		return 1;
+
+	NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, dst);
+
+	nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, print_mpp_handler, NULL);
+
+	return 0;
+ nla_put_failure:
+	return -ENOBUFS;
+}
+COMMAND(mpp, get, "<MAC address>",
+	NL80211_CMD_GET_MPP, 0, CIB_NETDEV, handle_mpp_get,
+	"Get information on mesh proxy path to the given node.");
+
+static int handle_mpp_dump(struct nl80211_state *state,
+			     struct nl_cb *cb,
+			     struct nl_msg *msg,
+			     int argc, char **argv,
+			     enum id_input id)
+{
+	printf("DEST ADDR         PROXY NODE        IFACE\n");
+	nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, print_mpp_handler, NULL);
+	return 0;
+}
+COMMAND(mpp, dump, NULL,
+	NL80211_CMD_GET_MPP, NLM_F_DUMP, CIB_NETDEV, handle_mpp_dump,
+	"List known mesh proxy paths.");
diff --git a/nl80211.h b/nl80211.h
index be9519b..80cff48 100644
--- a/nl80211.h
+++ b/nl80211.h
@@ -722,6 +722,10 @@
  *	QoS mapping is relevant for IP packets, it is only valid during an
  *	association. This is cleared on disassociation and AP restart.
  *
+ * @NL80211_CMD_GET_MPP: Get mesh path attributes for mesh proxy path to
+ *	destination %NL80211_ATTR_MAC on the interface identified by
+ *	%NL80211_ATTR_IFINDEX.
+ *
  * @NL80211_CMD_MAX: highest used command number
  * @__NL80211_CMD_AFTER_LAST: internal use
  */
@@ -893,6 +897,8 @@ enum nl80211_commands {
 
 	NL80211_CMD_SET_QOS_MAP,
 
+	NL80211_CMD_GET_MPP,
+
 	/* add new commands above here */
 
 	/* used to define NL80211_CMD_MAX below */
@@ -1591,6 +1597,9 @@ enum nl80211_commands {
  *	creation then the new interface will be owned by the netlink socket
  *	that created it and will be destroyed when the socket is closed
  *
+ * @NL80211_ATTR_TDLS_INITIATOR: flag attribute indicating the current end is
+ *	the TDLS link initiator.
+ *
  * @NL80211_ATTR_MAX: highest attribute number currently defined
  * @__NL80211_ATTR_AFTER_LAST: internal use
  */
@@ -1931,6 +1940,8 @@ enum nl80211_attrs {
 	NL80211_ATTR_CSA_C_OFFSETS_TX,
 	NL80211_ATTR_MAX_CSA_COUNTERS,
 
+	NL80211_ATTR_TDLS_INITIATOR,
+
 	/* add attributes here, update the policy in nl80211.c */
 
 	__NL80211_ATTR_AFTER_LAST,
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] Add mpp get/dump commands
  2014-09-12  6:59 [PATCH v2] Add mpp get/dump commands Henning Rogge
@ 2014-10-09 14:36 ` Johannes Berg
  2014-10-09 15:35   ` Henning Rogge
  0 siblings, 1 reply; 4+ messages in thread
From: Johannes Berg @ 2014-10-09 14:36 UTC (permalink / raw)
  To: Henning Rogge
  Cc: linux-wireless @ vger . kernel . org, Henning Rogge, Yeoh Chun-Yeow

On Fri, 2014-09-12 at 08:59 +0200, Henning Rogge wrote:
> Add the "mpp get" and "mpp dump" command to query to mac80211s mesh
> proxy path table through nl80211.

Applied.

>  nl80211.h | 11 +++++++++

Please don't send me nl80211.h updates though.

johannes


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] Add mpp get/dump commands
  2014-10-09 14:36 ` Johannes Berg
@ 2014-10-09 15:35   ` Henning Rogge
  2014-10-09 15:39     ` Johannes Berg
  0 siblings, 1 reply; 4+ messages in thread
From: Henning Rogge @ 2014-10-09 15:35 UTC (permalink / raw)
  To: Johannes Berg
  Cc: linux-wireless @ vger . kernel . org, Henning Rogge, Yeoh Chun-Yeow

On Thu, Oct 9, 2014 at 4:36 PM, Johannes Berg <johannes@sipsolutions.net> wrote:
> On Fri, 2014-09-12 at 08:59 +0200, Henning Rogge wrote:
>> Add the "mpp get" and "mpp dump" command to query to mac80211s mesh
>> proxy path table through nl80211.
>
> Applied.
>
>>  nl80211.h | 11 +++++++++
>
> Please don't send me nl80211.h updates though.

Had to change it to make the source compile... so next time change it,
but not add it to the commit?

Henning Rogge

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] Add mpp get/dump commands
  2014-10-09 15:35   ` Henning Rogge
@ 2014-10-09 15:39     ` Johannes Berg
  0 siblings, 0 replies; 4+ messages in thread
From: Johannes Berg @ 2014-10-09 15:39 UTC (permalink / raw)
  To: Henning Rogge
  Cc: linux-wireless @ vger . kernel . org, Henning Rogge, Yeoh Chun-Yeow

On Thu, 2014-10-09 at 17:35 +0200, Henning Rogge wrote:

> Had to change it to make the source compile... so next time change it,
> but not add it to the commit?

Yeah, see over on the thread with Lorenzo as well, where I explained
this. I just copy nl80211.h from the kernel tree to make sure no
mismatches happen.

johannes


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-10-09 15:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-12  6:59 [PATCH v2] Add mpp get/dump commands Henning Rogge
2014-10-09 14:36 ` Johannes Berg
2014-10-09 15:35   ` Henning Rogge
2014-10-09 15:39     ` Johannes Berg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.