From 62803247782e6cec902de1da3880d64734adf0ad Mon Sep 17 00:00:00 2001 From: Richard Barry Date: Mon, 14 Oct 2013 14:35:53 +0000 Subject: [PATCH] Add a configASSERT() that checks the gateway address is on the same subnet as the device in FreeRTOS+UDP. --- FreeRTOS-Plus/Source/FreeRTOS-Plus-UDP/FreeRTOS_UDP_IP.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-UDP/FreeRTOS_UDP_IP.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-UDP/FreeRTOS_UDP_IP.c index a490e481e..dd12aa748 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-UDP/FreeRTOS_UDP_IP.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-UDP/FreeRTOS_UDP_IP.c @@ -581,6 +581,10 @@ static portBASE_TYPE xReturn = pdFALSE; #else { *ipLOCAL_IP_ADDRESS_POINTER = xNetworkAddressing.ulDefaultIPAddress; + + /* Ensure the gateway is on the same subnet as the IP + address. */ + configASSERT( ( ( *ipLOCAL_IP_ADDRESS_POINTER ) & xNetworkAddressing.ulNetMask ) == ( xNetworkAddressing.ulGatewayAddress & xNetworkAddressing.ulNetMask ) ); } #endif /* ipconfigUSE_DHCP == 1 */