From 2bb14d854de40a7fa799f0bf4c5dbbccc38b8bc9 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 18 Jun 2017 16:02:11 -0600 Subject: [PATCH 1/2] L should be capitalized in 6LoWPAN --- ChangeLog.txt | 12 ++++++------ netutils/netlib/Makefile | 2 +- nshlib/nsh_netinit.c | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 89a5ea318..e52589cc8 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1906,7 +1906,7 @@ Kivilinna (2017-04-03). * NSH: Fix some warnings about integer/pointer casts of different sizes (probably only effects 64-bit simulation) (2017-04-03). - * examples/nettest: Trying to adapt to use for testing 6loWPAN + * examples/nettest: Trying to adapt to use for testing 6LoWPAN (2017-04-03). * examples/nettest: If doing loopback, but not using the official loopback device, then use the server should use the configured client @@ -1925,10 +1925,10 @@ default is +x. No printing of a trace of script commands as they are executed. From David Sidrane (2017-04-05). * Print expanded variables if -x. From David Sidrane (2017-04-05). - * examples/udpblaster: Several fixes to work with 6loWPAN (2017-04-06). + * examples/udpblaster: Several fixes to work with 6LoWPAN (2017-04-06). * examples/udpblaster: Add logic to bind the local UDP socket to a well-known address (2017-04-06). - * 6loWPAN: Add network IOCTL support to set the node address + * 6LoWPAN: Add network IOCTL support to set the node address (2017-04-06). * examples/ostest: Add tests for pthread_rwlock. Adding tests to be used to verify the pthread_rwlock lock works. From Mark Schulte @@ -1937,9 +1937,9 @@ unconditionally (2017-04-07). * examples/ostest: pthread rwlock additional tests and bugfixes. From Mark Schulte (2017-04-07). - * netutils: Add a helper function to convert a string to a 6loWPAN node + * netutils: Add a helper function to convert a string to a 6LoWPAN node address (2017-04-08). - * NSH library: Extend ifconfig to support 6loWPAN. Adapt to some + * NSH library: Extend ifconfig to support 6LoWPAN. Adapt to some changes in configuration variable usage (2017-04-08). * NSH set command: Eliminate useless argc check of SCRIPTS are enabled but ENVIRONMENT is disabled (2017-04-09). @@ -1995,7 +1995,7 @@ eth0 for network device name (2017-05-02). * wireless/wext: Add drivers_wext from the WPA supplicant; Integrate into NSH. From Simon Piriou (2017-05-02). - * 6loWPAN: Replace some Rime address naming with more consistent + * 6LoWPAN: Replace some Rime address naming with more consistent short/exended address terminology (2017-05-04). * wireless/ieee802154: Removes libradio to coincide with removal of ioctl with radio. Moves all functionality from libradio to libmac. diff --git a/netutils/netlib/Makefile b/netutils/netlib/Makefile index a36c6f844..0828ae46a 100644 --- a/netutils/netlib/Makefile +++ b/netutils/netlib/Makefile @@ -80,7 +80,7 @@ ifeq ($(CONFIG_NETDEV_WIRELESS_IOCTL),y) CSRCS += netlib_getessid.c netlib_setessid.c endif -# MAC address support(Ethernet and 6loWPAN only) +# MAC address support(Ethernet and 6LoWPAN only) ifeq ($(CONFIG_NET_ETHERNET),y) CSRCS += netlib_setmacaddr.c netlib_getmacaddr.c diff --git a/nshlib/nsh_netinit.c b/nshlib/nsh_netinit.c index f9d56af08..d4dbe8103 100644 --- a/nshlib/nsh_netinit.c +++ b/nshlib/nsh_netinit.c @@ -123,7 +123,7 @@ # undef CONFIG_NET_LOOPBACK #endif -/* Only Ethernet and 6loWPAN have MAC layer addresses */ +/* Only Ethernet and 6LoWPAN have MAC layer addresses */ #undef HAVE_MAC #if defined(CONFIG_NET_ETHERNET) || defined(CONFIG_NET_6LOWPAN) @@ -310,7 +310,7 @@ static void nsh_set_macaddr(void) eaddr[6] = (CONFIG_NSH_MACADDR >> (8 * 1)) & 0xff; eaddr[7] = (CONFIG_NSH_MACADDR >> (8 * 0)) & 0xff; - /* Set the 6loWPAN extended address */ + /* Set the 6LoWPAN extended address */ (void)netlib_seteaddr(NET_DEVNAME, eaddr); @@ -326,7 +326,7 @@ static void nsh_set_macaddr(void) * Description: * Setup IP addresses. * - * For 6loWPAN, the IP address derives from the MAC address. Setting it + * For 6LoWPAN, the IP address derives from the MAC address. Setting it * to any user provided value is asking for trouble. * ****************************************************************************/ From c2ad1d2d1c9aa8f916a0f50feeeaa05270c69c10 Mon Sep 17 00:00:00 2001 From: Anthony Merlino Date: Mon, 19 Jun 2017 05:56:52 -0400 Subject: [PATCH 2/2] Switches IEEE 802.15.4 based code to using byte arrays instead of uint16_t values for short address and PAN ID --- include/netutils/netlib.h | 2 +- include/wireless/ieee802154.h | 21 ++-- netutils/netlib/netlib_getpanid.c | 2 +- wireless/ieee802154/i8sak/i8sak.h | 6 +- wireless/ieee802154/i8sak/i8sak_acceptassoc.c | 28 ++--- wireless/ieee802154/i8sak/i8sak_assoc.c | 6 +- wireless/ieee802154/i8sak/i8sak_main.c | 107 ++++++++++++++++-- wireless/ieee802154/i8sak/i8sak_poll.c | 11 +- wireless/ieee802154/i8sak/i8sak_startpan.c | 44 +++++-- .../ieee802154/libmac/ieee802154_geteaddr.c | 2 +- .../ieee802154/libmac/ieee802154_getpanid.c | 4 +- .../ieee802154/libmac/ieee802154_getsaddr.c | 4 +- .../ieee802154/libmac/ieee802154_seteaddr.c | 2 +- .../ieee802154/libmac/ieee802154_setpanid.c | 4 +- .../ieee802154/libmac/ieee802154_setsaddr.c | 4 +- .../ieee802154/libmac/sixlowpan_geteaddr.c | 2 +- .../ieee802154/libmac/sixlowpan_getpanid.c | 4 +- .../ieee802154/libmac/sixlowpan_getsaddr.c | 4 +- .../ieee802154/libmac/sixlowpan_seteaddr.c | 2 +- .../ieee802154/libmac/sixlowpan_setpanid.c | 4 +- .../ieee802154/libmac/sixlowpan_setsaddr.c | 4 +- .../libutils/ieee802154_addrtostr.c | 4 + wireless/iwpan/src/iwpan.c | 4 +- 23 files changed, 195 insertions(+), 80 deletions(-) diff --git a/include/netutils/netlib.h b/include/netutils/netlib.h index 0f30da4ee..07a97b5bc 100644 --- a/include/netutils/netlib.h +++ b/include/netutils/netlib.h @@ -118,7 +118,7 @@ int netlib_getmacaddr(FAR const char *ifname, FAR uint8_t *macaddr); /* Set IEEE 802.15.4 extended address. */ int netlib_seteaddr(FAR const char *ifname, FAR const uint8_t *eaddr); -int netlib_getpanid(FAR const char *ifname, FAR uint16_t *panid); +int netlib_getpanid(FAR const char *ifname, FAR uint8_t *panid); bool netlib_eaddrconv(FAR const char *hwstr, FAR uint8_t *hw); #endif diff --git a/include/wireless/ieee802154.h b/include/wireless/ieee802154.h index e578077f0..7822a4e5c 100644 --- a/include/wireless/ieee802154.h +++ b/include/wireless/ieee802154.h @@ -2,7 +2,10 @@ * apps/include/wireless/ieee802154.h * * Copyright(C) 2015 Sebastien Lorquet. All rights reserved. + * Copyright(C) 2017 Verge Inc. All rights reserved. + * * Author: Sebastien Lorquet + * Author: Anthony Merlino * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -86,11 +89,11 @@ int ieee802154_calibrate_req(int fd, int ieee802154_setchan(int fd, uint8_t chan); int ieee802154_getchan(int fd, FAR uint8_t *chan); -int ieee802154_setpanid(int fd, uint16_t panid); -int ieee802154_getpanid(int fd, FAR uint16_t *panid); +int ieee802154_setpanid(int fd, FAR const uint8_t *panid); +int ieee802154_getpanid(int fd, FAR uint8_t *panid); -int ieee802154_setsaddr(int fd, uint16_t saddr); -int ieee802154_getsaddr(int fd, FAR uint16_t *saddr); +int ieee802154_setsaddr(int fd, FAR const uint8_t *saddr); +int ieee802154_getsaddr(int fd, FAR uint8_t *saddr); int ieee802154_seteaddr(int fd, FAR const uint8_t *eaddr); int ieee802154_geteaddr(int fd, FAR uint8_t *eaddr); @@ -154,13 +157,15 @@ int sixlowpan_calibrate_req(int sock, FAR const char *ifname, int sixlowpan_setchan(int sock, FAR const char *ifname, uint8_t chan); int sixlowpan_getchan(int sock, FAR const char *ifname, FAR uint8_t *chan); -int sixlowpan_setpanid(int sock, FAR const char *ifname, uint16_t panid); +int sixlowpan_setpanid(int sock, FAR const char *ifname, + FAR const uint8_t *panid); int sixlowpan_getpanid(int sock, FAR const char *ifname, - FAR uint16_t *panid); + FAR uint8_t *panid); -int sixlowpan_setsaddr(int sock, FAR const char *ifname, uint16_t saddr); +int sixlowpan_setsaddr(int sock, FAR const char *ifname, + FAR const uint8_t *saddr); int sixlowpan_getsaddr(int sock, FAR const char *ifname, - FAR uint16_t *saddr); + FAR uint8_t *saddr); int sixlowpan_seteaddr(int sock, FAR const char *ifname, FAR const uint8_t *eaddr); diff --git a/netutils/netlib/netlib_getpanid.c b/netutils/netlib/netlib_getpanid.c index 30f2d0ed7..98e2b4508 100644 --- a/netutils/netlib/netlib_getpanid.c +++ b/netutils/netlib/netlib_getpanid.c @@ -70,7 +70,7 @@ * ****************************************************************************/ -int netlib_getpanid(FAR const char *ifname, FAR uint16_t *panid) +int netlib_getpanid(FAR const char *ifname, FAR uint8_t *panid) { int ret = ERROR; diff --git a/wireless/ieee802154/i8sak/i8sak.h b/wireless/ieee802154/i8sak/i8sak.h index 7beece2a5..c9508ce14 100644 --- a/wireless/ieee802154/i8sak/i8sak.h +++ b/wireless/ieee802154/i8sak/i8sak.h @@ -99,6 +99,8 @@ /* /dev/ is 5 characters */ #define I8SAK_DAEMONNAME_FMTLEN (6 + (I8SAK_MAX_DEVNAME-5) + 1) + + /**************************************************************************** * Public Types ****************************************************************************/ @@ -148,7 +150,7 @@ struct i8sak_s uint8_t chpage; struct ieee802154_addr_s addr; struct ieee802154_addr_s ep; - uint16_t next_saddr; + uint8_t next_saddr[IEEE802154_SADDRSIZE]; uint8_t payload[IEEE802154_MAX_MAC_PAYLOAD_SIZE]; uint16_t payload_len; int blasterperiod; @@ -166,6 +168,8 @@ uint8_t i8sak_char2nibble(char ch); int i8sak_str2payload(FAR const char *str, FAR uint8_t *buf); void i8sak_str2eaddr(FAR const char *str, FAR uint8_t *eaddr); +void i8sak_str2saddr(FAR const char *str, FAR uint8_t *saddr); +void i8sak_str2panid(FAR const char *str, FAR uint8_t *panid); bool i8sak_str2bool(FAR const char *str); void i8sak_startpan_cmd (FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]); diff --git a/wireless/ieee802154/i8sak/i8sak_acceptassoc.c b/wireless/ieee802154/i8sak/i8sak_acceptassoc.c index 5edace40a..c68caa466 100644 --- a/wireless/ieee802154/i8sak/i8sak_acceptassoc.c +++ b/wireless/ieee802154/i8sak/i8sak_acceptassoc.c @@ -137,37 +137,25 @@ static void acceptassoc_eventcb(FAR struct ieee802154_notif_s *notif, FAR void * printf("i8sak: a device is trying to associate\n"); + /* Send a ASSOC.resp primtive to the MAC. Copy the association + * indication address into the association response primitive + */ + + IEEE802154_EADDRCOPY(assocresp.devaddr, notif->u.assocind.devaddr); + /* If the address matches our device, accept the association. * Otherwise, reject the assocation. */ - if (memcmp(¬if->u.assocind.devaddr[0], &i8sak->ep.eaddr[0], - IEEE802154_EADDR_LEN) == 0) + if (IEEE802154_EADDRCMP(notif->u.assocind.devaddr, i8sak->ep.eaddr)) { - /* Send a ASSOC.resp primtive to the MAC. Copy the association - * indication address into the association response primitive - */ - - memcpy(&assocresp.devaddr[0], ¬if->u.assocind.devaddr[0], - IEEE802154_EADDR_LEN); - - assocresp.assocsaddr = i8sak->next_saddr; - + IEEE802154_SADDRCOPY(assocresp.assocsaddr, i8sak->next_saddr); assocresp.status = IEEE802154_STATUS_SUCCESS; - printf("i8sak: accepting association request\n"); } else { - /* Send a ASSOC.resp primtive to the MAC. Copy the association - * indication address into the association response primitive - */ - - memcpy(&assocresp.devaddr[0], ¬if->u.assocind.devaddr[0], - IEEE802154_EADDR_LEN); - assocresp.status = IEEE802154_STATUS_DENIED; - printf("i8sak: rejecting association request\n"); } diff --git a/wireless/ieee802154/i8sak/i8sak_assoc.c b/wireless/ieee802154/i8sak/i8sak_assoc.c index d03e0b5a7..da34816ab 100644 --- a/wireless/ieee802154/i8sak/i8sak_assoc.c +++ b/wireless/ieee802154/i8sak/i8sak_assoc.c @@ -115,14 +115,14 @@ void i8sak_assoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) case 's': /* Parse extended address and put it into the i8sak instance */ - i8sak->ep.saddr = i8sak_str2luint16(optarg); + i8sak_str2saddr(optarg, i8sak->ep.saddr); i8sak->ep.mode= IEEE802154_ADDRMODE_SHORT; break; case 'e': /* Parse extended address and put it into the i8sak instance */ - i8sak_str2eaddr(optarg, &i8sak->ep.eaddr[0]); + i8sak_str2eaddr(optarg, i8sak->ep.eaddr); i8sak->ep.mode = IEEE802154_ADDRMODE_EXTENDED; break; @@ -148,7 +148,7 @@ void i8sak_assoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) if (optcnt && argc == 2) { - i8sak->ep.panid = i8sak_str2luint16(argv[1]); + i8sak_str2panid(argv[1], i8sak->ep.panid); } fd = open(i8sak->devname, O_RDWR); diff --git a/wireless/ieee802154/i8sak/i8sak_main.c b/wireless/ieee802154/i8sak/i8sak_main.c index ff84570d7..96586778f 100644 --- a/wireless/ieee802154/i8sak/i8sak_main.c +++ b/wireless/ieee802154/i8sak/i8sak_main.c @@ -353,7 +353,7 @@ uint8_t i8sak_char2nibble(char ch) * Name: i8sak_str2eaddr * * Description: - * Convert a string 8-byte EADAR array. + * Convert a string 8-byte EADDR array. * ****************************************************************************/ @@ -387,6 +387,82 @@ void i8sak_str2eaddr(FAR const char *str, FAR uint8_t *eaddr) } } +/**************************************************************************** + * Name: i8sak_str2saddr + * + * Description: + * Convert a string 2-byte SADDR array. + * + ****************************************************************************/ + +void i8sak_str2saddr(FAR const char *str, FAR uint8_t *saddr) +{ + FAR const char *src = str; + uint8_t bvalue; + char ch; + int i; + + for (i = 0; i < 2; i++) + { + ch = (char)*src++; + bvalue = i8sak_char2nibble(ch) << 4; + + ch = (char)*src++; + bvalue |= i8sak_char2nibble(ch); + + *saddr++ = bvalue; + + if (i < 1) + { + ch = (char)*src++; + if (ch != ':') + { + fprintf(stderr, "ERROR: Missing colon separator: %s\n", str); + fprintf(stderr, " Expected xx:xx\n"); + exit(EXIT_FAILURE); + } + } + } +} + +/**************************************************************************** + * Name: i8sak_str2panid + * + * Description: + * Convert a string 2-byte PAN ID array. + * + ****************************************************************************/ + +void i8sak_str2panid(FAR const char *str, FAR uint8_t *panid) +{ + FAR const char *src = str; + uint8_t bvalue; + char ch; + int i; + + for (i = 0; i < 2; i++) + { + ch = (char)*src++; + bvalue = i8sak_char2nibble(ch) << 4; + + ch = (char)*src++; + bvalue |= i8sak_char2nibble(ch); + + *panid++ = bvalue; + + if (i < 1) + { + ch = (char)*src++; + if (ch != ':') + { + fprintf(stderr, "ERROR: Missing colon separator: %s\n", str); + fprintf(stderr, " Expected xx:xx\n"); + exit(EXIT_FAILURE); + } + } + } +} + /**************************************************************************** * Name: i8sak_str2bool * @@ -496,23 +572,38 @@ static int i8sak_setup(FAR struct i8sak_s *i8sak, FAR const char *devname) /* Initialze default extended address */ - for (i = 0; i < IEEE802154_EADDR_LEN; i++) + for (i = 0; i < IEEE802154_EADDRSIZE; i++) { i8sak->addr.eaddr[i] = (uint8_t)((CONFIG_IEEE802154_I8SAK_DEV_EADDR >> (i*8)) & 0xFF); } /* Initialize the default remote endpoint address */ - for (i = 0; i < IEEE802154_EADDR_LEN; i++) + i8sak->ep.mode = IEEE802154_ADDRMODE_SHORT; + + for (i = 0; i < IEEE802154_EADDRSIZE; i++) { i8sak->ep.eaddr[i] = (uint8_t)((CONFIG_IEEE802154_I8SAK_PANCOORD_EADDR >> (i*8)) & 0xFF); } - i8sak->ep.mode = IEEE802154_ADDRMODE_SHORT; - i8sak->ep.saddr = CONFIG_IEEE802154_I8SAK_PANCOORD_SADDR; - i8sak->ep.panid = CONFIG_IEEE802154_I8SAK_PANID; + for (i = 0; i < IEEE802154_SADDRSIZE; i++) + { + i8sak->ep.saddr[i] = (uint8_t)((CONFIG_IEEE802154_I8SAK_PANCOORD_SADDR >> (i*8)) & 0xFF); + } - i8sak->next_saddr = CONFIG_IEEE802154_I8SAK_DEV_SADDR; + for (i = 0; i < IEEE802154_PANIDSIZE; i++) + { + i8sak->ep.panid[i] = (uint8_t)((CONFIG_IEEE802154_I8SAK_PANID >> (i*8)) & 0xFF); + } + + /* Set the next association device to the default device address, so that + * the first device to request association gets that address. + */ + + for (i = 0; i < IEEE802154_SADDRSIZE; i++) + { + i8sak->next_saddr[i] = (uint8_t)((CONFIG_IEEE802154_I8SAK_DEV_SADDR >> (i*8)) & 0xFF); + } fd = open(i8sak->devname, O_RDWR); if (fd < 0) @@ -521,7 +612,7 @@ static int i8sak_setup(FAR struct i8sak_s *i8sak, FAR const char *devname) i8sak_cmd_error(i8sak); } - ieee802154_seteaddr(fd, &i8sak->addr.eaddr[0]); + ieee802154_seteaddr(fd, i8sak->addr.eaddr); close(fd); diff --git a/wireless/ieee802154/i8sak/i8sak_poll.c b/wireless/ieee802154/i8sak/i8sak_poll.c index fa59dc2ed..7db6eaf48 100644 --- a/wireless/ieee802154/i8sak/i8sak_poll.c +++ b/wireless/ieee802154/i8sak/i8sak_poll.c @@ -63,7 +63,6 @@ ****************************************************************************/ static void poll_eventcb(FAR struct ieee802154_notif_s *notif, FAR void *arg); -static void poll_receiver(FAR struct mac802154dev_rxframe_s *frame, FAR void *arg); /**************************************************************************** * Public Functions @@ -133,13 +132,13 @@ void i8sak_poll_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) wpanlistener_add_eventreceiver(&i8sak->wpanlistener, poll_eventcb, &eventfilter, (FAR void *)i8sak, true); - printf("i8sak: Polling coordinator. PAN ID: 0x%04X SADDR: 0x%04X\n", - i8sak->ep.panid, - i8sak->ep.saddr); + printf("i8sak: Polling coordinator. PAN ID: %02X:%02X SADDR: %02X:%02X\n", + i8sak->ep.panid[0], i8sak->ep.panid[1], + i8sak->ep.saddr[0], i8sak->ep.saddr[1]); pollreq.coordaddr.mode = IEEE802154_ADDRMODE_SHORT; - pollreq.coordaddr.saddr = i8sak->ep.saddr; - pollreq.coordaddr.panid = i8sak->ep.panid; + IEEE802154_SADDRCOPY(pollreq.coordaddr.saddr, i8sak->ep.saddr); + IEEE802154_PANIDCOPY(pollreq.coordaddr.panid, i8sak->ep.panid); ieee802154_poll_req(fd, &pollreq); diff --git a/wireless/ieee802154/i8sak/i8sak_startpan.c b/wireless/ieee802154/i8sak/i8sak_startpan.c index c1dd5fcb7..409e83ea2 100644 --- a/wireless/ieee802154/i8sak/i8sak_startpan.c +++ b/wireless/ieee802154/i8sak/i8sak_startpan.c @@ -129,37 +129,61 @@ void i8sak_startpan_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]) if (!i8sak->addrset) { - for (i = 0; i < IEEE802154_EADDR_LEN; i++) + /* Set our address to the default PAN Coordinator configuration */ + + i8sak->addr.mode = IEEE802154_ADDRMODE_SHORT; + + for (i = 0; i < IEEE802154_EADDRSIZE; i++) { i8sak->addr.eaddr[i] = (uint8_t)((CONFIG_IEEE802154_I8SAK_PANCOORD_EADDR >> (i*8)) & 0xFF); } - i8sak->addr.mode = IEEE802154_ADDRMODE_SHORT; - i8sak->addr.saddr = CONFIG_IEEE802154_I8SAK_PANCOORD_SADDR; - i8sak->addr.panid = CONFIG_IEEE802154_I8SAK_PANID; + for (i = 0; i < IEEE802154_SADDRSIZE; i++) + { + i8sak->addr.saddr[i] = + (uint8_t)((CONFIG_IEEE802154_I8SAK_PANCOORD_SADDR >> (i*8)) & 0xFF); + } - for (i = 0; i < IEEE802154_EADDR_LEN; i++) + for (i = 0; i < IEEE802154_PANIDSIZE; i++) + { + i8sak->addr.panid[i] = + (uint8_t)((CONFIG_IEEE802154_I8SAK_PANID >> (i*8)) & 0xFF); + } + + /* Set the endpoint address to the default endpoint device */ + + i8sak->ep.mode = IEEE802154_ADDRMODE_SHORT; + + for (i = 0; i < IEEE802154_EADDRSIZE; i++) { i8sak->ep.eaddr[i] = (uint8_t)((CONFIG_IEEE802154_I8SAK_DEV_EADDR >> (i*8)) & 0xFF); } - i8sak->ep.mode = IEEE802154_ADDRMODE_SHORT; - i8sak->ep.saddr = CONFIG_IEEE802154_I8SAK_DEV_SADDR; - i8sak->ep.panid = CONFIG_IEEE802154_I8SAK_PANID; + for (i = 0; i < IEEE802154_SADDRSIZE; i++) + { + i8sak->ep.saddr[i] = + (uint8_t)((CONFIG_IEEE802154_I8SAK_DEV_SADDR >> (i*8)) & 0xFF); + } + + for (i = 0; i < IEEE802154_PANIDSIZE; i++) + { + i8sak->ep.panid[i] = + (uint8_t)((CONFIG_IEEE802154_I8SAK_PANID >> (i*8)) & 0xFF); + } } /* Set EADDR and SADDR */ - ieee802154_seteaddr(fd, &i8sak->addr.eaddr[0]); + ieee802154_seteaddr(fd, i8sak->addr.eaddr); ieee802154_setsaddr(fd, i8sak->addr.saddr); /* Tell the MAC to start acting as a coordinator */ printf("i8sak: starting PAN\n"); - startreq.panid = i8sak->addr.panid; + IEEE802154_PANIDCOPY(startreq.panid, i8sak->addr.panid); startreq.chnum = i8sak->chnum; startreq.chpage = i8sak->chpage; startreq.beaconorder = 15; diff --git a/wireless/ieee802154/libmac/ieee802154_geteaddr.c b/wireless/ieee802154/libmac/ieee802154_geteaddr.c index 5cfeeab06..773c7ffe8 100644 --- a/wireless/ieee802154/libmac/ieee802154_geteaddr.c +++ b/wireless/ieee802154/libmac/ieee802154_geteaddr.c @@ -61,7 +61,7 @@ int ieee802154_geteaddr(int fd, FAR uint8_t *eaddr) req.attr = IEEE802154_ATTR_MAC_EXTENDED_ADDR; ret = ieee802154_get_req(fd, &req); - memcpy(eaddr, &req.attrval.mac.eaddr[0], 8); + IEEE802154_EADDRCOPY(eaddr, req.attrval.mac.eaddr); return ret; } diff --git a/wireless/ieee802154/libmac/ieee802154_getpanid.c b/wireless/ieee802154/libmac/ieee802154_getpanid.c index 565fa1154..e48f1f1a7 100644 --- a/wireless/ieee802154/libmac/ieee802154_getpanid.c +++ b/wireless/ieee802154/libmac/ieee802154_getpanid.c @@ -52,7 +52,7 @@ * Public Functions ****************************************************************************/ -int ieee802154_getpanid(int fd, FAR uint16_t *panid) +int ieee802154_getpanid(int fd, FAR uint8_t *panid) { struct ieee802154_get_req_s req; int ret; @@ -60,7 +60,7 @@ int ieee802154_getpanid(int fd, FAR uint16_t *panid) req.attr = IEEE802154_ATTR_MAC_PANID; ret = ieee802154_get_req(fd, &req); - *panid = req.attrval.mac.panid; + IEEE802154_PANIDCOPY(panid, req.attrval.mac.panid); return ret; } diff --git a/wireless/ieee802154/libmac/ieee802154_getsaddr.c b/wireless/ieee802154/libmac/ieee802154_getsaddr.c index b9c11448a..2762b92fb 100644 --- a/wireless/ieee802154/libmac/ieee802154_getsaddr.c +++ b/wireless/ieee802154/libmac/ieee802154_getsaddr.c @@ -52,7 +52,7 @@ * Public Functions ****************************************************************************/ -int ieee802154_getsaddr(int fd, FAR uint16_t *saddr) +int ieee802154_getsaddr(int fd, FAR uint8_t *saddr) { struct ieee802154_get_req_s req; int ret; @@ -60,7 +60,7 @@ int ieee802154_getsaddr(int fd, FAR uint16_t *saddr) req.attr = IEEE802154_ATTR_MAC_SHORT_ADDRESS; ret = ieee802154_get_req(fd, &req); - *saddr = req.attrval.mac.saddr; + IEEE802154_SADDRCOPY(saddr, req.attrval.mac.saddr); return ret; } diff --git a/wireless/ieee802154/libmac/ieee802154_seteaddr.c b/wireless/ieee802154/libmac/ieee802154_seteaddr.c index ace1d9876..19494eafd 100644 --- a/wireless/ieee802154/libmac/ieee802154_seteaddr.c +++ b/wireless/ieee802154/libmac/ieee802154_seteaddr.c @@ -59,7 +59,7 @@ int ieee802154_seteaddr(int fd, FAR const uint8_t *eaddr) struct ieee802154_set_req_s req; req.attr = IEEE802154_ATTR_MAC_EXTENDED_ADDR; - memcpy(&req.attrval.mac.eaddr[0], eaddr, 8); + IEEE802154_EADDRCOPY(req.attrval.mac.eaddr, eaddr); return ieee802154_set_req(fd, &req); } diff --git a/wireless/ieee802154/libmac/ieee802154_setpanid.c b/wireless/ieee802154/libmac/ieee802154_setpanid.c index b578028c1..f9680e67c 100644 --- a/wireless/ieee802154/libmac/ieee802154_setpanid.c +++ b/wireless/ieee802154/libmac/ieee802154_setpanid.c @@ -53,12 +53,12 @@ * Public Functions ****************************************************************************/ -int ieee802154_setpanid(int fd, uint16_t panid) +int ieee802154_setpanid(int fd, FAR const uint8_t *panid) { struct ieee802154_set_req_s req; req.attr = IEEE802154_ATTR_MAC_PANID; - req.attrval.mac.panid = panid; + IEEE802154_PANIDCOPY(req.attrval.mac.panid, panid); return ieee802154_set_req(fd, &req); } diff --git a/wireless/ieee802154/libmac/ieee802154_setsaddr.c b/wireless/ieee802154/libmac/ieee802154_setsaddr.c index 03eb43628..6cadd4ac2 100644 --- a/wireless/ieee802154/libmac/ieee802154_setsaddr.c +++ b/wireless/ieee802154/libmac/ieee802154_setsaddr.c @@ -53,12 +53,12 @@ * Public Functions ****************************************************************************/ -int ieee802154_setsaddr(int fd, uint16_t saddr) +int ieee802154_setsaddr(int fd, FAR const uint8_t *saddr) { struct ieee802154_set_req_s req; req.attr = IEEE802154_ATTR_MAC_SHORT_ADDRESS; - req.attrval.mac.saddr = saddr; + IEEE802154_SADDRCOPY(req.attrval.mac.saddr, saddr); return ieee802154_set_req(fd, &req); } diff --git a/wireless/ieee802154/libmac/sixlowpan_geteaddr.c b/wireless/ieee802154/libmac/sixlowpan_geteaddr.c index 9f10c9b3e..0344d43c6 100644 --- a/wireless/ieee802154/libmac/sixlowpan_geteaddr.c +++ b/wireless/ieee802154/libmac/sixlowpan_geteaddr.c @@ -61,7 +61,7 @@ int sixlowpan_geteaddr(int sock, FAR const char *ifname, FAR uint8_t *eaddr) req.attr = IEEE802154_ATTR_MAC_EXTENDED_ADDR; ret = sixlowpan_get_req(sock, ifname, &req); - memcpy(eaddr, &req.attrval.mac.eaddr[0], 8); + IEEE802154_EADDRCOPY(eaddr, req.attrval.mac.eaddr); return ret; } diff --git a/wireless/ieee802154/libmac/sixlowpan_getpanid.c b/wireless/ieee802154/libmac/sixlowpan_getpanid.c index ae95008f4..0694e3f3e 100644 --- a/wireless/ieee802154/libmac/sixlowpan_getpanid.c +++ b/wireless/ieee802154/libmac/sixlowpan_getpanid.c @@ -53,7 +53,7 @@ * Public Functions ****************************************************************************/ -int sixlowpan_getpanid(int sock, FAR const char *ifname, FAR uint16_t *panid) +int sixlowpan_getpanid(int sock, FAR const char *ifname, FAR uint8_t *panid) { struct ieee802154_get_req_s req; int ret; @@ -61,7 +61,7 @@ int sixlowpan_getpanid(int sock, FAR const char *ifname, FAR uint16_t *panid) req.attr = IEEE802154_ATTR_MAC_PANID; ret = sixlowpan_get_req(sock, ifname, &req); - *panid = req.attrval.mac.panid; + IEEE802154_PANIDCOPY(panid, req.attrval.mac.panid); return ret; } diff --git a/wireless/ieee802154/libmac/sixlowpan_getsaddr.c b/wireless/ieee802154/libmac/sixlowpan_getsaddr.c index 0e8471677..ef221190c 100644 --- a/wireless/ieee802154/libmac/sixlowpan_getsaddr.c +++ b/wireless/ieee802154/libmac/sixlowpan_getsaddr.c @@ -53,7 +53,7 @@ * Public Functions ****************************************************************************/ -int sixlowpan_getsaddr(int sock, FAR const char *ifname, FAR uint16_t *saddr) +int sixlowpan_getsaddr(int sock, FAR const char *ifname, FAR uint8_t *saddr) { struct ieee802154_get_req_s req; int ret; @@ -61,7 +61,7 @@ int sixlowpan_getsaddr(int sock, FAR const char *ifname, FAR uint16_t *saddr) req.attr = IEEE802154_ATTR_MAC_SHORT_ADDRESS; ret = sixlowpan_get_req(sock, ifname, &req); - *saddr = req.attrval.mac.saddr; + IEEE802154_SADDRCOPY(saddr, req.attrval.mac.saddr); return ret; } diff --git a/wireless/ieee802154/libmac/sixlowpan_seteaddr.c b/wireless/ieee802154/libmac/sixlowpan_seteaddr.c index 453ef6d49..9f3dcb46d 100644 --- a/wireless/ieee802154/libmac/sixlowpan_seteaddr.c +++ b/wireless/ieee802154/libmac/sixlowpan_seteaddr.c @@ -58,7 +58,7 @@ int sixlowpan_seteaddr(int sock, FAR const char *ifname, FAR const uint8_t *eadd struct ieee802154_set_req_s req; req.attr = IEEE802154_ATTR_MAC_EXTENDED_ADDR; - memcpy(&req.attrval.mac.eaddr[0], eaddr, 8); + IEEE802154_EADDRCOPY(req.attrval.mac.eaddr, eaddr); return sixlowpan_set_req(sock, ifname, &req); } diff --git a/wireless/ieee802154/libmac/sixlowpan_setpanid.c b/wireless/ieee802154/libmac/sixlowpan_setpanid.c index b99e95691..559ae13e9 100644 --- a/wireless/ieee802154/libmac/sixlowpan_setpanid.c +++ b/wireless/ieee802154/libmac/sixlowpan_setpanid.c @@ -53,12 +53,12 @@ * Public Functions ****************************************************************************/ -int sixlowpan_setpanid(int sock, FAR const char *ifname, uint16_t panid) +int sixlowpan_setpanid(int sock, FAR const char *ifname, FAR const uint8_t *panid) { struct ieee802154_set_req_s req; req.attr = IEEE802154_ATTR_MAC_PANID; - req.attrval.mac.panid = panid; + IEEE802154_PANIDCOPY(req.attrval.mac.panid, panid); return sixlowpan_set_req(sock, ifname, &req); } diff --git a/wireless/ieee802154/libmac/sixlowpan_setsaddr.c b/wireless/ieee802154/libmac/sixlowpan_setsaddr.c index 7812ae21f..49c46f28b 100644 --- a/wireless/ieee802154/libmac/sixlowpan_setsaddr.c +++ b/wireless/ieee802154/libmac/sixlowpan_setsaddr.c @@ -53,12 +53,12 @@ * Public Functions ****************************************************************************/ -int sixlowpan_setsaddr(int sock, FAR const char *ifname, uint16_t saddr) +int sixlowpan_setsaddr(int sock, FAR const char *ifname, FAR const uint8_t *saddr) { struct ieee802154_set_req_s req; req.attr = IEEE802154_ATTR_MAC_SHORT_ADDRESS; - req.attrval.mac.saddr = saddr; + IEEE802154_SADDRCOPY(req.attrval.mac.saddr, saddr); return sixlowpan_set_req(sock, ifname, &req); } diff --git a/wireless/ieee802154/libutils/ieee802154_addrtostr.c b/wireless/ieee802154/libutils/ieee802154_addrtostr.c index 42c9ed02a..818dd302e 100644 --- a/wireless/ieee802154/libutils/ieee802154_addrtostr.c +++ b/wireless/ieee802154/libutils/ieee802154_addrtostr.c @@ -48,9 +48,11 @@ * Public Functions ****************************************************************************/ + int ieee802154_addrtostr(FAR char *buf, int len, FAR struct ieee802154_addr_s *addr) { +#if 0 #ifndef CONFIG_BIG_ENDIAN uint16_t panid = ((addr->panid & 0xff) << 8) | ((addr->panid >> 8) & 0xff); #else @@ -87,5 +89,7 @@ int ieee802154_addrtostr(FAR char *buf, int len, return snprintf(buf,len,""); } + return -1; +#endif return -1; } diff --git a/wireless/iwpan/src/iwpan.c b/wireless/iwpan/src/iwpan.c index 769a1ec3f..9ac1b28e9 100644 --- a/wireless/iwpan/src/iwpan.c +++ b/wireless/iwpan/src/iwpan.c @@ -315,7 +315,7 @@ static bool iwpan_str2bool(FAR const char *str) static void iwpan_show_cmd(int sock, FAR const char *ifname) { - uint8_t eaddr[IEEE802154_EADDR_LEN] = + uint8_t eaddr[IEEE802154_EADDRSIZE] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; @@ -506,7 +506,7 @@ static void iwpan_devmode_cmd(int sock, FAR const char *ifname, static void iwpan_eaddr_cmd(int sock, FAR const char *ifname, FAR const char *addrstr) { - uint8_t eaddr[IEEE802154_EADDR_LEN]; + uint8_t eaddr[IEEE802154_EADDRSIZE]; int ret; /* Convert input strings to values */