⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nwk_aodvjr_route.h

📁 ucos在NEC平台下的移植
💻 H
字号:
 /*
 *******************************************************************************************************
 * CONFIDENTIAL                                                                                        *
 * The use of this file is restricted by SkywiseSystems                    *
 *                                                                                                     *
 * Copyright liquanling 02/09/2006                                                                          *
 *******************************************************************************************************
 * This module contains general types, constants, macros and functions used by many other NWK modules.  
 *******************************************************************************************************
 * Compiler: NEC-CC78K0                                                                                  *
 * Target platform:                                                   *
 *******************************************************************************************************
 * The revision history is located at the bottom of this file                                          *
 *******************************************************************************************************/
  #ifndef NWK_AODVJR_ROUTE_H
 #define NWK_AODVJR_ROUTE_H

#define NO_ROUTE_AVAILABLE        0x00
#define TREE_LINK_FAILURE            0x01
#define NON_TREE_LINK_FAILURE    0x02
#define LOW_BATTERY_LEVEL           0x03
#define NO_ROUTING_CAPACITY       0x04
//when we construct the NWK header, we need initialize the 'discover route' use the value as following
#define SUPPRESS_ROUTE_DISCOVERY     0x00
#define ENABLE_ROUTE_DISCOVERY         0x01
#define FORCE_ROUTE_DISCOVERY           0x02



 //---------------the definition of the route error code-----------------------------------------------------------------
//----------------   -one command in th network layer----------------------------------
#define NWK_ROUTE_REPAIR 0x80

//------------------some constant about route discovery--------------
#define ROUTE_DISCOVERY_ENABLE          0x01
#define ROUTE_DISCOVERY_FORCE           0x02
#define ROUTE_DISCOVERY_SUPPRESS        0x00

#define INVALID_ROUTE_DISCOVERY_TABLE_INDEX   NWK_ROUTE_DISCOVERY_TABLE_SIZE
//-----------------the definition of the route table---------------------------
typedef struct
{
 UINT16  destinationAddress;
 BYTE  routeStatus;
 UINT16  nextHopAddress;
}ROUTE_TABLE_RNTRY;



//-----------------the definition of the route discovery entry------------------------

typedef struct 
{
    //this timeStamp is a timer 
    TICK            timeStamp;          //tick if the alias name of 'long int'--32bit
    TICK            rebroadcastJitterTimer;
   UINT16          srcAddress;
   UINT16          senderAddress;
    BYTE           forwardRREQ[NWK_HEADER_LENGTH+CMD_ROUTE_REQUEST_PAYLOAD_LENGTH]; 
    BYTE            routeRequestID;
    BYTE            forwardCost;//the accumulated path cost from source of the route request to the current device
    BYTE            residualCost;//the accumulated path cost from the current device to the destination device
    BYTE            routingTableIndex;      // Added so we can find the routing entry during clean-up.
} ROUTE_DISCOVERY_ENTRY;


typedef struct 
{
    BYTE        bufferedData[NWK_HEADER_LENGTH+nwkcMaxPayloadSize];
    BYTE        dataLength;
   UINT16      sourceAddress;
   UINT16      destinationAddress;
   TICK        timeStamp;
} BUFFERED_MESSAGE_INFO;

//-----------------------------------------------------------------------------------------
//   PACKET_ROUTING_STATUS InitiateRouteDiscovery( ZBOOL fromUpperLayers, BYTE discoverRoute );
//
//   DESCRIPTION:
//           If no packet is currently awaiting route discovery, this function buffers the current packet and
//           initiates route discovery.  If we already have a packet buffered, this packet will be discarded.
//   PARAMETER:
//           ZBOOL fromUpperLayers,
//                  If this funcition is called by function serving for nldeDataRequest or function serving for
//                  mcpsDataIndication();
//           BYTE discoverRoute ,
//                  Indicates if route discovery operation is supressed or forced or enable.
//   RETURN-VALUE:
//           PACKET_ROUTING_STATUS
//------------------------------------------------------------------------------------------
#if defined(NWK_SUPPORT_ROUTING) && !defined(NWK_USE_TREE_ROUTING_ONLY)
PACKET_ROUTING_STATUS InitiateRouteDiscovery( ZBOOL fromUpperLayers, BYTE discoverRoute );
#endif
//-----------------------------------------------------------------------------------------------------------------------
//  MESSAGE_ROUTING_STATUS GetRoutingAddress( ZBOOL fromUpperLayers, BYTE * nwkAddress, BYTE discoverRoute, BYTE *macAddress );
//  
//  DESCRIPTION:
//           This function takes the target NWK address and determines
//            the next hop MAC address to send the message to.  
//  PARAMETER:
//            ZBOOL fromUpperLayers, 
//                 we are currently called by nldeDataRequest() or mcpsDataIndication()??     
//            BYTE *nwkAddress,
//                 final destination address.
//            BYTE discoverRoute,
//                  indicates if route discovery operation is supressed or forced or enable.
//            BYTE *macAddress,
//                 a 'value-result' parameter,when the function finished,the address of next hop to the final destination wil
//                 be stored in 'macAddress'.
//   RETURN-VALUE:
//            ROUTE_FAILURE:                           message cannot be sent or buffered.
//            ROUTE_MESSAGE_BUFFERED          message buffered pending route discovery.
//            ROUTE_SEND_TO_MAC_ADDRESS   valid destination address found.
//   NOTE:     If the  destination address is not our child and we do not have a
//                  route, this function buffers the message and initiates
//                 Route Discovery.  If macAddress is a valid next hop
//                 destination, the function returns ROUTE_SEND_TO_MAC_ADDRESS.
//------------------------------------------------------------------------------------------------------------------------
#ifndef NWK_OPT_RFD
PACKET_ROUTING_STATUS GetRoutingAddress( ZBOOL fromUpperLayers, UINT16 nwkAddress, BYTE discoverRoute, UINT16 *macAddress );
#endif
//-----------------------------------------------------------------------------------------------------------
//    ZBOOL CreateRoutingTableEntries( BYTE * destinationAddress, BYTE *routeDiscoveryIndex, BYTE *routeTableIndex );
//
//    DESCRIPTION:
//             This function creates Route Discovery Table and Routing Table entries.
//    PARAMETER:
//             BYTE * targetAddr,
//                      The destination address.
//             BYTE *routeDiscoveryIndex,
//                      A 'value-result' parameter-Route Discovery Table index of new entry.
//             BYTE *routeTableIndex,
//                      A 'value-result' parameter-Routing Table index of new entry.
//    RETURN-VALUE:
//            TRUE:This function successfully creates the Route Discovery Table and Routing Table entries.
//            FALSE:Failed in creating Route Discovery Table  or Routing Table Entries
//    NOTE:HasRoutingCapacity() must return TRUE.
//------------------------------------------------------------------------------------------------------
#if defined(NWK_SUPPORT_ROUTING) && !defined(NWK_USE_TREE_ROUTING_ONLY)
ZBOOL CreateRoutingTableEntries( UINT16  destinationAddress, BYTE *routeDiscoveryIndex, BYTE *routeTableIndex );
#endif

//-----------------------------------------------------------------------------------------------------------------------
//  PACKET_ROUTING_STATUS GetRoutingAddress( ZBOOL fromUpperLayers, UINT16  nwkAddress, BYTE discoverRoute, UINT16 *macAddress );
//  
//  DESCRIPTION:
//           This function takes the target NWK address and determines
//            the next hop MAC address to send the message to.  
//  PARAMETER:
//            ZBOOL fromUpperLayers, 
//                 we are currently called by nldeDataRequest() or mcpsDataIndication()??     
//            BYTE *nwkAddress,
//                 final destination address.
//            BYTE discoverRoute,
//                  indicates if route discovery operation is supressed or forced or enable.
//            BYTE *macAddress,
//                 a 'value-result' parameter,when the function finished,the address of next hop to the final destination wil
//                 be stored in 'macAddress'.
//   RETURN-VALUE:
//            ROUTE_FAILURE:                           message cannot be sent or buffered.
//            ROUTE_MESSAGE_BUFFERED          message buffered pending route discovery.
//            ROUTE_SEND_TO_MAC_ADDRESS   valid destination address found.
//   NOTE:     If the  destination address is not our child and we do not have a
//                  route, this function buffers the message and initiates
//                 Route Discovery.  If macAddress is a valid next hop
//                 destination, the function returns ROUTE_SEND_TO_MAC_ADDRESS.
//------------------------------------------------------------------------------------------------------------------------
 

#if defined(NWK_SUPPORT_ROUTING) && !defined(NWK_USE_TREE_ROUTING_ONLY)
PACKET_ROUTING_STATUS GetRoutingAddress( ZBOOL fromUpperLayers, UINT16 nwkAddress, BYTE discoverRoute, UINT16*macAddress );
#endif


//-------------------------------------------------------------------------------------------------------------------------
//      ZBOOL HaveRoutingCapacity( ZBOOL validID, BYTE routeRequestID, SHORT_ADDR routeSourceAddress,SHORT_ADDR routeDestAddress, BYTE commandOptions );
//
//      DESCRIPTION:
//             This function determines if we have routing capacity based on the zigbee specification1.0 definition:
//              A device is said to have routing table capacity if:
//                     (a) This device is a ZigBee coordinator or ZigBee router.
//                     (b) This device maintains a routing table.
//                     (c) This devcie has a free routing table entry or it already has a routing table entry corresponding to the  destination.
//                     (d) The device is attempting route repair and it has reserved some entries for this purpose as described above.
//               A device is said to have route discovery table capacity?if:
//                      (a) It maintains a route discovery table.
//                      (b) It has a free entry in its route discovery table.
//      If a device has both routing table capacity and route discovery table capacity then it may be said the have routing capacity.
//      PARAMETER:
//             ZBOOL validID, 
//                    If routeRequestID is a valid ID?
//             BYTE routeRequestID, 
//                    ID of current route request.  Valid if routeSourceAddress is not our address.
//             BYTE *routeSourceAddress,
//                    Source of the route.
//             BYTE *routeDestAddress,
//                    Destination of the route.
//             BYTE commandOptions  
//                    Indicatie is we are doing route repair.
//      RETURN-VALUE:
//                TRUE  - we have routing capacity.
//                FALSE - we do not have routing capacity.
//------------------------------------------------------------------------------------------------------------------------
#if defined(NWK_SUPPORT_ROUTING) && !defined(NWK_USE_TREE_ROUTING_ONLY)
ZBOOL HaveRoutingCapacity( ZBOOL validID, BYTE routeRequestID, UINT16 routeSourceAddress,UINT16 routeDestAddress, BYTE commandOptions );
#endif
//-----------------------------------------------------------------------------------------------------------------------
//     void CreateAndSendRouteReply( UINT16 nwkSourceAddress, BYTE routeDiscoveryTableIndex, ROUTE_REQUEST_COMMAND *rreq );
//
//     DESCRIPTION:
//             Sends the Route Reply command frame to the sender of the previous packet.
//     PARAMETER:
//             UINT16 nwkSourceAddress,
//                   The packet's network source address.
//             BYTE routeDiscoveryTableIndex, 
//                   Index in the route discovery table.
//             ROUTE_REQUEST_COMMAND *rreq,
//                   Pointer points to route request command packet
//     NOTE:
//             This function can only be called in the mcpsDataIndication function.
//------------------------------------------------------------------------------------------------------------------------
#ifdef NWK_SUPPORT_ROUTING
void CreateAndSendRouteReply( UINT16 nwkSourceAddress, BYTE routeDiscoveryTableIndex, ROUTE_REQUEST_COMMAND *rreq );
 #endif

//-------------------------------------------------------------------------------------------------------
//     ZBOOL GetNextHop(const UINT16   destAddr, UINT16* nextHop, PACKET_ROUTING_STATUS*routeStatus );
//
//     DESCRIPTION:
//                 This function finds an entry in the routing table  for the given destination address.  Note that the
//                  caller must check the route status to see how to use the next hop destination.
//     PARAMETER:
//                 UINT16 * destAddr, 
//                          Desired short address.
//                 UINT16 *nextHop,
//                          A 'value-result' parameter,points to next hop address in the route path to the desired short address.
//                 PACKET_ROUTING_STATUS *routeStatus
//                          A 'value-result' parameter,points to route status.
//     RETURN-VALUE:
//                 TRUE : an entry found in the routing table.' currentRoutingEntry' and 'pCurrentRoutingEntry'
//                            will be set the the Routing Table entry that matches the request.
//                 FALSE: no entry found.
//-------------------------------------------------------------------------------------------------------
//#if defined(NWK_SUPPORT_ROUTING) && !defined(NWK_USE_TREE_ROUTING_ONLY)
#ifndef NWK_OPT_RFD
ZBOOL GetNextHop(const UINT16   destAddr, UINT16* nextHop, PACKET_ROUTING_STATUS*routeStatus );
 #endif
 
 #endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -