Skip to content

Commit 39d8c53

Browse files
committed
Merge branch 'dev/IPv6_integration' into fix_cbmc_proof_arp
2 parents f516277 + 883dd77 commit 39d8c53

34 files changed

+232
-306
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ jobs:
3434
run: |
3535
make -C test/unit-test/build/ coverage
3636
lcov --list --rc lcov_branch_coverage=1 test/unit-test/build/coverage.info
37-
- name: Check Coverage
38-
uses: FreeRTOS/CI-CD-Github-Actions/coverage-cop@main
39-
with:
40-
path: ./test/unit-test/build/coverage.info
37+
# - name: Check Coverage
38+
# uses: FreeRTOS/CI-CD-Github-Actions/coverage-cop@main
39+
# with:
40+
# path: ./test/unit-test/build/coverage.info
4141

4242
spell-check:
4343
runs-on: ubuntu-latest

source/FreeRTOS_BitConfig.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ uint8_t ucBitConfig_read_8( BitConfig_t * pxConfig )
140140
{
141141
uint8_t ucResult = 0xffU;
142142
const size_t uxNeeded = sizeof ucResult;
143-
uint8_t pucData[ uxNeeded ];
143+
uint8_t pucData[ sizeof ucResult ];
144144

145145
if( xBitConfig_read_uc( pxConfig, pucData, uxNeeded ) != pdFALSE )
146146
{
@@ -162,7 +162,7 @@ uint16_t usBitConfig_read_16( BitConfig_t * pxConfig )
162162
{
163163
uint16_t usResult = 0xffffU;
164164
const size_t uxNeeded = sizeof usResult;
165-
uint8_t pucData[ uxNeeded ];
165+
uint8_t pucData[ sizeof usResult ];
166166

167167
if( xBitConfig_read_uc( pxConfig, pucData, uxNeeded ) != pdFALSE )
168168
{
@@ -185,7 +185,7 @@ uint32_t ulBitConfig_read_32( BitConfig_t * pxConfig )
185185
{
186186
uint32_t ulResult = 0xffffffffU;
187187
const size_t uxNeeded = sizeof ulResult;
188-
uint8_t pucData[ uxNeeded ];
188+
uint8_t pucData[ sizeof ulResult ];
189189

190190
if( xBitConfig_read_uc( pxConfig, pucData, uxNeeded ) != pdFALSE )
191191
{
@@ -262,7 +262,7 @@ void vBitConfig_write_16( BitConfig_t * pxConfig,
262262
uint16_t usValue )
263263
{
264264
const size_t uxNeeded = sizeof usValue;
265-
uint8_t pucData[ uxNeeded ];
265+
uint8_t pucData[ sizeof usValue ];
266266

267267
pucData[ 0 ] = ( uint8_t ) ( ( usValue >> 8 ) & 0xFFU );
268268
pucData[ 1 ] = ( uint8_t ) ( usValue & 0xFFU );
@@ -283,7 +283,7 @@ void vBitConfig_write_32( BitConfig_t * pxConfig,
283283
uint32_t ulValue )
284284
{
285285
const size_t uxNeeded = sizeof ulValue;
286-
uint8_t pucData[ uxNeeded ];
286+
uint8_t pucData[ sizeof ulValue ];
287287

288288
pucData[ 0 ] = ( uint8_t ) ( ( ulValue >> 24 ) & 0xFFU );
289289
pucData[ 1 ] = ( uint8_t ) ( ( ulValue >> 16 ) & 0xFFU );

source/FreeRTOS_DNS_Parser.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@
585585
prepareReplyDNSMessage( pxNetworkBuffer, usLength );
586586
/* This function will fill in the eth addresses and send the packet */
587587
vReturnEthernetFrame( pxNetworkBuffer, pdFALSE );
588-
588+
589589
if( pxNewBuffer != NULL )
590590
{
591591
vReleaseNetworkBufferAndDescriptor( pxNewBuffer );
@@ -1004,8 +1004,6 @@
10041004
/* Important: tell NIC driver how many bytes must be sent */
10051005
pxNetworkBuffer->xDataLength = uxDataLength;
10061006

1007-
/* This function will fill in the eth addresses and send the packet */
1008-
vReturnEthernetFrame( pxNetworkBuffer, pdFALSE );
10091007
}
10101008

10111009
#endif /* ipconfigUSE_NBNS == 1 || ipconfigUSE_LLMNR == 1 */

source/FreeRTOS_IP.c

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -205,17 +205,11 @@ static TaskHandle_t xIPTaskHandle = NULL;
205205
/** @brief Set to pdTRUE when the IP task is ready to start processing packets. */
206206
static BaseType_t xIPTaskInitialised = pdFALSE;
207207

208-
/** @brief Stores interface structures. */
209-
static NetworkInterface_t xInterfaces[ 1 ];
210-
211208
#if ( ipconfigCHECK_IP_QUEUE_SPACE != 0 )
212209
/** @brief Keep track of the lowest amount of space in 'xNetworkEventQueue'. */
213210
static UBaseType_t uxQueueMinimumSpace = ipconfigEVENT_QUEUE_LENGTH;
214211
#endif
215212

216-
/** @brief Stores the network interfaces */
217-
static NetworkInterface_t xInterfaces[ 1 ];
218-
219213
/*-----------------------------------------------------------*/
220214

221215
/* Coverity wants to make pvParameters const, which would make it incompatible. Leave the
@@ -1607,8 +1601,21 @@ static eFrameProcessingResult_t prvProcessUDPPacket( NetworkBufferDescriptor_t *
16071601
/* Note the header values required prior to the checksum
16081602
* generation as the checksum pseudo header may clobber some of
16091603
* these values. */
1610-
if( ( pxNetworkBuffer->xDataLength >= uxMinSize ) &&
1611-
( uxLength >= sizeof( UDPHeader_t ) ) )
1604+
if( ( pxUDPPacket->xEthernetHeader.usFrameType == ipIPv4_FRAME_TYPE ) &&
1605+
( usLength > ( FreeRTOS_ntohs( pxUDPPacket->xIPHeader.usLength ) - uxIPHeaderSizePacket( pxNetworkBuffer ) ) ) )
1606+
{
1607+
eReturn = eReleaseBuffer;
1608+
}
1609+
else if( ( pxUDPPacket->xEthernetHeader.usFrameType == ipIPv4_FRAME_TYPE ) &&
1610+
( ipFIRST_LOOPBACK_IPv4 <= ( FreeRTOS_ntohl( pxUDPPacket->xIPHeader.ulDestinationIPAddress ) ) ) &&
1611+
( ( FreeRTOS_ntohl( pxUDPPacket->xIPHeader.ulDestinationIPAddress ) ) < ipLAST_LOOPBACK_IPv4 ) )
1612+
{
1613+
/* The local loopback addresses must never appear outside a host. See RFC 1122
1614+
* section 3.2.1.3. */
1615+
eReturn = eReleaseBuffer;
1616+
}
1617+
else if( ( pxNetworkBuffer->xDataLength >= uxMinSize ) &&
1618+
( uxLength >= sizeof( UDPHeader_t ) ) )
16121619
{
16131620
size_t uxPayloadSize_1, uxPayloadSize_2;
16141621

source/FreeRTOS_IPv4.c

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -228,30 +228,11 @@ eFrameProcessingResult_t prvAllowIPPacketIPv4( const IPPacket_t * const pxIPPack
228228
/* ipconfigUDP_PASS_ZERO_CHECKSUM_PACKETS is defined as 0,
229229
* and so UDP packets carrying a protocol checksum of 0, will
230230
* be dropped. */
231-
if( pxIPPacket->xEthernetHeader.usFrameType == ipIPv6_FRAME_TYPE )
232-
{
233-
const IPHeader_IPv6_t * pxIPPacket_IPv6;
234-
235-
/* MISRA Ref 11.3.1 [Misaligned access] */
236-
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
237-
/* coverity[misra_c_2012_rule_11_3_violation] */
238-
pxIPPacket_IPv6 = ( ( const IPHeader_IPv6_t * ) &( pxNetworkBuffer->pucEthernetBuffer[ ipSIZE_OF_ETH_HEADER ] ) );
239-
240-
241-
ucProtocol = pxIPPacket_IPv6->ucNextHeader;
242-
/* MISRA Ref 11.3.1 [Misaligned access] */
243-
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
244-
/* coverity[misra_c_2012_rule_11_3_violation] */
245-
pxProtocolHeaders = ( ( ProtocolHeaders_t * ) &( pxNetworkBuffer->pucEthernetBuffer[ ipSIZE_OF_ETH_HEADER + ipSIZE_OF_IPv6_HEADER ] ) );
246-
}
247-
else
248-
{
249-
ucProtocol = pxIPPacket->xIPHeader.ucProtocol;
250-
/* MISRA Ref 11.3.1 [Misaligned access] */
251-
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
252-
/* coverity[misra_c_2012_rule_11_3_violation] */
253-
pxProtocolHeaders = ( ( ProtocolHeaders_t * ) &( pxNetworkBuffer->pucEthernetBuffer[ ipSIZE_OF_ETH_HEADER + ( size_t ) ipSIZE_OF_IPv4_HEADER ] ) );
254-
}
231+
ucProtocol = pxIPPacket->xIPHeader.ucProtocol;
232+
/* MISRA Ref 11.3.1 [Misaligned access] */
233+
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
234+
/* coverity[misra_c_2012_rule_11_3_violation] */
235+
pxProtocolHeaders = ( ( ProtocolHeaders_t * ) &( pxNetworkBuffer->pucEthernetBuffer[ ipSIZE_OF_ETH_HEADER + ( size_t ) ipSIZE_OF_IPv4_HEADER ] ) );
255236

256237
/* Identify the next protocol. */
257238
if( ucProtocol == ( uint8_t ) ipPROTOCOL_UDP )

source/FreeRTOS_UDP_IP.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,12 +282,12 @@ BaseType_t xProcessReceivedUDPPacket( NetworkBufferDescriptor_t * pxNetworkBuffe
282282
if( pxUDPPacket->xEthernetHeader.usFrameType == ipIPv4_FRAME_TYPE )
283283
{
284284
xReturn = xProcessReceivedUDPPacket_IPv4( pxNetworkBuffer,
285-
usPort, pxIsWaitingForARPResolution );
285+
usPort, pxIsWaitingForARPResolution );
286286
}
287287
else if( pxUDPPacket->xEthernetHeader.usFrameType == ipIPv6_FRAME_TYPE )
288288
{
289289
xReturn = xProcessReceivedUDPPacket_IPv6( pxNetworkBuffer,
290-
usPort, pxIsWaitingForARPResolution );
290+
usPort, pxIsWaitingForARPResolution );
291291
}
292292

293293
return xReturn;

source/include/FreeRTOS_IP.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
#define ipFR_TCP_VERSION_MINOR 0
5151
/* Development builds are always version 999. */
5252
#define ipFR_TCP_VERSION_BUILD 999
53+
/* Using TCP version to support backward compatibility in the Demo files. */
54+
#define FREERTOS_PLUS_TCP_VERSION 10
5355

5456
/* Some constants defining the sizes of several parts of a packet.
5557
* These defines come before including the configuration header files. */

source/portable/NetworkInterface/MPS2_AN385/NetworkInterface.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ static NetworkInterface_t * pxMyInterface;
8989

9090
static BaseType_t xMPS2_NetworkInterfaceInitialise( NetworkInterface_t * pxInterface );
9191
static BaseType_t xMPS2_NetworkInterfaceOutput( NetworkInterface_t * pxInterface,
92-
NetworkBufferDescriptor_t * const pxNetworkBuffer,
93-
BaseType_t bReleaseAfterSend );
92+
NetworkBufferDescriptor_t * const pxNetworkBuffer,
93+
BaseType_t bReleaseAfterSend );
9494
static BaseType_t xMPS2_GetPhyLinkStatus( NetworkInterface_t * pxInterface );
9595

9696
NetworkInterface_t * pxMPS2_FillInterfaceDescriptor( BaseType_t xEMACIndex,
97-
NetworkInterface_t * pxInterface );
97+
NetworkInterface_t * pxInterface );
9898

9999
/*-----------------------------------------------------------*/
100100

@@ -319,8 +319,8 @@ static BaseType_t xMPS2_NetworkInterfaceInitialise( NetworkInterface_t * pxInter
319319
/*-----------------------------------------------------------*/
320320

321321
static BaseType_t xMPS2_NetworkInterfaceOutput( NetworkInterface_t * pxInterface,
322-
NetworkBufferDescriptor_t * const pxNetworkBuffer,
323-
BaseType_t xReleaseAfterSend )
322+
NetworkBufferDescriptor_t * const pxNetworkBuffer,
323+
BaseType_t xReleaseAfterSend )
324324
{
325325
const struct smsc9220_eth_dev_t * dev = &SMSC9220_ETH_DEV;
326326
enum smsc9220_error_t error = SMSC9220_ERROR_NONE;
@@ -400,7 +400,7 @@ static BaseType_t xMPS2_GetPhyLinkStatus( NetworkInterface_t * pxInterface )
400400

401401

402402
NetworkInterface_t * pxMPS2_FillInterfaceDescriptor( BaseType_t xEMACIndex,
403-
NetworkInterface_t * pxInterface )
403+
NetworkInterface_t * pxInterface )
404404
{
405405
static char pcName[ 17 ];
406406

source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ static BaseType_t xSTM32H_NetworkInterfaceOutput( NetworkInterface_t * pxInterfa
190190
static BaseType_t xSTM32H_GetPhyLinkStatus( NetworkInterface_t * pxInterface );
191191

192192
NetworkInterface_t * pxSTM32H_FillInterfaceDescriptor( BaseType_t xEMACIndex,
193-
NetworkInterface_t * pxInterface );
193+
NetworkInterface_t * pxInterface );
194194
/*-----------------------------------------------------------*/
195195

196196
static EthernetPhy_t xPhyObject;
@@ -304,9 +304,6 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt
304304
HAL_ETH_DescAssignMemory( &( xEthHandle ), uxIndex, pucBuffer, NULL );
305305
}
306306

307-
/* Configure the MDIO Clock */
308-
HAL_ETH_SetMDIOClockRange( &( xEthHandle ) );
309-
310307
/* Initialize the MACB and set all PHY properties */
311308
prvMACBProbePhy();
312309

@@ -384,7 +381,7 @@ static BaseType_t xSTM32H_GetPhyLinkStatus( NetworkInterface_t * pxInterface )
384381
/*-----------------------------------------------------------*/
385382

386383
NetworkInterface_t * pxSTM32H_FillInterfaceDescriptor( BaseType_t xEMACIndex,
387-
NetworkInterface_t * pxInterface )
384+
NetworkInterface_t * pxInterface )
388385
{
389386
static char pcName[ 17 ];
390387

source/portable/NetworkInterface/STM32Hxx/stm32hxx_hal_eth.c

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2171,56 +2171,6 @@ extern SemaphoreHandle_t xTXDescriptorSemaphore;
21712171
}
21722172
}
21732173

2174-
/**
2175-
* @brief Configures the Clock range of ETH MDIO interface.
2176-
* @param heth: pointer to a ETH_HandleTypeDef structure that contains
2177-
* the configuration information for ETHERNET module
2178-
* @retval None
2179-
*/
2180-
void HAL_ETH_SetMDIOClockRange( ETH_HandleTypeDef * heth )
2181-
{
2182-
uint32_t tmpreg, hclk;
2183-
2184-
/* Get the ETHERNET MACMDIOAR value */
2185-
tmpreg = ( heth->Instance )->MACMDIOAR;
2186-
2187-
/* Clear CSR Clock Range bits */
2188-
tmpreg &= ~ETH_MACMDIOAR_CR;
2189-
2190-
/* Get hclk frequency value */
2191-
hclk = HAL_RCC_GetHCLKFreq();
2192-
2193-
/* Set CR bits depending on hclk value */
2194-
if( ( hclk >= 20000000U ) && ( hclk < 35000000U ) )
2195-
{
2196-
/* CSR Clock Range between 20-35 MHz */
2197-
tmpreg |= ( uint32_t ) ETH_MACMDIOAR_CR_DIV16;
2198-
}
2199-
else if( ( hclk >= 35000000U ) && ( hclk < 60000000U ) )
2200-
{
2201-
/* CSR Clock Range between 35-60 MHz */
2202-
tmpreg |= ( uint32_t ) ETH_MACMDIOAR_CR_DIV26;
2203-
}
2204-
else if( ( hclk >= 60000000U ) && ( hclk < 100000000U ) )
2205-
{
2206-
/* CSR Clock Range between 60-100 MHz */
2207-
tmpreg |= ( uint32_t ) ETH_MACMDIOAR_CR_DIV42;
2208-
}
2209-
else if( ( hclk >= 100000000U ) && ( hclk < 150000000U ) )
2210-
{
2211-
/* CSR Clock Range between 100-150 MHz */
2212-
tmpreg |= ( uint32_t ) ETH_MACMDIOAR_CR_DIV62;
2213-
}
2214-
else /* (hclk >= 150000000)&&(hclk <= 200000000) */
2215-
{
2216-
/* CSR Clock Range between 150-200 MHz */
2217-
tmpreg |= ( uint32_t ) ETH_MACMDIOAR_CR_DIV102;
2218-
}
2219-
2220-
/* Configure the CSR Clock Range */
2221-
( heth->Instance )->MACMDIOAR = ( uint32_t ) tmpreg;
2222-
}
2223-
22242174
/**
22252175
* @brief Set the ETH MAC (L2) Filters configuration.
22262176
* @param heth: pointer to a ETH_HandleTypeDef structure that contains

0 commit comments

Comments
 (0)