I didn't make this patch, it came from jow.  I changed use of libnl-tiny
to libnl, since in my testing, it didn't compile with the former.

This adds the tools from the linux-zigbee project.  Note that this
project doesn't actually do ZigBee support, but related stuff,
see the FAQ:

http://sourceforge.net/apps/trac/linux-zigbee/wiki/FAQ

Incidentally, I've been using OpenZWave on OpenWrt for
many months now.  If there's interest in that, I can
package for OpenWrt too.


Index: linux-zigbee/patches/200-libnl-tiny-compat.patch
===================================================================
--- linux-zigbee/patches/200-libnl-tiny-compat.patch	(revision 0)
+++ linux-zigbee/patches/200-libnl-tiny-compat.patch	(revision 0)
@@ -0,0 +1,142 @@
+--- a/src/coordinator.c
++++ b/src/coordinator.c
+@@ -64,16 +64,17 @@ extern int yydebug;
+ 
+ static void cleanup(int ret);
+ 
+-static void log_msg_nl_perror(char *s)
++static void log_msg_nl_perror(int err, char *s)
+ {
+-	if (nl_get_errno()) {
+-		log_msg(0, "%s: %s", s, nl_geterror());
++	if (err < 0) {
++		log_msg(0, "%s: %s", s, nl_geterror(err));
+ 		cleanup(1);
+ 	}
+ }
+ 
+ static int mlme_start(uint16_t short_addr, uint16_t pan, uint8_t channel, uint8_t is_coordinator, const char * iface)
+ {
++	int err;
+ 	struct nl_msg *msg = nlmsg_alloc();
+ 	log_msg(0, "mlme_start\n");
+ 	genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, family, 0, NLM_F_REQUEST, IEEE802154_START_REQ, /* vers */ 1);
+@@ -93,13 +94,15 @@ static int mlme_start(uint16_t short_add
+ 	nla_put_u8(msg, IEEE802154_ATTR_BAT_EXT, 0);
+ 	nla_put_u8(msg, IEEE802154_ATTR_COORD_REALIGN, 0);
+ #endif
+-	nl_send_auto_complete(nl, msg);
+-	log_msg_nl_perror("nl_send_auto_complete");
++	err = nl_send_auto_complete(nl, msg);
++	log_msg_nl_perror(err, "nl_send_auto_complete");
+ 	return 0;
+ }
+ 
+ static int coordinator_associate(struct genlmsghdr *ghdr, struct nlattr **attrs)
+ {
++	int err;
++
+ 	log_msg(0, "Associate requested\n");
+ 
+ 	if (!attrs[IEEE802154_ATTR_DEV_INDEX] ||
+@@ -127,9 +130,9 @@ static int coordinator_associate(struct 
+ 	nla_put_u64(msg, IEEE802154_ATTR_DEST_HW_ADDR, nla_get_u64(attrs[IEEE802154_ATTR_SRC_HW_ADDR]));
+ 	nla_put_u16(msg, IEEE802154_ATTR_DEST_SHORT_ADDR, shaddr);
+ 
+-	nl_send_auto_complete(nl, msg);
++	err = nl_send_auto_complete(nl, msg);
+ 
+-	log_msg_nl_perror("nl_send_auto_complete");
++	log_msg_nl_perror(err, "nl_send_auto_complete");
+ 
+ 	return 0;
+ }
+@@ -284,6 +287,7 @@ int main(int argc, char **argv)
+ 	uint16_t pan = 0xffff, short_addr = 0xffff;
+ 	char pname[PATH_MAX];
+ 	uint8_t channel = 0;
++	int err;
+ 
+ 	debug = 0;
+ 	range_min = 0x8000;
+@@ -399,16 +403,15 @@ int main(int argc, char **argv)
+ 	nl = nl_handle_alloc();
+ 
+ 	if (!nl) {
+-		log_msg_nl_perror("nl_handle_alloc");
++		log_msg_nl_perror(-NLE_NOMEM, "nl_handle_alloc");
+ 		return 1;
+ 	}
+ 
+-	log_msg_nl_perror("genl_connect");
+-	genl_connect(nl);
+-	log_msg_nl_perror("genl_connect");
++	err = genl_connect(nl);
++	log_msg_nl_perror(err, "genl_connect");
+ 
+ 	family = genl_ctrl_resolve(nl, IEEE802154_NL_NAME);
+-	log_msg_nl_perror("genl_ctrl_resolve");
++	log_msg_nl_perror(family, "genl_ctrl_resolve");
+ 
+ 	nl_socket_add_membership(nl, nl_get_multicast_id(nl, IEEE802154_NL_NAME, IEEE802154_MCAST_COORD_NAME));
+ 
+@@ -469,8 +472,8 @@ int main(int argc, char **argv)
+ 	mlme_start(short_addr, pan, channel, 1, iface);
+ 
+ 	while (!die_flag) {
+-		nl_recvmsgs_default(nl);
+-		log_msg_nl_perror("nl_recvmsgs");
++		err = nl_recvmsgs_default(nl);
++		log_msg_nl_perror(err, "nl_recvmsgs");
+ 	}
+ 	cleanup(0);
+ 
+--- a/src/iz.c
++++ b/src/iz.c
+@@ -41,6 +41,9 @@
+ 
+ #include "iz.h"
+ 
++/* libnl-tiny provides extern int nl_debug but no symbol for it */
++int nl_debug = 0;
++
+ static int iz_cb_seq_check(struct nl_msg *msg, void *arg);
+ static int iz_cb_valid(struct nl_msg *msg, void *arg);
+ static int iz_cb_finish(struct nl_msg *msg, void *arg);
+@@ -105,6 +108,7 @@ int main(int argc, char **argv)
+ 	struct nl_handle *nl;
+ 	struct nl_msg *msg;
+ 	char *dummy = NULL;
++	int err;
+ 
+ 	/* Currently processed command info */
+ 	struct iz_cmd cmd;
+@@ -180,7 +184,7 @@ int main(int argc, char **argv)
+ 	/* Prepare NL command */
+ 	nl = nl_handle_alloc();
+ 	if (!nl) {
+-		nl_perror("Could not allocate NL handle");
++		nl_perror(-NLE_NOMEM, "Could not allocate NL handle");
+ 		return 1;
+ 	}
+ 	genl_connect(nl);
+@@ -204,7 +208,7 @@ int main(int argc, char **argv)
+ 	if (cmd.desc->request) {
+ 		msg = nlmsg_alloc();
+ 		if (!msg) {
+-			nl_perror("Could not allocate NL message!\n");
++			nl_perror(-NLE_NOMEM, "Could not allocate NL message!\n");
+ 			return 1;
+ 		}
+ 		genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, family, 0,
+@@ -225,8 +229,8 @@ int main(int argc, char **argv)
+ 
+ 	/* Received message handling loop */
+ 	while (iz_exit == IZ_CONT_OK) {
+-		if(nl_recvmsgs_default(nl)) {
+-			nl_perror("Receive failed");
++		if((err = nl_recvmsgs_default(nl)) < 0) {
++			nl_perror(err, "Receive failed");
+ 			return 1;
+ 		}
+ 	}
Index: linux-zigbee/patches/100-no-docs-tests.patch
===================================================================
--- linux-zigbee/patches/100-no-docs-tests.patch	(revision 0)
+++ linux-zigbee/patches/100-no-docs-tests.patch	(revision 0)
@@ -0,0 +1,22 @@
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -2,7 +2,7 @@ include $(top_srcdir)/Makefile.common
+ 
+ ACLOCAL_AMFLAGS = -I m4
+ 
+-SUBDIRS = lib addrdb src tests test-serial
++SUBDIRS = lib addrdb src
+ 
+ include_HEADERS = include/ieee802154.h include/nl802154.h
+ noinst_HEADERS = include/libcommon.h include/addrdb.h include/logging.h
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -3,7 +3,7 @@ include $(top_srcdir)/Makefile.common
+ sbin_PROGRAMS = izattach izcoordinator iz
+ bin_PROGRAMS = izchat
+ 
+-manpages = izcoordinator.8 iz.8 izattach.8 izchat.1
++manpages =
+ izattach_DESC = "attach a serial device to IEEE 802.15.4 stack"
+ izcoordinator_DESC = "simple coordinator for IEEE 802.15.4 network"
+ iz_DESC = "configure an IEEE 802.15.4 interface"
Index: linux-zigbee/Makefile
===================================================================
--- linux-zigbee/Makefile	(revision 0)
+++ linux-zigbee/Makefile	(revision 0)
@@ -0,0 +1,48 @@
+#
+# Copyright (C) 2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=linux-zigbee
+PKG_VERSION:=2011-12-14
+PKG_RELEASE=$(PKG_SOURCE_VERSION)
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE_URL:=git://linux-zigbee.git.sourceforge.net/gitroot/linux-zigbee/linux-zigbee
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_VERSION:=2e45d08f8e0840807359c350247866f4749c0cec
+
+PKG_FIXUP:=autoreconf
+PKG_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+CONFIGURE_VARS += \
+	NL_CFLAGS="-I$(STAGING_DIR)/usr/include/libnl-tiny -Dnl_handle=nl_sock -Dnl_handle_alloc=nl_socket_alloc -Dnl_handle_destroy=nl_socket_destroy" \
+	NL_LIBS="-lnl -lnl-genl"
+
+
+define linux-zigbee-module
+  define Package/linux-zigbee-$(1)
+    SECTION:=net
+    CATEGORY:=Network
+    TITLE:=Linux ZigBee $(1) Utility
+    DEPENDS:=+libnl
+  endef
+
+  define Package/linux-zigbee-$(1)/install
+	$(INSTALL_DIR) $$(1)/usr/bin
+	$(INSTALL_BIN) $$(PKG_INSTALL_DIR)/usr/*/$(1) $$(1)/usr/bin/$(1)
+  endef
+endef
+
+
+EXECUTABLES = iz izattach izcoordinator izchat
+
+$(foreach x,$(EXECUTABLES),$(eval $(call linux-zigbee-module,$(x))))
+$(foreach x,$(EXECUTABLES),$(eval $(call BuildPackage,linux-zigbee-$(x))))


Signed-off-by: Peter Naulls <pe...@chocky.org>
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to