Skip to content
Snippets Groups Projects
Commit 86d57a65 authored by rahix's avatar rahix
Browse files

Merge branch 'rahix/epic-freertos' into 'master'

Use FreeRTOS in epicardium

See merge request !11
parents 875d9f8f 3e0a8fbb
No related branches found
No related tags found
No related merge requests found
Showing
with 12895 additions and 0 deletions
This diff is collapsed.
/*
* FreeRTOS+TCP V2.0.11
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* http://aws.amazon.com/freertos
* http://www.FreeRTOS.org
*/
/* Standard includes. */
#include <stdint.h>
/* FreeRTOS includes. */
#include "FreeRTOS.h"
#include "task.h"
#include "semphr.h"
/* FreeRTOS+TCP includes. */
#include "FreeRTOS_UDP_IP.h"
#include "FreeRTOS_IP.h"
#include "FreeRTOS_Sockets.h"
#include "FreeRTOS_IP_Private.h"
/*
* uxStreamBufferAdd( )
* Adds data to a stream buffer. If uxOffset > 0, data will be written at
* an offset from uxHead while uxHead will not be moved yet. This possibility
* will be used when TCP data is received while earlier data is still missing.
* If 'pucData' equals NULL, the function is called to advance 'uxHead' only.
*/
size_t uxStreamBufferAdd( StreamBuffer_t *pxBuffer, size_t uxOffset, const uint8_t *pucData, size_t uxCount )
{
size_t uxSpace, uxNextHead, uxFirst;
uxSpace = uxStreamBufferGetSpace( pxBuffer );
/* If uxOffset > 0, items can be placed in front of uxHead */
if( uxSpace > uxOffset )
{
uxSpace -= uxOffset;
}
else
{
uxSpace = 0u;
}
/* The number of bytes that can be written is the minimum of the number of
bytes requested and the number available. */
uxCount = FreeRTOS_min_uint32( uxSpace, uxCount );
if( uxCount != 0u )
{
uxNextHead = pxBuffer->uxHead;
if( uxOffset != 0u )
{
/* ( uxOffset > 0 ) means: write in front if the uxHead marker */
uxNextHead += uxOffset;
if( uxNextHead >= pxBuffer->LENGTH )
{
uxNextHead -= pxBuffer->LENGTH;
}
}
if( pucData != NULL )
{
/* Calculate the number of bytes that can be added in the first
write - which may be less than the total number of bytes that need
to be added if the buffer will wrap back to the beginning. */
uxFirst = FreeRTOS_min_uint32( pxBuffer->LENGTH - uxNextHead, uxCount );
/* Write as many bytes as can be written in the first write. */
memcpy( ( void* ) ( pxBuffer->ucArray + uxNextHead ), pucData, uxFirst );
/* If the number of bytes written was less than the number that
could be written in the first write... */
if( uxCount > uxFirst )
{
/* ...then write the remaining bytes to the start of the
buffer. */
memcpy( ( void * )pxBuffer->ucArray, pucData + uxFirst, uxCount - uxFirst );
}
}
if( uxOffset == 0u )
{
/* ( uxOffset == 0 ) means: write at uxHead position */
uxNextHead += uxCount;
if( uxNextHead >= pxBuffer->LENGTH )
{
uxNextHead -= pxBuffer->LENGTH;
}
pxBuffer->uxHead = uxNextHead;
}
if( xStreamBufferLessThenEqual( pxBuffer, pxBuffer->uxFront, uxNextHead ) != pdFALSE )
{
/* Advance the front pointer */
pxBuffer->uxFront = uxNextHead;
}
}
return uxCount;
}
/*-----------------------------------------------------------*/
/*
* uxStreamBufferGet( )
* 'uxOffset' can be used to read data located at a certain offset from 'lTail'.
* If 'pucData' equals NULL, the function is called to advance 'lTail' only.
* if 'xPeek' is pdTRUE, or if 'uxOffset' is non-zero, the 'lTail' pointer will
* not be advanced.
*/
size_t uxStreamBufferGet( StreamBuffer_t *pxBuffer, size_t uxOffset, uint8_t *pucData, size_t uxMaxCount, BaseType_t xPeek )
{
size_t uxSize, uxCount, uxFirst, uxNextTail;
/* How much data is available? */
uxSize = uxStreamBufferGetSize( pxBuffer );
if( uxSize > uxOffset )
{
uxSize -= uxOffset;
}
else
{
uxSize = 0u;
}
/* Use the minimum of the wanted bytes and the available bytes. */
uxCount = FreeRTOS_min_uint32( uxSize, uxMaxCount );
if( uxCount > 0u )
{
uxNextTail = pxBuffer->uxTail;
if( uxOffset != 0u )
{
uxNextTail += uxOffset;
if( uxNextTail >= pxBuffer->LENGTH )
{
uxNextTail -= pxBuffer->LENGTH;
}
}
if( pucData != NULL )
{
/* Calculate the number of bytes that can be read - which may be
less than the number wanted if the data wraps around to the start of
the buffer. */
uxFirst = FreeRTOS_min_uint32( pxBuffer->LENGTH - uxNextTail, uxCount );
/* Obtain the number of bytes it is possible to obtain in the first
read. */
memcpy( pucData, pxBuffer->ucArray + uxNextTail, uxFirst );
/* If the total number of wanted bytes is greater than the number
that could be read in the first read... */
if( uxCount > uxFirst )
{
/*...then read the remaining bytes from the start of the buffer. */
memcpy( pucData + uxFirst, pxBuffer->ucArray, uxCount - uxFirst );
}
}
if( ( xPeek == pdFALSE ) && ( uxOffset == 0UL ) )
{
/* Move the tail pointer to effecively remove the data read from
the buffer. */
uxNextTail += uxCount;
if( uxNextTail >= pxBuffer->LENGTH )
{
uxNextTail -= pxBuffer->LENGTH;
}
pxBuffer->uxTail = uxNextTail;
}
}
return uxCount;
}
This diff is collapsed.
This diff is collapsed.
/*
* FreeRTOS+TCP V2.0.11
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* http://aws.amazon.com/freertos
* http://www.FreeRTOS.org
*/
/* Standard includes. */
#include <stdint.h>
#include <stdio.h>
/* FreeRTOS includes. */
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "semphr.h"
/* FreeRTOS+TCP includes. */
#include "FreeRTOS_IP.h"
#include "FreeRTOS_Sockets.h"
#include "FreeRTOS_IP_Private.h"
#include "FreeRTOS_UDP_IP.h"
#include "FreeRTOS_ARP.h"
#include "FreeRTOS_DHCP.h"
#include "NetworkInterface.h"
#include "NetworkBufferManagement.h"
#if( ipconfigUSE_DNS == 1 )
#include "FreeRTOS_DNS.h"
#endif
/* The expected IP version and header length coded into the IP header itself. */
#define ipIP_VERSION_AND_HEADER_LENGTH_BYTE ( ( uint8_t ) 0x45 )
/* Part of the Ethernet and IP headers are always constant when sending an IPv4
UDP packet. This array defines the constant parts, allowing this part of the
packet to be filled in using a simple memcpy() instead of individual writes. */
UDPPacketHeader_t xDefaultPartUDPPacketHeader =
{
/* .ucBytes : */
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* Ethernet source MAC address. */
0x08, 0x00, /* Ethernet frame type. */
ipIP_VERSION_AND_HEADER_LENGTH_BYTE, /* ucVersionHeaderLength. */
0x00, /* ucDifferentiatedServicesCode. */
0x00, 0x00, /* usLength. */
0x00, 0x00, /* usIdentification. */
0x00, 0x00, /* usFragmentOffset. */
ipconfigUDP_TIME_TO_LIVE, /* ucTimeToLive */
ipPROTOCOL_UDP, /* ucProtocol. */
0x00, 0x00, /* usHeaderChecksum. */
0x00, 0x00, 0x00, 0x00 /* Source IP address. */
}
};
/*-----------------------------------------------------------*/
void vProcessGeneratedUDPPacket( NetworkBufferDescriptor_t * const pxNetworkBuffer )
{
UDPPacket_t *pxUDPPacket;
IPHeader_t *pxIPHeader;
eARPLookupResult_t eReturned;
uint32_t ulIPAddress = pxNetworkBuffer->ulIPAddress;
/* Map the UDP packet onto the start of the frame. */
pxUDPPacket = ( UDPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer;
/* Determine the ARP cache status for the requested IP address. */
eReturned = eARPGetCacheEntry( &( ulIPAddress ), &( pxUDPPacket->xEthernetHeader.xDestinationAddress ) );
if( eReturned != eCantSendPacket )
{
if( eReturned == eARPCacheHit )
{
#if( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 0 )
uint8_t ucSocketOptions;
#endif
iptraceSENDING_UDP_PACKET( pxNetworkBuffer->ulIPAddress );
/* Create short cuts to the data within the packet. */
pxIPHeader = &( pxUDPPacket->xIPHeader );
#if ( ipconfigSUPPORT_OUTGOING_PINGS == 1 )
/* Is it possible that the packet is not actually a UDP packet
after all, but an ICMP packet. */
if( pxNetworkBuffer->usPort != ipPACKET_CONTAINS_ICMP_DATA )
#endif /* ipconfigSUPPORT_OUTGOING_PINGS */
{
UDPHeader_t *pxUDPHeader;
pxUDPHeader = &( pxUDPPacket->xUDPHeader );
pxUDPHeader->usDestinationPort = pxNetworkBuffer->usPort;
pxUDPHeader->usSourcePort = pxNetworkBuffer->usBoundPort;
pxUDPHeader->usLength = ( uint16_t ) ( pxNetworkBuffer->xDataLength + sizeof( UDPHeader_t ) );
pxUDPHeader->usLength = FreeRTOS_htons( pxUDPHeader->usLength );
pxUDPHeader->usChecksum = 0u;
}
/* memcpy() the constant parts of the header information into
the correct location within the packet. This fills in:
xEthernetHeader.xSourceAddress
xEthernetHeader.usFrameType
xIPHeader.ucVersionHeaderLength
xIPHeader.ucDifferentiatedServicesCode
xIPHeader.usLength
xIPHeader.usIdentification
xIPHeader.usFragmentOffset
xIPHeader.ucTimeToLive
xIPHeader.ucProtocol
and
xIPHeader.usHeaderChecksum
*/
/* Save options now, as they will be overwritten by memcpy */
#if( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 0 )
ucSocketOptions = pxNetworkBuffer->pucEthernetBuffer[ ipSOCKET_OPTIONS_OFFSET ];
#endif
/*
* Offset the memcpy by the size of a MAC address to start at the packet's
* Ethernet header 'source' MAC address; the preceding 'destination' should not be altered.
*/
char *pxUdpSrcAddrOffset = ( char *) pxUDPPacket + sizeof( MACAddress_t );
memcpy( pxUdpSrcAddrOffset, xDefaultPartUDPPacketHeader.ucBytes, sizeof( xDefaultPartUDPPacketHeader ) );
#if ipconfigSUPPORT_OUTGOING_PINGS == 1
if( pxNetworkBuffer->usPort == ipPACKET_CONTAINS_ICMP_DATA )
{
pxIPHeader->ucProtocol = ipPROTOCOL_ICMP;
pxIPHeader->usLength = ( uint16_t ) ( pxNetworkBuffer->xDataLength + sizeof( IPHeader_t ) );
}
else
#endif /* ipconfigSUPPORT_OUTGOING_PINGS */
{
pxIPHeader->usLength = ( uint16_t ) ( pxNetworkBuffer->xDataLength + sizeof( IPHeader_t ) + sizeof( UDPHeader_t ) );
}
/* The total transmit size adds on the Ethernet header. */
pxNetworkBuffer->xDataLength = pxIPHeader->usLength + sizeof( EthernetHeader_t );
pxIPHeader->usLength = FreeRTOS_htons( pxIPHeader->usLength );
/* HT:endian: changed back to network endian */
pxIPHeader->ulDestinationIPAddress = pxNetworkBuffer->ulIPAddress;
#if( ipconfigUSE_LLMNR == 1 )
{
/* LLMNR messages are typically used on a LAN and they're
* not supposed to cross routers */
if( pxNetworkBuffer->ulIPAddress == ipLLMNR_IP_ADDR )
{
pxIPHeader->ucTimeToLive = 0x01;
}
}
#endif
#if( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 0 )
{
pxIPHeader->usHeaderChecksum = 0u;
pxIPHeader->usHeaderChecksum = usGenerateChecksum( 0UL, ( uint8_t * ) &( pxIPHeader->ucVersionHeaderLength ), ipSIZE_OF_IPv4_HEADER );
pxIPHeader->usHeaderChecksum = ~FreeRTOS_htons( pxIPHeader->usHeaderChecksum );
if( ( ucSocketOptions & ( uint8_t ) FREERTOS_SO_UDPCKSUM_OUT ) != 0u )
{
usGenerateProtocolChecksum( (uint8_t*)pxUDPPacket, pxNetworkBuffer->xDataLength, pdTRUE );
}
else
{
pxUDPPacket->xUDPHeader.usChecksum = 0u;
}
}
#endif
}
else if( eReturned == eARPCacheMiss )
{
/* Add an entry to the ARP table with a null hardware address.
This allows the ARP timer to know that an ARP reply is
outstanding, and perform retransmissions if necessary. */
vARPRefreshCacheEntry( NULL, ulIPAddress );
/* Generate an ARP for the required IP address. */
iptracePACKET_DROPPED_TO_GENERATE_ARP( pxNetworkBuffer->ulIPAddress );
pxNetworkBuffer->ulIPAddress = ulIPAddress;
vARPGenerateRequestPacket( pxNetworkBuffer );
}
else
{
/* The lookup indicated that an ARP request has already been
sent out for the queried IP address. */
eReturned = eCantSendPacket;
}
}
if( eReturned != eCantSendPacket )
{
/* The network driver is responsible for freeing the network buffer
after the packet has been sent. */
#if defined( ipconfigETHERNET_MINIMUM_PACKET_BYTES )
{
if( pxNetworkBuffer->xDataLength < ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES )
{
BaseType_t xIndex;
for( xIndex = ( BaseType_t ) pxNetworkBuffer->xDataLength; xIndex < ( BaseType_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES; xIndex++ )
{
pxNetworkBuffer->pucEthernetBuffer[ xIndex ] = 0u;
}
pxNetworkBuffer->xDataLength = ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES;
}
}
#endif
xNetworkInterfaceOutput( pxNetworkBuffer, pdTRUE );
}
else
{
/* The packet can't be sent (DHCP not completed?). Just drop the
packet. */
vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer );
}
}
/*-----------------------------------------------------------*/
BaseType_t xProcessReceivedUDPPacket( NetworkBufferDescriptor_t *pxNetworkBuffer, uint16_t usPort )
{
BaseType_t xReturn = pdPASS;
FreeRTOS_Socket_t *pxSocket;
UDPPacket_t *pxUDPPacket = (UDPPacket_t *) pxNetworkBuffer->pucEthernetBuffer;
/* Caller must check for minimum packet size. */
pxSocket = pxUDPSocketLookup( usPort );
if( pxSocket )
{
/* When refreshing the ARP cache with received UDP packets we must be
careful; hundreds of broadcast messages may pass and if we're not
handling them, no use to fill the ARP cache with those IP addresses. */
vARPRefreshCacheEntry( &( pxUDPPacket->xEthernetHeader.xSourceAddress ), pxUDPPacket->xIPHeader.ulSourceIPAddress );
#if( ipconfigUSE_CALLBACKS == 1 )
{
/* Did the owner of this socket register a reception handler ? */
if( ipconfigIS_VALID_PROG_ADDRESS( pxSocket->u.xUDP.pxHandleReceive ) )
{
struct freertos_sockaddr xSourceAddress, destinationAddress;
void *pcData = ( void * ) &( pxNetworkBuffer->pucEthernetBuffer[ ipUDP_PAYLOAD_OFFSET_IPv4 ] );
FOnUDPReceive_t xHandler = ( FOnUDPReceive_t ) pxSocket->u.xUDP.pxHandleReceive;
xSourceAddress.sin_port = pxNetworkBuffer->usPort;
xSourceAddress.sin_addr = pxNetworkBuffer->ulIPAddress;
destinationAddress.sin_port = usPort;
destinationAddress.sin_addr = pxUDPPacket->xIPHeader.ulDestinationIPAddress;
if( xHandler( ( Socket_t * ) pxSocket, ( void* ) pcData, ( size_t ) pxNetworkBuffer->xDataLength,
&xSourceAddress, &destinationAddress ) )
{
xReturn = pdFAIL; /* FAIL means that we did not consume or release the buffer */
}
}
}
#endif /* ipconfigUSE_CALLBACKS */
#if( ipconfigUDP_MAX_RX_PACKETS > 0 )
{
if( xReturn == pdPASS )
{
if ( listCURRENT_LIST_LENGTH( &( pxSocket->u.xUDP.xWaitingPacketsList ) ) >= pxSocket->u.xUDP.uxMaxPackets )
{
FreeRTOS_debug_printf( ( "xProcessReceivedUDPPacket: buffer full %ld >= %ld port %u\n",
listCURRENT_LIST_LENGTH( &( pxSocket->u.xUDP.xWaitingPacketsList ) ),
pxSocket->u.xUDP.uxMaxPackets, pxSocket->usLocalPort ) );
xReturn = pdFAIL; /* we did not consume or release the buffer */
}
}
}
#endif
if( xReturn == pdPASS )
{
vTaskSuspendAll();
{
if( xReturn == pdPASS )
{
taskENTER_CRITICAL();
{
/* Add the network packet to the list of packets to be
processed by the socket. */
vListInsertEnd( &( pxSocket->u.xUDP.xWaitingPacketsList ), &( pxNetworkBuffer->xBufferListItem ) );
}
taskEXIT_CRITICAL();
}
}
xTaskResumeAll();
/* Set the socket's receive event */
if( pxSocket->xEventGroup != NULL )
{
xEventGroupSetBits( pxSocket->xEventGroup, eSOCKET_RECEIVE );
}
#if( ipconfigSUPPORT_SELECT_FUNCTION == 1 )
{
if( ( pxSocket->pxSocketSet != NULL ) && ( ( pxSocket->xSelectBits & eSELECT_READ ) != 0 ) )
{
xEventGroupSetBits( pxSocket->pxSocketSet->xSelectGroup, eSELECT_READ );
}
}
#endif
#if( ipconfigSOCKET_HAS_USER_SEMAPHORE == 1 )
{
if( pxSocket->pxUserSemaphore != NULL )
{
xSemaphoreGive( pxSocket->pxUserSemaphore );
}
}
#endif
#if( ipconfigUSE_DHCP == 1 )
{
if( xIsDHCPSocket( pxSocket ) )
{
xSendEventToIPTask( eDHCPEvent );
}
}
#endif
}
}
else
{
/* There is no socket listening to the target port, but still it might
be for this node. */
#if( ipconfigUSE_LLMNR == 1 )
/* a LLMNR request, check for the destination port. */
if( ( usPort == FreeRTOS_ntohs( ipLLMNR_PORT ) ) ||
( pxUDPPacket->xUDPHeader.usSourcePort == FreeRTOS_ntohs( ipLLMNR_PORT ) ) )
{
vARPRefreshCacheEntry( &( pxUDPPacket->xEthernetHeader.xSourceAddress ), pxUDPPacket->xIPHeader.ulSourceIPAddress );
xReturn = ( BaseType_t )ulDNSHandlePacket( pxNetworkBuffer );
}
else
#endif /* ipconfigUSE_LLMNR */
#if( ipconfigUSE_NBNS == 1 )
/* a NetBIOS request, check for the destination port */
if( ( usPort == FreeRTOS_ntohs( ipNBNS_PORT ) ) ||
( pxUDPPacket->xUDPHeader.usSourcePort == FreeRTOS_ntohs( ipNBNS_PORT ) ) )
{
vARPRefreshCacheEntry( &( pxUDPPacket->xEthernetHeader.xSourceAddress ), pxUDPPacket->xIPHeader.ulSourceIPAddress );
xReturn = ( BaseType_t )ulNBNSHandlePacket( pxNetworkBuffer );
}
else
#endif /* ipconfigUSE_NBNS */
{
xReturn = pdFAIL;
}
}
return xReturn;
}
/*-----------------------------------------------------------*/
Changes in V2.0.11
+ Updates some drivers in the portable layer.
Changes between 160919 and 180821 releases:
+ Multiple security improvements and fixes in packet parsing routines, DNS
caching, and TCP sequence number and ID generation.
+ Disable NBNS and LLMNR by default.
+ Add TCP hang protection by default.
We thank Ori Karliner of Zimperium zLabs Team for reporting these issues.
+ Update FreeRTOS_gethostbyname() to allow an IP address to be passed in -
in which case it is just returned as a uint32_t.
+ Introduce ipconfigSOCKET_HAS_USER_WAKE_CALLBACK to FreeRTOS_Sockets.c to
allow a user supposed callback function to be executed when socket events
occur in the same way that the socket semaphore is currently used.
+ Update xNetworkBuffersInitialise() to ensure the semaphore created by the
function is not accessed until after the NULL check.
+ Improve print messages output by the Win32 port layer version of
prvPrintAvailableNetworkInterfaces().
Changes between 160908 and 160919 releases:
+ Add a NULL check before attempting to close the DHCP socket. [Prior to
160823 the IP task closed the DHCP socket by calling a public API function
- which checked for the socket being NULL. This was changed to call a
local private function, which did not have a NULL check, in place of the
public API function.]
+ Various [internal only] naming changes to better comply with the FreeRTOS
naming conventions.
+ Improvements to the Zynq network driver. DMA transmission buffers now use
a counting semaphore. When all TX-buffers are in-use, the IP-task will
block momentarily until a TX-buffer becomes available.
+ Experimental implementation of the TCP window scaling protocol. The
scaling option will always be offered, at least with a factor 1. If the
TCP sliding window size becomes more than 64KB, the factor will increase
automatically.
+ ipconfigETHERNET_MINIMUM_PACKET_BYTES is now applied for every protocol:
TCP, UDP, and ARP.
+ Updated the Zynq project to use BufferAllocation_1.c rather than
BufferAllocation_2.c - which is a requirement with its current
configuration (due to the alignment requirements on the combined cache and
DMA configuration).
Changes between 160823 and 160908 releases:
+ Use ipconfigZERO_COPY_TX_DRIVER as the xReleaseAfterSend() parameter where
prvTCPReturnPacket() is called in prvSendData() to prevent unnecessary
copying of data.
+ Remove the use of the uxGetRxEventCount variable, which was used to give
priority to incoming messages, but could result in the IP task starving
application tasks of processing time.
Changes between 160112 and 160823 releases
NOTE: The 160908 release is a maintenance release for the 160112 single
interface labs release - not a release of the current development branch.
+ Various minor stability enhancements, including the ability to work with
configTICK_RATE_HZ set to less than 1KHz, closing DHCP sockets directly
rather than via FreeRTOS_closesocket(), and better handling of unknown
TCP packets before an IP address has been assigned.
+ ipBUFFER_PADDING is now configurable through the ipconfigBUFFER_PADDING
constant to improve network buffer alignment handling capabilities (expert
users/driver writers only).
+ Multiple improvements to the FTP server, including to how read only and
zero length files are handled.
+ ipconfigFTP_HAS_USER_PROPERTIES_HOOK (to allow each user to have a
different root directory and access rights) and
ipconfigHTTP_HAS_HANDLE_REQUEST_HOOK (to handle AJAX style data)
introduced, although these are not yet fully tested and the constant names
are likely to change.
+ Introduce ipconfigHAS_TX_CRC_OFFLOADING.
+ ipconfigUSE_DHCP_HOOK is now called ipconfigUSE_DHCP_HOOK, and the name
of the callback function has also changed. See the web documentation for
details.
+ ipconfigTCP_RX_BUF_LEN is now ipconfigTCP_RX_BUFFER_LENGTH, and
ipconfigTCP_TX_BUF_LEN is now ipconfigTCP_TX_BUFFER_LENGTH, which is
actually how they have always been documented.
+ Added example TFTP server capable of receiving (not sending) files.
Intended for bootloader type functionality.
+ Various variable name changes for consistency (mainly ensuring UDP, TCP,
DNS, etc. always use the same case letters, and type prefixes are correct).
+ Various minor edits to improve types used by internal variables.
+ Simplified mapping of standard library functions to their Visual Studio
equivalents.
+ Improve robustness of network drivers.
+ Introduce pxResizeNetworkBufferWithDescriptor().
+ Removed obsolete FreeRTOSIPConfig.h constants from
FreeRTOSIPConfigDefaults.h.
+ Added additional asserts() - predominantly to catch incorrect structure
packing.
Changes between 160112 and 160111 releases
+ Updated the STM32 network driver so checksums are calculated by the
hardware.
+ Implemented a simple "quit" command in the TCP command console.
Changes between 150825 and 160111 releases
+ New device support: Demo applications and example drivers are provided
for Atmel SAM4E and ST STM32F4 microcontrollers.
+ Various updates to improve compliance with the FreeRTOS coding standard.
+ Added a command console example that uses TCP/IP for input and output (the
pre-existing command console example uses UDP/IP).
+ Updated the UDP logging example so it will send log messages to the local
UDP broadcast address if a specific IP address is not provided. This
simplifies configuration, but note not all switches and routers will pass
broadcast messages.
+ Add TCP echo client and TCP echo server examples to the Zynq demo.
+ Minor updates to the Zynq network driver.
+ Update the Zynq project to use version 2015.4 of the Xilinx SDK.
+ Introduce FreeRTOS_SignalSocket(), which can be used to interrupt a task
that is blocked while reading from a socket ( FreeRTOS_recv[from] ).
+ Make use of FreeRTOS_SignalSocket() in the FTP and HTTP servers.
+ Major updates to the NTP client, although this is not included in any of
the pre-configured demo applications yet.
+ Added support for DHCP zero pad option.
+ Added uxGetMinimumIPQueueSpace(), a function to monitor the minimum amount
of space on the message queue.
+ Better handling of zero length files in the FTP server.
+ Fixed a bug reported by Andrey Ivanov from swissEmbedded that affects
users of 'ipconfigZERO_COPY_TX_DRIVER'.
Changes between 150825 150825 (?)
+ Added xApplicationDHCPUserHook() so a user defined hook will be
called at certain points in the DHCP process if
ipconfigDHCP_USES_USER_HOOK is set to 1.
+ Added FreeRTOS_get_tx_head() to improve TCP zero copy behaviour - for
expert use only.
+ RST is no longer sent if only the ACK flag is set.
+ Previously, an immediate ACK was only sent when buffer space was
exhausted. Now, to improve performance, it is possible to send an
immediate ACK earlier - dependent on the ipconfigTCP_ACK_EARLIER_PACKET
setting.
+ LLMNR and NBNS requests can now be sent to locate other devices -
previously these protocols would only be replied to, not generated.
+ Added Auto-IP functionality (still in test) in case DHCP fails. Dependent
on the ipconfigDHCP_FALL_BACK_LINK_LAYER_ADDRESS and
ipconfigARP_USE_CLASH_DETECTION settings.
+ Added NTP code and demo.
+ FTP can now STOR and RETR zero-length files.
+ Added LLMNR demo to Win32 demo - so now the Win32 responds to
"ping RTOSDemo".
Changes between 141019 and 150825
+ Added FTP server, which uses the new FreeRTOS+FAT component.
+ Added basic HTTP server, which uses the new FreeRTOS+FAT component.
+ Multiple definitions that are now common with FreeRTOS+FAT have been moved
into FreeRTOS's ProjDefs.h header file, and so prefixed with 'pd'.
+ Introduced ipconfigZERO_COPY_TX_DRIVER, which defines who is responsible
for freeing a buffer sent to to the MAC driver for transmission, and
facilitates the development of zero copy drivers.
+ Introduced the FREERTOS_MSG_DONTWAIT flag. The flag can be used as a
simpler and faster alternative to using FreeRTOS_setsockopt() to set the
send or receive timeout to 0.
+ A few functions that were previously all lower case are now mixed case, as
lower case function names are only used when they are equivalent to a
a Berkeley sockets API function of the same name.
+ Introduced uxGetMinimumFreeNetworkBuffers() to return the minimum number
of network buffers that have ever existed since the application started
executing.
+ Introduce ipconfigETHERNET_MINIMUM_PACKET_BYTES to allow the application
writer to set their own minimum buffer size should the hardware not be
capable of padding under-sized Ethernet frames.
+ vNetworkBufferRelease() renamed vReleaseNetworkBuffer() - just for
consistency with the names of other functions in the same file.
+ Grouped DHCP status data into a structure.
+ DHCP is now tried both with and without the broadcast flag.
+ Replaced occurrences of configASSERT_VOID() with configASSERT().
+ ipconfigDNS_USE_CALLBACKS introduced to allow FreeRTOS_gethostbyname() to
be used without blocking.
+ Fix: LLMNR and NBNS behaviour when the reply is in a larger buffer than the
request, and BufferAllocation_2 was used.
+ Introduced ipMAX_IP_TASK_SLEEP_TIME to allow the application writer to
override the default value of 10 seconds.
+ Fix: Correct error in *pxUDPPayloadBuffer_to_NetworkBuffer().
+ FreeRTOS_recv() now recognises the FREERTOS_ZERO_COPY flag, which, when
set, the void *pvBuffer parameter is interpreted as void **pvBuffer.
+ FreeRTOS_listen() now returns an error code. Previously it always
returned 0.
+ Fix: Previously if a listening socket was reused, and a connection
failed, the TCP/IP stack closed the socket, now the socket is correctly
left unclosed as it is owned by the application.
+ Various other formatting and minor fix alterations.
\ No newline at end of file
FreeRTOS+TCP is released under the following MIT license.
Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
[{000214A0-0000-0000-C000-000000000046}]
Prop3=19,2
[InternetShortcut]
URL=http://www.freertos.org/tcp
IDList=
/*
* FreeRTOS+TCP V2.0.11
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* http://aws.amazon.com/freertos
* http://www.FreeRTOS.org
*/
#ifndef FREERTOS_ARP_H
#define FREERTOS_ARP_H
#ifdef __cplusplus
extern "C" {
#endif
/* Application level configuration options. */
#include "FreeRTOSIPConfig.h"
#include "FreeRTOSIPConfigDefaults.h"
#include "IPTraceMacroDefaults.h"
/*-----------------------------------------------------------*/
/* Miscellaneous structure and definitions. */
/*-----------------------------------------------------------*/
typedef struct xARP_CACHE_TABLE_ROW
{
uint32_t ulIPAddress; /* The IP address of an ARP cache entry. */
MACAddress_t xMACAddress; /* The MAC address of an ARP cache entry. */
uint8_t ucAge; /* A value that is periodically decremented but can also be refreshed by active communication. The ARP cache entry is removed if the value reaches zero. */
uint8_t ucValid; /* pdTRUE: xMACAddress is valid, pdFALSE: waiting for ARP reply */
} ARPCacheRow_t;
typedef enum
{
eARPCacheMiss = 0, /* 0 An ARP table lookup did not find a valid entry. */
eARPCacheHit, /* 1 An ARP table lookup found a valid entry. */
eCantSendPacket /* 2 There is no IP address, or an ARP is still in progress, so the packet cannot be sent. */
} eARPLookupResult_t;
typedef enum
{
eNotFragment = 0, /* The IP packet being sent is not part of a fragment. */
eFirstFragment, /* The IP packet being sent is the first in a set of fragmented packets. */
eFollowingFragment /* The IP packet being sent is part of a set of fragmented packets. */
} eIPFragmentStatus_t;
/*
* If ulIPAddress is already in the ARP cache table then reset the age of the
* entry back to its maximum value. If ulIPAddress is not already in the ARP
* cache table then add it - replacing the oldest current entry if there is not
* a free space available.
*/
void vARPRefreshCacheEntry( const MACAddress_t * pxMACAddress, const uint32_t ulIPAddress );
#if( ipconfigARP_USE_CLASH_DETECTION != 0 )
/* Becomes non-zero if another device responded to a gratuitos ARP message. */
extern BaseType_t xARPHadIPClash;
/* MAC-address of the other device containing the same IP-address. */
extern MACAddress_t xARPClashMacAddress;
#endif /* ipconfigARP_USE_CLASH_DETECTION */
#if( ipconfigUSE_ARP_REMOVE_ENTRY != 0 )
/*
* In some rare cases, it might be useful to remove a ARP cache entry of a
* known MAC address to make sure it gets refreshed.
*/
uint32_t ulARPRemoveCacheEntryByMac( const MACAddress_t * pxMACAddress );
#endif /* ipconfigUSE_ARP_REMOVE_ENTRY != 0 */
/*
* Look for ulIPAddress in the ARP cache. If the IP address exists, copy the
* associated MAC address into pxMACAddress, refresh the ARP cache entry's
* age, and return eARPCacheHit. If the IP address does not exist in the ARP
* cache return eARPCacheMiss. If the packet cannot be sent for any reason
* (maybe DHCP is still in process, or the addressing needs a gateway but there
* isn't a gateway defined) then return eCantSendPacket.
*/
eARPLookupResult_t eARPGetCacheEntry( uint32_t *pulIPAddress, MACAddress_t * const pxMACAddress );
#if( ipconfigUSE_ARP_REVERSED_LOOKUP != 0 )
/* Lookup an IP-address if only the MAC-address is known */
eARPLookupResult_t eARPGetCacheEntryByMac( MACAddress_t * const pxMACAddress, uint32_t *pulIPAddress );
#endif
/*
* Reduce the age count in each entry within the ARP cache. An entry is no
* longer considered valid and is deleted if its age reaches zero.
*/
void vARPAgeCache( void );
/*
* Send out an ARP request for the IP address contained in pxNetworkBuffer, and
* add an entry into the ARP table that indicates that an ARP reply is
* outstanding so re-transmissions can be generated.
*/
void vARPGenerateRequestPacket( NetworkBufferDescriptor_t * const pxNetworkBuffer );
/*
* After DHCP is ready and when changing IP address, force a quick send of our new IP
* address
*/
void vARPSendGratuitous( void );
#ifdef __cplusplus
} // extern "C"
#endif
#endif /* FREERTOS_ARP_H */
/*
* FreeRTOS+TCP V2.0.11
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* http://aws.amazon.com/freertos
* http://www.FreeRTOS.org
*/
#ifndef FREERTOS_DHCP_H
#define FREERTOS_DHCP_H
#ifdef __cplusplus
extern "C" {
#endif
/* Application level configuration options. */
#include "FreeRTOSIPConfig.h"
#include "IPTraceMacroDefaults.h"
/* Used in the DHCP callback if ipconfigUSE_DHCP_HOOK is set to 1. */
typedef enum eDHCP_PHASE
{
eDHCPPhasePreDiscover, /* Driver is about to send a DHCP discovery. */
eDHCPPhasePreRequest, /* Driver is about to request DHCP an IP address. */
#if( ipconfigDHCP_SEND_DISCOVER_AFTER_AUTO_IP != 0 )
eDHCPPhasePreLLA, /* Driver is about to try get an LLA address */
#endif /* ipconfigDHCP_SEND_DISCOVER_AFTER_AUTO_IP */
} eDHCPCallbackPhase_t;
/* Used in the DHCP callback if ipconfigUSE_DHCP_HOOK is set to 1. */
typedef enum eDHCP_ANSWERS
{
eDHCPContinue, /* Continue the DHCP process */
eDHCPUseDefaults, /* Stop DHCP and use the static defaults. */
eDHCPStopNoChanges, /* Stop DHCP and continue with current settings. */
} eDHCPCallbackAnswer_t;
/*
* NOT A PUBLIC API FUNCTION.
*/
void vDHCPProcess( BaseType_t xReset );
/* Internal call: returns true if socket is the current DHCP socket */
BaseType_t xIsDHCPSocket( Socket_t xSocket );
/* Prototype of the hook (or callback) function that must be provided by the
application if ipconfigUSE_DHCP_HOOK is set to 1. See the following URL for
usage information:
http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_IP_Configuration.html#ipconfigUSE_DHCP_HOOK
*/
eDHCPCallbackAnswer_t xApplicationDHCPHook( eDHCPCallbackPhase_t eDHCPPhase, uint32_t ulIPAddress );
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* FREERTOS_DHCP_H */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment