summaryrefslogtreecommitdiff
path: root/digital/zigbit/bitcloud/stack/Components/NWK/include/private
diff options
context:
space:
mode:
Diffstat (limited to 'digital/zigbit/bitcloud/stack/Components/NWK/include/private')
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkAddress.h82
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkAddressConflict.h105
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkAddressMap.h117
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkBTT.h86
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkCommands.h86
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkConcentrator.h83
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkConfig.h137
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkDataReq.h92
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkDbg.h473
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkDirectJoin.h59
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkDiscovery.h73
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkEDScan.h75
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkFormation.h92
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkFrame.h363
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkIB.h178
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkJoinInd.h209
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkJoinReq.h172
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkLeave.h200
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkLinkStatus.h194
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkLoopback.h87
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkManager.h127
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkManyToOne.h69
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkMem.h421
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkNeighborTable.h261
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkOrphan.h109
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkPacket.h154
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkPassiveAck.h174
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkPermitJoining.h86
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkReportCommand.h167
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkReset.h100
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouteCache.h116
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouteDiscovery.h91
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouteDiscoveryTable.h240
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouteRecord.h172
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouteReply.h125
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouteRequest.h149
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouting.h71
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRoutingTable.h162
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRx.h85
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRxSecurity.h54
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkSilentJoin.h94
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkSourceRouting.h119
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkStartRouter.h89
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkStateMachine.h154
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkStatusInd.h86
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkStatusReq.h230
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkSync.h92
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkSyncLoss.h61
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkSystem.h100
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkTaskManager.h98
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkTx.h209
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkTxDelay.h101
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkTxSecurity.h70
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkUpdateCommand.h146
54 files changed, 7545 insertions, 0 deletions
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkAddress.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkAddress.h
new file mode 100644
index 00000000..b3516b86
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkAddress.h
@@ -0,0 +1,82 @@
+/**************************************************************************//**
+ \file nwkAddress.h
+
+ \brief Formation header file.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2009-05-12 M. Gekk - Created.
+ Last change:
+ $Id: nwkAddress.h 17923 2011-07-08 14:13:30Z mgekk $
+ ******************************************************************************/
+#if !defined _NWK_ADDRESS_H
+#define _NWK_ADDRESS_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <types.h>
+#include <mac.h>
+#include <nwkCommon.h>
+#include <nwkSystem.h>
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined _COORDINATOR_ || defined _ROUTER_
+/**************************************************************************//**
+ \brief Allocate short address.
+
+ \param[in] router - parameters is used if tree addressing is active.
+ \param[in] addrRequested - if rejoin is used, it is address device selects for
+ itself otherwise NWK_NO_SHORT_ADDR.
+ \param[in] extAddr - IEEE extended address of node.
+ \return Allocated address. addrRequested - is possible,
+ or address allocated in little endian.
+ ******************************************************************************/
+NWK_PRIVATE ShortAddr_t nwkAllocateShortAddr(const bool router,
+ const ShortAddr_t addrRequested, const ExtAddr_t extAddr);
+#endif /* _COORDINATOR_ or _ROUTER_ */
+
+#if defined _NWK_DISTRIBUTED_ADDRESSING_
+/**************************************************************************//**
+ \brief Computing the size of the address sub-block.
+
+ \param[in] depth - current depth of node in network tree topology.
+ \return cskip block in big endian format.
+ ******************************************************************************/
+NWK_PRIVATE NwkAddrRange_t nwkCSkip(const NwkDepth_t depth);
+#endif /* _NWK_DISTRIBUTED_ADDRESSING_ */
+
+/**************************************************************************//**
+ \brief Allocate non-conflict short address
+
+ \param[in] shortAddr - initial value of short address.
+ \param[in] extAddr - pointer to IEEE extended address of node for which is
+ allocated a short address.
+ \return Valid short address in little endian format.
+ ******************************************************************************/
+NWK_PRIVATE ShortAddr_t nwkAllocNonConflAddr(ShortAddr_t shortAddr,
+ const ExtAddr_t *const extAddr);
+
+/**************************************************************************//**
+ \brief Is received broadcast packet for this device or not?
+
+ \param[in] dstAddr - destination broadcast address.
+
+ \return 'true' if broadcast packet can be handled by this device
+ otherwise return 'false'.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkBroadcastForMe(const ShortAddr_t dstAddr);
+
+#endif /* _NWK_ADDRESS_H */
+/** eof nwkAddress.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkAddressConflict.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkAddressConflict.h
new file mode 100644
index 00000000..7b349907
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkAddressConflict.h
@@ -0,0 +1,105 @@
+/**************************************************************************//**
+ \file nwkAddressConflict.h
+
+ \brief Interface of address conflict resolver.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2009-06-23 Max Gekk - Created.
+ 2010-07-04 Max Gekk - Redesign.
+ Last change:
+ $Id: nwkAddressConflict.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_ADDRESS_CONFLICT_H
+#define _NWK_ADDRESS_CONFLICT_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <types.h>
+#include <queue.h>
+#include <mac.h>
+#include <nwkCommon.h>
+#include <nlmeJoin.h>
+#include <nwkStatusReq.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Internal states of the address conflict component. */
+typedef enum _NwkAddrConflictState_t
+{
+ NWK_ADDR_CONFLICT_IDLE_STATE = 0xAA,
+ NWK_ADDR_CONFLICT_FIRST_STATE = 0x43,
+ NWK_ADDR_CONFLICT_BEGIN_STATE = NWK_ADDR_CONFLICT_FIRST_STATE,
+ NWK_ADDR_CONFLICT_MAC_SET_STATE = 0x44,
+ NWK_ADDR_CONFLICT_REJOIN_STATE = 0x45,
+ NWK_ADDR_CONFLICT_SEND_STATUS_STATE = 0x46,
+ NWK_ADDR_CONFLICT_LAST_STATE
+} NwkAddrConflictState_t;
+
+/** Internal variables of the network manager component. */
+typedef struct _NwkAddrConflict_t
+{
+ /** Finite-state machine */
+ NwkAddrConflictState_t state;
+ /** Current conflict address. */
+ ShortAddr_t shortAddr;
+ bool sendNwkStatus;
+ union
+ {
+ MAC_SetReq_t macSet;
+ NWK_JoinReq_t rejoin;
+ NwkStatusReq_t nwkStatus;
+ } req;
+} NwkAddrConflict_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined _RESOLVE_ADDR_CONFLICT_
+/**************************************************************************//**
+ \brief Reset address conflict component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetAddressConflict(void);
+
+/**************************************************************************//**
+ \brief Main task handler of address conflict component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkAddressConflictTaskHandler(void);
+
+/**************************************************************************//**
+ \brief Resolve address conflict for given short address.
+
+ \param[in] shortAddr - conflicted short address.
+ \return None.
+******************************************************************************/
+NWK_PRIVATE void nwkResolveAddressConflict(const ShortAddr_t shortAddr,
+ const bool sendNwkStatus);
+
+/******************************************************************************
+ \brief nwkAddressConflict idle checking.
+
+ \return true, if nwkAddressConflict performs no activity, false - otherwise.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkAddressConflictIsIdle(void);
+
+#else /* _RESOLVE_ADDR_CONFLICT_ */
+
+#define nwkResetAddressConflict() (void)0
+#define nwkAddressConflictTaskHandler NULL
+#define nwkAddressConflictIsIdle NULL
+#define nwkResolveAddressConflict(shortAddr, sendNwkStatus) ((void)0)
+
+#endif /* _RESOLVE_ADDR_CONFLICT_ */
+#endif /* _NWK_ADDRESS_CONFLICT_H */
+/** eof nwkAddressConflict.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkAddressMap.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkAddressMap.h
new file mode 100644
index 00000000..c6418f35
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkAddressMap.h
@@ -0,0 +1,117 @@
+/**************************************************************************//**
+ \file nwkAddressMap.h
+
+ \brief The access interface to the address map..
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2010-07-04 Max Gekk - Created.
+ Last change:
+ $Id: nwkAddressMap.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_ADDRESS_MAP_H
+#define _NWK_ADDRESS_MAP_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <appFramework.h>
+#include <nwkSystem.h>
+#include <nwkCommon.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Type of size of the address map. */
+typedef uint8_t NwkSizeOfAddressMap_t;
+
+/** Type of index of the address map. */
+typedef NwkSizeOfAddressMap_t NwkAddressMapIndex_t;
+
+/** Type of entry of the address map. */
+typedef struct _NwkAddressMapEntry_t
+{
+ /** The entry is busy (true) or not (false). */
+ bool busy : 1;
+ /** Conflict of short addresses is detected (true) or not (false). */
+ bool conflict : 1;
+ NwkBitField_t reserved : 6;
+ /** A network address (16-bit). */
+ ShortAddr_t shortAddr;
+ /** IEEE address (64-bit). */
+ ExtAddr_t extAddr;
+} NwkAddressMapEntry_t;
+
+/** Type of the address map. */
+typedef struct _NwkAddressMap_t
+{
+ /** Array of address map entries. */
+ NwkAddressMapEntry_t *table;
+ /** Pointer to memory area after last entry of the address map. */
+ NwkAddressMapEntry_t *end;
+ /** Current position for a new entry. */
+ NwkAddressMapEntry_t *current;
+} NwkAddressMap_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Add a short and extended addresses in the address map.
+
+ \param[in] shortAddr - a short address.
+ \param[in] extAddr - an extended address.
+ \param[in] isConflict - 'true' if shortAddr conflict with other short address
+ in the network otherwise 'false'.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkAddToAddressMap(const ShortAddr_t shortAddr,
+ const ExtAddr_t extAddr, const bool isConflict);
+
+/**************************************************************************//**
+ \brief Find entry in the address map by IEEE address.
+
+ \param[in] extAddr - pointer to IEEE extended 64-bit address.
+ \return Pointer to an entry in the address map.
+ ******************************************************************************/
+NWK_PRIVATE NwkAddressMapEntry_t*
+ nwkFindAddressMapEntryByExtAddr(const ExtAddr_t *const extAddr);
+
+/**************************************************************************//**
+ \brief Find entry in the address map by short address.
+
+ \param[in] shortAddr - a network short address.
+ \return Pointer to an entry in the address map.
+ ******************************************************************************/
+NWK_PRIVATE NwkAddressMapEntry_t*
+ nwkFindAddressMapEntryByShortAddr(const ShortAddr_t shortAddr);
+
+#if defined _RESOLVE_ADDR_CONFLICT_
+/**************************************************************************//**
+ \brief Find entry in the address map with conflicted short address.
+
+ \return Pointer to an entry in the address map.
+ ******************************************************************************/
+NWK_PRIVATE NwkAddressMapEntry_t* nwkFindAddrMapConflictEntry(void);
+#endif /* _RESOLVE_ADDR_CONFLICT_ */
+
+/**************************************************************************//**
+ \brief Get maximum size of NWK address map.
+ ******************************************************************************/
+NWK_PRIVATE NwkSizeOfAddressMap_t nwkAddrMapSize(void);
+
+/**************************************************************************//**
+ \brief Reset the address map.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetAddressMap(void);
+
+#endif /* _NWK_ADDRESS_MAP_H */
+/** eof nwkAddressMap.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkBTT.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkBTT.h
new file mode 100644
index 00000000..881b5576
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkBTT.h
@@ -0,0 +1,86 @@
+/**************************************************************************//**
+ \file nwkBTT.h
+
+ \brief Broadcast transaction table.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2007-09-01 V. Panov - Created.
+ 2008-11-17 M. Gekk - Correct clearing of record in BTT. In case of overflow
+ of the table function nwkCheckBTT returns an error.
+ BTT moved in ConfigServer.
+ 2009-04-29 M. Gekk - Refactoring.
+ 2009-11-24 Igor Vagulin - reimplemented using sysDuplicateTable.
+ Last change:
+ $Id: nwkBTT.h 17946 2011-07-13 09:26:59Z mgekk $
+ ******************************************************************************/
+#if !defined _NWK_BTT_H
+#define _NWK_BTT_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <mac.h>
+#include <sysDuplicateTable.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Broadcast transaction table */
+typedef struct _NwkBTT_t
+{
+ /** Pointer to BTT sysDuplicateTable descriptor */
+ SYS_DuplicateTable_t btt;
+} NwkBTT_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Reseting of the broadcast transaction table.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetBTT(void);
+
+/**************************************************************************//**
+ \brief Check entry for short address and sequence number.
+
+ \param[in] shortAddr - source address of broadcast packet.
+ \param[in] sequenceNumber - a sequence number of broadcast packet.
+ ******************************************************************************/
+NWK_PRIVATE SysDuplicateTableAnswer_t nwkCheckBTT(const ShortAddr_t shortAddr,
+ const uint8_t sequenceNumber);
+
+/**************************************************************************//**
+ \brief Clear the existing entry in the broadcast transaction table.
+
+ \param[in] shortAddr - a short address of broadcast packet,
+ \param[in] sequenceNumber - a sequence number of broadcast packet.
+
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkClearBTR(const ShortAddr_t shortAddr,
+ const uint8_t sequenceNumber);
+
+/**************************************************************************//**
+ \brief Add new BTR to BTT with own address and given sequence number
+
+ \param[in] sequenceNumber - a sequence number of broadcast packet.
+ \return None.
+ ******************************************************************************/
+#if !defined NWK_ALWAYS_REJECT_OWN_BROADCAST
+NWK_PRIVATE void nwkAddOwnBTR(const uint8_t sequenceNumber);
+
+#else
+#define nwkAddOwnBTR(sequenceNumber) (void)0
+#endif /* NWK_ALWAYS_REJECT_OWN_BROADCAST */
+#endif /* _NWK_BTT_H */
+/** eof nwkBTT.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkCommands.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkCommands.h
new file mode 100644
index 00000000..a92c7da8
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkCommands.h
@@ -0,0 +1,86 @@
+/**************************************************************************//**
+ \file nwkCommands.h
+
+ \brief NWK commands header file.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2007-06-20 V. Panov - Created.
+ 2009-04-28 M. Gekk - Refactoring.
+ Last change:
+ $Id: nwkCommands.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_COMMANDS_H
+#define _NWK_COMMANDS_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <types.h>
+#include <nwkFrame.h>
+#include <nwkTx.h>
+
+/******************************************************************************
+ Definition section
+ ******************************************************************************/
+/* Total number of command requests. */
+#define NWK_COMMAND_REQ_AMOUNT (NWK_MAX_COMMAND_TX_ID + 1U)
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Type of command request counter. */
+typedef uint8_t NwkCommandCount_t;
+
+/** Internal variables of the commands component. */
+typedef struct _NwkCommands_t
+{
+ NwkCommandCount_t reqCount[NWK_COMMAND_REQ_AMOUNT];
+} NwkCommands_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Request to perform outgoing command allocated in data buffer.
+
+ \param[in] txId - the transmission identifier of a command
+ which is requested to send.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkCommandReq(const NwkTxId_t txId);
+
+/**************************************************************************//**
+ \brief Action when any command received.
+
+ \param[in] payload - command payload (with ID)
+ \param[in] header - pointer to network frame header.
+ \param[in] parse - parsed header fields
+ \return 'true' if continue command processing otherwise 'false'.
+******************************************************************************/
+NWK_PRIVATE bool nwkCommandInd(const uint8_t *const payload,
+ const NwkFrameHeader_t *const header, const NwkParseHeader_t *const parse);
+
+/**************************************************************************//**
+ \brief The packet for NWK command has been released.
+
+ \return 'true' if free packet has been allocated otherwise return 'false'.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkCommandFreePacketInd(void);
+
+/**************************************************************************//**
+ \brief Reset the commands component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetCommands(void);
+
+#endif /* _NWK_COMMANDS_H */
+/** eof nwkCommands.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkConcentrator.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkConcentrator.h
new file mode 100644
index 00000000..65e5a4a0
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkConcentrator.h
@@ -0,0 +1,83 @@
+/**************************************************************************//**
+ \file nwkConcentrator.h
+
+ \brief Interface of network concentrator.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2009-09-14 Max Gekk - Created.
+ Last change:
+ $Id: nwkConcentrator.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_CONCENTRATOR_H
+#define _NWK_CONCENTRATOR_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <appTimer.h>
+#include <nlmeRouteDiscovery.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Internal states of the network concentrator. */
+typedef enum _NwkConcentratorState_t
+{
+ NWK_CONCENTRATOR_IDLE_STATE = 0x89,
+ NWK_CONCENTRATOR_FIRST_STATE = 0x8A,
+ NWK_CONCENTRATOR_START_TIMER_STATE = NWK_CONCENTRATOR_FIRST_STATE,
+ NWK_CONCENTRATOR_ROUTE_DISCOVERY_STATE = 0x8B,
+ NWK_CONCENTRATOR_LAST_STATE
+} NwkConcentratorState_t;
+
+/** State and parameters of the network concentrator. */
+typedef struct _NwkConcentrator_t
+{
+ NwkConcentratorState_t state;
+ union
+ {
+ HAL_AppTimer_t timer;
+ NWK_RouteDiscoveryReq_t routeDiscovery;
+ } req;
+} NwkConcentrator_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined _NWK_CONCENTRATOR_
+/**************************************************************************//**
+ \brief Start the network concentrator.
+
+ Periodic sending of route discovery commands.
+ ******************************************************************************/
+NWK_PRIVATE void nwkStartConcentrator(void);
+
+/**************************************************************************//**
+ \brief nwkReset module call this function when network layer is reseting.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetConcentrator(void);
+
+/**************************************************************************//**
+ \brief Check state of the concentrator and stop timer.
+ ******************************************************************************/
+NWK_PRIVATE void nwkStopConcentratorTimer(void);
+
+#else /* _NWK_CONCENTRATOR_ */
+
+#define nwkStartConcentrator() (void)0
+#define nwkStopConcentratorTimer() (void)0
+#define nwkResetConcentrator() (void)0
+
+#endif /* _NWK_CONCENTRATOR_ */
+#endif /* _NWK_CONCENTRATOR_H */
+/** eof nwkConcentrator.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkConfig.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkConfig.h
new file mode 100644
index 00000000..a66816d5
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkConfig.h
@@ -0,0 +1,137 @@
+/**************************************************************************//**
+ \file nwkConfig.h
+
+ \brief Constant definition header file.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2007-06-20 V. Panov - Created.
+ 2008-09-29 M. Gekk - Values of constants for a network from 60
+ nodes are increased.
+ Last change:
+ $Id: nwkConfig.h 19021 2011-10-26 12:36:59Z mgekk $
+******************************************************************************/
+#if !defined _NWK_CONFIG_H
+#define _NWK_CONFIG_H
+
+/******************************************************************************
+ Definitions section
+ ******************************************************************************/
+/** A Boolean flag indicating whether the device is capable of becoming
+ * the ZigBee coordinator. ZigBee spec r17, page 338, table 3.43.
+ * */
+#if defined _COORDINATOR_
+ #define NWKC_COORDINATOR_CAPABLE true
+#else
+ #define NWKC_COORDINATOR_CAPABLE false
+#endif /* _COORDINATOR_ */
+
+/** Define for coordinator address */
+#define NWKC_COORD_ADDR 0x0000U
+
+/** North America */
+/* #define NWK_NO_WIFI_CHANNELS_MASK 0x610800 */
+/** Europe */
+#define NWK_NO_WIFI_CHANNELS_MASK 0x618000U
+
+#define NWK_FAVOURITE_CHANNELS_MASK (NWK_NO_WIFI_CHANNELS_MASK)
+
+#define NWKC_PROTOCOL_ID 0U
+
+#define NWKC_INITIAL_LINK_STATUS_PERIOD 15000UL /* msec*/
+
+#define NWK_MAX_CHANNEL 26
+
+#define NWK_MAX_LINK_STATUS_FAILURES 3U
+#define NWK_END_DEVICE_MAX_FAILURES 3U
+
+#define NWK_MAX_ED_LEVEL 0xCCU /* 255 * 0.8 */
+
+/** Support network realignment */
+/* #define NWK_COORD_REALIGNMENT */
+
+#if defined _NWK_NONSTANDARD_BEACON_FILTER_
+ /** Filter by extended pan id */
+ #define NWK_BEACON_FILTER_EXTENDED_PANID
+ /** If predefined short pan id then discard beacons with other pan id. */
+ #define NWK_BEACON_FILTER_PREDEFINED_PANID
+ /** Beacons with the end device capacity bit equal zero will discard. */
+ #define NWK_BEACON_FILTER_END_DEVICE_CAPACITY
+ /** Beacons with the router capacity bit equal zero will discard. */
+ #define NWK_BEACON_FILTER_ROUTER_CAPACITY
+#endif /* NWK_NONSTANDARD_BEACON_FILTER */
+
+/** Update the neighbor table only if our network address is presented in
+ * the received link status command. */
+/* #define NWK_LINK_STATUS_ONLY_IN_LIST */
+
+/** Duration of searching other networks on same channel.
+ * It is ~(2^NWK_REPORT_SCAN_DURATION)*960*16 (usec) - for 2.4MHz */
+#define NWK_SEARCH_NETWORKS_DURATION 8U /* ~4sec - 2.4MHz */
+
+#define NWK_SELECT_RANDOM_PARENT
+#define NWK_DELTA_LQI (255/10)
+
+#if defined _NWK_ROUTE_CACHE_
+ #define NWKC_NO_ROUTE_CACHE false
+#else
+ #define NWKC_NO_ROUTE_CACHE true
+#endif /* _NWK_ROUTE_CACHE_ */
+
+/** Maximum number of the many-to-one route requests after that the
+ * route record command must be transmitted if no source route packet has
+ * been received. */
+#define NWK_MAX_NO_SOURCE_ROUTE_PERIODS 3U
+
+#if defined _COORDINATOR_ || defined _ROUTER_
+ #define NWK_ROUTING_CAPACITY
+#endif /* _COORDINATOR_ or _ROUTER_ */
+
+/** The maximum time duration in milliseconds allowed for the parent and
+ * all child devices to retransmit a broadcast message. */
+#define NWK_PASSIVE_ACK_TIMEOUT 15625UL /* octets duration ~= 500 ms. in 2.4Ghz */
+
+/** Maximum data packet retransmission. The maximum number of retries allowed
+ * after a broadcast transmission failure.*/
+#define NWK_MAX_BROADCAST_RETRIES 3U
+
+/** Maximum value of a link cost metric. */
+#define NWK_MAX_LINK_COST 7U
+
+/** Time duration in milliseconds until a route discovery expires.
+ * ZigBee spec r18, Table 3.43, page 342. */
+#define NWKC_ROUTE_DISCOVERY_TIME 0x2710U
+
+#define NWK_ALWAYS_REJECT_OWN_BROADCAST
+
+#if !defined _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 0
+#endif
+
+#if defined _CERTIFICATION_
+/* Doesn't change relationship of router child. */
+#define NWK_TAKES_CARE_OF_CHILD_ROUTER
+
+#define NWK_LIFE_TIME_OF_RX_ON_END_DEVICE (65534UL * 2048UL) /* msec */
+
+#else /* not _CERTIFICATION_ */
+
+#define NWK_LIFE_TIME_OF_RX_ON_END_DEVICE (60U * 2048UL) /* msec */
+
+#endif /* _CERTIFICATION_ */
+
+#define NWK_MAX_DEPTH_IN_BEACON 0xf
+
+/** The cost of an outgoing link as measured by the neighbor. A value
+ * of 0 indicates no outgoing cost is available. See ZigBee Spec r19, Table 3.48. */
+#define NWK_NO_OUTGOING_COST 0U
+
+#endif /* _NWK_CONFIG_H */
+/** eof nwkConfig.h */
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkDataReq.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkDataReq.h
new file mode 100644
index 00000000..e0fe02a7
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkDataReq.h
@@ -0,0 +1,92 @@
+/**************************************************************************//**
+ \file nwkDataReq.h
+
+ \brief Interface of the data request component.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2009-08-29 M. Gekk - Created.
+ Last change:
+ $Id: nwkDataReq.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_DATA_REQ_H
+#define _NWK_DATA_REQ_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <queue.h>
+#include <nwkCommon.h>
+#include <nldeData.h>
+
+/******************************************************************************
+ Define(s) section
+ ******************************************************************************/
+/** Transmission parameters of data packets. */
+#define NWK_UNICAST_DATA_TX_PARAMETERS \
+ {NWK_TX_DELAY_UNICAST_DATA, NULL, nwkConfirmDataTx, false}
+#define NWK_BROADCAST_DATA_TX_PARAMETERS \
+ {NWK_TX_DELAY_BROADCAST, NULL, nwkConfirmDataTx, false}
+#define NWK_MULTICAST_MEMBER_TX_PARAMETERS \
+ {NWK_TX_DELAY_INITIAL_MULTICAST, NULL, nwkConfirmDataTx, false}
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Internal states of data confirmation. */
+typedef enum _NwkDataConfState_t
+{
+ NWK_DATA_CONF_IDLE_STATE = 0x41,
+ NWK_DATA_CONF_FIRST_STATE = 0x03,
+ NWK_DATA_CONF_PROCESS_STATE = NWK_DATA_CONF_FIRST_STATE,
+ NWK_DATA_CONF_LAST_STATE
+} NwkDataConfState_t;
+
+/** Internal variables of this component. */
+typedef struct _NwkDataConf_t
+{
+ QueueDescriptor_t queue;
+ NwkDataConfState_t state;
+} NwkDataConf_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Reset the data request component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetDataConf(void);
+
+/**************************************************************************//**
+ \brief Main task handler of the data request component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkDataConfTaskHandler(void);
+
+/**************************************************************************//**
+ \brief Confirmation of data transmission.
+
+ \param[in] outPkt - pointer to output packet.
+ \param[in] status - network status of data transmission.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkConfirmDataTx(NwkOutputPacket_t *const outPkt,
+ const NWK_Status_t status);
+
+/******************************************************************************
+ \brief nwkDataReq idle checking.
+
+ \return true, if nwkDataReq performs no activity, false - otherwise.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkDataReqIsIdle(void);
+
+#endif /* _NWK_DATA_REQ_H */
+/** eof nwkDataReq.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkDbg.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkDbg.h
new file mode 100644
index 00000000..9e4cb22d
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkDbg.h
@@ -0,0 +1,473 @@
+/**************************************************************************//**
+ \file nwkDbg.h
+
+ \brief Constants for debugging and tracing
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2008-09-19 M. Gekk - New assert identifiers are added.
+ 2009-04-02 M. Gekk - Refactoring.
+ Last change:
+ $Id: nwkDbg.h 18296 2011-08-19 12:29:05Z mgekk $
+ ******************************************************************************/
+#if !defined _NWK_DBG_H
+#define _NWK_DBG_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <dbg.h>
+
+/******************************************************************************
+ Define(s) section
+ ******************************************************************************/
+
+#if defined _SYS_ASSERT_ON_
+
+#define NWK_SET_STATE(obj, newState) (obj)->state = (newState)
+#define NWK_CHECK_STATE(obj, checkState, nameOfAssert) \
+ assert((checkState) == (obj)->state, nameOfAssert)
+
+#else /* _SYS_ASSERT_ON_ */
+
+#define NWK_SET_STATE(obj, newState)
+#define NWK_CHECK_STATE(obj, waitState, nameOfAssert)
+#if defined assert
+#undef assert
+#endif /* assert */
+#define assert(condition, dbgCode) (void)0
+
+#endif /* _SYS_ASSERT_ON_ */
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Network assert code. Range 0x3000 - 0x3FFF. */
+typedef enum _NwkDbgCode_t
+{
+ NWKIB_NWKRELOADNIBFROMCONFIGSERVER0 = 0x3001,
+ NWKADDRESS_MACSETCONF0 = 0x3005,
+ NWKADDRESS_NWKALLOCATESHORTADDR1 = 0x3006,
+ NWKJOINREQ_GETSUITABLEPARENT = 0x300B,
+ NWKJOINREQ_NWKASSOCIATE = 0x300C,
+ NWKJOINREQ_NWKJOINREQTASKHANDLER0 = 0x300D,
+ NWKJOINREQ_NWKJOINREQTASKHANDLER1 = 0x300E,
+ NWKJOINREQ_NWKJOINREQTASKHANDLER2 = 0x300F,
+ NWKJOINREQ_NWKJOINREQTASKHANDLER3 = 0x3010,
+ NWKJOINREQ_NWKJOINREQTASKHANDLER4 = 0x3011,
+ NWKJOINREQ_NWKNETWORKDISCOVERYCONF0 = 0x3012,
+ NWKJOINREQ_NWKNETWORKDISCOVERYCONF1 = 0x3013,
+ NWKJOINREQ_MACSETCONF0 = 0x3014,
+ NWKJOINREQ_MACSETCONF1 = 0x3015,
+ NWKJOINREQ_MACSETCONF2 = 0x3016,
+ NWKJOINREQ_MACSETCONF3 = 0x3017,
+ NWKJOINREQ_MACSETCONF4 = 0x3018,
+ NWKJOINREQ_MACRXENABLECONF0 = 0x3019,
+ NWKJOINREQ_MACRXENABLECONF1 = 0x301A,
+ NWKJOINREQ_MACGETCONF0 = 0x301B,
+ NWKJOINREQ_MACGETCONF1 = 0x301C,
+ NWKJOINREQ_NWKCONFIRMJOINREQTX0 = 0x301D,
+ NWKJOINREQ_NWKREJOINRESPONSEFRAMEIND0 = 0x301E,
+ NWKJOINREQ_RESPONSEWAITTIMERFIRED0 = 0x301F,
+ NWKJOINREQ_RESPONSEWAITTIMERFIRED1 = 0x3020,
+ NWKJOINREQ_RESPONSEWAITTIMERFIRED2 = 0x3021,
+ NWKJOINREQ_DECRYPTRESPONSEFIRED0 = 0x3022,
+ NWKJOINREQ_DECRYPTRESPONSEFIRED1 = 0x3023,
+ NWKJOINREQ_MACPOLLCONF0 = 0x3024,
+ NWKJOINREQ_MACPOLLCONF1 = 0x3025,
+ NWKJOINREQ_MACASSOCIATECONF0 = 0x3026,
+ NWKJOINREQ_MACRXENABLECONF2 = 0x3027,
+ NWKJOINREQ_NWKJOINREQ0 = 0x3028,
+ NWKJOINREQ_NWKJOINREQ1 = 0x3029,
+ NWKJOINREQ_NWKNETWORKDISCOVERYCONF2 = 0x302A,
+ NWK_RD_INVALID_STATE_IN_TIMER_CALLBACK = 0x3030,
+ NWK_ROUTEDISCOVERY_PROCESSROUTEDISCOVERYOBJ = 0x3031,
+ NWK_ROUTEDISCOVERY_NWKSETRREQTIMEOUTTIMER = 0x3032,
+ NWK_ROUTEDISCOVERY_NWKRREQTIMEOUTTIMERFIRED = 0x3033,
+ NWKJOININD_FINDFREEJOININDOBJ0 = 0x3040,
+ NWKJOININD_FREEJOININDOBJ0 = 0x3041,
+ NWKJOININD_NWKJOININDTASKHANDLER0 = 0x3042,
+ NWKJOININD_NWKPREPAREJOINRESPTX0 = 0x3043,
+ NWKJOININD_NWKJOININDISIDLE = 0x3044,
+ NWKJOININD_NWKCONFIRMJOINRESPTX0 = 0x3045,
+ NWKJOININD_MACCOMMSTATUSIND0 = 0x3046,
+ NWKJOININD_MACCOMMSTATUSIND1 = 0x3047,
+ NWKJOININD_NWKCONFIRMADDRCONFLICTJOINRESPTX0 = 0x3048,
+ NWKJOININD_NWKRESETJOININD0 = 0x3049,
+ NWKRESET_NWKRESETREQ0 = 0x3050,
+ NWKRESET_NWKRESETREQ1 = 0x3051,
+ NWKRESET_NWKRESETTASKHANDLER0 = 0x3052,
+ NWKRESET_NWKRESETTASKHANDLER1 = 0x3053,
+ NWKRESET_NWKRESETTASKHANDLER2 = 0x3054,
+ NWKRESET_NWKRESETCONF0 = 0x3055,
+ NWKRESET_MACRESETCONF0 = 0x3056,
+ NWKRESET_MACRESETCONF1 = 0x3057,
+ NWKRESET_MACRESETCONF2 = 0x3058,
+ NWKRESET_MACSETCONF1 = 0x3059,
+ NWKRESET_MACSETCONF0 = 0x305A,
+ NWKRESET_MACSTARTCONF0 = 0x305B,
+ NWKRESET_MACSTARTCONF1 = 0x305C,
+ NWKRESET_MACRXENABLECONF0 = 0x305D,
+ NWKRESET_MACRXENABLECONF1 = 0x305E,
+ NWKPERMITJOINING_NWKPERMITJOININGREQ1 = 0x3060,
+ NWKPERMITJOINING_NWKPERMITJOININGTASKHANDLER0 = 0x3061,
+ NWKPERMITJOINING_NWKPERMITJOININGTASKHANDLER1 = 0x3062,
+ NWKPERMITJOINING_NWKPERMITJOININGTASKHANDLER2 = 0x3063,
+ NWKPERMITJOINING_MACSETCONF0 = 0x3064,
+ NWKPERMITJOINING_MACSETCONF1 = 0x3065,
+ NWKPERMITJOINING_NWKPERMITJOININGREQ2 = 0x3069,
+ NWKPERMITJOINING_NWKSETREJOINPERMIT0 = 0x306A,
+ NWKSYNC_NWKSYNCREQ0 = 0x3070,
+ NWKSYNC_NWKSYNCPOLLREQ0 = 0x3071,
+ NWKSYNC_NWKSYNCPOLLREQ1 = 0x3072,
+ NWKSYNC_NWKSYNCTASKHANDLER0 = 0x3073,
+ NWKSYNC_NWKSYNCTASKHANDLER1 = 0x3074,
+ NWKSYNC_NWKSYNCTASKHANDLER2 = 0x3075,
+ NWKSYNC_NWKSYNCTASKHANDLER3 = 0x3076,
+ NWKSYNC_NWKSYNCTASKHANDLER4 = 0x3077,
+ NWKSYNC_NWKSYNCTASKHANDLER5 = 0x3078,
+ NWKSYNC_NWKSYNCMACPOLLCONF_0 = 0x3079,
+ NWKSYNC_NWKSYNCMACPOLLCONF_1 = 0x307A,
+ NWKSYNC_NWKSYNCREQ1 = 0x307B,
+ NWKSYNC_MACPOLLIND0 = 0x307C,
+ NWKEDSCAN_NWKEDSCANREQ0 = 0x3080,
+ NWKEDSCAN_NWKEDSCANTASKHANDLER0 = 0x3081,
+ NWKEDSCAN_NWKEDSCANTASKHANDLER1 = 0x3082,
+ NWKEDSCAN_NWKEDSCANTASKHANDLER2 = 0x3083,
+ NWKEDSCAN_NWKEDSCANTASKHANDLER3 = 0x3084,
+ NWKEDSCAN_NWKEDSCANTASKHANDLER4 = 0x3085,
+ NWKEDSCAN_NWKEDSCANTASKHANDLER5 = 0x3086,
+ NWKEDSCAN_MACEDSCANCONF0 = 0x3087,
+ NWKEDSCAN_MACEDSCANCONF1 = 0x3088,
+ NWKEDSCAN_MACEDSCANCONF2 = 0x3089,
+ NWKEDSCAN_NWKEDSCANREQ1 = 0x308A,
+ NWKSTARTROUTER_NWKSTARTROUTERREQ0 = 0x3090,
+ NWKSTARTROUTER_NWKSTARTROUTERTASKHANDLER0 = 0x3091,
+ NWKSTARTROUTER_NWKSTARTROUTERTASKHANDLER1 = 0x3092,
+ NWKSTARTROUTER_NWKSTARTROUTERTASKHANDLER2 = 0x3093,
+ NWKSTARTROUTER_NWKSTARTROUTERTASKHANDLER3 = 0x3094,
+ NWKSTARTROUTER_NWKSTARTROUTERTASKHANDLER4 = 0x3095,
+ NWKSTARTROUTER_NWKSTARTROUTERTASKHANDLER5 = 0x3096,
+ NWKSTARTROUTER_MACSTARTCONF0 = 0x3097,
+ NWKSTARTROUTER_MACSTARTCONF1 = 0x3098,
+ NWKSTARTROUTER_MACSTARTCONF2 = 0x3099,
+ NWKSTARTROUTER_NWKSTARTROUTERREQ1 = 0x309A,
+ NWKFORMATION_NWKNETWORKFORMATIONREQ0 = 0x30A0,
+ NWKFORMATION_NWKFORMATIONTASKHANDLER0 = 0x30A1,
+ NWKFORMATION_NWKFORMATIONTASKHANDLER1 = 0x30A2,
+ NWKFORMATION_NWKFORMATIONTASKHANDLER2 = 0x30A3,
+ NWKFORMATION_NWKFORMATIONTASKHANDLER3 = 0x30A4,
+ NWKFORMATION_MACSTARTREALIGNMENTCONF0 = 0x30A5,
+ NWKFORMATION_MACSTARTREALIGNMENTCONF1 = 0x30A6,
+ NWKFORMATION_MACSTARTREALIGNMENTCONF2 = 0x30A7,
+ NWKFORMATION_MACEDSCANCONF0 = 0x30A8,
+ NWKFORMATION_MACEDSCANCONF1 = 0x30A9,
+ NWKFORMATION_MACEDSCANCONF2 = 0x30AA,
+ NWKFORMATION_MACACTIVESCANCONFIRM0 = 0x30AB,
+ NWKFORMATION_MACACTIVESCANCONFIRM1 = 0x30AC,
+ NWKFORMATION_MACACTIVESCANCONFIRM2 = 0x30AD,
+ NWKFORMATION_MACSETCONF0 = 0x30AE,
+ NWKFORMATION_MACSETCONF1 = 0x30AF,
+ NWKFORMATION_MACSETCONF2 = 0x30B0,
+ NWKFORMATION_MACSTARTCONF0 = 0x30B1,
+ NWKFORMATION_MACSTARTCONF1 = 0x30B2,
+ NWKFORMATION_MACSTARTCONF2 = 0x30B3,
+ NWKFORMATION_MACRXENABLECONF0 = 0x30B4,
+ NWKFORMATION_MACRXENABLECONF1 = 0x30B5,
+ NWKFORMATION_MACRXENABLECONF2 = 0x30B6,
+ NWKFORMATION_FINDBESTCHANNEL0 = 0x30B7,
+ NWKFORMATION_FINDBESTCHANNEL1 = 0x30B8,
+ NWKFORMATION_MACACTIVESCANCONFIRM3 = 0x30B9,
+ NWKFORMATION_MACEDSCANCONF3 = 0x30BA,
+ NWKFORMATION_MACEDSCANCONF4 = 0x30BB,
+ NWKFORMATION_NWKNETWORKFORMATIONREQ1 = 0x30BC,
+ NWKSYNCLOSS_MACSYNCLOSSIND0 = 0x30C0,
+ NWKSYNCLOSS_MACSYNCLOSSIND1 = 0x30C1,
+ NWKSYNCLOSS_MACSYNCLOSSIND2 = 0x30C2,
+ NWKSYNCLOSS_MACSYNCLOSSIND3 = 0x30C3,
+ NWKSYNCLOSS_NWKSTARTROUTERCONF0 = 0x30C4,
+ NWKSYNCLOSS_NWKSTARTROUTERCONF1 = 0x30C5,
+ NWKSYNCLOSS_NWKRESETREALIGNMENT0 = 0x30C6,
+ NWKDISCOVERY_NWKNETWORKDISCOVERYREQ0 = 0x30D0,
+ NWKDISCOVERY_NWKNETWORKDISCOVERYREQ1 = 0x30D1,
+ NWKDISCOVERY_NWKDISCOVERYTASKHANDLER0 = 0x30D2,
+ NWKDISCOVERY_NWKDISCOVERYTASKHANDLER1 = 0x30D3,
+ NWKDISCOVERY_NWKDISCOVERYTASKHANDLER2 = 0x30D4,
+ NWKDISCOVERY_NWKDISCOVERYTASKHANDLER3 = 0x30D5,
+ NWKDISCOVERY_MACBEACONNOTIFYIND0 = 0x30D6,
+ NWKDISCOVERY_MACACTIVESCANCONFIRM0 = 0x30D7,
+ NWKDISCOVERY_MACACTIVESCANCONFIRM1 = 0x30D8,
+ NWKDISCOVERY_MACACTIVESCANCONFIRM2 = 0x30D9,
+ NWKDISCOVERY_NWKFILLPANDESCRIPTORS0 = 0x30DA,
+ NWKDISCOVERY_NWKFILLPANDESCRIPTORS1 = 0x30DB,
+ NWKLINKSTATUS_NWKLINKSTATUSTIMERFIRED0 = 0x30E0,
+ NWKLINKSTATUS_NWKCONFIRMLINKSTATUSTX0 = 0x30E1,
+ NWKLINKSTATUS_NWKSTARTLINKSTATUSTIMER0 = 0x30E2,
+ NWKLINKSTATUS_NWKPREPARELINKSTATUSTX0 = 0x30E3,
+ NWKLINKSTATUS_NWKPREPARELINKSTATUSTX1 = 0x30E4,
+ NWKLINKSTATUS_NWKSTOPLINKSTATUSTIMER = 0x30E5,
+ NWKLINKSTATUS_NWKCOPYCOSTINFOTOLINKSTATUSCMD0 = 0x30E7,
+ NWKNEIGHBORTABLE_NWKRESETNEIBTABLE0 = 0x30F0,
+ NWKNEIGHBORTABLE_NWKRESETNEIBTABLE1 = 0x30F1,
+ NWKNEIGHBORTABLE_NWKRESETNEIBTABLE2 = 0x30F2,
+ NWKNEIGHBORTABLE_NWKFREENEIGHBOR0 = 0x30F3,
+ NWKNEIGHBORTABLE_NWKSETLIFETIMEOFNEIGHBOR0 = 0x30F4,
+ NWKNEIGHBORTABLE_NEIGHBORTIMERFIRED0 = 0x30F5,
+ NWKNEIGHBORTABLE_NWKSTARTAGETIMEROFNEIGHBORTABLE0 = 0x30F6,
+ NWKNEIGHBORTABLE_NWKISKNOWNCHILD0 = 0x30F7,
+ NWKADDRESSMAP_NWKADDTOADDRESSMAP1 = 0x3110,
+ NWKADDRESSMAP_NWKGETSHORTBYEXTADDRESS0 = 0x3111,
+ NWKADDRESSMAP_NWKSTATUSCOMMANDCONF0 = 0x3112,
+ NWKADDRESSMAP_NWKSTATUSCOMMANDCONF1 = 0x3113,
+ NWKADDRESSMAP_NWKADDTOADDRESSMAP0 = 0x3114,
+ NWKADDRESSMAP_NWKRESETADDRESSMAP0 = 0x3115,
+ NWKLEAVE_NWKREMOVENEIGHBOR0 = 0x3120,
+ NWKLEAVE_NWKLEAVEREQ0 = 0x3121,
+ NWKLEAVE_NWKLEAVEREQ1 = 0x3122,
+ NWKLEAVE_NWKLEAVETASKHANDLER0 = 0x3123,
+ NWKLEAVE_NWKLEAVETASKHANDLER1 = 0x3124,
+ NWKLEAVE_NWKLEAVETASKHANDLER2 = 0x3125,
+ NWKLEAVE_NWKLEAVETASKHANDLER3 = 0x3126,
+ NWKLEAVE_NWKLEAVENEIGHBOR0 = 0x3127,
+ NWKLEAVE_NWKLEAVENEIGHBOR1 = 0x3128,
+ NWKLEAVE_NWKCONFIRMOFLEAVEITSELFCMD0 = 0x3129,
+ NWKLEAVE_NWKCONFIRMOFLEAVEITSELFCMD1 = 0x312A,
+ NWKLEAVE_MACRESETCONF0 = 0x312B,
+ NWKLEAVE_MACRESETCONF1 = 0x312C,
+ NWKLEAVE_MACRESETCONF2 = 0x312D,
+ NWKLEAVE_NWKCONFIRMOFLEAVECHILDCMD0 = 0x312E,
+ NWKLEAVE_NWKCONFIRMOFLEAVECHILDCMD1 = 0x312F,
+ NWKLEAVE_NWKCONFIRMOFLEAVECHILDCMD2 = 0x3130,
+ NWKLEAVE_NWKCONFIRMOFLEAVECHILDCMD3 = 0x3131,
+ NWKLEAVE_NWKPREPAREMACDATAOFLEAVEITSELFCMD0 = 0x3132,
+ NWKLEAVE_NWKPREPAREMACDATAOFLEAVEITSELFCMD1 = 0x3133,
+ NWKLEAVE_NWKPREPAREMACDATAOFLEAVECHILDCMD0 = 0x3135,
+ NWKLEAVEIND_NWKLEAVECONF0 = 0x3138,
+ NWKLEAVEIND_NWKLEAVECONF1 = 0x3139,
+ NWKLEAVE_NWKCONFIRMOFLEAVECHILDCMD4 = 0x313A,
+ NWKLEAVE_NWKCONFIRMOFLEAVEITSELFCMD2 = 0x313B,
+ NWKLEAVE_NWKCONFIRMOFLEAVECHILDCMD5 = 0x313C,
+ NWKREPORTCOMMAND_NWKDETECTPANIDCONFLICT0 = 0x3140,
+ NWKREPORTCOMMAND_NWKSEARCHOTHERNETWORKS0 = 0x3141,
+ NWKREPORTCOMMAND_MACACTIVESCANCONFIRM0 = 0x3142,
+ NWKREPORTCOMMAND_MACACTIVESCANCONFIRM1 = 0x3143,
+ NWKREPORTCOMMAND_NWKPREPAREREPORTTX0 = 0x3144,
+ NWKREPORTCOMMAND_NWKPREPAREREPORTTX1 = 0x3145,
+ NWKREPORTCOMMAND_NWKPREPAREREPORTTX2 = 0x3146,
+ NWKREPORTCOMMAND_NWKCONFIRMREPORTTX0 = 0x3148,
+ NWKUPDATECOMMAND_NWKUPDATEPANID0 = 0x3150,
+ NWKUPDATECOMMAND_NWKUPDATETIMERFIRED0 = 0x3151,
+ NWKUPDATECOMMAND_MACSETCONF0 = 0x3152,
+ NWKUPDATECOMMAND_MACSETCONF1 = 0x3153,
+ NWKMANAGER_NWKDETECTPANIDCONFLICTBYNWKMANAGER0 = 0x3160,
+ NWKMANAGER_NWKREPORTFRAMEIND0 = 0x3161,
+ NWKMANAGER_NWKCHOSEPANID0 = 0x3162,
+ NWKMANAGER_MACACTIVESCANCONF0 = 0x3163,
+ NWKMANAGER_MACACTIVESCANCONF1 = 0x3164,
+ NWKMANAGER_NWKPREPAREUPDATETX0 = 0x3165,
+ NWKMANAGER_NWKCONFIRMUPDATETX0 = 0x3167,
+ NWKMANAGER_NWKCONFIRMUPDATETX1 = 0x3168,
+ NWKMANAGER_NWKMANAGERSETPANIDDONE0 = 0x3169,
+ NWKMANAGER_MACACTIVESCANCONF2 = 0x316A,
+ NWKSTATUSIND_NWKADDRCONFLICTCONF0 = 0x3170,
+ NWKSTATUSREQ_NWKSTATUSREQ0 = 0x3171,
+ NWKSTATUSREQ_NWKSTATUSREQ1 = 0x3172,
+ NWKSTATUSREQ_NWKCONFIRMNETWORKSTATUSTX0 = 0x3175,
+ NWKSTATUSREQ_NWKCONFIRMNETWORKSTATUSTX1 = 0x3176,
+ NWKSTATUSREQ_NWKPREPARENETWORKSTATUSTX0 = 0x3177,
+ NWKSTATUSREQ_NWKSENDROUTEERRORCONF0 = 0x3178,
+ NWKADDRESSCONFLICT_NWKJOINCONF0 = 0x3180,
+ NWKADDRESSCONFLICT_NWKJOINCONF1 = 0x3181,
+ NWKADDRESSCONFLICT_MACSETCONF0 = 0x3182,
+ NWKADDRESSCONFLICT_NWKSTATUSCONF0 = 0x3183,
+ NWKPACKET_NWKALLOCINPUTPACKET0 = 0x3190,
+ NWKPACKET_NWKALLOCOUTPUTPACKET0 = 0x3191,
+ NWKPACKET_NWKFREEBUFFER0 = 0x3192,
+ NWKPACKET_NWKALLOCDATAREQ0 = 0x3193,
+ NWKPACKET_NWKALLOCDATAREQTASKHANDLER0 = 0x3194,
+ NWKPACKET_NWKALLOCDATAREQTASKHANDLER1 = 0x3195,
+ NWKPACKET_NWKFREEBUFFER1 = 0x3196,
+ NWKRX_NWKRXINDICATION0 = 0x31A0,
+ NWKRX_NWKDATAINDTRANSITCONF0 = 0x31A1,
+ NWKRX_NWKDATARESP0 = 0x31A2,
+ NWKRX_NWKRETRANSMITBUFFER0 = 0x31A3,
+ NWKRX_NWKDECRYPTTRANSITFRAMECONF0 = 0x31A4,
+ NWKRX_NWKDECRYPTFRAMECONF0 = 0x31A5,
+ NWKRX_NWKRETRANSMITBUFFER1 = 0x31A6,
+ NWKRX_NWKINITINPUTPACKET0 = 0x31A7,
+ NWKDATAREQ_NWKDATAREQ0 = 0x31B0,
+ NWKDATAREQ_NWKDATAREQ1 = 0x31B1,
+ NWKDATAREQ_NWKDATACONF0 = 0x31B3,
+ NWKDATAREQ_NWKDATACONFTASKHANDLER0 = 0x31B4,
+ NWKDATAREQ_NWKDATACONFTASKHANDLER1 = 0x31B5,
+ NWKDATAREQ_NWKDATACONFTASKHANDLER2 = 0x31B6,
+ NWKDATAREQ_NWKINITRADIUSFIELD0 = 0x31B7,
+ NWKTASKMANAGER_NWKTASKHANDLER0 = 0x31C0,
+ NWKCOMMANDS_NWKCOMMANDCONF0 = 0x31D0,
+ NWKCOMMANDS_NWKCOMMANDREQ0 = 0x31D2,
+ NWKCOMMANDS_NWKCOMMANDREQ1 = 0x31D3,
+ NWKTXSECURITY_NWKENCRYPTOUTPUTPACKETCONF0 = 0x31E0,
+ NWKTXSECURITY_NWKENCRYPTOUTPUTPACKETCONF1 = 0x31E1,
+ NWKTXSECURITY_NWKDECRYPTOUTPUTPACKETCONF0 = 0x31E2,
+ NWKTXSECURITY_NWKDECRYPTOUTPUTPACKETCONF1 = 0x31E3,
+ NWKROUTING_NWKGETNEXTHOP0 = 0x31F0,
+ NWKCONCENTRATOR_NWKSTARTCONCENTRATOR0 = 0x3200,
+ NWKCONCENTRATOR_NWKCONCENTRATORTIMERFIRED0 = 0x3201,
+ NWKCONCENTRATOR_NWKROUTEDISCOVERYCONF0 = 0x3202,
+ NWKCONCENTRATOR_NWKSTOPCONCENTRATOR_TIMER = 0x3203,
+ NWKTXDELAY_NWKINITDELAYANDRETRIES0 = 0x3210,
+ NWKTXDELAY_NWKINITDELAYANDRETRIES1 = 0x3211,
+ NWKTXDELAY_NWKTXDELAYREQ0 = 0x3212,
+ NWKTXDELAY_NWKTXDELAYREQ1 = 0x3213,
+ NWKTXDELAY_NWKTXDELAYREQ2 = 0x3214,
+ NWKTXDELAY_NWKTXDELAYREQ3 = 0x3215,
+ NWKTXDELAY_NWKTXDELAYTIMERFIRED0 = 0x3216,
+ NWKTXDELAY_NWKFLUSHTXDELAY0 = 0x3217,
+ NWKTXDELAY_NWKFLUSHTXDELAY1 = 0x3218,
+ NWKTXDELAY_NWKBROADCASTTXDELAYREQ0 = 0x3219,
+ NWKTXDELAY_NWKINITINITIALRREQTXDELAY0 = 0x321A,
+ NWKTXDELAY_NWKINITDELAYANDRETRIES2 = 0x321B,
+ NWKTX_NWKSENDPACKET0 = 0x3220,
+ NWKTX_MACDATACONF0 = 0x3221,
+ NWKTX_NWKROUTE0 = 0x3222,
+ NWKTX_NWKROUTE1 = 0x3223,
+ NWKTX_NWKROUTE2 = 0x3224,
+ NWKTX_NWKTXCONF0 = 0x3225,
+ NWKTX_NWKROUTEDISCOVERYCONF0 = 0x3226,
+ NWKTX_NWKTXDELAYCONF0 = 0x3227,
+ NWKTX_NWKTXREQ0 = 0x3228,
+ NWKTX_NWKTXTASKHANDLER0 = 0x3229,
+ NWKTX_NWKTXTASKHANDLER1 = 0x322A,
+ NWKTX_NWKISDATAPACKET0 = 0x322B,
+ NWKTX_NWKTRANSMITOUTPUTPACKET0 = 0x322C,
+ NWKTX_NWKROUTERECORDCONF0 = 0x322D,
+ NWKLOOPBACK_NWKLOOPBACKTXREQ0 = 0x3230,
+ NWKLOOPBACK_NWKPROCESSLOOPBACKREQUEST0 = 0x3231,
+ NWKLOOPBACK_NWKLOOPBACKTASKHANDLER0 = 0x3232,
+ NWKLOOPBACK_NWKLOOPBACKTASKHANDLER1 = 0x3233,
+ NWKLOOPBACK_NWKLOOPBACKTASKHANDLER2 = 0x3234,
+ NWKLOOPBACK_NWKLOOPBACKTASKHANDLER3 = 0x3235,
+ NWKLOOPBACK_NWKLOOPBACKTASKHANDLER4 = 0x3236,
+ NWKLOOPBACK_NWKLOOPBACKTASKHANDLER5 = 0x3237,
+ NWKROUTEREPLY_NWKPREPAREROUTEREPLYTX0 = 0x3240,
+ NWKROUTEREPLY_NWKPREPAREROUTEREPLYTX1 = 0x3241,
+ NWKROUTEREPLY_NWKPREPAREROUTEREPLYTX2 = 0x3242,
+ NWKROUTEREPLY_NWKPREPAREPAYLOADOFROUTEREPLY0 = 0x3243,
+ NWKROUTEREPLY_NWKCONFIRMROUTEREPLYTX0 = 0x3244,
+ NWKROUTEREPLY_NWKCONFIRMROUTEREPLYTX1 = 0x3245,
+ NWKROUTINGTABLE_NWKRESETROUTINGTABLE0 = 0x3250,
+ NWKROUTINGTABLE_NWKUPDATEROUTINGENTRY0 = 0x3251,
+ NWKROUTINGTABLE_NWKALLOCROUTINGENTRY0 = 0x3252,
+ NWKROUTEREQUEST_NWKPREPAREROUTEREQUESTTX0 = 0x3260,
+ NWKROUTEREQUEST_NWKPREPAREROUTEREQUESTTX1 = 0x3261,
+ NWKROUTEDISCOVERY_NWKROUTEDISCOVERYREQ0 = 3270,
+ NWKROUTEDISCOVERY_NWKROUTEDISCOVERYCONF0 = 0x3271,
+ NWKROUTEDISCOVERY_NWKROUTEDISCOVERYCONF1 = 0x3272,
+ NWKROUTEDISCOVERY_NWKROUTEDISCOVERYTASKHANDLER0 = 0x3273,
+ NWKROUTEDISCOVERY_NWKROUTEDISCOVERYTASKHANDLER1 = 0x3274,
+ NWKROUTEDISCOVERY_NWKROUTEDISCOVERYTASKHANDLER2 = 0x3275,
+ NWKRDTABLE_NWKSENDROUTEDISCOVERYREQUEST0 = 0x3280,
+ NWKRDTABLE_NWKSENDROUTEDISCOVERYREPLY0 = 0x3281,
+ NWKRDTABLE_NWKFREEROUTEDISCOVERYTABLE0 = 0x3282,
+ NWKRDTABLE_NWKCONFIRMROUTEREQUESTTX0 = 0x3283,
+ NWKRDTABLE_NWKRESETROUTEDISCOVERYTABLE0 = 0x3284,
+ NWKRDTABLE_NWKROUTEDISCOVERYTABLETASKHANDLER0 = 0x3285,
+ NWKROUTECACHE_NWKFINDROUTERECORD0 = 0x3290,
+ NWKROUTECACHE_NWKADDROUTERECORD0 = 0x3291,
+ NWKROUTECACHE_NWKADDROUTERECORD1 = 0x3292,
+ NWKROUTECACHE_NWKRESETROUTECACHE0 = 0x3293,
+ NWKROUTERECORD_NWKPREPAREROUTERECORDTX0 = 0x3300,
+ NWKROUTERECORD_NWKPREPAREHEADEROFROUTERECORD0 = 0x3301,
+ NWKROUTERECORD_NWKCONFIRMROUTERECORDTX1 = 0x3302,
+ NWKROUTERECORD_NWKCONFIRMROUTERECORDTX0 = 0x3303,
+ NWKROUTERECORD_NWKFORMATIONTASKHANDLER2 = 0x3304,
+ NWKROUTERECORD_NWKFORMATIONTASKHANDLER1 = 0x3305,
+ NWKROUTERECORD_NWKFORMATIONTASKHANDLER0 = 0x3306,
+ NWKROUTERECORD_NWKROUTERECORDREQ0 = 0x3307,
+ NWKROUTERECORD_NWKROUTERECORDREQ1 = 0x3308,
+ NWKSOURCEROUTING_NWKUSESOURCEROUTING0 = 0x3310,
+ NWKSOURCEROUTING_NWKUSESOURCEROUTING1 = 0x3311,
+ NWKSOURCEROUTING_NWKPREPARESOURCEROUTETX0 = 0x3312,
+ NWKSOURCEROUTING_NWKPREPARESOURCEROUTETX1 = 0x3313,
+ NWKSOURCEROUTING_NWKPREPARETRANSITSOURCEROUTETX0 = 0x3314,
+ NWKSOURCEROUTING_NWKPREPARETRANSITSOURCEROUTETX1 = 0x3315,
+ NWKDIRECTJOIN_NWKDIRECTJOINTASKHANDLER0 = 0x3320,
+ NWKDIRECTJOIN_NWKDIRECTJOINTASKHANDLER1 = 0x3321,
+ NWKORPHAN_NWKORPHANTASKHANDLER0 = 0x3330,
+ NWKORPHAN_NWKORPHANTASKHANDLER1 = 0x3331,
+ NWKORPHAN_NWKORPHANSCANCONF0 = 0x3340,
+ NWKORPHAN_CONFIRMREQUEST0 = 0x3341,
+ NWKORPHAN_NWKORPHANCOMMSTATUSIND0 = 0x3350,
+ NWKORPHAN_NWKORPHANGETCONF0 = 0x3360,
+ NWKORPHAN_NWKORPHANGETCONF1 = 0x3361,
+ NWKORPHAN_NWKORPHANSETCONF0 = 0x3370,
+ NWKORPHAN_NWKORPHANSETCONF1 = 0x3371,
+ NWKORPHAN_NWKORPHANREQ0 = 0x3380,
+ NWKMANYTOONE_NWKSHORTADDROFCONCENTRATOR0 = 0x3390,
+ NWKMANYTOONE_NWKSHORTADDROFCONCENTRATOR1 = 0x3391,
+ NWKMANYTOONE_NWKNEXTHOPTOCONCENTRATOR0 = 0x3392,
+ NWKMANYTOONE_NWKNEXTHOPTOCONCENTRATOR1 = 0x3393,
+ NWKMANYTOONE_NWKNEXTCONCENTRATOR0 = 0x3394,
+ NWKMANYTOONE_NWKNEXTCONCENTRATOR1 = 0x3495,
+ NWKMANYTOONE_NWKNEWCONCENTRATORFOUND0 = 0x3496,
+ NWKMANYTOONE_NWKMANYTOONETASKHANDLER0 = 0x3497,
+ NWKMANYTOONE_NWKMANYTOONETASKHANDLER1 = 0x3498,
+ NWKMANYTOONE_SUBSCRIBETOCONCENTRATORINFO = 0x3499,
+ NWKMANYTOONE_UNSUBSCRIBETOCONCENTRATORINFO = 0x349A,
+ NWKGROUP_NWKADDGROUP0 = 0x34A0,
+ NWKGROUP_NWKREMOVEGROUP0 = 0x34A1,
+ NWKGROUP_NWKISGROUPMEMBER0 = 0x34A2,
+ NWKGROUP_NWKREMOVEALLGROUPS0 = 0x34A3,
+ NWKSECURITY_NWKGETACTIVEKEYSEQNUMBER_0 = 0x34B0,
+ NWKSECURITY_NWKGETACTIVEKEY_0 = 0x34B1,
+ NWKSECURITY_NWKEXTRACTSECOUTCOUNTER_0 = 0x34B2,
+ NWKSECURITY_NWKRESETSECURITYIB_0 = 0x34B3,
+ NWKSYSTEM_MEMCPYCHECKOVERLAP0 = 0x34C0,
+ NWKROUTING_TRANSMITCOUNTEROVERFLOW0 = 0x34D0,
+ NWKROUTING_TRANSMITFAILURECOUNTEROVERFLOW0 = 0x34D1,
+ NWKSILENTJOIN_NWKSILENTJOINREQ0 = 0x34E0,
+ NWKSILENTJOIN_NWKSILENTJOINTASKHANDLER0 = 0x34E1,
+ NWKSILENTJOIN_NWKSILENTJOINTASKHANDLER1 = 0x34E2,
+ NWKSILENTJOIN_NWKSILENTJOINSETCONF0 = 0x34E3,
+ NWKSILENTJOIN_NWKSILENTJOINSETCONF1 = 0x34E4,
+ NWKPASSIVEACK_NWKNEWPASSIVEACK0 = 0x34F0,
+ NWKPASSIVEACK_NWKNEWPASSIVEACK1 = 0x34F1,
+ NWKPASSIVEACK_NWKTRACEPASSIVEACK0 = 0x34F2,
+ NWKPASSIVEACK_NWKISPASSIVEACKDONE0 = 0x34F3
+} NwkDbgCode_t;
+
+/** Values of system log messages */
+typedef enum _NwkLogCodeId_t
+{
+ LOG_NWK_DATA_REQ = 0x00,
+ LOG_NWK_DATA_REQ_NO_ASSOC = 0x01,
+ LOG_NWK_DATA_REQ_INVALID_RADIUS = 0x02,
+ LOG_NWK_DATA_REQ_MULTICAST_NO_SUPPORT = 0x03,
+ LOG_NWK_DATA_REQ_INVALID_BROADCAST_ADDR = 0x04,
+ LOG_NWK_DATA_REQ_BTT_FULL = 0x05,
+ LOG_NWK_DATA_REQ_BTR_EXISTS = 0x06,
+ LOG_NWK_DATA_CONF = 0x07,
+ LOG_NWK_SSP_ENCRYPT_FRAME_REQ = 0x08,
+ LOG_NWK_ENCRYPT_OUTPUT_PACKET_SUCCESS = 0x09,
+ LOG_NWK_ENCRYPT_OUTPUT_PACKET_FAIL = 0x0A,
+ LOG_NWK_START_CONCENTRATOR = 0x0B,
+ LOG_NWK_STOP_CONCENTRATOR = 0x0C,
+ LOG_NWK_START_CONCENTRATOR_TIMER = 0x0D,
+ LOG_NWK_CONCENTRATOR_PREPARE_ROUTE_DISCOVERY = 0x0E,
+ LOG_NWK_CONCENTRATOR_ROUTE_DISCOVERY_SUCCESS = 0x0F,
+ LOG_NWK_CONCENTRATOR_ROUTE_DISCOVERY_FAIL = 0x10,
+ LOG_NWK_LOOPBACK_REQUEST = 0x11,
+ LOG_NWK_LOOPBACK_TASK_HANDLER = 0x12,
+ LOG_NWK_LOOPBACK_REQUEST_DONE = 0x13
+} NwkLogCodeId_t;
+
+#endif /* _NWK_DBG_H */
+/** eof nwkDbg.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkDirectJoin.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkDirectJoin.h
new file mode 100644
index 00000000..6b87b025
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkDirectJoin.h
@@ -0,0 +1,59 @@
+/*****************************************************************************
+ \file nwkDirectJoin.h
+
+ \brief Interface of directly join another device to network.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2010-03-17 I.Vagulin - Created.
+ Last change:
+ $Id: nwkDirectJoin.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_DIRECT_JOIN_H
+#define _NWKDIRECTJOIN_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <queue.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Direct join memory */
+typedef struct _NwkDirectJoin_t
+{
+ /** Request queue */
+ QueueDescriptor_t queue;
+} NwkDirectJoin_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if (defined(_ROUTER_) || defined(_COORDINATOR_)) && defined(_NWK_DIRECT_JOIN_)
+/**************************************************************************//**
+ \brief Reseting of the direct join module.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetDirectJoin(void);
+
+/**************************************************************************//**
+ \brief task handler of diret join module
+ ******************************************************************************/
+NWK_PRIVATE void nwkDirectJoinTaskHandler(void);
+#else
+
+#define nwkResetDirectJoin() (void)0
+#define nwkDirectJoinTaskHandler NULL
+
+#endif /* _NWK_DIRECT_JOIN_ and (_ROUTER_ or _COORDINATOR_) */
+#endif /* _NWK_DIRECT_JOIN_H */
+/** eof nwkDirectJoin.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkDiscovery.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkDiscovery.h
new file mode 100644
index 00000000..e526d94f
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkDiscovery.h
@@ -0,0 +1,73 @@
+/**************************************************************************//**
+ \file nwkDiscovery.h
+
+ \brief Discovery header file.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2007-06-14 S. Vladykin - Created.
+ 2008-12-10 M. Gekk - Reduction of the used RAM.
+ 2009-04-06 M. Gekk - Refactoring.
+ Last change:
+ $Id: nwkDiscovery.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_DISCOVERY_H
+#define _NWK_DISCOVERY_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <queue.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Internal states of NLME-NETWORK-DISCOVERY component */
+typedef enum _NwkDiscoveryState_t
+{
+ NWK_DISCOVERY_IDLE_STATE = 0xD6,
+ NWK_DISCOVERY_FIRST_STATE = 0x70,
+ NWK_DISCOVERY_BEGIN_STATE = NWK_DISCOVERY_FIRST_STATE,
+ NWK_DISCOVERY_MAC_SCAN_STATE = 0x71,
+ NWK_DISCOVERY_CONFIRM_STATE = 0x72,
+ NWK_DISCOVERY_LAST_STATE
+} NwkDiscoveryState_t;
+
+/** Internal parameters of NLME-NETWORK-DISCOVERY */
+typedef struct _NwkDiscovery_t
+{
+ QueueDescriptor_t queue; /**< Queue of requests from upper layer */
+ NwkDiscoveryState_t state; /**< finite-state machine */
+} NwkDiscovery_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Main task handler of NLME-NETWORK-DISCOVERY component
+ ******************************************************************************/
+NWK_PRIVATE void nwkDiscoveryTaskHandler(void);
+
+/**************************************************************************//**
+ \brief Reset NLME-NETWORK-DISCOVERY component
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetDiscovery(void);
+
+/******************************************************************************
+ \brief nwkDiscovery idle checking.
+
+ \return true, if nwkDiscovery performs no activity, false - otherwise.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkDiscoveryIsIdle(void);
+
+#endif /* _NWK_DISCOVERY_H */
+/** eof nwkDiscovery.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkEDScan.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkEDScan.h
new file mode 100644
index 00000000..654a1972
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkEDScan.h
@@ -0,0 +1,75 @@
+/**************************************************************************//**
+ \file nwkEDScan.h
+
+ \brief EDScan header file.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2007-06-14 S. Vladykin - Created.
+ 2008-12-10 M. Gekk - Reduction of the used RAM.
+ 2009-03-15 M. Gekk - Refactoring.
+ Last change:
+ $Id: nwkEDScan.h 17448 2011-06-09 13:53:59Z ataradov $
+ *****************************************************************************/
+#if !defined _NWK_EDSCAN_H
+#define _NWK_EDSCAN_H
+
+/*****************************************************************************
+ Includes section
+ *****************************************************************************/
+#include <nwkConfig.h>
+#include <queue.h>
+#include <nwkCommon.h>
+
+/*****************************************************************************
+ Types section
+ *****************************************************************************/
+/** Internal states of NLME-ED-SCAN component */
+typedef enum _NwkEDScanState_t
+{
+ NWK_EDSCAN_IDLE_STATE = 0x13,
+ NWK_EDSCAN_FIRST_STATE = 0xE7,
+ NWK_EDSCAN_BEGIN_STATE = NWK_EDSCAN_FIRST_STATE,
+ NWK_EDSCAN_MAC_SCAN_STATE = 0xE8,
+ NWK_EDSCAN_CONFIRM_STATE = 0xE9,
+ NWK_EDSCAN_LAST_STATE
+} NwkEDScanState_t;
+
+/** Internal parameters of NLME-ED-SCAN */
+typedef struct _NwkEDScan_t
+{
+ QueueDescriptor_t queue; /**< Queue of requests from upper layer */
+ NwkEDScanState_t state; /**< finite-state machine */
+ NwkState_t savedStateMachine;
+} NwkEDScan_t;
+
+/*****************************************************************************
+ Prototypes section
+ *****************************************************************************/
+/*************************************************************************//**
+ \brief Reset NLME-ED-SCAN component.
+ *****************************************************************************/
+NWK_PRIVATE void nwkResetEDScan(void);
+
+/******************************************************************************
+ \brief nwkEDScan idle checking.
+
+ \return true, if nwkEDScan performs no activity, false - otherwise.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkEDScanIsIdle(void);
+
+/*************************************************************************//**
+ \brief Main task handler of NLME-ED-SCAN
+ *****************************************************************************/
+NWK_PRIVATE void nwkEDScanTaskHandler(void);
+
+#endif /* _NWK_EDSCAN_H */
+/** eof nwkEDScan.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkFormation.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkFormation.h
new file mode 100644
index 00000000..c383cbaf
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkFormation.h
@@ -0,0 +1,92 @@
+/**************************************************************************//**
+ \file nwkFormation.h
+
+ \brief Formation header file.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2007-06-14 S. Vladykin - Created.
+ 2008-12-19 M. Gekk - Numbers are added to enum of state.
+ 2009-03-24 M. Gekk - Refactoring.
+ Last change:
+ $Id: nwkFormation.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_FORMATION_H
+#define _NWK_FORMATION_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <types.h>
+#include <queue.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Internal states of NLME-NETWORK-FORMATION component */
+typedef enum _NwkFormationState_t
+{
+ NWK_FORMATION_IDLE_STATE = 0xB7,
+ NWK_FORMATION_FIRST_STATE = 0x54,
+ NWK_FORMATION_BEGIN_STATE = NWK_FORMATION_FIRST_STATE,
+ NWK_FORMATION_MAC_REALIGNMENT_STATE = 0x55,
+ NWK_FORMATION_MAC_ACTIVE_SCAN_STATE = 0x56,
+ NWK_FORMATION_MAC_ED_SCAN_STATE = 0x57,
+ NWK_FORMATION_CONFIRM_STATE = 0x58,
+ NWK_FORMATION_SET_SHORT_ADDR_STATE = 0x59,
+ NWK_FORMATION_SET_BEACON_PAYLOAD_LEN_STATE = 0x5A,
+ NWK_FORMATION_SET_BEACON_PAYLOAD_STATE = 0x5B,
+ NWK_FORMATION_SET_RX_ON_WHEN_IDLE_STATE = 0x5C,
+ NWK_FORMATION_MAC_START_STATE = 0x5D,
+ NWK_FORMATION_RX_ENABLE_STATE = 0x5E,
+ NWK_FORMATION_SET_TRANSACTION_TIME_STATE = 0x5F,
+ NWK_FORMATION_LAST_STATE
+} NwkFormationState_t;
+
+/** Internal parameters of NLME-NETWORK-FORMATION component. */
+typedef struct _NwkFormation_t
+{
+ QueueDescriptor_t queue; /**< Queue of requests from upper layer. */
+ NwkFormationState_t state; /**< finite-state machine. */
+ bool coordRealignment;
+} NwkFormation_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined _COORDINATOR_
+/**************************************************************************//**
+ \brief Main task handler of NLME-NETWORK-FORMATION component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkFormationTaskHandler(void);
+
+/**************************************************************************//**
+ \brief Reset NLME-NETWORK-FORMATION component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetFormation(void);
+
+/******************************************************************************
+ \brief nwkFormation idle checking.
+
+ \return true, if nwkFormation performs no activity, false - otherwise.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkFormationIsIdle(void);
+
+#else /* not defined _COORDINATOR_ */
+
+#define nwkFormationTaskHandler NULL
+#define nwkFormationIsIdle NULL
+#define nwkResetFormation() (void)0
+
+#endif /* _COORDINATOR_ */
+#endif /* _NWK_FORMATION_H */
+/** eof nwkFormation.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkFrame.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkFrame.h
new file mode 100644
index 00000000..2a6781a5
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkFrame.h
@@ -0,0 +1,363 @@
+/**************************************************************************//**
+ \file nwkFrame.h
+
+ \brief Network frames header file.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2007-07-01 S. Vladykin - Created.
+ 2009-06-12 M. Gekk - Refactoring.
+ Last change:
+ $Id: nwkFrame.h 18245 2011-08-16 09:23:15Z arazinkov $
+ ******************************************************************************/
+#if !defined _NWK_FRAME_H
+#define _NWK_FRAME_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <types.h>
+#include <nwkSystem.h>
+#include <appFramework.h>
+#include <nwkCommon.h>
+
+/******************************************************************************
+ Define(s) section
+ ******************************************************************************/
+#define NWK_HEADER(outPkt) ((NwkFrameHeader_t *)(NWK_GET_OUTPKT_DATA(outPkt)))
+#define IS_DATA(nwkHeader) \
+ (NWK_FRAMETYPE_DATA == (nwkHeader)->frameControl.frameType)
+#define IS_COMMAND(nwkHeader) \
+ (NWK_FRAMETYPE_COMMAND == (nwkHeader)->frameControl.frameType)
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Values of the Frame Type Sub-Field. ZigBee spec r17, Table 3.37. */
+typedef enum _NwkFrameTypeFlag_t
+{
+ NWK_FRAMETYPE_DATA = 0,
+ NWK_FRAMETYPE_COMMAND = 1,
+/**//**
+ * \brief Inter-PAN delivery modes
+ * ZigBee Smart Energy profile specification r15
+ * B.4 Frame Format, page 90
+ */
+ NWK_FRAMETYPE_INTERPAN = 3
+} NwkFrameTypeFlag_t;
+
+/** Values of the Discover Route Sub-Field. ZigBee spec r17, Table 3.38. */
+typedef enum _NwkDiscoverRouteFlag_t
+{
+ NWK_DISCOVER_ROUTE_SUPPRESS = 0,
+ NWK_DISCOVER_ROUTE_ENABLE = 1
+} NwkDiscoverRouteFlag_t;
+
+/** Values of the Multicast Mode Sub-Field. ZigBee spec r17, Table 3.39. */
+typedef enum _NwkMulticastMode_t
+{
+ NWK_FRAME_MULTICAST_NON_MEMBER_MODE = 0,
+ NWK_FRAME_MULTICAST_MEMBER_MODE = 1
+} NwkMulticastMode_t;
+
+/** NWK command frame identifiers. ZigBee spec r17, Table 3.40. */
+typedef enum _NwkCmdIdentifier_t
+{
+ NWK_CMD_ROUTE_REQUEST = 0x01, /**< ZigBee spec r17, 3.4.1 */
+ NWK_CMD_ROUTE_REPLY = 0x02, /**< ZigBee spec r17, 3.4.2 */
+ NWK_CMD_NETWORK_STATUS = 0x03, /**< ZigBee spec r17, 3.4.3 */
+ NWK_CMD_LEAVE = 0x04, /**< ZigBee spec r17, 3.4.4 */
+ NWK_CMD_ROUTE_RECORD = 0x05, /**< ZigBee spec r17, 3.4.5 */
+ NWK_CMD_REJOIN_REQUEST = 0x06, /**< ZigBee spec r17, 3.4.6 */
+ NWK_CMD_REJOIN_RESPONSE = 0x07, /**< ZigBee spec r17, 3.4.7 */
+ NWK_CMD_LINK_STATUS = 0x08, /**< ZigBee spec r17, 3.4.8 */
+ NWK_CMD_NETWORK_REPORT = 0x09, /**< ZigBee spec r17, 3.4.9 */
+ NWK_CMD_NETWORK_UPDATE = 0x0a /**< ZigBee spec r17, 3.4.10 */
+} NwkCmdIdentifier_t;
+
+/** Type of command id field. */
+typedef uint8_t NwkCommandIdField_t;
+
+/** Frame Control Field. ZigBee spec r17, 3.3.1.1, page 308. */
+/* The frame control field is 16 bits in length and contains
+ * information defining the frame type, addressing and sequencing
+ * fields and other control flags.*/
+BEGIN_PACK
+typedef struct PACK _NwkFrameControl_t
+{
+ LITTLE_ENDIAN_OCTET(3, (
+ /** The frame type sub-field is 2 bits in length and shall be set to one of
+ * the nonreserved values: NWK_FRAMETYPE_DATA or NWK_FRAMETYPE_COMMAND. */
+ NwkBitField_t frameType : 2,
+ /** The protocol version sub-field shall be set to a number reflecting
+ * the ZigBee NWK protocol version in use. The protocol version in use
+ * on a particular device shall be made available as the value of
+ * the NWK constant nwkcProtocolVersion. */
+ NwkBitField_t protocolVersion : 4,
+ /** The discover route sub-field may be used to control route discovery
+ * operations for the transit of this frame. */
+ NwkBitField_t discoverRoute : 2
+ ))
+ LITTLE_ENDIAN_OCTET(6, (
+ /** The multicast flag sub-field is 1 bit in length and has the value 0
+ * if the frame is a unicast or broadcast frame and the value 1 if it is
+ * a multicast frame. The multicast control field of the NWK header shall
+ * be present only if the multicast flag has the value 1.
+ * ZigBee spec r17, 3.3.1.1.4, page 309. */
+ NwkBitField_t multicastFlag : 1,
+ /** The security sub-field shall have a value of 1 if, and only if,
+ * the frame is to have NWK security operations enabled. If security for
+ * this frame is implemented at another layer or disabled entirely,
+ * it shall have a value of 0. */
+ NwkBitField_t security : 1,
+ /** The source route sub-field shall have a value of 1 if and only
+ * if a source route subframe is present in the NWK header.
+ * ZigBee spec r17, 3.3.1.1.6, page 308. */
+ NwkBitField_t sourceRoute : 1,
+ /** The destination IEEE address sub-field shall have a value of 1 if,
+ * and only if, the NWK header is to include the full IEEE address
+ * of the destination. */
+ NwkBitField_t dstExtAddr : 1,
+ /** The source IEEE address sub-field shall have a value of 1 if, and
+ * only if, the NWK header is to include the full IEEE address
+ * of the source device. */
+ NwkBitField_t srcExtAddr : 1,
+ NwkBitField_t reserved : 3
+ ))
+} NwkFrameControl_t;
+END_PACK
+
+/** Type of unaligned extended IEEE address. */
+BEGIN_PACK
+typedef union PACK _NwkFrameExtAddr_t
+{
+ ExtAddr_t value;
+ uint8_t raw[sizeof(ExtAddr_t)];
+} NwkFrameExtAddr_t;
+END_PACK
+
+/** The multicast control sub-field is 1 octet in length and shall only be
+ * present if the multicast flag sub-field has a value of 1. It is divided into
+ * three sub-fields as illustrated in ZigBee spec r17, Figure 3.7. */
+BEGIN_PACK
+typedef struct PACK _NwkFrameMulticastField_t
+{
+ LITTLE_ENDIAN_OCTET(3, (
+ /** The multicast mode sub-field indicates whether the frame is to be
+ * transmitted using member or non-member mode. Member mode is used to
+ * propagate multicasts between the devices that are members of
+ * the destination group. Nonmember mode is used to transmit a multicast
+ * frame from a device that is not a member of the multicast group to
+ * a device that is a member of the multicast group. */
+ NwkBitField_t mode : 2,
+ /** The nonmember radius sub-field indicates the range of a member mode
+ * multicast when relayed by devices that are not members of the
+ * destination group. */
+ NwkBitField_t nonMemberRadius : 3,
+ /** The maximum value of the NonmemberRadius sub-field for this frame.
+ * ZigBee spec r17, 3.3.1.8.3, page 312. */
+ NwkBitField_t maxNonMemberRadius : 3
+ ))
+} NwkFrameMulticastField_t;
+END_PACK
+
+/** Source route subframe format. ZigBee spec r18, Figure 3.8, page 316. */
+BEGIN_PACK
+typedef struct PACK _NwkSourceRouteSubframe_t
+{
+ /** The relay count sub-field indicates the number of relays contained in
+ * the relay list. ZigBee spec r18, 3.3.1.9.1, page 316. */
+ uint8_t relayCount;
+ /** The relay index sub-field indicates the index of the next relay in
+ * the relay list subfield to which the packet will be transmitted.
+ * ZigBee spec r18, 3.3.1.9.2, page 316. */
+ uint8_t relayIndex;
+ /** The relay list sub-field shall contain the list of relay addresses.
+ * ZigBee spec r18, 3.3.1.9.3, page 316. */
+ ShortAddr_t relayList[NWK_MAX_SOURCE_ROUTE];
+} NwkSourceRouteSubframe_t;
+END_PACK
+
+/** Type of parsed NWK header. */
+typedef struct _NwkParseHeader_t
+{
+ /** Pointer to a destination extended address in a original NWK header. */
+ const NwkFrameExtAddr_t *dstExt;
+ /** Pointer to a source extended address in a original NWK header. */
+ const NwkFrameExtAddr_t *srcExt;
+ /** Pointer to a multicast field. */
+ NwkFrameMulticastField_t *multicast;
+ /** Pointer to a source route subframe. */
+ NwkSourceRouteSubframe_t *sourceRouteSubframe;
+ /** Pointer to first octet of NWK payload. */
+ uint8_t *payload;
+ /** Size of NWK header in octets. */
+ NwkLength_t headerSize;
+ /** Size of NWK payload in octets. */
+ NwkLength_t payloadSize;
+ /** Source MAC short address. */
+ ShortAddr_t macSrcAddr;
+ /** Link quality indicator of received frame. */
+ Lqi_t lqi;
+ /** Received signal strength indication. */
+ Rssi_t rssi;
+ /** Extended address from auxilary header. It's address of previous hop. */
+ ExtAddr_t auxExtAddr;
+} NwkParseHeader_t;
+
+/** Type of a NWK header, which comprises frame control, addressing
+ * and sequencing information. */
+BEGIN_PACK
+typedef struct PACK _NwkFrameHeader_t
+{
+ /** The frame control field shall be formatted as illustrated in
+ * ZigBee spec r17, Figure 3.6. */
+ NwkFrameControl_t frameControl;
+ /** The destination address field shall always be present and shall be 2
+ * octets in length. If the multicast flag sub-field of the frame control
+ * field has the value 0, the destination address field shall hold the 16-bit
+ * network address of the destination device or a broadcast address
+ * (see Table 3.54). If the multicast flag sub-field has the value 1,
+ * the destination address field shall hold the 16-bit Group ID of the
+ * destination multicast group. ZigBee spec r17, 3.3.1.2, page 310. */
+ ShortAddr_t dstAddr;
+ /** The source address field shall always be present. It shall always be 2
+ * octets in length and shall hold the network address of the source device of
+ * the frame. ZigBee spec r17, 3.3.1.3, page 310. */
+ ShortAddr_t srcAddr;
+ /** The radius field shall always be present. It will be 1 octet in length and
+ * specifies the range of a radius-limited transmission. The field shall be
+ * decremented by 1 by each receiving device. */
+ NwkRadius_t radius;
+ /** The sequence number field is present in every frame and is 1 octet
+ * in length. The sequence number value shall be incremented by 1 with each
+ * new frame transmitted */
+ NwkSequenceNumber_t sequenceNumber;
+ union PACK
+ {
+ struct PACK
+ {
+ /** The destination IEEE address field, if present, contains the 64-bit
+ * IEEE address corresponding to the 16-bit network address contained in
+ * the destination address field of the NWK header.
+ * ZigBee spec r17, 3.3.1.6, page 310. */
+ NwkFrameExtAddr_t dstExt;
+ /** The source IEEE address field, if present, contains the 64-bit
+ * IEEE address corresponding to the 16-bit network address contained
+ * in the source address field. */
+ NwkFrameExtAddr_t srcExt;
+ uint8_t payload[1];
+ } dst_src;
+ struct PACK
+ {
+ NwkFrameExtAddr_t srcExt;
+ uint8_t payload[1];
+ } src;
+ struct PACK
+ {
+ /** The multicast control sub-field is 1 octet in length and shall only
+ * be present if the multicast flag sub-field has a value of 1. It is
+ * divided into three sub-fields as illustrated in ZigBee spec r17,
+ * Figure 3.7. */
+ NwkFrameMulticastField_t control;
+ uint8_t payload[1];
+ } multicast;
+ struct PACK
+ {
+ NwkFrameExtAddr_t dstExt;
+ NwkFrameExtAddr_t srcExt;
+ NwkFrameMulticastField_t control;
+ uint8_t payload[1];
+ } dst_src_multicast;
+ /** First octet of NWK payload. */
+ uint8_t payload[1];
+ } field;
+} NwkFrameHeader_t;
+END_PACK
+
+/** The beacon payload shall contain the information shown in ZigBee spec r17,
+ * Table 3.56. This enables the NWK layer to provide additional information
+ * to new devices that are performing network discovery and allows these new
+ * devices to more efficiently select a network and a particular neighbor
+ * to join. */
+BEGIN_PACK
+typedef struct PACK _NwkBeaconPayload_t
+{
+ /** This field identifies the network layer protocols in use and,
+ * for purposes of this specification, shall always be set to 0,
+ * indicating the ZigBee protocols. */
+ uint8_t protocolId;
+ struct PACK
+ {
+ LITTLE_ENDIAN_OCTET(2, (
+ /** A ZigBee stack profile identifier. */
+ NwkBitField_t stackProfile :4,
+ /** The version of the ZigBee protocol. */
+ NwkBitField_t nwkProtocolVersion :4
+ ))
+ LITTLE_ENDIAN_OCTET(4, (
+ NwkBitField_t reserved :2,
+ /** This value is set to 1 if this device is capable of accepting join
+ * requests from router capable devices and is set to 0 otherwise. */
+ NwkBitField_t routerCapacity :1,
+ /** The network depth of this device. A value of 0x00 indicates that
+ * this device is the ZigBee coordinator for the network. */
+ NwkBitField_t deviceDepth :4,
+ /** This value is set to 1 if the device is capable of accepting join
+ * requests from end devices seeking to join the network and is set
+ * to 0 otherwise. */
+ NwkBitField_t endDeviceCapacity :1
+ ))
+ } field;
+ /** The globally unique ID for the PAN of which the beaconing
+ * device is a member. */
+ ExtPanId_t nwkExtendedPanid;
+ /** This value indicates the difference in time, measured in symbols,
+ * between the beacon transmission time of the device and the beacon
+ * transmission time of its parent. */
+ uint8_t txOffset[3];
+ /** This field reflects the value of nwkUpdateId from the NIB. */
+ NwkUpdateId_t updateId;
+} NwkBeaconPayload_t;
+END_PACK
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/******************************************************************************
+ \brief Clear frame, then fill it with commonly used fields.
+
+ \param[in] nwkHeader - pointer to header.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkPrepareCommonFrame(NwkFrameHeader_t *const nwkHeader);
+
+/******************************************************************************
+ \brief Parse floating fields of frame.
+
+ \param[in] nwkHeader - header to parse.
+ \param[in] parse - structure with pointer to frame fields,
+ NULL - if field is not present, correct pointer otherwise.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkParseHeader(NwkFrameHeader_t *const nwkHeader,
+ NwkParseHeader_t *const parse);
+
+/**************************************************************************//**
+ \brief Gets maximum default radius. It's 2*maxDepth or 255.
+
+ \return 2 * maxDepth if maxDepth less 128 otherwise 255.
+ ******************************************************************************/
+NWK_PRIVATE NwkRadius_t nwkGetDefaultRadius(void);
+
+#endif /* _NWK_FRAME_H */
+/** eof nwkFrame.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkIB.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkIB.h
new file mode 100644
index 00000000..3db5b413
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkIB.h
@@ -0,0 +1,178 @@
+/**************************************************************************//**
+ \file nwkIB.h
+
+ \brief Network information base.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2009-05-01 M. Gekk - Created.
+ Last change:
+ $Id: nwkIB.h 18296 2011-08-19 12:29:05Z mgekk $
+ ******************************************************************************/
+#if !defined _NWK_IB_H
+#define _NWK_IB_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <types.h>
+#include <configServer.h>
+#include <nwkSystem.h>
+#include <mac.h>
+#include <nwkCommon.h>
+#include <nwkSecurity.h>
+#include <nwkSystem.h>
+#include <nwkFrame.h>
+#include <nlmeReset.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+typedef struct _NIB_t
+{
+ /*** Attributes are initialized by NWK-layer. ***/
+ /** A network address of parent node. */
+ ShortAddr_t parentNetworkAddress;
+ /** The count of total transmissions. */
+ uint16_t transmitCounter;
+ /** The count of transmissions with failures. */
+ uint16_t transmitFailureCounter;
+ /** The address of the designated network channel manager function. */
+ ShortAddr_t managerAddr;
+ /** This field shall contain the device capability information established at
+ * network joining time. */
+ MAC_CapabilityInf_t capabilityInformation;
+ /** The tree depth of the neighbor device. A value of 0x00 indicates that
+ * the device is the ZigBee coordinator for the network. */
+ NwkDepth_t depth;
+ /** A sequence number used to identify outgoing frames */
+ NwkSequenceNumber_t sequenceNumber;
+ /** The total delivery time for a broadcast transmission, i.e. the time
+ * required for a broadcast to be delivered to every device in the network. */
+ uint32_t networkBroadcastDeliveryTime;
+ /** The value identifying a snapshot of the network settings with which this
+ * node is operating with. */
+ NwkUpdateId_t updateId;
+ /** Network rejoin permissions, by default end devices and routers can rejoin. */
+ NWK_RejoinPermit_t rejoinPermit;
+
+ struct {
+ /** This field is used by MAC layer. */
+ NwkLength_t header[MAC_MAX_BEACON_HEADER_LENGTH];
+ /** The beacon payload contain the information which enables the NWK layer
+ * to provide additional information to new devices that are performing
+ * network discovery and allows these new devices to more efficiently select
+ * a network and a particular neighbor to join. */
+ NwkBeaconPayload_t payload;
+ } beacon;
+ /*** Attributes are initialized in Config Server. ***/
+ /** The type of the device:
+ * - 0x00 - zigbee coordinator
+ * - 0x01 - zigbee router
+ * - 0x02 - zigbee end device */
+ DeviceType_t deviceType;
+ /** A value that determines the method used to assign addresses:
+ * - 0x00 = use distributed address allocation
+ * - 0x01 = reserved
+ * - 0x02 = use stochastic address allocation. */
+ NWK_AddrAlloc_t addrAlloc;
+ /** The current route symmetry setting. 1 means that routes are considered to
+ * be comprised of symmetric links. Backward and forward routes are created
+ * during one-route discovery and they are identical. 0 indicates that routes
+ * are not consider to be comprised of symmetric links. Only the forward route
+ * is stored during route discovery.*/
+ bool symLink;
+ /** Determines whether or not the static addressing mode will be used.
+ * If set to '1' then the device must use a static network address
+ * otherwise, the stochastic addressing mode will be employed. */
+ bool uniqueAddr;
+ /** The identifier of the ZigBee stack profile in use for this device. */
+ StackProfile_t stackProfile;
+ /** The version of the ZigBee NWK protocol in the device. */
+ uint8_t protocolVersion;
+ /** The depth a device can have. */
+ NwkDepth_t maxDepth;
+ /** Route to neighbor directly only if the incoming cost is less than given
+ * threshold. */
+ NwkLinkCost_t maxNeighborRouteCost;
+ /** RF channel page */
+ uint8_t channelPage;
+ /** Number of RF channel */
+ Channel_t logicalChannel;
+ /** The 16-bit address that the device uses to communicate with the PAN. */
+ ShortAddr_t networkAddress;
+ /** The short (16-bit) pan identifier of a zigbee network. */
+ PanId_t panId;
+ /** The Extended PAN Identifier for the PAN of which the device is a member.
+ * The value 0x0000000000000000 means the Extended PAN Identifier is unknown.
+ **/
+ ExtPanId_t extendedPanId;
+ /** The number of routers any one device is allowed to have as children. */
+ NwkChildCount_t maxRouters;
+ /** The number of end devices any one device is allowed to have as children.
+ **/
+ NwkChildCount_t maxEndDevices;
+#if defined _SECURITY_
+ /** Pointer to the security information base. */
+ NWK_SecurityIB_t securityIB;
+#endif /* _SECURITY_ */
+} NIB_t;
+
+/******************************************************************************
+ Definitions section
+ ******************************************************************************/
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Reset the network information base.
+
+ \param[in] powerFailureControl - stack restoring after power failure control bitfield;
+ affects on initialization procedure.
+ \param[in] capabilityInformation - this parameter shall contain the device
+ capability information. See ZigBee spec r18, Table 3.47, page 356.
+
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetNib(const NWK_PowerFailureControl_t powerFailureControl,
+ const MAC_CapabilityInf_t capabilityInformation);
+
+/**************************************************************************//**
+ \brief Update beacon payload depending on NIB values
+ ******************************************************************************/
+NWK_PRIVATE void nwkUpdateBeaconPayload(void);
+
+/**************************************************************************//**
+ \brief Set depth in NIB and update cSkips.
+
+ \param[in] depth - new value of depth.
+ ******************************************************************************/
+NWK_PRIVATE void nwkSetDepth(NwkDepth_t depth);
+
+/**************************************************************************//**
+ \brief Reload parameters from the config server.
+ ******************************************************************************/
+NWK_PRIVATE void nwkReloadNibFromConfigServer(void);
+
+#if defined _ROUTER_ || defined _ENDDEVICE_
+/**************************************************************************//**
+ \brief Set a network address of parent device.
+
+ \param[in] addr - short address of parent device.
+ ******************************************************************************/
+NWK_PRIVATE void nwkSetParentShortAddr(ShortAddr_t addr);
+
+#endif /* _ROUTER_ or _ENDDEVICE_ */
+
+#endif /* _NWK_IB_H */
+/** eof nwkIB.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkJoinInd.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkJoinInd.h
new file mode 100644
index 00000000..e2cddee0
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkJoinInd.h
@@ -0,0 +1,209 @@
+/**************************************************************************//**
+ \file nwkJoinInd.h
+
+ \brief Join indication header file.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2007-06-14 S. Vladykin - Created.
+ 2008-12-10 M. Gekk - Optimization of NWK memory.
+ 2009-02-13 M. Gekk - Refactoring.
+ Last change:
+ $Id: nwkJoinInd.h 19021 2011-10-26 12:36:59Z mgekk $
+ ******************************************************************************/
+#if !defined _NWK_JOININD_H
+#define _NWK_JOININD_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <types.h>
+#include <mac.h>
+#include <nldeData.h>
+#include <nwkNeighbor.h>
+#include <nwkFrame.h>
+
+/******************************************************************************
+ Define(s) section
+ ******************************************************************************/
+#define NWK_JOIN_RESP_TX_PARAMETERS \
+ {NWK_TX_DELAY_UNICAST_COMMAND, nwkPrepareJoinRespTx, \
+ nwkConfirmJoinRespTx, true}
+
+#define NWK_ADDR_CONFLICT_JOIN_RESP_TX_PARAMETERS \
+ {NWK_TX_DELAY_UNICAST_COMMAND, nwkPrepareJoinRespTx, \
+ nwkConfirmAddrConflictJoinRespTx, true}
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Payload of rejoin response command */
+BEGIN_PACK
+typedef struct PACK
+{
+ NwkCommandIdField_t commandId;
+ /** If the rejoin was successful, this two-octet field contains the new
+ * network address assigned to the rejoining device. If the rejoin was
+ * not successful, this field contains the broadcast address (0xffff).
+ * ZigBee spec r17, 3.4.7.3.1. */
+ ShortAddr_t networkAddr;
+ /** This field shall contain one of the nonreserved association status values
+ **/
+ uint8_t rejoinStatus;
+} NwkRejoinRespCmd_t;
+END_PACK
+
+/** Service fields of rejoin response */
+typedef struct _NwkRejoinResp_t
+{
+ ExtAddr_t extendedAddr;
+ ShortAddr_t newNetworkAddr;
+ ShortAddr_t oldNetworkAddr;
+ uint8_t status;
+ bool secureJoin;
+} NwkRejoinResp_t;
+
+/** States of join indication object */
+typedef enum _NwkJoinIndObjState_t
+{
+ NWK_JOIN_IND_FREE_STATE = 0x00,
+ NWK_JOIN_IND_FIRST_STATE = 0x01,
+ NWK_JOIN_IND_PENDING_STATE = NWK_JOIN_IND_FIRST_STATE,
+ NWK_JOIN_IND_ASSOC_INDICATE_STATE = 0x02,
+ NWK_JOIN_IND_REJOIN_INDICATE_STATE = 0x03,
+ NWK_JOIN_IND_SEND_REJOIN_RESPONSE_STATE = 0x04,
+ NWK_JOIN_IND_SEND_ASSOC_RESPONSE_STATE = 0x05,
+ NWK_JOIN_IND_LAST_STATE
+} NwkJoinIndObjState_t;
+
+/** Join indication object */
+typedef struct _NwkJoinIndObj_t
+{
+ NwkJoinIndObjState_t state;
+ MAC_CapabilityInf_t capabilityInformation;
+ union
+ {
+ MAC_AssociateResp_t assoc;
+ NwkRejoinResp_t rejoin;
+ } resp;
+} NwkJoinIndObj_t;
+
+/** Array of join indication objects */
+typedef struct _NwkJoinInd_t
+{
+ uint8_t totalObjects;
+ NwkJoinIndObj_t *objects;
+} NwkJoinInd_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined _ROUTER_ || defined _COORDINATOR_
+/**************************************************************************//**
+ \brief Rejoin request has been received.
+
+ \param[in] payload - command payload pointer.
+ \param[in] header - command parameters.
+ \param[in] parse - source and destination extended address pointers.
+
+ \return 'true' if continue processing of command packet otherwise 'false'.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkRejoinRequestFrameInd(const uint8_t *const payload,
+ const NwkFrameHeader_t *const header, const NwkParseHeader_t *const parse);
+
+#if defined _RESOLVE_ADDR_CONFLICT_
+/**************************************************************************//**
+ \brief Reporting of end device address conflict.
+
+ \param[in] child - pointer to child's entry in the neighbor table.
+ ******************************************************************************/
+NWK_PRIVATE
+ void nwkSendUnsolicitedRejoinResponse(const NwkNeighbor_t *const child);
+#endif /* _RESOLVE_ADDR_CONFLICT_ */
+
+/**************************************************************************//**
+ \brief Task handler of join indication component
+ ******************************************************************************/
+NWK_PRIVATE void nwkJoinIndTaskHandler(void);
+
+/**************************************************************************//**
+ \brief Reset the join indication component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetJoinInd(void);
+
+/**************************************************************************//**
+ \brief Prepare header and payload of the rejoin response command.
+
+ \param[in] outPkt - pointer to output packet.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkPrepareJoinRespTx(NwkOutputPacket_t *const outPkt);
+
+/**************************************************************************//**
+ \brief Confirmation of rejoin response command transmission.
+
+ \param[in] outPkt - pointer to output packet.
+ \param[in] status - network status of rejoin response transmission.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkConfirmJoinRespTx(NwkOutputPacket_t *const outPkt,
+ const NWK_Status_t status);
+
+/**************************************************************************//**
+ \brief Adding child into table.
+ All required fields are filled. Address is allocated.
+
+ \param[in] extAddr - extended IEEE address of child.
+ \param[in] shortAddr - address that device selected for itself,
+ trying to keep it.
+ \param[in] capability - MAC capability information.
+
+ \return NULL if fail, or pointer to created record otherwise.
+ ******************************************************************************/
+NWK_PRIVATE NwkNeighbor_t* nwkAddChild(const ExtAddr_t extAddr,
+ ShortAddr_t shortAddr, const MAC_CapabilityInf_t capability);
+
+
+/******************************************************************************
+ \brief nwkJoinInd idle checking.
+
+ \return true, if nwkJoinInd performs no activity, false - otherwise.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkJoinIndIsIdle(void);
+
+/**************************************************************************//**
+ \brief Confirmation of address conflict rejoin response transmission.
+
+ \param[in] outPkt - pointer to output packet.
+ \param[in] status - network status of rejoin response transmission.
+ ******************************************************************************/
+#if defined _RESOLVE_ADDR_CONFLICT_
+NWK_PRIVATE
+ void nwkConfirmAddrConflictJoinRespTx(NwkOutputPacket_t *const outPkt,
+ const NWK_Status_t status);
+#else
+#define nwkConfirmAddrConflictJoinRespTx NULL
+#endif /* _RESOLVE_ADDR_CONFLICT_ */
+
+#else /* _ROUTER_ or _COORDINATOR_ are not defined. */
+
+#define nwkRejoinRequestFrameInd NULL
+#define nwkJoinIndTaskHandler NULL
+#define nwkResetJoinInd() (void)0
+#define nwkPrepareJoinRespTx NULL
+#define nwkConfirmJoinRespTx NULL
+#define nwkConfirmAddrConflictJoinRespTx NULL
+#define nwkJoinIndIsIdle NULL
+
+#endif /* _ROUTER_ or _COORDINATOR_ */
+#endif /* _NWK_JOININD_H */
+/** eof nwkJoinInd.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkJoinReq.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkJoinReq.h
new file mode 100644
index 00000000..d9875567
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkJoinReq.h
@@ -0,0 +1,172 @@
+/**************************************************************************//**
+ \file nwkJoinReq.h
+
+ \brief Join request header file.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2007-06-14 S. Vladykin - Created.
+ 2008-12-10 M. Gekk - Optimization of NWK memory.
+ 2009-02-09 M. Gekk - Refactoring.
+ Last change:
+ $Id: nwkJoinReq.h 17448 2011-06-09 13:53:59Z ataradov $
+******************************************************************************/
+#if !defined _NWK_JOINREQ_H
+#define _NWK_JOINREQ_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <queue.h>
+#include <mac.h>
+#include <nlmeJoin.h>
+#include <nldeData.h>
+#include <nlmeNetworkDiscovery.h>
+#include <nwkNeighbor.h>
+#include <nwkFrame.h>
+#include <appTimer.h>
+#include <nwkAddress.h>
+
+/******************************************************************************
+ Define(s) section
+ ******************************************************************************/
+#define NWK_JOIN_REQ_TX_PARAMETERS \
+ {NWK_TX_DELAY_UNICAST_COMMAND, nwkPrepareJoinReqTx, nwkConfirmJoinReqTx, true}
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Internal states of the join request component. */
+typedef enum _NwkJoinReqState_t
+{
+ JOIN_REQ_IDLE_STATE = 0xDA,
+ JOIN_REQ_FIRST_STATE = 0x21,
+ JOIN_REQ_GET_ELEM_FROM_QUEUE = JOIN_REQ_FIRST_STATE,
+ JOIN_REQ_CONFIRM_STATE = 0x22,
+ JOIN_REQ_ASSOCIATION_WAIT_STATE = 0x23,
+ JOIN_REQ_SET_BEACON_PAYLOAD_STATE = 0x24,
+ JOIN_REQ_SET_BEACON_PAYLOAD_LEN_STATE = 0x25,
+ JOIN_REQ_SET_RX_ON_WHEN_IDLE_STATE = 0x26,
+ JOIN_REQ_RX_ENABLE_STATE = 0x27,
+ JOIN_REQ_PKT_PREPARE_AND_SEND_STATE = 0x28,
+ JOIN_REQ_SET_PANID_STATE = 0x29,
+ JOIN_REQ_SET_CHANNEL_STATE = 0x2A,
+ JOIN_REQ_GET_RESPONSE_WAIT_TIME_STATE = 0x2B,
+ JOIN_REQ_WAIT_REJOIN_RESPONSE_DECRYPT = 0x2C,
+ JOIN_REQ_REJOIN_RESPONSE_WAITING_STATE = 0x2D,
+ JOIN_REQ_SET_SHORT_ADDRESS_STATE = 0x2E,
+ JOIN_REQ_SET_COORD_SHORT_ADDR_STATE = 0x2F,
+ JOIN_REQ_SET_COORD_EXT_ADDR_STATE = 0x30,
+ JOIN_REQ_SET_SHORT_ADDRESS_ONLY_STATE = 0x31,
+ JOIN_REQ_NETWORK_DISCOVERY_STATE = 0x32,
+ JOIN_REQ_SET_FIRST_SHORT_ADDRESS_STATE = 0x33,
+ JOIN_REQ_SET_TRANSACTION_TIME_STATE = 0x34,
+ JOIN_REQ_LAST_STATE
+} NwkJoinReqState_t;
+
+/** Format of rejoin command payload. ZigBee spec r17, 3.4.6.3, page 329. */
+/** The NWK frame payload contains a command identifier field and a capability
+ * information field. The command frame identifier shall contain the value
+ * indicating a rejoin request command frame. */
+BEGIN_PACK
+typedef struct PACK
+{
+ NwkCommandIdField_t commandId;
+ /** This one-octet field has the format of the capability information field
+ * in the association request command. ZigBee spec r17, 3.4.6.3.1, page 329. */
+ MAC_CapabilityInf_t capability;
+} NwkRejoinReqCmd_t;
+END_PACK
+
+/** Internal parameters of the join request component. */
+typedef struct _NwkJoinReq_t
+{
+ NwkJoinReqState_t state;
+ QueueDescriptor_t queue;
+ NWK_JoinReq_t *joinReq;
+ NwkNeighbor_t *currentCandidateRouter;
+ uint8_t attempNum;
+ HAL_AppTimer_t timer;
+ MAC_PollReq_t pollReq;
+ union
+ {
+ MAC_AssociateReq_t macAssoc;
+ MAC_SetReq_t macSet;
+ MAC_GetReq_t macGet;
+ MAC_RxEnableReq_t macRxEnable;
+ NWK_NetworkDiscoveryReq_t netDisc;
+ } req;
+} NwkJoinReq_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined _ROUTER_ || defined _ENDDEVICE_
+/**************************************************************************//**
+ \brief Action when command received.
+
+ \param[in] payload - a payload of network join request command.
+ \param[in] header - pointer to raw NWK header.
+ \param[in] parse - parsed header fields.
+
+ \return 'true' if continue processing of command packet otherwise 'false'.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkRejoinResponseFrameInd(const uint8_t *const payload,
+ const NwkFrameHeader_t *const header, const NwkParseHeader_t *const parse);
+
+/**************************************************************************//**
+ \brief Reset the join request component
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetJoinReq(void);
+
+/**************************************************************************//**
+ \brief Task handler of NWK join request component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkJoinReqTaskHandler(void);
+
+/**************************************************************************//**
+ \brief Prepare header and payload of the join request command.
+
+ \param[in] outPkt - pointer to output packet.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkPrepareJoinReqTx(NwkOutputPacket_t *const outPkt);
+
+/**************************************************************************//**
+ \brief Confirmation of join request command transmission.
+
+ \param[in] outPkt - pointer to output packet.
+ \param[in] status - network status of join request transmission.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkConfirmJoinReqTx(NwkOutputPacket_t *const outPkt,
+ const NWK_Status_t status);
+
+/******************************************************************************
+ \brief nwkJoinReq idle checking.
+
+ \return true, if nwkJoinReq performs no activity, false - otherwise.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkJoinReqIsIdle(void);
+
+#else /* _ROUTER_ or _ENDDEVICE_ */
+
+#define nwkRejoinResponseFrameInd NULL
+#define nwkResetJoinReq() (void)0
+#define nwkJoinReqTaskHandler NULL
+#define nwkPrepareJoinReqTx NULL
+#define nwkConfirmJoinReqTx NULL
+#define nwkJoinReqIsIdle NULL
+
+#endif /* _ROUTER_ or _ENDDEVICE_ */
+#endif /* _NWK_JOINREQ_H */
+/** eof nwkJoinReq.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkLeave.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkLeave.h
new file mode 100644
index 00000000..a66a10d7
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkLeave.h
@@ -0,0 +1,200 @@
+/**************************************************************************//**
+ \file nwkLeave.h
+
+ \brief Network leave header file.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2007-06-27 V. Panov - Created.
+ 2009-05-26 M. Gekk - Refactoring.
+ Last change:
+ $Id: nwkLeave.h 18970 2011-10-21 12:48:41Z mgekk $
+******************************************************************************/
+#if !defined _NWK_LEAVE_H
+#define _NWK_LEAVE_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <queue.h>
+#include <appFramework.h>
+#include <mac.h>
+#include <nwkNeighbor.h>
+#include <nwkFrame.h>
+#include <nldeData.h>
+#include <nlmeLeave.h>
+
+/******************************************************************************
+ Definitions section
+ ******************************************************************************/
+/** Size of NWK leave command payload. */
+#define NWK_LEAVE_CMD_PAYLOAD_SIZE 2U
+/** Total size of self leave command - NWK header + payload */
+#define NWK_LEAVE_ITSELF_CMD_SIZE 18U
+/** Total size of child leave command - NWK header + payload */
+#define NWK_LEAVE_CHILD_CMD_SIZE 26U
+/** Parameters of leave command transmission. */
+#define NWK_LEAVE_ITSELF_TX_PARAMETERS \
+ {NWK_TX_DELAY_BROADCAST, nwkPrepareLeaveItselfTx,\
+ nwkConfirmLeaveItselfTx, true}
+#define NWK_LEAVE_CHILD_TX_PARAMETERS \
+ {NWK_TX_DELAY_UNICAST_COMMAND, nwkPrepareLeaveChildTx,\
+ nwkConfirmLeaveChildTx, true}
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Internal states of NLME-LEAVE component */
+typedef enum _NwkLeaveState_t
+{
+ NWK_LEAVE_IDLE_STATE = 0xE6,
+ NWK_LEAVE_FIRST_STATE = 0x11,
+ NWK_LEAVE_BEGIN_STATE = NWK_LEAVE_FIRST_STATE,
+ NWK_LEAVE_SELF_SEND_CMD_STATE = 0x12,
+ NWK_LEAVE_SELF_WAIT_CONFIRM_STATE = 0x13,
+ NWK_LEAVE_SELF_RESET_MAC_STATE = 0x14,
+ NWK_LEAVE_CHILD_SEND_CMD_STATE = 0x15,
+ NWK_LEAVE_CHILD_WAIT_CONFIRM_STATE = 0x16,
+ NWK_LEAVE_CONFIRM_STATE = 0x17,
+ NWK_LEAVE_LAST_STATE
+} NwkLeaveState_t;
+
+/** Leave Command Options Field */
+typedef enum _NwkLeaveCommandOptionsField_t
+{
+ /** The Rejoin sub-field is a single-bit field. If the value of this
+ * sub-field is 1, the device that is leaving from its current parent
+ * will rejoin the network. If the value of this sub-field is 0, the device
+ * will not rejoin the network. ZigBee spec r17, 3.4.4.3.1.1, page 325. */
+ NWK_LEAVE_REJOIN = 0x20,
+ /** The request sub-field is a single-bit field. If the value of this
+ * sub-field is 1, then the leave command frame is a request for another
+ * device to leave the network. If the value of this sub-field is 0,
+ * then the leave command frame is an indication that the sending device
+ * plans to leave the network. ZigBee spec r17, 3.4.4.3.1.2, page 326. */
+ NWK_LEAVE_REQUEST = 0x40,
+ /** The remove children sub-field is a single-bit field. If this sub-field
+ * has a value of 1, then the children of the device that is leaving
+ * the network will also be removed. If this sub-field has a value of 0,
+ * then the children of the device leaving the network will not be removed.
+ * ZigBee spec r17, 3.4.4.3.1.3, page 326. */
+ NWK_LEAVE_REMOVE_CHILDREN = 0x80
+} NwkLeaveCommandOptionsField_t;
+
+/** Internal variables of NLME-LEAVE component. */
+typedef struct _NwkLeave_t
+{
+ /** Finite-state machine */
+ NwkLeaveState_t state;
+ /** Queue of requests from upper layer */
+ QueueDescriptor_t queue;
+ /** Number of children which has been excluded from a network. */
+ NwkSizeOfNeighborTable_t leaveChildCount;
+ union
+ {
+ /** MLME-RESET request primitive's parameters. */
+ MAC_ResetReq_t macReset;
+ struct
+ {
+ /** The short address of the leaved child. */
+ ShortAddr_t shortAddr;
+ /** The extended address of the leaved child. */
+ ExtAddr_t extAddr;
+ /** The bits indicate the transmission options for the MAC frame. */
+ MAC_TxOptions_t txOptions;
+ } child;
+ } param;
+#if defined _ROUTER_ && defined _NWK_DISTRIBUTED_ADDRESSING_
+ /** The leave indication component is busy or not. */
+ bool leaveIndBusy;
+ /** Leave request which is used by the leave indication component. */
+ NWK_LeaveReq_t leaveReq;
+#endif /* _ROUTER_ and _NWK_DISTRIBUTED_ADDRESSING_ */
+} NwkLeave_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Main task handler of NLME-LEAVE component
+ ******************************************************************************/
+NWK_PRIVATE void nwkLeaveTaskHandler(void);
+
+/**************************************************************************//**
+ \brief Reset NLME-LEAVE component
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetLeave(void);
+
+/**************************************************************************//**
+ \brief Action when a leave command is received.
+
+ \param[in] payload - pointer to NPDU of NWK leave command.
+ \param[in] header - NWK header.
+ \param[in] parse - parsed header fields.
+ \return 'true' if continue processing of command packet otherwise 'false'.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkLeaveFrameInd(const uint8_t *const payload,
+ const NwkFrameHeader_t *const header, const NwkParseHeader_t *const parse);
+
+/**************************************************************************//**
+ \brief Prepare header and payload of the leave itself command.
+
+ \param[in] outPkt - pointer to output packet.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkPrepareLeaveItselfTx(NwkOutputPacket_t *const outPkt);
+
+/**************************************************************************//**
+ \brief Confirmation of the leave itself command transmission.
+
+ \param[in] outPkt - pointer to output packet.
+ \param[in] status - network status of the leave command transmission.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkConfirmLeaveItselfTx(NwkOutputPacket_t *const outPkt,
+ const NWK_Status_t status);
+
+#if defined _ROUTER_ || defined _COORDINATOR_
+/**************************************************************************//**
+ \brief Prepare header and payload of the leave child command.
+
+ \param[in] outPkt - pointer to output packet.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkPrepareLeaveChildTx(NwkOutputPacket_t *const outPkt);
+
+/**************************************************************************//**
+ \brief Confirmation of the leave child command transmission.
+
+ \param[in] outPkt - pointer to output packet.
+ \param[in] status - network status of the leave command transmission.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkConfirmLeaveChildTx(NwkOutputPacket_t *const outPkt,
+ const NWK_Status_t status);
+
+/******************************************************************************
+ \brief nwkLeaveReq idle checking.
+
+ \return true, if nwkLeaveReq performs no activity, false - otherwise.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkLeaveReqIsIdle(void);
+
+#else /* _ROUTER_ or _COORDINATOR_ */
+
+#define nwkPrepareLeaveChildTx NULL
+#define nwkConfirmLeaveChildTx NULL
+#define nwkLeaveReqIsIdle NULL
+
+#endif /* _ROUTER_ or _COORDINATOR_ */
+#endif /* _NWK_LEAVE_H */
+/** eof nwkLeave.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkLinkStatus.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkLinkStatus.h
new file mode 100644
index 00000000..534672f5
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkLinkStatus.h
@@ -0,0 +1,194 @@
+/**************************************************************************//**
+ \file nwkLinkStatus.h
+
+ \brief The data structures concerning processing of LinkStatus command
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2007-08-01 V. Panov - Created.
+ 2009-04-10 M. Gekk - Refactoring.
+ Last change:
+ $Id: nwkLinkStatus.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+/**//**
+ * The link status command frame allows neighboring routers to communicate
+ * their incoming link costs to each other as described in sub-clause 3.6.3.4.
+ * Link status frames are transmitted as one-hop broadcasts without retries.
+ * ZigBee spec r17, 3.4.8, page 330.
+ * */
+#if !defined _NWK_LINK_STATUS_H
+#define _NWK_LINK_STATUS_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <nwkSystem.h>
+#include <appTimer.h>
+#include <appFramework.h>
+#include <nwkCommon.h>
+#include <nldeData.h>
+#include <nwkFrame.h>
+
+/******************************************************************************
+ Define(s) section
+ ******************************************************************************/
+#define NWK_LINK_STATUS_TX_PARAMETERS \
+ {NWK_TX_DELAY_LINK_STATUS, nwkPrepareLinkStatusTx,\
+ nwkConfirmLinkStatusTx, true}
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Internal states of the link status component. */
+typedef enum _NwkLinkStatusState_t
+{
+ NWK_LINK_STATUS_IDLE_STATE = 0x00,
+ NWK_LINK_STATUS_FIRST_STATE = 0x01,
+ NWK_LINK_STATUS_WAIT_STATE = NWK_LINK_STATUS_FIRST_STATE,
+ NWK_LINK_STATUS_SEND_STATE = 0x02,
+ NWK_LINK_STATUS_LAST_STATE
+} NwkLinkStatusState_t;
+
+/** Internal parameters of the link status component. */
+typedef struct _NwkLinkStatus_t
+{
+ /** The timer of counting of the link status period. */
+ HAL_AppTimer_t timer;
+ NwkLinkStatusState_t state; /**< Finite-state machine */
+} NwkLinkStatus_t;
+
+BEGIN_PACK
+/** Command Options Field*/
+typedef struct PACK _NwkLinkStatusOptions_t
+{
+ LITTLE_ENDIAN_OCTET(4, (
+ /** This field indicates the number of link status entries */
+ NwkBitField_t entryCount : 5,
+ /** The first frame sub-field is set to 1 if this is the first frame of
+ * the sender's link status.*/
+ NwkBitField_t firstFrame : 1,
+ /** The last frame sub-field is set to 1 if this is the last frame of
+ * the sender's link status. */
+ NwkBitField_t lastFrame : 1,
+ NwkBitField_t reserved : 1
+ ))
+} NwkLinkStatusOptions_t;
+
+/** Link Status Entry. ZigBee spec r17, 3.4.8.3.2 */
+typedef struct PACK _NwkLinkStatusEntry_t
+{
+ LITTLE_ENDIAN_OCTET(4, (
+ /** The incoming cost field contains the device's estimate of the link cost
+ * for the neighbor, which is a value between 1 and 7.*/
+ NwkBitField_t incomingCost : 3,
+ NwkBitField_t reserved1 : 1,
+ /** The outgoing cost field contains the value of the outgoing cost field
+ * from the neighbor table.*/
+ NwkBitField_t outgoingCost : 3,
+ NwkBitField_t reserved2 : 1
+ ))
+} NwkLinkStatusEntry_t;
+
+/** Link status item. ZigBee spec r17, figure 3.23. */
+typedef struct PACK _NwkLinkStatusItem_t
+{
+ /** Each link status entry contains the network address of a router neighbor.
+ **/
+ ShortAddr_t addr;
+ /* Link Status Entry. */
+ NwkLinkStatusEntry_t linkStatus;
+} NwkLinkStatusItem_t;
+
+/** The NWK command payload of the link status command.
+ * ZigBee spec r17, figure 3.21. */
+typedef struct PACK _NwkLinkPayload_t
+{
+ NwkLinkStatusOptions_t options;
+ NwkLinkStatusItem_t table[1];
+} NwkLinkStatusPayload_t;
+END_PACK
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined(_ROUTER_) || defined(_COORDINATOR_)
+
+/******************************************************************************
+ \brief Start HAL timer for periodically send the link status.
+
+ A ZigBee router or coordinator shall periodically send a link status
+ command every nwkLinkStatusPeriod seconds. This function start the app timer.
+ ******************************************************************************/
+NWK_PRIVATE void nwkStartLinkStatusTimer(void);
+
+/******************************************************************************
+ \brief Stop HAL timer for periodically send the link status.
+
+ A ZigBee router or coordinator shall periodically send a link status
+ command every nwkLinkStatusPeriod seconds. This function stops the app timer.
+ ******************************************************************************/
+NWK_PRIVATE void nwkStopLinkStatusTimer(void);
+
+/**************************************************************************//**
+ \brief Reset the link status component
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetLinkStatus(void);
+
+/**************************************************************************//**
+ \brief Action when link status command received
+
+ \param[in] payload - command payload.
+ \param[in] header - raw NWK header.
+ \param[in] parse - parsed header fields.
+ \return 'true' if continue processing of command packet otherwise 'false'.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkLinkStatusInd(const uint8_t *const payload,
+ const NwkFrameHeader_t *const header, const NwkParseHeader_t *const parse);
+
+/**************************************************************************//**
+ \brief Prepare header and payload of the link status command.
+
+ \param[in] outPkt - pointer to output packet.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkPrepareLinkStatusTx(NwkOutputPacket_t *const outPkt);
+
+/**************************************************************************//**
+ \brief Confirmation of link status command transmission.
+
+ \param[in] outPkt - pointer to output packet.
+ \param[in] status - network status of link status transmission.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkConfirmLinkStatusTx(NwkOutputPacket_t *const outPkt,
+ const NWK_Status_t status);
+
+/******************************************************************************
+ \brief nwkLinkStatus idle checking.
+
+ \return true, if nwkLinkStatus performs no activity, false - otherwise.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkLinkStatusIsIdle(void);
+
+#else /* _ROUTER_ or _COORDINATOR_ */
+
+#define nwkResetLinkStatus() (void)0
+#define nwkStartLinkStatusTimer() (void)0
+#define nwkStopLinkStatusTimer() (void)0
+#define nwkLinkStatusInd NULL
+#define nwkPrepareLinkStatusTx NULL
+#define nwkConfirmLinkStatusTx NULL
+#define nwkLinkStatusIsIdle NULL
+
+#endif /* _ROUTER_ or _COORDINATOR_ */
+#endif /* _NWK_LINK_STATUS_H */
+/** eof nwkLinkStatus.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkLoopback.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkLoopback.h
new file mode 100644
index 00000000..91710e26
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkLoopback.h
@@ -0,0 +1,87 @@
+/**************************************************************************//**
+ \file nwkLoopback.h
+
+ \brief Interface of network loopback.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2009-10-06 Max Gekk - Created.
+ Last change:
+ $Id: nwkLoopback.h 17923 2011-07-08 14:13:30Z mgekk $
+ ******************************************************************************/
+#if !defined _NWK_LOOPBACK_H
+#define _NWK_LOOPBACK_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <queue.h>
+#include <nldeData.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Internal states of the loopback component. */
+typedef enum _NwkLoopbackState_t
+{
+ NWK_LOOPBACK_UNKNOWN_STATE = 0x00,
+ NWK_LOOPBACK_FIRST_STATE = 0x8e,
+ NWK_LOOPBACK_IDLE_STATE = NWK_LOOPBACK_FIRST_STATE,
+ NWK_LOOPBACK_REQUEST_PROCESSING_STATE = 0x8f,
+ NWK_LOOPBACK_WAIT_PACKET_STATE = 0x90,
+ NWK_LOOPBACK_LAST_STATE
+} NwkLoopbackState_t;
+
+/** Internal parameters of the loopback component. */
+typedef struct _NwkLoopback_t
+{
+ QueueDescriptor_t queue; /**< Queue of requests from upper layer */
+ NwkLoopbackState_t state; /**< Finite-state machine */
+} NwkLoopback_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+
+/**************************************************************************//**
+ \brief The main task handler of the network loopback component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkLoopbackTaskHandler(void);
+
+/**************************************************************************//**
+ \brief Handler of free packet indication.
+ ******************************************************************************/
+NWK_PRIVATE void nwkLoopbackFreePacketInd(void);
+
+/**************************************************************************//**
+ \brief Reset the network loopback component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetLoopback(void);
+
+/******************************************************************************
+ \brief nwkLoopback idle checking.
+
+ \return true, if nwkLoopback performs no activity, false - otherwise.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkLoopbackIsIdle(void);
+
+/**************************************************************************//**
+ \brief Checks, if outgoing packet should be indicated to the next upper layer.
+
+ \param[in] req - pointer to NLDE-DATA.request parameter's structure.
+
+ \return True, if indication required, false - otherwise
+ ******************************************************************************/
+NWK_PRIVATE bool nwkLoopbackRequired(const NWK_DataReq_t *const req);
+
+#endif /* _NWK_LOOPBACK_H */
+/** nwkLoopback.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkManager.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkManager.h
new file mode 100644
index 00000000..f12c1b9b
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkManager.h
@@ -0,0 +1,127 @@
+/**************************************************************************//**
+ \file nwkManager.h
+
+ \brief Interface of the network manager.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2009-06-08 Max Gekk - Created.
+ Last change:
+ $Id: nwkManager.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_MANAGER_H
+#define _NWK_MANAGER_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <appFramework.h>
+#include <mac.h>
+#include <nldeData.h>
+#include <nwkFrame.h>
+
+/******************************************************************************
+ Define(s) section
+ ******************************************************************************/
+#define NWK_UPDATE_TX_PARAMETERS \
+ {NWK_TX_DELAY_BROADCAST, nwkPrepareUpdateTx, nwkConfirmUpdateTx, true}
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Internal states of the report command component */
+typedef enum _NwkManagerState_t
+{
+ NWK_MANAGER_IDLE_STATE = 0xFB,
+ NWK_MANAGER_FIRST_STATE = 0x83,
+ NWK_MANAGER_MAC_SCAN_STATE = NWK_MANAGER_FIRST_STATE,
+ NWK_MANAGER_PREPARE_MAC_DATA_STATE = 0x84,
+ NWK_MANAGER_SEND_UPDATE_CMD_STATE = 0x85,
+ NWK_MANAGER_SET_PAN_ID_STATE = 0x86,
+ NWK_MANAGER_LAST_STATE
+} NwkManagerState_t;
+
+/** Internal variables of the network manager component. */
+typedef struct _NwkManager_t
+{
+ /** Finite-state machine */
+ NwkManagerState_t state;
+ PanId_t newPanId; /* New non conflicted panId. */
+ /* Range non conflicted panId from newPanId field. */
+ PanId_t nonConflictRange;
+ /** MLME-SCAN request primitive's parameters. */
+ MAC_ScanReq_t macScan;
+} NwkManager_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined _RESOLVE_PANID_CONFLICT_ && defined _NETWORK_MANAGER_
+/**************************************************************************//**
+ \brief Processing a conflict of panId by the network manager.
+ ******************************************************************************/
+NWK_PRIVATE void nwkDetectPanIdConflictByNwkManager(void);
+
+/**************************************************************************//**
+ \brief Reset the report command component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetNetworkManager(void);
+
+/**************************************************************************//**
+ \brief Action when a report command is received.
+
+ \param[in] payload - pointer to NPDU of NWK report command.
+ \param[in] header - nwk header.
+ \param[in] parse - parsed header fields.
+ \return 'true' - continue command processing otherwise 'false'.
+******************************************************************************/
+NWK_PRIVATE bool nwkReportFrameInd(const uint8_t *const payload,
+ const NwkFrameHeader_t *const header, const NwkParseHeader_t *const parse);
+
+/**************************************************************************//**
+ \brief Prepare header and payload of the update command.
+
+ \param[in] outPkt - pointer to output packet.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkPrepareUpdateTx(NwkOutputPacket_t *const outPkt);
+
+/**************************************************************************//**
+ \brief Confirmation of the update command transmission.
+
+ \param[in] outPkt - pointer to output packet.
+ \param[in] status - network status of the update command transmission.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkConfirmUpdateTx(NwkOutputPacket_t *const outPkt,
+ const NWK_Status_t status);
+
+/******************************************************************************
+ \brief nwkNetworkManager idle checking.
+
+ \return true, if nwkNetworkManager performs no activity, false - otherwise.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkNetworkManagerIsIdle(void);
+
+#else /* _RESOLVE_PANID_CONFLICT_ and _NETWORK_MANAGER_ */
+
+/* Interface of the network manager is disabled. */
+INLINE void nwkDetectPanIdConflictByNwkManager(void) {}
+#define nwkResetNetworkManager() (void)0
+#define nwkReportFrameInd NULL
+#define nwkPrepareUpdateTx NULL
+#define nwkConfirmUpdateTx NULL
+#define nwkNetworkManagerIsIdle NULL
+
+#endif /* _RESOLVE_PANID_CONFLICT_ and _NETWORK_MANAGER_ */
+#endif /* _NWK_MANAGER_H */
+/* eof nwkManager.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkManyToOne.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkManyToOne.h
new file mode 100644
index 00000000..7eaf3dbc
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkManyToOne.h
@@ -0,0 +1,69 @@
+/**************************************************************************//**
+ \file nwkManyToOne.h
+
+ \brief Internal interface of the many-to-one component.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2010-05-13 M. Gekk - Created.
+ Last change:
+ $Id: nwkManyToOne.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_MANY_TO_ONE_H
+#define _NWK_MANY_TO_ONE_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <nwkRoutingTable.h>
+#include <queue.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/* Internal variables of the many-to-one component. */
+typedef struct _NwkManyToOne_t
+{
+ QueueDescriptor_t queue; /**< Queue of requests from upper layer. */
+} NwkManyToOne_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined NWK_ROUTING_CAPACITY && defined _NWK_MANY_TO_ONE_ROUTING_
+/**************************************************************************//**
+ \brief Main task handler of the many-to-one component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkManyToOneTaskHandler(void);
+
+/**************************************************************************//**
+ \brief Reset the many-to-one component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetManyToOne(void);
+
+/**************************************************************************//**
+ \brief Many-to-one route request from concentrator has been received.
+
+ \param[in] entry - pointer to concentrator entry in the routing table.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkNewConcentratorFound(NwkRoutingTableEntry_t *const entry);
+
+#else
+
+#define nwkManyToOneTaskHandler NULL
+#define nwkResetManyToOne() (void)0
+#define nwkNewConcentratorFound(entry) (void)0
+
+#endif /* NWK_ROUTING_CAPACITY and _NWK_MANY_TO_ONE_ROUTING_ */
+#endif /* _NWK_MANY_TO_ONE_H */
+/** eof nwkManyToOne.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkMem.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkMem.h
new file mode 100644
index 00000000..8453f399
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkMem.h
@@ -0,0 +1,421 @@
+/**************************************************************************//**
+ \file nwkMem.h
+
+ \brief NWK Memory header file.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2007-06-14 S. Vladykin - Created.
+ 2009-04-30 M. Gekk - Refactoring.
+ Last change:
+ $Id: nwkMem.h 18049 2011-07-20 13:08:36Z mgekk $
+ ******************************************************************************/
+#if !defined _NWK_MEM_H
+#define _NWK_MEM_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <nwkCommon.h>
+#include <nwkIB.h>
+#include <nwkTaskManager.h>
+#include <nwkReset.h>
+#include <nwkDiscovery.h>
+#include <nwkTx.h>
+#include <nwkDataReq.h>
+#include <nwkTxDelay.h>
+#include <nwkPacket.h>
+#include <nwkLeave.h>
+#include <nwkEDScan.h>
+#include <nwkBTT.h>
+#include <nwkAddressConflict.h>
+#include <nwkAddressMap.h>
+#include <nwkCommands.h>
+#include <nwkLoopback.h>
+#include <nwkFormation.h>
+#include <nwkStartRouter.h>
+#include <nwkJoinReq.h>
+#include <nwkJoinInd.h>
+#include <nwkPermitJoining.h>
+#include <nwkLinkStatus.h>
+#include <nwkRoutingTable.h>
+#include <nwkRouteDiscovery.h>
+#include <nwkRouteDiscoveryTable.h>
+#include <nwkStatusInd.h>
+#include <nwkSync.h>
+#include <nwkSyncLoss.h>
+#include <nwkConcentrator.h>
+#include <nwkReportCommand.h>
+#include <nwkUpdateCommand.h>
+#include <nwkManager.h>
+#include <nwkDirectJoin.h>
+#include <nwkOrphan.h>
+#include <nwkSilentJoin.h>
+#include <nwkRouteRecord.h>
+#include <nwkRouteCache.h>
+#include <nwkManyToOne.h>
+#include <nwkGroup.h>
+#include <nwkPassiveAck.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Internal variables of NWK layer. */
+typedef struct _NwkMem_t
+{
+ /** Global NWK state. */
+ NwkState_t state;
+ /** State of task manager. */
+ NwkTaskManager_t taskManager;
+ /** Internal variables of NLME-RESET component. */
+ NwkReset_t reset;
+ /** Internal variables of NLME-DISCOVERY component. */
+ NwkDiscovery_t discovery;
+ /** States and parameters of packet transmission component. */
+ NwkTx_t tx;
+ NwkDataConf_t dataConf;
+ NwkTxDelay_t txDelay;
+ NwkPacketManager_t packetManager;
+ /** Internal variables of NLME-LEAVE component. */
+ NwkLeave_t leave;
+ /** Internal variables of NLME-ED-SCAN component. */
+ NwkEDScan_t edScan;
+ /** Broadcast transaction table. Only pointer to configServer
+ * and a size of table. */
+ NwkBTT_t BTT;
+ /** Address map table. */
+ NwkAddressMap_t addressTable;
+ /** Neighbor table */
+ NwkNeighborTable_t neighborTable;
+ /** Address conflict resolver. */
+ NwkAddrConflict_t addrConflict;
+ /** Requests to send command packets. */
+ NwkCommands_t commands;
+ /** Queue and state of loopback component. */
+ NwkLoopback_t loopback;
+#if defined _COORDINATOR_
+ /** Internal variables of NLME-FORMATION component. */
+ NwkFormation_t formation;
+#endif /* _COORDINATOR_ */
+#if defined _ROUTER_
+ /** Internal variables of NLME-START-ROUTER component. */
+ NwkStartRouter_t startRouter;
+#endif /* _ROUTER_ */
+#if defined _ROUTER_ || defined _ENDDEVICE_
+ /** Internal state of NLME-JOIN.request primitive. */
+ NwkJoinReq_t joinReq;
+#endif /* _ROUTER_ or _ENDDEVICE_ */
+#if defined _ROUTER_ || defined _COORDINATOR_
+ /** Internal state of NLME-JOIN.indication primitive. */
+ NwkJoinInd_t joinInd;
+ /** Internal variables of NLME-PERMIT-JOINING component. */
+ NwkPermitJoining_t permitJoining;
+ /** Internal state of handler of a link status command. */
+ NwkLinkStatus_t linkStatus;
+ #if defined NWK_ROUTING_CAPACITY \
+ && (defined _NWK_MESH_ROUTING_ || defined _NWK_MANY_TO_ONE_ROUTING_)
+ /** Status and internals variables of a routing components. */
+ NwkRouteDiscovery_t routeDiscovery;
+ NwkRouteDiscoveryTable_t routeDiscoveryTable;
+ NwkRoutingTable_t routingTable;
+ #endif /* NWK_ROUTING_CAPACITY and (_NWK_MESH_ROUTING_ or _NWK_MANY_TO_ONE_ROUTING_) */
+ #if defined NWK_ROUTING_CAPACITY && defined _NWK_ROUTE_RECORD_
+ /** Internal state of handler of a route record command. */
+ NwkRouteRecord_t routeRecord;
+ #endif /* NWK_ROUTING_CAPACITY and _NWK_ROUTE_RECORD_ */
+ /** Variables of network status sender. */
+ NwkStatusSender_t statusSender;
+#if defined _NWK_DIRECT_JOIN_
+ NwkDirectJoin_t directJoin;
+#endif /* _NWK_DIRECT_JOIN_ */
+#if defined _NWK_PASSIVE_ACK_
+ NwkPassiveAck_t passiveAck;
+#endif /* _NWK_PASSIVE_ACK_ */
+#endif /* _ROUTER_ or _COORDINATOR_ */
+#if defined _ENDDEVICE_
+ /** Internal variables of NLME-SYNC component. */
+ NwkSync_t sync;
+#endif /* _ENDDEVICE_ */
+#if defined _ROUTER_ && defined NWK_COORD_REALIGNMENT
+ /** Internal variables of NLME-SYNC-LOSS component. */
+ NwkSyncLoss_t syncLoss;
+#endif /* _ROUTER_ and NWK_COORD_REALIGNMENT */
+#if defined _RESOLVE_PANID_CONFLICT_
+ /** Internal state of handler of a report command. */
+ NwkReportCommand_t nwkReportCommand;
+ /** Internal state of handler of a update command. */
+ NwkUpdateCommand_t nwkUpdateCommand;
+ #if defined _NETWORK_MANAGER_
+ NwkManager_t manager;
+ #endif /* _NETWORK_MANAGER_ */
+#endif /* _RESOLVE_PANID_CONFLICT_ */
+#if defined _NWK_CONCENTRATOR_
+ NwkConcentrator_t concentrator;
+#endif /* _NWK_CONCENTRATOR_ */
+#if defined _NWK_ROUTE_CACHE_
+ NwkRouteCache_t routeCache;
+#endif /* _NWK_ROUTE_CACHE_ */
+#if defined _NWK_ORPHAN_JOIN_
+ NwkOrphan_t orphan;
+#endif
+#if defined _NWK_SILENT_JOIN_
+ NwkSilentJoin_t silentJoin;
+#endif
+#if defined NWK_ROUTING_CAPACITY && defined _NWK_MANY_TO_ONE_ROUTING_
+ NwkManyToOne_t manyToOne;
+#endif
+#if defined _GROUP_TABLE_
+ NWK_GroupTable_t groupTable;
+#endif
+} NwkMem_t;
+
+/******************************************************************************
+ External variables section
+******************************************************************************/
+
+/** nwkMem is defined in nwkMem.c */
+extern NwkMem_t nwkMem;
+/** csNIB is defined in configServer.c */
+extern NIB_t csNIB;
+
+/******************************************************************************
+ Inline functions section
+ ******************************************************************************/
+INLINE NIB_t* nwkMemNib(void)
+{
+ return &csNIB;
+}
+
+INLINE NwkTaskManager_t* nwkMemTaskManager(void)
+{
+ return &nwkMem.taskManager;
+}
+
+INLINE NwkReset_t* nwkMemReset(void)
+{
+ return &nwkMem.reset;
+}
+
+INLINE NwkDiscovery_t* nwkMemDiscovery(void)
+{
+ return &nwkMem.discovery;
+}
+
+INLINE NwkTx_t* nwkMemTx(void)
+{
+ return &nwkMem.tx;
+}
+
+INLINE NwkDataConf_t* nwkMemDataConf(void)
+{
+ return &nwkMem.dataConf;
+}
+
+INLINE NwkTxDelay_t* nwkMemTxDelay(void)
+{
+ return &nwkMem.txDelay;
+}
+
+INLINE NwkPacketManager_t* nwkMemPacketManager(void)
+{
+ return &nwkMem.packetManager;
+}
+
+INLINE NwkLeave_t* nwkMemLeave(void)
+{
+ return &nwkMem.leave;
+}
+
+INLINE NwkEDScan_t* nwkMemEDScan(void)
+{
+ return &nwkMem.edScan;
+}
+
+INLINE NwkBTT_t* nwkMemBTT(void)
+{
+ return &nwkMem.BTT;
+}
+
+INLINE NwkAddressMap_t* nwkMemAddressMap(void)
+{
+ return &nwkMem.addressTable;
+}
+
+INLINE NwkAddrConflict_t* nwkMemAddrConflict(void)
+{
+ return &nwkMem.addrConflict;
+}
+
+INLINE NwkCommands_t* nwkMemCommands(void)
+{
+ return &nwkMem.commands;
+}
+
+INLINE NwkLoopback_t* nwkMemLoopback(void)
+{
+ return &nwkMem.loopback;
+}
+
+#if defined _COORDINATOR_
+INLINE NwkFormation_t* nwkMemFormation(void)
+{
+ return &nwkMem.formation;
+}
+#endif
+#if defined _ROUTER_
+INLINE NwkStartRouter_t* nwkMemStartRouter(void)
+{
+ return &nwkMem.startRouter;
+}
+#endif
+#if defined _ROUTER_ || defined _ENDDEVICE_
+INLINE NwkJoinReq_t* nwkMemJoinReq(void)
+{
+ return &nwkMem.joinReq;
+}
+#endif
+#if defined _ROUTER_ || defined _COORDINATOR_
+INLINE NwkJoinInd_t* nwkMemJoinInd(void)
+{
+ return &nwkMem.joinInd;
+}
+
+INLINE NwkPermitJoining_t* nwkMemPermitJoining(void)
+{
+ return &nwkMem.permitJoining;
+}
+
+INLINE NwkLinkStatus_t* nwkMemLinkStatus(void)
+{
+ return &nwkMem.linkStatus;
+}
+
+#if defined NWK_ROUTING_CAPACITY \
+ && (defined _NWK_MESH_ROUTING_ || defined _NWK_MANY_TO_ONE_ROUTING_)
+INLINE NwkRouteDiscovery_t* nwkMemRouteDiscovery(void)
+{
+ return &nwkMem.routeDiscovery;
+}
+
+INLINE NwkRouteDiscoveryTable_t* nwkMemRouteDiscoveryTable(void)
+{
+ return &nwkMem.routeDiscoveryTable;
+}
+
+INLINE NwkRoutingTable_t* nwkMemRoutingTable(void)
+{
+ return &nwkMem.routingTable;
+}
+#endif /* NWK_ROUTING_CAPACITY and (_NWK_MESH_ROUTING_ or _NWK_MANY_TO_ONE_ROUTING_) */
+#if defined NWK_ROUTING_CAPACITY && defined _NWK_ROUTE_RECORD_
+INLINE NwkRouteRecord_t* nwkMemRouteRecord(void)
+{
+ return &nwkMem.routeRecord;
+}
+#endif /* NWK_ROUTING_CAPACITY and _NWK_ROUTE_RECORD_ */
+
+INLINE NwkStatusSender_t* nwkMemStatusSender(void)
+{
+ return &nwkMem.statusSender;
+}
+
+#if defined _NWK_PASSIVE_ACK_
+INLINE NwkPassiveAck_t* nwkMemPassiveAck(void)
+{
+ return &nwkMem.passiveAck;
+}
+#endif /* _NWK_PASSIVE_ACK_ */
+#endif /* _ROUTER_ or _COORDINATOR_ */
+
+#if defined _ENDDEVICE_
+INLINE NwkSync_t* nwkMemSync(void)
+{
+ return &nwkMem.sync;
+}
+#endif
+#if defined _ROUTER_ && defined NWK_COORD_REALIGNMENT
+INLINE NwkSyncLoss_t* nwkMemSyncLoss(void)
+{
+ return &nwkMem.syncLoss;
+}
+#endif /* _ROUTER_ and NWK_COORD_REALIGNMENT */
+
+INLINE NwkNeighborTable_t* nwkMemNeighborTable(void)
+{
+ return &nwkMem.neighborTable;
+}
+
+#if defined _RESOLVE_PANID_CONFLICT_
+INLINE NwkReportCommand_t* nwkMemReportCommand(void)
+{
+ return &nwkMem.nwkReportCommand;
+}
+
+INLINE NwkUpdateCommand_t* nwkMemUpdateCommand(void)
+{
+ return &nwkMem.nwkUpdateCommand;
+}
+#if defined _NETWORK_MANAGER_
+INLINE NwkManager_t* nwkMemManager(void)
+{
+ return &nwkMem.manager;
+}
+#endif /* _NETWORK_MANAGER_ */
+#endif /* _RESOLVE_PANID_CONFLICT_ */
+#if defined _NWK_CONCENTRATOR_
+INLINE NwkConcentrator_t* nwkMemConcentrator(void)
+{
+ return &nwkMem.concentrator;
+}
+#endif /* _NWK_CONCENTRATOR_ */
+#if defined _NWK_ROUTE_CACHE_
+INLINE NwkRouteCache_t* nwkMemRouteCache(void)
+{
+ return &nwkMem.routeCache;
+}
+#endif /* _NWK_ROUTE_CACHE_ */
+
+#if (defined(_ROUTER_) || defined(_COORDINATOR_)) && defined(_NWK_DIRECT_JOIN_)
+INLINE NwkDirectJoin_t* nwkMemDirectJoin(void)
+{
+ return &nwkMem.directJoin;
+}
+#endif
+
+#if defined _NWK_ORPHAN_JOIN_
+INLINE NwkOrphan_t* nwkMemOrphan(void)
+{
+ return &nwkMem.orphan;
+}
+#endif
+
+#if defined _NWK_SILENT_JOIN_
+INLINE NwkSilentJoin_t* nwkMemSilentJoin(void)
+{
+ return &nwkMem.silentJoin;
+}
+#endif
+
+#if defined NWK_ROUTING_CAPACITY && defined _NWK_MANY_TO_ONE_ROUTING_
+INLINE NwkManyToOne_t* nwkMemManyToOne(void)
+{
+ return &nwkMem.manyToOne;
+}
+#endif
+#if defined _GROUP_TABLE_
+INLINE NWK_GroupTable_t* nwkMemGroup(void)
+{
+ return &nwkMem.groupTable;
+}
+#endif
+#endif /* _NWK_MEM_H */
+/** eof nwkMem.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkNeighborTable.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkNeighborTable.h
new file mode 100644
index 00000000..7c7c6179
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkNeighborTable.h
@@ -0,0 +1,261 @@
+/**************************************************************************//**
+ \file nwkNeighborTable.h
+
+ \brief Interface of the neighbor table..
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2009-05-12 M. Gekk - Created.
+ Last change:
+ $Id: nwkNeighborTable.h 18296 2011-08-19 12:29:05Z mgekk $
+ ******************************************************************************/
+#if !defined _NWK_NEIGHBOR_TABLE_H
+#define _NWK_NEIGHBOR_TABLE_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <mac.h>
+#include <nwkNeighbor.h>
+#include <nwkMem.h>
+
+/******************************************************************************
+ Define(s) section
+ ******************************************************************************/
+#define IS_EMPTY(ntEntry) (RELATIONSHIP_EMPTY == ntEntry->relationship)
+#define IS_AUTHENTICATED_CHILD(ntEntry) \
+ (RELATIONSHIP_CHILD == ntEntry->relationship)
+#define IS_UNAUTHENTICATED_CHILD(ntEntry) \
+ (RELATIONSHIP_UNAUTHENTICATED_CHILD == ntEntry->relationship)
+#define IS_END_DEVICE(ntEntry) \
+ (DEVICE_TYPE_END_DEVICE == ntEntry->deviceType)
+#define IS_CHILD(ntEntry) \
+ (IS_AUTHENTICATED_CHILD(ntEntry) || IS_UNAUTHENTICATED_CHILD(ntEntry))
+#define IS_PARENT(ntEntry) (RELATIONSHIP_PARENT == ntEntry->relationship)
+#define IS_RX_ON_WHEN_IDLE(ntEntry) (ntEntry->rxOnWhenIdle)
+#define FREE_NEIGHBOR(neighbor) neighbor->relationship = RELATIONSHIP_EMPTY
+/** Getting mutable part of neighbor entry. */
+#define MUTABLE_PART(neighbor) nwkMutablePart(nwkMemNeighborTable(), neighbor)
+/** Minimum value of a cost metric. */
+#define NWK_MIN_LINK_COST 1
+
+/******************************************************************************
+ Inline static functions prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief First entry of the neighbor table.
+ ******************************************************************************/
+INLINE NwkNeighbor_t* nwkNtBegin(void)
+{
+ return nwkMemNeighborTable()->table;
+}
+
+/**************************************************************************//**
+ \brief Function returns a pointer to memory area after last entry of the
+ neighbor table.
+ ******************************************************************************/
+INLINE NwkNeighbor_t* nwkNtEnd(void)
+{
+ return nwkMemNeighborTable()->end;
+}
+
+/**************************************************************************//**
+ \brief Function return a total size of the neighbor table.
+ ******************************************************************************/
+INLINE NwkSizeOfNeighborTable_t nwkNtSize(void)
+{
+ return nwkMemNeighborTable()->size;
+}
+
+/**************************************************************************//**
+ \brief Getting the mutable part of given neighbor entry.
+ ******************************************************************************/
+INLINE NwkMutablePartOfNeighbor_t* nwkMutablePart(
+ NwkNeighborTable_t const *const neighborTable,
+ NwkNeighbor_t const *const neighbor)
+{
+ return neighborTable->mutableTable + (neighbor - neighborTable->table);
+}
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Reset the neighbor table.
+
+ \param[in] powerFailureControl - stack restoring after power failure control bitfield;
+ affects on initialization procedure.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetNeighborTable(NWK_PowerFailureControl_t powerFailureControl);
+
+/**************************************************************************//**
+ \brief Clear all entries in the neighbor table.
+
+ \param[in] removeParent - remove parent's entry.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkClearNeighborTable(const bool removeParent);
+
+/**************************************************************************//**
+ \brief Free a entry in the neighbor table.
+
+ \param[in] neighbor - pointer to a neighbor.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkFreeNeighbor(NwkNeighbor_t *const neighbor);
+
+/**************************************************************************//**
+ \brief Update of time of a life of the neighbor.
+
+ \param[in] neighbor - pointer to a neighbor.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkSetLifeTimeOfNeighbor(NwkNeighbor_t *const neighbor);
+
+#if defined NWK_ROUTING_CAPACITY && defined _NWK_MESH_ROUTING_
+/**************************************************************************//**
+ \brief Checking of that the given device is destination node for the
+ short address.
+
+ \param[in] shortAddr - unicast or multicast short address.
+ \param[in] group - if 'true' then shortAddress is a multicast address.
+ \return 'true' if this node is destination else 'false'.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkIsRouteDestination(const ShortAddr_t shortAddr,
+ const bool group);
+#endif /* NWK_ROUTING_CAPACITY and _NWK_MESH_ROUTING_ */
+
+/**************************************************************************//**
+ \brief Calculate an incoming cost by LQI.
+
+ \param[in] lqi - link quality indicator.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE NwkPathCost_t nwkCostFromLqi(const Lqi_t lqi);
+
+/**************************************************************************//**
+ \brief Recalculation LQI and costs for the set neighbor.
+
+ \param[in] neighbor - pointer to a neighbor
+ \param[in] linkQuality - the link quality indicator of a received packet.
+ \param[in] rssi - received signal strength indication.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkUpdateLqiAndCostOfNeighbor(NwkNeighbor_t *const neighbor,
+ const Lqi_t linkQuality, const Rssi_t rssi);
+
+/**************************************************************************//**
+ \brief Recalculation LQI and costs for a neighbor with given short address.
+
+ \param[in] addr - short address of a neighbor.
+ \param[in] linkQuality - the link quality indicator of a received packet.
+ \param[in] rssi - received signal strength indication.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkUpdateLqiAndLifeTime(const ShortAddr_t addr,
+ const Lqi_t linkQuality, const Rssi_t rssi);
+
+/**************************************************************************//**
+ \brief Is there a free place in the neighbor table.
+
+ \param endDeviceCount - current number of end device children.
+ \param routerCount - current number of router children.
+
+ \return 'true' if the neighbor table is full otherwise return 'false'.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkIsNeighborTableFull(const NwkChildCount_t endDeviceCount,
+ const NwkChildCount_t routerCount);
+
+/**************************************************************************//**
+ \brief Gets value for the end device capacity bit in the beacon payload.
+
+ \param endDeviceCount - current number of end device children.
+
+ \return 1U if a end device can rejoin to this device otherwise return 0U.
+ ******************************************************************************/
+NWK_PRIVATE uint8_t nwkGetEdCapacity(const NwkChildCount_t endDeviceCount);
+
+/**************************************************************************//**
+ \brief Gets value for the router capacity bit in the beacon payload.
+
+ \param routerCount - current number of router children.
+
+ \return 1U if a router can rejoin to this device otherwise return 0U.
+ ******************************************************************************/
+NWK_PRIVATE uint8_t nwkGetRouterCapacity(const NwkChildCount_t routerCount);
+
+/**************************************************************************//**
+ \brief Calculation of quantity of children and updating of capacity bits.
+ ******************************************************************************/
+NWK_PRIVATE void nwkUpdateCapacityBitsInBeacon(void);
+
+/**************************************************************************//**
+ \brief Updating capacity bits in beacon by end devices and routers count.
+
+ \param[in] endDeviceCount - current number of end device children.
+ \param[in] routerCount - current number of router children.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkUpdateCapacityBits(const NwkChildCount_t endDeviceCount,
+ const NwkChildCount_t routerCount);
+
+#if defined _RESOLVE_ADDR_CONFLICT_
+/******************************************************************************
+ \brief Find a neighbor with address conflict.
+
+ This function reset the conflict flag.
+
+ \return Pointer to neighbor's entry in the neighbor table.
+******************************************************************************/
+NWK_PRIVATE NwkNeighbor_t* nwkFindAddrConflictNeighbor(void);
+
+#if defined _ROUTER_ || defined _COORDINATOR_
+/******************************************************************************
+ \brief Find a end device child with given short address.
+
+ \param[in] shortAddr - short address of end device child.
+ \return Pointer to neighbor's entry in the neighbor table.
+******************************************************************************/
+NWK_PRIVATE NwkNeighbor_t* nwkFindEndDeviceChild(const ShortAddr_t shortAddr);
+#endif /* _ROUTER_ or _COORDINATOR_ */
+#endif /* _RESOLVE_ADDR_CONFLICT_ */
+
+#if defined _ROUTER_ || defined _COORDINATOR_
+/**************************************************************************//**
+ \brief Start the age timer of the neighbor table.
+ ******************************************************************************/
+NWK_PRIVATE void nwkStartAgeTimerOfNeighborTable(void);
+
+/**************************************************************************//**
+ \brief Stop the age timer of the neighbor table.
+ ******************************************************************************/
+NWK_PRIVATE void nwkStopAgeTimerOfNeighborTable(void);
+
+/**************************************************************************//**
+ \brief Search of the following child after given with a flag rxOnWhenIdle
+ in 'false' and that can take indirect packet.
+
+ \param[in] neighbor - the neighbor with which search should begin.
+ \param[in] exceptShortAddr - the address of the child which should be passed.
+ \return Pointer to sleeping child's entry in the neighbor table.
+ ******************************************************************************/
+NWK_PRIVATE NwkNeighbor_t* nwkNextSleepingChildForIndirectTx(
+ NwkNeighbor_t* neighbor, const ShortAddr_t exceptShortAddr);
+
+#else
+#define nwkStartAgeTimerOfNeighborTable() (void)0
+#define nwkStopAgeTimerOfNeighborTable() (void)0
+
+#endif /* _ROUTER_ or _COORDINATOR_ */
+
+#endif /* _NWK_NEIGHBOR_TABLE_H */
+/** eof nwkNeighborTable.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkOrphan.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkOrphan.h
new file mode 100644
index 00000000..c1f3683a
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkOrphan.h
@@ -0,0 +1,109 @@
+/*************************************************************************//**
+ \file nwkOrphan.h
+
+ \brief Interface of orphan join functionality.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2010-03-17 I.Vagulin - Created.
+ Last change:
+ $Id: nwkOrphan.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_ORPHAN_H
+#define _NWK_ORPHAN_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <queue.h>
+#include <nlmeJoin.h>
+#include <macOrphan.h>
+#include <macScan.h>
+#include <macSetGet.h>
+#include <macRxEnable.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+typedef enum
+{
+ NWK_ORPHAN_STATE_MIN = 0x65,
+ NWK_ORPHAN_STATE_IDLE,
+
+ /* child */
+ NWK_ORPHAN_STATE_REQUEST_QUEUED,
+ NWK_ORPHAN_STATE_WAIT_SCAN_CONFIRM,
+ NWK_ORPHAN_STATE_SET_PARAMS,
+ NWK_ORPHAN_STATE_GET_PARAMS,
+
+ /* parent */
+ NWK_ORPHAN_STATE_WAIT_RESPONSE_CONFIRM,
+
+ NWK_ORPHAN_STATE_MAX
+} NwkOrphanState_t ;
+
+/** Orphan memory */
+typedef struct _NwkOrphan_t
+{
+ NwkOrphanState_t state;
+
+#if defined _ROUTER_ || defined _ENDDEVICE_
+ /** Request queue */
+ QueueDescriptor_t queue;
+ /** joinReq currently in processing */
+ NWK_JoinReq_t *current;
+ /** Memory for mac requests */
+#endif
+ union
+ {
+#if defined _ROUTER_ || defined _COORDINATOR_
+ MAC_OrphanResp_t resp;
+#endif
+#if defined _ROUTER_ || defined _ENDDEVICE_
+ MAC_ScanReq_t scan;
+ MAC_GetReq_t get;
+ MAC_SetReq_t set;
+ MAC_RxEnableReq_t rxEnable;
+#endif
+ } req ;
+} NwkOrphan_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if (defined(_ROUTER_) || defined(_ENDDEVICE_)) && defined(_NWK_ORPHAN_JOIN_)
+/**************************************************************************//**
+ \brief Reseting of the orphan module.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetOrphan(void);
+
+/**************************************************************************//**
+ \brief Main task handler of orphan module.
+ ******************************************************************************/
+NWK_PRIVATE void nwkOrphanTaskHandler(void);
+
+/**************************************************************************//**
+ \brief Process orphan join requests.
+
+ \param[in] req - NLME-JOIN request parameters' structure pointer.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkOrphanReq(NWK_JoinReq_t *req);
+
+#else
+
+#define nwkResetOrphan() (void)0
+#define nwkOrphanTaskHandler NULL
+
+#endif /* (_ROUTER_ or _ENDDEVICE_) and _NWK_ORPHAN_JOIN_ */
+#endif /* _NWK_ORPHAN_H */
+/** eof nwkOrphan.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkPacket.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkPacket.h
new file mode 100644
index 00000000..f93f21ed
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkPacket.h
@@ -0,0 +1,154 @@
+/**************************************************************************//**
+ \file nwkPacket.h
+
+ \brief Interface of the network packet manager.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2009-07-06 M. Gekk - Created.
+ Last change:
+ $Id: nwkPacket.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_PACKET_H
+#define _NWK_PACKET_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <queue.h>
+#include <mac.h>
+#include <nwkCommon.h>
+#include <nwkRx.h>
+#include <nwkTx.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Type of network packet. */
+typedef enum _NwkPacketType_t
+{
+ NWK_UNKNOWN_PACKET = 0x0,
+ /** Command packet from NWK component. */
+ NWK_OUTPUT_COMMAND_PACKET = 0x1,
+ /** Command packet from MAC-layer. */
+ NWK_INPUT_COMMAND_PACKET = 0x2,
+ /** Data packet from MAC-layer. */
+ NWK_INPUT_DATA_PACKET = 0x3,
+ /** Transit packet from MAC-layer. */
+ NWK_TRANSIT_PACKET = 0x4,
+ /** Loopback transmission from APS-layer. */
+ NWK_LOOPBACK_PACKET = 0x5,
+ /** Data packet from an external layer. */
+ NWK_EXTERN_PACKET = 0x6,
+ NWK_BUFFER_TYPE_LAST
+} NwkPacketType_t;
+
+/** Network packet type. */
+typedef struct _NwkPacket_t
+{
+ /** Network packet type. */
+ NwkPacketType_t type;
+ TOP_GUARD
+ uint8_t macHeader[MAC_MSDU_OFFSET];
+ uint8_t macPayload[MAC_MAX_MSDU_SIZE];
+#if (MAC_AFFIX_LENGTH - MAC_MSDU_OFFSET)
+ uint8_t macFooter[MAC_AFFIX_LENGTH - MAC_MSDU_OFFSET];
+#endif
+ BOTTOM_GUARD
+ union
+ {
+ /** Service information for incoming packet from MAC-layer. */
+ NwkInputPacket_t in;
+ /** Service information for outgoing packet from NWK-layer. */
+ NwkOutputPacket_t out;
+#if defined _NWK_ALLOCATOR_
+ /** Service information for outgoing packet from an upper-layer. */
+ NwkExternPacket_t ext;
+#endif /* _NWK_ALLOCATOR_ */
+ } pkt;
+} NwkPacket_t;
+
+/** Internal variables of the network packet manager. */
+typedef struct _NwkPacketManager_t
+{
+ /** Array of network packets. */
+ NwkPacket_t *pkt;
+ /** Total amount of network packets. */
+ uint8_t amount;
+ /** Queue of external packet allocation requests. */
+ QueueDescriptor_t queue;
+} NwkPacketManager_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Allocate a free memory space for an input packet with type.
+
+ \param[in] type - type of packet.
+ \param[in] length - needed packet length.
+ \return Pointer to input packet or NULL.
+ ******************************************************************************/
+NWK_PRIVATE NwkInputPacket_t* nwkAllocInputPacket(const NwkPacketType_t type,
+ const NwkLength_t length);
+
+/**************************************************************************//**
+ \brief Free an input packet.
+
+ \param[in] inPkt - pointer to an input packet.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkFreeInputPacket(NwkInputPacket_t *const inPkt);
+
+/**************************************************************************//**
+ \brief Allocate a free memory space for an output.
+
+ \param[in] type - type of output packet.
+ \return Pointer to output packet or NULL.
+ ******************************************************************************/
+NWK_PRIVATE NwkOutputPacket_t* nwkAllocOutputPacket(const NwkPacketType_t type);
+
+/**************************************************************************//**
+ \brief Free an output packet.
+
+ \param[in] outPkt - pointer to an output packet.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkFreeOutputPacket(NwkOutputPacket_t *const outPkt);
+
+/**************************************************************************//**
+ \brief Reset the network packet manager.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetPacketManager(void);
+
+#if defined NWK_ROUTING_CAPACITY
+/**************************************************************************//**
+ \brief To transform an input packet to the output packet.
+
+ \param[in] inPkt - pointer to an input packet.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE
+NwkOutputPacket_t* nwkTransformInToOutPacket(NwkInputPacket_t *const inPkt);
+#endif /* NWK_ROUTING_CAPACITY */
+
+#if defined _NWK_ALLOCATOR_
+/**************************************************************************//**
+ \brief Process an incoming request to allocate memory for NWK_DataReq.
+ ******************************************************************************/
+NWK_PRIVATE void nwkAllocDataReqTaskHandler(void);
+
+#else
+#define nwkAllocDataReqTaskHandler NULL
+#endif /* _NWK_ALLOCATOR_ */
+#endif /* _NWK_PACKET_H */
+/** eof nwkPacket.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkPassiveAck.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkPassiveAck.h
new file mode 100644
index 00000000..6e76b48c
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkPassiveAck.h
@@ -0,0 +1,174 @@
+/**************************************************************************//**
+ \file nwkPassiveAck.h
+
+ \brief Private interface of the passive acknowledgement mechanism.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2011-07-16 Max Gekk - Created.
+ Last change:
+ $Id: nwkPassiveAck.h 18049 2011-07-20 13:08:36Z mgekk $
+ ******************************************************************************/
+/**//**
+ *
+ * Passive acknowledgement means that every ZigBee router and ZigBee
+ * coordinator keeps track of which of its neighboring devices have successfully
+ * relayed the broadcast transmission. ZigBee spec r18, 3.6.5, page 411.
+ *
+ **/
+#if !defined _NWK_PASSIVE_ACK_H
+#define _NWK_PASSIVE_ACK_H
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <types.h>
+#include <mac.h>
+#include <nwkFrame.h>
+#include <nwkTxDelay.h>
+#include <nwkRx.h>
+
+/******************************************************************************
+ Definitions section
+ ******************************************************************************/
+#define IS_PASSIVE_ACK_FOUND(offset) \
+ ((offset).index < nwkMemPassiveAck()->amount)
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** In this structute the node stores information about passive acks
+ * (rebroadcasts) that are received from other routers (and coordinator too)
+ * in the neighborhood. */
+typedef struct _NwkPassiveAckEntry_t
+{
+ /* This field is used as unque identifier of the entry. NULL means that
+ * the entry is free. txDelay only stores pointer to NwkTxDelayReq_t
+ * structure and nwkPassiveAck doesn't read or write fields of the structure. */
+ NwkTxDelayReq_t *txDelay;
+ /* Short address of node that originates a transmission of the broadcast packets. */
+ ShortAddr_t srcAddr;
+ /* Sequence number of NWK packets for which we wait passive acks. */
+ NwkSequenceNumber_t seqNum;
+} NwkPassiveAckEntry_t;
+
+/* Type of value for storing the amount of passive ack entries. */
+typedef uint8_t NwkPassiveAckAmount_t;
+/* Type of index of a passive ack record. */
+typedef NwkPassiveAckAmount_t NwkPassiveAckIndex_t;
+
+typedef struct _NwkPassiveAck_t
+{
+ /* Total amount of passive acknowledgement in the table. */
+ NwkPassiveAckAmount_t amount;
+ /* The pointer to the first item of table that stores information
+ * about each passive acks. */
+ NwkPassiveAckEntry_t *table;
+} NwkPassiveAck_t;
+
+/* Offset of the passive ack entry in the passive ack table. */
+typedef struct _NwkPassiveAckOffset_t
+{
+ /* Index of the passive ack entry in the passive ack table. */
+ NwkPassiveAckIndex_t index;
+ /* Value of this field is equal 1U << index. */
+ NwkPassiveAckMap_t mask;
+} NwkPassiveAckOffset_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined _NWK_PASSIVE_ACK_ && (defined _ROUTER_ || defined _COORDINATOR_)
+/******************************************************************************
+ \brief Creates the new entry in the passive ack table.
+
+ \param[in] txDelay - that pointer is used as unique identifier.
+ \param[in] prevHopAddr - short address of node from which the packet is received.
+ \param[in] srcAddr - short address of node that initiates broadcast.
+ \param[in] seqNum - sequence number in NWK header of broadcast packet.
+
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkNewPassiveAck(NwkTxDelayReq_t *const txDelay,
+ const ShortAddr_t prevHopAddr, const ShortAddr_t srcAddr,
+ const NwkSequenceNumber_t seqNum);
+
+/******************************************************************************
+ \brief Starts tracing external broadcasts.
+
+ Creates the new entry only for transit broadcast packets.
+
+ \param[in] inPkt - the pointer to an incoming packet.
+ \param[in] prevHopAddr - short address of node from which the packet is received.
+ \param[in] srcAddr - short address of node that initiates broadcast.
+ \param[in] seqNum - sequence number in NWK header of broadcast packet.
+ \param[in] radius - value of radius from NWK header of original broadcast.
+
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkTracePassiveAck(NwkInputPacket_t *const inPkt,
+ const ShortAddr_t prevHopAddr, const ShortAddr_t srcAddr,
+ const NwkSequenceNumber_t seqNum, const NwkRadius_t radius);
+
+/******************************************************************************
+ \brief Finds an passive ack entry by the identifier.
+
+ \param[in] txDelay - primary key of an passive ack entry.
+
+ \return Offset of an passive ack entry if it is found
+ otherwise returns invalid offset \see IS_PASSIVE_ACK_FOUND.
+ ******************************************************************************/
+NWK_PRIVATE
+NwkPassiveAckOffset_t nwkFindPassiveAck(const NwkTxDelayReq_t *const txDelay);
+
+/******************************************************************************
+ \brief Frees an passive ack entry.
+
+ \param[in] txDelay - the valid pointer to NwkTxDelayReq_t structure,
+ used to find and free an entry in the passive ack table
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkFreePassiveAck(const NwkTxDelayReq_t *const txDelay);
+
+/******************************************************************************
+ \brief Checks that all expected rebroadcast are received.
+
+ \param[in] offset - offset of entry in the passive ack table.
+ \return 'true' if all expected neighbors confirms that they was received
+ original broadcast packet otherwise 'false'.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkIsPassiveAckDone(const NwkPassiveAckOffset_t offset);
+
+/******************************************************************************
+ \brief A rebroadcast is received, stores information about it.
+
+ \param[in] prevHopAddr - short address of node from which the packet is received.
+ \param[in] srcAddr - short address of node that initiates broadcast.
+ \param[in] seqNum - sequence number in NWK header of broadcast packet.
+
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkPassiveAckReceived(const ShortAddr_t prevHopAddr,
+ const ShortAddr_t srcAddr, const NwkSequenceNumber_t seqNum);
+
+/******************************************************************************
+ \brief Resets the internal state and structures of the passive ack component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetPassiveAck(void);
+
+#else
+#define nwkNewPassiveAck(id, prevHopAddr, srcAddr, seqNum) (void)0
+#define nwkTracePassiveAck(inPkt, prevHopAddr, srcAddr, seqNum, radius) (void)0
+#define nwkFreePassiveAck(id) (void)0
+#define nwkPassiveAckReceived(prevHopAddr, srcAddr, seqNum) (void)0
+#define nwkResetPassiveAck() (void)0
+#endif /* _NWK_PASSIVE_ACK_ */
+#endif /* _NWK_PASSIVE_ACK_H */
+/** eof nwkPassiveAck.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkPermitJoining.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkPermitJoining.h
new file mode 100644
index 00000000..0df4d173
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkPermitJoining.h
@@ -0,0 +1,86 @@
+/**************************************************************************//**
+ \file nwkPermitJoining.h
+
+ \brief NWK permit joining header file.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2007-06-27 V. Panov - Created.
+ 2008-12-10 M. Gekk - Reduction of usage of the RAM at separate compiling.
+ Last change:
+ $Id: nwkPermitJoining.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_PERMIT_JOINING_H
+#define _NWK_PERMIT_JOINING_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <queue.h>
+#include <mac.h>
+#include <nlmePermitJoining.h>
+#include <appTimer.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Internal states of NLME-PERMIT_JOINING component */
+typedef enum _NwkPermitJoiningStates_t
+{
+ NWK_PERMIT_JOINING_IDLE_STATE = 0x48,
+ NWK_PERMIT_JOINING_FIRST_STATE = 0x4A,
+ NWK_PERMIT_JOINING_WAIT_TIMER_FIRED_STATE = NWK_PERMIT_JOINING_FIRST_STATE,
+ NWK_PERMIT_JOINING_BEGIN_STATE = 0x5D,
+ NWK_PERMIT_JOINING_CONFIRM_STATE = 0x5E,
+ NWK_PERMIT_JOINING_TIMER_FIRED_STATE = 0x5F,
+ NWK_PERMIT_JOINING_SET_ASSOC_PERMIT_STATE = 0x60,
+ NWK_PERMIT_JOINING_LAST_STATE
+} NwkPermitJoiningState_t;
+
+/** Internal parameters of NLME-PERMIT-JOINING component. */
+typedef struct _NwkPermitJoining_t
+{
+ NwkPermitJoiningState_t state;
+ QueueDescriptor_t queue;
+ MAC_SetReq_t macReq;
+} NwkPermitJoining_t;
+
+/******************************************************************************
+ Inline functions section
+ ******************************************************************************/
+#if defined _ROUTER_ || defined _COORDINATOR_
+/*************************************************************************//**
+ \brief Task handler of the NLME-PERMIT-JOINING component.
+ *****************************************************************************/
+NWK_PRIVATE void nwkPermitJoiningTaskHandler(void);
+
+/*************************************************************************//**
+ \brief Reset the NLME-PERMIT-JOINING component.
+ *****************************************************************************/
+NWK_PRIVATE void nwkResetPermitJoining(void);
+
+/******************************************************************************
+ \brief nwkPermitJoining idle checking.
+
+ \return true, if nwkPermitJoining performs no activity, false - otherwise.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkPermitJoiningIsIdle(void);
+
+#else /* _ROUTER_ or _COORDINATOR_ */
+
+#define nwkPermitJoiningTaskHandler NULL
+#define nwkPermitJoiningIsIdle NULL
+#define nwkResetPermitJoining() (void)0
+
+#endif /* _ROUTER_ or _COORDINATOR_ */
+#endif /* _NWK_PERMIT_JOINING_H */
+/** eof nwkPermitJoining.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkReportCommand.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkReportCommand.h
new file mode 100644
index 00000000..552de474
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkReportCommand.h
@@ -0,0 +1,167 @@
+/**************************************************************************//**
+ \file nwkReportCommand.h
+
+ \brief Report command header file.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2008-12-10 M. Gekk - Reduction of usage of the RAM at separate compiling.
+ 2009-06-05 M. Gekk - Refactoring.
+ Last change:
+ $Id: nwkReportCommand.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_REPORT_COMMAND_H
+#define _NWK_REPORT_COMMAND_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <nwkSystem.h>
+#include <mac.h>
+#include <nldeData.h>
+#include <nwkFrame.h>
+
+/******************************************************************************
+ Definitions section
+ ******************************************************************************/
+/** Maximum size of a list of 16-bit PAN identifiers that are operating in the
+ * neighborhood of the reporting device.*/
+#define NWK_MAX_REPORT_PANID 16U
+/** Types of report information command. */
+#define NWK_REPORT_TYPE_PANID_CONFLICT 0U
+/** Minimum size of the report command payload without
+ * report information field. */
+#define NWK_SIZE_OF_MIN_REPORT_CMD_PAYLOD 10U
+#define NWK_REPORT_TX_PARAMETERS \
+ {NWK_TX_DELAY_UNICAST_COMMAND, nwkPrepareReportTx, nwkConfirmReportTx, true}
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Internal states of the report command component */
+typedef enum _NwkReportCommandState_t
+{
+ /** State after reset */
+ NWK_REPORT_IDLE_STATE = 0x27,
+ /** States of preparing and sending a report command. */
+ NWK_REPORT_FIRST_STATE = 0x51,
+ NWK_REPORT_SCAN_STATE = NWK_REPORT_FIRST_STATE,
+ NWK_REPORT_PREPARE_MAC_DATA_STATE = 0x52,
+ NWK_REPORT_SEND_STATE = 0x54,
+ NWK_REPORT_LAST_STATE
+} NwkReportCommandState_t;
+
+/** Internal variables of the report command component. */
+typedef struct _NwkReportCommand_t
+{
+ /** Finite-state machine */
+ NwkReportCommandState_t state;
+ /** MLME-SCAN request primitive's parameters */
+ MAC_ScanReq_t macScan;
+} NwkReportCommand_t;
+
+/** Payload of network report command. ZigBee spec r17, Figure 3.24. */
+BEGIN_PACK
+typedef struct PACK _NwkReportCommandPayload_t
+{
+ /** Id of report command. ZigBee spec r17, Table 3.40. */
+ NwkCommandIdField_t commandId;
+ LITTLE_ENDIAN_OCTET(2, (
+ /** Command Options Field. ZigBee spec r17, Figure 3.25. */
+ /** The report information count sub-field contains an integer indicating
+ * the number of records contained within the Report Information field.*/
+ NwkBitField_t infoCount : 5,
+ /** The report command identifier sub-field contains an integer indicating
+ * the type of report information command.
+ * ZigBee spec r17, 3.4.9.3.1.2, page 334. */
+ NwkBitField_t reportCmdId : 3
+ ))
+ /** The EPID field shall contain the 64-bit EPID that identifies the network
+ * that the reporting device is a member of.
+ * ZigBee spec r17, 3.4.9.3.2, page 334. */
+ ExtPanId_t extPanId;
+ /** The report information field provides the information being reported,
+ * the format of this field depends upon the value of the Report Command
+ * Identifier sub-field. */
+ union
+ {
+ uint8_t info[NWK_MAX_REPORT_PANID * sizeof(PanId_t)];
+ PanId_t panId[NWK_MAX_REPORT_PANID];
+ } report;
+} NwkReportCommandPayload_t;
+END_PACK
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined _RESOLVE_PANID_CONFLICT_
+/**************************************************************************//**
+ \brief Function detects the potential conflict of addresses.
+
+ \param[in] beaconNotify - MLME-BEACON_NOTIFY indication parameters' pointer.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE
+void nwkDetectPanIdConflict(const MAC_BeaconNotifyInd_t *const beaconNotify);
+
+/**************************************************************************//**
+ \brief Reset the report command component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetReportCommand(void);
+
+/**************************************************************************//**
+ \brief Searching other network and fill MAC pan descriptors in configServer.
+
+ \param[in] macScan - MLME-SCAN.request parameters.
+ \param[in] MAC_ScanConf - MLME-SCAN confirm callback function.
+ ******************************************************************************/
+NWK_PRIVATE void nwkSearchOtherNetworks(MAC_ScanReq_t *const macScan,
+ void (*MAC_ScanConf)(MAC_ScanConf_t *));
+
+/**************************************************************************//**
+ \brief Prepare header and payload of the report command.
+
+ \param[in] outPkt - pointer to output packet.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkPrepareReportTx(NwkOutputPacket_t *const outPkt);
+
+/**************************************************************************//**
+ \brief Confirmation of the report command transmission.
+
+ \param[in] outPkt - pointer to output packet.
+ \param[in] status - network status of report transmission.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkConfirmReportTx(NwkOutputPacket_t *const outPkt,
+ const NWK_Status_t status);
+
+/******************************************************************************
+ \brief nwkReportCommand idle checking.
+
+ \return true, if nwkReportCommand performs no activity, false - otherwise.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkReportCommandIsIdle(void);
+
+#else /* _RESOLVE_PANID_CONFLICT_ */
+
+/* Interface of the report command is disabled. */
+#define nwkDetectPanIdConflict(beaconNotify)
+#define nwkResetReportCommand() (void)0
+#define nwkSearchOtherNetworks(macScan, MAC_ScanConf)
+#define nwkPrepareReportTx NULL
+#define nwkConfirmReportTx NULL
+#define nwkReportCommandIsIdle NULL
+
+#endif /* _RESOLVE_PANID_CONFLICT_ */
+#endif /* _NWK_REPORT_COMMAND_H */
+/** eof nwkReportCommand.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkReset.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkReset.h
new file mode 100644
index 00000000..d0e1dfb6
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkReset.h
@@ -0,0 +1,100 @@
+/**************************************************************************//**
+ \file nwkReset.h
+
+ \brief NWK reset header file.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2007-06-20 V. Panov - Created.
+ 2009-03-07 M. Gekk - Refactoring.
+ Last change:
+ $Id: nwkReset.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_RESET_H
+#define _NWK_RESET_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <queue.h>
+#include <mac.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Internal states of the NLME-RESET component. */
+typedef enum _NwkResetState_t
+{
+ NWK_RESET_IDLE_STATE = 0x19,
+ NWK_RESET_FIRST_STATE = 0xC1,
+ NWK_RESET_BEGIN_STATE = NWK_RESET_FIRST_STATE,
+ NWK_RESET_CONFIRM_STATE = 0xC2,
+ NWK_RESET_MAC_STATE = 0xC3,
+ NWK_RESET_RX_ENABLE_STATE = 0xC4,
+ NWK_RESET_SET_SHORT_ADDRESS_STATE = 0xC5,
+ NWK_RESET_SET_COORD_SHORT_ADDR_STATE = 0xC6,
+ NWK_RESET_SET_PANID_STATE = 0xC7,
+ NWK_RESET_SET_COORD_EXT_ADDR_STATE = 0xC8,
+ NWK_RESET_SET_ASSOC_PAN_COORD_STATE = 0xC9,
+ NWK_RESET_SET_CHANNEL_STATE = 0xCA,
+ NWK_RESET_SET_RX_ON_WHEN_IDLE_STATE = 0xCB,
+ NWK_RESET_SET_BEACON_PAYLOAD_STATE = 0xCC,
+ NWK_RESET_SET_BEACON_PAYLOAD_LEN_STATE = 0xCD,
+ NWK_RESET_SET_ASSOC_PERMIT_STATE = 0xCE,
+ NWK_RESET_MAC_START_STATE = 0xCF,
+ NWK_RESET_SET_TRANSACTION_TIME_STATE = 0xD0,
+ NWK_RESET_LAST_STATE
+} NwkResetState_t;
+
+/** Internal parameters of NLME-RESET component. */
+typedef struct _NwkReset_t
+{
+ /** Finite-state machine */
+ NwkResetState_t state;
+ /** Queue of requests from upper layer */
+ QueueDescriptor_t queue;
+ union
+ {
+ MAC_ResetReq_t reset;
+ MAC_SetReq_t set;
+ MAC_RxEnableReq_t rxEnable;
+ MAC_StartReq_t start;
+ } mac;
+} NwkReset_t;
+
+/** Type of reset function. */
+typedef void (* nwkResetFunction_t)(void);
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Task handler of reset component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetTaskHandler(void);
+
+/******************************************************************************
+ \brief nwkReset idle checking.
+
+ \return true, if nwkReset performs no activity, false - otherwise.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkResetIsIdle(void);
+
+/******************************************************************************
+ \brief NWK layer reset phase completion checker.
+
+ \return true, if NWK reset done, false - otherwise.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkResetCompleted(void);
+
+#endif /* _NWK_RESET_H */
+/** eof nwkReset.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouteCache.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouteCache.h
new file mode 100644
index 00000000..2abc7f34
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouteCache.h
@@ -0,0 +1,116 @@
+/**************************************************************************//**
+ \file nwkRouteCache.h
+
+ \brief Interface of the route cache (route record table).
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2010-03-15 M. Gekk - Created.
+ Last change:
+ $Id: nwkRouteCache.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_ROUTE_CACHE_H
+#define _NWK_ROUTE_CACHE_H
+/** See format of the route cache record in ZigBee spec r18, Table 3.45. */
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <mac.h>
+#include <nwkCommon.h>
+#include <nwkRouteRecord.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Type of index in the route cache. */
+typedef uint16_t NwkRouteCacheIndex_t;
+/** Type of total size of the route cache. */
+typedef NwkRouteCacheIndex_t NwkRouteCacheSize_t;
+/** Type of the relay count field. Valid range 0-0xffff.
+ * See Zigbee spec r18, Table 3.45. */
+typedef uint16_t NwkRelayCount_t;
+
+/** Format of a route cache record. ZigBee spec r18, page 350. */
+typedef struct _NwkRouteCacheRecord_t
+{
+ /** The destination network address for this route record.*/
+ ShortAddr_t dstAddr;
+ /** The count of relay nodes from concentrator to the destination.
+ * ZigBee spec r18, Table 3.45, page 350. */
+ NwkRelayCount_t relayCount;
+ /** The set of network addresses that represent the route in order from
+ * the concentrator to the destination. ZigBee spec r18, Table 3.45. */
+ ShortAddr_t path[NWK_MAX_SOURCE_ROUTE];
+} NwkRouteCacheRecord_t;
+
+/* Internal variables and state of the route cache. */
+typedef struct _NwkRouteCache_t
+{
+ /* A set of cached route records. */
+ NwkRouteCacheRecord_t *record;
+ /* Total number of route records. */
+ NwkRouteCacheSize_t size;
+ /* The index of oldest route record. */
+ NwkRouteCacheIndex_t current;
+} NwkRouteCache_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined _NWK_ROUTE_CACHE_
+/**************************************************************************//**
+ \brief Find a record in the route cache by a destination address.
+
+ \param[in] dstAddr - destination short address. Address must be valid.
+ \return Pointer to a record of the route cache if it is found
+ otherwise 'false'.
+ ******************************************************************************/
+NWK_PRIVATE
+NwkRouteCacheRecord_t* nwkFindRouteRecord(const ShortAddr_t dstAddr);
+
+/**************************************************************************//**
+ \brief Add new record into the route cache.
+
+ Preconditions:
+ - Size of relay list must be less NWK_MAX_SOURCE_ROUTE.
+ - Destination address must be valid (range 0x0000-0xFFF7).
+
+ \param[in] dstAddr - destination short address of new route record.
+ \param[in] routeRecordPayload - pointer to payload of a received route record
+ command packet.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkAddRouteRecord(const ShortAddr_t dstAddr,
+ const NwkRouteRecordPayload_t *const routeRecordPayload);
+
+/**************************************************************************//**
+ \brief Delete a record from the route cache.
+
+ \param[in] dstAddr - destination short address for a route record.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkDeleteRouteRecord(const ShortAddr_t dstAddr);
+
+/**************************************************************************//**
+ \brief Reset the route cache.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetRouteCache(void);
+
+#else /* _NWK_ROUTE_CACHE_ */
+
+#define nwkResetRouteCache() (void)0
+
+#endif /* _NWK_ROUTE_CACHE_ */
+#endif /* _NWK_ROUTE_CACHE_H */
+/** eof nwkRouteCache.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouteDiscovery.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouteDiscovery.h
new file mode 100644
index 00000000..996edcff
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouteDiscovery.h
@@ -0,0 +1,91 @@
+/**************************************************************************//**
+ \file nwkRouteDiscovery.h
+
+ \brief Network route discovery header file.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2007-09-05 V. Panov - Created.
+ 2008-09-06 M. Gekk - Modified to support parallel processing.
+ 2010-02-06 M. Gekk - Refactoring.
+ Last change:
+ $Id: nwkRouteDiscovery.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_ROUTE_DISCOVERY_H
+#define _NWK_ROUTE_DISCOVERY_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <queue.h>
+#include <nlmeRouteDiscovery.h>
+#include <nwkCommon.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Internal states of the route discovery component. */
+typedef enum _NwkRouteDiscoveryState_t
+{
+ NWK_ROUTE_DISCOVERY_IDLE_STATE = 0x99,
+ NWK_ROUTE_DISCOVERY_PROCESS_STATE = 0x38
+} NwkRouteDiscoveryState_t;
+
+/** Internal state and variables of route discovery component. */
+typedef struct _NwkRouteDiscovery_t
+{
+ QueueDescriptor_t queue; /**< Queue of requests from other components. */
+ /** Identifier of initial route request. */
+ NwkRouteRequestId_t routeRequestId;
+#if defined _SYS_ASSERT_ON_
+ /** Finite-state machine. */
+ NwkRouteDiscoveryState_t state;
+#endif /* _SYS_ASSERT_ON_ */
+} NwkRouteDiscovery_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined NWK_ROUTING_CAPACITY \
+ && (defined _NWK_MESH_ROUTING_ || defined _NWK_CONCENTRATOR_)
+/**************************************************************************//**
+ \brief Task handler of the route discovery component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkRouteDiscoveryTaskHandler(void);
+
+/******************************************************************************
+ \brief Reset the route discovery component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetRouteDiscovery(void);
+
+/******************************************************************************
+ \brief Flush all route discovery requests.
+ ******************************************************************************/
+NWK_PRIVATE void nwkFlushRouteDiscovery(void);
+
+/******************************************************************************
+ \brief nwkRouteDiscovery idle checking.
+
+ \return true, if nwkRouteDiscovery performs no activity, false - otherwise.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkRouteDiscoveryIsIdle(void);
+
+#else /* no NWK_ROUTING_CAPACITY */
+
+#define nwkRouteDiscoveryTaskHandler NULL
+#define nwkRouteDiscoveryIsIdle NULL
+#define nwkResetRouteDiscovery() (void)0
+#define nwkFlushRouteDiscovery() (void)0
+
+#endif /* NWK_ROUTING_CAPACITY and (_NWK_MESH_ROUTING_ or _NWK_CONCENTRATOR_) */
+#endif /* _NWK_ROUTE_DISCOVERY_H */
+/** eof nwkRouteDiscovery.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouteDiscoveryTable.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouteDiscoveryTable.h
new file mode 100644
index 00000000..c25509a2
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouteDiscoveryTable.h
@@ -0,0 +1,240 @@
+/**************************************************************************//**
+ \file nwkRouteDiscoveryTable.h
+
+ \brief Interface of the route discovery table.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2007-09-17 V. Panov - Created.
+ 2010-02-04 M. Gekk - Redesign.
+ Last change:
+ $Id: nwkRouteDiscoveryTable.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+/**//**
+ * A ZigBee router or ZigBee coordinator maintains a route discovery table
+ * containing the information that is required during route discovery.
+ **/
+#if !defined _NWK_ROUTE_DISCOVERY_TABLE_H
+#define _NWK_ROUTE_DISCOVERY_TABLE_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <nwkSystem.h>
+#include <appFramework.h>
+#include <appTimer.h>
+#include <nwkCommon.h>
+#include <nlmeRouteDiscovery.h>
+#include <nwkPacket.h>
+
+/******************************************************************************
+ Define(s) section
+ ******************************************************************************/
+#define NWK_RDISC_IS_MANY_TO_ONE(routeDiscoveryEntry) \
+ (NWK_DSTADDRMODE_NOADDR == (routeDiscoveryEntry)->dstAddrMode)
+#define NWK_RDISC_IS_MULTICAST(routeDiscoveryEntry) \
+ (NWK_DSTADDRMODE_MULTICAST == (routeDiscoveryEntry)->dstAddrMode)
+#define NWK_RDISC_IS_UNICAST(routeDiscoveryEntry) \
+ (NWK_DSTADDRMODE_SHORT == (routeDiscoveryEntry)->dstAddrMode)
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Route discovery table entry. See ZigBee spec r18, Table 3.53, page 391. */
+typedef struct _NwkRouteDiscoveryEntry_t
+{
+ /** Time-to-live of entry. If this field is equal to 0 then entry is inactive.
+ **/
+ uint8_t ttl;
+ /* For this entry route request transmission is required or not. */
+ bool routeRequestRequired : 1;
+ /** A flag indicating that route request is required on originator. */
+ bool initialRouteRequest : 1;
+ /* For this entry route reply transmission is required or not. */
+ bool routeReplyRequired : 1;
+ bool highPriority : 1;
+ /** A flag indicating that the concentrator does not store source routes. */
+ bool noRouteCache : 1;
+ /* - NWK_DSTADDRMODE_NOADDR - this value indicating that the source node
+ * is a concentrator that issued a many-to-one route request.
+ * - NWK_DSTADDRMODE_MULTICAST - the destination address is a Group ID.
+ * - NWK_DSTADDRMODE_SHORT - unicast route discovery.
+ * */
+ NwkBitField_t dstAddrMode : 2;
+ bool reserved : 1;
+ /** The accumulated path cost from the source of
+ * the route request to the current device. */
+ NwkPathCost_t forwardCost;
+ /** The accumulated path cost from the current device
+ * to the destination device. */
+ NwkPathCost_t residualCost;
+ /** The 16-bit network address of the route request's initiator. */
+ ShortAddr_t srcAddr;
+ /** The 16-bit network address of the device that has sent the most recent
+ * lowest cost route request command frame corresponding to this entry's
+ * route request identifier and source address. This field is used to
+ * determine the path that an eventual route reply command frame should
+ * follow. */
+ ShortAddr_t senderAddr;
+ /** Destination short address or group id of route discovery request. */
+ ShortAddr_t dstAddr;
+ /** A sequence number for a route request command frame that is incremented
+ * each time a device initiates a route request. */
+ NwkRouteRequestId_t routeRequestId;
+ /** Current hop distance from originator of route descovery. */
+ NwkRadius_t radius;
+ /** Sequence number of initial route request command. */
+ uint8_t sequenceNumber;
+ /** Initial route request parameters. */
+ NWK_RouteDiscoveryReq_t *req;
+ /** Pointer to output network packet. */
+ NwkOutputPacket_t *outPkt;
+} NwkRouteDiscoveryEntry_t;
+
+/** State of processing of incoming requests to send route request
+ * or reply commands. */
+typedef enum _NwkRouteDiscoveryTableState_t
+{
+ NWK_RDISC_TABLE_IDLE_STATE = 0x00,
+ /** Preparing and sending of route reqply or request command. */
+ NWK_RDISC_TABLE_REQUEST_PROCESSING_STATE = 0x93,
+ /** Wating a free packet from the network packet manager. */
+ NWK_RDISC_TABLE_WAIT_PACKET_STATE = 0x1A
+} NwkRouteDiscoveryTableState_t;
+
+/**
+ * Route discovery table - a table used by a ZigBee coordinator or ZigBee router
+ * to store temporary information used during route discovery.
+ **/
+typedef struct _NwkRouteDiscoveryTable_t
+{
+ /** The countdown timer that is used for decrement of time-to-live fields.*/
+ HAL_AppTimer_t timer;
+ /** Pointer to the route discovery table. */
+ NwkRouteDiscoveryEntry_t *table;
+ /** Pointer to memory area after last entry of the route discovery table. */
+ NwkRouteDiscoveryEntry_t *end;
+ /** Current state of the route discovery table. */
+ NwkRouteDiscoveryTableState_t state;
+ /** Boolean flag indicating that the countdown timer is started. */
+ bool isTimerStarted;
+} NwkRouteDiscoveryTable_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined NWK_ROUTING_CAPACITY \
+ && (defined _NWK_MESH_ROUTING_ || defined _NWK_MANY_TO_ONE_ROUTING_)
+/**************************************************************************//**
+ \brief Allocate place for new discovery request in the route discovery table.
+
+ \param[in] highPriority - if new entry is important
+ then this parameter is 'true' otherwise 'false'.
+ \return Pointer to an allocated route discovery entry or NULL.
+ ******************************************************************************/
+NWK_PRIVATE
+NwkRouteDiscoveryEntry_t* nwkAllocRouteDiscoveryEntry(const bool highPriority);
+
+/**************************************************************************//**
+ \brief Find an active route discovery entry by route request id and source address.
+
+ \param[in] srcAddr - network address of route discovery originator.
+ \param[in] requestId - identifier of initial route request.
+ \return Pointer to a route discovery entry or NULL if entry is not found.
+ ******************************************************************************/
+NWK_PRIVATE NwkRouteDiscoveryEntry_t* nwkFindRouteDiscoveryEntry(
+ const ShortAddr_t srcAddr,
+ const NwkRouteRequestId_t requestId);
+
+/**************************************************************************//**
+ \brief Main task handler of the NWK route discovery component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkRouteDiscoveryTableTaskHandler(void);
+
+/**************************************************************************//**
+ \brief Indication about network packet realizing.
+ ******************************************************************************/
+NWK_PRIVATE void nwkRouteDiscoveryTableFreePacketInd(void);
+
+/**************************************************************************//**
+ \brief Reset internal state and entries of the route discovery table.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetRouteDiscoveryTable(void);
+
+/**************************************************************************//**
+ \brief Stop processing of route discovery entries.
+ ******************************************************************************/
+NWK_PRIVATE void nwkFlushRouteDiscoveryTable(void);
+
+/**************************************************************************//**
+ \brief Prepare and send the route request command.
+
+ \param[in] entry - pointer to a route discovery entry that is required
+ transmission of route request command.
+ \param[in] isInitialRequest - 'true' if this node is originator
+ of route discovery otherwise 'false'.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE
+void nwkSendRouteDiscoveryRequest(NwkRouteDiscoveryEntry_t *const entry,
+ const bool isInitialRequest);
+
+/******************************************************************************
+ \brief nwkRouteDiscoveryTable idle checking.
+
+ \return true, if nwkRouteDiscoveryTable performs no activity, false - otherwise.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkRouteDiscoveryTableIsIdle(void);
+
+#if defined _NWK_MESH_ROUTING_
+/**************************************************************************//**
+ \brief Prepare and send the route reply command.
+
+ \param[in] entry - pointer to a route discovery entry that is required
+ transmission of route reply command.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE
+void nwkSendRouteDiscoveryReply(NwkRouteDiscoveryEntry_t *const entry);
+#endif /* _NWK_MESH_ROUTING_ */
+
+/**************************************************************************//**
+ \brief Reliably adding a path cost and a link cost.
+
+ \param[in] pathCost - cost of path.
+ \param[in] linkCost - cost of link.
+ \return Summary path cost.
+ ******************************************************************************/
+NWK_PRIVATE NwkPathCost_t nwkSumPathCost(const NwkPathCost_t pathCost,
+ const NwkLinkCost_t linkCost);
+
+/**************************************************************************//**
+ \brief Confirmation of the route request transmission.
+
+ \param[in] outPkt - pointer to output packet.
+ \param[in] status - network status of route request transmission.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkConfirmRouteRequestTx(NwkOutputPacket_t *const outPkt,
+ const NWK_Status_t status);
+
+#else /* NWK_ROUTING_CAPACITY and _NWK_MESH_ROUTING_ */
+
+#define nwkRouteDiscoveryTableTaskHandler NULL
+#define nwkConfirmRouteRequestTx NULL
+#define nwkRouteDiscoveryTableIsIdle NULL
+#define nwkResetRouteDiscoveryTable() (void)0
+#define nwkRouteDiscoveryTableFreePacketInd() (void)0
+
+#endif /* NWK_ROUTING_CAPACITY and (_NWK_MESH_ROUTING_ or _NWK_MANY_TO_ONE_ROUTING_) */
+#endif /* _NWK_ROUTE_DISCOVERY_TABLE_H */
+/* eof nwkRouteDiscoveryTable.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouteRecord.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouteRecord.h
new file mode 100644
index 00000000..144628c9
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouteRecord.h
@@ -0,0 +1,172 @@
+/**************************************************************************//**
+ \file nwkRouteRecord.h
+
+ \brief Interface of the route record functionality.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2007-09-28 V. Panov - Created.
+ 2008-12-10 M. Gekk - Memory optimization.
+ 2010-03-07 M. Gekk - Redesign.
+ Last change:
+ $Id: nwkRouteRecord.h 18167 2011-08-08 11:26:31Z mgekk $
+ ******************************************************************************/
+/**//**
+ * The route record command allows the route taken by a unicast packet
+ * through the network to be recorded in the command payload and delivered
+ * to the destination device. ZigBee spec r18, 3.4.5, page 330.
+ **/
+#if !defined _NWK_ROUTE_RECORD_H
+#define _NWK_ROUTE_RECORD_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <queue.h>
+#include <nwkCommon.h>
+#include <nldeData.h>
+#include <nwkFrame.h>
+
+/******************************************************************************
+ Define(s) section
+ ******************************************************************************/
+#define NWK_ROUTE_RECORD_TX_PARAMETERS \
+ {NWK_TX_DELAY_INITIAL_ROUTE_RECORD, nwkPrepareRouteRecordTx, \
+ nwkConfirmRouteRecordTx, true}
+#define NWK_ROUTE_RECORD_TRANSIT_TX_PARAMETERS \
+ {NWK_TX_DELAY_UNICAST_COMMAND, nwkPrepareTransitRouteRecordTx, NULL, true}
+#define NWK_IS_NOT_ROUTE_RECORD(outPkt) \
+ ((NWK_ROUTE_RECORD_TX_ID != (outPkt)->txId) && \
+ (NWK_ROUTE_RECORD_TRANSIT_TX_ID != (outPkt)->txId))
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Route record command format. ZigBee spec r18, Figure 3.18, page 330. */
+BEGIN_PACK
+typedef struct PACK _NwkRouteRecordPayload_t
+{
+ /** The identifier of the route request command. */
+ uint8_t commandId;
+ /** This field contains the number of relays in the relay list field of
+ * the route record command. ZigBee spec r18, 3.4.5.3.1, page 331. */
+ uint8_t relayCount;
+ /** The relay list field is a list of the 16-bit network addresses of the nodes
+ * that have relayed the packet. ZigBee spec r18, 3.4.5.3.2, page 331. */
+ ShortAddr_t relayList[NWK_MAX_SOURCE_ROUTE];
+} NwkRouteRecordPayload_t;
+END_PACK
+
+/** Internal states of the route record component */
+typedef enum _NwkRouteRecordState_t
+{
+ NWK_ROUTE_RECORD_IDLE_STATE = 0x2E,
+ NWK_ROUTE_RECORD_FIRST_STATE = 0xF6,
+ NWK_ROUTE_RECORD_BEGIN_STATE = NWK_ROUTE_RECORD_FIRST_STATE,
+ NWK_ROUTE_RECORD_PREPARE_STATE = 0xF7,
+ NWK_ROUTE_RECORD_SEND_STATE = 0xF8,
+ NWK_ROUTE_RECORD_CONFIRM_STATE = 0xF9,
+ NWK_ROUTE_RECORD_LAST_STATE
+} NwkRouteRecordState_t;
+
+/** Internal variables and state of the route record component. */
+typedef struct _NwkRouteRecord_t
+{
+ QueueDescriptor_t queue; /**< Queue of requests from other NWK components. */
+ NwkRouteRecordState_t state; /**< finite-state machine. */
+} NwkRouteRecord_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined NWK_ROUTING_CAPACITY && defined _NWK_ROUTE_RECORD_
+/**************************************************************************//**
+ \brief Send the route record command before given output packet.
+
+ \param[in] outPkt - pointer to output packet for which route record is sending.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkRouteRecordReq(NwkOutputPacket_t *const outPkt);
+
+/**************************************************************************//**
+ \brief Transmission of the route record command is done.
+
+ \param[in] outPkt - pointer to output packet for which route record is sending.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkRouteRecordConf(NwkOutputPacket_t *const outPkt);
+
+/**************************************************************************//**
+ \brief Prepare header and payload of the route record command.
+
+ \param outPkt - pointer to output packet.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkPrepareRouteRecordTx(NwkOutputPacket_t *const outPkt);
+
+/**************************************************************************//**
+ \brief Confirmation of the route record command transmission.
+
+ \param outPkt - pointer to output packet.
+ \param status - network status of route record transmission.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkConfirmRouteRecordTx(NwkOutputPacket_t *const outPkt,
+ const NWK_Status_t status);
+
+/**************************************************************************//**
+ \brief Relay list of transit route record is changed.
+
+ \param outPkt - pointer to output packet.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE
+void nwkPrepareTransitRouteRecordTx(NwkOutputPacket_t *const outPkt);
+
+/**************************************************************************//**
+ \brief Reset the route record component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetRouteRecord(void);
+
+/**************************************************************************//**
+ \brief Main task handler of the route record component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkRouteRecordTaskHandler(void);
+
+#else /* NWK_ROUTING_CAPACITY and _NWK_ROUTE_RECORD_ */
+
+#define nwkPrepareRouteRecordTx NULL
+#define nwkConfirmRouteRecordTx NULL
+#define nwkPrepareTransitRouteRecordTx NULL
+#define nwkResetRouteRecord() (void)0
+#define nwkRouteRecordTaskHandler NULL
+
+#endif /* NWK_ROUTING_CAPACITY and _NWK_ROUTE_RECORD_ */
+
+#if defined NWK_ROUTING_CAPACITY && defined _NWK_ROUTE_CACHE_
+/******************************************************************************
+ \brief Action when a route record command is received.
+
+ \param payload - pointer to raw command payload.
+ \param header - pointer to raw NWK header of command.
+ \param parse - parsed NWK header fields.
+ \return 'true' if continue processing of command packet otherwise 'false'.
+******************************************************************************/
+NWK_PRIVATE bool nwkRouteRecordFrameInd(const uint8_t *const payload,
+ const NwkFrameHeader_t *const header, const NwkParseHeader_t *const parse);
+
+#else /* NWK_ROUTING_CAPACITY and _NWK_ROUTE_CACHE_*/
+#define nwkRouteRecordFrameInd NULL
+#endif /* NWK_ROUTING_CAPACITY and _NWK_ROUTE_CACHE_ */
+
+#endif /* _NWK_ROUTE_RECORD_H */
+/** eof nwkRouteRecord.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouteReply.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouteReply.h
new file mode 100644
index 00000000..f0b8c0f2
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouteReply.h
@@ -0,0 +1,125 @@
+/**************************************************************************//**
+ \file nwkRouteReply.h
+
+ \brief Route reply command types and functions.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2007-09-17 V. Panov - Created.
+ 2009-11-07 M. Gekk - Refactoring.
+ Last change:
+ $Id: nwkRouteReply.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_ROUTE_REPLY_H
+#define _NWK_ROUTE_REPLY_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <nwkSystem.h>
+#include <appFramework.h>
+#include <nwkCommon.h>
+#include <nldeData.h>
+#include <nwkFrame.h>
+#include <nwkRouteDiscoveryTable.h>
+
+/******************************************************************************
+ Define(s) section
+ ******************************************************************************/
+#define NWK_ROUTE_REPLY_TX_PARAMETERS \
+ {NWK_TX_DELAY_UNICAST_COMMAND, NULL, NULL, true}
+/* Maximum amount of extended addresses in the route reply payload. */
+#define NWK_MAX_RREPLY_EXT_ADDR_AMOUNT 2U
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** The options field of route reply command. ZigBee spec. r17, Figure 3.14. */
+BEGIN_PACK
+typedef struct PACK _NwkRouteReplyOptions_t
+{
+ LITTLE_ENDIAN_OCTET(5, (
+ NwkBitField_t reserved1 : 4,
+ /** If this field has value of 1 then the IEEE address of originator is
+ * included in the payload of the route reply command. */
+ NwkBitField_t extAddrOfOriginator : 1,
+ /** If this field has value of 1 then the IEEE address of responder is
+ * included in the payload of the route reply command. */
+ NwkBitField_t extAddrOfResponder : 1,
+ /** This field shall have a value of 1 if and only if the command frame is
+ * a reply to a request for a route to a multicast group. */
+ NwkBitField_t multicast : 1,
+ NwkBitField_t reserved2 : 1
+ ))
+} NwkRouteReplyOptions_t;
+
+/** The NWK payload of the route reply command. */
+typedef struct PACK _NwkRouteReplyPayload_t
+{
+ /** The identifier of the route reply command. */
+ NwkCommandIdField_t commandId;
+ /** The format of the 8-bit command options field is shown in
+ * ZigBee spec r17, Figure 3.14, page 319. */
+ NwkRouteReplyOptions_t options;
+ /** The route request identifier is the number of the route request to which
+ * this frame is a reply. ZigBee spec r17, 3.4.2.3.2. */
+ uint8_t routeRequestId;
+ /** The network address of the originator of the route request command frame
+ * to which this frame is a reply. ZigBee spec r17, 3.4.2.3.3, page 320. */
+ ShortAddr_t shortAddrOfOriginator;
+ /** The responder address field shall always be the same as the value
+ * in the destination address field of the corresponding route request
+ * command frame.*/
+ ShortAddr_t shortAddrOfResponder;
+ /** The path cost field is used to sum link cost as the route reply
+ * command frame transits the network. */
+ NwkPathCost_t pathCost;
+ /** The first element contain the 64-bit address of the originator of
+ * the route request command frame to which this frame is a reply.
+ * The second element contain the 64-bit address of the destination of
+ * the route request command frame to which this frame is a reply.*/
+ ExtAddr_t extAddr[NWK_MAX_RREPLY_EXT_ADDR_AMOUNT];
+} NwkRouteReplyPayload_t;
+END_PACK
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined NWK_ROUTING_CAPACITY && defined _NWK_MESH_ROUTING_
+/******************************************************************************
+ \brief Action when command received.
+
+ \param[in] payload - pointer to payload of route reply command.
+ \param[in] header - pointer to raw network header of route reply command.
+ \param[in] parse - parsed header fields.
+ \return 'true' if continue processing of command packet otherwise 'false'.
+******************************************************************************/
+NWK_PRIVATE bool nwkRouteReplyFrameInd(const uint8_t *const payload,
+ const NwkFrameHeader_t *const header, const NwkParseHeader_t *const parse);
+
+/**************************************************************************//**
+ \brief Prepare header and payload of the route reply command.
+
+ \param[in] outPkt - pointer to output packet.
+ \param[in] entry - pointer to a route discovery entry.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkPrepareRouteReplyTx(NwkOutputPacket_t *const outPkt,
+ NwkRouteDiscoveryEntry_t *const entry);
+
+#else /* NWK_ROUTING_CAPACITY */
+
+#define nwkRouteReplyFrameInd NULL
+
+#endif /* NWK_ROUTING_CAPACITY */
+#endif /* _NWK_ROUTE_REPLY_H */
+/** eof nwkRouteReply.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouteRequest.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouteRequest.h
new file mode 100644
index 00000000..45bf6d03
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouteRequest.h
@@ -0,0 +1,149 @@
+/**************************************************************************//**
+ \file nwkRouteRequest.h
+
+ \brief Interface of route request commands.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2007-09-17 V. Panov - Created.
+ 2008-12-10 M. Gekk - Optimization of NWK memory.
+ 2009-11-20 M. Gekk - Refactoring.
+ Last change:
+ $Id: nwkRouteRequest.h 18498 2011-09-12 08:49:29Z mgekk $
+ ******************************************************************************/
+#if !defined _NWK_ROUTE_REQUEST_H
+#define _NWK_ROUTE_REQUEST_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <nwkSystem.h>
+#include <appFramework.h>
+#include <nldeData.h>
+#include <nwkFrame.h>
+#include <nwkRouteDiscoveryTable.h>
+
+/******************************************************************************
+ Define(s) section
+ ******************************************************************************/
+/** Transmission parameters of route request command. */
+#define NWK_INITIAL_ROUTE_REQ_TX_PARAMETERS \
+ {NWK_TX_DELAY_INITIAL_ROUTE_REQUEST, NULL, nwkConfirmRouteRequestTx, true}
+#define NWK_ROUTE_REQ_TX_PARAMETERS \
+ {NWK_TX_DELAY_ROUTE_REQUEST, NULL, NULL, true}
+#define NWK_INITIAL_MANYTOONE_ROUTE_REQ_TX_PARAMETERS \
+ {NWK_TX_DELAY_INITIAL_MANYTOONE_ROUTE_REQUEST, NULL, nwkConfirmRouteRequestTx, true}
+#define NWK_MANYTOONE_ROUTE_REQ_TX_PARAMETERS \
+ {NWK_TX_DELAY_MANYTOONE_ROUTE_REQUEST, NULL, NULL, true}
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Many-to-One field values. See ZigBee spec r18, 3.4.1.3.1.1, page 320. */
+typedef enum _NwkRReqManyToOneFlag_t
+{
+ /** The route request is not a many-to-one route request. */
+ NWK_RREQ_IS_NOT_MANY_TO_ONE = 0,
+ /** The route request is a many-to-one route request and the sender supports
+ * a route record table.*/
+ NWK_RREQ_IS_MANY_TO_ONE = 1,
+ /** The route request is a many-to-one route request and the sender does not
+ * support a route record table. */
+ NWK_RREQ_IS_MANY_TO_ONE_NO_RREC_TABLE = 2,
+ NWK_RREQ_RESERVED_MANY_TO_ONE_FLAG = 3
+} NwkRReqManyToOneFlag_t;
+
+BEGIN_PACK
+/** Route request command options field. ZigBee spec r18, 3.4.1.3.1, page 320.
+ **/
+typedef struct PACK _NwkRouteRequestOptions_t
+{
+ LITTLE_ENDIAN_OCTET(5, (
+ NwkBitField_t reserved1 : 3,
+ /** The many-to-one field shall have one of the non-reserved values shown
+ * in ZigBee spec r18, Table 3.41 and type NwkRReqManyToOneFlag_t. */
+ NwkBitField_t manyToOne : 2,
+ /** The destination IEEE address field is a single-bit field. It shall have
+ * a value of 1 if, and only if, the command frame contains the destination
+ * IEEE address. ZigBee spec r18, 3.4.1.3.1.2, page 321. */
+ NwkBitField_t dstExt : 1,
+ /** The multicast sub-field is a single-bit field. It shall have a value
+ * of 1 if, and only if, the command frame is a request for a route
+ * to a multicast group... ZigBee spec r18, 3.4.1.3.1.3, page 321. */
+ NwkBitField_t multicast : 1,
+ NwkBitField_t reserved2 : 1
+ ))
+} NwkRouteRequestOptions_t;
+END_PACK
+
+BEGIN_PACK
+/** Route request command frame format. See ZigBee spec r18,
+ * Figure 3.11, page 319. */
+typedef struct PACK _NwkRouteRequestPayload_t
+{
+ /** The identifier of the route request command. */
+ uint8_t commandId;
+ /** Route request command options field. See NwkRouteRequestOptions_t. */
+ NwkRouteRequestOptions_t options;
+ /** The route request identifier is an 8-bit sequence number for route
+ * requests and is incremented by 1 every time the NWK layer on a particular
+ * device issues a route request. ZigBee spec r18, 3.4.1.3.2, page 321. */
+ NwkRouteRequestId_t identifier;
+ /** The destination address shall be 2 octets in length and represents
+ * the intended destination of the route request command frame.
+ * ZigBee spec r18, 3.4.1.3.3. */
+ ShortAddr_t dstAddr;
+ /** The path cost field is eight bits in length and is used to accumulate
+ * routing cost information as a route request command frame moves through
+ * the network. ZigBee spec r18, 3.4.1.3.4, page 321; sub-clause 3.6.3.5.2. */
+ NwkPathCost_t pathCost;
+ /** The destination IEEE address shall be 8 octets in length and represents
+ * the IEEE address of the destination of the route request command frame.
+ ** ZigBee spec r18, 3.4.1.3.5, page 321. */
+ ExtAddr_t dstExtAddr;
+} NwkRouteRequestPayload_t;
+END_PACK
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined NWK_ROUTING_CAPACITY \
+ && (defined _NWK_MESH_ROUTING_ || defined _NWK_MANY_TO_ONE_ROUTING_)
+/**************************************************************************//**
+ \brief Action when route request command received.
+
+ \param[in] payload - pointer to payload of route request command.
+ \param[in] header - pointer to raw network header of route request command.
+ \param[in] parse - parsed header fields.
+
+ \return 'true' if continue processing of command packet otherwise 'false'.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkRouteRequestFrameInd(const uint8_t *const payload,
+ const NwkFrameHeader_t *const header, const NwkParseHeader_t *const parse);
+
+/**************************************************************************//**
+ \brief Prepare header and payload of the route request command.
+
+ \param[in] outPkt - pointer to output packet.
+ \param[in] entry - pointer to a route discovery entry.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkPrepareRouteRequestTx(NwkOutputPacket_t *const outPkt,
+ NwkRouteDiscoveryEntry_t *const entry);
+
+#else /* NWK_ROUTING_CAPACITY and (_NWK_MESH_ROUTING_ or _NWK_MANY_TO_ONE_ROUTING_) */
+
+#define nwkRouteRequestFrameInd NULL
+
+#endif /* NWK_ROUTING_CAPACITY and (_NWK_MESH_ROUTING_ or _NWK_MANY_TO_ONE_ROUTING_) */
+#endif /* _NWK_ROUTE_REQUEST_H */
+/** eof nwkRouteRequest.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouting.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouting.h
new file mode 100644
index 00000000..3ed7e025
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouting.h
@@ -0,0 +1,71 @@
+/**************************************************************************//**
+ \file nwkRouting.h
+
+ \brief Routing header file.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2007-06-14 V. Panov - Created.
+ 2008-09-06 M. Gekk - Modified to support parallel processing.
+ 2009-09-08 M. Gekk - Refactoring.
+ Last change:
+ $Id: nwkRouting.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_ROUTING_H
+#define _NWK_ROUTING_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <appFramework.h>
+#include <nldeData.h>
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Getting MAC short address of next hop by destination network address.
+
+ \param[in] dstAddr - destination network address.
+ \param[in] srcAddr - short address of node for that a next hop is searched.
+ \param[in] prevHopAddr - address of previous hop.
+ \param[in] isMulticast - 'true' if destination address is multicast group.
+ \param[in] isMulticastMember - 'true' if destination address is multicast
+ member address.
+ \param[in] nextHop - pointer to short address of next hop node
+ or MAC_NO_SHORT_ADDR.
+ \param[in] hops - number of hops that is equal to CS_MAX_NETWORK_DEPTH * 2.
+ It is not read in function to avoid unnecessary reading of
+ CS_MAX_NETWORK_DEPTH when not implementing routing of packet
+ from upper layer.
+
+ \return Routing method used for searching the next hop node.
+ ******************************************************************************/
+NWK_PRIVATE NwkRouting_t nwkGetNextHop(const ShortAddr_t dstAddr,
+ const ShortAddr_t srcAddr, const ShortAddr_t prevHopAddr,
+ const bool isMulticast, const bool isMulticastMember,
+ ShortAddr_t *const nextHop, NwkRadius_t hops);
+
+/**************************************************************************//**
+ \brief Process routing result.
+
+ Update link state, the routing table and indicate to upper layer..
+
+ \param[in] outPkt - pointer to output packet.
+ \param[in] nwkStatus - status of transmission.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkRoutingIsCompleted(const NwkOutputPacket_t *const outPkt,
+ const NWK_Status_t nwkStatus);
+
+#endif /* _NWK_ROUTING_H */
+/** eof nwkRouting.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRoutingTable.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRoutingTable.h
new file mode 100644
index 00000000..b0a80408
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRoutingTable.h
@@ -0,0 +1,162 @@
+/**************************************************************************//**
+ \file nwkRoutingTable.h
+
+ \brief Interface of the routing table.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2009-11-15 Max Gekk - Created.
+ Last change:
+ $Id: nwkRoutingTable.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_ROUTING_TABLE_H
+#define _NWK_ROUTING_TABLE_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <appFramework.h>
+#include <nwkCommon.h>
+#include <nwkSystem.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Type of routing table size. */
+typedef uint8_t NwkRoutingTableSize_t;
+/** Type of routing entry index. */
+typedef NwkRoutingTableSize_t NwkRoutingEntryIndex_t;
+/** Type of routing rate. */
+typedef uint8_t NwkRoutingRate_t;
+
+/** Routing table entry. ZigBee spec r17, Table 3.51. */
+typedef struct _NwkRoutingTableEntry_t
+{
+ /** The 16-bit network address or Group ID of this route. If the destination
+ * device is a ZigBee router, ZigBee coordinator, or an end device, and
+ * nwkAddrAlloc has a value of 0x02, this field shall contain the actual
+ * 16-bit address of that device. If the destination device is an end device
+ * and nwkAddrAlloc has a value of 0x00, this field shall contain the 16-bit
+ * network address of the device's parent. */
+ ShortAddr_t dstAddr;
+ /** The 16-bit network address of the next hop on the way to the destination.
+ **/
+ ShortAddr_t nextHopAddr;
+ /** A flag indicating that the entry is active. */
+ bool active : 1;
+ /** A flag indicating that the destination indicated by this address does
+ * not store source routes. */
+ bool noRouteCache : 1;
+ /** A flag indicating that the destination is a concentrator
+ * that issued a many-to-one route request. */
+ bool manyToOne : 1;
+ /** A flag indicating that a route record command frame should be sent to
+ * the destination prior to the next data packet. */
+ bool routeRecordRequired : 1;
+ /** A flag indicating that the destination address is a Group ID. */
+ bool groupId : 1;
+ /** Counter of the many-to-one discovery periods
+ * without any source route packets. */
+ NwkBitField_t noSourceRoutePeriods : 2;
+ /** Indicate to upper layer about new concentrator. */
+ bool newConcentrator : 1;
+ NwkRoutingRate_t rate;
+ /** Cost of route path to destination node. */
+ NwkPathCost_t cost;
+} NwkRoutingTableEntry_t;
+
+/** The routing table. */
+typedef struct _NwkRoutingTable_t
+{
+ /** Pointer to first entry of the routing table. */
+ NwkRoutingTableEntry_t *table;
+ /** Current size of the routing table. */
+ NwkRoutingTableSize_t size;
+ /* Number of failure transmission after that a routing entry will be deleted.
+ **/
+ uint8_t failOrder;
+} NwkRoutingTable_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined NWK_ROUTING_CAPACITY \
+ && (defined _NWK_MESH_ROUTING_ || defined _NWK_MANY_TO_ONE_ROUTING_)
+/**************************************************************************//**
+ \brief Allocate a new entry in the routing table.
+
+ \return pointer to an entry or NULL.
+ ******************************************************************************/
+NWK_PRIVATE NwkRoutingTableEntry_t* nwkAllocRoutingEntry(void);
+
+/**************************************************************************//**
+ \brief Free the entry of the routing table.
+
+ \param[in] dstAddr - a short address of destination node.
+ \param[in] isGroupId - 'true' if dstAddr is group id otherwise 'false'.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkFreeRoutingEntry(const ShortAddr_t dstAddr,
+ const bool isGroupId);
+
+/**************************************************************************//**
+ \brief Find a routing table entry by destination address.
+
+ \param[in] dstAddr - a short address of destination node.
+ \param[in] isGroupId - 'true' if dstAddr is group id otherwise 'false'.
+
+ \return pointer to a routing table entry with given dstAddr.
+ ******************************************************************************/
+NWK_PRIVATE
+NwkRoutingTableEntry_t* nwkFindRoutingEntry(const ShortAddr_t dstAddr,
+ const bool isGroupId);
+
+/******************************************************************************
+ \brief Update information of the routing table entry after a packet transmission.
+
+ \param[in] entry - pointer to an entry in the routing table.
+ \param status - NWK status of packet transmission.
+ ******************************************************************************/
+NWK_PRIVATE void nwkUpdateRoutingEntry(NwkRoutingTableEntry_t *const entry,
+ const NWK_Status_t status);
+
+/**************************************************************************//**
+ \brief Reset the routing table.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetRoutingTable(void);
+
+#if defined _NWK_MESH_ROUTING_
+/**************************************************************************//**
+ \brief Setting the next hop address of the routing table entry.
+
+ \param[in] dstAddr - a short address of destination node.
+ \param[in] nextHopAddr - short address of next hop node.
+ \param[in] isGroupId - 'true' if dstAddr is group id otherwise 'false'.
+ \param[in] cost - cost of path to destination node.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkUpdateNextHop(const ShortAddr_t dstAddr,
+ const bool isGroupId, const ShortAddr_t nextHopAddr,
+ const NwkPathCost_t cost);
+
+#else
+#define nwkUpdateNextHop(dstAddr, isGroupId, nextHopAddr, cost) (void)0
+#endif /* _NWK_MESH_ROUTING_ */
+#else /* NWK_ROUTING_CAPACITY and (_NWK_MESH_ROUTING_ or _NWK_MANY_TO_ONE_ROUTING_) */
+
+#define nwkResetRoutingTable() (void)0
+#define nwkUpdateNextHop(dstAddr, isGroupId, nextHopAddr, cost) (void)0
+#define nwkFreeRoutingEntry(dstAddr, isGroupId) (void)0
+
+#endif /* NWK_ROUTING_CAPACITY and (_NWK_MESH_ROUTING_ or _NWK_MANY_TO_ONE_ROUTING_) */
+#endif /* _NWK_ROUTING_TABLE_H */
+/** eof nwkRoutingTable.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRx.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRx.h
new file mode 100644
index 00000000..5366119f
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRx.h
@@ -0,0 +1,85 @@
+/**************************************************************************//**
+ \file nwkRx.h
+
+ \brief Functions of processing of input data
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2007-06-14 V. Panov - Created.
+ 2008-11-25 M. Gekk - Counters of buffers have been remote.
+ 2008-12-10 M. Gekk - Memory optimization.
+ 2009-07-08 M. Gekk - Redesign.
+ Last change:
+ $Id: nwkRx.h 18298 2011-08-19 12:42:09Z mgekk $
+ ******************************************************************************/
+#if !defined _NWK_RX_H
+#define _NWK_RX_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <nwkCommon.h>
+#include <nwkSystem.h>
+#include <nwkFrame.h>
+#include <nldeData.h>
+#include <nwkTx.h>
+#if defined _SECURITY_
+#include <sspSfp.h>
+#endif /* _SECURITY_ */
+
+/******************************************************************************
+ Definition section
+ ******************************************************************************/
+#define NWK_UNICAST_COMMAND_TRANSIT_TX_PARAMETERS \
+ {NWK_TX_DELAY_UNICAST_COMMAND, NULL, NULL, true}
+#define NWK_UNICAST_DATA_TRANSIT_TX_PARAMETERS \
+ {NWK_TX_DELAY_TRANSIT_DATA, NULL, NULL, true}
+#define NWK_BROADCAST_TRANSIT_TX_PARAMETERS \
+ {NWK_TX_DELAY_BROADCAST, NULL, NULL, true}
+#define NWK_MULTICAST_MEMBER_TRANSIT_TX_PARAMETERS \
+ {NWK_TX_DELAY_MULTICAST, NULL, NULL, true}
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Input packet meta information. */
+typedef struct _NwkInputPacket_t
+{
+ bool retransmit : 1;
+ bool decryptRequired : 1;
+ bool indicate : 1;
+ NwkBitField_t txId : 5;
+ uint8_t *data;
+ NwkLength_t length;
+ NwkParseHeader_t parsedHeader;
+ union
+ {
+ NWK_DataInd_t dataInd;
+#if defined _SECURITY_
+ SSP_DecryptFrameReq_t decryptReq;
+#endif /* _SECURITY_ */
+ } primitive;
+} NwkInputPacket_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief The upper layer has completed data processing.
+
+ \param[in] resp - NLDE-DATA indication primitive's parameters structure.
+ \return None.
+ ******************************************************************************/
+void NWK_DataResp(NWK_DataResp_t *resp);
+
+#endif /* _NWK_RX_H */
+/** eof nwkRx.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRxSecurity.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRxSecurity.h
new file mode 100644
index 00000000..3bdea48a
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRxSecurity.h
@@ -0,0 +1,54 @@
+/**************************************************************************//**
+ \file nwkRxSecurity.h
+
+ \brief Interface of security processing of incoming packets.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2011-02-03 M. Gekk - Created.
+ Last change:
+ $Id: nwkRxSecurity.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_RX_SECURITY_H
+#define _NWK_RX_SECURITY_H
+
+#if defined _SECURITY_
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <nwkSecurity.h>
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Update the incoming frame counter by key sequence number.
+
+ \param[in] seqNum - key sequence number.
+ \param[in] srcExtAddr - an extended source address.
+ \param[in] newValue - a new value of the incoming frame counter.
+
+ \return 'true' if incoming frame counter is updated otherwise 'false'.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkUpdateInFrameCounter(const NWK_KeySeqNum_t seqNum,
+ const ExtAddr_t srcExtAddr, const NwkInFrameCounter_t counter);
+
+/**************************************************************************//**
+ \brief Get network key by key sequence number.
+
+ \return Pointer to value of a network key.
+ ******************************************************************************/
+NWK_PRIVATE const uint8_t* NWK_GetKey(const NWK_KeySeqNum_t seqNum);
+
+#endif /* _SECURITY_ */
+#endif /* _NWK_RX_SECURITY_H */
+/** eof nwkRxSecurity.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkSilentJoin.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkSilentJoin.h
new file mode 100644
index 00000000..430dc08d
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkSilentJoin.h
@@ -0,0 +1,94 @@
+/*************************************************************************//**
+ \file nwkSilentJoin.h
+
+ \brief Interface of silent join functionality.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2011-03-17 A. Taradov - Created.
+ Last change:
+ $Id: nwkOrphan.h 15388 2011-02-20 23:55:47Z mgekk $
+ ******************************************************************************/
+#if !defined _NWK_SILENT_JOIN_H
+#define _NWK_SILENT_JOIN_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <queue.h>
+#include <nlmeJoin.h>
+#include <macSetGet.h>
+#include <macRxEnable.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+typedef enum
+{
+ NWK_SILENT_JOIN_STATE_MIN = 0x15,
+ NWK_SILENT_JOIN_STATE_IDLE,
+ NWK_SILENT_JOIN_STATE_REQUEST_QUEUED,
+ NWK_SILENT_JOIN_STATE_SET_PARAMS,
+ NWK_SILENT_JOIN_STATE_MAX
+} NwkSilentJoinState_t;
+
+/** Silent join memory */
+typedef struct _NwkSilentJoin_t
+{
+ NwkSilentJoinState_t state;
+
+#if defined _ROUTER_ || defined _ENDDEVICE_
+ /** Request queue */
+ QueueDescriptor_t queue;
+#endif
+
+#if defined _ROUTER_ || defined _ENDDEVICE_
+ /** Memory for mac requests */
+ union
+ {
+ MAC_SetReq_t set;
+ MAC_RxEnableReq_t rxEnable;
+ } req;
+#endif
+} NwkSilentJoin_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if (defined(_ROUTER_) || defined(_ENDDEVICE_)) && defined(_NWK_SILENT_JOIN_)
+/**************************************************************************//**
+ \brief Silent join module reset.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetSilentJoin(void);
+
+/**************************************************************************//**
+ \brief Main task handler of the silent join module.
+ ******************************************************************************/
+NWK_PRIVATE void nwkSilentJoinTaskHandler(void);
+
+/**************************************************************************//**
+ \brief Process silent join requests.
+
+ \param[in] req - NLME-JOIN request parameters' structure pointer.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkSilentJoinReq(NWK_JoinReq_t *req);
+
+#else
+
+#define nwkResetSilentJoin() (void)0
+#define nwkSilentJoinTaskHandler NULL
+
+#endif /* (_ROUTER_ or _ENDDEVICE_) and _NWK_SILENT_JOIN_ */
+#endif /* _NWK_SILENT_JOIN_H */
+
+/** eof nwkSilentJoin.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkSourceRouting.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkSourceRouting.h
new file mode 100644
index 00000000..449c859d
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkSourceRouting.h
@@ -0,0 +1,119 @@
+/**************************************************************************//**
+ \file nwkSourceRouting.h
+
+ \brief Interface of source routing functionality.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2010-03-14 M. Gekk - Created.
+ Last change:
+ $Id: nwkSourceRouting.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+/**//**
+ * Source routing allows a sender of a packet to completely specify
+ * the route the packet takes through the network.
+ **/
+#if !defined _NWK_SOURCE_ROUTING_H
+#define _NWK_SOURCE_ROUTING_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <nldeData.h>
+#include <nwkDataReq.h>
+#include <nwkFrame.h>
+
+/******************************************************************************
+ Define(s) section
+ ******************************************************************************/
+#define NWK_SOURCE_ROUTE_TX_PARAMETERS \
+ {NWK_TX_DELAY_UNICAST_DATA, nwkPrepareSourceRouteTx, nwkConfirmDataTx, false}
+#define NWK_SOURCE_ROUTE_TRANSIT_TX_PARAMETERS \
+ {NWK_TX_DELAY_UNICAST_DATA, nwkPrepareTransitSourceRouteTx, \
+ nwkConfirmTransitSoureRouteTx, true}
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined NWK_ROUTING_CAPACITY \
+ && defined _NWK_SOURCE_ROUTING_ && defined _NWK_CONCENTRATOR_
+/**************************************************************************//**
+ \brief Try to use the source routing, and write the source route subframe.
+
+ Initialize of transmission identifier if source route is used.
+
+ \param[in] req - pointer to NLDE-Data request's parameters.
+ \param[in] nwkHeaderLength - pointer to current maximum length of NWK header.
+
+ \return 'true' if the source route subframe is present otherwise 'false'.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkUseSourceRouting(NWK_DataReq_t *const req,
+ NwkLength_t *const nwkHeaderLength);
+
+/**************************************************************************//**
+ \brief Prepare an initial source route packet.
+
+ \param[in] outPkt - pointer to output packet.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkPrepareSourceRouteTx(NwkOutputPacket_t *const outPkt);
+
+#else /* NWK_ROUTING_CAPACITY and _NWK_SOURCE_ROUTING_ and _NWK_CONCENTRATOR_ */
+
+#define nwkUseSourceRouting(req, nwkHeaderLength) false
+#define nwkPrepareSourceRouteTx NULL
+
+#endif /* NWK_ROUTING_CAPACITY and _NWK_SOURCE_ROUTING_ and _NWK_CONCENTRATOR_ */
+
+#if defined NWK_ROUTING_CAPACITY && defined _NWK_SOURCE_ROUTING_
+/**************************************************************************//**
+ \brief Decrement the relay index sub-field by 1, and relay the frame to
+ the address immediately prior to its own address in the relay list.
+
+ \param[in] outPkt - pointer to output packet.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE
+void nwkPrepareTransitSourceRouteTx(NwkOutputPacket_t *const outPkt);
+
+/**************************************************************************//**
+ \brief Confirmation of source route packet transmission.
+
+ If status isn't NWK_SUCCESS_STATUS then send back NWK status command with
+ code 0x0B (NWK_SOURCE_ROUTE_FAILURE).
+
+ \param[in] outPkt - pointer to output packet.
+ \param[in] status - NWK status of source route packet transmission.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkConfirmTransitSoureRouteTx(NwkOutputPacket_t *const outPkt,
+ const NWK_Status_t status);
+
+/**************************************************************************//**
+ \brief A data packet has been received for this node.
+
+ Update the source route information about a concentrator.
+
+ \param[in] nwkHeader - pointer to the raw NWK header of a source route packet.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE
+void nwkUpdateSourceRouteInfo(const NwkFrameHeader_t *const nwkHeader);
+
+#else /* NWK_ROUTING_CAPACITY and _NWK_SOURCE_ROUTING_ */
+#define nwkPrepareTransitSourceRouteTx NULL
+#define nwkConfirmTransitSoureRouteTx NULL
+#define nwkUpdateSourceRouteInfo(nwkHeader) (void)0
+#endif /* NWK_ROUTING_CAPACITY and _NWK_SOURCE_ROUTING_ */
+
+#endif /* _NWK_SOURCE_ROUTING_H */
+/** eof nwkSourceRouting.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkStartRouter.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkStartRouter.h
new file mode 100644
index 00000000..cb1f3fe9
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkStartRouter.h
@@ -0,0 +1,89 @@
+/**************************************************************************//**
+ \file nwkStartRouter.h
+
+ \brief Start router header file.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2007-06-27 V. Panov - Created.
+ 2008-12-10 M. Gekk - Reduction of usage of the RAM at separate compiling.
+ 2009-03-19 M. Gekk - Refactoring.
+ Last change:
+ $Id: nwkStartRouter.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_START_ROUTER_H
+#define _NWK_START_ROUTER_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <queue.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Internal states of NLME-START-ROUTER component */
+typedef enum _NwkStartRouterState_t
+{
+ NWK_START_ROUTER_IDLE_STATE = 0x9A,
+ NWK_START_ROUTER_FIRST_STATE = 0x45,
+ NWK_START_ROUTER_BEGIN_STATE = NWK_START_ROUTER_FIRST_STATE,
+ NWK_START_ROUTER_MAC_REQ_STATE = 0x46,
+ NWK_START_ROUTER_CONFIRM_STATE = 0x47,
+ NWK_START_ROUTER_LAST_STATE
+} NwkStartRouterState_t;
+
+/** Internal parameters of NLME-START-ROUTER */
+typedef struct _NwkStartRouter_t
+{
+ NwkStartRouterState_t state; /**< Finite-state machine */
+ QueueDescriptor_t queue; /**< Queue of requests from upper layer */
+ bool coordRealignment;
+} NwkStartRouter_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined _ROUTER_
+/**************************************************************************//**
+ \brief Main task handler of NLME-START-ROUTER component
+ ******************************************************************************/
+NWK_PRIVATE void nwkStartRouterTaskHandler(void);
+
+/**************************************************************************//**
+ \brief Reset NLME-START-ROUTER component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetStartRouter(void);
+
+/******************************************************************************
+ \brief nwkStartRouter idle checking.
+
+ \return true, if nwkStartRouter performs no activity, false - otherwise.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkStartRouterIsIdle(void);
+
+#if defined NWK_COORD_REALIGNMENT
+/**************************************************************************//**
+ \brief Is network configuration realignment allowed or not?
+ ******************************************************************************/
+NWK_PRIVATE bool nwkRealignmentIsAllowed(void);
+#endif /* NWK_COORD_REALIGNMENT */
+
+#else /* _ROUTER_ */
+
+#define nwkStartRouterTaskHandler NULL
+#define nwkStartRouterIsIdle NULL
+#define nwkResetStartRouter() (void)0
+
+#endif /* _ROUTER_ */
+#endif /* _NWKSTARTROUTER_H */
+/** eof nwkStartRouter.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkStateMachine.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkStateMachine.h
new file mode 100644
index 00000000..19a92871
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkStateMachine.h
@@ -0,0 +1,154 @@
+/**************************************************************************//**
+ \file nwkStateMachine.h
+
+ \brief State machine header file.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2007-06-14 V. Panov - Created.
+ 2009-02-21 M. Gekk - Refactoring.
+ Last change:
+ $Id: nwkStateMachine.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_STATE_MACHINE_H
+#define _NWK_STATE_MACHINE_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <nwkCommon.h>
+#include <nwkMem.h>
+
+/******************************************************************************
+ Define(s) section
+ ******************************************************************************/
+/* Identifiers of modules, packed to groups. A combination of modules, which
+ activity is accepted, forms global NWK layer state. All modules in group
+ change their status simultaneously by some event, so if the activity
+ permission politics changes, perform corrsponding changes. */
+
+#define NWK_MODULE_ID_DATA_REQ (1U << 0)
+#define NWK_MODULE_ID_SYNC (1U << 0)
+#define NWK_MODULE_ID_LINK_STATUS (1U << 0)
+#define NWK_MODULE_ID_NETWORK_COMMAND (1U << 0)
+#define NWK_MODULE_ID_LEAVE (1U << 0)
+#define NWK_MODULE_ID_PANID_CONFLICT (1U << 0)
+#define NWK_MODULE_ID_DATA_IND (1U << 0)
+#define NWK_MODULE_ID_EDSCAN (1U << 0)
+#define NWK_MODULE_ID_ADDR_CONFLICT (1U << 0)
+#define NWK_MODULE_ID_ROUTE_DISCOVERY (1U << 0)
+#define NWK_MODULE_ID_PERMIT_JOINING (1U << 0)
+
+#define NWK_MODULE_ID_FORMATION (1U << 1)
+#define NWK_MODULE_ID_START_ROUTER (1U << 2)
+#define NWK_MODULE_ID_JOIN_IND (1U << 3)
+
+#define NWK_MODULE_ID_JOIN_REQ (1U << 4)
+#define NWK_MODULE_ID_COMMAND_REQ (1U << 4)
+
+#define NWK_MODULE_ID_COMMAND_IND (1U << 5)
+#define NWK_MODULE_ID_DISCOVERY (1U << 5)
+
+/** Reserved bit is set until NWK reset process completed. */
+#define NWK_MODULE_ID_RESERVED (1U << 7)
+
+/* Module permissions */
+#define NWK_MODULE_NONE 0U
+
+#define NWK_EVENT_RESET_REQ \
+ (NWK_MODULE_ID_DISCOVERY | NWK_MODULE_ID_FORMATION \
+ | NWK_MODULE_ID_JOIN_REQ | NWK_MODULE_ID_COMMAND_REQ \
+ | NWK_MODULE_ID_COMMAND_IND | NWK_MODULE_ID_START_ROUTER)
+
+#define NWK_EVENT_FORMATION_SUCCESS \
+ ((NwkStateMachineEvent_t)(~NWK_MODULE_ID_FORMATION))
+
+#define NWK_EVENT_LEAVE_ALL_CHILDREN \
+ ((NwkStateMachineEvent_t)(~NWK_MODULE_ID_JOIN_IND\
+ & ~NWK_MODULE_ID_FORMATION \
+ & ~NWK_MODULE_ID_START_ROUTER))
+
+#define NWK_EVENT_LEAVE_SUCCESS \
+ (NWK_MODULE_ID_JOIN_REQ | NWK_MODULE_ID_COMMAND_REQ \
+ | NWK_MODULE_ID_FORMATION)
+
+#define NWK_EVENT_REJOIN_REQ \
+ (NWK_MODULE_ID_JOIN_REQ | NWK_MODULE_ID_COMMAND_REQ \
+ | NWK_MODULE_ID_COMMAND_IND | NWK_MODULE_ID_DISCOVERY)
+
+#define NWK_EVENT_AWAYTING_RESET (NWK_MODULE_ID_RESERVED)
+#define NWK_EVENT_REJOIN_SUCCESS (NWK_EVENT_FORMATION_SUCCESS)
+#define NWK_EVENT_POWER_FAILURE_RESET (NWK_EVENT_FORMATION_SUCCESS)
+#define NWK_EVENT_JOIN_SUCCESS (NWK_EVENT_FORMATION_SUCCESS)
+#define NWK_EVENT_LEAVE_FAIL (NWK_EVENT_FORMATION_SUCCESS)
+
+#define NWK_EVENT_EDSCAN NWK_MODULE_NONE /* Disable all NWK modules */
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Type of identifier of module. */
+typedef uint8_t NwkStateMachineModuleID_t;
+
+/** Type of NWK event. */
+typedef NwkState_t NwkStateMachineEvent_t;
+
+/******************************************************************************
+ Inline functions section
+ *****************************************************************************/
+/**************************************************************************//**
+ \brief this function return true, if module with moduleID is allowed to work.
+ ******************************************************************************/
+INLINE uint8_t nwkCheckStateMachine(NwkStateMachineModuleID_t moduleID)
+{
+ return (nwkMem.state & moduleID);
+}
+
+/**************************************************************************//**
+ \brief Modules that can switch state machine shall send events.
+
+ \param[in] event - id of event.
+ \return None.
+ ******************************************************************************/
+INLINE void nwkSwitchStateMachine(NwkStateMachineEvent_t event)
+{
+ nwkMem.state = event;
+}
+
+/**************************************************************************//**
+ \brief This function return the current state of network layer.
+
+ \return Current global state of NWK-layer.
+ ******************************************************************************/
+INLINE NwkState_t nwkGetStateMachine(void)
+{
+ return nwkMem.state;
+}
+
+/**************************************************************************//**
+ \brief Set new the network layer state.
+
+ \param[in] state - new state.
+ \return current state
+ ******************************************************************************/
+INLINE void nwkRestoreStateMachine(NwkState_t state)
+{
+ nwkMem.state = state;
+}
+
+/**************************************************************************//**
+ \brief State machine reset routine.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetStateMachine(void);
+
+#endif /* _NWK_STATE_MACHINE_H */
+/** eof nwkStateMachine.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkStatusInd.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkStatusInd.h
new file mode 100644
index 00000000..ee464c82
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkStatusInd.h
@@ -0,0 +1,86 @@
+/**************************************************************************//**
+ \file nwkStatusInd.h
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2007-06-14 V. Panov - Created
+ 2009-06-16 M. Gekk - Refactoring.
+ Last change:
+ $Id: nwkStatusInd.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_STATUS_IND_H
+#define _NWK_STATUS_IND_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <nlmeNwkStatus.h>
+#include <nwkFrame.h>
+#include <nwkRx.h>
+
+/******************************************************************************
+ Inline functions section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Wrapper for NLME-NWK-STATUS indication primitive.
+
+ \param[in] shortAddr - a network address of the device associated with
+ the status information.
+ \param[in] status - error code associated with the status indication.
+ \return None.
+ ******************************************************************************/
+INLINE void nwkStatusIndicate(const ShortAddr_t shortAddr,
+ const NWK_StatusIndErrorCodes_t status)
+{
+ NWK_NwkStatusInd_t ind;
+
+ ind.shortAddress = shortAddr;
+ ind.status = status;
+ NWK_NwkStatusInd(&ind);
+}
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined(_ROUTER_) || defined(_COORDINATOR_)
+/**************************************************************************//**
+ \brief NWK status command has been received.
+
+ \param[in] payload - pointer to status code field and destination address.
+ \param[in] header - NWK header of the network status command.
+ \param[in] parse - parsed NWK header.
+ \return 'true' if continue processing of command packet otherwise 'false'.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkStatusFrameInd(const uint8_t *const payload,
+ const NwkFrameHeader_t *const header, const NwkParseHeader_t *const parse);
+
+#else /* _ROUTER_ or _COORDINATOR_ */
+#define nwkStatusFrameInd NULL
+#endif /* _ROUTER_ or _COORDINATOR_ */
+
+#if defined NWK_ROUTING_CAPACITY && defined _NWK_MANY_TO_ONE_ROUTING_
+/**************************************************************************//**
+ \brief Is it the input many-to-one network status.
+
+ \param[in] inPkt - pointer to the input packet
+
+ \return 'true' if the input packet is network status command with status code
+ equal to many-to-one route error otherwise 'false'.
+ ******************************************************************************/
+NWK_PRIVATE
+bool nwkIsManyToOneNetworkStatus(const NwkInputPacket_t *const inPkt);
+
+#else
+#define nwkIsManyToOneNetworkStatus(inPkt) false
+#endif /* NWK_ROUTING_CAPACITY and _NWK_MANY_TO_ONE_ROUTING_ */
+#endif /* _NWK_STATUS_IND_H */
+/** eof nwkStatusInd.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkStatusReq.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkStatusReq.h
new file mode 100644
index 00000000..70ee0f6d
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkStatusReq.h
@@ -0,0 +1,230 @@
+/**************************************************************************//**
+ \file nwkStatusReq.h
+
+ \brief Interface of the network status sender.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2009-06-23 Max Gekk - Created.
+ Last change:
+ $Id: nwkStatusReq.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_STATUS_REQ_H
+#define _NWK_STATUS_REQ_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <queue.h>
+#include <nwkCommon.h>
+#include <nldeData.h>
+#include <nwkFrame.h>
+#include <nwkRx.h>
+
+/******************************************************************************
+ Definitions section
+ ******************************************************************************/
+/** Size of NWK status command payload:
+ * - command id - 1 octet
+ * - status code - 1 octet
+ * - destination address - 2 octet */
+#define NWK_STATUS_CMD_PAYLOAD_SIZE 4U
+/** Constant parameters of network status transmission. */
+#define NWK_UNICAST_STATUS_TX_PARAMETERS \
+ {NWK_TX_DELAY_UNICAST_COMMAND, nwkPrepareNetworkStatusTx,\
+ nwkConfirmNetworkStatusTx, true}
+#define NWK_BROADCAST_STATUS_TX_PARAMETERS \
+ {NWK_TX_DELAY_BROADCAST, nwkPrepareNetworkStatusTx, \
+ nwkConfirmNetworkStatusTx, true}
+#define NWK_MANY_TO_ONE_STATUS_TX_PARAMETERS \
+ {NWK_TX_DELAY_UNICAST_COMMAND, nwkPrepareNetworkStatusTx, \
+ nwkConfirmManyToOneNetworkStatusTx, false}
+#define NWK_MANY_TO_ONE_TRANSIT_STATUS_TX_PARAMETERS \
+ {NWK_TX_DELAY_UNICAST_COMMAND, NULL,\
+ nwkConfirmManyToOneNetworkStatusTx, false}
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Confirmation parameters of NWK status command sending. */
+typedef struct _NwkStatusConf_t
+{
+ /* Status of NWK status command sending.*/
+ NWK_Status_t status;
+} NwkStatusConf_t;
+
+/** Type of NWK status request parameters. */
+typedef struct _NwkStatusReq_t
+{
+ /** Service field - for internal needs. */
+ struct
+ {
+ QueueElement_t qelem; /**< link used for queuing */
+ } service;
+ /** Value of status code field in network status frame. */
+ NWK_StatusIndErrorCodes_t statusCode;
+ /** Target address for this network status command. */
+ ShortAddr_t targetAddr;
+ /** Destination address for this network status command. */
+ ShortAddr_t dstAddr;
+ /* Short address of next hop for this command. */
+ ShortAddr_t nextHopAddr;
+ /* Short address of previous hop of original packet. */
+ ShortAddr_t prevHopAddr;
+ /** Callback for request to send of the NWK status command.*/
+ void (* nwkStatusConf)(NwkStatusConf_t *conf);
+ NwkStatusConf_t confirm;
+} NwkStatusReq_t;
+
+/** Network status command frame format. ZigBee spec r17, figure 3.15. */
+BEGIN_PACK
+typedef struct PACK _NwkStatusCommandPayload_t
+{
+ /** Command frame identifier. */
+ NwkCommandIdField_t commandId;
+ /** Status code field. This field shall be set to one of the non-reserved
+ * values shown in ZigBee spec r17, Table 3.42. */
+ uint8_t statusCode;
+ /** The destination address field is 2 octets in length and shall be present
+ * if, and only if, the network status command frame is being sent in
+ * response to a routing failure. In this case, it shall contain
+ * the destination address from the data frame that encountered the failure.
+ * ZigBee spec r17, 3.4.3.3.2, page 324. */
+ ShortAddr_t dstAddr;
+} NwkStatusCommandPayload_t;
+END_PACK
+
+/** Internal states of NWK status command sender. */
+typedef enum _NwkStateOfStatusSender_t
+{
+ NWK_STATUS_SENDER_IDLE_STATE = 0x78,
+ NWK_STATUS_SENDER_FIRST_STATE = 0x20,
+ NWK_STATUS_SENDER_PREPARE_TX_STATE = NWK_STATUS_SENDER_FIRST_STATE,
+ NWK_STATUS_SENDER_SEND_STATE = 0x21,
+ NWK_STATUS_SENDER_LAST_STATE
+} NwkStateOfStatusSender_t;
+
+/** Internal variables of the NWK status command sender. */
+typedef struct _NwkStatusSender_t
+{
+ /** Current state of NWK status sender. */
+ NwkStateOfStatusSender_t state;
+ /** Queue of requests to send NWK status command. */
+ QueueDescriptor_t queue;
+ /** Route error command is sent. */
+ bool routeErrorBusy;
+ /** The request to send the route error status command. */
+ NwkStatusReq_t routeError;
+} NwkStatusSender_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined _ROUTER_ || defined _COORDINATOR_
+#if defined _RESOLVE_ADDR_CONFLICT_ || defined _NWK_MANY_TO_ONE_ROUTING_ ||\
+ defined _NWK_SOURCE_ROUTING_ || defined _NWK_MESH_ROUTING_
+/**************************************************************************//**
+ \brief Request to send a network status command.
+
+ \param[in] req - request information: statusCode, destination address and etc.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkStatusReq(NwkStatusReq_t *const req);
+#endif
+
+/**************************************************************************//**
+ \brief Reset NWK status sender.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetStatusSender(void);
+
+#if defined _NWK_SOURCE_ROUTING_ || defined _NWK_MESH_ROUTING_
+/**************************************************************************//**
+ \brief Send the status command with status code NWK_NO_ROUTE_AVAILABLE.
+
+ \param[in] srcAddr - source address of route path.
+ \param[in] dstAddr - destination address of route path.
+ \param[in] statusCode - status code for network status command frame.
+ \param[in] prevHopAddr - short address of previous hop of data frame
+
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkSendRouteErrorStatus(const ShortAddr_t srcAddr,
+ const ShortAddr_t dstAddr, const ShortAddr_t prevHopAddr,
+ const NWK_StatusIndErrorCodes_t statusCode);
+#endif /* _NWK_SOURCE_ROUTING_ or _NWK_MESH_ROUTING_*/
+
+/**************************************************************************//**
+ \brief Prepare header and payload of the network status command.
+
+ \param[in] outPkt - pointer to output packet.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkPrepareNetworkStatusTx(NwkOutputPacket_t *const outPkt);
+
+/**************************************************************************//**
+ \brief Confirmation of network status command transmission.
+
+ \param[in] outPkt - pointer to output packet.
+ \param[in] status - network status of status command transmission.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkConfirmNetworkStatusTx(NwkOutputPacket_t *const outPkt,
+ const NWK_Status_t status);
+
+#if defined _NWK_MANY_TO_ONE_ROUTING_
+/**************************************************************************//**
+ \brief Send the many-to-one route error status command.
+
+ \param[in] srcAddr - the source address of the data frame
+ \param[in] concAddr - short address of concentrator
+ \param[in] prevHopAddr - short address of previous hop of data frame
+ \param[in] nextHopAddr - short address of failure next hop
+
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkSendManyToOneRouteErrorStatus(const ShortAddr_t srcAddr,
+ const ShortAddr_t concAddr, const ShortAddr_t prevHopAddr,
+ const ShortAddr_t nextHopAddr);
+#endif /* _NWK_MANY_TO_ONE_ROUTING_ */
+
+#else /* _ROUTER_ or _COORDINATOR_ */
+
+#define nwkResetStatusSender() (void)0
+#define nwkPrepareNetworkStatusTx NULL
+#define nwkConfirmNetworkStatusTx NULL
+
+INLINE void nwkSendRouteErrorStatus(const ShortAddr_t srcAddr,
+ const ShortAddr_t dstAddr, const bool multicast)
+{
+ (void)srcAddr, (void)dstAddr, (void)multicast;
+}
+
+#endif /* _ROUTER_ or _COORDINATOR_ */
+
+#if defined NWK_ROUTING_CAPACITY && defined _NWK_MANY_TO_ONE_ROUTING_
+/**************************************************************************//**
+ \brief Confirmation of sending NWK status command with many-to-one error.
+
+ \param[in] outPkt - pointer to output packet
+ \param[in] status - status of sending
+
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE
+void nwkConfirmManyToOneNetworkStatusTx(NwkOutputPacket_t *const outPkt,
+ const NWK_Status_t status);
+
+#else
+#define nwkConfirmManyToOneNetworkStatusTx NULL
+#endif /* NWK_ROUTING_CAPACITY and _NWK_MANY_TO_ONE_ROUTING_ */
+#endif /* _NWK_STATUS_REQ_H */
+/** nwkStatusReq.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkSync.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkSync.h
new file mode 100644
index 00000000..75bf12c1
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkSync.h
@@ -0,0 +1,92 @@
+/**************************************************************************//**
+ \file nwkSync.h
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2007-06-27 V. Panov - Created.
+ 2008-12-10 M. Gekk - Reduction of usage of the RAM at separate compiling.
+ 2009-03-10 M. Gekk - Refactoring.
+ Last change:
+ $Id: nwkSync.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_SYNC_H
+#define _NWK_SYNC_H
+
+/*****************************************************************************
+ Includes section
+ *****************************************************************************/
+#include <nwkConfig.h>
+#include <queue.h>
+#include <mac.h>
+
+/******************************************************************************
+ Definitions section
+ ******************************************************************************/
+/** Maximum synchronization attempts. */
+#define MAX_SYNC_FAIL_COUNTER 8U
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Internal states of NLME-SYNC component */
+typedef enum _NwkSyncState_t
+{
+ NWK_SYNC_IDLE_STATE = 0x31,
+ NWK_SYNC_FIRST_STATE = 0xA3,
+ NWK_SYNC_BEGIN_STATE = NWK_SYNC_FIRST_STATE,
+ NWK_SYNC_MAC_POLL_STATE = 0xA4,
+ NWK_SYNC_CONFIRM_STATE = 0xA5,
+ NWK_SYNC_LAST_STATE
+} NwkSyncState_t;
+
+/** Internal parameters of NLME-SYNC component. */
+typedef struct _NwkSync_t
+{
+ /** Internal component's state*/
+ NwkSyncState_t state;
+ /** Counter of synchronization attempts */
+ uint8_t counter;
+ /** Queue of NLME-SYNC.request from an upper layer */
+ QueueDescriptor_t queue;
+ /** MLME-POLL request primitive's parameters */
+ MAC_PollReq_t macReq; /**< macReq must be no in union */
+} NwkSync_t;
+
+/*****************************************************************************
+ Prototypes section
+ *****************************************************************************/
+#if defined _ENDDEVICE_
+/*************************************************************************//**
+ \brief Main task handler of NLME-SYNC component
+ *****************************************************************************/
+NWK_PRIVATE void nwkSyncTaskHandler(void);
+
+/*************************************************************************//**
+ \brief Reset NLME-SYNC component.
+ *****************************************************************************/
+NWK_PRIVATE void nwkResetSync(void);
+
+/******************************************************************************
+ \brief nwkSync idle checking.
+
+ \return true, if nwkSync performs no activity, false - otherwise.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkSyncIsIdle(void);
+
+#else /* _ENDDEVICE_ */
+
+#define nwkSyncTaskHandler NULL
+#define nwkSyncIsIdle NULL
+#define nwkResetSync() (void)0
+
+#endif /* _ENDDEVICE_ */
+#endif /* _NWK_SYNC_H */
+/** eof nwkSync.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkSyncLoss.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkSyncLoss.h
new file mode 100644
index 00000000..aef3a380
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkSyncLoss.h
@@ -0,0 +1,61 @@
+/**************************************************************************//**
+ \file nwkSyncLoss.h
+
+ \brief SyncLoss header file.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2009-04-02 M. Gekk - Created.
+ Last change:
+ $Id: nwkSyncLoss.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWKSYNCLOSS_H
+#define _NWKSYNCLOSS_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <nlmeStartRouter.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Internal states of SyncLoss component */
+typedef enum _NwkSyncLossState_t
+{
+ NWK_SYNC_LOSS_IDLE_STATE = 0x00,
+ NWK_REALIGNMENT_START_STATE = 0x01
+} NwkSyncLossState_t;
+
+/** Internal parameters of SyncLoss */
+typedef struct _NwkSyncLoss_t
+{
+ NwkSyncLossState_t state;
+ NWK_StartRouterReq_t startRouter;
+} NwkSyncLoss_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined(_ROUTER_) && defined(NWK_COORD_REALIGNMENT)
+/******************************************************************************
+ \brief Reset SyncLoss component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetSyncLoss(void);
+
+#else /* _ROUTER_ && NWK_COORD_REALIGNMENT */
+
+#define nwkResetSyncLoss() (void)0
+
+#endif /* _ROUTER_ && NWK_COORD_REALIGNMENT */
+#endif /* _NWKSYNCLOSS_H */
+/** eof nwkSyncLoss.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkSystem.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkSystem.h
new file mode 100644
index 00000000..f001f90f
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkSystem.h
@@ -0,0 +1,100 @@
+/**************************************************************************//**
+ \file nwkSystem.h
+
+ \brief Network system header file.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2007-06-20 V. Panov - Created.
+ 2009-08-16 M. Gekk - Refactoring.
+ Last change:
+ $Id: nwkSystem.h 17801 2011-07-04 08:55:01Z mgekk $
+ ******************************************************************************/
+#if !defined _NWKSYSTEM_H
+#define _NWKSYSTEM_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <types.h>
+#include <appFramework.h>
+#include <mnUtils.h>
+
+ /******************************************************************************
+ Inline static functions prototypes section
+ ******************************************************************************/
+INLINE bool isCorrectExtPanId(const uint64_t panId)
+{
+ const uint8_t *p = (const uint8_t *)&panId;
+ const uint8_t *const pend = p + sizeof(panId);
+ uint16_t sum = 0U;
+
+ do
+ sum += *p;
+ while (++p < pend);
+ return (0U != sum) && ((8U * 0xFFU) != sum);
+}
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+typedef ShortAddr_t NwkAddrRange_t;
+
+/******************************************************************************
+ Definitions section
+ ******************************************************************************/
+/** Converting of time value from milliseconds to seconds. */
+#define NWK_MSEC_TO_SEC(time) ((time) >> 10)
+/** Converting of time value from seconds to milliseconds. */
+#define NWK_SEC_TO_MSEC(time) ((time) << 10)
+
+#define IS_CORRECT_BROADCAST_ADDR(A) \
+ ((0xFFFFU == (A))||((0xFFFBU <= LE16_TO_CPU(A))&&(LE16_TO_CPU(A) <= 0xFFFDU)))
+
+#define NWK_INVALID_PANID 0xFFFFU
+
+#define CHECK_MEM_OVERLAP(dst, src, len, assert_num) \
+ assert(!(((src) < (dst)) \
+ && ((uint8_t *)(dst) < (const uint8_t *)(src) + (len))), \
+ assert_num)
+
+#if defined UINT64_MEMCMP
+ #define IS_EQ_EXT_PANID(A, B) (0 == memcmp(&(A), &(B), sizeof(uint64_t)))
+ #define IS_CORRECT_EXT_PANID(P) isCorrectExtPanId(P)
+ #define COPY_TO_RAW_EXT_ADDR(DST, SRC) \
+ memmove((DST).raw, &(SRC), sizeof(uint64_t))
+ #define COPY_FROM_RAW_EXT_ADDR(DST, SRC) \
+ memmove(&(DST), (SRC).raw, sizeof(uint64_t))
+ #define COPY_EXT_PANID(DST, SRC) memmove(&(DST), &(SRC), sizeof(uint64_t))
+#else
+ #define IS_EQ_EXT_PANID(A, B) ((A) == (B))
+ #define IS_CORRECT_EXT_PANID(P) \
+ ((0ULL < (P)) && ((P) < 0xFFFFFFFFFFFFFFFFULL))
+ #define COPY_TO_RAW_EXT_ADDR(DST, SRC) (DST).value = (SRC)
+ #define COPY_FROM_RAW_EXT_ADDR(DST, SRC) (DST) = (SRC).value
+ #define COPY_EXT_PANID(DST, SRC) (DST) = (SRC)
+#endif
+
+/* Get address of any NWK table. */
+#define NWK_ADDR_OF_TABLE(table) ((void **)&(table))
+
+/* Macros are used for queue operations. */
+#define NWK_DEL_QELEM(queue, type) \
+ GET_PARENT_BY_FIELD(type, service.qelem, deleteHeadQueueElem(queue))
+
+#define NWK_GET_QELEM(queue, type) \
+ GET_PARENT_BY_FIELD(type, service.qelem, getQueueElem(queue))
+
+#define NWK_NEXT_QELEM(parent, type) \
+ GET_PARENT_BY_FIELD(type, service.qelem, getNextQueueElem(&(parent)->service.qelem))
+
+#endif /* _NWKSYSTEM_H */
+/** eof nwkSystem.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkTaskManager.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkTaskManager.h
new file mode 100644
index 00000000..4ea4c019
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkTaskManager.h
@@ -0,0 +1,98 @@
+/**************************************************************************//**
+ \file nwkTaskManager.h
+
+ \brief Header file of NWK task manager.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2007-06-14 V. Panov - Created.
+ 2008-08-21 Max Gekk - More fair planning of tasks.
+ 2009-06-12 Max Gekk - Refactoring.
+ Last change:
+ $Id: nwkTaskManager.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_TASK_MANAGER_H
+#define _NWK_TASK_MANAGER_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <types.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Identifiers of NWK task handlers. */
+typedef enum _NwkTaskID_t
+{
+ NWK_TASK_RESET,
+ NWK_TASK_SYNC,
+ NWK_TASK_ADDR_CONFLICT,
+ NWK_TASK_TX,
+ NWK_TASK_ROUTE_DISCOVERY,
+ NWK_TASK_ROUTE_DISCOVERY_TABLE,
+ NWK_TASK_START_ROUTER,
+ NWK_TASK_PERMIT_JOINING,
+ NWK_TASK_DISCOVERY_REQ,
+ NWK_TASK_FORMATION_REQ,
+ NWK_TASK_JOIN_REQ,
+ NWK_TASK_JOIN_IND,
+ NWK_TASK_LEAVE,
+ NWK_TASK_EDSCAN,
+ NWK_TASK_DATA_CONF,
+ NWK_TASK_LOOPBACK,
+ NWK_TASK_ROUTE_RECORD,
+ NWK_TASK_DIRECT_JOIN,
+ NWK_TASK_ORPHAN,
+ NWK_TASK_SILENT_JOIN,
+ NWK_TASK_MANYTOONE,
+ NWK_TASK_ALLOC_DATA_REQ,
+ NWK_TASKS_SIZE
+} NwkTaskID_t;
+
+/** Bit array of NWK task. If bit is '1' the task is posted. */
+typedef uint32_t NwkTaskBitMask_t;
+
+/** Type of iterator for task identifiers. */
+typedef uint8_t NwkTaskIdIter_t;
+
+typedef struct _NwkTaskManager_t
+{
+ NwkTaskBitMask_t bitMap;
+ NwkTaskIdIter_t current;
+} NwkTaskManager_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/******************************************************************************
+ \brief post NWK task.
+
+ \param taskID - identifier of NWK task.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkPostTask(const NwkTaskID_t taskID);
+
+/******************************************************************************
+ \brief Cancel NWK task.
+
+ \param[in] mask - bit mask of NWK task dentifier.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkClearTaskBit(const NwkTaskBitMask_t mask);
+
+/******************************************************************************
+ \brief Reset the task manager.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetTaskManager(void);
+
+#endif /* _NWK_TASK_MANAGER_H */
+/** eof nwkTaskManager.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkTx.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkTx.h
new file mode 100644
index 00000000..d2e35d4e
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkTx.h
@@ -0,0 +1,209 @@
+/**************************************************************************//**
+ \file nwkTx.h
+
+ \brief Interface of NWK transmission.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2007-06-14 V. Panov - Created.
+ 2008-12-10 Max Gekk - Reduction of the used RAM.
+ 2009-10-16 Max Gekk - Redesign.
+ Last change:
+ $Id: nwkTx.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_TX_H
+#define _NWK_TX_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <nldeData.h>
+#include <nwkDbg.h>
+
+/******************************************************************************
+ Definition section
+ ******************************************************************************/
+/** List of transmission parameters: delay type, prepare and confirm functions.
+ * NOTE: Offset of tx parameters in this list must be equal tx id. */
+#define NWK_TX_PARAMETERS \
+{ \
+ NWK_LINK_STATUS_TX_PARAMETERS, /* NWK_LINK_STATUS_TX_ID */ \
+ NWK_BROADCAST_STATUS_TX_PARAMETERS, /* NWK_BROADCAST_STATUS_TX_ID */ \
+ NWK_UNICAST_STATUS_TX_PARAMETERS, /* NWK_UNICAST_STATUS_TX_ID */ \
+ NWK_JOIN_REQ_TX_PARAMETERS, /* NWK_JOIN_REQ_TX_ID */ \
+ NWK_ADDR_CONFLICT_JOIN_RESP_TX_PARAMETERS, /* NWK_ADDR_CONFLICT_JOIN_RESP_TX_ID */ \
+ NWK_JOIN_RESP_TX_PARAMETERS, /* NWK_JOIN_RESP_TX_ID */ \
+ NWK_LEAVE_ITSELF_TX_PARAMETERS, /* NWK_LEAVE_ITSELF_TX_ID */ \
+ NWK_LEAVE_CHILD_TX_PARAMETERS, /* NWK_LEAVE_CHILD_TX_ID */ \
+ NWK_REPORT_TX_PARAMETERS, /* NWK_REPORT_TX_ID */ \
+ NWK_UPDATE_TX_PARAMETERS, /* NWK_UPDATE_TX_ID */ \
+ NWK_ROUTE_REPLY_TX_PARAMETERS, /* NWK_ROUTE_REPLY_TX_ID */ \
+ NWK_INITIAL_ROUTE_REQ_TX_PARAMETERS, /* NWK_INITIAL_ROUTE_REQ_TX_ID */\
+ NWK_INITIAL_MANYTOONE_ROUTE_REQ_TX_PARAMETERS, /* NWK_INITIAL_MANYTOONE_ROUTE_REQ_TX_ID */\
+ NWK_ROUTE_REQ_TX_PARAMETERS, /* NWK_ROUTE_REQ_TX_ID */ \
+ NWK_MANYTOONE_ROUTE_REQ_TX_PARAMETERS, /* NWK_MANYTOONE_ROUTE_REQ_TX_ID */\
+ NWK_ROUTE_RECORD_TX_PARAMETERS, /* NWK_ROUTE_RECORD_TX_ID */ \
+ NWK_MANY_TO_ONE_STATUS_TX_PARAMETERS, /* NWK_MANY_TO_ONE_STATUS_TX_ID */\
+ \
+ NWK_UNICAST_COMMAND_TRANSIT_TX_PARAMETERS, /* NWK_UNICAST_COMMAND_TRANSIT_TX_ID */ \
+ NWK_UNICAST_DATA_TRANSIT_TX_PARAMETERS, /* NWK_UNICAST_DATA_TRANSIT_TX_ID */ \
+ NWK_BROADCAST_TRANSIT_TX_PARAMETERS, /* NWK_BROADCAST_TRANSIT_TX_ID */ \
+ NWK_MULTICAST_MEMBER_TRANSIT_TX_PARAMETERS, /* NWK_MULTICAST_MEMBER_TRANSIT_TX_ID */\
+ NWK_SOURCE_ROUTE_TRANSIT_TX_PARAMETERS, /* NWK_SOURCE_ROUTE_TRANSIT_TX_ID */ \
+ NWK_ROUTE_RECORD_TRANSIT_TX_PARAMETERS, /* NWK_ROUTE_RECORD_TRANSIT_TX_ID */ \
+ NWK_MANY_TO_ONE_TRANSIT_STATUS_TX_PARAMETERS, /* NWK_MANY_TO_ONE_TRANSIT_STATUS_TX_ID */\
+ \
+ NWK_UNICAST_DATA_TX_PARAMETERS, /* NWK_UNICAST_DATA_TX_ID */ \
+ NWK_BROADCAST_DATA_TX_PARAMETERS, /* NWK_BROADCAST_DATA_TX_ID */ \
+ NWK_MULTICAST_MEMBER_TX_PARAMETERS, /* NWK_MULTICAST_MEMBER_TX_ID */ \
+ NWK_SOURCE_ROUTE_TX_PARAMETERS /* NWK_SOURCE_ROUTE_TX_ID */ \
+}
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Identifiers of transmission requests. */
+typedef enum _NwkTxId_t
+{
+ NWK_LINK_STATUS_TX_ID = 0x00,
+ NWK_BROADCAST_STATUS_TX_ID = 0x01,
+ NWK_UNICAST_STATUS_TX_ID = 0x02,
+ NWK_JOIN_REQ_TX_ID = 0x03,
+ NWK_ADDR_CONFLICT_JOIN_RESP_TX_ID = 0x04,
+ NWK_JOIN_RESP_TX_ID = 0x05,
+ NWK_LEAVE_ITSELF_TX_ID = 0x06,
+ NWK_LEAVE_CHILD_TX_ID = 0x07,
+ NWK_REPORT_TX_ID = 0x08,
+ NWK_UPDATE_TX_ID = 0x09,
+ NWK_ROUTE_REPLY_TX_ID = 0x0A,
+ NWK_INITIAL_ROUTE_REQ_TX_ID = 0x0B,
+ NWK_INITIAL_MANYTOONE_ROUTE_REQ_TX_ID = 0x0C,
+ NWK_ROUTE_REQ_TX_ID = 0x0D,
+ NWK_MANYTOONE_ROUTE_REQ_TX_ID = 0x0E,
+ NWK_ROUTE_RECORD_TX_ID = 0x0F,
+ NWK_MANY_TO_ONE_STATUS_TX_ID = 0x10,
+ NWK_MAX_COMMAND_TX_ID = NWK_MANY_TO_ONE_STATUS_TX_ID,
+
+ NWK_UNICAST_COMMAND_TRANSIT_TX_ID = 0x11,
+ NWK_UNICAST_DATA_TRANSIT_TX_ID = 0x12,
+ NWK_MULTICAST_NON_MEMBER_TRANSIT_TX_ID = NWK_UNICAST_DATA_TRANSIT_TX_ID,
+ NWK_BROADCAST_TRANSIT_TX_ID = 0x13,
+ NWK_MULTICAST_MEMBER_TRANSIT_TX_ID = 0x14,
+ NWK_SOURCE_ROUTE_TRANSIT_TX_ID = 0x15,
+ NWK_ROUTE_RECORD_TRANSIT_TX_ID = 0x16,
+ NWK_MANY_TO_ONE_TRANSIT_STATUS_TX_ID = 0x17,
+
+ NWK_MIN_DATA_TX_ID = 0x18,
+ NWK_UNICAST_DATA_TX_ID = NWK_MIN_DATA_TX_ID,
+ NWK_MULTICAST_NON_MEMBER_TX_ID = NWK_UNICAST_DATA_TX_ID,
+ NWK_BROADCAST_DATA_TX_ID = 0x19,
+ NWK_MULTICAST_MEMBER_TX_ID = 0x1A,
+ NWK_SOURCE_ROUTE_TX_ID = 0x1B,
+
+ NWK_MAX_TX_ID
+} NwkTxId_t;
+
+/** Type of iterator for transmission identifiers. */
+typedef uint8_t NwkTxIdIter_t;
+
+/** Type of callback function for preparing an output packet. */
+typedef void (* NwkPrepareTxFunc_t)(NwkOutputPacket_t *const);
+/** Type of callback function for confirmation of packet transmission. */
+typedef void (* NwkConfirmTxFunc_t)(NwkOutputPacket_t *const,
+ const NWK_Status_t);
+
+/** Internal variables of transmission component. */
+typedef struct _NwkTx_t
+{
+ /** Queue of output packets */
+ QueueDescriptor_t queue;
+} NwkTx_t;
+
+/** Internal states of output packet for debug. */
+typedef enum _NwkOutPktState_t
+{
+ NWK_OUTPKT_IN_QUEUE_STATE = 0x00,
+ NWK_OUTPKT_RDISCOVERY_STATE = 0x01,
+ NWK_OUTPKT_MAC_STATE = 0x02,
+ NWK_OUTPKT_DELAY_STATE = 0x03,
+ NWK_OUTPKT_ENCRYPT_STATE = 0x04,
+ NWK_OUTPKT_DECRYPT_STATE = 0x05,
+ NWK_OUTPKT_ROUTE_RECORD_STATE = 0x06
+} NwkOutPktState_t;
+
+/******************************************************************************
+ Inline static functions prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Is this packet a network data?
+
+ \param[in] outPkt - pointer to the output network packet.
+ \return 'true' if this output packet is data packet otherwise return 'false'.
+ ******************************************************************************/
+INLINE bool nwkIsDataPacket(const NwkOutputPacket_t *const outPkt)
+{
+ assert(outPkt->txId < NWK_MAX_TX_ID, NWKTX_NWKISDATAPACKET0);
+ return NWK_MIN_DATA_TX_ID <= outPkt->txId;
+}
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Request to transmit the output packet.
+
+ \param[in] outPkt - pointer to the output network packet.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkTxReq(NwkOutputPacket_t *const outPkt);
+
+/**************************************************************************//**
+ \brief Main task handler of the packet transmission component
+ ******************************************************************************/
+NWK_PRIVATE void nwkTxTaskHandler(void);
+
+/**************************************************************************//**
+ \brief Reset the packet transmission component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetTx(void);
+
+/**************************************************************************//**
+ \brief Confirmation of packet transmission.
+
+ \param[in] outPkt - pointer to output packet.
+ \param[in] status - network status of packet transmission.
+
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkTxConf(NwkOutputPacket_t *const outPkt,
+ const NWK_Status_t status);
+
+/**************************************************************************//**
+ \brief Write default values to parameters of MAC_DataReq request.
+
+ \param[in] outPkt - pointer to an output packet.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkInitMacDataReq(NwkOutputPacket_t *const outPkt);
+
+/**************************************************************************//**
+ \brief Start packet transmission.
+
+ \param[in] outPkt - pointer to output packet.
+ \param[in] encrypt - if 'true' then packet encrypting is required.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkTransmitOutputPacket(NwkOutputPacket_t *const outPkt,
+ const bool encrypt);
+
+#endif /* _NWK_TX_H */
+/** eof nwkTx.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkTxDelay.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkTxDelay.h
new file mode 100644
index 00000000..fb841445
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkTxDelay.h
@@ -0,0 +1,101 @@
+/**************************************************************************//**
+ \file nwkTxDelay.h
+
+ \brief Interface of transmission delays.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2009-09-20 Max Gekk - Created.
+ Last change:
+ $Id: nwkTxDelay.h 18167 2011-08-08 11:26:31Z mgekk $
+ ******************************************************************************/
+#if !defined _NWK_TX_DELAY_H
+#define _NWK_TX_DELAY_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <appTimer.h>
+#include <queue.h>
+#include <nldeData.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Internal variables of delay component. */
+typedef struct _NwkTxDelay_t
+{
+ bool isTimerStarted;
+ HAL_AppTimer_t timer;
+ QueueDescriptor_t queue;
+} NwkTxDelay_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Transmission delay request.
+
+ \param[in] delayReq - pointer to delay request's parameters.
+ \param[in] macStatus - pointer to MAC status of MLDE-DATA.confirm or NULL if
+ it is first transmission.
+ \return further behavior.
+ ******************************************************************************/
+NWK_PRIVATE NwkTxDelayStatus_t nwkTxDelayReq(NwkTxDelayReq_t *const delayReq,
+ MAC_Status_t *const macStatus);
+
+/**************************************************************************//**
+ \brief The transmission delay has expired.
+
+ \param[in] delayReq - pointer to delay request's parameters.
+ \param[in] status - status of further behavior.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkTxDelayConf(NwkTxDelayReq_t *const delayReq,
+ const NwkTxDelayStatus_t status);
+
+/**************************************************************************//**
+ \brief Flush all delays.
+ ******************************************************************************/
+NWK_PRIVATE void nwkFlushTxDelays(void);
+
+/**************************************************************************//**
+ \brief Reset delay component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetTxDelays(void);
+
+/******************************************************************************
+ \brief nwkTxDelay idle checking.
+
+ \return true, if nwkTxDelay performs no activity, false - otherwise.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkTxDelayIsIdle(void);
+
+/**************************************************************************//**
+ \brief Delivery time of broadcast data transmission on a network.
+
+ \return Current value of broadcast delivery time in milliseconds.
+ ******************************************************************************/
+NWK_PRIVATE uint32_t nwkGetBroadcastDeliveryTime(void);
+
+#if defined _NWK_PASSIVE_ACK_ && (defined _ROUTER_ || defined _COORDINATOR_)
+/**************************************************************************//**
+ \brief All expected passive acks are received, confirm the passive ack req.
+
+ \param[in] delayReq - pointer to delay request's parameters.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkPassiveAckConf(NwkTxDelayReq_t *const delayReq);
+#endif /* _NWK_PASSIVE_ACK_ */
+
+#endif /* _NWK_TX_DELAY_H */
+/** eof nwkTxDelay.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkTxSecurity.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkTxSecurity.h
new file mode 100644
index 00000000..fc9d0120
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkTxSecurity.h
@@ -0,0 +1,70 @@
+/**************************************************************************//**
+ \file nwkTxSecurity.h
+
+ \brief Interface of transmission security.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2009-08-31 M. Gekk - Created.
+ Last change:
+ $Id: nwkTxSecurity.h 17721 2011-06-27 10:38:42Z mgekk $
+ ******************************************************************************/
+#if !defined _NWK_TX_SECURITY_H
+#define _NWK_TX_SECURITY_H
+
+#if defined _SECURITY_
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <mac.h>
+#include <sspSfp.h>
+#include <nwkTx.h>
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Check of that enciphering for a proceeding network packet is required.
+
+ \param[in] outPkt - pointer to a network output packet.
+ \return 'true' if encrypting is required otherwise 'false'
+ ******************************************************************************/
+NWK_PRIVATE bool nwkIsEncryptingRequired(NwkOutputPacket_t *const outPkt);
+
+/**************************************************************************//**
+ \brief Request to encrypt an output network packet.
+
+ \param[in] encryptReq - encrypt frame primitive's parameters structure.
+ \param[in] macDataReq - MCPS-DATA request primitive's parameters structure.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkEncryptOutputPacket(SSP_EncryptFrameReq_t *const encryptReq,
+ const MAC_DataReq_t *const macDataReq);
+
+/**************************************************************************//**
+ \brief Request to decrypt an output network packet.
+
+ \param[in] decryptReq - decrypt frame primitive's parameters structure.
+ \param[in] macDataReq - MCPS-DATA request primitive's parameters structure.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkDecryptOutputPacket(SSP_DecryptFrameReq_t *const decryptReq,
+ const MAC_DataReq_t *const macDataReq);
+
+#else /* _SECURITY_ */
+
+#define nwkIsEncryptingRequired(outPkt) false
+#define nwkIsDecryptingRequired(outPkt) false
+
+#endif /* _SECURITY_ */
+#endif /* _NWK_TX_SECURITY_H */
+/** eof nwkTxSecurity.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkUpdateCommand.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkUpdateCommand.h
new file mode 100644
index 00000000..e0fff7de
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkUpdateCommand.h
@@ -0,0 +1,146 @@
+/**************************************************************************//**
+ \file nwkUpdateCommand.h
+
+ \brief Update command header file.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2008-12-10 M. Gekk - Reduction of usage of the RAM at separate compiling.
+ 2009-06-08 M. Gekk - Refactoring.
+ Last change:
+ $Id: nwkUpdateCommand.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_UPDATE_COMMAND_H
+#define _NWK_UPDATE_COMMAND_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <nwkSystem.h>
+#include <mac.h>
+#include <nwkCommon.h>
+#include <appTimer.h>
+#include <nwkFrame.h>
+
+/******************************************************************************
+ Definitions section
+ ******************************************************************************/
+/** Types of update information command. */
+#define NWK_UPDATE_TYPE_PANID_CONFLICT 0U
+/** Minimum size of the update command payload without update information field.
+ **/
+#define NWK_SIZE_OF_UPDATE_CMD_PAYLOD 13U
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Internal states of the update command component. */
+typedef enum _NwkUpdateCommandState_t
+{
+ /** State after reset */
+ NWK_UPDATE_IDLE_STATE = 0x92,
+ NWK_UPDATE_FIRST_STATE = 0x19,
+ NWK_UPDATE_WAIT_BROADCAST_DELIVERY_STATE = NWK_UPDATE_FIRST_STATE,
+ NWK_UPDATE_MAC_SET_PAN_ID_STATE = 0x1B,
+ NWK_UPDATE_LAST_STATE
+} NwkUpdateCommandState_t;
+
+/** Confirmation of setting a new pan id. */
+typedef void (* NwkUpdatePanIdConf_t)(void);
+
+/** Internal variables of the update command component. */
+typedef struct _NwkUpdateCommand_t
+{
+ /** Finite-state machine */
+ NwkUpdateCommandState_t state;
+ PanId_t newPanId;
+ NwkUpdateId_t updateId;
+ NwkUpdatePanIdConf_t callback;
+ union
+ {
+ HAL_AppTimer_t timer;
+ MAC_SetReq_t macSet;
+ } req;
+} NwkUpdateCommand_t;
+
+/** Payload of network update command. ZigBee spec r17, Figure 3.28. */
+BEGIN_PACK
+typedef struct PACK _NwkUpdateCommandPayload_t
+{
+ /** Id of the update command. ZigBee spec r17, Table 3.40. */
+ NwkCommandIdField_t commandId;
+ /** The update information count sub-field contains an integer indicating
+ * the number of records contained within the Update Information field. */
+ LITTLE_ENDIAN_OCTET(2, (
+ NwkBitField_t infoCount :5,
+ /** The update command identifier sub-field contains an integer indicating
+ * the type of update information command.
+ * ZigBee spec r17, Figure 3.30, page 337. */
+ NwkBitField_t updateCmdId :3
+ ))
+ /** The EPID field shall contain the 64bit EPID that identifies the network
+ * that is to be updated. ZigBee spec r17, 3.4.10.3.2, page 337. */
+ ExtPanId_t extPanId;
+ /** The update information field provides the information being updated,
+ * the format of this field depends upon the value of the Update Command
+ * Identifier sub-field. ZigBee spec r17, 3.4.10.3.4, page 337. */
+ NwkUpdateId_t updateId;
+ /** The PAN identifier update shall be made up of a single 16-bit PAN
+ * identifier that is the new PAN identifier for this network to use.
+ * ZigBee spec r17, 3.4.10.3.4.1, page 338. */
+ PanId_t newPanId;
+} NwkUpdateCommandPayload_t;
+END_PACK
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined _RESOLVE_PANID_CONFLICT_
+/**************************************************************************//**
+ \brief Set a new pan id.
+
+ \param[in] newPanId - a new identifier of PAN.
+ \param[in] updateId - a new update identifier.
+ \param[in] callback - pointer to a update confirmation function.
+
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkUpdatePanId(const PanId_t newPanId,
+ const NwkUpdateId_t updateId, const NwkUpdatePanIdConf_t callback);
+
+/**************************************************************************//**
+ \brief Action when a update command is received.
+
+ \param[in] payload - pointer to NPDU of NWK update command.
+ \param[in] header - nwk header.
+ \param[in] parse - parsed header fields.
+
+ \return 'true' - continue processing command otherwise 'false'.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkUpdateFrameInd(const uint8_t *const payload,
+ const NwkFrameHeader_t *const header, const NwkParseHeader_t *const parse);
+
+/**************************************************************************//**
+ \brief Reset the update command component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetUpdateCommand(void);
+
+#else /* _RESOLVE_PANID_CONFLICT_ */
+
+/* Interface of the update command is disabled. */
+#define nwkUpdatePanId(newPanId,updateId,callback)
+#define nwkUpdateFrameInd NULL
+#define nwkResetUpdateCommand() (void)0
+
+#endif /* _RESOLVE_PANID_CONFLICT_ */
+#endif /* _NWK_UPDATE_COMMAND_H */
+/** eof nwkUpdateCommand.h */
+