Skip to contentSkip to conversation

initial commit of wpan-tools

PATCH New Alexander Aring 1 participant 9 messages Aug 20, 2014

Subsystems (3)
lore
Share & tools
lore

Alexander Aring

author maintainer
#0 lore raw

cover initial commit of wpan-tools

Hi,

this is just for review. I already apply these patches to the wpan-tools repository. Some things are hacked like the version string, maybe we should use some script to get git commit-id or make a real version.

It is a longer process to have a nice userspace tool. This is just the begin to handle with the new cfg802154 interface.

The cfg802154 interface is available at [0], but needs some rebase work. I will send them later. Sorry this will be a huge series of patches.

[0] https://github.com/linux-wpan/linux-wpan-next/tree/wpan_rework_rfc

- Alex

Alexander Aring (8):
COPYING: add COPYING file
initial commit
gitignore: add gitignore files
iwpan: fix coding style issue
nl802154: update to current header file
phy: initial commit for phy pib handling
mac: initial commit for mac pib handling
gitignore: add phy and mac object files

author maintainer
#1 lore raw

PATCH 1/8 COPYING: add COPYING file

---
 COPYING | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
 create mode 100644 COPYING
COPYING new file +23 -0
new file mode 100644
index 0000000..5cd3daa
@@ -0,0 +1,23 @@
+Copyright (c) 2014		Alexander Aring
+
+
+Code is based on iw tool.
+
+Original Authors:
+
+Copyright (c) 2007, 2008	Johannes Berg
+Copyright (c) 2007		Andy Lutomirski
+Copyright (c) 2007		Mike Kershaw
+Copyright (c) 2008-2009		Luis R. Rodriguez
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Signature · 1 line
2.0.4
author maintainer
#2 lore raw

PATCH 2/8 initial commit

In reply to Alexander Aring

This patch is just copy&paste everything from the iw tool and change 80211 to 802154. Also wireless to wpan. Also add handling for add and remove interfaces like the iw command just for wpan devices.

---
 Makefile.am     |  23 +++
 autogen.sh      |  25 +++
 configure.ac    |  73 ++++++++
 src/Makefile.am |  10 ++
 src/interface.c | 100 +++++++++++
 src/iwpan.c     | 534 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/iwpan.h     | 113 ++++++++++++
 src/nl802154.h  |  88 ++++++++++
 src/sections.c  |   4 +
 9 files changed, 970 insertions(+)
 create mode 100644 Makefile.am
 create mode 100755 autogen.sh
 create mode 100644 configure.ac
 create mode 100644 src/Makefile.am
 create mode 100644 src/interface.c
 create mode 100644 src/iwpan.c
 create mode 100644 src/iwpan.h
 create mode 100644 src/nl802154.h
 create mode 100644 src/sections.c
Makefile.am new file +23 -0
new file mode 100644
index 0000000..06c72cd
@@ -0,0 +1,23 @@
+EXTRA_DIST =
+CLEANFILES =
+ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
+AM_MAKEFLAGS = --no-print-directory
+
+AM_CPPFLAGS = \
+	-include $(top_builddir)/config.h \
+	-DSYSCONFDIR=\""$(sysconfdir)"\" \
+	-DLIBEXECDIR=\""$(libexecdir)"\" \
+	-I${top_srcdir}/src/abc \
+	-I${top_srcdir}/src
+
+AM_CFLAGS = ${WPAN_TOOLS_CFLAGS} \
+	-fvisibility=hidden \
+	-ffunction-sections \
+	-fdata-sections
+
+AM_LDFLAGS = \
+	-Wl,--gc-sections \
+	-Wl,--as-needed
+
+SUBDIRS = \
+	src
autogen.sh new file +25 -0
new file mode 100755
index 0000000..0d60b0a
@@ -0,0 +1,25 @@
+#!/bin/sh -e
+
+if [ -f .git/hooks/pre-commit.sample -a ! -f .git/hooks/pre-commit ] ; then
+        cp -p .git/hooks/pre-commit.sample .git/hooks/pre-commit && \
+        chmod +x .git/hooks/pre-commit && \
+        echo "Activated pre-commit hook."
+fi
+
+autoreconf --install --symlink
+
+libdir() {
+        echo $(cd $1/$(gcc -print-multi-os-directory); pwd)
+}
+
+args="--prefix=/usr \
+--sysconfdir=/etc \
+--libdir=$(libdir /usr/lib)"
+
+echo
+echo "----------------------------------------------------------------"
+echo "Initialized build system. For a common configuration please run:"
+echo "----------------------------------------------------------------"
+echo
+echo "./configure CFLAGS='-g -O0' $args"
+echo
configure.ac new file +73 -0

73 lines not on this page · raw message

src/Makefile.am new file +10 -0
new file mode 100644
index 0000000..9b42fc1
@@ -0,0 +1,10 @@
+bin_PROGRAMS = \
+	iwpan
+
+iwpan_SOURCES = \
+	iwpan.c \
+	sections.c \
+	interface.c
+
+iwpan_CFLAGS = $(AM_CFLAGS) $(LIBNL3_CFLAGS)
+iwpan_LDADD = $(LIBNL3_LIBS)
src/interface.c new file +100 -0

100 lines not on this page · raw message

src/iwpan.c new file +534 -0

534 lines not on this page · raw message

src/iwpan.h new file +113 -0

113 lines not on this page · raw message

src/nl802154.h new file +88 -0

88 lines not on this page · raw message

src/sections.c new file +4 -0
new file mode 100644
index 0000000..40fdc94
@@ -0,0 +1,4 @@
+#include "iwpan.h"
+
+SECTION(get);
+SECTION(set);
Signature · 1 line
2.0.4
author maintainer
#3 lore raw

PATCH 3/8 gitignore: add gitignore files

In reply to Alexander Aring
---
 .gitignore     | 11 +++++++++++
 m4/.gitignore  |  5 +++++
 src/.gitignore |  5 +++++
 3 files changed, 21 insertions(+)
 create mode 100644 .gitignore
 create mode 100644 m4/.gitignore
 create mode 100644 src/.gitignore
.gitignore new file +11 -0
new file mode 100644
index 0000000..522b35c
@@ -0,0 +1,11 @@
+tags
+TAGS
+Makefile
+Makefile.in
+aclocal.m4
+autom4te.cache
+build-aux
+config.*
+configure
+libtool
+stamp-h1
m4/.gitignore new file +5 -0
new file mode 100644
index 0000000..38066dd
@@ -0,0 +1,5 @@
+libtool.m4
+ltoptions.m4
+ltsugar.m4
+ltversion.m4
+lt~obsolete.m4
src/.gitignore new file +5 -0
new file mode 100644
index 0000000..1cc1353
@@ -0,0 +1,5 @@
+.deps
+iwpan
+iwpan-interface.o
+iwpan-iwpan.o
+iwpan-sections.o
Signature · 1 line
2.0.4
author maintainer
#4 lore raw

PATCH 4/8 iwpan: fix coding style issue

In reply to Alexander Aring
---
 src/iwpan.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
src/iwpan.c +2 -1
index 73d5ba3..1e0b162 100644
@@ -118,8 +118,9 @@ static void __usage_cmd(const struct cmd *cmd, char *indent, bool full)
 			printf("%.*s\n", (int)(lend - start), start);
 			start = lend + 1;
 		} while (end != lend);
-	} else
+	} else {
 		printf("\n");
+	}
 
 	if (!full || !cmd->help)
 		return;
Signature · 1 line
2.0.4
author maintainer
#5 lore raw

PATCH 5/8 nl802154: update to current header file

In reply to Alexander Aring
---
 src/nl802154.h | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)
src/nl802154.h +15 -11
index c1f2f13..51d08b0 100644
@@ -18,18 +18,14 @@
  *
  */
 
-#ifndef __LINUX_NL802154_H
-#define __LINUX_NL802154_H
+#ifndef NL802154_H
+#define NL802154_H
 
 #define NL802154_GENL_NAME "nl802154"
 
-/* commands */
-/* REQ should be responded with CONF
- * and INDIC with RESP
- */
 enum nl802154_commands {
 /* don't change the order or add anything between, this is ABI! */
-/* Currently we don't shipping this file via uapi, ignore the above one */
+/* currently we don't shipping this file via uapi, ignore the above one */
 	NL802154_CMD_UNSPEC,
 
 	NL802154_CMD_GET_WPAN_PHY,		/* can dump */
@@ -42,6 +38,11 @@ enum nl802154_commands {
 	NL802154_CMD_NEW_INTERFACE,
 	NL802154_CMD_DEL_INTERFACE,
 
+	NL802154_CMD_SET_PAGE,
+	NL802154_CMD_SET_CHANNEL,
+
+	NL802154_CMD_SET_PAN_ID,
+
 	/* add new commands above here */
 
 	/* used to define NL802154_CMD_MAX below */
@@ -51,7 +52,7 @@ enum nl802154_commands {
 
 enum nl802154_attrs {
 /* don't change the order or add anything between, this is ABI! */
-/* Currently we don't shipping this file via uapi, ignore the above one */
+/* currently we don't shipping this file via uapi, ignore the above one */
 	NL802154_ATTR_UNSPEC,
 
 	NL802154_ATTR_WPAN_PHY,
@@ -61,11 +62,14 @@ enum nl802154_attrs {
 	NL802154_ATTR_IFNAME,
 	NL802154_ATTR_IFTYPE,
 
-	NL802154_ATTR_GENERATION,
+	NL802154_ATTR_WPAN_DEV,
 
-	NL802154_ATTR_SUPPORTED_COMMANDS,
+	NL802154_ATTR_IFACE_SOCKET_OWNER,
 
-	NL802154_ATTR_WPAN_DEV,
+	NL802154_ATTR_PAGE,
+	NL802154_ATTR_CHANNEL,
+
+	NL802154_ATTR_PAN_ID,
 
 	/* add attributes here, update the policy in nl802154.c */
 
Signature · 1 line
2.0.4
author maintainer
#6 lore raw

PATCH 6/8 phy: initial commit for phy pib handling

In reply to Alexander Aring

This patch adds src/phy.c file. In this file should be the implement the phy pib handling of the IEEE 802.15.4 standard.

In this patch we add handling to set channel and page according channel/page number.

---
 src/Makefile.am |  3 ++-
 src/phy.c       | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 69 insertions(+), 1 deletion(-)
 create mode 100644 src/phy.c
src/Makefile.am +2 -1
index 9b42fc1..ef7e846 100644
@@ -4,7 +4,8 @@ bin_PROGRAMS = \
 iwpan_SOURCES = \
 	iwpan.c \
 	sections.c \
-	interface.c
+	interface.c \
+	phy.c
 
 iwpan_CFLAGS = $(AM_CFLAGS) $(LIBNL3_CFLAGS)
 iwpan_LDADD = $(LIBNL3_LIBS)
src/phy.c new file +67 -0

67 lines not on this page · raw message

Signature · 1 line
2.0.4
author maintainer
#7 lore raw

PATCH 7/8 mac: initial commit for mac pib handling

In reply to Alexander Aring

This patch adds a new mac.c file into src directory. In this file we should implement all mac pib handling according the IEEE 802.15.4 standard.

For this initial commit we support setting for the pan id of an IEEE 802.15.4 interface.

---
 src/Makefile.am |  3 ++-
 src/mac.c       | 40 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 1 deletion(-)
 create mode 100644 src/mac.c
src/Makefile.am +2 -1
index ef7e846..b702c91 100644
@@ -5,7 +5,8 @@ iwpan_SOURCES = \
 	iwpan.c \
 	sections.c \
 	interface.c \
-	phy.c
+	phy.c \
+	mac.c
 
 iwpan_CFLAGS = $(AM_CFLAGS) $(LIBNL3_CFLAGS)
 iwpan_LDADD = $(LIBNL3_LIBS)
src/mac.c new file +40 -0
new file mode 100644
index 0000000..5fa1111
@@ -0,0 +1,40 @@
+#include <net/if.h>
+#include <errno.h>
+#include <string.h>
+#include <stdbool.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 "nl802154.h"
+#include "iwpan.h"
+
+static int handle_pan_id_set(struct nl802154_state *state,
+			     struct nl_cb *cb,
+			     struct nl_msg *msg,
+			     int argc, char **argv,
+			     enum id_input id)
+{
+	unsigned long pan_id;
+	char *end;
+
+	if (argc < 1)
+		return 1;
+
+	/* PAN ID */
+	pan_id = strtoul(argv[0], &end, 0);
+	if (*end != '\0')
+		return 1;
+
+	NLA_PUT_U16(msg, NL802154_ATTR_PAN_ID, pan_id);
+
+	return 0;
+
+nla_put_failure:
+	return -ENOBUFS;
+}
+COMMAND(set, pan_id, "<pan_id>",
+	NL802154_CMD_SET_PAN_ID, 0, CIB_NETDEV, handle_pan_id_set, NULL);
Signature · 1 line
2.0.4