|
|
|
@ -357,7 +357,8 @@ struct freertos_sockaddr xAddress;
|
|
|
|
|
/* Wait until there is something to do. If the following call exits
|
|
|
|
|
* due to a time out rather than a message being received, set a
|
|
|
|
|
* 'NoEvent' value. */
|
|
|
|
|
if ( xQueueReceive( xNetworkEventQueue, ( void * ) &xReceivedEvent, xNextIPSleep ) == pdFALSE ) {
|
|
|
|
|
if ( xQueueReceive( xNetworkEventQueue, ( void * ) &xReceivedEvent, xNextIPSleep ) == pdFALSE )
|
|
|
|
|
{
|
|
|
|
|
xReceivedEvent.eEventType = eNoEvent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -804,8 +805,7 @@ void *pvReturn;
|
|
|
|
|
if( pxNetworkBuffer != NULL )
|
|
|
|
|
{
|
|
|
|
|
/* Set the actual packet size in case a bigger buffer was returned. */
|
|
|
|
|
pxNetworkBuffer->xDataLength =
|
|
|
|
|
sizeof( UDPPacket_t ) + xRequestedSizeBytes;
|
|
|
|
|
pxNetworkBuffer->xDataLength = sizeof( UDPPacket_t ) + xRequestedSizeBytes;
|
|
|
|
|
|
|
|
|
|
/* Leave space for the UPD header. */
|
|
|
|
|
pvReturn = ( void * ) &( pxNetworkBuffer->pucEthernetBuffer[ ipUDP_PAYLOAD_OFFSET_IPv4 ] );
|
|
|
|
@ -1516,8 +1516,8 @@ uint8_t ucProtocol;
|
|
|
|
|
/* Bound the calculated header length: take away the Ethernet header size,
|
|
|
|
|
then check if the IP header is claiming to be longer than the remaining
|
|
|
|
|
total packet size. Also check for minimal header field length. */
|
|
|
|
|
if( uxHeaderLength > pxNetworkBuffer->xDataLength - ipSIZE_OF_ETH_HEADER ||
|
|
|
|
|
uxHeaderLength < ipSIZE_OF_IPv4_HEADER )
|
|
|
|
|
if( ( uxHeaderLength > ( pxNetworkBuffer->xDataLength - ipSIZE_OF_ETH_HEADER ) ) ||
|
|
|
|
|
( uxHeaderLength < ipSIZE_OF_IPv4_HEADER ) )
|
|
|
|
|
{
|
|
|
|
|
return eReleaseBuffer;
|
|
|
|
|
}
|
|
|
|
@ -1545,8 +1545,7 @@ uint8_t ucProtocol;
|
|
|
|
|
pxNetworkBuffer->xDataLength -= optlen;
|
|
|
|
|
|
|
|
|
|
/* Fix-up new version/header length field in IP packet. */
|
|
|
|
|
pxIPHeader->ucVersionHeaderLength =
|
|
|
|
|
( pxIPHeader->ucVersionHeaderLength & 0xF0 ) | /* High nibble is the version. */
|
|
|
|
|
pxIPHeader->ucVersionHeaderLength = ( pxIPHeader->ucVersionHeaderLength & 0xF0 ) | /* High nibble is the version. */
|
|
|
|
|
( ( ipSIZE_OF_IPv4_HEADER >> 2 ) & 0x0F ); /* Low nibble is the header size, in bytes, divided by four. */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1612,8 +1611,7 @@ uint8_t ucProtocol;
|
|
|
|
|
if( ( FreeRTOS_ntohs( pxUDPPacket->xUDPHeader.usLength ) - sizeof( UDPHeader_t ) ) <
|
|
|
|
|
pxNetworkBuffer->xDataLength )
|
|
|
|
|
{
|
|
|
|
|
pxNetworkBuffer->xDataLength = FreeRTOS_ntohs( pxUDPPacket->xUDPHeader.usLength ) -
|
|
|
|
|
sizeof( UDPHeader_t );
|
|
|
|
|
pxNetworkBuffer->xDataLength = FreeRTOS_ntohs( pxUDPPacket->xUDPHeader.usLength ) - sizeof( UDPHeader_t );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Fields in pxNetworkBuffer (usPort, ulIPAddress) are network order. */
|
|
|
|
@ -1814,8 +1812,7 @@ uint8_t ucProtocol;
|
|
|
|
|
|
|
|
|
|
/* Per https://tools.ietf.org/html/rfc791, the four-bit Internet Header
|
|
|
|
|
Length field contains the length of the internet header in 32-bit words. */
|
|
|
|
|
uxIPHeaderLength = ( UBaseType_t )
|
|
|
|
|
( sizeof( uint32_t ) * ( pxIPPacket->xIPHeader.ucVersionHeaderLength & 0x0Fu ) );
|
|
|
|
|
uxIPHeaderLength = ( UBaseType_t ) ( sizeof( uint32_t ) * ( pxIPPacket->xIPHeader.ucVersionHeaderLength & 0x0Fu ) );
|
|
|
|
|
|
|
|
|
|
/* Check for minimum packet size. */
|
|
|
|
|
if( uxBufferLength < sizeof( IPPacket_t ) + uxIPHeaderLength - ipSIZE_OF_IPv4_HEADER )
|
|
|
|
@ -1840,7 +1837,7 @@ uint8_t ucProtocol;
|
|
|
|
|
/* Switch on the Layer 3/4 protocol. */
|
|
|
|
|
if( ucProtocol == ( uint8_t ) ipPROTOCOL_UDP )
|
|
|
|
|
{
|
|
|
|
|
if( uxBufferLength < uxIPHeaderLength + ipSIZE_OF_ETH_HEADER + ipSIZE_OF_UDP_HEADER )
|
|
|
|
|
if( uxBufferLength < ( uxIPHeaderLength + ipSIZE_OF_ETH_HEADER + ipSIZE_OF_UDP_HEADER ) )
|
|
|
|
|
{
|
|
|
|
|
return ipINVALID_LENGTH;
|
|
|
|
|
}
|
|
|
|
@ -1854,7 +1851,7 @@ uint8_t ucProtocol;
|
|
|
|
|
}
|
|
|
|
|
else if( ucProtocol == ( uint8_t ) ipPROTOCOL_TCP )
|
|
|
|
|
{
|
|
|
|
|
if( uxBufferLength < uxIPHeaderLength + ipSIZE_OF_ETH_HEADER + ipSIZE_OF_TCP_HEADER )
|
|
|
|
|
if( uxBufferLength < ( uxIPHeaderLength + ipSIZE_OF_ETH_HEADER + ipSIZE_OF_TCP_HEADER ) )
|
|
|
|
|
{
|
|
|
|
|
return ipINVALID_LENGTH;
|
|
|
|
|
}
|
|
|
|
@ -1869,7 +1866,7 @@ uint8_t ucProtocol;
|
|
|
|
|
else if( ( ucProtocol == ( uint8_t ) ipPROTOCOL_ICMP ) ||
|
|
|
|
|
( ucProtocol == ( uint8_t ) ipPROTOCOL_IGMP ) )
|
|
|
|
|
{
|
|
|
|
|
if( uxBufferLength < uxIPHeaderLength + ipSIZE_OF_ETH_HEADER + ipSIZE_OF_ICMP_HEADER )
|
|
|
|
|
if( uxBufferLength < ( uxIPHeaderLength + ipSIZE_OF_ETH_HEADER + ipSIZE_OF_ICMP_HEADER ) )
|
|
|
|
|
{
|
|
|
|
|
return ipINVALID_LENGTH;
|
|
|
|
|
}
|
|
|
|
|