summaryrefslogtreecommitdiffhomepage
path: root/digital/zigbit/bitcloud/stack/Components/NWK
diff options
context:
space:
mode:
Diffstat (limited to 'digital/zigbit/bitcloud/stack/Components/NWK')
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nldeData.h402
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeDirectJoin.h76
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeEdScan.h88
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeJoin.h148
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeLeave.h105
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeNetworkDiscovery.h122
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeNetworkFormation.h95
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeNwkStatus.h122
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nlmePermitJoining.h99
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeReset.h124
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeRouteDiscovery.h88
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeSetGet.h299
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeStartRouter.h81
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeSync.h79
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeSyncLoss.h34
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nwk.h87
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nwkAddressResolv.h67
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nwkAttributes.h196
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nwkCommon.h353
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nwkConfigServer.h47
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nwkGroup.h144
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nwkNeighbor.h241
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nwkProfiler.h68
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nwkRouteInfo.h124
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nwkSecurity.h270
-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
79 files changed, 11104 insertions, 0 deletions
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nldeData.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nldeData.h
new file mode 100644
index 00000000..8595e54e
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nldeData.h
@@ -0,0 +1,402 @@
+/**************************************************************************//**
+ \file nldeData.h
+
+ \brief NLDE-DATA interface
+
+ \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-13 Max Gekk - Created.
+ Last change:
+ $Id: nldeData.h 18405 2011-08-31 15:42:23Z mgekk $
+ ******************************************************************************/
+#if !defined _NLDE_DATA_H
+#define _NLDE_DATA_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <types.h>
+#include <appFramework.h>
+#include <mac.h>
+#include <nwkCommon.h>
+#include <nwkNeighbor.h>
+#include <nlmeRouteDiscovery.h>
+#if defined _SECURITY_
+#include <sspSfp.h>
+#endif /* _SECURITY_ */
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/**//**
+ * \brief NLDE-DATA confirm primitive's parameters structure declaration.
+ * ZigBee Specification r17, 3.2.2.2 NLDE-DATA.confirm, page 264.
+ */
+typedef struct _NWK_DataConf_t
+{
+ /* Service fields - for internal needs. */
+ struct
+ {
+ QueueElement_t qelem;
+ } service;
+
+ /** The status of the corresponding request. */
+ NWK_Status_t status;
+ /** The handle associated with the NSDU being confirmed. */
+ void *nsduHandle;
+ /** A time indication for the transmitted packet based on the local clock. */
+ uint32_t txTime;
+ /** Quantity (or approximate quantity, it depends on routing method) of hops between source and destination nodes */
+ NwkRadius_t hops;
+} NWK_DataConf_t;
+
+/** Transmission delay types. */
+typedef enum _NwkTxDelayType_t
+{
+ NWK_TX_DELAY_UNICAST_DATA = 0x00,
+ NWK_TX_DELAY_UNICAST_COMMAND = 0x01,
+ NWK_TX_DELAY_LINK_STATUS = 0x02,
+ NWK_TX_DELAY_INITIAL_ROUTE_REQUEST = 0x03,
+ NWK_TX_DELAY_INITIAL_MANYTOONE_ROUTE_REQUEST = 0x04,
+ NWK_TX_DELAY_ROUTE_REQUEST = 0x05,
+ NWK_TX_DELAY_MANYTOONE_ROUTE_REQUEST = 0x06,
+ NWK_TX_DELAY_BROADCAST = 0x07,
+ NWK_TX_DELAY_BROADCAST_SUCCESS = 0x08,
+ NWK_TX_DELAY_MULTICAST = 0x09,
+ NWK_TX_DELAY_MULTICAST_SUCCESS = 0x0A,
+ NWK_TX_DELAY_INITIAL_MULTICAST= 0x0B,
+ NWK_TX_DELAY_INITIAL_ROUTE_RECORD = 0x0C,
+ NWK_TX_DELAY_TRANSIT_DATA = 0x0D,
+ NWK_LAST_TX_DELAY
+} NwkTxDelayType_t;
+
+/** Further behavior after delay. */
+typedef enum _NwkTxDelayStatus_t
+{
+ NWK_TX_NOW = 0x0, /**< Immediately to send. */
+ NWK_TX_DONE = 0x1, /**< To complete transmission. */
+ NWK_TX_DELAY_REQUIRED = 0x2, /**< Delay before transmission. */
+ NWK_TX_INDIRECT = 0x3 /**< Indirect transmission to all children. */
+} NwkTxDelayStatus_t;
+
+/** Delay request's parameters. */
+typedef struct _NwkTxDelayReq_t
+{
+ /* Service fields - for internal needs. */
+ struct
+ { /** Link to a next output packet in queue. */
+ QueueElement_t qelem;
+ } service;
+
+ NwkTxDelayType_t type;
+ uint8_t attempt;
+ uint16_t delay;
+ NwkTxDelayStatus_t actionAfterDelay;
+} NwkTxDelayReq_t;
+
+/* Routing methods, used for data packet transmission. */
+typedef enum _NwkRoutingMethod_t
+{
+ NWK_ROUTING_UNKNOWN,
+ NWK_ROUTING_FAIL,
+ NWK_ROUTING_INDIRECT,
+ NWK_ROUTING_TO_PARENT,
+ NWK_ROUTING_TO_NEIGHBOR,
+ NWK_ROUTING_TREE,
+ NWK_ROUTING_MESH,
+ NWK_ROUTING_MANYTOONE,
+ NWK_ROUTING_BROADCAST,
+ NWK_ROUTING_DIRECT,
+ NWK_ROUTING_MANYTOONE_RECORD
+} NwkRoutingMethod_t;
+
+/* Information about routing method and quantity of hops to destination node */
+typedef struct _NwkRouting_t
+{
+ NwkRoutingMethod_t method;
+ NwkRadius_t hops;
+} NwkRouting_t;
+
+/**//**
+ * \brief Meta-information of output packet.
+ */
+typedef struct _NwkOutputPacket_t
+{
+ /* Service fields - for internal needs. */
+ struct
+ { /** Link to a next output packet in queue. */
+ QueueElement_t qelem;
+ } service;
+
+ /** Identifier of transmission request. */
+ uint8_t txId;
+ /** Transmission context. */
+ void *context;
+ /** pointer to the destination neighbor. */
+ NwkNeighbor_t *neighbor;
+ /** Used routing method for transmission and quantity of hops to destination node. */
+ NwkRouting_t routingInfo;
+ /** Address of node from which the packet has been received. */
+ ShortAddr_t prevHopAddr;
+ /** Flag indicates that secured packet must be decrypted or not. */
+ bool decryptRequired;
+ /** MCPS-DATA request primitive's parameters structure. */
+ MAC_DataReq_t macDataReq;
+ union
+ {
+ /** NLME-ROUTE-DISCOVERY request primitive's parameters structure. */
+ NWK_RouteDiscoveryReq_t routeDiscovery;
+ /** Transmission delay parameters. */
+ NwkTxDelayReq_t txDelay;
+#if defined _NWK_ROUTE_RECORD_
+ /** Internal variables of the route record component. */
+ struct
+ {/** Extended address of node from which an original packet
+ * has been received. */
+ ExtAddr_t from;
+ } routeRecord;
+#endif /* _NWK_ROUTE_RECORD_ */
+#if defined _SECURITY_
+ /** Encrypt Frame primitive's parameters structure. */
+ SSP_EncryptFrameReq_t encrypt;
+ /** Decrypt Frame primitive's parameters structure. */
+ SSP_DecryptFrameReq_t decrypt;
+#endif /* _SECURITY_ */
+ } req;
+#if defined _SYS_ASSERT_ON_
+ uint8_t state;
+#endif
+} NwkOutputPacket_t;
+
+/**//**
+ * \brief NLDE-DATA request primitive's parameters structure declaration.
+ * Zigbee Specification r17, 3.2.2.1 NLDE-DATA.request, page 261.
+ */
+typedef struct _NWK_DataReq_t
+{
+ /* Service fields - for internal needs. */
+ struct
+ {
+ QueueElement_t qelem; /**< link used for queuing */
+ NwkOutputPacket_t outPkt;
+ } service;
+
+ /* Public fields. */
+ /** The type of destination address supplied by the DstAddr parameter. */
+ NWK_DstAddrMode_t dstAddrMode;
+ /** Destination address. */
+ ShortAddr_t dstAddr;
+ /** The number of octets comprising the NSDU to be transferred. */
+ NwkLength_t nsduLength;
+ /** The set of octets comprising the NSDU to be transferred. */
+ uint8_t *nsdu;
+ /** The handle associated with the NSDU to be transmitted by the NWK layer. */
+ void *nsduHandle;
+ /** The distance, in hops, that a frame will be allowed
+ * to travel through the network. */
+ NwkRadius_t radius;
+ /** The distance, in hops, that a multicast frame will be relayed by nodes
+ * not a member of the group. A value of 0x07 is treated as infinity.*/
+ NwkRadius_t nonmemberRadius;
+ /** The DiscoverRoute parameter may be used to control route discovery
+ * operations for the transit of this frame: false = suppress route discovery,
+ * true = enable route discovery */
+ bool discoverRoute;
+ /** Encrypt packet by network key before transmission. */
+ bool securityEnable;
+ /** Decrypt packet after transmission or not. This is recommendation for NWK layer.
+ * NWK layer may set this flag to 'true' if packet was decrypted. */
+ bool decryptRequired;
+ /** Send to self a) broadcast, if destination address is matched to device type,
+ * b) multicast, if device is in group or c) unicast, if destination address
+ * is short address of this device. If this flag is 'false' then NWK-layer never
+ * sends to self otherwise it sends to self only conditions a)-c) are true.
+ * Before call NWK_DataConf this flag is set to true if NWK_DataInd will be called.
+ * */
+ bool boomerang;
+ /** NLDE-DATA confirm callback function's pointer. */
+ void (*NWK_DataConf)(NWK_DataConf_t *conf);
+ NWK_DataConf_t confirm;
+} NWK_DataReq_t;
+
+/** Service information for an outgoing external packet. */
+typedef NWK_DataReq_t NwkExternPacket_t;
+
+/** Nonstandard NLDE-DATA.response */
+typedef struct _NWK_DataResp_t
+{
+ uint8_t status;
+} NWK_DataResp_t;
+
+/**//**
+ * \brief NLDE-DATA indication primitive's parameters structure declaration.
+ * Zigbee Specification r17, 3.2.2.3 NLDE-DATA.indication, page 266.
+ */
+typedef struct _NWK_DataInd_t
+{
+ /* Service fields - for internal needs. */
+ struct
+ {
+ QueueElement_t qelem; /**< link used for queuing */
+ } service;
+
+ /** The type of destination address supplied by the DstAddr parameter.
+ * This may have one of the following two values:
+ * - 0x01 = 16-bit multicast group address,
+ * - 0x02 = 16-bit network address of a device or a broadcast address. */
+ NWK_DstAddrMode_t dstAddrMode;
+ /** The destination address to which the NSDU was sent. */
+ ShortAddr_t dstAddr;
+ /** The individual device address from which the NSDU originated. */
+ ShortAddr_t srcAddr;
+ /** The short node address from which the NSDU received. */
+ ShortAddr_t prevHopAddr;
+ /** The number of octets comprising the NSDU being indicated. */
+ NwkLength_t nsduLength;
+ /** The set of octets comprising the NSDU being indicated. */
+ uint8_t *nsdu;
+ /** The link quality indication delivered by the MAC on receipt of this frame
+ * as a parameter of the MCPS-DATA.indication primitive. */
+ Lqi_t linkQuality;
+ /** RSSI delivered by the MAC on receipt of this frame as a parameter of
+ * the MCPS-DATA.indication primitive.*/
+ Rssi_t rssi;
+ /** A time indication for the received packet based on the local clock. */
+ uint32_t rxTime;
+ /** An indication of whether the received data frame is using security. */
+ bool securityUse;
+ /** The flag indicates that the packet was sent through the loop. */
+ bool boomerang;
+ /** NLDE-DATA response callback function's pointer. */
+ void (*NWK_DataResp)(NWK_DataResp_t *resp);
+ NWK_DataResp_t response;
+} NWK_DataInd_t;
+
+/**//**
+ * \brief Confirmation parameters of NWK Data allocation.
+ */
+typedef struct _NWK_AllocDataConf_t
+{
+ NWK_DataReq_t *nwkDataReq;
+} NWK_AllocDataConf_t;
+
+/**//**
+ * \brief Parameters of NWK Data allocation request.
+ */
+typedef struct _NWK_AllocDataReq_t
+{
+ /* Service fields - for internal needs. */
+ struct
+ {
+ QueueElement_t qelem; /**< link used for queuing */
+ } service;
+
+ /** The number of allocated octets in the NSDU. */
+ NwkLength_t nsduLength;
+ /** Pointer to confirm callback function. */
+ void (*NWK_AllocDataConf)(NWK_AllocDataConf_t *conf);
+ NWK_AllocDataConf_t confirm;
+} NWK_AllocDataReq_t;
+
+/******************************************************************************
+ Define(s) section
+ ******************************************************************************/
+/** Get length of output packet. */
+#define NWK_GET_OUTPKT_LEN(outPkt) ((outPkt)->macDataReq.msduLength)
+/** Set length of output packet. */
+#define NWK_SET_OUTPKT_LEN(outPkt, len) (outPkt)->macDataReq.msduLength = (len)
+#define NWK_SET_INVALID_OUTPKT_LEN(outPkt) \
+ NWK_SET_OUTPKT_LEN(outPkt, MAC_MAX_MSDU_SIZE + 1U)
+#define NWK_IS_VALID_OUTPKT_LEN(outPkt) \
+ (NWK_GET_OUTPKT_LEN(outPkt) <= MAC_MAX_MSDU_SIZE)
+/** Add value to length of output packet. */
+#define NWK_ADD_TO_OUTPKT_LEN(outPkt, value) \
+ (outPkt)->macDataReq.msduLength += (value)
+/** Subtract value from length of output packet. */
+#define NWK_SUB_FROM_OUTPKT_LEN(outPkt, value) \
+ (outPkt)->macDataReq.msduLength -= (value)
+/** Get pointer to data (NWK header + payload) of output packet. */
+#define NWK_GET_OUTPKT_DATA(outPkt) ((void *)((outPkt)->macDataReq.msdu))
+/** Initialize msdu pointer. */
+#define NWK_SET_OUTPKT_DATA(outPkt, ptr) \
+ (outPkt)->macDataReq.msdu = (uint8_t *)(ptr)
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief NLDE-DATA request primitive's prototype.
+
+ \param[in] req - NLDE-DATA request parameters' structure pointer.
+ \return None.
+ ******************************************************************************/
+void NWK_DataReq(NWK_DataReq_t *const req);
+
+/**************************************************************************//**
+ \brief NLDE-DATA indication primitive's prototype.
+
+ \param[in] ind - NLDE-DATA indication parameters' structure pointer.
+ \return None.
+ ******************************************************************************/
+extern void NWK_DataInd(NWK_DataInd_t *ind);
+
+/**************************************************************************//**
+ \brief The request to send own data packet to itself.
+
+ \param[in] req - pointer to parameters of NLDE-DATA.request primitive.
+ \return None.
+ ******************************************************************************/
+void NWK_LoopbackTxReq(NWK_DataReq_t *const req);
+
+#if defined _INTERPAN_
+/**************************************************************************//**
+ \brief INTRP-DATA.ind primitive handler.
+
+ It is intended to notify APS Layer about incoming Inter-PAN packet.
+
+ \param[in] ind - NLDE-DATA indication parameters' structure pointer.
+ \return None.
+ ******************************************************************************/
+void NWK_IntrpDataInd(MAC_DataInd_t *ind);
+#endif /*_INTERPAN_*/
+#if defined _NWK_ALLOCATOR_
+/**************************************************************************//**
+ \brief Allocate memory for NWK_DataReq_t structure and MPDU.
+
+ \param[in] req - pointer to allocation parameters' structure.
+ \return None.
+ ******************************************************************************/
+void NWK_AllocDataReq(NWK_AllocDataReq_t *const req);
+
+/**************************************************************************//**
+ \brief Free memory which is allocated for NWK_DataReq_t structure and MPDU.
+
+ \param[in] req - NLDE-DATA request parameters' structure pointer.
+ \return None.
+ ******************************************************************************/
+void NWK_FreeDataReq(NWK_DataReq_t *const req);
+
+/**************************************************************************//**
+ \brief Transform pointer to NWK_DataInd_t to pointer to NWK_DataReq_t.
+
+ This function initializes nsdu and nsduLength by appropriate field
+ from NWK_DataInd_t structure.
+
+ \param[in] ind - NLDE-DATA indication parameters' structure pointer.
+ \param[in] secure - if 'true' then encryption on NWK will be used for
+ NLDE-DATA.request otherwise 'false'.
+ \return Pointer to NLDE-DATA.request's parameters.
+ ******************************************************************************/
+NWK_DataReq_t* NWK_DataTransformIndToReq(NWK_DataInd_t *ind, const bool secure);
+
+#endif /* _NWK_ALLOCATOR_ */
+#endif /* _NLDE_DATA_H */
+/** eof nldeData.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeDirectJoin.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeDirectJoin.h
new file mode 100644
index 00000000..1e2141a7
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeDirectJoin.h
@@ -0,0 +1,76 @@
+/**************************************************************************//**
+ \file nlmeDirectJoin.h
+
+ \brief NLME-DIRECT-JOIN interface
+
+ \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-12 Max Gekk - Created.
+ Last change:
+ $Id: nlmeDirectJoin.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NLME_DIRECT_JOIN_H
+#define _NLME_DIRECT_JOIN_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <appFramework.h>
+#include <nwkCommon.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/**//**
+ * \brief NLME-DIRECT-JOIN confirm primitive's parameters structure declaration.
+ * ZigBee Specification r17, 3.2.2.15 NLME-DIRECT-JOIN.confirm, page 287.
+ */
+typedef struct _NWK_DirectJoinConf_t
+{
+ /** The status of the corresponding request. */
+ NWK_Status_t status;
+} NWK_DirectJoinConf_t;
+
+/**//**
+ * \brief NLME-DIRECT-JOIN request primitive's parameters structure declaration.
+ * Zigbee Specification r17, 3.2.2.14 NLME-DIRECT-JOIN.request, page 286.
+ */
+typedef struct _NWK_DirectJoinReq_t
+{
+ /** Service fields - for internal needs. */
+ struct
+ {
+ QueueElement_t qelem; /**< link used for queuing */
+ } service;
+ /** The IEEE address of the device to be directly joined.*/
+ ExtAddr_t deviceAddress;
+ /** Recommended network address. */
+ ShortAddr_t networkAddress;
+ /** The operating capabilities of the device being directly joined. */
+ MAC_CapabilityInf_t capabilityInformation;
+ /** NLME-DIRECT-JOIN confirm callback function's pointer. */
+ void (*NWK_DirectJoinConf)(NWK_DirectJoinConf_t *conf);
+ NWK_DirectJoinConf_t confirm;
+} NWK_DirectJoinReq_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief NLME-DIRECT-JOIN request primitive's prototype.
+
+ \param[in] req - NLME-DIRECT-JOIN request parameters' structure pointer.
+ \return None.
+ ******************************************************************************/
+void NWK_DirectJoinReq(NWK_DirectJoinReq_t *const req);
+
+#endif /* _NLME_DIRECT_JOIN_H */
+/** eof nlmeDirectJoin.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeEdScan.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeEdScan.h
new file mode 100644
index 00000000..0e5a09bc
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeEdScan.h
@@ -0,0 +1,88 @@
+/**************************************************************************//**
+ \file nlmeEdScan.h
+
+ \brief NLME-ED-SCAN interface
+
+ \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-11 Max Gekk - Created.
+ Last change:
+ $Id: nlmeEdScan.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NLME_ED_SCAN_H
+#define _NLME_ED_SCAN_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <appFramework.h>
+#include <nwkCommon.h>
+
+/******************************************************************************
+ Define(s) section
+ ******************************************************************************/
+/** Maximum number of channels which can be scanned for one request. */
+#define MAX_EDSCAN_CHANNEL_AMOUNT 16U
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/**//**
+ * \brief NLME-ED-SCAN confirm primitive's parameters structure declaration.
+ * ZigBee Specification r17, 3.2.2.10 NLME-ED-SCAN.confirm
+ */
+typedef struct _NWK_EDScanConf_t
+{
+ /** The status of the request. */
+ NWK_Status_t status;
+ /** Indicates which channels given in the request were not scanned. */
+ ChannelsMask_t unScannedChannels;
+ /** Size of energyDetectList */
+ uint8_t energyDetectListSize;
+ /** The list of energy measurements */
+ PHY_EnergyLevel_t energyDetectList[MAX_EDSCAN_CHANNEL_AMOUNT];
+} NWK_EDScanConf_t;
+
+/**//**
+ * \brief NLME-ED-SCAN request primitive's parameters structure declaration.
+ * Zigbee Specification r17, 3.2.2.9 NLME-ED-SCAN.request.
+ */
+typedef struct _NWK_EDScanReq_t
+{
+ /** Service fields - for internal needs. */
+ struct
+ {
+ QueueElement_t qelem; /**< link used for queuing */
+ MAC_ScanReq_t macScanReq;
+ } service;
+ /** Bitmask of channels are to be scanned */
+ ChannelsMask_t scanChannels;
+ /** A value used to calculate the length of time to spend
+ * scanning each channel. */
+ ScanDuration_t scanDuration;
+ /** NLME-ED-SCAN confirm callback function's pointer. */
+ void (*NWK_EDScanConf)(NWK_EDScanConf_t *conf);
+ NWK_EDScanConf_t confirm;
+} NWK_EDScanReq_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief NLME-ED-SCAN request primitive's prototype.
+
+ \param[in] req - NLME-ED-SCAN request parameters' structure pointer.
+ \return None.
+ ******************************************************************************/
+void NWK_EDScanReq(NWK_EDScanReq_t *const req);
+
+#endif /* _NLME_ED_SCAN_H */
+/** eof nlmeEdScan.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeJoin.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeJoin.h
new file mode 100644
index 00000000..d2331f28
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeJoin.h
@@ -0,0 +1,148 @@
+/**************************************************************************//**
+ \file nlmeJoin.h
+
+ \brief NLME-JOIN interface
+
+ \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-11 Max Gekk - Created.
+ Last change:
+ $Id: nlmeJoin.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NLME_JOIN_H
+#define _NLME_JOIN_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <mac.h>
+#include <nwkCommon.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/**//**
+ * \brief NLME-JOIN confirm primitive's parameters structure declaration.
+ * ZigBee Specification r17, 3.2.2.13 NLME-JOIN.confirm, page 285.
+ */
+typedef struct _NWK_JoinConf_t
+{
+ /** The status of the corresponding request. Valid Range: NWK_SUCCESS_STATUS,
+ * NWK_NOT_PERMITTED_STATUS, NWK_NO_NETWORKS_STATUS or any status value
+ * returned from MLME-ASSOCIATE.confirm, MLME-SET.confirm, MLME-GET.confirm,
+ * MLME-RX-ENABLE.confirm, NLME-NETWORK-DISCOVERY.confirm. */
+ NWK_Status_t status;
+ /** The 16-bit network address that was allocated to this device. This parameter
+ * will be equal to 0xffff if the join attempt was unsuccessful. */
+ ShortAddr_t networkAddress;
+ /** The 64-bit extended PAN identifier for the network of which the device is
+ * now a member. */
+ ExtPanId_t extendedPANId;
+ /** The value of phyCurrentChannel attribute of the PHY PIB, which is equal to
+ * the current channel of the network that has been joined. */
+ Channel_t activeChannel;
+} NWK_JoinConf_t;
+
+/** The method of joining the network. */
+typedef enum _NWK_RejoinNetwork_t
+{
+ /** The device is requesting to join a network through association. */
+ NWK_REJOIN_ASSOCIATION = 0,
+ /** The device is joining directly or rejoining the network using
+ * the orphaning procedure. */
+ NWK_REJOIN_ORPHAN = 1,
+ /** The device is joining the network using the NWK rejoining procedure. */
+ NWK_REJOIN_NWK_REJOIN = 2,
+ /** The device is to change the operational network channel to that
+ * identified in the ScanChannels parameter. */
+ NWK_REJOIN_CHANGE_CHANNEL = 3,
+ /** The device is joining to a network with known parameters. Device's own
+ * parameters are also known. This rejoin won't be visible on the air. */
+ NWK_REJOIN_SILENT = 4,
+} NWK_RejoinNetwork_t;
+
+/**//**
+ * \brief NLME-JOIN request primitive's parameters structure declaration.
+ * Zigbee Specification r17, 3.2.2.11 NLME-JOIN.request, page 281.
+ */
+typedef struct _NWK_JoinReq_t
+{
+ /** Service fields - for internal needs. */
+ struct
+ {
+ QueueElement_t qelem; /**< link used for queuing */
+ } service;
+ /** The 64-bit PAN identifier of the network to join.*/
+ ExtPanId_t extendedPANId;
+ /** This parameter controls the method of joining the network. */
+ NWK_RejoinNetwork_t rejoinNetwork;
+ /** The 27 least significant bits (b0, b1,... b26) indicate which channels
+ * are to be scanned (1=scan, 0=do not scan) for each of the 27 valid channels.
+ **/
+ ChannelsMask_t scanChannels;
+ /** A value used to calculate the length of time to spend scanning each
+ * channel. The time spent scanning each channel is
+ * (aBaseSuperframeDuration * (2^n + 1)) symbols,
+ * where n is the value of the ScanDuration parameter. */
+ ScanDuration_t scanDuration;
+ /** The operating capabilities of the device being directly joined. */
+ /** This parameter should be set in NWK_ResetReq. */
+ /* MAC_CapabilityInf_t capabilityInformation; */
+ /** If the value of RejoinNetwork is 0x02 and this is TRUE than the device
+ * will try to rejoin securely. Otherwise, this is set to FALSE. */
+ bool securityEnable;
+ /** NLME-JOIN confirm callback function's pointer. */
+ void (*NWK_JoinConf)(NWK_JoinConf_t *conf);
+ NWK_JoinConf_t confirm;
+} NWK_JoinReq_t;
+
+/**//**
+ * \brief NLME-JOIN indication primitive's parameters structure declaration.
+ * Zigbee Specification r17, 3.2.2.12 NLME-JOIN.indication, page 283.
+ */
+typedef struct _NWK_JoinInd_t
+{
+ /** The network address of an entity that has been added to the network. */
+ ShortAddr_t networkAddress;
+ /** The 64-bit IEEE address of an entity that has been added to the network.*/
+ ExtAddr_t extendedAddress;
+ /** Specifies the operational capabilities of the joining device. */
+ MAC_CapabilityInf_t capabilityInformation;
+ /** The RejoinNetwork parameter indicating the method
+ * used to join the network. */
+ NWK_RejoinNetwork_t rejoinNetwork;
+ /** This parameter will be TRUE if the rejoin was performed in a secure manner.
+ * Otherwise, this parameter will be FALSE. */
+ bool secureJoin;
+ bool isRejoin;
+} NWK_JoinInd_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief NLME-JOIN request primitive's prototype.
+
+ \param[in] req - NLME-JOIN request parameters' structure pointer.
+ \return None.
+ ******************************************************************************/
+void NWK_JoinReq(NWK_JoinReq_t *const req);
+
+/**************************************************************************//**
+ \brief NLME-JOIN indication primitive's prototype.
+
+ \param[in] ind - NLME-JOIN indication parameters' structure pointer.
+ \return None.
+ ******************************************************************************/
+extern void NWK_JoinInd(NWK_JoinInd_t *ind);
+
+#endif /* _NLME_JOIN_H */
+/** eof nlmeJoin.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeLeave.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeLeave.h
new file mode 100644
index 00000000..071e9f0a
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeLeave.h
@@ -0,0 +1,105 @@
+/**************************************************************************//**
+ \file nlmeLeave.h
+
+ \brief NLME-LEAVE interface
+
+ \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-13 Max Gekk - Created.
+ Last change:
+ $Id: nlmeLeave.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NLME_LEAVE_H
+#define _NLME_LEAVE_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <appFramework.h>
+#include <nwkCommon.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/**//**
+ * \brief NLME-LEAVE confirm primitive's parameters structure declaration.
+ * ZigBee Specification r17, 3.2.2.18 NLME-LEAVE.confirm, page 291.
+ */
+typedef struct _NWK_LeaveConf_t
+{
+ /** The status of the corresponding request.*/
+ NWK_Status_t status;
+} NWK_LeaveConf_t;
+
+/**//**
+ * \brief NLME-LEAVE request primitive's parameters structure declaration.
+ * Zigbee Specification r17, 3.2.2.16 NLME-LEAVE.request, page 288.
+ */
+typedef struct _NWK_LeaveReq_t
+{
+ /** Service fields - for internal needs. */
+ struct
+ {
+ QueueElement_t qelem; /**< link used for queuing */
+ } service;
+ /** The 64-bit IEEE address of the entity to be removed from the network
+ * or NULL if the device removes itself from the network. */
+ ExtAddr_t deviceAddress;
+ /** This parameter has a value of TRUE if the device being asked to leave the
+ * network is also being asked to remove its child devices, if any. Otherwise,
+ * it has a value of FALSE. */
+ bool removeChildren;
+ /** This parameter has a value of TRUE if the device being asked to leave from
+ * the current parent is requested to rejoin the network.
+ * Otherwise, the parameter has a value of FALSE. */
+ bool rejoin;
+ /** NLME-LEAVE confirm callback function's pointer. */
+ void (*NWK_LeaveConf)(NWK_LeaveConf_t *conf);
+ NWK_LeaveConf_t confirm;
+} NWK_LeaveReq_t;
+
+/**//**
+ * \brief NLME-LEAVE indication primitive's parameters structure declaration.
+ * Zigbee Specification r17, 3.2.2.17 NLME-LEAVE.indication, page 290.
+ */
+ typedef struct _NWK_LeaveInd_t
+{
+ /** The 64-bit IEEE address of an entity that has removed itself from
+ * the network or NULL in the case that the device issuing the primitive has
+ * been removed from the network by its parent. */
+ ExtAddr_t deviceAddress;
+ /** This parameter has a value of TRUE if the device being asked to leave the
+ * current parent is requested to rejoin the network. Otherwise, this parameter
+ * has a value of FALSE. */
+ bool rejoin;
+} NWK_LeaveInd_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief NLME-LEAVE request primitive's prototype.
+
+ \param[in] req - NLME-LEAVE request parameters' structure pointer.
+ \return None.
+ ******************************************************************************/
+void NWK_LeaveReq(NWK_LeaveReq_t *const req);
+
+/**************************************************************************//**
+ \brief NLME-LEAVE indication primitive's prototype.
+
+ \param[in] ind - NLME-LEAVE indication parameters' structure pointer.
+ \return None.
+ ******************************************************************************/
+extern void NWK_LeaveInd(NWK_LeaveInd_t *ind);
+
+#endif /* _NLME_LEAVE_H */
+/** eof nlmeLeave.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeNetworkDiscovery.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeNetworkDiscovery.h
new file mode 100644
index 00000000..b8d45646
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeNetworkDiscovery.h
@@ -0,0 +1,122 @@
+/**************************************************************************//**
+ \file nlmeNetworkDiscovery.h
+
+ \brief NLME-NETWORK-DISCOVERY interface
+
+ \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-11 Max Gekk - Created
+ Last change:
+ $Id: nlmeNetworkDiscovery.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NLME_NETWORK_DISCOVERY_H
+#define _NLME_NETWORK_DISCOVERY_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <types.h>
+#include <mac.h>
+#include <nwkCommon.h>
+#include <appFramework.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/**//**
+ * \brief Network Descriptor Information Fields.
+ * */
+BEGIN_PACK
+typedef struct PACK _NWK_NetworkDescriptor_t
+{
+ /** The 64-bit PAN identifier of the network. */
+ ExtPanId_t extendedPANId;
+ /** The current logical channel occupied by the network. */
+ Channel_t logicalChannel;
+ /** A ZigBee stack profile identifier indicating the stack profile in use in
+ * the discovered network. */
+ StackProfile_t stackProfile;
+ /** The version of the ZigBee protocol in use in the discovered network. */
+ uint8_t zigBeeVersion;
+ /** This specifies how often the MAC sub-layer beacon is to be transmitted by
+ * a given device on the network. */
+ BeaconOrder_t beaconOrder;
+ /** For beacon-oriented networks, that is, beacon order < 15, this specifies
+ * the length of the active period of the superframe. */
+ BeaconOrder_t superframeOrder;
+ /** A value of '1' indicates that at least one ZigBee router on the network
+ * currently permits joining, i.e. its NWK has been issued an NLME-PERMIT-JOINING
+ * primitive and, the time limit if given, has not yet expired. */
+ bool permitJoining;
+ /** This value is set to '1' if the device s capable of accepting join
+ * requests from router-capable devices and set to '0' otherwise. */
+ bool routerCapacity;
+ /** This value is set to '1' if the device is capable of accepting join
+ * requests from end devices and set to '0' otherwise. */
+ bool endDeviceCapacity;
+} NWK_NetworkDescriptor_t;
+END_PACK
+
+/**//**
+ * \brief NLME-NETWORK-DISCOVERY confirm primitive's parameters structure.
+ * ZigBee Specification r17, 3.2.2.2, NLME-NETWORK-DISCOVERY.confirm
+ */
+typedef struct _NWK_NetworkDiscoveryConf_t
+{
+ /** The status of the request. Any status values returned with MLME-SCAN.confirm
+ * primitive or NWK_INVALID_REQUEST_STATUS, NWK_SUCCESS_STATUS. */
+ NWK_Status_t status;
+ /** The number of networks discovered by the search. */
+ uint8_t networkCount;
+ /** Size of networkDescriptors array. It must be initialized by user.
+ * Zero value is admissible. */
+ uint8_t maxNetworkDescr;
+ /** The array of descriptors, one for each of the networks discovered.
+ * It must be initialized by user. NULL pointer is admissible. */
+ NWK_NetworkDescriptor_t *networkDescriptors;
+} NWK_NetworkDiscoveryConf_t;
+
+/**//**
+ * \brief NLME-NETWORK-DISCOVERY request primitive's parameters structure.
+ * Zigbee Specification r17, 3.2.2.1 NLME-NETWORK-DISCOVERY.request.
+ */
+typedef struct _NWK_NetworkDiscoveryReq_t
+{
+ /** Service fields - for internal needs. */
+ struct
+ {
+ QueueElement_t qelem; /**< link used for queuing */
+ MAC_ScanReq_t macScan;
+ } service;
+ /** A value used to calculate the length of time to spend scanning each channel. */
+ ScanDuration_t scanDuration;
+ /** The mask of channels that must be scanned. */
+ ChannelsMask_t scanChannels;
+ /** NLME-NETWORK-DISCOVERY confirm callback function's pointer. */
+ void (*NWK_NetworkDiscoveryConf)(NWK_NetworkDiscoveryConf_t *conf);
+ NWK_NetworkDiscoveryConf_t confirm;
+ /** Field that allows to keep entries in neighbor table during network discovery request called from application */
+ bool clearNeighborTable;
+} NWK_NetworkDiscoveryReq_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief NLME-NETWORK-DISCOVERY request primitive's prototype.
+
+ \param[in] req - NLME-NETWORK-DISCOVERY request parameters' structure pointer.
+ \return None.
+ ******************************************************************************/
+void NWK_NetworkDiscoveryReq(NWK_NetworkDiscoveryReq_t *const req);
+
+#endif /* _NLME_NETWORK_DISCOVERY_H */
+/** eof nlmeNetworkDiscovery.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeNetworkFormation.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeNetworkFormation.h
new file mode 100644
index 00000000..88b6ed4c
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeNetworkFormation.h
@@ -0,0 +1,95 @@
+/**************************************************************************//**
+ \file nlmeNetworkFormation.h
+
+ \brief NLME-NETWORK-FORMATION interface
+
+ \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-11 Max Gekk - Created.
+ Last change:
+ $Id: nlmeNetworkFormation.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NLME_NETWORK_FORMATION_H
+#define _NLME_NETWORK_FORMATION_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <mac.h>
+#include <nwkCommon.h>
+#include <nlmeEdScan.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/**//**
+ * \brief NLME-NETWORK-FORMATION confirm primitive's parameters structure.
+ * ZigBee Specification r17, 3.2.2.3, NLME-NETWORK-FORMATION.confirm
+ */
+typedef struct _NWK_NetworkFormationConf_t
+{
+ /** The status of the request. */
+ NWK_Status_t status;
+} NWK_NetworkFormationConf_t;
+
+/**//**
+ * \brief NLME-NETWORK-FORMATION request primitive's parameters structure.
+ * Zigbee Specification r17, 3.2.2.3 NLME-NETWORK-FORMATION.request.
+ */
+typedef struct _NWK_NetworkFormationReq_t
+{
+ /** Service fields - for internal needs. */
+ struct
+ { /** Link to a next network formation request in queue. */
+ QueueElement_t qelem;
+ union
+ {
+ struct
+ {
+ MAC_ScanReq_t req;
+ PHY_EnergyLevel_t energyList[MAX_EDSCAN_CHANNEL_AMOUNT];
+ } scan;
+ MAC_SetReq_t setReq;
+ MAC_StartReq_t startReq;
+ MAC_RxEnableReq_t rxEnableReq;
+ } mac;
+ } service;
+ /** Channels are to be scanned in preparation for starting a network. */
+ ChannelsMask_t scanChannels;
+ /** The time spent scanning each channel is
+ * (aBaseSuperframeDuration * (2n + 1)) symbols,
+ * where n is the value of the ScanDuration parameter. */
+ ScanDuration_t scanDuration;
+ /** The beacon order of the network that the higher layers wish to form. */
+ /* NwkBeaconOrder_t beaconOrder; */
+ /* The superframe order of the network that the higher layers wish to form. */
+ /* NwkBeaconOrder_t superFrameOrder; */
+ /* Support battery life extension mode. This parameter is ignored if the
+ * BeaconOrder parameter has a value of 15. */
+ /* bool batteryLifeExtention; */
+ /** NLME-NETWORK-FORMATION confirm callback function's pointer. */
+ void (*NWK_NetworkFormationConf)(NWK_NetworkFormationConf_t *conf);
+ NWK_NetworkFormationConf_t confirm;
+} NWK_NetworkFormationReq_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief NLME-NETWORK-FORMATION request primitive's prototype.
+
+ \param[in] req - NLME-NETWORK-FORMATION request parameters' structure pointer.
+ \return None.
+ ******************************************************************************/
+void NWK_NetworkFormationReq(NWK_NetworkFormationReq_t *const req);
+
+#endif /* _NLME_NETWORK_FORMATION_H */
+/** eof nlmeNetworkFormation.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeNwkStatus.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeNwkStatus.h
new file mode 100644
index 00000000..3fa8cc37
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeNwkStatus.h
@@ -0,0 +1,122 @@
+/**************************************************************************//**
+ \file nlmeNwkStatus.h
+
+ \brief NLME-NWK-STATUS interface
+
+ \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-12 Max Gekk - Created.
+ Last change:
+ $Id: nlmeNwkStatus.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NLME_NWK_STATUS_H
+#define _NLME_NWK_STATUS_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <appFramework.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+
+/** Status Codes for network status command frame. */
+typedef enum _NWK_StatusIndErrorCodes_t
+{
+ /** Route discovery and/or repair has been attempted and no route to
+ * the intended destination address has been discovered. */
+ NWK_NO_ROUTE_AVAILABLE = 0x00,
+ /** The routing failure occurred as a result of the failure of an attempt
+ * to route the frame along the tree. */
+ NWK_TREE_LINK_FAILURE = 0x01,
+ /** The routing failure did not occur as a result of an attempt to route along
+ * the tree. */
+ NWK_NON_TREE_LINK_FAILURE = 0x02,
+ /** The frame was not relayed because the relaying device was running low
+ * on battery power. */
+ NWK_LOW_BATTERY_LEVEL = 0x03,
+ /** The failure occurred because the relaying device has no routing capacity.
+ **/
+ NWK_NO_ROUTING_CAPACITY = 0x04,
+ /** The failure occurred as the result of an attempt to buffer
+ * a frame for a sleeping end device child and the relaying device
+ * had no buffer capacity to use. */
+ NWK_NO_INDIRECT_CAPACITY = 0x05,
+ /** A frame that was buffered on behalf of a sleeping end device child has
+ * been dropped as a result of a time-out. */
+ NWK_INDIRECT_TRANSACTION_EXPIRY = 0x06,
+ /** An end device child of the relaying device is for some reason unavailable.
+ **/
+ NWK_TARGET_DEVICE_UNAVAILABLE = 0x07,
+ /** The frame was addressed to a non-existent end device
+ * child of the relaying device. */
+ NWK_TARGET_ADDRESS_UNALLOCATED = 0x08,
+ /** The failure occurred as a result of a failure in the RF link to
+ * the device's parent. This status is only used locally on a device
+ * to indicate loss of communication with the parent. */
+ NWK_PARENT_LINK_FAILURE = 0x09,
+ /** The multicast route identified in the destination address
+ * field should be validated. */
+ NWK_VALIDATE_ROUTE = 0x0A,
+ /** Source routing has failed, probably indicating a link failure in one of
+ * the source route's links. */
+ NWK_SOURCE_ROUTE_FAILURE = 0x0B,
+ /** A route established as a result of a many-to-one route request has failed.
+ **/
+ NWK_MANY_TO_ONE_ROUTE_FAILURE = 0x0C,
+ /** The address in the destination address field has been determined to be
+ * in use by two or more devices. */
+ NWK_ADDRESS_CONFLICT = 0x0D,
+ /** The source device has the IEEE address in the Source IEEE address field
+ * and, if the Destination IEEE address field is present, the value it
+ * contains is the expected IEEE address of the destination. */
+ NWK_VERIFY_ADDRESSES = 0x0E,
+ /** The operational network PAN identifier of the device has been updated. */
+ NWK_PAN_IDENTIFIER_UPDATE = 0x0F,
+ /** The network address of the device has been updated. */
+ NWK_NETWORK_ADDRESS_UPDATE = 0x10,
+ /** A frame counter reported in a received frame had a value less than or
+ * equal to that stored in nwkSecurityMaterialSet. */
+ NWK_BAD_FRAME_COUNTER = 0x11,
+ /** The key sequence number reported in a received frame did not match
+ * that of nwkActiveKeySeqNumber. */
+ NWK_BAD_KEY_SEQUENCE_NUMBER = 0x12,
+ NWK_PARENT_LINK_SUCCESS = 0x13,
+ NWK_BAD_LINK = 0x14,
+ NWK_STATIC_ADDRESS_CONFLICT = 0x15
+} NWK_StatusIndErrorCodes_t;
+
+/**//**
+ * \brief NLME-NWK-STATUS indication primitive's parameters structure.
+ * Zigbee Specification r17, 3.2.2.30 NLME-NWK-STATUS.indication, page 302.
+ */
+typedef struct _NWK_NwkStatusInd_t
+{
+ /** The 16-bit network address of the device
+ * associated with the status information. */
+ ShortAddr_t shortAddress;
+ /** The error code associated with the failure. */
+ NWK_StatusIndErrorCodes_t status;
+} NWK_NwkStatusInd_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief NLME-NWK-STATUS indication primitive's prototype.
+
+ \return None.
+ ******************************************************************************/
+extern void NWK_NwkStatusInd(NWK_NwkStatusInd_t *ind);
+
+#endif /* _NLME_NWK_STATUS_H */
+/** eof nlmeNwkStatus.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmePermitJoining.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmePermitJoining.h
new file mode 100644
index 00000000..7729f1d4
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmePermitJoining.h
@@ -0,0 +1,99 @@
+/**************************************************************************//**
+ \file nlmePermitJoining.h
+
+ \brief NLME-PERMIT-JOINING interface
+
+ \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-12 Max Gekk - Created.
+ Last change:
+ $Id: nlmePermitJoining.h 18296 2011-08-19 12:29:05Z mgekk $
+ ******************************************************************************/
+#if !defined _NLME_PERMIT_JOINING_H
+#define _NLME_PERMIT_JOINING_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <types.h>
+#include <nwkCommon.h>
+
+/******************************************************************************
+ Definitions section
+ ******************************************************************************/
+/** Permissions flags of network rejoin. */
+#define NWK_ALLOW_REJOIN 0U
+#define NWK_BAN_ED_REJOIN 1U /* End Devices can't rejoin to this device. */
+#define NWK_BAN_ROUTER_REJOIN 2U /* Routers can't rejoin to this device. */
+#define NWK_BAN_REJOIN \
+ ((NWK_RejoinPermit_t)(NWK_BAN_ED_REJOIN | NWK_BAN_ROUTER_REJOIN))
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/**//**
+ * \brief NLME-PERMIT-JOINING confirm primitive's parameters structure.
+ * ZigBee Specification r17, 3.2.2.6 NLME-PERMIT-JOINING.confirm, page 276.
+ */
+typedef struct _NWK_PermitJoiningConf_t
+{
+ /** The status of the corresponding request. Valid Range: NWK_SUCCESS_STATUS
+ * or any status returned from the MLME-SET.confirm primitive. */
+ NWK_Status_t status;
+} NWK_PermitJoiningConf_t;
+
+/**//**
+ * \brief NLME-PERMIT-JOINING request primitive's parameters structure.
+ * Zigbee Specification r17, 3.2.2.5 NLME-PERMIT-JOINING.request, page 274.
+ */
+typedef struct _NWK_PermitJoiningReq_t
+{
+ /** Service fields - for internal needs. */
+ struct
+ {
+ QueueElement_t qelem; /**< link used for queuing */
+ } service;
+ /** The length of time in seconds during which the ZigBee coordinator or
+ * router will allow associations. The value 0x00 and 0xff indicate that
+ * permission is disabled or enabled, respectively,
+ * without a specified time limit. */
+ uint8_t permitDuration;
+ /** NLME-PERMIT-JOINING confirm callback function's pointer. */
+ void (*NWK_PermitJoiningConf)(NWK_PermitJoiningConf_t *conf);
+ NWK_PermitJoiningConf_t confirm;
+} NWK_PermitJoiningReq_t;
+
+/** Type of rejoin permissions to the given devices. */
+typedef uint8_t NWK_RejoinPermit_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief NLME-PERMIT-JOINING request primitive's prototype.
+
+ \param[in] req - NLME-PERMIT-JOINING request parameters' structure pointer.
+ \return None.
+ ******************************************************************************/
+void NWK_PermitJoiningReq(NWK_PermitJoiningReq_t *const req);
+
+/**************************************************************************//**
+ \brief Enable or disable an end deivce or a router rejoin.
+
+ \param[in] permit - rejoin permissions, allow an end device rejoin only
+ if NWK_BAN_ED_REJOIN bit isn't set, and allow a router
+ rejoin only if NWK_BAN_ROUTER_REJOIN flag isn't set.
+ \return None.
+ ******************************************************************************/
+void NWK_SetRejoinPermit(const NWK_RejoinPermit_t permit);
+
+#endif /* _NLME_PERMIT_JOINING_H */
+/** eof nlmePermitJoining.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeReset.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeReset.h
new file mode 100644
index 00000000..2a1df8f6
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeReset.h
@@ -0,0 +1,124 @@
+/**************************************************************************//**
+ \file nlmeReset.h
+
+ \brief NLME-RESET interface.
+
+ \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-13 Max Gekk - Created.
+ Last change:
+ $Id: nlmeReset.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NLME_RESET_H
+#define _NLME_RESET_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkCommon.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/**//**
+ * \brief NLME-RESET confirm primitive's parameters structure declaration.
+ * ZigBee Specification r17, 3.2.2.20 NLME-RESET.confirm, page 293.
+ */
+typedef struct _NWK_ResetConf_t
+{
+ /** The result of the reset operation. */
+ NWK_Status_t status;
+} NWK_ResetConf_t;
+
+/**//**
+ * \brief Power failure status bitfield declaration.
+ */
+typedef struct _NWK_PowerFailureControl_t
+{
+ NwkBitField_t active : 1;
+ NwkBitField_t networkOperationsAccepted : 1;
+ NwkBitField_t reserved : 6;
+} NWK_PowerFailureControl_t;
+
+/**//**
+ * \brief NLME-RESET request primitive's parameters structure declaration.
+ * Zigbee Specification r17, 3.2.2.19 NLME-RESET.request, page 292.
+ */
+typedef struct _NWK_ResetReq_t
+{
+ /** Service fields - for internal needs. */
+ struct
+ {
+ QueueElement_t qelem; /**< link used for queuing */
+ } service;
+ /** To restore or not the saved parameters? */
+ NWK_PowerFailureControl_t powerFailureControl;
+ /** This field shall contain the device capability information.
+ * See ZigBee spec r18, Table 3.44, page 345. */
+ MAC_CapabilityInf_t capabilityInformation;
+ /** NLME-RESET confirm callback function's pointer. */
+ void (*NWK_ResetConf)(NWK_ResetConf_t *conf);
+ NWK_ResetConf_t confirm;
+} NWK_ResetReq_t;
+
+/******************************************************************************
+ Definitions section
+ ******************************************************************************/
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief NLME-RESET request primitive's prototype.
+
+ \param[in] req - NLME-RESET request parameters' structure pointer.
+ \return None.
+******************************************************************************/
+void NWK_ResetReq(NWK_ResetReq_t *const req);
+
+/**************************************************************************//**
+ \brief Check, if BitCloud was restored after power failure
+
+ \param[in] powerFailureControl - stack restoring after power failure control bitfield;
+ affects on initialization procedure.
+ \return True, if BitCloud was restored after power failure; false - otherwise
+******************************************************************************/
+INLINE bool NWK_StackRestoredAfterPowerFailure(NWK_PowerFailureControl_t powerFailureControl)
+{
+ return powerFailureControl.active && powerFailureControl.networkOperationsAccepted;
+}
+
+/**************************************************************************//**
+ \brief Retruns Power Failure control information default value.
+
+ \return Power Failure control default value.
+ ******************************************************************************/
+INLINE NWK_PowerFailureControl_t NWK_GetDefaultPowerFailureControl(void)
+{
+ NWK_PowerFailureControl_t powerFailureControl =
+ {
+ .active = 0U,
+ .networkOperationsAccepted = 0U,
+ .reserved = 0U
+ };
+
+ return powerFailureControl;
+}
+
+/**************************************************************************//**
+ \brief Gather Power Failure control information.
+
+ \return Power Failure control information.
+ ******************************************************************************/
+NWK_PowerFailureControl_t NWK_GatherPowerFailureInfo(void);
+
+#endif /* _NLME_RESET_H */
+/** eof nlmeReset.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeRouteDiscovery.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeRouteDiscovery.h
new file mode 100644
index 00000000..381dcb57
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeRouteDiscovery.h
@@ -0,0 +1,88 @@
+/**************************************************************************//**
+ \file nlmeRouteDiscovery.h
+
+ \brief NLME-ROUTE-DISCOVERY interface.
+
+ \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-13 Max Gekk - Created.
+ Last change:
+ $Id: nlmeRouteDiscovery.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NLME_ROUTE_DISCOVERY_H
+#define _NLME_ROUTE_DISCOVERY_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <appFramework.h>
+#include <nlmeNwkStatus.h>
+#include <nwkCommon.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/**//**
+ * \brief NLME-ROUTE-DISCOVERY confirm primitive's parameters structure.
+ * ZigBee Specification r17, 3.2.2.32 NLME-NETWORK-FORMATION.confirm, page 306.
+ */
+typedef struct _NWK_RouteDiscoveryConf_t
+{
+ /** The status of an attempt to initiate route discovery. */
+ NWK_Status_t status;
+ /** In the case where the Status parameter has a value of ROUTE_ERROR,
+ * this code gives further information about the kind of error that occurred.
+ * Otherwise, it should be ignored. ZigBee spec r17, Table 3.35. */
+ NWK_StatusIndErrorCodes_t networkStatusCode;
+ ShortAddr_t nextHop;
+} NWK_RouteDiscoveryConf_t;
+
+/**//**
+ * \brief NLME-ROUTE-DISCOVERY request primitive's parameters structure.
+ * Zigbee Specification r17, 3.2.2.31 NLME-ROUTE-DISCOVERY.request.
+ */
+typedef struct _NWK_RouteDiscoveryReq_t
+{
+ /** Service fields - for internal needs. */
+ struct
+ {
+ QueueElement_t qelem; /**< link used for queuing */
+ } service;
+ /** A parameter specifying the kind of destination address provided. */
+ NWK_DstAddrMode_t dstAddrMode;
+ /** The destination of the route discovery. */
+ ShortAddr_t dstAddr;
+ /** This optional parameter describes the number of hops that the route
+ * request will travel through the network. */
+ NwkRadius_t radius;
+ /** In the case where DstAddrMode has a value of zero, indicating many-to-one
+ * route discovery, this flag determines whether the NWK should establish
+ * a route record table. TRUE = no route record table should be established,
+ * FALSE = establish a route record table */
+ bool noRouteCache;
+ /** NLME-ROUTE-DISCOVERY confirm callback function's pointer. */
+ void (*NWK_RouteDiscoveryConf)(NWK_RouteDiscoveryConf_t *conf);
+ NWK_RouteDiscoveryConf_t confirm;
+} NWK_RouteDiscoveryReq_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief NLME-ROUTE-DISCOVERY request primitive's prototype.
+
+ \param[in] req - NLME-ROUTE-DISCOVERY request parameters' structure pointer.
+ \return None.
+ ******************************************************************************/
+void NWK_RouteDiscoveryReq(NWK_RouteDiscoveryReq_t *const req);
+
+#endif /* _NLME_ROUTE_DISCOVERY_H */
+/** eof nlmeRouteDiscovery.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeSetGet.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeSetGet.h
new file mode 100644
index 00000000..d6c37e9b
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeSetGet.h
@@ -0,0 +1,299 @@
+/**************************************************************************//**
+ \file nlmeSetGet.h
+
+ \brief NLME-SET and NLME-GET interface
+
+ \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-13 Max Gekk - Created.
+ Last change:
+ $Id: nlmeSetGet.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NLME_SET_GET_H
+#define _NLME_SET_GET_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <types.h>
+#include <appFramework.h>
+#include <nwkCommon.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Identifiers of network information base attributes. ZigBee spec r17,
+ * Table 3.44. */
+typedef enum _NWK_NibId_t
+{
+ /** This NIB attribute have the same value as macPANId. */
+ NWK_NIB_PANID_ID = 0x80,
+ /** A sequence number used to identify outgoing frames. */
+ NWK_NIB_SEQUENCE_NUMBER_ID = 0x81,
+ /** The maximum time duration in milliseconds allowed for the parent and
+ * all child devices to retransmit a broadcast message.
+ * Valid range: 0-0x2710. */
+ NWK_NIB_PASSIVE_ACK_TIMEOUT_ID = 0x82,
+ /** The maximum number of retries allowed after a broadcast transmission
+ * failure. Valid range: 0-5. */
+ NWK_NIB_MAX_BROADCAST_RETRIES_ID = 0x83,
+ /** The number of children a device is allowed to have on its current network.
+ **/
+ NWK_NIB_MAX_CHILDREN_ID = 0x84,
+ /** The depth a device can have. */
+ NWK_NIB_MAX_DEPTH_ID = 0x85,
+ /** The number of routers any one device is allowed to have as children. */
+ NWK_NIB_MAX_ROUTERS_ID = 0x86,
+ /** The current set of neighbor table entries in the device. */
+ NWK_NIB_NEIGHBOR_TABLE_ID = 0x87,
+ /** Time duration in seconds that a broadcast message needs to encompass
+ * the entire network. */
+ NWK_NIB_NETWORK_BROADCAST_DELIVERY_TIME_ID = 0x88,
+ /** If this is set to 0, the NWK layer shall calculate link cost from
+ * all neighbor nodes using the LQI values reported by the MAC layer;
+ * otherwise, it shall report a constant value. */
+ NWK_NIB_REPORT_CONSTANT_COST_ID = 0x89,
+ /** The number of retries allowed after an unsuccessful route request. */
+ NWK_NIB_ROUTE_DISCOVERY_RETRIES_PERMITTED_ID = 0x8A,
+ /** The current set of routing table entries in the device. */
+ NWK_NIB_ROUTE_TABLE_ID = 0x8B,
+ /** A flag that determines if a time stamp indication is provided on incoming
+ * and outgoing packets.
+ * '1' - time indication provided.
+ * '0' - no time indication provided. */
+ NWK_NIB_TIME_STAMP_ID = 0x8C,
+ /** The current route symmetry setting. 'true' 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. 'false' indicates that
+ * routes are not consider to be comprised of symmetric links. Only the forward
+ * route is stored during route discovery. */
+ NWK_NIB_SYM_LINK_ID = 0x8E,
+ /** This field shall contain the device capability information established at
+ * network joining time. */
+ NWK_NIB_CAPABILITY_INFORMATION_ID = 0x8F,
+ /** A value that determines the method used to assign addresses:
+ * - 0x00 = use distributed address allocation
+ * - 0x01 = reserved
+ * - 0x02 = use stochastic address allocation. */
+ NWK_NIB_ADDR_ALLOC_ID = 0x90,
+ /** A flag that determines whether the NWK layer should assume the ability
+ * to use hierarchical routing:
+ * - true = assume the ability to use hierarchical routing.
+ * - false = never use hierarchical routing. */
+ NWK_NIB_USE_TREE_ROUTING_ID = 0x91,
+ /** The address of the designated network channel manager function. */
+ NWK_NIB_MANAGER_ADDR_ID = 0x92,
+ /** The maximum number of hops in a source route. */
+ NWK_NIB_MAX_SOURCE_ROUTE_ID = 0x93,
+ /** The value identifying a snapshot of the network settings with
+ * which this node is operating with. */
+ NWK_NIB_UPDATE_ID = 0x94,
+ /** The maximum time (in superframe periods) that a transaction is stored by a
+ * coordinator and indicated in its beacon. */
+ NWK_NIB_TRANSACTION_PERSISTENCE_TIME_ID = 0x95,
+ /** The 16-bit address that the device uses to communicate with the PAN. */
+ NWK_NIB_NETWORK_ADDRESS_ID = 0x96,
+ /** The identifier of the ZigBee stack profile in use for this device. */
+ NWK_NIB_STACK_PROFILE_ID = 0x97,
+ /** The current set of broadcast transaction table entries in the device. */
+ NWK_NIB_BROADCAST_TRANSACTION_TABLE_ID = 0x98,
+ /** The Extended PAN Identifier for the PAN of which the device is a member.
+ * The value 0x0000000000000000 means the Extended PAN Identifier is unknown.
+ **/
+ NWK_NIB_EXTENDED_PANID_ID = 0x9A,
+ /** A flag determining the layer where multicast messaging occurs.
+ * - true = multicast occurs at the network layer.
+ * - false = multicast occurs at the APS layer and using the APS header.*/
+ NWK_NIB_USE_MULTICAST_ID = 0x9B,
+ /** The route record table. */
+ NWK_NIB_ROUTE_RECORD_TABLE_ID = 0x9C,
+ /** A flag determining if this device is a concentrator.
+ * - true = Device is a concentrator.
+ * - false = Device is not a concentrator.*/
+ NWK_NIB_IS_CONCENTRATOR_ID = 0x9D,
+ /** The hop count radius for concentrator route discoveries. */
+ NWK_NIB_CONCENTRATOR_RADIUS_ID = 0x9E,
+ /** The time in seconds between concentrator route discoveries.
+ * If set to 0x0000, the discoveries are done at start up and
+ * by the next higher layer only. */
+ NWK_NIB_CONCENTRATOR_DISCOVERY_TIME_ID = 0x9F,
+ /** The security level for outgoing and incoming NWK frames. */
+ NWK_NIB_SECURITY_LEVEL_ID = 0xA0,
+ /** Set of network security material descriptors capable of maintaining
+ * an active and alternate network key. */
+ NWK_NIB_SECURITY_MATERIAL_SET_ID = 0xA1,
+ /** The sequence number of the active network key in nwkSecurityMaterialSet.
+ **/
+ NWK_NIB_ACTIVE_KEY_SEQ_NUMBER_ID = 0xA2,
+ /** Indicates whether incoming NWK frames must be all checked for freshness
+ * when the memory for incoming frame counts is exceeded. */
+ NWK_NIB_ALL_FRESH_ID = 0xA3,
+ /** Indicates whether security shall be applied to incoming and outgoing NWK
+ * data frames.If set to 0x01, security processing shall be applied to all
+ * incoming and outgoing frames except data frames destined for the current
+ * device that have the security sub-field of the frame control field
+ * set to 0. If this attribute has a value of 0x01, the NWK layer shall not
+ * relay frames that have the security sub-field of the frame control field
+ * set to 0. The SecurityEnable parameter of the NLDE-DATA.request primitive
+ * shall override the setting of this attribute. */
+ NWK_NIB_SECURE_ALL_FRAMES_ID = 0xA5,
+ /** The time in seconds between link status command frames. */
+ NWK_NIB_LINK_STATUS_PERIOD_ID = 0xA6,
+ /** The number of missed link status command frames before resetting the link
+ * costs to zero. */
+ NWK_NIB_ROUTER_AGE_LIMIT_ID = 0xA7,
+ /** Use static addressing or not. */
+ NWK_NIB_UNIQUE_ADDR_ID = 0xA8,
+ /** The current set of 64-bit IEEE to 16-bit network address map. */
+ NWK_NIB_ADDRESS_MAP_ID = 0xA9,
+ /** Extra nib attributes. */
+ NWK_NIB_INT_LOGICAL_CHANNEL_ID = 0xF0,
+ NWK_NIB_INT_PARENT_SHORT_ID = 0xF1,
+ NWK_NIB_INT_TRANSMIT_COUNTER_ID = 0xF2,
+ NWK_NIB_INT_TRANSMIT_FAILURE_COUNTER_ID = 0xF3,
+ NWK_NIB_INT_DEPTH_ID = 0xF4,
+ NWK_NIB_INT_SECURITY_IB_ID = 0xF5,
+ NWK_NIB_INT_EXTENDED_ADDRESS_ID = 0xF6,
+ NWK_NIB_MAX_NEIGHBOR_ROUTE_COST_ID = 0xF7,
+ NWK_NIB_PREDEFINED_PANID_ID = 0xF8
+} NWK_NibId_t;
+
+/** NWK NIB attribute type. */
+typedef union _NWK_NibAttr_t
+{
+ PanId_t panId;
+ NwkSequenceNumber_t sequenceNumber;
+ uint16_t passiveAckTimeout;
+ uint8_t maxBroadcastRetries;
+ NwkChildCount_t maxChildren;
+ NwkDepth_t maxDepth;
+ NwkChildCount_t maxRouters;
+ void *neighborTable;
+ uint32_t networkBroadcastDeliveryTime;
+ uint8_t reportConstantCost;
+ uint8_t routeDiscoveryRetriesPermitted;
+ void *routeTable;
+ bool symLink;
+ MAC_CapabilityInf_t capabilityInformation;
+ uint8_t addrAlloc;
+ bool useTreeRouting;
+ ShortAddr_t managerAddr;
+ uint8_t maxSourceRoute;
+ NwkUpdateId_t updateId;
+ uint16_t transactionPersistenceTime;
+ ShortAddr_t networkAddress;
+ uint8_t stackProfile;
+ void *broadcastTransactionTable;
+ void *groupIDTable;
+ ExtPanId_t extendedPANID;
+ bool useMulticast;
+ void *routeRecordTable;
+ bool isConcentrator;
+ NwkRadius_t concentratorRadius;
+ uint8_t concentratorDiscoveryTime;
+ uint8_t linkStatusPeriod;
+ uint8_t routerAgeLimit;
+ bool uniqueAddr;
+ void *addressMap;
+ bool timeStamp;
+ uint16_t txTotal;
+ Channel_t logicalChannel;
+ ShortAddr_t parentShortAddr;
+ uint16_t transmitCounter;
+ uint16_t transmitFailureCounter;
+ NwkDepth_t depth;
+ void *securityIB;
+ ExtAddr_t extAddr;
+} NWK_NibAttr_t;
+
+/**//**
+ * \brief NLME-SET confirm primitive's parameters structure declaration.
+ * ZigBee Specification r17, 3.2.2.29 NLME-GET.confirm, page 301.
+ */
+typedef struct _NWK_SetConf_t
+{
+ /** The result of the request to write the NIB attribute. */
+ NWK_Status_t status;
+ /** The identifier of the NIB attribute that was written. */
+ NWK_NibId_t attrId;
+} NWK_SetConf_t;
+
+typedef struct _NWK_SetReq_t
+{
+ /** Service fields - for internal needs. */
+ struct
+ {
+ QueueElement_t qelem; /**< link used for queuing */
+ };
+ /** The identifier of the NIB attribute to write. */
+ NWK_NibId_t attrId;
+ /** The value to write to the indicated NIB attribute. */
+ NWK_NibAttr_t attrValue;
+ /** NLME-SET confirm callback function's pointer. */
+ void (*NWK_SetConf)(NWK_SetConf_t *conf);
+ /** NLME-SET confirm parameters' structure. */
+ NWK_SetConf_t confirm;
+} NWK_SetReq_t;
+
+/**//**
+ * \brief NLME-GET confirm primitive's parameters structure declaration.
+ * ZigBee Specification r17, 3.2.2.27 NLME-GET.confirm, page 299.
+ */
+typedef struct _NWK_GetConf_t
+{
+ /** The results of the request to read a NIB attribute value. */
+ NWK_Status_t status;
+ /** The identifier of the NIB attribute that was read. */
+ NWK_NibId_t attrId;
+ /** The value of the indicated NIB attribute that was read. */
+ NWK_NibAttr_t attrValue;
+} NWK_GetConf_t;
+
+/**//**
+ * \brief NLME-GET request primitive's parameters structure declaration.
+ * Zigbee Specification r17, 3.2.2.26 NLME-SYNC.request, page 298.
+ */
+typedef struct _NWK_GetReq_t
+{
+ /** Service fields - for internal needs. */
+ struct
+ {
+ QueueElement_t qelem; /**< link used for queuing */
+ } service;
+ /** The identifier of the PIB attribute to read. */
+ NWK_NibId_t attrId;
+ /** NLME-GET confirm callback function's pointer. */
+ void (*NWK_GetConf)(NWK_GetConf_t *conf);
+ /** NLME-GET confirm parameters' structure. */
+ NWK_GetConf_t confirm;
+} NWK_GetReq_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief NLME-SET request primitive's prototype.
+
+ \param[in] req - NLME-SET request parameters' structure pointer.
+ \return None.
+ ******************************************************************************/
+void NWK_SetReq(NWK_SetReq_t *const req);
+
+/**************************************************************************//**
+ \brief NLME-GET request primitive's prototype.
+
+ \param[in] req - NLME-GET request parameters' structure pointer.
+ \return None.
+ ******************************************************************************/
+void NWK_GetReq(NWK_GetReq_t *const req);
+
+#endif /* _NLME_SET_GET_H */
+/** eof nlmeSetGet.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeStartRouter.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeStartRouter.h
new file mode 100644
index 00000000..d4de3afe
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeStartRouter.h
@@ -0,0 +1,81 @@
+/**************************************************************************//**
+ \file nlmeStartRouter.h
+
+ \brief NLME-START-ROUTER interface
+
+ \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-11 Max Gekk - Created.
+ Last change:
+ $Id: nlmeStartRouter.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NLME_START_ROUTER_H
+#define _NLME_START_ROUTER_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <mac.h>
+#include <nwkCommon.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/**//**
+ * \brief NLME-START-ROUTER confirm primitive's parameters structure declaration.
+ * ZigBee Specification r17, 3.2.2.7 NLME-START-ROUTER.confirm
+ */
+typedef struct _NWK_StartRouterConf_t
+{
+ /** The result of the attempt to initialize a ZigBee router.
+ * Valid range: NWK_INVALID_REQUEST_STATUS or any status value returned from
+ * the MAC_StartConf callback.*/
+ NWK_Status_t status;
+} NWK_StartRouterConf_t;
+
+/**//**
+ * \brief NLME-START-ROUTER request primitive's parameters structure declaration.
+ * Zigbee Specification r17, 3.2.2.8 NLME-START-ROUTER.request.
+ */
+typedef struct _NWK_StartRouterReq_t
+{
+ /** Service fields - for internal needs. */
+ struct
+ {
+ QueueElement_t qelem; /**< link used for queuing */
+ MAC_StartReq_t macStart;
+ } service;
+ /** The beacon order of the network that the higher layers wish to form. */
+ /* NwkBeaconOrder_t beaconOrder; */
+ /* The superframe order of the network that the higher layers wish to form. */
+ /* NwkBeaconOrder_t superFrameOrder; */
+ /* Supporting battery life extension mode. This parameter is ignored if the
+ * BeaconOrder parameter has a value of 15. */
+ /* bool batteryLifeExtention; */
+ /* NLME-START-ROUTER confirm callback function's pointer. */
+ void (*NWK_StartRouterConf)(NWK_StartRouterConf_t *conf);
+ /** NLME-START-ROUTER confirm primitive's parameters */
+ NWK_StartRouterConf_t confirm;
+} NWK_StartRouterReq_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief NLME-START-ROUTER request primitive's prototype.
+
+ \param[in] req - NLME-START-ROUTER request parameters' structure pointer.
+ \return None.
+ ******************************************************************************/
+void NWK_StartRouterReq(NWK_StartRouterReq_t *const req);
+
+#endif /* _NLME_START_ROUTER_H */
+/** eof nlmeStartRouter.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeSync.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeSync.h
new file mode 100644
index 00000000..b01eb4f2
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeSync.h
@@ -0,0 +1,79 @@
+/**************************************************************************//**
+ \file nlmeSync.h
+
+ \brief NLME-SYNC interface
+
+ \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-12 Max Gekk - Created.
+ Last change:
+ $Id: nlmeSync.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NLME_SYNC_H
+#define _NLME_SYNC_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkCommon.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/**//**
+ * \brief NLME-SYNC confirm primitive's parameters structure declaration.
+ * ZigBee Specification r17, 3.2.2.24 NLME-SYNC.confirm, page 296.
+ */
+typedef struct _NWK_SyncConf_t
+{
+ /** The result of the request to synchronize with the ZigBee coordinator or
+ * router. Valid Range: NWK_SUCCESS_STATUS, NWK_INVALID_PARAMETER_STATUS,
+ * or any status value returned from the MLME_POLL.confirm primitive. */
+ NWK_Status_t status;
+} NWK_SyncConf_t;
+
+/**//**
+ * \brief NLME-SYNC request primitive's parameters structure declaration.
+ * Zigbee Specification r17, 3.2.2.22 NLME-SYNC.request, page 294.
+ */
+typedef struct _NWK_SyncReq_t
+{
+ /** Service fields - for internal needs. */
+ struct
+ {
+ QueueElement_t qelem; /**< link used for queuing */
+ } service;
+ /** Whether or not the synchronization should be maintained for future beacons.
+ **/
+ bool track;
+ /** NLME-SYNC confirm callback function's pointer. */
+ void (*NWK_SyncConf)(NWK_SyncConf_t *conf);
+ NWK_SyncConf_t confirm;
+} NWK_SyncReq_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief NLME-SYNC request primitive's prototype.
+
+ The function sends a data request to the parent polling for buffered data. The confirmation callback is raised with NWK_SUCCESS_STATUS, if the
+ request has been executed successfully and a response from the parents has been received. If the current node's parent is storing data frames
+ for the child, then after sending response to the polling request it starts sending the data. When the child receives the data the standard callback
+ idicating data frame reception is executed.
+
+ \param[in] req - NLME-SYNC request parameters' structure pointer.
+ \return None.
+ ******************************************************************************/
+void NWK_SyncReq(NWK_SyncReq_t *const req);
+
+#endif /* _NLME_SYNC_H */
+/** eof nlmeSync.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeSyncLoss.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeSyncLoss.h
new file mode 100644
index 00000000..7e8d4353
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeSyncLoss.h
@@ -0,0 +1,34 @@
+/**************************************************************************//**
+ \file nlmeSyncLoss.h
+
+ \brief NLME-SYNC-LOSS interface
+
+ \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-12 Max Gekk - Created.
+ Last change:
+ $Id: nlmeSyncLoss.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NLME_SYNC_LOSS_H
+#define _NLME_SYNC_LOSS_H
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief NLME-SYNC-LOSS indication primitive's prototype.
+
+ \return None.
+ ******************************************************************************/
+extern void NWK_SyncLossInd(void);
+
+#endif /* _NLME_SYNC_LOSS_H */
+/** eof nlmeSyncLoss.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nwk.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nwk.h
new file mode 100644
index 00000000..94f82a6c
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nwk.h
@@ -0,0 +1,87 @@
+/**************************************************************************//**
+ \file nwk.h
+
+ \brief Interface of NWK layer.
+
+ \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-13 Max Gekk - Created.
+ Last change:
+ $Id: nwk.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_H
+#define _NWK_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkCommon.h>
+
+#include <nldeData.h>
+#include <nlmeDirectJoin.h>
+#include <nlmeEdScan.h>
+#include <nlmeJoin.h>
+#include <nlmeLeave.h>
+#include <nlmeNetworkDiscovery.h>
+#include <nlmeNetworkFormation.h>
+#include <nlmeNwkStatus.h>
+#include <nlmePermitJoining.h>
+#include <nlmeReset.h>
+#include <nlmeRouteDiscovery.h>
+#include <nlmeStartRouter.h>
+#include <nlmeSync.h>
+#include <nlmeSyncLoss.h>
+
+/** Extra network headers */
+#include <nwkAttributes.h>
+#include <nwkSecurity.h>
+#include <nwkAddressResolv.h>
+#include <nwkNeighbor.h>
+#include <nwkRouteInfo.h>
+#include <nwkGroup.h>
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief NWK_Init shall be called only by APS and only once at startup.
+
+ \return None.
+ ******************************************************************************/
+void NWK_Init(void);
+
+/**************************************************************************//**
+ \brief The stack don't sleep if this function return 'true'.
+
+ \return 'true' if the network layer if active otherwise 'false'.
+ ******************************************************************************/
+bool NWK_IsActiveTransaction(void);
+
+/**************************************************************************//**
+ \brief NWK layer activities launching
+ ******************************************************************************/
+void NWK_LaunchActivities(void);
+
+/**************************************************************************//**
+ \brief NWK layer activities stopping
+ ******************************************************************************/
+void NWK_StopActivities(void);
+
+/**************************************************************************//**
+ \brief Determine if node has all the parameters required to operate in network.
+
+ \return True, if node has all the parameters required to operate in network;
+ false - otherwise.
+ ******************************************************************************/
+bool NWK_DeviceIsAbleToOperateInNetwork(void);
+
+#endif /* _NWK_H */
+/** eof nwk.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkAddressResolv.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkAddressResolv.h
new file mode 100644
index 00000000..a89e439d
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkAddressResolv.h
@@ -0,0 +1,67 @@
+/**************************************************************************//**
+ \file nwkAddressResolv.h
+
+ \brief Interface of address resolution.
+
+ \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: nwkAddressResolv.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_ADDRESS_RESOLV_H
+#define _NWK_ADDRESS_RESOLV_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <appFramework.h>
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Link short network and IEEE extended address.
+
+ \param[in] shortAddr - a short address.
+ \param[in] extAddr - an extended address.
+ \return 'true' if short and extended addresses are linked successfully
+ otherwise 'false'.
+ ******************************************************************************/
+bool NWK_LinkShortAndExtAddress(const ShortAddr_t shortAddr,
+ const ExtAddr_t extAddr);
+
+/**************************************************************************//**
+ \brief Remove the entry with given address from the address map.
+
+ \param[in] extAddr - pointer to a extended address.
+ \return None.
+ ******************************************************************************/
+void NWK_RemoveFromAddressMap(const ExtAddr_t *const extAddr);
+
+/**************************************************************************//**
+ \brief Searching a extended address by the short address.
+
+ \param[in] shortAddr - a short address.
+ \return Pointer to the extended address in the address map.
+ ******************************************************************************/
+const ExtAddr_t* NWK_GetExtByShortAddress(const ShortAddr_t shortAddr);
+
+/**************************************************************************//**
+ \brief Searching a short address by the extended address.
+
+ \param[in] extAddr - pointer to the extended address.
+ \return Pointer to the short address in the address map.
+ ******************************************************************************/
+const ShortAddr_t* NWK_GetShortByExtAddress(const ExtAddr_t *const extAddr);
+
+#endif /* _NWK_ADDRESS_RESOLV_H */
+/** eof nwkAddressResolv.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkAttributes.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkAttributes.h
new file mode 100644
index 00000000..1dad0c46
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkAttributes.h
@@ -0,0 +1,196 @@
+/**************************************************************************//**
+ \file nwkAttributes.h
+
+ \brief Interface of network attributes.
+
+ \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 Max Gekk - Created
+ Last change:
+ $Id: nwkAttributes.h 18225 2011-08-12 14:02:16Z mgekk $
+ ******************************************************************************/
+#if !defined _NWK_ATTRIBUTES_H
+#define _NWK_ATTRIBUTES_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <types.h>
+#include <appFramework.h>
+#include <nwkCommon.h>
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief This function return a short address that is allocated by parent.
+
+ \return Short address of this node or NWK_NO_SHORT_ADDR.
+ ******************************************************************************/
+ShortAddr_t NWK_GetShortAddr(void);
+
+/**************************************************************************//**
+ \brief Setting new short address of this device.
+
+ \param[in] shortAddr - new short (16-bit) address.
+ \param[in] silent - report (false) or not (true) to upper-layer.
+
+ \return NWK_SUCCESS_STATUS - if this request is valid
+ otherwise NWK_NOT_PERMITTED_STATUS.
+ ******************************************************************************/
+NWK_Status_t NWK_SetShortAddr(const ShortAddr_t shortAddr, const bool silent);
+
+/**************************************************************************//**
+ \brief This function return a short address of parent.
+
+ \return Short address of parent device or NWK_NO_SHORT_ADDR
+ ******************************************************************************/
+ShortAddr_t NWK_GetParentShortAddr(void);
+
+/**************************************************************************//**
+ \brief This function return a short panid of network.
+
+ \return short panid or 0xFFFF
+ ******************************************************************************/
+PanId_t NWK_GetPanId(void);
+
+/**************************************************************************//**
+ \brief This function return a extended panid of network.
+
+ \return extended panid or 0
+ ******************************************************************************/
+ExtPanId_t NWK_GetExtPanId(void);
+
+/**************************************************************************//**
+ \brief Set a NWK extended PAN ID parameter value.
+
+ \param[in] extPanId - pointer to new NWK extended PAN ID parameter value.
+ \return None.
+ ******************************************************************************/
+void NWK_SetExtPanId(const ExtPanId_t *extPanId);
+
+/**************************************************************************//**
+ \brief Current RF channel.
+ ******************************************************************************/
+Channel_t NWK_GetLogicalChannel(void);
+
+/**************************************************************************//**
+ \brief Setting a new RF channel.
+
+ \param[in] channel - the number of new channel.
+ ******************************************************************************/
+void NWK_SetLogicalChannel(const Channel_t channel);
+
+/**************************************************************************//**
+ \brief Maximum delivery time of broadcasting transmission on a network.
+
+ Distination nodes of broadcasting transmission are only full function devices.
+
+ \return Current value of broadcast delivery time in milliseconds.
+ ******************************************************************************/
+uint32_t NWK_GetBroadcastDeliveryTime(void);
+
+/**************************************************************************//**
+ \brief Medium delivery time of unicast packet to a sleep end device.
+
+ \return Current value of unicast delivery time in milliseconds.
+ ******************************************************************************/
+uint32_t NWK_GetUnicastDeliveryTime(void);
+
+/**************************************************************************//**
+ \brief Set a short address of the network manager.
+
+ \param[in] - short address of the network manager.
+ ******************************************************************************/
+void NWK_SetManagerAddr(const ShortAddr_t shortAddr);
+
+/**************************************************************************//**
+ \brief Getting network address of channel manager.
+
+ \return Network manager address.
+ ******************************************************************************/
+ShortAddr_t NWK_GetManagerAddr(void);
+
+/**************************************************************************//**
+ \brief Set an id of network snapshot.
+
+ \param[in] - new value of the update identifier.
+ ******************************************************************************/
+void NWK_SetUpdateId(const NwkUpdateId_t updateId);
+
+/**************************************************************************//**
+ \brief Getting an id of network snapshot.
+
+ \return Network snapshot id
+ ******************************************************************************/
+NwkUpdateId_t NWK_GetUpdateId(void);
+
+/**************************************************************************//**
+ \brief Sets symmetric link attribute value.
+
+ \param[in] symLink - new symmetric link attribute value.
+ \return None.
+ ******************************************************************************/
+void NWK_SetSymLink(const bool symLink);
+
+/**************************************************************************//**
+ \brief Changing the route fail order.
+
+ After 2^order failure attempts a route entry will be deleted.
+
+ \param[in] order - new order of route fail.
+ \return NWK_SUCCESS_STATUS if order is valid
+ otherwise NWK_INVALID_PARAMETER_STATUS.
+ ******************************************************************************/
+NWK_Status_t NWK_SetFailRouteOrder(const uint8_t order);
+
+/**************************************************************************//**
+ \brief Gets attribute value which specifies if static addressing mode is in use
+
+ \return True, if static addressing mode is in use; false - otherwise
+ ******************************************************************************/
+bool NWK_IsStaticAddressingMode(void);
+
+/**************************************************************************//**
+ \brief Gets protocol version attribute value.
+
+ \return Protocol version attribute value.
+ ******************************************************************************/
+uint8_t NWK_GetProtocolVersion(void);
+
+/**************************************************************************//**
+ \brief Getting the total number of transmissions
+
+ \return Value of total number of transmissions
+ ******************************************************************************/
+uint16_t NWK_GetTransmitCouner(void);
+
+/**************************************************************************//**
+ \brief Getting the transmission failures counter.
+
+ \return Value of transmission failures counter
+ ******************************************************************************/
+uint16_t NWK_GetTransmitFailureCounter(void);
+
+/**************************************************************************//**
+ \brief Resets the transmission failures counter and the total tx counter.
+ ******************************************************************************/
+void NWK_ResetTransmitCounters(void);
+
+/**************************************************************************//**
+ \brief Getting a device type parameter value.
+
+ \return device type parameter value.
+ ******************************************************************************/
+DeviceType_t NWK_GetDeviceType(void);
+
+#endif /* _NWK_ATTRIBUTES_H */
+/** eof nwkAttributes.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkCommon.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkCommon.h
new file mode 100644
index 00000000..e17fd64b
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkCommon.h
@@ -0,0 +1,353 @@
+/**************************************************************************//**
+ \file nwkCommon.h
+
+ \brief Declarations of common NWK layer constants and types.
+
+ \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-13 Max Gekk - Created.
+ Last change:
+ $Id: nwkCommon.h 17470 2011-06-10 11:31:00Z mgekk $
+ ******************************************************************************/
+#if !defined _NWK_COMMON_H
+#define _NWK_COMMON_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <types.h>
+#include <queue.h>
+
+/******************************************************************************
+ Definitions section
+ ******************************************************************************/
+/** Base NWK header length of data packet:
+ * - frame control field (2 octets),
+ * - destination address (2 octets),
+ * - source address (2 octets),
+ * - radius (1 octet),
+ * - sequence number (1 octet),
+ * - multicast control field (1 octet). */
+#define NWK_DATA_FRAME_HEADER_LENGTH 9U
+/** Length of auxiliary frame header. See ZigBee spec r18, Figure 4.3. */
+#if defined _SECURITY_
+ #define NWK_AUXILIARY_HEADER_SIZE 14U
+ #define NWK_MAX_DATA_FRAME_FOOTER_LENGTH 4U
+#else
+ #define NWK_AUXILIARY_HEADER_SIZE 0U
+ #define NWK_MAX_DATA_FRAME_FOOTER_LENGTH 0U
+#endif /* _SECURITY_ */
+
+/** The hop count radius for concentrator route discoveries.
+ * ZigBee spec r18, Table 3.44, page 348. */
+#define NWK_CONCENTRATOR_RADIUS 8U /* hop */
+/** The maximum number of hops in a source route. ZigBee spec r18, Table 3.44.
+ **/
+#define NWK_MAX_SOURCE_ROUTE (NWK_CONCENTRATOR_RADIUS)
+/** Maximum length of the source route subframe:
+ * - relay count field (1 octet),
+ * - relay index field (1 octet),
+ * - relay list (NWK_MAX_SOURCE_ROUTE * size of short address).
+ * See ZigBee spec r18, 3.3.1.9, page 316. */
+#if defined _NWK_SOURCE_ROUTING_
+ #define NWK_MAX_SOURCE_ROUTE_SUBFRAME_LENGTH (2U+(2U*NWK_MAX_SOURCE_ROUTE))
+#else
+ #define NWK_MAX_SOURCE_ROUTE_SUBFRAME_LENGTH 0U
+#endif /* _NWK_SOURCE_ROUTING_ */
+
+/** Maximum lenght of NWK header. */
+#define NWK_MAX_UNSECURE_HEADER_LEHGTH \
+ (NWK_DATA_FRAME_HEADER_LENGTH + NWK_MAX_SOURCE_ROUTE_SUBFRAME_LENGTH)
+#define NWK_MAX_DATA_FRAME_HEADER_LEHGTH \
+ (NWK_MAX_UNSECURE_HEADER_LEHGTH + NWK_AUXILIARY_HEADER_SIZE)
+
+/** Length of the reserved part in the data frame. */
+#define NWK_AFFIX_LENGTH (MAC_AFFIX_LENGTH + \
+ NWK_MAX_DATA_FRAME_HEADER_LEHGTH + NWK_MAX_DATA_FRAME_FOOTER_LENGTH)
+
+/** Length of the reserved header in the data frame. */
+#define NWK_NSDU_OFFSET (MAC_MSDU_OFFSET + NWK_MAX_DATA_FRAME_HEADER_LEHGTH)
+
+/** Maximum lenght of NWK payload. */
+#define NWK_MAX_NSDU_SIZE (MAC_MAX_MSDU_SIZE \
+ - NWK_MAX_DATA_FRAME_HEADER_LEHGTH - NWK_MAX_DATA_FRAME_FOOTER_LENGTH)
+
+/** Valid broadcast addresses. See ZigBee spec r18, Table 3.54, page 411. */
+#define IS_BROADCAST_ADDR(A) (LE16_TO_CPU(A) >= 0xFFF8U)
+#define IS_CORRECT_SHORT_ADDR(A) (LE16_TO_CPU(A) < 0xFFF8U)
+
+/** Low power routers only. */
+#define LOW_POWER_ROUT_ADDR CCPU_TO_LE16(0xFFFBU)
+#define BROADCAST_ADDR_LOWPOWER_ROUTERS LOW_POWER_ROUT_ADDR
+
+/** All routers and coordinator in a network. */
+#define ALL_ROUT_AND_COORD_ADDR CCPU_TO_LE16(0xFFFCU)
+#define BROADCAST_ADDR_ROUTERS ALL_ROUT_AND_COORD_ADDR
+
+/** All devices with MAC attribute macRxOnWhenIdle = TRUE. */
+#define RX_ON_WHEN_IDLE_ADDR CCPU_TO_LE16(0xFFFDU)
+#define BROADCAST_ADDR_RX_ON_WHEN_IDLE RX_ON_WHEN_IDLE_ADDR
+
+/** All devices in PAN. */
+#define ALL_DEVICES_IN_PAN_ADDR 0xFFFFU
+#define BROADCAST_ADDR_ALL ALL_DEVICES_IN_PAN_ADDR
+
+/** The value of the nwkNetworkAddress attribute of its NIB has
+ * a value of 0xffff indicating that it is not currently joined to a network. */
+#define NWK_NO_SHORT_ADDR 0xFFFFU
+
+/** The maximum broadcast jitter time measured in number of octets.
+ * ZigBee spec r18, Table 3.43. */
+#define NWKC_MAX_BROADCAST_JITTER 2000U /*<! ~0x40 milliseconds in 2.4GHz */
+
+/* Maximum radius for non-member mode multicast frame. */
+#define NWK_MAX_NON_MEMBER_MULTICAST_RADIUS 7U
+
+/** The value of the extendedPanId attribute in NIB has
+ * a value of 0x0000000000000000 indicating that the device is not (or wasn't)
+ * currently joined to a network. */
+#define NWK_NO_EXT_PANID 0ULL
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** NWK primitives' return codes. ZigBee spec r17, 3.7, page 417. */
+typedef enum _NWK_Status
+{
+ /** A request has been executed successfully. */
+ NWK_SUCCESS_STATUS = 0x00,
+ /** The MAC requested operation was completed successfully. */
+ NWK_MAC_SUCCESS_STATUS = 0x00,
+ /** IEEE 802.15.4-2006, Table 83.
+ * Valid values of the Association Status field. */
+ NWK_MAC_PAN_AT_CAPACITY_STATUS = 0x01,
+ NWK_MAC_PAN_ACCESS_DENIED_STATUS = 0x02,
+ /** An invalid or out-of-range parameter has been passed to a primitive from
+ * the next higher layer. */
+ NWK_INVALID_PARAMETERS_STATUS = 0xC1,
+ /** The next higher layer has issued a request that is invalid or cannot be
+ * executed given the current state of the NWK layer. */
+ NWK_INVALID_REQUEST_STATUS = 0xC2,
+ /** An NLME-JOIN.request has been disallowed. */
+ NWK_NOT_PERMITTED_STATUS = 0xC3,
+ /** An NLME-NETWORK-FORMATION.request has failed to start a network. */
+ NWK_STARTUP_FAILURE_STATUS = 0xC4,
+ /** A device with the address supplied to the NLMEDIRECT-JOIN.request is
+ * already present in the neighbor table of the device on which
+ * the NLME-DIRECT-JOIN.request was issued. */
+ NWK_ALREADY_PRESENT_STATUS = 0xC5,
+ /** Used to indicate that an NLME-SYNC.request has failed at the MAC layer. */
+ NWK_SYNC_FAILURE_STATUS = 0xC6,
+ /** An NLME-JOIN-DIRECTLY.request has failed because there is no more room in
+ * the neighbor table. */
+ NWK_NEIGHBOR_TABLE_FULL_STATUS = 0xC7,
+ /** An NLME-LEAVE.request has failed because the device addressed in
+ * the parameter list is not in the neighbor table of the issuing device. */
+ NWK_UNKNOWN_DEVICE_STATUS = 0xC8,
+ /** An NLME-GET.request or NLME-SET.request has been issued with
+ * an unknown attribute identifier. */
+ NWK_UNSUPPORTED_ATTRIBUTE_STATUS = 0xC9,
+ /** An NLME-JOIN.request has been issued in an environment
+ * where no networks are detectable. */
+ NWK_NO_NETWORKS_STATUS = 0xCA,
+ /** Security processing has been attempted on an outgoing frame,
+ * and has failed because the frame counter has reached its maximum value. */
+ NWK_MAX_FRM_COUNTER_STATUS = 0xCC,
+ /** Security processing has been attempted on an outgoing frame,
+ * and has failed because no key was available with which to process it. */
+ NWK_NO_KEY_STATUS = 0xCD,
+ /** Security processing has been attempted on an outgoing frame,
+ * and has failed because the security engine produced erroneous output. */
+ NWK_BAD_CCM_OUTPUT_STATUS = 0xCE,
+ /** An attempt to discover a route has failed due to a lack of routing table
+ * or discovery table capacity. */
+ NWK_NO_ROUTING_CAPACITY_STATUS = 0xCF,
+ /** An attempt to discover a route has failed due to a reason other
+ * than a lack of routing capacity. */
+ NWK_ROUTE_DISCOVERY_FAILED_STATUS = 0xD0,
+ /** An NLDE-DATA.request has failed due to a routing
+ * failure on the sending device. */
+ NWK_ROUTE_ERROR_STATUS = 0xD1,
+ /** An attempt to send a broadcast frame or member mode multicast has failed
+ * due to the fact that there is no room in the BTT. */
+ NWK_BT_TABLE_FULL_STATUS = 0xD2,
+ /** An NLDE-DATA.request has failed due to insufficient buffering available.
+ **/
+ NWK_FRAME_NOT_BUFFERED_STATUS = 0xD3,
+ /** IEEE 802.15.4-2006, Table 78 MAC enumerations description. */
+ /** The frame counter purportedly applied by the originator of the
+ * received frame is invalid. */
+ NWK_MAC_COUNTER_ERROR_STATUS = 0xDB,
+ /** The key purportedly applied by the originator of the received frame is
+ * not allowed to be used with that frame type according to the key usage
+ * policy of the recipient. */
+ NWK_MAC_IMPROPER_KEY_TYPE_STATUS = 0xDC,
+ /** The security level purportedly applied by the originator of the received
+ * frame does not meet the minimum security level required/expected by
+ * the recipient for that frame type. */
+ NWK_MAC_IMPROPER_SECURITY_LEVEL_STATUS = 0xDD,
+ /** The received frame was purportedly secured using security based on
+ * IEEE Std 802.15.4-2003, and such security is not supported by this standard.
+ **/
+ NWK_MAC_UNSUPPORTED_LEGACY_STATUS = 0xDE,
+ /** The security purportedly applied by the originator of the received frame
+ * is not supported. */
+ NWK_MAC_UNSUPPORTED_SECURITY_STATUS = 0xDF,
+ /** The beacon was lost following a synchronization request. */
+ NWK_MAC_BEACON_LOSS_STATUS = 0xE0,
+ /** A transmission could not take place due to activity on the channel,
+ * i.e., the CSMA-CA mechanism has failed. */
+ NWK_MAC_CHANNEL_ACCESS_FAILURE_STATUS = 0xE1,
+ /** The GTS request has been denied by the PAN coordinator. */
+ NWK_MAC_DENIED_STATUS = 0xE2,
+ /** The attempt to disable the transceiver has failed. */
+ NWK_MAC_DISABLE_TRX_FAILURE_STATUS = 0xE3,
+ /** Either a frame resulting from processing has a length that is
+ * greater than aMaxPHYPacketSize or a requested transaction is
+ * too large to fit in the CAP or GTS. */
+ NWK_MAC_FRAME_TOO_LONG_STATUS = 0xE5,
+ /** The requested GTS transmission failed because the specified
+ * GTS either did not have a transmit GTS direction or was not defined. */
+ NWK_MAC_INVALID_GTS_STATUS = 0xE6,
+ /** A request to purge an MSDU from the transaction queue was made using
+ * an MSDU handle that was not found in the transaction table. */
+ NWK_MAC_INVALID_HANDLE_STATUS = 0xE7,
+ /** A parameter in the primitive is either not supported or is out of
+ * the valid range. */
+ NWK_MAC_INVALID_PARAMETER_STATUS = 0xE8,
+ /** No acknowledgment was received after macMaxFrameRetries. */
+ NWK_MAC_NO_ACK_STATUS = 0xE9,
+ /** A scan operation failed to find any network beacons. */
+ NWK_MAC_NO_BEACON_STATUS = 0xEA,
+ /** No response data were available following a request. */
+ NWK_MAC_NO_DATA_STATUS = 0xEB,
+ /** The operation failed because a 16-bit short address was not allocated. */
+ NWK_MAC_NO_SHORT_ADDRESS_STATUS = 0xEC,
+ /** A receiver enable request was unsuccessful because it could not be
+ * completed within the CAP. */
+ NWK_MAC_OUT_OF_CAP_STATUS = 0xED,
+ /** A PAN identifier conflict has been detected and communicated
+ * to the PAN coordinator. */
+ NWK_MAC_PAN_ID_CONFLICT_STATUS = 0xEE,
+ /** A coordinator realignment command has been received. */
+ NWK_MAC_REALIGNMENT_STATUS = 0xEF,
+ /** The transaction has expired and its information was discarded. */
+ NWK_MAC_TRANSACTION_EXPIRED_STATUS = 0xF0,
+ /** There is no capacity to store the transaction. */
+ NWK_MAC_TRANSACTION_OVERFLOW_STATUS = 0xF1,
+ /** The transceiver was in the transmitter enabled state when the receiver
+ * was requested to be enabled. */
+ NWK_MAC_TX_ACTIVE_STATUS = 0xF2,
+ /** The key purportedly used by the originator of the received frame is
+ * not available or, if available, the originating device is not known
+ * or is blacklisted with that particular key. */
+ NWK_MAC_UNAVAILABLE_KEY_STATUS = 0xF3,
+ /** A SET/GET request was issued with the identifier of a PIB
+ * attribute that is not supported. */
+ NWK_MAC_UNSUPPORTED_ATTRIBUTE_STATUS = 0xF4,
+ /** A request to send data was unsuccessful because neither the source address
+ * parameters nor the destination address parameters were present. */
+ NWK_MAC_INVALID_ADDRESS_STATUS = 0xF5,
+ /** A receiver enable request was unsuccessful because it specified a number
+ * of symbols that was longer than the beacon interval. */
+ NWK_MAC_ON_TIME_TOO_LONG_STATUS = 0xF6,
+ /** A receiver enable request was unsuccessful because it could not be
+ * completed within the current superframe and was not permitted to be
+ * deferred until the next superframe. */
+ NWK_MAC_PAST_TIME_STATUS = 0xF7,
+ /** The device was instructed to start sending beacons based on the
+ * timing of the beacon transmissions of its coordinator, but the device
+ * is not currently tracking the beacon of its coordinator. */
+ NWK_MAC_TRACKING_OFF_STATUS = 0xF8,
+ /** An attempt to write to a MAC PIB attribute that is in a table failed
+ * because the specified table index was out of range. */
+ NWK_MAC_INVALID_INDEX_STATUS = 0xF9,
+ /** There are some unscanned channels yet, but there is no memory */
+ NWK_MAC_LIMIT_REACHED_STATUS = 0xFA,
+ /** A SET/GET request was issued with the identifier of an attribute
+ * that is read only. */
+ NWK_MAC_READ_ONLY_STATUS = 0xFB,
+ /** A request to perform a scan operation failed because the MLME was
+ * in the process of performing a previously initiated scan operation. */
+ NWK_MAC_SCAN_IN_PROGRESS_STATUS = 0xFC,
+ /** The device was instructed to start sending beacons based on the timing of
+ * the beacon transmissions of its coordinator, but the instructed start time
+ * overlapped the transmission time of the beacon of its coordinator. */
+ NWK_MAC_SUPERFRAME_OVERLAP_STATUS = 0xFD
+} NWK_Status_t;
+
+/** Type of the 64-bit PAN identifier of the network.*/
+typedef uint64_t ExtPanId_t;
+
+/** Type of channels mask. */
+typedef uint32_t ChannelsMask_t;
+
+/** Type of MAC channel number. */
+typedef uint8_t Channel_t;
+
+/** Type of update identifier. The value identifying a snapshot of the network
+ * settings with which this node is operating with.*/
+typedef uint8_t NwkUpdateId_t;
+
+/** Type of sequence number of NWK packets. */
+typedef uint8_t NwkSequenceNumber_t;
+
+typedef uint8_t BeaconOrder_t;
+typedef BeaconOrder_t ScanDuration_t;
+
+/** Type of link quality indicator. */
+typedef uint8_t Lqi_t;
+/** Type of received signal strength indication. */
+typedef int8_t Rssi_t;
+
+/** Type of link cost. */
+typedef uint8_t NwkLinkCost_t;
+/** Type of route path cost. */
+typedef uint8_t NwkPathCost_t;
+
+/** Length of any NWK data: header, payload and etc. */
+typedef uint8_t NwkLength_t;
+
+/** Type of children counters. */
+typedef uint8_t NwkChildCount_t;
+
+typedef uint8_t NwkDepth_t;
+typedef NwkDepth_t NwkRadius_t;
+
+/** The kind of destination address*/
+typedef enum _NWK_DstAddrMode_t
+{
+ NWK_DSTADDRMODE_NOADDR = 0, /**< No destination address. */
+ /** 16-bit network address of a multicast group. */
+ NWK_DSTADDRMODE_MULTICAST = 1,
+ /** 16-bit network address of an individual device or a broadcast address. */
+ NWK_DSTADDRMODE_SHORT = 2
+} NWK_DstAddrMode_t;
+
+/** The method used to assign addresses. */
+typedef enum _NWK_AddrAlloc_t
+{
+ NWK_ADDR_ALLOC_DISTRIBUTED = 0, /**< Use distributed address allocation. */
+ NWK_ADDR_ALLOC_RESERVED = 1,
+ NWK_ADDR_ALLOC_STOCHASTIC = 2, /**< Use stochastic address allocation. */
+ NWK_ADDR_ALLOC_FROM_UID = 3 /**< Use 2 octet from IEEE extended address. */
+} NWK_AddrAlloc_t;
+
+/** Type of initial route request identifier. */
+typedef uint8_t NwkRouteRequestId_t;
+
+/** Global state of the network layer. */
+typedef uint8_t NwkState_t;
+
+typedef BitField_t NwkBitField_t;
+
+#endif /* _NWK_COMMON_H */
+/** eof nwkCommon.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkConfigServer.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkConfigServer.h
new file mode 100644
index 00000000..3a2f70c4
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkConfigServer.h
@@ -0,0 +1,47 @@
+/**************************************************************************//**
+ \file nwkConfigServer.h
+
+ \brief The data types necessary for building of the ConfigServer.
+
+ \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-13 Max Gekk - Created.
+ Last change:
+ $Id: nwkConfigServer.h 18049 2011-07-20 13:08:36Z mgekk $
+ ******************************************************************************/
+#if !defined _NWK_CONFIG_SERVER_H
+#define _NWK_CONFIG_SERVER_H
+
+/******************************************************************************
+ Definitions section
+ ******************************************************************************/
+#ifndef NWK_PRIVATE
+ #define NWK_PRIVATE
+#endif /* #ifndef NWK_PRIVATE */
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkTx.h>
+#include <nwkPacket.h>
+#include <nwkJoinInd.h>
+#include <nwkRoutingTable.h>
+#include <nwkRouteDiscoveryTable.h>
+#include <nwkRouteDiscovery.h>
+#include <nwkAddressMap.h>
+#include <nwkBTT.h>
+#include <nwkRouteCache.h>
+#include <nwkGroup.h>
+#include <nwkIB.h>
+#include <nwkPassiveAck.h>
+
+#endif /* _NWK_CONFIG_SERVER_H */
+/** eof nwkConfigServer.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkGroup.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkGroup.h
new file mode 100644
index 00000000..160d1ca8
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkGroup.h
@@ -0,0 +1,144 @@
+/**************************************************************************//**
+ \file nwkGroup.h
+
+ \brief Interface of the group 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-07-20 Max Gekk - Created.
+ Last change:
+ $Id: nwkGroup.h 18320 2011-08-23 14:02:26Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_GROUP_H
+#define _NWK_GROUP_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <appFramework.h>
+#include <nlmeReset.h>
+
+/******************************************************************************
+ Definitions section
+ ******************************************************************************/
+/** Value that can not be used as a group data parameter. */
+#define NWK_INVALID_GROUP_DATA 0x00U
+/** Universal group data. It means any group data value. */
+#define NWK_ANY_GROUP_DATA 0xFFU
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Type of data linked to group. */
+typedef uint8_t NWK_GroupData_t;
+/** Type of group address. */
+typedef GroupAddr_t NWK_GroupAddr_t;
+
+/** Type of group table entry. */
+typedef struct _NWK_GroupTableEntry_t
+{
+ /** The data used by user, for example APS end point. */
+ NWK_GroupData_t data;
+ /** Address of group. */
+ NWK_GroupAddr_t addr;
+} NWK_GroupTableEntry_t;
+
+/** Type of size of the group table.*/
+typedef uint8_t NWK_GroupTableSize_t;
+
+/** Type of internal variables of group component. */
+typedef struct _NWK_GroupTable_t
+{
+ /** Pointer to first entry of the group table. */
+ NWK_GroupTableEntry_t *begin;
+ /** Pointer to memory after last entry of the group table. */
+ NWK_GroupTableEntry_t *end;
+} NWK_GroupTable_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined _GROUP_TABLE_
+/**************************************************************************//**
+ \brief Add new entry to the group table.
+
+ \param[in] addr - address of group. Valid range 0x0000 - 0xffff.
+ \param[in] data - value linked to group. Valid range 0x01 - 0xfe.
+
+ \return 'true' if entry is added successfully otherwise 'false'.
+ ******************************************************************************/
+bool NWK_AddGroup(const NWK_GroupAddr_t addr, const NWK_GroupData_t data);
+
+/**************************************************************************//**
+ \brief Remove group entries from the group table.
+
+ \param[in] addr - address of group. Valid range 0x0000 - 0xffff.
+ \param[in] data - value linked to group. Valid range 0x01 - 0xff.
+ If data is equal to NWK_ANY_GROUP_DATA then remove
+ all entries with given group address.
+
+ \return 'true' if any entry is removed successfully otherwise 'false'.
+ ******************************************************************************/
+bool NWK_RemoveGroup(const NWK_GroupAddr_t addr, const NWK_GroupData_t data);
+
+/**************************************************************************//**
+ \brief Remove all group entries with given group data
+
+ \param[in] data - value linked to group. Valid range 0x01 - 0xff.
+ If data is equal to NWK_ANY_GROUP_DATA then remove
+ all entries from table.
+
+ \return 'true' if any entry is removed successfully otherwise 'false'.
+ ******************************************************************************/
+bool NWK_RemoveAllGroups(const NWK_GroupData_t data);
+
+/**************************************************************************//**
+ \brief Check group address and data in the group table.
+
+ \param[in] addr - address of group. Valid range 0x0000 - 0xffff.
+ \param[in] data - value linked to group. Valid range 0x01 - 0xff.
+ If data is equal to NWK_ANY_GROUP_DATA that means
+ any enties with given group address.
+
+ \return 'true' if pair addr and data is found in the group table
+ otherwise 'false'.
+ ******************************************************************************/
+bool NWK_IsGroupMember(const NWK_GroupAddr_t addr, const NWK_GroupData_t data);
+
+/**************************************************************************//**
+ \brief Get remaining groups capacity.
+
+ \return number of free entries in the group table.
+ ******************************************************************************/
+NWK_GroupTableSize_t NWK_GroupCapacity(void);
+
+/**************************************************************************//**
+ \brief Get first or next non-free entry from the groups table.
+
+ \param[in] entry - address of the current entry or NULL to get the first entry.
+
+ \return pointer to the next non-free entry or NULL if no more entries exist.
+ ******************************************************************************/
+NWK_GroupTableEntry_t* NWK_NextGroup(NWK_GroupTableEntry_t *entry);
+
+/**************************************************************************//**
+ \brief Allocate and initialize the group table.
+
+ \param[in] powerFailureControl - stack restoring after power failure control bitfield;
+ affects on initialization procedure.
+ ******************************************************************************/
+void NWK_ResetGroups(const NWK_PowerFailureControl_t powerFailureControl);
+
+#else
+#define NWK_ResetGroups(powerFailureControl) (void)0
+#endif /* _GROUP_TABLE_ */
+#endif /* _NWK_GROUP_H */
+/** eof nwkGroup.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkNeighbor.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkNeighbor.h
new file mode 100644
index 00000000..f30822c0
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkNeighbor.h
@@ -0,0 +1,241 @@
+/**************************************************************************//**
+ \file nwkNeighbor.h
+
+ \brief Neighbor table interface.
+
+ \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-14 Max Gekk - Created.
+ Last change:
+ $Id: nwkNeighbor.h 19021 2011-10-26 12:36:59Z mgekk $
+ ******************************************************************************/
+/**//**
+ * The neighbor table of a device shall contain information on every device
+ * within transmission range. ZigBee Spec r17, 3.6.1.5, page 366.
+ **/
+#if !defined _NWK_NEIGHBOR_H
+#define _NWK_NEIGHBOR_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <appFramework.h>
+#include <appTimer.h>
+#include <nwkCommon.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** The relationship between the neighbor and the current device */
+typedef enum _Relationship_t
+{
+ RELATIONSHIP_PARENT = 0x00, /**< neighbor is the parent */
+ RELATIONSHIP_CHILD = 0x01, /**< neighbor is a child */
+ RELATIONSHIP_SIBLING = 0x02, /**< neighbor is a sibling */
+ RELATIONSHIP_NONE_OF_ABOVE = 0x03, /**< none of the above */
+ RELATIONSHIP_PREVIOUS_CHILD = 0x04, /**< previous child */
+ RELATIONSHIP_UNAUTHENTICATED_CHILD = 0x05, /**< unauthenticated child */
+ RELATIONSHIP_EMPTY
+} Relationship_t;
+
+/** The neighbor table item. */
+typedef struct _NwkNeighbor_t
+{
+ Relationship_t relationship;
+ /** The type of neighbor device. */
+ DeviceType_t deviceType;
+ /** IEEE 802.15.4-2006 7.3.1.2 Capability Information field. */
+ MAC_CapabilityInf_t capability;
+ /** The logical channel on which the network is operating. */
+ Channel_t logicalChannel;
+ /** The 16-bit network address of the neighboring device. */
+ ShortAddr_t networkAddr;
+ PanId_t panId;
+ /** 64-bit IEEE address that is unique to every device. */
+ ExtAddr_t extAddr;
+ /** The 64-bit unique identifier of the network to which the device belongs.*/
+ ExtPanId_t extPanId;
+ /** The tree depth of the neighbor device. */
+ NwkDepth_t depth;
+ /** The value identifying a snapshot of the network settings with which this
+ * node is operating with.*/
+ NwkUpdateId_t updateId;
+ /** Indicates if neighbor's receiver is enabled during idle periods. */
+ bool rxOnWhenIdle :1;
+ /** An indication of whether the device is accepting joining requests. */
+ bool permitJoining :1;
+ /** An indication of whether the device has been
+ * ruled out as a potential parent. */
+ bool potentialParent :1;
+ /** Network address of the neighbor is conflict with other address in network.
+ **/
+ bool isAddressConflict :1;
+ /** Upper layer knowns about this child (true) or not (false).*/
+ bool isKnownChild :1;
+ unsigned reserved1 :3;
+} NwkNeighbor_t;
+
+/** Type of life time of neighbors in ticks. */
+typedef uint16_t NwkLifeTime_t;
+/** The bit map of passive acks, each bit is matched to a broadcast that
+ * waits passive acknowledgements. */
+typedef uint8_t NwkPassiveAckMap_t;
+
+/** Mutable fields of a entry in the neighbor table. */
+typedef struct _NwkMutablePartOfNeighbor_t
+{
+ /** The time of life of a neighbor entry. */
+ NwkLifeTime_t lifeTime;
+ /** The estimated link quality for RF transmissions from this device. */
+ Lqi_t lqi;
+ Rssi_t rssi;
+ /** The cost of an outgoing link as measured by the neighbor. */
+ unsigned outgoingCost :3;
+ /** The cost of an incoming link as measured by this device. */
+ unsigned incomingCost :3;
+ /** Does the lqi field (and incomingCost) have a valid value. */
+ unsigned isLqiUnInit :1;
+ unsigned reserved1 :1;
+#if defined _NWK_PASSIVE_ACK_
+ NwkPassiveAckMap_t passiveAckMap;
+#endif /* _NWK_PASSIVE_ACK_ */
+} NwkMutablePartOfNeighbor_t;
+
+/** Type of size of the neighbor table. */
+typedef uint8_t NwkSizeOfNeighborTable_t;
+
+/** Type of the neighbor table. */
+typedef struct _NwkNeighborTable_t
+{
+ /** The array of a neighbor entry. */
+ NwkNeighbor_t *table;
+ /** Pointer to memory area after last entry of the neighbor table. */
+ NwkNeighbor_t *end;
+ /** The array of a mutable neighbor entry. */
+ NwkMutablePartOfNeighbor_t *mutableTable;
+ /** Current size of the neighbor table. */
+ NwkSizeOfNeighborTable_t size;
+#if defined _ROUTER_ || defined _COORDINATOR_
+ /** Timer for internal use. */
+ HAL_AppTimer_t ageTimer;
+#endif /* _ROUTER_ or _COORDINATOR_ */
+} NwkNeighborTable_t;
+
+/** For backward compatibility */
+typedef NwkNeighbor_t Neib_t;
+typedef NwkMutablePartOfNeighbor_t MutableNeib_t;
+typedef NwkNeighborTable_t NeibTable_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Access function to the neighbor table.
+
+ \return Pointer to the neighbor table.
+ ******************************************************************************/
+NwkNeighborTable_t* NWK_GetNeighborTable(void);
+
+/**************************************************************************//**
+ \brief Searching a neighbor entry by extended address.
+
+ \param[in] extAddr - extended IEEE address of neighbor.
+ \return NULL if no records found, or entry with extAddr otherwise
+ ******************************************************************************/
+NwkNeighbor_t* NWK_FindNeighborByExtAddr(const ExtAddr_t extAddr);
+
+/**************************************************************************//**
+ \brief Searching a neighbor entry by short address.
+
+ \param[in] shortAddr - network address of neighbor.
+ \return NULL if no records found, or entry with shortAddr otherwise
+ ******************************************************************************/
+NwkNeighbor_t* NWK_FindNeighborByShortAddr(const ShortAddr_t shortAddr);
+
+/**************************************************************************//**
+ \brief Remove a neighbor from the neighbor table with leave indication.
+
+ \param[in] neighbor - pointer to a entry in the neighbor table.
+ \param[in] cleanAddressMap - Remove records from address map if existed.
+ \return None.
+ ******************************************************************************/
+void NWK_RemoveNeighbor(NwkNeighbor_t *const neighbor, bool cleanAddressMap);
+
+/**************************************************************************//**
+ \brief Link quality indication for given neighbor.
+
+ \param[in] neighbor - pointer to a entry of neighbor in the neighbor table.
+ \return LQI of received frames from a neighbor
+ ******************************************************************************/
+Lqi_t NWK_GetNeighborsLqi(NwkNeighbor_t const *const neighbor);
+
+/**************************************************************************//**
+ \brief RSSI for given neighbor.
+
+ \param[in] neighbor - pointer to a entry of neighbor in the neighbor table.
+ \return RSSI of received frames from a neighbor
+ ******************************************************************************/
+Rssi_t NWK_GetNeighborsRssi(NwkNeighbor_t const *const neighbor);
+
+/**************************************************************************//**
+ \brief Is given neighbor known child.
+
+ \param[in] extAddr - extended address of child.
+ \param[in] setKnownFlag - change the known flag to 'true' if this parameter
+ is equal 'true'.
+
+ \return Current value of known flag.
+ ******************************************************************************/
+bool NWK_IsKnownChild(const ExtAddr_t extAddr, const bool setKnownFlag);
+
+/**************************************************************************//**
+ \brief Is given neighbor is child.
+
+ \param[in] neighbor - pointer to a entry of neighbor in the neighbor table.
+
+ \return True, given neighbor is child.; otherwise - false.
+ ******************************************************************************/
+INLINE bool NWK_IsChild(Neib_t const *const neighbor)
+{
+ return (RELATIONSHIP_CHILD == neighbor->relationship)
+ || (RELATIONSHIP_UNAUTHENTICATED_CHILD == neighbor->relationship);
+}
+
+/**************************************************************************//**
+ \brief Is given neighbor is unauthenticated child.
+
+ \param[in] neighbor - pointer to a entry of neighbor in the neighbor table.
+
+ \return True, given neighbor is unauthenticated child.; otherwise - false.
+ ******************************************************************************/
+INLINE bool NWK_IsUnauthenticatedChild(Neib_t const *const neighbor)
+{
+ return (RELATIONSHIP_UNAUTHENTICATED_CHILD == neighbor->relationship);
+}
+
+/**************************************************************************//**
+ \brief Authenticate a child node.
+
+ \param[in] extAddr - pointer to the extended address of child.
+ \return None.
+ ******************************************************************************/
+bool NWK_AuthenticateNeighbor(const ExtAddr_t *const extAddr);
+
+/*****************************************************************************
+ \brief This function adds neighbor table record for a known neighbor.
+
+ \param[in] nwkAddress - neighbor network address.
+ \return None.
+ *****************************************************************************/
+void NWK_AddKnownNeighbor(const ShortAddr_t nwkAddress);
+
+#endif /* _NWK_NEIGHBOR_H */
+/** eof nwkNeighbor.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkProfiler.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkProfiler.h
new file mode 100644
index 00000000..b1e40a96
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkProfiler.h
@@ -0,0 +1,68 @@
+/**************************************************************************//**
+ \file nwkProfiler.h
+
+ \brief Interface of NWK Profiler.
+
+ \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-10-29 Max Gekk - Created
+ Last change:
+ $Id: nwkProfiler.h 18049 2011-07-20 13:08:36Z mgekk $
+ ******************************************************************************/
+#if !defined _NWK_PROFILER_H
+#define _NWK_PROFILER_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <types.h>
+
+#if defined _PROFILER_
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/* NWK Profiling information. */
+BEGIN_PACK
+typedef struct PACK _NWK_ProfilingInfo_t
+{
+ /** Maximum number of simultaneous join transaction. */
+ uint8_t maxJoinTrans;
+ /** Current number of processing join requests. */
+ uint8_t incomingJoinReq;
+ /** Current number of pending buffer for join response command. */
+ uint8_t pendingJoinRespBuffers;
+ /** Total NWK buffers. */
+ uint8_t nwkBuffersAmount;
+ /** Current number of busy output command buffers. */
+ uint8_t outCmdBuffers;
+ /** Total number of passive acks. */
+ uint8_t passiveAckAmount;
+ /** Used passive acks amount. */
+ uint8_t usedPassiveAcks;
+} NWK_ProfilingInfo_t;
+END_PACK
+
+/******************************************************************************
+ Global variables section
+ ******************************************************************************/
+extern NWK_ProfilingInfo_t nwkProfilingInfo;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Collect profiling information and update nwkProfInfo.
+ ******************************************************************************/
+void NWK_CollectProfilingInfo(void);
+
+#endif /* _PROFILER_ */
+#endif /* _NWK_PROFILER_H */
+/** eof nwkProfiler.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkRouteInfo.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkRouteInfo.h
new file mode 100644
index 00000000..679d393d
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkRouteInfo.h
@@ -0,0 +1,124 @@
+/**************************************************************************//**
+ \file nwkRouteInfo.h
+
+ \brief Public route information.
+
+ \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-07 Max Gekk - Created.
+ Last change:
+ $Id: nwkRouteInfo.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_ROUTE_INFO_H
+#define _NWK_ROUTE_INFO_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <appFramework.h>
+
+/******************************************************************************
+ Definitions section
+ ******************************************************************************/
+/* Invalid concentrator descriptor. */
+#define NWK_INVALID_CONCENTRATOR (UINT8_MAX)
+/* Macro return true if concentrator descriptor is valid. */
+#define IS_VALID_CONCENTRATOR(descr) (NWK_INVALID_CONCENTRATOR != (descr))
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/* Type of concentrator descriptor. */
+typedef uint8_t NWK_Concentrator_t;
+
+/* Type of concentrator indication structure. */
+typedef struct _NWK_ConcentratorInd_t
+{
+ /** Service fields - for internal needs. */
+ struct
+ {
+ QueueElement_t qelem; /**< link used for queuing */
+ } service;
+ /* This function is called when new concentrator is found. */
+ void (* NWK_ConcentratorInd)(NWK_Concentrator_t concentrator);
+} NWK_ConcentratorInd_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief This function return the 16-bit network address of the next hop on
+ the way to the destination.
+
+ \return The network address of the next hop.
+ ******************************************************************************/
+ShortAddr_t NWK_GetNextHop(ShortAddr_t dstAddr);
+
+/**************************************************************************//**
+ \brief Get descriptor of next concentrator.
+
+ Example:
+ NWK_Concentrator_t c = NWK_INVALID_CONCENTRATOR;
+
+ while (IS_VALID_CONCENTRATOR(c = NWK_NextConcentrator(c)))
+ {
+ cAddr = NWK_ShortAddrOfConcentrator(c);
+ if (MASTER_CONCENTRATOR_ADDR == cAddr)
+ ...
+ ...
+ }
+
+ \param[in] prevConcentrator - descriptor of previous concentrator or
+ NWK_INVALID_CONCENTRATOR if it's initial call.
+
+ \return if next concentrator is found then return valid descriptor otherwise
+ return NWK_INVALID_CONCENTRATOR.
+ ******************************************************************************/
+NWK_Concentrator_t NWK_NextConcentrator(const NWK_Concentrator_t prevConcentrator);
+
+/**************************************************************************//**
+ \brief Get short address of given concentrator.
+
+ Note: Call this function and NWK_NextConcentrator() in same task.
+
+ \param[in] concentrator - descriptor of concentrator (see NWK_NextConcentrator).
+ \return Short address of concentrator.
+ ******************************************************************************/
+ShortAddr_t NWK_ShortAddrOfConcentrator(const NWK_Concentrator_t concentrator);
+
+/**************************************************************************//**
+ \brief Get short address of next hop node for given concentrator.
+
+ Note: Call this function and NWK_NextConcentrator() in same task.
+
+ \param[in] concentrator - descriptor of concentrator (see NWK_NextConcentrator).
+ \return Short address of next hop.
+ ******************************************************************************/
+ShortAddr_t NWK_NextHopToConcentrator(const NWK_Concentrator_t concentrator);
+
+/**************************************************************************//**
+ \brief Subscribe to indication about new concentrators.
+
+ \param[in] ind - pointer to concentrator indication structure.
+ \return None.
+ ******************************************************************************/
+void NWK_SubscribeToConcentratorInfo(NWK_ConcentratorInd_t *const ind);
+
+/**************************************************************************//**
+ \brief Unsubscribe from indication about new concentrators.
+
+ \param[in] ind - pointer to concentrator indication structure.
+ \return None.
+ ******************************************************************************/
+void NWK_UnsubscribeFromConcentratorInfo(NWK_ConcentratorInd_t *const ind);
+
+#endif /* _NWK_ROUTE_INFO_H */
+/** eof nwkRouteInfo.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkSecurity.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkSecurity.h
new file mode 100644
index 00000000..d06fa66a
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkSecurity.h
@@ -0,0 +1,270 @@
+/**************************************************************************//**
+ \file nwkSecurity.h
+
+ \brief Network security interface.
+
+ \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-13 Max Gekk - Created.
+ 2009-08-15 Max Gekk - Refactoring.
+ 2011-01-29 Max Gekk - Redesign.
+ Last change:
+ $Id: nwkSecurity.h 18245 2011-08-16 09:23:15Z arazinkov $
+ ******************************************************************************/
+/**//**
+ * The NWK layer is responsible for the processing steps needed to securely
+ * transmit outgoing frames and securely receive incoming frames. Upper layers
+ * control the security processing operations by setting up the appropriate keys
+ * and frame counters and establishing which security level to use.
+ * ZigBee spec r17, 4.3, page 426.
+ **/
+#if !defined _NWK_SECURITY_H && defined _SECURITY_
+#define _NWK_SECURITY_H
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <sspCommon.h>
+#include <mac.h>
+#include <nlmeReset.h>
+
+/******************************************************************************
+ Define(s) section
+ ******************************************************************************/
+#define NWK_PRECONFIGURED_NETWORK_KEY 0U
+#define NWK_NOT_PRECONFIGURED_NETWORK_KEY 3U
+
+/** Amount of incoming frame counters. */
+#define NWK_IN_FRAMES_MAX 4U
+/** Startup active network key sequence number */
+#define NWK_STARTUP_ACTIVE_KEY_SEQUENCE_NUMBER 0U
+/** Size of security counter in bytes */
+#define NWK_SIZE_OF_SECURITY_COUNTER 4U
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Type of NWK Key Sequence Number. */
+typedef uint8_t NWK_KeySeqNum_t;
+/** Type of NWK Key Index and amount. */
+typedef uint8_t NwkKeyAmount_t;
+typedef NwkKeyAmount_t NwkKeyIndex_t;
+
+/** Type of outgoing frame counter used for outgoing frames. */
+typedef uint32_t NwkOutFrameCounter_t;
+/** Type of incoming frame counter used for incoming frames. */
+typedef uint32_t NwkInFrameCounter_t;
+/** Type of outgoing frame counter higher bytes. */
+typedef uint16_t NwkOutFrameCounterTop_t;
+/** Type of outgoing frame counter lower bytes. */
+typedef uint16_t NwkOutFrameCounterLow_t;
+
+/** Outgoing security frame counter handle type. */
+BEGIN_PACK
+typedef union PACK
+{
+ NwkOutFrameCounter_t value;
+ struct
+ {
+ LITTLE_ENDIAN_OCTET(2,
+ (NwkOutFrameCounterLow_t low,
+ NwkOutFrameCounterTop_t top
+ ))
+ } part;
+} NwkOutFrameCounterHandle_t;
+END_PACK
+
+BEGIN_PACK
+typedef union PACK _NwkUnalignedInFrameCounter_t
+{
+ NwkInFrameCounter_t value;
+ uint8_t raw[sizeof(NwkInFrameCounter_t)];
+} NwkUnalignedInFrameCounter_t;
+END_PACK
+
+/** The Incoming Frame Counter Descriptor. */
+typedef struct _NWK_InFrameCounterSet_t
+{
+ bool isSet; /** Flag indicates busy status of entry. */
+ /** Extended device address. */
+ ExtAddr_t senderAddress;
+ /** Incoming frame counter used for incoming frames. */
+ NwkInFrameCounter_t value;
+} NWK_InFrameCounterSet_t;
+
+/** The Network Security Material Descriptor - key and key sequence number. */
+typedef struct _NWK_SecurityKey_t
+{
+ bool isSet; /** Flag indicates busy status of entry. */
+
+ /** A sequence number assigned to a network key by the Trust Center and used
+ * to distinguish network keys for purposes of key updates, and incoming
+ * frame security operations. */
+ NWK_KeySeqNum_t seqNum;
+ /** Outgoing frame counter higher bytes. */
+ NwkOutFrameCounterTop_t outCounterTop;
+ /** The actual value of the key. */
+ uint8_t value[SECURITY_KEY_SIZE];
+} NWK_SecurityKey_t;
+
+/** The Network Mutable Security Material Descriptor - incoming and outgoing
+ * frame counters. */
+typedef struct _NWK_SecurityFrameCounters_t
+{
+ /** Outgoing frame counter lower bytes. */
+ NwkOutFrameCounterLow_t outCounterLow;
+ /** Set of incoming frame counter values and corresponding device addresses. */
+ /* NWK_InFrameCounterSet_t inCounters[NWK_IN_FRAMES_MAX]; */
+} NWK_SecurityFrameCounters_t;
+
+/** Security-Related NIB Attributes. */
+typedef struct _NWK_SecurityIB_t
+{
+ /** Private field for internal use - the index of active key. */
+ NwkKeyIndex_t activeIndex;
+ /** The security level for outgoing and incoming NWK frames. */
+ uint8_t securityLevel;
+ /** Indicates whether security shall be applied to incoming
+ * and outgoing NWK data frames. */
+ bool secureAllFrames;
+ /** Total amount of NWK security keys. */
+ NwkKeyAmount_t keyAmount;
+ /** Set of network security material descriptors capable of maintaining
+ * an active and alternate network key. */
+ NWK_SecurityKey_t *key;
+ /** Pointer to set of security incoming and outgoing key frame counters.*/
+ NWK_SecurityFrameCounters_t *counter;
+} NWK_SecurityIB_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Get value of the nwkSecurityLevel attribute.
+
+ ZigBee spec r17, page 344, Table 3.44.
+
+ \return Current value of nwkSecurityLevel.
+ ******************************************************************************/
+uint8_t NWK_GetSecurityLevel(void);
+
+/**************************************************************************//**
+ \brief Getting value of nwkSecureAllFrames attribute.
+ ZigBee spec r17, page 344, Table 3.44.
+
+ \return Current value of nwkSecureAllFrames.
+ ******************************************************************************/
+bool NWK_GetSecureAllFrames(void);
+
+/**************************************************************************//**
+ \brief Set a new network key.
+
+ \param[in] key - a new network security key.
+ \param[in] keySeqNum - key sequence number.
+ \return 'true' if operation was completed successfully otherwise 'false'.
+ ******************************************************************************/
+bool NWK_SetKey(const uint8_t *const key, const NWK_KeySeqNum_t keySeqNum);
+
+/**************************************************************************//**
+ \brief Set NWK key as active.
+
+ \param[in] keySeqNum - key sequence number.
+ \return 'true' if operation was completed successfully otherwise 'false'.
+ ******************************************************************************/
+bool NWK_ActivateKey(const NWK_KeySeqNum_t keySeqNum);
+
+/**************************************************************************//**
+ \brief Check active network key.
+
+ \return 'true' if active NWK key is set otherwise 'false'.
+ ******************************************************************************/
+bool NWK_IsAnyKeyActivated(void);
+
+/**************************************************************************//**
+ \brief Get active network key.
+
+ \return Pointer to value of active network key.
+ ******************************************************************************/
+const uint8_t* NWK_GetActiveKey(void);
+
+/**************************************************************************//**
+ \brief Getting value of nwkActiveKeySeqNumber attribute.
+ ZigBee spec r17, page 344, Table 3.44.
+
+ \return Current value of nwkActiveKeySeqNumber.
+ ******************************************************************************/
+NWK_KeySeqNum_t NWK_GetActiveKeySeqNumber(void);
+
+/**************************************************************************//**
+ \brief Update outgoing security frame counter of active NWK key and return
+ it's value.
+
+ \return Outgoing frame counter in little-endian format.
+ ******************************************************************************/
+NwkOutFrameCounter_t NWK_GetUpdatedSecOutCounter(void);
+
+/**************************************************************************//**
+ \brief Return outgoing security frame counter value of active NWK key
+
+ \return Outgoing frame counter in little-endian format.
+ ******************************************************************************/
+NwkOutFrameCounter_t NWK_GetSecOutCounter(void);
+
+/**************************************************************************//**
+ \brief Update the incoming frame counter.
+
+ \param[in] srcExtAddr - an extended source address.
+ \param[in] newValue - a new value of the incoming frame counter.
+ \return None.
+ ******************************************************************************/
+void NWK_SetInFrameCounter(const ExtAddr_t srcExtAddr,
+ const NwkInFrameCounter_t counter);
+
+/**************************************************************************//**
+ \brief Deactivate current active NWK key.
+ ******************************************************************************/
+void NWK_DeactivateKey(void);
+
+/**************************************************************************//**
+ \brief Set all incoming and outgoing frame counters to zero.
+ ******************************************************************************/
+void NWK_ResetAllSecurityCounters(void);
+
+/**************************************************************************//**
+ \brief Reseting the network security subsystem.
+
+ \param[in] powerFailureControl - stack restoring after power failure control bitfield;
+ affects on initialization procedure.
+ \return None.
+ ******************************************************************************/
+void NWK_ResetSecurityIB(const NWK_PowerFailureControl_t powerFailureControl);
+
+/**************************************************************************//**
+ \brief Checks, if security services are provided by NWK.
+
+ \return True, if security services are provided by NWK, false - otherwise.
+ ******************************************************************************/
+bool NWK_IsSecurityProvided(void);
+
+#if defined _CERTIFICATION_
+/**************************************************************************//**
+ \brief Changes the maximum number of stored NWK security keys.
+
+ \param[in] keyAmount - new total amount of NWK keys.
+
+ \return NWK_SUCCESS_STATUS if keyAmount is changed successfuly otherwise
+ return NWK_INVALID_PARAMETERS_STATUS.
+ ******************************************************************************/
+NWK_Status_t NWK_SetKeyAmount(const uint8_t keyAmount);
+#endif /* _CERTIFICATION_ */
+
+#endif /* _NWK_SECURITY_H and _SECURITY_ */
+/** eof nwkSecurity.h */
+
+
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 */
+