From 334d1734dc44da52ea6346302bbad93627bbae3d Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 10 Sep 2017 10:13:33 -0600 Subject: [PATCH] 6LoWPAN/Radio: Rename radio property sp_pktlen to sp_framelen. Add 6LoWPAN utility to get the max frame length (not yet hooked in) --- .../wireless/spirit/drivers/spirit_netdev.c | 4 +-- include/nuttx/net/radiodev.h | 2 +- net/sixlowpan/sixlowpan_hc06.c | 2 +- net/sixlowpan/sixlowpan_internal.h | 17 ++++++++++ net/sixlowpan/sixlowpan_utils.c | 34 +++++++++++++++++++ wireless/ieee802154/mac802154_loopback.c | 4 +-- wireless/ieee802154/mac802154_netdev.c | 4 +-- wireless/pktradio/pktradio_loopback.c | 4 +-- 8 files changed, 61 insertions(+), 10 deletions(-) diff --git a/drivers/wireless/spirit/drivers/spirit_netdev.c b/drivers/wireless/spirit/drivers/spirit_netdev.c index bd2abf9f1a..d9c43bd6af 100644 --- a/drivers/wireless/spirit/drivers/spirit_netdev.c +++ b/drivers/wireless/spirit/drivers/spirit_netdev.c @@ -2403,8 +2403,8 @@ static int spirit_properties(FAR struct radio_driver_s *netdev, /* General */ - properties->sp_addrlen = 1; /* Length of an address */ - properties->sp_pktlen = CONFIG_SPIRIT_PKTLEN; /* Fixed packet length */ + properties->sp_addrlen = 1; /* Length of an address */ + properties->sp_framelen = CONFIG_SPIRIT_PKTLEN; /* Fixed packet length */ /* Multicast address */ diff --git a/include/nuttx/net/radiodev.h b/include/nuttx/net/radiodev.h index 71c43c1adf..91cebd35b6 100644 --- a/include/nuttx/net/radiodev.h +++ b/include/nuttx/net/radiodev.h @@ -59,7 +59,7 @@ struct radiodev_properties_s { uint8_t sp_addrlen; /* Length of an address */ - uint8_t sp_pktlen; /* Fixed packet/frame size (up to 255) */ + uint8_t sp_framelen; /* Fixed packet/frame size (up to 255) */ struct netdev_varaddr_s sp_mcast; /* Multicast address */ struct netdev_varaddr_s sp_bcast; /* Broadcast address */ #ifdef CONFIG_NET_STARPOINT diff --git a/net/sixlowpan/sixlowpan_hc06.c b/net/sixlowpan/sixlowpan_hc06.c index 69a37d7f3c..b084f7e96b 100644 --- a/net/sixlowpan/sixlowpan_hc06.c +++ b/net/sixlowpan/sixlowpan_hc06.c @@ -50,7 +50,7 @@ * -Add compression options to UDP, currently only supports * both ports compressed or both ports elided * -Verify TC/FL compression works - * -Add stateless multicast option + * -Add multicast support for M=1 and DAC=1 */ /**************************************************************************** diff --git a/net/sixlowpan/sixlowpan_internal.h b/net/sixlowpan/sixlowpan_internal.h index c4fccf84d3..bdd5b894d3 100644 --- a/net/sixlowpan/sixlowpan_internal.h +++ b/net/sixlowpan/sixlowpan_internal.h @@ -606,6 +606,23 @@ void sixlowpan_ipfromaddr(FAR const struct netdev_varaddr_s *addr, bool sixlowpan_ismacbased(const net_ipv6addr_t ipaddr, FAR const struct netdev_varaddr_s *addr); +/**************************************************************************** + * Name: sixlowpan_radio_framelen + * + * Description: + * Get the maximum frame length supported by radio network drvier. + * + * Input parameters: + * radio - Reference to a radio network driver state instance. + * + * Returned Value: + * A non-negative, maximum frame lengthis returned on success; A negated + * errno valueis returned on any failure. + * + ****************************************************************************/ + +int sixlowpan_radio_framelen(FAR struct radio_driver_s *radio); + /**************************************************************************** * Name: sixlowpan_src_panid * diff --git a/net/sixlowpan/sixlowpan_utils.c b/net/sixlowpan/sixlowpan_utils.c index 120db50059..f4c27dc530 100644 --- a/net/sixlowpan/sixlowpan_utils.c +++ b/net/sixlowpan/sixlowpan_utils.c @@ -508,6 +508,40 @@ bool sixlowpan_ismacbased(const net_ipv6addr_t ipaddr, } } +/**************************************************************************** + * Name: sixlowpan_radio_framelen + * + * Description: + * Get the maximum frame length supported by radio network drvier. + * + * Input parameters: + * radio - Reference to a radio network driver state instance. + * + * Returned Value: + * A non-negative, maximum frame lengthis returned on success; A negated + * errno valueis returned on any failure. + * + ****************************************************************************/ + +int sixlowpan_radio_framelen(FAR struct radio_driver_s *radio) +{ + struct radiodev_properties_s properties; + int ret; + + /* Only the radio driver knows the correct max frame length supported by + * the radio. + */ + + DEBUGASSERT(radio->r_properties != NULL); + ret = radio->r_properties(radio, &properties); + if (ret < 0) + { + return ret; + } + + return (int)properties.sp_framelen; +} + /**************************************************************************** * Name: sixlowpan_src_panid * diff --git a/wireless/ieee802154/mac802154_loopback.c b/wireless/ieee802154/mac802154_loopback.c index 92223cd44d..3e08f4a823 100644 --- a/wireless/ieee802154/mac802154_loopback.c +++ b/wireless/ieee802154/mac802154_loopback.c @@ -1005,8 +1005,8 @@ static int lo_properties(FAR struct radio_driver_s *netdev, /* General */ - properties->sp_addrlen = LO_ADDRSIZE; /* Length of an address */ - properties->sp_pktlen = LO_FRAMELEN; /* Fixed frame length */ + properties->sp_addrlen = LO_ADDRSIZE; /* Length of an address */ + properties->sp_framelen = LO_FRAMELEN; /* Fixed frame length */ /* Multicast address (uses broadcast address) * diff --git a/wireless/ieee802154/mac802154_netdev.c b/wireless/ieee802154/mac802154_netdev.c index 5f112ee05e..6a5bc54d58 100644 --- a/wireless/ieee802154/mac802154_netdev.c +++ b/wireless/ieee802154/mac802154_netdev.c @@ -1159,8 +1159,8 @@ static int macnet_properties(FAR struct radio_driver_s *netdev, /* General */ - properties->sp_addrlen = MACNET_ADDRSIZE; /* Length of an address */ - properties->sp_pktlen = MACNET_FRAMELEN; /* Fixed frame length */ + properties->sp_addrlen = MACNET_ADDRSIZE; /* Length of an address */ + properties->sp_framelen = MACNET_FRAMELEN; /* Fixed frame length */ /* Multicast address (uses broadcast address) * diff --git a/wireless/pktradio/pktradio_loopback.c b/wireless/pktradio/pktradio_loopback.c index 8b62a2afb1..ca89e6ef49 100644 --- a/wireless/pktradio/pktradio_loopback.c +++ b/wireless/pktradio/pktradio_loopback.c @@ -961,8 +961,8 @@ static int lo_properties(FAR struct radio_driver_s *netdev, /* General */ - properties->sp_addrlen = CONFIG_PKTRADIO_ADDRLEN; /* Length of an address */ - properties->sp_pktlen = CONFIG_NET_6LOWPAN_FRAMELEN; /* Fixed frame length */ + properties->sp_addrlen = CONFIG_PKTRADIO_ADDRLEN; /* Length of an address */ + properties->sp_framelen = CONFIG_NET_6LOWPAN_FRAMELEN; /* Fixed frame length */ /* Multicast address */