mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 23:40:19 +08:00
Bring closer to NuttX coding standard.
This commit is contained in:
+99
-133
@@ -44,6 +44,10 @@
|
|||||||
|
|
||||||
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
|
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
/* Frame Type */
|
/* Frame Type */
|
||||||
|
|
||||||
#define IEEE802154_FRAME_BEACON 0x00
|
#define IEEE802154_FRAME_BEACON 0x00
|
||||||
@@ -63,7 +67,10 @@
|
|||||||
#define IEEE802154_CMD_COORD_REALIGN 0x08
|
#define IEEE802154_CMD_COORD_REALIGN 0x08
|
||||||
#define IEEE802154_CMD_GTS_REQ 0x09
|
#define IEEE802154_CMD_GTS_REQ 0x09
|
||||||
|
|
||||||
/* private types */
|
/****************************************************************************
|
||||||
|
* Private Types
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
/* The privmac structure is an extension of the public ieee802154_mac_s type.
|
/* The privmac structure is an extension of the public ieee802154_mac_s type.
|
||||||
* It contains storage for the IEEE802.15.4 MIB attributes.
|
* It contains storage for the IEEE802.15.4 MIB attributes.
|
||||||
*/
|
*/
|
||||||
@@ -111,76 +118,47 @@ struct ieee802154_privmac_s
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/* forward declarations */
|
/****************************************************************************
|
||||||
|
* Private Function Prototypes
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
static int mac802154_reqdata (struct ieee802154_mac_s *mac,
|
static int mac802154_reqdata(FAR struct ieee802154_mac_s *mac,
|
||||||
uint8_t handle,
|
uint8_t handle, FAR uint8_t *buf, int len);
|
||||||
uint8_t *buf,
|
static int mac802154_reqpurge(FAR struct ieee802154_mac_s *mac,
|
||||||
int len);
|
uint8_t handle);
|
||||||
|
static int mac802154_reqassociate(FAR struct ieee802154_mac_s *mac,
|
||||||
static int mac802154_reqpurge (struct ieee802154_mac_s *mac,
|
uint16_t panid, FAR uint8_t *coordeadr);
|
||||||
uint8_t handle);
|
static int mac802154_reqdisassociate(FAR struct ieee802154_mac_s *mac,
|
||||||
|
FAR uint8_t *eadr, uint8_t reason);
|
||||||
static int mac802154_reqassociate (struct ieee802154_mac_s *mac,
|
static int mac802154_reqget(FAR struct ieee802154_mac_s *mac,
|
||||||
uint16_t panid,
|
int attribute);
|
||||||
uint8_t *coordeadr);
|
static int mac802154_reqgts(FAR struct ieee802154_mac_s *mac,
|
||||||
|
FAR uint8_t *characteristics);
|
||||||
static int mac802154_reqdisassociate(struct ieee802154_mac_s *mac,
|
static int mac802154_reqreset(FAR struct ieee802154_mac_s *mac,
|
||||||
uint8_t *eadr,
|
bool setdefaults);
|
||||||
uint8_t reason);
|
static int mac802154_reqrxenable(FAR struct ieee802154_mac_s *mac,
|
||||||
|
bool deferrable, int ontime, int duration);
|
||||||
static int mac802154_reqget (struct ieee802154_mac_s *mac,
|
static int mac802154_reqscan(FAR struct ieee802154_mac_s *mac,
|
||||||
int attribute);
|
uint8_t type, uint32_t channels, int duration);
|
||||||
|
static int mac802154_reqset(FAR struct ieee802154_mac_s *mac,
|
||||||
static int mac802154_reqgts (struct ieee802154_mac_s *mac,
|
int attribute, FAR uint8_t *value, int valuelen);
|
||||||
uint8_t* characteristics);
|
static int mac802154_reqstart(FAR struct ieee802154_mac_s *mac,
|
||||||
|
uint16_t panid, int channel, uint8_t bo, uint8_t fo,
|
||||||
static int mac802154_reqreset (struct ieee802154_mac_s *mac,
|
bool coord, bool batext, bool realign);
|
||||||
bool setdefaults);
|
static int mac802154_reqsync(FAR struct ieee802154_mac_s *mac,
|
||||||
|
int channel, bool track);
|
||||||
static int mac802154_reqrxenable (struct ieee802154_mac_s *mac,
|
static int mac802154_reqpoll(FAR struct ieee802154_mac_s *mac,
|
||||||
bool deferrable,
|
FAR uint8_t *coordaddr);
|
||||||
int ontime,
|
static int mac802154_rspassociate(FAR struct ieee802154_mac_s *mac,
|
||||||
int duration);
|
uint8_t eadr, uint16_t saddr, int status);
|
||||||
|
static int mac802154_rsporphan(FAR struct ieee802154_mac_s *mac,
|
||||||
static int mac802154_reqscan (struct ieee802154_mac_s *mac,
|
FAR uint8_t *orphanaddr, uint16_t saddr, bool associated);
|
||||||
uint8_t type,
|
|
||||||
uint32_t channels,
|
|
||||||
int duration);
|
|
||||||
|
|
||||||
static int mac802154_reqset (struct ieee802154_mac_s *mac,
|
|
||||||
int attribute,
|
|
||||||
uint8_t *value,
|
|
||||||
int valuelen);
|
|
||||||
|
|
||||||
static int mac802154_reqstart (struct ieee802154_mac_s *mac,
|
|
||||||
uint16_t panid,
|
|
||||||
int channel,
|
|
||||||
uint8_t bo,
|
|
||||||
uint8_t fo,
|
|
||||||
bool coord,
|
|
||||||
bool batext,
|
|
||||||
bool realign);
|
|
||||||
|
|
||||||
static int mac802154_reqsync (struct ieee802154_mac_s *mac,
|
|
||||||
int channel,
|
|
||||||
bool track);
|
|
||||||
|
|
||||||
static int mac802154_reqpoll (struct ieee802154_mac_s *mac,
|
|
||||||
uint8_t *coordaddr);
|
|
||||||
|
|
||||||
static int mac802154_rspassociate (struct ieee802154_mac_s *mac,
|
|
||||||
uint8_t eadr,
|
|
||||||
uint16_t saddr,
|
|
||||||
int status);
|
|
||||||
|
|
||||||
static int mac802154_rsporphan (struct ieee802154_mac_s *mac,
|
|
||||||
uint8_t *orphanaddr,
|
|
||||||
uint16_t saddr,
|
|
||||||
bool associated);
|
|
||||||
|
|
||||||
|
|
||||||
/* data */
|
/****************************************************************************
|
||||||
|
* Private Data
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
static const struct ieee802154_macops_s mac802154ops =
|
static const struct ieee802154_macops_s mac802154ops =
|
||||||
{
|
{
|
||||||
.req_data = mac802154_reqdata
|
.req_data = mac802154_reqdata
|
||||||
@@ -221,30 +199,31 @@ static int mac802154_defaultmib(FAR struct ieee802154_privmac_s *priv)
|
|||||||
priv->macBattLifeExtPeriods = 0;
|
priv->macBattLifeExtPeriods = 0;
|
||||||
priv->macMaxCSMABackoffs = 4;
|
priv->macMaxCSMABackoffs = 4;
|
||||||
|
|
||||||
priv->macBeaconOrder = 15;
|
priv->macBeaconOrder = 15;
|
||||||
priv->macSuperframeOrder = 15;
|
priv->macSuperframeOrder = 15;
|
||||||
|
|
||||||
priv->macMinBE = 3;
|
priv->macMinBE = 3;
|
||||||
priv->macGTSPermit = 1;
|
priv->macGTSPermit = 1;
|
||||||
priv->macPromiscuousMode = 0;
|
priv->macPromiscuousMode = 0;
|
||||||
priv->macRxOnWhenIdle = 0;
|
priv->macRxOnWhenIdle = 0;
|
||||||
priv->macBeaconTxTime = 0x000000;
|
priv->macBeaconTxTime = 0x000000;
|
||||||
|
|
||||||
priv->macBeaconPayloadLength = 0;
|
priv->macBeaconPayloadLength = 0;
|
||||||
priv->macBSN = 0; /*shall be random*/
|
priv->macBSN = 0; /* Shall be random */
|
||||||
priv->macCoordExtendedAddress[8];
|
priv->macCoordExtendedAddress[8];
|
||||||
priv->macCoordShortAddress = 0xffff;
|
priv->macCoordShortAddress = 0xffff;
|
||||||
priv->macDSN = 0 /*shall be random*/;
|
priv->macDSN = 0; /* Shall be random */
|
||||||
priv->macPANId = 0xffff;
|
priv->macPANId = 0xffff;
|
||||||
priv->macShortAddress = 0xffff;
|
priv->macShortAddress = 0xffff;
|
||||||
priv->macTransactionPersistenceTime = 0x01f4;
|
priv->macTransactionPersistenceTime = 0x01f4;
|
||||||
#if 0
|
#if 0
|
||||||
/* Security MIB */
|
/* Security MIB */
|
||||||
priv->macACLEntryDescriptorSetSize = 0;
|
|
||||||
priv->macDefaultSecurity = 0;
|
priv->macACLEntryDescriptorSetSize = 0;
|
||||||
priv->macDefaultSecuritySuite = 0;
|
priv->macDefaultSecurity = 0;
|
||||||
|
priv->macDefaultSecuritySuite = 0;
|
||||||
priv->macDefaultSecurityMaterialLength = 0x15;
|
priv->macDefaultSecurityMaterialLength = 0x15;
|
||||||
priv->macSecurityMode = 0;
|
priv->macSecurityMode = 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,11 +258,9 @@ static int mac802154_applymib(FAR struct ieee802154_privmac_s *priv)
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int mac802154_reqdata(FAR struct ieee802154_mac_s *mac,
|
static int mac802154_reqdata(FAR struct ieee802154_mac_s *mac,
|
||||||
uint8_t handle,
|
uint8_t handle, FAR uint8_t *buf, int len)
|
||||||
uint8_t *buf,
|
|
||||||
int len)
|
|
||||||
{
|
{
|
||||||
FAR struct ieee802154_privmac_s * priv = (FAR struct ieee802154_privmac_s *) mac;
|
FAR struct ieee802154_privmac_s *priv = (FAR struct ieee802154_privmac_s *)mac;
|
||||||
return -ENOTTY;
|
return -ENOTTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -298,9 +275,9 @@ static int mac802154_reqdata(FAR struct ieee802154_mac_s *mac,
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int mac802154_reqpurge(FAR struct ieee802154_mac_s *mac,
|
static int mac802154_reqpurge(FAR struct ieee802154_mac_s *mac,
|
||||||
uint8_t handle)
|
uint8_t handle)
|
||||||
{
|
{
|
||||||
FAR struct ieee802154_privmac_s * priv = (FAR struct ieee802154_privmac_s *) mac;
|
FAR struct ieee802154_privmac_s *priv = (FAR struct ieee802154_privmac_s *)mac;
|
||||||
return -ENOTTY;
|
return -ENOTTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -318,7 +295,7 @@ static int mac802154_reqassociate(FAR struct ieee802154_mac_s *mac,
|
|||||||
uint16_t panid,
|
uint16_t panid,
|
||||||
uint8_t *coordeadr)
|
uint8_t *coordeadr)
|
||||||
{
|
{
|
||||||
FAR struct ieee802154_privmac_s * priv = (FAR struct ieee802154_privmac_s *) mac;
|
FAR struct ieee802154_privmac_s * priv = (FAR struct ieee802154_privmac_s *)mac;
|
||||||
return -ENOTTY;
|
return -ENOTTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -335,10 +312,9 @@ static int mac802154_reqassociate(FAR struct ieee802154_mac_s *mac,
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int mac802154_reqdisassociate(FAR struct ieee802154_mac_s *mac,
|
static int mac802154_reqdisassociate(FAR struct ieee802154_mac_s *mac,
|
||||||
uint8_t *eadr,
|
FAR uint8_t *eadr, uint8_t reason)
|
||||||
uint8_t reason)
|
|
||||||
{
|
{
|
||||||
FAR struct ieee802154_privmac_s * priv = (FAR struct ieee802154_privmac_s *) mac;
|
FAR struct ieee802154_privmac_s *priv = (FAR struct ieee802154_privmac_s *)mac;
|
||||||
return -ENOTTY;
|
return -ENOTTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -355,7 +331,7 @@ static int mac802154_reqdisassociate(FAR struct ieee802154_mac_s *mac,
|
|||||||
static int mac802154_reqget(FAR struct ieee802154_mac_s *mac,
|
static int mac802154_reqget(FAR struct ieee802154_mac_s *mac,
|
||||||
int attribute)
|
int attribute)
|
||||||
{
|
{
|
||||||
FAR struct ieee802154_privmac_s * priv = (FAR struct ieee802154_privmac_s *) mac;
|
FAR struct ieee802154_privmac_s *priv = (FAR struct ieee802154_privmac_s *)mac;
|
||||||
return -ENOTTY;
|
return -ENOTTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -371,9 +347,9 @@ static int mac802154_reqget(FAR struct ieee802154_mac_s *mac,
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int mac802154_reqgts(FAR struct ieee802154_mac_s *mac,
|
static int mac802154_reqgts(FAR struct ieee802154_mac_s *mac,
|
||||||
uint8_t* characteristics)
|
FAR uint8_t *characteristics)
|
||||||
{
|
{
|
||||||
FAR struct ieee802154_privmac_s * priv = (FAR struct ieee802154_privmac_s *) mac;
|
FAR struct ieee802154_privmac_s *priv = (FAR struct ieee802154_privmac_s *)mac;
|
||||||
return -ENOTTY;
|
return -ENOTTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -406,11 +382,9 @@ static int mac802154_reqreset(FAR struct ieee802154_mac_s *mac,
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int mac802154_reqrxenable(FAR struct ieee802154_mac_s *mac,
|
static int mac802154_reqrxenable(FAR struct ieee802154_mac_s *mac,
|
||||||
bool deferrable,
|
bool deferrable, int ontime, int duration)
|
||||||
int ontime,
|
|
||||||
int duration)
|
|
||||||
{
|
{
|
||||||
FAR struct ieee802154_privmac_s * priv = (FAR struct ieee802154_privmac_s *) mac;
|
FAR struct ieee802154_privmac_s * priv = (FAR struct ieee802154_privmac_s *)mac;
|
||||||
return -ENOTTY;
|
return -ENOTTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -430,11 +404,9 @@ static int mac802154_reqrxenable(FAR struct ieee802154_mac_s *mac,
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int mac802154_reqscan(FAR struct ieee802154_mac_s *mac,
|
static int mac802154_reqscan(FAR struct ieee802154_mac_s *mac,
|
||||||
uint8_t type,
|
uint8_t type, uint32_t channels, int duration)
|
||||||
uint32_t channels,
|
|
||||||
int duration)
|
|
||||||
{
|
{
|
||||||
FAR struct ieee802154_privmac_s * priv = (FAR struct ieee802154_privmac_s *) mac;
|
FAR struct ieee802154_privmac_s *priv = (FAR struct ieee802154_privmac_s *)mac;
|
||||||
return -ENOTTY;
|
return -ENOTTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -449,11 +421,9 @@ static int mac802154_reqscan(FAR struct ieee802154_mac_s *mac,
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int mac802154_reqset(FAR struct ieee802154_mac_s *mac,
|
static int mac802154_reqset(FAR struct ieee802154_mac_s *mac,
|
||||||
int attribute,
|
int attribute, FAR uint8_t *value, int valuelen)
|
||||||
uint8_t *value,
|
|
||||||
int valuelen)
|
|
||||||
{
|
{
|
||||||
FAR struct ieee802154_privmac_s * priv = (FAR struct ieee802154_privmac_s *) mac;
|
FAR struct ieee802154_privmac_s *priv = (FAR struct ieee802154_privmac_s *)mac;
|
||||||
return -ENOTTY;
|
return -ENOTTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -468,15 +438,11 @@ static int mac802154_reqset(FAR struct ieee802154_mac_s *mac,
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int mac802154_reqstart(FAR struct ieee802154_mac_s *mac,
|
static int mac802154_reqstart(FAR struct ieee802154_mac_s *mac,
|
||||||
uint16_t panid,
|
uint16_t panid, int channel, uint8_t bo,
|
||||||
int channel,
|
uint8_t fo, bool coord, bool batext,
|
||||||
uint8_t bo,
|
|
||||||
uint8_t fo,
|
|
||||||
bool coord,
|
|
||||||
bool batext,
|
|
||||||
bool realign)
|
bool realign)
|
||||||
{
|
{
|
||||||
FAR struct ieee802154_privmac_s * priv = (FAR struct ieee802154_privmac_s *) mac;
|
FAR struct ieee802154_privmac_s *priv = (FAR struct ieee802154_privmac_s *)mac;
|
||||||
return -ENOTTY;
|
return -ENOTTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -492,10 +458,9 @@ static int mac802154_reqstart(FAR struct ieee802154_mac_s *mac,
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int mac802154_reqsync(FAR struct ieee802154_mac_s *mac,
|
static int mac802154_reqsync(FAR struct ieee802154_mac_s *mac,
|
||||||
int channel,
|
int channel, bool track)
|
||||||
bool track)
|
|
||||||
{
|
{
|
||||||
FAR struct ieee802154_privmac_s * priv = (FAR struct ieee802154_privmac_s *) mac;
|
FAR struct ieee802154_privmac_s *priv = (FAR struct ieee802154_privmac_s *)mac;
|
||||||
return -ENOTTY;
|
return -ENOTTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -511,9 +476,9 @@ static int mac802154_reqsync(FAR struct ieee802154_mac_s *mac,
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int mac802154_reqpoll(FAR struct ieee802154_mac_s *mac,
|
static int mac802154_reqpoll(FAR struct ieee802154_mac_s *mac,
|
||||||
uint8_t *coordaddr)
|
FAR uint8_t *coordaddr)
|
||||||
{
|
{
|
||||||
FAR struct ieee802154_privmac_s * priv = (FAR struct ieee802154_privmac_s *) mac;
|
FAR struct ieee802154_privmac_s *priv = (FAR struct ieee802154_privmac_s *)mac;
|
||||||
return -ENOTTY;
|
return -ENOTTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -527,11 +492,9 @@ static int mac802154_reqpoll(FAR struct ieee802154_mac_s *mac,
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int mac802154_rspassociate(FAR struct ieee802154_mac_s *mac,
|
static int mac802154_rspassociate(FAR struct ieee802154_mac_s *mac,
|
||||||
uint8_t eadr,
|
uint8_t eadr, uint16_t saddr, int status)
|
||||||
uint16_t saddr,
|
|
||||||
int status)
|
|
||||||
{
|
{
|
||||||
FAR struct ieee802154_privmac_s * priv = (FAR struct ieee802154_privmac_s *) mac;
|
FAR struct ieee802154_privmac_s *priv = (FAR struct ieee802154_privmac_s *)mac;
|
||||||
return -ENOTTY;
|
return -ENOTTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -545,11 +508,10 @@ static int mac802154_rspassociate(FAR struct ieee802154_mac_s *mac,
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int mac802154_rsporphan(FAR struct ieee802154_mac_s *mac,
|
static int mac802154_rsporphan(FAR struct ieee802154_mac_s *mac,
|
||||||
uint8_t *orphanaddr,
|
FAR uint8_t *orphanaddr, uint16_t saddr,
|
||||||
uint16_t saddr,
|
|
||||||
bool associated)
|
bool associated)
|
||||||
{
|
{
|
||||||
FAR struct ieee802154_privmac_s * priv = (FAR struct ieee802154_privmac_s *) mac;
|
FAR struct ieee802154_privmac_s *priv = (FAR struct ieee802154_privmac_s *)mac;
|
||||||
return -ENOTTY;
|
return -ENOTTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -565,22 +527,26 @@ static int mac802154_rsporphan(FAR struct ieee802154_mac_s *mac,
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
FAR struct ieee802154_mac_s * mac802154_register(FAR struct ieee802154_radio_s *radiodev, unsigned int minor)
|
FAR struct ieee802154_mac_s *
|
||||||
|
mac802154_register(FAR struct ieee802154_radio_s *radiodev,
|
||||||
|
unsigned int minor)
|
||||||
{
|
{
|
||||||
FAR struct ieee802154_privmac_s *mac;
|
FAR struct ieee802154_privmac_s *mac;
|
||||||
|
|
||||||
/* allocate object */
|
/* Allocate object */
|
||||||
mac = (FAR struct ieee802154_privmac_s *)kmm_zalloc(sizeof(struct ieee802154_privmac_s));
|
|
||||||
|
mac = (FAR struct ieee802154_privmac_s *)
|
||||||
|
kmm_zalloc(sizeof(struct ieee802154_privmac_s));
|
||||||
if(!mac)
|
if(!mac)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* init fields */
|
/* Initialize fields */
|
||||||
|
|
||||||
mac->pubmac.radio = radiodev;
|
mac->pubmac.radio = radiodev;
|
||||||
mac->pubmac.ops = mac802154ops;
|
mac->pubmac.ops = mac802154ops;
|
||||||
mac802154_defaultmib(mac);
|
mac802154_defaultmib(mac);
|
||||||
mac802154_applymib(mac);
|
mac802154_applymib(mac);
|
||||||
return &mac->pubmac;
|
return &mac->pubmac;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user