Routing implementation.
Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include "sysConfig.h"
#include "nwk.h"
#include "nwkTx.h"
#include "nwkFrame.h"
#include "nwkRoute.h"
#include "nwkGroup.h"
#include "nwkCommand.h"
#include "nwkRouteDiscovery.h"
Macros | |
#define | NWK_ROUTE_DEFAULT_RANK 128 |
#define | NWK_ROUTE_MAX_RANK 255 |
Functions | |
NWK_RouteTableEntry_t * | NWK_RouteFindEntry (uint16_t dst, uint8_t multicast) |
void | NWK_RouteFreeEntry (NWK_RouteTableEntry_t *entry) |
NWK_RouteTableEntry_t * | NWK_RouteNewEntry (void) |
uint16_t | NWK_RouteNextHop (uint16_t dst, uint8_t multicast) |
NWK_RouteTableEntry_t * | NWK_RouteTable (void) |
bool | nwkRouteErrorReceived (NWK_DataInd_t *ind) |
void | nwkRouteFrame (NwkFrame_t *frame) |
void | nwkRouteFrameReceived (NwkFrame_t *frame) |
void | nwkRouteFrameSent (NwkFrame_t *frame) |
void | nwkRouteInit (void) |
Initializes the Routing module. More... | |
static void | nwkRouteNormalizeRanks (void) |
void | nwkRoutePrepareTx (NwkFrame_t *frame) |
void | nwkRouteRemove (uint16_t dst, uint8_t multicast) |
static void | nwkRouteSendRouteError (uint16_t src, uint16_t dst, uint8_t multicast) |
void | nwkRouteUpdateEntry (uint16_t dst, uint8_t multicast, uint16_t nextHop, uint8_t lqi) |
Variables | |
static NWK_RouteTableEntry_t | nwkRouteTable [NWK_ROUTE_TABLE_SIZE] |
#define NWK_ROUTE_DEFAULT_RANK 128 |
Referenced by NWK_RouteNewEntry(), and nwkRouteUpdateEntry().
#define NWK_ROUTE_MAX_RANK 255 |
Referenced by nwkRouteFrameSent().
NWK_RouteTableEntry_t* NWK_RouteFindEntry | ( | uint16_t | dst, |
uint8_t | multicast | ||
) |
References NWK_ROUTE_TABLE_SIZE, and nwkRouteTable.
Referenced by NWK_RouteNextHop(), nwkRouteFrameReceived(), nwkRouteFrameSent(), nwkRouteRemove(), and nwkRouteUpdateEntry().
void NWK_RouteFreeEntry | ( | NWK_RouteTableEntry_t * | entry | ) |
References NWK_ROUTE_UNKNOWN.
Referenced by nwkRouteFrameSent(), and nwkRouteRemove().
NWK_RouteTableEntry_t* NWK_RouteNewEntry | ( | void | ) |
References NWK_ROUTE_DEFAULT_RANK, NWK_ROUTE_DEFAULT_SCORE, NWK_ROUTE_TABLE_SIZE, and nwkRouteTable.
Referenced by nwkRouteFrameReceived(), and nwkRouteUpdateEntry().
uint16_t NWK_RouteNextHop | ( | uint16_t | dst, |
uint8_t | multicast | ||
) |
References NWK_ROUTE_UNKNOWN, and NWK_RouteFindEntry().
Referenced by nwkRouteFrame(), and nwkRoutePrepareTx().
NWK_RouteTableEntry_t* NWK_RouteTable | ( | void | ) |
References nwkRouteTable.
bool nwkRouteErrorReceived | ( | NWK_DataInd_t * | ind | ) |
References NWK_DataInd_t::data, NwkCommandRouteError_t::dstAddr, if(), NwkCommandRouteError_t::multicast, nwkRouteRemove(), and NWK_DataInd_t::size.
Referenced by nwkRxSeriveDataInd().
void nwkRouteFrame | ( | NwkFrame_t * | frame | ) |
References NwkFrame_t::header, NwkFrameHeader_t::multicast, NWK_ROUTE_UNKNOWN, NWK_RouteNextHop(), NWK_TX_CONTROL_ROUTING, NwkFrameHeader_t::nwkDstAddr, NwkFrameHeader_t::nwkFcf, nwkFrameFree(), nwkRouteSendRouteError(), NwkFrameHeader_t::nwkSrcAddr, nwkTxFrame(), and NwkFrame_t::tx.
Referenced by nwkRxTaskHandler().
void nwkRouteFrameReceived | ( | NwkFrame_t * | frame | ) |
References NwkIb_t::addr, NwkFrame_t::header, NwkFrameHeader_t::macDstAddr, NwkFrameHeader_t::macDstPanId, NwkFrameHeader_t::macSrcAddr, NWK_BROADCAST_ADDR, NWK_BROADCAST_PANID, NWK_ROUTE_DEFAULT_SCORE, NWK_ROUTE_NON_ROUTING, NWK_RouteFindEntry(), NWK_RouteNewEntry(), NwkFrameHeader_t::nwkDstAddr, nwkIb, NwkFrameHeader_t::nwkSrcAddr, and NwkFrame_t::rx.
Referenced by nwkRxHandleReceivedFrame().
void nwkRouteFrameSent | ( | NwkFrame_t * | frame | ) |
References NwkFrame_t::header, NwkFrameHeader_t::multicast, NWK_BROADCAST_ADDR, NWK_ROUTE_DEFAULT_SCORE, NWK_ROUTE_MAX_RANK, NWK_RouteFindEntry(), NWK_RouteFreeEntry(), NWK_SUCCESS_STATUS, NwkFrameHeader_t::nwkDstAddr, NwkFrameHeader_t::nwkFcf, nwkRouteNormalizeRanks(), and NwkFrame_t::tx.
Referenced by nwkTxTaskHandler().
void nwkRouteInit | ( | void | ) |
Initializes the Routing module.
References NWK_ROUTE_TABLE_SIZE, NWK_ROUTE_UNKNOWN, and nwkRouteTable.
Referenced by NWK_Init().
|
static |
References NWK_ROUTE_TABLE_SIZE, and nwkRouteTable.
Referenced by nwkRouteFrameSent().
void nwkRoutePrepareTx | ( | NwkFrame_t * | frame | ) |
void nwkRouteRemove | ( | uint16_t | dst, |
uint8_t | multicast | ||
) |
References NWK_RouteFindEntry(), and NWK_RouteFreeEntry().
Referenced by nwkRouteErrorReceived(), and nwkRxRejectDuplicate().
|
static |
References NwkCommandRouteError_t::dstAddr, NwkFrame_t::header, NwkCommandRouteError_t::id, NwkCommandRouteError_t::multicast, NWK_COMMAND_ROUTE_ERROR, NwkFrameHeader_t::nwkDstAddr, nwkFrameAlloc(), nwkFrameCommandInit(), nwkTxFrame(), NwkFrame_t::payload, NwkFrame_t::size, NwkCommandRouteError_t::srcAddr, and NwkFrame_t::tx.
Referenced by nwkRouteFrame().
void nwkRouteUpdateEntry | ( | uint16_t | dst, |
uint8_t | multicast, | ||
uint16_t | nextHop, | ||
uint8_t | lqi | ||
) |
|
static |
Referenced by NWK_RouteFindEntry(), NWK_RouteNewEntry(), NWK_RouteTable(), nwkRouteInit(), and nwkRouteNormalizeRanks().