Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
when a frame must be acked or not, not only the routing table is evaluated but also if the router is configured to forward
  • Loading branch information
Ing-Dom committed Feb 11, 2024
1 parent 6f368cc commit ba3133a
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 46 deletions.
2 changes: 1 addition & 1 deletion src/knx/bau091A.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ TPAckType Bau091A::isAckRequired(uint16_t address, bool isGrpAddr)

if(lcconfig & LCCONFIG::GROUP_IACK_ROUT)
// is group address in filter table? ACK if yes, No if not
if(_routerObj.isGroupAddressInFilterTable(address))
if(_netLayer.isRoutedGroupAddress(address, 1))
ack = TPAckType::AckReqAck;
else
ack = TPAckType::AckReqNone;
Expand Down
121 changes: 76 additions & 45 deletions src/knx/network_layer_coupler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,80 @@ bool NetworkLayerCoupler::isGroupAddressInFilterTable(uint16_t groupAddress)
}
}

bool NetworkLayerCoupler::isRoutedGroupAddress(uint16_t groupAddress, uint8_t sourceInterfaceIndex)
{
uint8_t interfaceIndex = (sourceInterfaceIndex == kSecondaryIfIndex) ? kPrimaryIfIndex : kSecondaryIfIndex;

uint8_t lcconfig = LCCONFIG::PHYS_FRAME_ROUT | LCCONFIG::PHYS_REPEAT | LCCONFIG::BROADCAST_REPEAT | LCCONFIG::GROUP_IACK_ROUT | LCCONFIG::PHYS_IACK_NORMAL; // default value from spec. in case prop is not availible.
uint8_t lcgrpconfig = LCGRPCONFIG::GROUP_6FFFROUTE | LCGRPCONFIG::GROUP_7000UNLOCK | LCGRPCONFIG::GROUP_REPEAT; // default value from spec. in case prop is not availible.
Property* prop_lcgrpconfig;
Property* prop_lcconfig;

if(sourceInterfaceIndex == kPrimaryIfIndex) // direction Prim -> Sec ( e.g. IP -> TP)
{
prop_lcgrpconfig = _rtObjPrimary->property(PID_MAIN_LCGRPCONFIG);
prop_lcconfig = _rtObjPrimary->property(PID_MAIN_LCCONFIG);
}
else // direction Sec -> Prim ( e.g. TP -> IP)
{
prop_lcgrpconfig = _rtObjPrimary->property(PID_SUB_LCGRPCONFIG);
prop_lcconfig = _rtObjPrimary->property(PID_SUB_LCCONFIG);
}
if(prop_lcgrpconfig)
prop_lcgrpconfig->read(lcgrpconfig);

if(prop_lcconfig)
prop_lcconfig->read(lcconfig);


if(groupAddress < 0x7000) // Main group 0-13
{
// PID_SUB_LCGRPCONFIG Bit 0-1
switch(lcgrpconfig & LCGRPCONFIG::GROUP_6FFF)
{
case LCGRPCONFIG::GROUP_6FFFLOCK:
//printHex("1drop frame to 0x", (uint8_t*)destination, 2);
return false;//drop
break;
case LCGRPCONFIG::GROUP_6FFFROUTE:
if(isGroupAddressInFilterTable(groupAddress))
;//send
else
{
//printHex("2drop frame to 0x", (uint8_t*)destination, 2);
return false;//drop
}
break;
default: // LCGRPCONFIG::GROUP_6FFFUNLOCK
;//send
}
}
else // Main group 14-31
{
// PID_SUB_LCGRPCONFIG Bit 2-3 LCGRPCONFIG::GROUP_7000
switch(lcgrpconfig & LCGRPCONFIG::GROUP_7000)
{
case LCGRPCONFIG::GROUP_7000LOCK:
//printHex("3drop frame to 0x", (uint8_t*)destination, 2);
return false;//drop
break;
case LCGRPCONFIG::GROUP_7000ROUTE:
if(isGroupAddressInFilterTable(groupAddress))
;//send
else
{
//printHex("4drop frame to 0x", (uint8_t*)destination, 2);
return false;//drop
}
break;
default: // LCGRPCONFIG::GROUP_7000UNLOCK
;//send
}
}

return true;
}

bool NetworkLayerCoupler::isRoutedIndividualAddress(uint16_t individualAddress, uint8_t srcIfIndex)
{
// TODO: improve: we have to be notified about anything that might affect routing decision
Expand Down Expand Up @@ -204,53 +278,10 @@ void NetworkLayerCoupler::sendMsgHopCount(AckType ack, AddressType addrType, uin
prop_lcconfig->read(lcconfig);



if(addrType == AddressType::GroupAddress && destination != 0) // destination == 0 means broadcast and must not be filtered with the GroupAddresses
{
if(destination < 0x7000) // Main group 0-13
{
// PID_SUB_LCGRPCONFIG Bit 0-1
switch(lcgrpconfig & LCGRPCONFIG::GROUP_6FFF)
{
case LCGRPCONFIG::GROUP_6FFFLOCK:
//printHex("1drop frame to 0x", (uint8_t*)destination, 2);
return;//drop
break;
case LCGRPCONFIG::GROUP_6FFFROUTE:
if(isGroupAddressInFilterTable(destination))
;//send
else
{
//printHex("2drop frame to 0x", (uint8_t*)destination, 2);
return;//drop
}
break;
default: // LCGRPCONFIG::GROUP_6FFFUNLOCK
;//send
}
}
else // Main group 14-31
{
// PID_SUB_LCGRPCONFIG Bit 2-3 LCGRPCONFIG::GROUP_7000
switch(lcgrpconfig & LCGRPCONFIG::GROUP_7000)
{
case LCGRPCONFIG::GROUP_7000LOCK:
//printHex("3drop frame to 0x", (uint8_t*)destination, 2);
return;//drop
break;
case LCGRPCONFIG::GROUP_7000ROUTE:
if(isGroupAddressInFilterTable(destination))
;//send
else
{
//printHex("4drop frame to 0x", (uint8_t*)destination, 2);
return;//drop
}
break;
default: // LCGRPCONFIG::GROUP_7000UNLOCK
;//send
}
}
if(!isRoutedGroupAddress(destination, sourceInterfaceIndex))
return; // drop;
}


Expand Down
2 changes: 2 additions & 0 deletions src/knx/network_layer_coupler.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class NetworkLayerCoupler : public NetworkLayer

bool isRoutedIndividualAddress(uint16_t individualAddress, uint8_t srcIfIndex);

bool isRoutedGroupAddress(uint16_t groupAddress, uint8_t sourceInterfaceIndex);

void rtObjPrimary(RouterObject& rtObjPrimary); // Coupler model 2.0
void rtObjSecondary(RouterObject& rtObjSecondary); // Coupler model 2.0
void rtObj(RouterObject& rtObj); // Coupler model 1.x
Expand Down

0 comments on commit ba3133a

Please sign in to comment.