---
 include/nl802154.h     |    1 +
 src/iz-phy.c           |   68 ++++++++++++++++++++++++++++++++++++++++++++++++
 test-serial/test_DQ.py |    6 ++--
 3 files changed, 72 insertions(+), 3 deletions(-)

diff --git a/include/nl802154.h b/include/nl802154.h
index ce1e6a1..cc80bd6 100644
--- a/include/nl802154.h
+++ b/include/nl802154.h
@@ -131,6 +131,7 @@ enum {
        IEEE802154_DEV_WPAN,
        IEEE802154_DEV_MONITOR,
        IEEE802154_DEV_SMAC,
+       IEEE802154_DEV_6LOWPAN,
        __IEEE802154_DEV_MAX,
 };
 
diff --git a/src/iz-phy.c b/src/iz-phy.c
index 3c51fb8..d816f7e 100644
--- a/src/iz-phy.c
+++ b/src/iz-phy.c
@@ -185,6 +185,64 @@ static iz_res_t add_phy_response(struct iz_cmd *cmd, 
struct genlmsghdr *ghdr, st
        return IZ_STOP_OK;
 }
 
+/******************
+ *  6lowpan handling  *
+ ******************/
+
+static iz_res_t lowpan_phy_parse(struct iz_cmd *cmd)
+{
+       if (cmd->argc < 2 || cmd->argc > 4) {
+               printf("Incorrect number of arguments!\n");
+               return IZ_STOP_ERR;
+       }
+
+       cmd->phy = cmd->argv[1];
+       cmd->iface = cmd->argv[2]; /* Either iface name or NULL */
+
+       return IZ_CONT_OK;
+}
+
+static iz_res_t lowpan_phy_request(struct iz_cmd *cmd, struct nl_msg *msg)
+{
+       unsigned char hwa[IEEE802154_ADDR_LEN];
+
+       /* add single interface */
+       NLA_PUT_STRING(msg, IEEE802154_ATTR_PHY_NAME, cmd->phy);
+       if (cmd->iface)
+               NLA_PUT_STRING(msg, IEEE802154_ATTR_DEV_NAME, cmd->iface);
+
+       NLA_PUT_U8(msg, IEEE802154_ATTR_DEV_TYPE, IEEE802154_DEV_6LOWPAN);
+
+       if (cmd->argc >= 4) {
+               int ret = parse_hw_addr(cmd->argv[3], hwa);
+               if (ret) {
+                       printf("Bad coordinator address!\n");
+                       return IZ_STOP_ERR;
+               }
+               NLA_PUT(msg, IEEE802154_ATTR_HW_ADDR,
+                       IEEE802154_ADDR_LEN, hwa);
+       }
+
+       return IZ_CONT_OK;
+
+nla_put_failure:
+       return IZ_STOP_ERR;
+
+}
+
+static iz_res_t lowpan_phy_response(struct iz_cmd *cmd, struct genlmsghdr 
*ghdr, struct nlattr **attrs)
+{
+       if (!attrs[IEEE802154_ATTR_DEV_NAME] ||
+           !attrs[IEEE802154_ATTR_PHY_NAME])
+               return IZ_STOP_ERR;
+
+       printf("Registered new device ('%s') on phy %s\n",
+                       nla_get_string(attrs[IEEE802154_ATTR_DEV_NAME]),
+                       nla_get_string(attrs[IEEE802154_ATTR_PHY_NAME]));
+
+       return IZ_STOP_OK;
+}
+
 /********************
  * MONITOR handling *
  ********************/
@@ -303,6 +361,16 @@ const struct iz_module iz_phy = {
                .response       = add_phy_response,
        },
        {
+               .name           = "6lowpan",
+               .usage          = "phy [name [hwaddr]]",
+               .doc            = "Add a 6LOWPAN interface attached to 
specified phy.",
+               .nl_cmd         = IEEE802154_ADD_IFACE,
+               .nl_resp        = IEEE802154_ADD_IFACE,
+               .parse          = lowpan_phy_parse,
+               .request        = lowpan_phy_request,
+               .response       = lowpan_phy_response,
+       },
+       {
                .name           = "monitor",
                .usage          = "phy [name]",
                .doc            = "Add monitoring interface, passing all 
received frames.",
diff --git a/test-serial/test_DQ.py b/test-serial/test_DQ.py
index 2271fe7..01944f6 100644
--- a/test-serial/test_DQ.py
+++ b/test-serial/test_DQ.py
@@ -45,8 +45,8 @@ class DQ:
 
                try:
                        self.oldattrs = tcgetattr(self.file)
-                       attrs = [IGNPAR, self.oldattrs[1], 0, 0, B115200, 
B115200, self.oldattrs[6]]
-                       attrs[2] = B115200 | CS8 | CLOCAL | CREAD
+                       attrs = [IGNPAR, self.oldattrs[1], 0, 0, B230400, 
B230400, self.oldattrs[6]]
+                       attrs[2] = B230400 | CS8 | CLOCAL | CREAD
                        attrs[6][VTIME] = 0
                        attrs[6][VMIN] = 1
                        tcflush(self.file, TCIFLUSH)
@@ -162,7 +162,7 @@ class DQ:
                while 1:
                        v = self.__response()
                        if (v != 0x8b) :
-                               print "Returned invalid id value %x" % (v)
+                               print "Returned invalid rid value %x" % (v)
                        else:
                                break
                return self.status


------------------------------------------------------------------------------
Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
Be part of this innovative community and reach millions of netbook users 
worldwide. Take advantage of special opportunities to increase revenue and 
speed time-to-market. Join now, and jumpstart your future.
http://p.sf.net/sfu/intel-atom-d2d
_______________________________________________
Linux-zigbee-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-zigbee-devel

Reply via email to