pthread.h: Fix rwlock initializer

This commit is contained in:
Mark Schulte 2017-04-08 12:34:08 -06:00 committed by Gregory Nutt
parent 3f51180cca
commit 35ca733108
10 changed files with 122 additions and 103 deletions

View File

@ -539,7 +539,7 @@ CONFIG_NET_6LOWPAN_MAXADDRCONTEXT=1
CONFIG_NET_6LOWPAN_MAXADDRCONTEXT_PREFIX_0_0=0xaa
CONFIG_NET_6LOWPAN_MAXADDRCONTEXT_PREFIX_0_1=0xaa
# CONFIG_NET_6LOWPAN_MAXADDRCONTEXT_PREINIT_1 is not set
CONFIG_NET_6LOWPAN_RIMEADDR_SIZE=2
# CONFIG_NET_6LOWPAN_RIMEADDR_EXTENDED is not set
CONFIG_NET_6LOWPAN_MAXAGE=20
CONFIG_NET_6LOWPAN_MAX_MACTRANSMITS=4
CONFIG_NET_6LOWPAN_MAXPAYLOAD=102

View File

@ -63,6 +63,17 @@
* Pre-processor Definitions
****************************************************************************/
/* By default, a 2-byte Rime address is used for the IEEE802.15.4 MAC
* device's link layer address. If CONFIG_NET_6LOWPAN_RIMEADDR_EXTENDED
* is selected, then an 8-byte Rime address will be used.
*/
#ifdef CONFIG_NET_6LOWPAN_RIMEADDR_EXTENDED
# define NET_6LOWPAN_RIMEADDR_SIZE 8
#else
# define NET_6LOWPAN_RIMEADDR_SIZE 2
#endif
/* Frame format definitions *************************************************/
/* Fragment header.
*
@ -374,7 +385,7 @@
struct rimeaddr_s
{
uint8_t u8[CONFIG_NET_6LOWPAN_RIMEADDR_SIZE];
uint8_t u8[NET_6LOWPAN_RIMEADDR_SIZE];
};
/* The device structure for IEEE802.15.4 MAC network device differs from the

View File

@ -352,7 +352,7 @@ typedef int pthread_rwlockattr_t;
#define PTHREAD_RWLOCK_INITIALIZER {PTHREAD_MUTEX_INITIALIZER, \
PTHREAD_COND_INITIALIZER, \
0, 0}
0, 0, false}
#ifdef CONFIG_PTHREAD_CLEANUP
/* This type describes the pthread cleanup callback (non-standard) */

View File

@ -739,7 +739,7 @@ static int netdev_ifrioctl(FAR struct socket *psock, int cmd,
req->ifr_hwaddr.sa_family = AF_INETX;
memcpy(req->ifr_hwaddr.sa_data, ieee->i_nodeaddr.u8,
CONFIG_NET_6LOWPAN_RIMEADDR_SIZE);
NET_6LOWPAN_RIMEADDR_SIZE);
ret = OK;
}
else
@ -782,7 +782,7 @@ static int netdev_ifrioctl(FAR struct socket *psock, int cmd,
req->ifr_hwaddr.sa_family = AF_INETX;
memcpy(ieee->i_nodeaddr.u8, req->ifr_hwaddr.sa_data,
CONFIG_NET_6LOWPAN_RIMEADDR_SIZE);
NET_6LOWPAN_RIMEADDR_SIZE);
ret = OK;
}
else

View File

@ -151,12 +151,7 @@ static int netprocfs_linklayer(FAR struct netprocfs_file_s *netfile)
{
ieee = (FAR struct ieee802154_driver_s *)dev;
#if CONFIG_NET_6LOWPAN_RIMEADDR_SIZE == 2
len += snprintf(&netfile->line[len], NET_LINELEN - len,
"%s\tLink encap:6loWPAN HWaddr %02x:%02x",
dev->d_ifname,
ieee->i_nodeaddr.u8[0], ieee->i_nodeaddr.u8[1]);
#else /* CONFIG_NET_6LOWPAN_RIMEADDR_SIZE == 8 */
#ifdef CONFIG_NET_6LOWPAN_RIMEADDR_EXTENDED
len += snprintf(&netfile->line[len], NET_LINELEN - len,
"%s\tLink encap:6loWPAN HWaddr "
"%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
@ -165,6 +160,11 @@ static int netprocfs_linklayer(FAR struct netprocfs_file_s *netfile)
ieee->i_nodeaddr.u8[2], ieee->i_nodeaddr.u8[3],
ieee->i_nodeaddr.u8[4], ieee->i_nodeaddr.u8[5],
ieee->i_nodeaddr.u8[6], ieee->i_nodeaddr.u8[7]);
#else
len += snprintf(&netfile->line[len], NET_LINELEN - len,
"%s\tLink encap:6loWPAN HWaddr %02x:%02x",
dev->d_ifname,
ieee->i_nodeaddr.u8[0], ieee->i_nodeaddr.u8[1]);
#endif
}
break;
@ -215,22 +215,22 @@ static int netprocfs_linklayer(FAR struct netprocfs_file_s *netfile)
#elif defined(CONFIG_NET_6LOWPAN)
ieee = (FAR struct ieee802154_driver_s *)dev;
#if CONFIG_NET_6LOWPAN_RIMEADDR_SIZE == 2
len += snprintf(&netfile->line[len], NET_LINELEN - len,
"%s\tLink encap:6loWPAN HWaddr %02x:%02x at %s",
dev->d_ifname,
ieee->i_nodeaddr.u8[0], ieee->i_nodeaddr.u8[1],
status);
#else /* CONFIG_NET_6LOWPAN_RIMEADDR_SIZE == 8 */
#ifdef CONFIG_NET_6LOWPAN_RIMEADDR_EXTENDED
len += snprintf(&netfile->line[len], NET_LINELEN - len,
"%s\tLink encap:6loWPAN HWaddr "
"%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x at %s",
"%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x at %s\n",
dev->d_ifname,
ieee->i_nodeaddr.u8[0], ieee->i_nodeaddr.u8[1],
ieee->i_nodeaddr.u8[2], ieee->i_nodeaddr.u8[3],
ieee->i_nodeaddr.u8[4], ieee->i_nodeaddr.u8[5],
ieee->i_nodeaddr.u8[6], ieee->i_nodeaddr.u8[7],
status);
#else
len += snprintf(&netfile->line[len], NET_LINELEN - len,
"%s\tLink encap:6loWPAN HWaddr %02x:%02x at %s\n",
dev->d_ifname,
ieee->i_nodeaddr.u8[0], ieee->i_nodeaddr.u8[1],
status);
#endif
#elif defined(CONFIG_NET_LOOPBACK)
len += snprintf(&netfile->line[len], NET_LINELEN - len,
@ -443,7 +443,7 @@ static int netprocfs_txstatistics_header(FAR struct netprocfs_file_s *netfile)
DEBUGASSERT(netfile != NULL);
return snprintf(netfile->line, NET_LINELEN, "\tTX: %-8s %-8s %-8s %-8s\n",
"Queued", "Sent", "Erorts", "Timeouts");
"Queued", "Sent", "Errors", "Timeouts");
}
#endif /* CONFIG_NETDEV_STATISTICS */

View File

@ -133,12 +133,13 @@ config NET_6LOWPAN_MAXADDRCONTEXT_PREFIX_2_1
endif # NET_6LOWPAN_MAXADDRCONTEXT_PREINIT_0
endif # NET_6LOWPAN_COMPRESSION_HC06
config NET_6LOWPAN_RIMEADDR_SIZE
int "Rime address size"
default 2
range 2 8
config NET_6LOWPAN_RIMEADDR_EXTENDED
int "Extended Rime address"
default n
---help---
Only the values 2 and 8 are supported
By default, a 2-byte Rime address is used for the IEEE802.15.4 MAC
device's link layer address. If this option is selected, then an
8-byte Rime address will be used.
config NET_6LOWPAN_MAXAGE
int "Packet reassembly timeout"

View File

@ -125,11 +125,7 @@ static inline uint8_t sixlowpan_addrlen(uint8_t addrmode)
static bool sixlowpan_addrnull(FAR uint8_t *addr)
{
#if CONFIG_NET_6LOWPAN_RIMEADDR_SIZE == 2
int i = 2;
#else
int i = 8;
#endif
int i = NET_6LOWPAN_RIMEADDR_SIZE;
while (i-- > 0)
{
@ -354,10 +350,10 @@ static void sixlowpan_setup_params(FAR struct ieee802154_driver_s *ieee,
/* Use short address mode if so configured */
#if CONFIG_NET_6LOWPAN_RIMEADDR_SIZE == 2
params->fcf.dest_addr_mode = FRAME802154_SHORTADDRMODE;
#else
#ifdef CONFIG_NET_6LOWPAN_RIMEADDR_EXTENDED
params->fcf.dest_addr_mode = FRAME802154_LONGADDRMODE;
#else
params->fcf.dest_addr_mode = FRAME802154_SHORTADDRMODE;
#endif
}
@ -543,14 +539,14 @@ int sixlowpan_framecreate(FAR struct ieee802154_driver_s *ieee,
wlinfo("Frame type: %02x hdrlen: %d\n",
params.fcf.frame_type, hdrlen);
#if CONFIG_NET_6LOWPAN_RIMEADDR_SIZE == 2
wlinfo("Dest address: %02x:%02x\n",
params.dest_addr[0], params.dest_addr[1]);
#else
#ifdef CONFIG_NET_6LOWPAN_RIMEADDR_EXTENDED
wlinfo("Dest address: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
params.dest_addr[0], params.dest_addr[1], params.dest_addr[2],
params.dest_addr[3], params.dest_addr[4], params.dest_addr[5],
params.dest_addr[6], params.dest_addr[7]);
#else
wlinfo("Dest address: %02x:%02x\n",
params.dest_addr[0], params.dest_addr[1]);
#endif
return hdrlen;

View File

@ -74,13 +74,13 @@
/* Rime addres macros */
/* Copy a Rime address */
#define rimeaddr_copy(dest,src) \
memcpy(dest, src, CONFIG_NET_6LOWPAN_RIMEADDR_SIZE)
#define rimeaddr_copy(dest,src) \
memcpy(dest, src, NET_6LOWPAN_RIMEADDR_SIZE)
/* Compare two Rime addresses */
#define rimeaddr_cmp(addr1,addr2) \
(memcmp(addr1, addr2, CONFIG_NET_6LOWPAN_RIMEADDR_SIZE) == 0)
(memcmp(addr1, addr2, NET_6LOWPAN_RIMEADDR_SIZE) == 0)
/* Pointers in the Rime buffer */

View File

@ -88,14 +88,14 @@ void sixlowpan_ipfromrime(FAR const struct rimeaddr_s *rime,
memset(ipaddr, 0, sizeof(net_ipv6addr_t));
ipaddr[0] = HTONS(0xfe80);
#if CONFIG_NET_6LOWPAN_RIMEADDR_SIZE == 2
#ifdef CONFIG_NET_6LOWPAN_RIMEADDR_EXTENDED
memcpy(&ipaddr[4], rime, NET_6LOWPAN_RIMEADDR_SIZE);
ipaddr[4] ^= HTONS(0x0200);
#else
ipaddr[5] = HTONS(0x00ff);
ipaddr[6] = HTONS(0xfe00);
memcpy(&ipaddr[7], rime, CONFIG_NET_6LOWPAN_RIMEADDR_SIZE);
memcpy(&ipaddr[7], rime, NET_6LOWPAN_RIMEADDR_SIZE);
ipaddr[7] ^= HTONS(0x0200);
#else
memcpy(&ipaddr[4], rime, CONFIG_NET_6LOWPAN_RIMEADDR_SIZE);
ipaddr[4] ^= HTONS(0x0200);
#endif
}
@ -119,10 +119,10 @@ void sixlowpan_rimefromip(const net_ipv6addr_t ipaddr,
DEBUGASSERT(ipaddr[0] == HTONS(0xfe80));
#if CONFIG_NET_6LOWPAN_RIMEADDR_SIZE == 2
memcpy(rime, &ipaddr[7], CONFIG_NET_6LOWPAN_RIMEADDR_SIZE);
#ifdef CONFIG_NET_6LOWPAN_RIMEADDR_EXTENDED
memcpy(rime, &ipaddr[4], NET_6LOWPAN_RIMEADDR_SIZE);
#else
memcpy(rime, &ipaddr[4], CONFIG_NET_6LOWPAN_RIMEADDR_SIZE);
memcpy(rime, &ipaddr[7], NET_6LOWPAN_RIMEADDR_SIZE);
#endif
rime->u8[0] ^= 0x02;
}
@ -145,14 +145,14 @@ bool sixlowpan_ismacbased(const net_ipv6addr_t ipaddr,
{
FAR const uint8_t *rimeptr = rime->u8;
#if CONFIG_NET_6LOWPAN_RIMEADDR_SIZE == 2
return (ipaddr[5] == HTONS(0x00ff) && ipaddr[6] == HTONS(0xfe00) &&
ipaddr[7] == htons((GETINT16(rimeptr, 0) ^ 0x0200)));
#else /* CONFIG_NET_6LOWPAN_RIMEADDR_SIZE == 8 */
#ifdef CONFIG_NET_6LOWPAN_RIMEADDR_EXTENDED
return (ipaddr[4] == htons((GETINT16(rimeptr, 0) ^ 0x0200)) &&
ipaddr[5] == GETINT16(rimeptr, 2) &&
ipaddr[6] == GETINT16(rimeptr, 4) &&
ipaddr[7] == GETINT16(rimeptr, 6));
#else
return (ipaddr[5] == HTONS(0x00ff) && ipaddr[6] == HTONS(0xfe00) &&
ipaddr[7] == htons((GETINT16(rimeptr, 0) ^ 0x0200)));
#endif
}

View File

@ -195,57 +195,68 @@ static int lo_txpoll(FAR struct net_driver_s *dev)
while (head != NULL)
{
/* Remove the IOB from the queue */
/* Increment statistics */
iob = head;
head = iob->io_flink;
iob->io_flink = NULL;
NETDEV_RXPACKETS(&priv->lo_ieee.i_dev);
/* Is the queue now empty? */
/* Remove the IOB from the queue */
if (head == NULL)
{
tail = NULL;
}
iob = head;
head = iob->io_flink;
iob->io_flink = NULL;
/* Return the next frame to the network */
/* Is the queue now empty? */
iob->io_flink = NULL;
priv->lo_ieee.i_framelist = iob;
if (head == NULL)
{
tail = NULL;
}
ninfo("Send frame %p to the network. Length=%u\n", iob, iob->io_len);
ret = sixlowpan_input(&priv->lo_ieee);
if (ret < 0)
{
nerr("ERROR: sixlowpan_input returned %d\n", ret);
}
/* Return the next frame to the network */
/* What if the network responds with more frames to send? */
iob->io_flink = NULL;
priv->lo_ieee.i_framelist = iob;
if (priv->lo_ieee.i_framelist != NULL)
{
/* Append the new list to the tail of the queue */
ninfo("Send frame %p to the network. Length=%u\n", iob, iob->io_len);
ret = sixlowpan_input(&priv->lo_ieee);
iob = priv->lo_ieee.i_framelist;
priv->lo_ieee.i_framelist = NULL;
/* Increment statistics */
if (tail == NULL)
{
head = iob;
}
else
{
tail->io_flink = iob;
}
NETDEV_TXPACKETS(&priv->lo_ieee.i_dev);
/* Find the new tail of the IOB queue */
if (ret < 0)
{
nerr("ERROR: sixlowpan_input returned %d\n", ret);
NETDEV_TXERRORS(&priv->lo_ieee.i_dev);
NETDEV_ERRORS(&priv->lo_ieee.i_dev);
}
for (tail = iob, iob = iob->io_flink;
iob != NULL;
tail = iob, iob = iob->io_flink);
}
/* What if the network responds with more frames to send? */
priv->lo_txdone = true;
if (priv->lo_ieee.i_framelist != NULL)
{
/* Append the new list to the tail of the queue */
iob = priv->lo_ieee.i_framelist;
priv->lo_ieee.i_framelist = NULL;
if (tail == NULL)
{
head = iob;
}
else
{
tail->io_flink = iob;
}
/* Find the new tail of the IOB queue */
for (tail = iob, iob = iob->io_flink;
iob != NULL;
tail = iob, iob = iob->io_flink);
}
priv->lo_txdone = true;
}
return 0;
@ -352,17 +363,17 @@ static int lo_ifup(FAR struct net_driver_s *dev)
dev->d_ipv6addr[3], dev->d_ipv6addr[4], dev->d_ipv6addr[5],
dev->d_ipv6addr[6], dev->d_ipv6addr[7]);
#if CONFIG_NET_6LOWPAN_RIMEADDR_SIZE == 2
ninfo(" Node: %02x:%02x PANID=%04x\n",
priv->lo_ieee.i_nodeaddr.u8[0], priv->lo_ieee.i_nodeaddr.u8[1],
priv->lo_ieee.i_panid);
#else /* CONFIG_NET_6LOWPAN_RIMEADDR_SIZE == 8 */
#ifdef CONFIG_NET_6LOWPAN_RIMEADDR_EXTENDED
ninfo(" Node: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x PANID=%04x\n",
priv->lo_ieee.i_nodeaddr.u8[0], priv->lo_ieee.i_nodeaddr.u8[1],
priv->lo_ieee.i_nodeaddr.u8[2], priv->lo_ieee.i_nodeaddr.u8[3],
priv->lo_ieee.i_nodeaddr.u8[4], priv->lo_ieee.i_nodeaddr.u8[5],
priv->lo_ieee.i_nodeaddr.u8[6], priv->lo_ieee.i_nodeaddr.u8[7],
priv->lo_ieee.i_panid);
#else
ninfo(" Node: %02x:%02x PANID=%04x\n",
priv->lo_ieee.i_nodeaddr.u8[0], priv->lo_ieee.i_nodeaddr.u8[1],
priv->lo_ieee.i_panid);
#endif
/* Set and activate a timer process */
@ -508,12 +519,12 @@ static int lo_txavail(FAR struct net_driver_s *dev)
#if defined(CONFIG_NET_IGMP) || defined(CONFIG_NET_ICMPv6)
static int lo_addmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac)
{
#if CONFIG_NET_6LOWPAN_RIMEADDR_SIZE == 2
ninfo("MAC: %02x:%02x\n",
mac[0], mac[1]);
#else /* CONFIG_NET_6LOWPAN_RIMEADDR_SIZE == 8 */
#ifdef CONFIG_NET_6LOWPAN_RIMEADDR_EXTENDED
ninfo("MAC: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], mac[6], mac[7]);
#else
ninfo("MAC: %02x:%02x\n",
mac[0], mac[1]);
#endif
/* There is no multicast support in the loopback driver */
@ -543,12 +554,12 @@ static int lo_addmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac)
#ifdef CONFIG_NET_IGMP
static int lo_rmmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac)
{
#if CONFIG_NET_6LOWPAN_RIMEADDR_SIZE == 2
ninfo("MAC: %02x:%02x\n",
mac[0], mac[1]);
#else /* CONFIG_NET_6LOWPAN_RIMEADDR_SIZE == 8 */
#ifdef CONFIG_NET_6LOWPAN_RIMEADDR_EXTENDED
ninfo("MAC: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], mac[6], mac[7]);
#else
ninfo("MAC: %02x:%02x\n",
mac[0], mac[1]);
#endif
/* There is no multicast support in the loopback driver */