mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-10-17 10:17:45 -04:00
Sync with a:FR (#75)
* AFR sync * AFR sync: CBMC * AFR sync: CBMC: remove .bak files * AFR sync: CBMC: more cleanup * Corrected CBMC proofs * Corrected CBMC patches * Corrected CBMC patches-1 * Corrected CBMC patches-2 * remove .bak files (3) Co-authored-by: Yuhui Zheng <10982575+yuhui-zheng@users.noreply.github.com>
This commit is contained in:
parent
6557291e54
commit
cb7edd2323
99 changed files with 6475 additions and 4241 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* FreeRTOS+TCP V2.2.0
|
||||
* FreeRTOS+TCP V2.2.1
|
||||
* 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
|
||||
|
@ -157,7 +157,7 @@ from the FreeRTOSIPConfig.h configuration header file. */
|
|||
* This macro will only be used if FreeRTOS_debug_printf() is defined for logging
|
||||
*/
|
||||
#ifndef ipconfigTCP_MAY_LOG_PORT
|
||||
#define ipconfigTCP_MAY_LOG_PORT(xPort) ( ( xPort ) != 23u )
|
||||
#define ipconfigTCP_MAY_LOG_PORT(xPort) ( ( xPort ) != 23U )
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -171,11 +171,11 @@ from the FreeRTOSIPConfig.h configuration header file. */
|
|||
|
||||
|
||||
#ifndef ipconfigDNS_RECEIVE_BLOCK_TIME_TICKS
|
||||
#define ipconfigDNS_RECEIVE_BLOCK_TIME_TICKS pdMS_TO_TICKS( 500u )
|
||||
#define ipconfigDNS_RECEIVE_BLOCK_TIME_TICKS pdMS_TO_TICKS( 5000U )
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigDNS_SEND_BLOCK_TIME_TICKS
|
||||
#define ipconfigDNS_SEND_BLOCK_TIME_TICKS pdMS_TO_TICKS( 500u )
|
||||
#define ipconfigDNS_SEND_BLOCK_TIME_TICKS pdMS_TO_TICKS( 500U )
|
||||
#endif
|
||||
/*
|
||||
* FreeRTOS debug logging routine (proposal)
|
||||
|
@ -196,7 +196,7 @@ from the FreeRTOSIPConfig.h configuration header file. */
|
|||
#endif /* ifdef ipconfigHAS_DEBUG_PRINTF */
|
||||
|
||||
#ifndef FreeRTOS_debug_printf
|
||||
#define FreeRTOS_debug_printf( MSG ) do{} while(0)
|
||||
#define FreeRTOS_debug_printf( MSG ) do{} while( ipFALSE_BOOL )
|
||||
#define ipconfigHAS_DEBUG_PRINTF 0
|
||||
#endif
|
||||
|
||||
|
@ -217,7 +217,7 @@ from the FreeRTOSIPConfig.h configuration header file. */
|
|||
#endif /* ifdef ipconfigHAS_PRINTF */
|
||||
|
||||
#ifndef FreeRTOS_printf
|
||||
#define FreeRTOS_printf( MSG ) do{} while(0)
|
||||
#define FreeRTOS_printf( MSG ) do{} while( ipFALSE_BOOL )
|
||||
#define ipconfigHAS_PRINTF 0
|
||||
#endif
|
||||
|
||||
|
@ -227,7 +227,7 @@ from the FreeRTOSIPConfig.h configuration header file. */
|
|||
* An example of this is the netstat command, which produces many lines of logging
|
||||
*/
|
||||
#ifndef FreeRTOS_flush_logging
|
||||
#define FreeRTOS_flush_logging( ) do{} while(0)
|
||||
#define FreeRTOS_flush_logging( ) do{} while( ipFALSE_BOOL )
|
||||
#endif
|
||||
|
||||
/* Malloc functions. Within most applications of FreeRTOS, the couple
|
||||
|
@ -274,7 +274,7 @@ from the FreeRTOSIPConfig.h configuration header file. */
|
|||
#endif
|
||||
|
||||
#ifndef ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS
|
||||
#define ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS ( pdMS_TO_TICKS( 20 ) )
|
||||
#define ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS ( pdMS_TO_TICKS( 20U ) )
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigARP_CACHE_ENTRIES
|
||||
|
@ -282,11 +282,11 @@ from the FreeRTOSIPConfig.h configuration header file. */
|
|||
#endif
|
||||
|
||||
#ifndef ipconfigMAX_ARP_RETRANSMISSIONS
|
||||
#define ipconfigMAX_ARP_RETRANSMISSIONS ( 5u )
|
||||
#define ipconfigMAX_ARP_RETRANSMISSIONS ( 5U )
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigMAX_ARP_AGE
|
||||
#define ipconfigMAX_ARP_AGE 150u
|
||||
#define ipconfigMAX_ARP_AGE 150U
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigUSE_ARP_REVERSED_LOOKUP
|
||||
|
@ -301,6 +301,10 @@ from the FreeRTOSIPConfig.h configuration header file. */
|
|||
#define ipconfigINCLUDE_FULL_INET_ADDR 1
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigUSE_LINKED_RX_MESSAGES
|
||||
#define ipconfigUSE_LINKED_RX_MESSAGES 0
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS
|
||||
#define ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS 45
|
||||
#endif
|
||||
|
@ -326,7 +330,7 @@ from the FreeRTOSIPConfig.h configuration header file. */
|
|||
* for each UDP socket.
|
||||
* Can be overridden with the socket option FREERTOS_SO_UDP_MAX_RX_PACKETS
|
||||
*/
|
||||
#define ipconfigUDP_MAX_RX_PACKETS 0u
|
||||
#define ipconfigUDP_MAX_RX_PACKETS 0U
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigUSE_DHCP
|
||||
|
@ -359,7 +363,7 @@ from the FreeRTOSIPConfig.h configuration header file. */
|
|||
#endif
|
||||
|
||||
#ifndef ipconfigTCP_MSS
|
||||
#define ipconfigTCP_MSS ( ipconfigNETWORK_MTU - ipSIZE_OF_IPv4_HEADER - ipSIZE_OF_TCP_HEADER )
|
||||
#define ipconfigTCP_MSS ( ipconfigNETWORK_MTU - ( ipSIZE_OF_IPv4_HEADER + ipSIZE_OF_TCP_HEADER ) )
|
||||
#endif
|
||||
|
||||
/* Each TCP socket has circular stream buffers for Rx and Tx, which
|
||||
|
@ -367,19 +371,19 @@ from the FreeRTOSIPConfig.h configuration header file. */
|
|||
* The defaults for these size are defined here, although
|
||||
* they can be overridden at runtime by using the setsockopt() call */
|
||||
#ifndef ipconfigTCP_RX_BUFFER_LENGTH
|
||||
#define ipconfigTCP_RX_BUFFER_LENGTH ( 4u * ipconfigTCP_MSS ) /* defaults to 5840 bytes */
|
||||
#define ipconfigTCP_RX_BUFFER_LENGTH ( 4U * ipconfigTCP_MSS ) /* defaults to 5840 bytes */
|
||||
#endif
|
||||
|
||||
/* Define the size of Tx stream buffer for TCP sockets */
|
||||
#ifndef ipconfigTCP_TX_BUFFER_LENGTH
|
||||
# define ipconfigTCP_TX_BUFFER_LENGTH ( 4u * ipconfigTCP_MSS ) /* defaults to 5840 bytes */
|
||||
# define ipconfigTCP_TX_BUFFER_LENGTH ( 4U * ipconfigTCP_MSS ) /* defaults to 5840 bytes */
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigMAXIMUM_DISCOVER_TX_PERIOD
|
||||
#ifdef _WINDOWS_
|
||||
#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD ( pdMS_TO_TICKS( 999 ) )
|
||||
#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD ( pdMS_TO_TICKS( 999U ) )
|
||||
#else
|
||||
#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD ( pdMS_TO_TICKS( 30000 ) )
|
||||
#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD ( pdMS_TO_TICKS( 30000U ) )
|
||||
#endif /* _WINDOWS_ */
|
||||
#endif /* ipconfigMAXIMUM_DISCOVER_TX_PERIOD */
|
||||
|
||||
|
@ -413,8 +417,16 @@ from the FreeRTOSIPConfig.h configuration header file. */
|
|||
#ifndef ipconfigDNS_CACHE_ENTRIES
|
||||
#define ipconfigDNS_CACHE_ENTRIES 1
|
||||
#endif
|
||||
|
||||
#endif /* ipconfigUSE_DNS_CACHE != 0 */
|
||||
|
||||
/* When accessing services which have multiple IP addresses, setting this
|
||||
greater than 1 can improve reliability by returning different IP address
|
||||
answers on successive calls to FreeRTOS_gethostbyname(). */
|
||||
#ifndef ipconfigDNS_CACHE_ADDRESSES_PER_ENTRY
|
||||
#define ipconfigDNS_CACHE_ADDRESSES_PER_ENTRY 1
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigCHECK_IP_QUEUE_SPACE
|
||||
#define ipconfigCHECK_IP_QUEUE_SPACE 0
|
||||
#endif
|
||||
|
@ -544,7 +556,7 @@ connections, hang protection can help reduce the impact of SYN floods. */
|
|||
|
||||
/* Non-activity timeout is expressed in seconds. */
|
||||
#ifndef ipconfigTCP_HANG_PROTECTION_TIME
|
||||
#define ipconfigTCP_HANG_PROTECTION_TIME 30
|
||||
#define ipconfigTCP_HANG_PROTECTION_TIME 30U
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigTCP_IP_SANITY
|
||||
|
@ -559,11 +571,15 @@ connections, hang protection can help reduce the impact of SYN floods. */
|
|||
/* Expert option: define a value for 'ipBUFFER_PADDING'.
|
||||
When 'ipconfigBUFFER_PADDING' equals 0,
|
||||
'ipBUFFER_PADDING' will get a default value of 8 + 2 bytes. */
|
||||
#define ipconfigBUFFER_PADDING 0
|
||||
#define ipconfigBUFFER_PADDING 0U
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigPACKET_FILLER_SIZE
|
||||
#define ipconfigPACKET_FILLER_SIZE 2
|
||||
#define ipconfigPACKET_FILLER_SIZE 2U
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigSELECT_USES_NOTIFY
|
||||
#define ipconfigSELECT_USES_NOTIFY 0
|
||||
#endif
|
||||
|
||||
#endif /* FREERTOS_DEFAULT_IP_CONFIG_H */
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* FreeRTOS+TCP V2.2.0
|
||||
* FreeRTOS+TCP V2.2.1
|
||||
* 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
|
||||
|
@ -42,7 +42,7 @@ extern "C" {
|
|||
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. */
|
||||
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;
|
||||
|
@ -54,13 +54,6 @@ typedef enum
|
|||
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
|
||||
|
@ -121,6 +114,23 @@ void vARPGenerateRequestPacket( NetworkBufferDescriptor_t * const pxNetworkBuffe
|
|||
*/
|
||||
void vARPSendGratuitous( void );
|
||||
|
||||
/* This function will check if the target IP-address belongs to this device.
|
||||
If so, the packet will be passed to the IP-stack, who will answer it.
|
||||
The function is to be called within the function xNetworkInterfaceOutput()
|
||||
in NetworkInterface.c as follows:
|
||||
|
||||
if( xCheckLoopback( pxDescriptor, bReleaseAfterSend ) != 0 )
|
||||
{
|
||||
/ * The packet has been sent back to the IP-task.
|
||||
* The IP-task will further handle it.
|
||||
* Do not release the descriptor.
|
||||
* /
|
||||
return pdTRUE;
|
||||
}
|
||||
/ * Send the packet as usual. * /
|
||||
*/
|
||||
BaseType_t xCheckLoopback( NetworkBufferDescriptor_t * const pxDescriptor, BaseType_t bReleaseAfterSend );
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* FreeRTOS+TCP V2.2.0
|
||||
* FreeRTOS+TCP V2.2.1
|
||||
* 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
|
||||
|
@ -34,23 +34,53 @@ extern "C" {
|
|||
#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;
|
||||
#if( ipconfigUSE_DHCP_HOOK != 0 )
|
||||
/* 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. */
|
||||
} eDHCPCallbackPhase_t;
|
||||
|
||||
/* Used in the DHCP callback if ipconfigUSE_DHCP_HOOK is set to 1. */
|
||||
typedef enum eDHCP_ANSWERS
|
||||
/* 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;
|
||||
#endif /* #if( ipconfigUSE_DHCP_HOOK != 0 ) */
|
||||
|
||||
/* DHCP state machine states. */
|
||||
typedef enum
|
||||
{
|
||||
eDHCPContinue, /* Continue the DHCP process */
|
||||
eDHCPUseDefaults, /* Stop DHCP and use the static defaults. */
|
||||
eDHCPStopNoChanges, /* Stop DHCP and continue with current settings. */
|
||||
} eDHCPCallbackAnswer_t;
|
||||
eWaitingSendFirstDiscover = 0, /* Initial state. Send a discover the first time it is called, and reset all timers. */
|
||||
eWaitingOffer, /* Either resend the discover, or, if the offer is forthcoming, send a request. */
|
||||
eWaitingAcknowledge, /* Either resend the request. */
|
||||
#if( ipconfigDHCP_FALL_BACK_AUTO_IP != 0 )
|
||||
eGetLinkLayerAddress, /* When DHCP didn't respond, try to obtain a LinkLayer address 168.254.x.x. */
|
||||
#endif
|
||||
eLeasedAddress, /* Resend the request at the appropriate time to renew the lease. */
|
||||
eNotUsingLeasedAddress /* DHCP failed, and a default IP address is being used. */
|
||||
} eDHCPState_t;
|
||||
|
||||
/* Hold information in between steps in the DHCP state machine. */
|
||||
struct xDHCP_DATA
|
||||
{
|
||||
uint32_t ulTransactionId;
|
||||
uint32_t ulOfferedIPAddress;
|
||||
uint32_t ulDHCPServerAddress;
|
||||
uint32_t ulLeaseTime;
|
||||
/* Hold information on the current timer state. */
|
||||
TickType_t xDHCPTxTime;
|
||||
TickType_t xDHCPTxPeriod;
|
||||
/* Try both without and with the broadcast flag */
|
||||
BaseType_t xUseBroadcast;
|
||||
/* Maintains the DHCP state machine state. */
|
||||
eDHCPState_t eDHCPState;
|
||||
};
|
||||
|
||||
typedef struct xDHCP_DATA DHCPData_t;
|
||||
|
||||
/*
|
||||
* NOT A PUBLIC API FUNCTION.
|
||||
|
@ -60,12 +90,14 @@ 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 );
|
||||
#if( ipconfigUSE_DHCP_HOOK != 0 )
|
||||
/* 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 );
|
||||
#endif /* ( ipconfigUSE_DHCP_HOOK != 0 ) */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* FreeRTOS+TCP V2.2.0
|
||||
* FreeRTOS+TCP V2.2.1
|
||||
* 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
|
||||
|
@ -43,9 +43,9 @@ extern "C" {
|
|||
* The target IP address will be 224.0.0.252
|
||||
*/
|
||||
#if( ipconfigBYTE_ORDER == pdFREERTOS_BIG_ENDIAN )
|
||||
#define ipLLMNR_IP_ADDR 0xE00000FC
|
||||
#define ipLLMNR_IP_ADDR 0xE00000FCUL
|
||||
#else
|
||||
#define ipLLMNR_IP_ADDR 0xFC0000E0
|
||||
#define ipLLMNR_IP_ADDR 0xFC0000E0UL
|
||||
#endif /* ipconfigBYTE_ORDER == pdFREERTOS_BIG_ENDIAN */
|
||||
|
||||
#define ipLLMNR_PORT 5355 /* Standard LLMNR port. */
|
||||
|
@ -55,18 +55,21 @@ extern "C" {
|
|||
#define ipNBNS_PORT 137 /* NetBIOS Name Service. */
|
||||
#define ipNBDGM_PORT 138 /* Datagram Service, not included. */
|
||||
|
||||
/*
|
||||
* The following function should be provided by the user and return true if it
|
||||
* matches the domain name.
|
||||
*/
|
||||
extern BaseType_t xApplicationDNSQueryHook( const char *pcName );
|
||||
#if( ipconfigUSE_LLMNR == 1 ) || ( ipconfigUSE_NBNS == 1 )
|
||||
/*
|
||||
* The following function should be provided by the user and return true if it
|
||||
* matches the domain name.
|
||||
*/
|
||||
extern BaseType_t xApplicationDNSQueryHook( const char *pcName );
|
||||
#endif /* ( ipconfigUSE_LLMNR == 1 ) || ( ipconfigUSE_NBNS == 1 ) */
|
||||
|
||||
/*
|
||||
* LLMNR is very similar to DNS, so is handled by the DNS routines.
|
||||
*/
|
||||
uint32_t ulDNSHandlePacket( NetworkBufferDescriptor_t *pxNetworkBuffer );
|
||||
uint32_t ulDNSHandlePacket( const NetworkBufferDescriptor_t *pxNetworkBuffer );
|
||||
|
||||
#if( ipconfigUSE_LLMNR == 1 )
|
||||
/* The LLMNR MAC address is 01:00:5e:00:00:fc */
|
||||
extern const MACAddress_t xLLMNR_MacAdress;
|
||||
#endif /* ipconfigUSE_LLMNR */
|
||||
|
||||
|
@ -84,12 +87,13 @@ uint32_t ulDNSHandlePacket( NetworkBufferDescriptor_t *pxNetworkBuffer );
|
|||
|
||||
#if( ipconfigUSE_DNS_CACHE != 0 )
|
||||
|
||||
/* Look for the indicated host name in the DNS cache. Returns the IPv4
|
||||
address if present, or 0x0 otherwise. */
|
||||
/* Look for the indicated host name in the DNS cache. Returns the IPv4
|
||||
address if present, or 0x0 otherwise. */
|
||||
uint32_t FreeRTOS_dnslookup( const char *pcHostName );
|
||||
|
||||
/* Remove all entries from the DNS cache. */
|
||||
void FreeRTOS_dnsclear();
|
||||
/* Remove all entries from the DNS cache. */
|
||||
void FreeRTOS_dnsclear( void );
|
||||
|
||||
#endif /* ipconfigUSE_DNS_CACHE != 0 */
|
||||
|
||||
#if( ipconfigDNS_USE_CALLBACKS != 0 )
|
||||
|
@ -104,18 +108,33 @@ uint32_t ulDNSHandlePacket( NetworkBufferDescriptor_t *pxNetworkBuffer );
|
|||
* Asynchronous version of gethostbyname()
|
||||
* xTimeout is in units of ms.
|
||||
*/
|
||||
uint32_t FreeRTOS_gethostbyname_a( const char *pcHostName, FOnDNSEvent pCallback, void *pvSearchID, TickType_t xTimeout );
|
||||
uint32_t FreeRTOS_gethostbyname_a( const char *pcHostName, FOnDNSEvent pCallback, void *pvSearchID, TickType_t uxTimeout );
|
||||
void FreeRTOS_gethostbyname_cancel( void *pvSearchID );
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* FULL, UP-TO-DATE AND MAINTAINED REFERENCE DOCUMENTATION FOR ALL THESE
|
||||
* FUNCTIONS IS AVAILABLE ON THE FOLLOWING URL:
|
||||
* _TBD_ Add URL
|
||||
* Lookup a IPv4 node in a blocking-way.
|
||||
* It returns a 32-bit IP-address, 0 when not found.
|
||||
* gethostbyname() is already deprecated.
|
||||
*/
|
||||
uint32_t FreeRTOS_gethostbyname( const char *pcHostName );
|
||||
|
||||
#if( ipconfigDNS_USE_CALLBACKS == 1 )
|
||||
/*
|
||||
* The function vDNSInitialise() initialises the DNS module.
|
||||
* It will be called "internally", by the IP-task.
|
||||
*/
|
||||
void vDNSInitialise( void );
|
||||
#endif /* ( ipconfigDNS_USE_CALLBACKS == 1 ) */
|
||||
|
||||
#if( ipconfigDNS_USE_CALLBACKS == 1 )
|
||||
/*
|
||||
* A function local to the library.
|
||||
*/
|
||||
extern void vDNSCheckCallBack( void *pvSearchID );
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* FreeRTOS+TCP V2.2.0
|
||||
* FreeRTOS+TCP V2.2.1
|
||||
* 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
|
||||
|
@ -30,36 +30,73 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
|
||||
/* Application level configuration options. */
|
||||
#include "FreeRTOSIPConfig.h"
|
||||
#include "FreeRTOSIPConfigDefaults.h"
|
||||
#include "IPTraceMacroDefaults.h"
|
||||
|
||||
/* Some constants defining the sizes of several parts of a packet */
|
||||
#define ipSIZE_OF_ETH_HEADER 14u
|
||||
#define ipSIZE_OF_IPv4_HEADER 20u
|
||||
#define ipSIZE_OF_IGMP_HEADER 8u
|
||||
#define ipSIZE_OF_ICMP_HEADER 8u
|
||||
#define ipSIZE_OF_UDP_HEADER 8u
|
||||
#define ipSIZE_OF_TCP_HEADER 20u
|
||||
#ifdef __COVERITY__
|
||||
/* Coverity static checks don't like inlined functions.
|
||||
As it is up to the users to allow inlining, don't let
|
||||
let Coverity know about it. */
|
||||
|
||||
#ifdef portINLINE
|
||||
/* coverity[misra_c_2012_rule_20_5_violation] */
|
||||
/* The usage of #undef violates the rule. */
|
||||
#undef portINLINE
|
||||
|
||||
#endif
|
||||
|
||||
#define portINLINE
|
||||
#endif
|
||||
|
||||
/* Some constants defining the sizes of several parts of a packet.
|
||||
These defines come before inlucding the configuration header files. */
|
||||
/* The size of the Ethernet header is 14, meaning that 802.1Q VLAN tags
|
||||
are not ( yet ) supported. */
|
||||
#define ipSIZE_OF_ETH_HEADER 14U
|
||||
#define ipSIZE_OF_IPv4_HEADER 20U
|
||||
#define ipSIZE_OF_IGMP_HEADER 8U
|
||||
#define ipSIZE_OF_ICMP_HEADER 8U
|
||||
#define ipSIZE_OF_UDP_HEADER 8U
|
||||
#define ipSIZE_OF_TCP_HEADER 20U
|
||||
|
||||
#define ipSIZE_OF_IPv4_ADDRESS 4U
|
||||
|
||||
/*
|
||||
* Generate a randomized TCP Initial Sequence Number per RFC.
|
||||
* This function must be provided by the application builder.
|
||||
*/
|
||||
/* coverity[misra_c_2012_rule_8_6_violation] */
|
||||
/* "ulApplicationGetNextSequenceNumber" is declared but never defined. */
|
||||
extern uint32_t ulApplicationGetNextSequenceNumber( uint32_t ulSourceAddress,
|
||||
uint16_t usSourcePort,
|
||||
uint32_t ulDestinationAddress,
|
||||
uint16_t usDestinationPort );
|
||||
|
||||
/* The number of octets in the MAC and IP addresses respectively. */
|
||||
#define ipMAC_ADDRESS_LENGTH_BYTES ( 6 )
|
||||
#define ipIP_ADDRESS_LENGTH_BYTES ( 4 )
|
||||
|
||||
/* IP protocol definitions. */
|
||||
#define ipPROTOCOL_ICMP ( 1 )
|
||||
#define ipPROTOCOL_IGMP ( 2 )
|
||||
#define ipPROTOCOL_TCP ( 6 )
|
||||
#define ipPROTOCOL_UDP ( 17 )
|
||||
#define ipPROTOCOL_ICMP ( 1U )
|
||||
#define ipPROTOCOL_IGMP ( 2U )
|
||||
#define ipPROTOCOL_TCP ( 6U )
|
||||
#define ipPROTOCOL_UDP ( 17U )
|
||||
|
||||
/* The character used to fill ICMP echo requests, and therefore also the
|
||||
character expected to fill ICMP echo replies. */
|
||||
#define ipECHO_DATA_FILL_BYTE 'x'
|
||||
|
||||
/* Dimensions the buffers that are filled by received Ethernet frames. */
|
||||
#define ipSIZE_OF_ETH_CRC_BYTES ( 4UL )
|
||||
#define ipSIZE_OF_ETH_OPTIONAL_802_1Q_TAG_BYTES ( 4UL )
|
||||
#define ipTOTAL_ETHERNET_FRAME_SIZE ( ( ( uint32_t ) ipconfigNETWORK_MTU ) + ( ( uint32_t ) ipSIZE_OF_ETH_HEADER ) + ipSIZE_OF_ETH_CRC_BYTES + ipSIZE_OF_ETH_OPTIONAL_802_1Q_TAG_BYTES )
|
||||
|
||||
/*_RB_ Comment may need updating. */
|
||||
|
||||
/* Space left at the beginning of a network buffer storage area to store a
|
||||
pointer back to the network buffer. Should be a multiple of 8 to ensure 8 byte
|
||||
alignment is maintained on architectures that require it.
|
||||
|
@ -77,10 +114,11 @@ buffer will have the following contents:
|
|||
uint8_t ucVersionHeaderLength;
|
||||
etc
|
||||
*/
|
||||
|
||||
#if( ipconfigBUFFER_PADDING != 0 )
|
||||
#define ipBUFFER_PADDING ipconfigBUFFER_PADDING
|
||||
#else
|
||||
#define ipBUFFER_PADDING ( 8u + ipconfigPACKET_FILLER_SIZE )
|
||||
#define ipBUFFER_PADDING ( 8U + ipconfigPACKET_FILLER_SIZE )
|
||||
#endif
|
||||
|
||||
/* The structure used to store buffers and pass them around the network stack.
|
||||
|
@ -114,6 +152,8 @@ typedef enum eNETWORK_EVENTS
|
|||
eNetworkDown /* The network connection has been lost. */
|
||||
} eIPCallbackEvent_t;
|
||||
|
||||
/* MISRA check: some modules refer to this typedef even though
|
||||
ipconfigSUPPORT_OUTGOING_PINGS is not enabled. */
|
||||
typedef enum ePING_REPLY_STATUS
|
||||
{
|
||||
eSuccess = 0, /* A correct reply has been received for an outgoing ping. */
|
||||
|
@ -121,12 +161,15 @@ typedef enum ePING_REPLY_STATUS
|
|||
eInvalidData /* A reply was received to an outgoing ping but the payload of the reply was not correct. */
|
||||
} ePingReplyStatus_t;
|
||||
|
||||
typedef enum eNETWORK_ADDRESS_TYPE
|
||||
typedef struct xIP_TIMER
|
||||
{
|
||||
eNetWorkAddressTypeIPV4,
|
||||
eNetWorkAddressTypeIPV6,
|
||||
eNetWorkAddressTypeHostName
|
||||
} eNetWorkAddressType_t;
|
||||
uint32_t
|
||||
bActive : 1, /* This timer is running and must be processed. */
|
||||
bExpired : 1; /* Timer has expired and a task must be processed. */
|
||||
TimeOut_t xTimeOut;
|
||||
TickType_t ulRemainingTime;
|
||||
TickType_t ulReloadTime;
|
||||
} IPTimer_t;
|
||||
|
||||
/* Endian related definitions. */
|
||||
#if( ipconfigBYTE_ORDER == pdFREERTOS_LITTLE_ENDIAN )
|
||||
|
@ -169,52 +212,45 @@ typedef enum eNETWORK_ADDRESS_TYPE
|
|||
static portINLINE uint32_t FreeRTOS_round_up (uint32_t a, uint32_t d);
|
||||
static portINLINE uint32_t FreeRTOS_round_down (uint32_t a, uint32_t d);
|
||||
static portINLINE BaseType_t FreeRTOS_min_BaseType (BaseType_t a, BaseType_t b);
|
||||
static portINLINE BaseType_t FreeRTOS_max_BaseType (BaseType_t a, BaseType_t b);
|
||||
static portINLINE UBaseType_t FreeRTOS_max_UBaseType (UBaseType_t a, UBaseType_t b);
|
||||
static portINLINE UBaseType_t FreeRTOS_min_UBaseType (UBaseType_t a, UBaseType_t b);
|
||||
|
||||
|
||||
static portINLINE int32_t FreeRTOS_max_int32 (int32_t a, int32_t b) { return a >= b ? a : b; }
|
||||
static portINLINE uint32_t FreeRTOS_max_uint32 (uint32_t a, uint32_t b) { return a >= b ? a : b; }
|
||||
static portINLINE int32_t FreeRTOS_min_int32 (int32_t a, int32_t b) { return a <= b ? a : b; }
|
||||
static portINLINE uint32_t FreeRTOS_min_uint32 (uint32_t a, uint32_t b) { return a <= b ? a : b; }
|
||||
static portINLINE uint32_t FreeRTOS_round_up (uint32_t a, uint32_t d) { return d * ( ( a + d - 1u ) / d ); }
|
||||
static portINLINE int32_t FreeRTOS_max_int32 (int32_t a, int32_t b) { return ( a >= b ) ? a : b; }
|
||||
static portINLINE uint32_t FreeRTOS_max_uint32 (uint32_t a, uint32_t b) { return ( a >= b ) ? a : b; }
|
||||
static portINLINE int32_t FreeRTOS_min_int32 (int32_t a, int32_t b) { return ( a <= b ) ? a : b; }
|
||||
static portINLINE uint32_t FreeRTOS_min_uint32 (uint32_t a, uint32_t b) { return ( a <= b ) ? a : b; }
|
||||
static portINLINE uint32_t FreeRTOS_round_up (uint32_t a, uint32_t d) { return d * ( ( a + d - 1U ) / d ); }
|
||||
static portINLINE uint32_t FreeRTOS_round_down (uint32_t a, uint32_t d) { return d * ( a / d ); }
|
||||
|
||||
static portINLINE BaseType_t FreeRTOS_max_BaseType (BaseType_t a, BaseType_t b) { return a >= b ? a : b; }
|
||||
static portINLINE UBaseType_t FreeRTOS_max_UBaseType (UBaseType_t a, UBaseType_t b) { return a >= b ? a : b; }
|
||||
static portINLINE BaseType_t FreeRTOS_min_BaseType (BaseType_t a, BaseType_t b) { return a <= b ? a : b; }
|
||||
static portINLINE UBaseType_t FreeRTOS_min_UBaseType (UBaseType_t a, UBaseType_t b) { return a <= b ? a : b; }
|
||||
static portINLINE BaseType_t FreeRTOS_min_BaseType (BaseType_t a, BaseType_t b) { return ( a <= b ) ? a : b; }
|
||||
|
||||
#else
|
||||
|
||||
#define FreeRTOS_max_int32(a,b) ( ( ( int32_t ) ( a ) ) >= ( ( int32_t ) ( b ) ) ? ( ( int32_t ) ( a ) ) : ( ( int32_t ) ( b ) ) )
|
||||
#define FreeRTOS_max_uint32(a,b) ( ( ( uint32_t ) ( a ) ) >= ( ( uint32_t ) ( b ) ) ? ( ( uint32_t ) ( a ) ) : ( ( uint32_t ) ( b ) ) )
|
||||
#define FreeRTOS_max_int32(a,b) ( ( ( ( int32_t ) ( a ) ) >= ( ( int32_t ) ( b ) ) ) ? ( ( int32_t ) ( a ) ) : ( ( int32_t ) ( b ) ) )
|
||||
#define FreeRTOS_max_uint32(a,b) ( ( ( ( uint32_t ) ( a ) ) >= ( ( uint32_t ) ( b ) ) ) ? ( ( uint32_t ) ( a ) ) : ( ( uint32_t ) ( b ) ) )
|
||||
|
||||
#define FreeRTOS_min_int32(a,b) ( ( ( int32_t ) a ) <= ( ( int32_t ) b ) ? ( ( int32_t ) a ) : ( ( int32_t ) b ) )
|
||||
#define FreeRTOS_min_uint32(a,b) ( ( ( uint32_t ) a ) <= ( ( uint32_t ) b ) ? ( ( uint32_t ) a ) : ( ( uint32_t ) b ) )
|
||||
#define FreeRTOS_min_int32(a,b) ( ( ( ( int32_t ) a ) <= ( ( int32_t ) b ) ) ? ( ( int32_t ) a ) : ( ( int32_t ) b ) )
|
||||
#define FreeRTOS_min_uint32(a,b) ( ( ( ( uint32_t ) a ) <= ( ( uint32_t ) b ) ) ? ( ( uint32_t ) a ) : ( ( uint32_t ) b ) )
|
||||
|
||||
/* Round-up: a = d * ( ( a + d - 1 ) / d ) */
|
||||
/* Round-up: divide a by d and round=up the result. */
|
||||
#define FreeRTOS_round_up(a,d) ( ( ( uint32_t ) ( d ) ) * ( ( ( ( uint32_t ) ( a ) ) + ( ( uint32_t ) ( d ) ) - 1UL ) / ( ( uint32_t ) ( d ) ) ) )
|
||||
#define FreeRTOS_round_down(a,d) ( ( ( uint32_t ) ( d ) ) * ( ( ( uint32_t ) ( a ) ) / ( ( uint32_t ) ( d ) ) ) )
|
||||
|
||||
#define FreeRTOS_ms_to_tick(ms) ( ( ms * configTICK_RATE_HZ + 500 ) / 1000 )
|
||||
|
||||
#define FreeRTOS_max_BaseType(a, b) ( ( ( BaseType_t ) ( a ) ) >= ( ( BaseType_t ) ( b ) ) ? ( ( BaseType_t ) ( a ) ) : ( ( BaseType_t ) ( b ) ) )
|
||||
#define FreeRTOS_max_UBaseType(a, b) ( ( ( UBaseType_t ) ( a ) ) >= ( ( UBaseType_t ) ( b ) ) ? ( ( UBaseType_t ) ( a ) ) : ( ( UBaseType_t ) ( b ) ) )
|
||||
#define FreeRTOS_min_BaseType(a, b) ( ( ( BaseType_t ) ( a ) ) <= ( ( BaseType_t ) ( b ) ) ? ( ( BaseType_t ) ( a ) ) : ( ( BaseType_t ) ( b ) ) )
|
||||
#define FreeRTOS_min_UBaseType(a, b) ( ( ( UBaseType_t ) ( a ) ) <= ( ( UBaseType_t ) ( b ) ) ? ( ( UBaseType_t ) ( a ) ) : ( ( UBaseType_t ) ( b ) ) )
|
||||
|
||||
#endif /* ipconfigHAS_INLINE_FUNCTIONS */
|
||||
|
||||
#define pdMS_TO_MIN_TICKS( xTimeInMs ) ( pdMS_TO_TICKS( ( xTimeInMs ) ) < ( ( TickType_t ) 1 ) ? ( ( TickType_t ) 1 ) : pdMS_TO_TICKS( ( xTimeInMs ) ) )
|
||||
#define ipMS_TO_MIN_TICKS( xTimeInMs ) ( ( pdMS_TO_TICKS( ( xTimeInMs ) ) < ( ( TickType_t ) 1U ) ) ? ( ( TickType_t ) 1U ) : pdMS_TO_TICKS( ( xTimeInMs ) ) )
|
||||
|
||||
/* For backward compatibility. */
|
||||
#define pdMS_TO_MIN_TICKS( xTimeInMs ) ipMS_TO_MIN_TICKS( xTimeInMs )
|
||||
|
||||
#ifndef pdTRUE_SIGNED
|
||||
/* Temporary solution: eventually the defines below will appear in 'Source\include\projdefs.h' */
|
||||
#define pdTRUE_SIGNED pdTRUE
|
||||
#define pdFALSE_SIGNED pdFALSE
|
||||
#define pdTRUE_UNSIGNED ( ( UBaseType_t ) 1u )
|
||||
#define pdFALSE_UNSIGNED ( ( UBaseType_t ) 0u )
|
||||
#define pdTRUE_UNSIGNED ( 1U )
|
||||
#define pdFALSE_UNSIGNED ( 0U )
|
||||
#define ipTRUE_BOOL ( 1 == 1 )
|
||||
#define ipFALSE_BOOL ( 1 == 2 )
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -228,15 +264,32 @@ BaseType_t FreeRTOS_IPInit( const uint8_t ucIPAddress[ ipIP_ADDRESS_LENGTH_BYTES
|
|||
const uint8_t ucDNSServerAddress[ ipIP_ADDRESS_LENGTH_BYTES ],
|
||||
const uint8_t ucMACAddress[ ipMAC_ADDRESS_LENGTH_BYTES ] );
|
||||
|
||||
void * FreeRTOS_GetUDPPayloadBuffer( size_t xRequestedSizeBytes, TickType_t xBlockTimeTicks );
|
||||
void FreeRTOS_GetAddressConfiguration( uint32_t *pulIPAddress, uint32_t *pulNetMask, uint32_t *pulGatewayAddress, uint32_t *pulDNSServerAddress );
|
||||
void FreeRTOS_SetAddressConfiguration( const uint32_t *pulIPAddress, const uint32_t *pulNetMask, const uint32_t *pulGatewayAddress, const uint32_t *pulDNSServerAddress );
|
||||
BaseType_t FreeRTOS_SendPingRequest( uint32_t ulIPAddress, size_t xNumberOfBytesToSend, TickType_t xBlockTimeTicks );
|
||||
void FreeRTOS_ReleaseUDPPayloadBuffer( void *pvBuffer );
|
||||
void * FreeRTOS_GetUDPPayloadBuffer( size_t uxRequestedSizeBytes, TickType_t uxBlockTimeTicks );
|
||||
void FreeRTOS_GetAddressConfiguration( uint32_t *pulIPAddress,
|
||||
uint32_t *pulNetMask,
|
||||
uint32_t *pulGatewayAddress,
|
||||
uint32_t *pulDNSServerAddress );
|
||||
|
||||
void FreeRTOS_SetAddressConfiguration( const uint32_t *pulIPAddress,
|
||||
const uint32_t *pulNetMask,
|
||||
const uint32_t *pulGatewayAddress,
|
||||
const uint32_t *pulDNSServerAddress );
|
||||
|
||||
/* MISRA defining 'FreeRTOS_SendPingRequest' should be dependent on 'ipconfigSUPPORT_OUTGOING_PINGS'.
|
||||
In order not to break some existing project, define it unconditionally. */
|
||||
BaseType_t FreeRTOS_SendPingRequest( uint32_t ulIPAddress, size_t uxNumberOfBytesToSend, TickType_t uxBlockTimeTicks );
|
||||
|
||||
void FreeRTOS_ReleaseUDPPayloadBuffer( void const * pvBuffer );
|
||||
const uint8_t * FreeRTOS_GetMACAddress( void );
|
||||
void FreeRTOS_UpdateMACAddress( const uint8_t ucMACAddress[ipMAC_ADDRESS_LENGTH_BYTES] );
|
||||
void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent );
|
||||
void vApplicationPingReplyHook( ePingReplyStatus_t eStatus, uint16_t usIdentifier );
|
||||
#if( ipconfigUSE_NETWORK_EVENT_HOOK == 1 )
|
||||
/* coverity[misra_c_2012_rule_8_6_violation] */
|
||||
/* This function shall be defined by the application. */
|
||||
void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent );
|
||||
#endif
|
||||
#if ( ipconfigSUPPORT_OUTGOING_PINGS == 1 )
|
||||
void vApplicationPingReplyHook( ePingReplyStatus_t eStatus, uint16_t usIdentifier );
|
||||
#endif
|
||||
uint32_t FreeRTOS_GetIPAddress( void );
|
||||
void FreeRTOS_SetIPAddress( uint32_t ulIPAddress );
|
||||
void FreeRTOS_SetNetmask( uint32_t ulNetmask );
|
||||
|
@ -264,12 +317,19 @@ const char *FreeRTOS_GetTCPStateName( UBaseType_t ulState);
|
|||
void FreeRTOS_PrintARPCache( void );
|
||||
void FreeRTOS_ClearARP( void );
|
||||
|
||||
/* Return pdTRUE if the IPv4 address is a multicast address. */
|
||||
BaseType_t xIsIPv4Multicast( uint32_t ulIPAddress );
|
||||
|
||||
/* Set the MAC-address that belongs to a given IPv4 multi-cast address. */
|
||||
void vSetMultiCastIPv4MacAddress( uint32_t ulIPAddress, MACAddress_t *pxMACAddress );
|
||||
|
||||
#if( ipconfigDHCP_REGISTER_HOSTNAME == 1 )
|
||||
|
||||
/* DHCP has an option for clients to register their hostname. It doesn't
|
||||
have much use, except that a device can be found in a router along with its
|
||||
name. If this option is used the callback below must be provided by the
|
||||
application writer to return a const string, denoting the device's name. */
|
||||
/* coverity[misra_c_2012_rule_8_6_violation], typically defined in a user module. */
|
||||
const char *pcApplicationHostnameHook( void );
|
||||
|
||||
#endif /* ipconfigDHCP_REGISTER_HOSTNAME */
|
||||
|
@ -282,7 +342,10 @@ The function is defined in 'iot_secure_sockets.c'.
|
|||
If that module is not included in the project, the application must provide an
|
||||
implementation of it.
|
||||
The macro's ipconfigRAND32() and configRAND32() are not in use anymore. */
|
||||
BaseType_t xApplicationGetRandomNumber( uint32_t *pulNumber );
|
||||
/* "xApplicationGetRandomNumber" is declared but never defined, because it may
|
||||
be defined in a user module. */
|
||||
/* coverity[misra_c_2012_rule_8_6_violation] */
|
||||
extern BaseType_t xApplicationGetRandomNumber( uint32_t *pulNumber );
|
||||
|
||||
/* For backward compatibility define old structure names to the newer equivalent
|
||||
structure name. */
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* FreeRTOS+TCP V2.2.0
|
||||
* FreeRTOS+TCP V2.2.1
|
||||
* 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
|
||||
|
@ -41,6 +41,8 @@ extern "C" {
|
|||
#include "FreeRTOS_TCP_IP.h"
|
||||
#endif
|
||||
|
||||
#include "semphr.h"
|
||||
|
||||
#include "event_groups.h"
|
||||
|
||||
typedef struct xNetworkAddressingParameters
|
||||
|
@ -53,6 +55,7 @@ typedef struct xNetworkAddressingParameters
|
|||
} NetworkAddressingParameters_t;
|
||||
|
||||
extern BaseType_t xTCPWindowLoggingLevel;
|
||||
extern QueueHandle_t xNetworkEventQueue;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
/* Protocol headers. */
|
||||
|
@ -101,17 +104,6 @@ struct xIP_HEADER
|
|||
#include "pack_struct_end.h"
|
||||
typedef struct xIP_HEADER IPHeader_t;
|
||||
|
||||
#include "pack_struct_start.h"
|
||||
struct xIGMP_HEADER
|
||||
{
|
||||
uint8_t ucVersionType; /* 0 + 1 = 1 */
|
||||
uint8_t ucMaxResponseTime; /* 1 + 1 = 2 */
|
||||
uint16_t usChecksum; /* 2 + 2 = 4 */
|
||||
uint32_t usGroupAddress; /* 4 + 4 = 8 */
|
||||
}
|
||||
#include "pack_struct_end.h"
|
||||
typedef struct xIGMP_HEADER IGMPHeader_t;
|
||||
|
||||
#include "pack_struct_start.h"
|
||||
struct xICMP_HEADER
|
||||
{
|
||||
|
@ -155,18 +147,6 @@ struct xTCP_HEADER
|
|||
#include "pack_struct_end.h"
|
||||
typedef struct xTCP_HEADER TCPHeader_t;
|
||||
|
||||
#include "pack_struct_start.h"
|
||||
struct xPSEUDO_HEADER
|
||||
{
|
||||
uint32_t ulSourceAddress;
|
||||
uint32_t ulDestinationAddress;
|
||||
uint8_t ucZeros;
|
||||
uint8_t ucProtocol;
|
||||
uint16_t usUDPLength;
|
||||
}
|
||||
#include "pack_struct_end.h"
|
||||
typedef struct xPSEUDO_HEADER PseudoHeader_t;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
/* Nested protocol packets. */
|
||||
/*-----------------------------------------------------------*/
|
||||
|
@ -227,6 +207,13 @@ typedef union XPROT_PACKET
|
|||
ICMPPacket_t xICMPPacket;
|
||||
} ProtocolPacket_t;
|
||||
|
||||
typedef union xPROT_HEADERS
|
||||
{
|
||||
ICMPHeader_t xICMPHeader;
|
||||
UDPHeader_t xUDPHeader;
|
||||
TCPHeader_t xTCPHeader;
|
||||
} ProtocolHeaders_t;
|
||||
|
||||
|
||||
/* The maximum UDP payload length. */
|
||||
#define ipMAX_UDP_PAYLOAD_LENGTH ( ( ipconfigNETWORK_MTU - ipSIZE_OF_IPv4_HEADER ) - ipSIZE_OF_UDP_HEADER )
|
||||
|
@ -281,18 +268,6 @@ setting. */
|
|||
/* The offset into an IP packet into which the IP data (payload) starts. */
|
||||
#define ipIP_PAYLOAD_OFFSET ( sizeof( IPPacket_t ) )
|
||||
|
||||
#include "pack_struct_start.h"
|
||||
struct xUDP_IP_FRAGMENT_PARAMETERS
|
||||
{
|
||||
uint8_t ucSocketOptions;
|
||||
uint8_t ucPadFor16BitAlignment;
|
||||
uint16_t usFragmentedPacketOffset;
|
||||
uint16_t usFragmentLength;
|
||||
uint16_t usPayloadChecksum;
|
||||
}
|
||||
#include "pack_struct_end.h"
|
||||
typedef struct xUDP_IP_FRAGMENT_PARAMETERS IPFragmentParameters_t;
|
||||
|
||||
#if( ipconfigBYTE_ORDER == pdFREERTOS_LITTLE_ENDIAN )
|
||||
|
||||
/* Ethernet frame types. */
|
||||
|
@ -339,7 +314,8 @@ extern NetworkAddressingParameters_t xNetworkAddressing;
|
|||
/* Structure that stores the defaults for netmask, gateway address and DNS.
|
||||
These values will be copied to 'xNetworkAddressing' in case DHCP is not used,
|
||||
and also in case DHCP does not lead to a confirmed request. */
|
||||
extern NetworkAddressingParameters_t xDefaultAddressing;
|
||||
/*lint -e9003*/
|
||||
extern NetworkAddressingParameters_t xDefaultAddressing; /*lint !e9003 could define variable 'xDefaultAddressing' at block scope [MISRA 2012 Rule 8.9, advisory]. */
|
||||
|
||||
/* True when BufferAllocation_1.c was included, false for BufferAllocation_2.c */
|
||||
extern const BaseType_t xBufferAllocFixedSize;
|
||||
|
@ -351,11 +327,43 @@ extern const BaseType_t xBufferAllocFixedSize;
|
|||
|
||||
/* The local IP address is accessed from within xDefaultPartUDPPacketHeader,
|
||||
rather than duplicated in its own variable. */
|
||||
#define ipLOCAL_IP_ADDRESS_POINTER ( ( uint32_t * ) &( xDefaultPartUDPPacketHeader.ulWords[ 20u / sizeof(uint32_t) ] ) )
|
||||
#define ipLOCAL_IP_ADDRESS_POINTER ( ( uint32_t * ) &( xDefaultPartUDPPacketHeader.ulWords[ 20U / sizeof(uint32_t) ] ) )
|
||||
|
||||
/* The local MAC address is accessed from within xDefaultPartUDPPacketHeader,
|
||||
rather than duplicated in its own variable. */
|
||||
#define ipLOCAL_MAC_ADDRESS ( &xDefaultPartUDPPacketHeader.ucBytes[0] )
|
||||
#define ipLOCAL_MAC_ADDRESS ( xDefaultPartUDPPacketHeader.ucBytes )
|
||||
|
||||
/* In this library, there is often a cast from a character pointer
|
||||
* to a pointer to a struct.
|
||||
* In order to suppress MISRA warnings, do the cast within a macro,
|
||||
* which can be exempt from warnings:
|
||||
*
|
||||
* 3 required by MISRA:
|
||||
* -emacro(740,ipPOINTER_CAST) // 750: Unusual pointer cast (incompatible indirect types) [MISRA 2012 Rule 1.3, required])
|
||||
* -emacro(9005,ipPOINTER_CAST) // 9005: attempt to cast away const/volatile from a pointer or reference [MISRA 2012 Rule 11.8, required]
|
||||
* -emacro(9087,ipPOINTER_CAST) // 9087: cast performed between a pointer to object type and a pointer to a different object type [MISRA 2012 Rule 11.3, required]
|
||||
*
|
||||
* 2 advisory by MISRA:
|
||||
* -emacro(9079,ipPOINTER_CAST) // 9079: conversion from pointer to void to pointer to other type [MISRA 2012 Rule 11.5, advisory])
|
||||
* --emacro((826),ipPOINTER_CAST) // 826: Suspicious pointer-to-pointer conversion (area too small)
|
||||
*
|
||||
* The MISRA warnings can safely be suppressed because all casts are planned with care.
|
||||
*/
|
||||
|
||||
#define ipPOINTER_CAST( TYPE, pointer ) ( ( TYPE ) ( pointer ) )
|
||||
|
||||
/* Sequence and ACK numbers are essentially unsigned (uint32_t). But when
|
||||
* a distance is calculated, it is useful to use signed numbers:
|
||||
* int32_t lDistance = ( int32_t ) ( ulSeq1 - ulSeq2 );
|
||||
*
|
||||
* 1 required by MISRA:
|
||||
* -emacro(9033,ipNUMERIC_CAST) // 9033: Impermissible cast of composite expression (different essential type categories) [MISRA 2012 Rule 10.8, required])
|
||||
*
|
||||
* 1 advisory by MISRA:
|
||||
* -emacro(9030,ipNUMERIC_CAST) // 9030: Impermissible cast; cannot cast from 'essentially Boolean' to 'essentially signed' [MISRA 2012 Rule 10.5, advisory])
|
||||
*/
|
||||
|
||||
#define ipNUMERIC_CAST( TYPE, expression ) ( ( TYPE ) ( expression ) )
|
||||
|
||||
/* ICMP packets are sent using the same function as UDP packets. The port
|
||||
number is used to distinguish between the two, as 0 is an invalid UDP port. */
|
||||
|
@ -368,15 +376,15 @@ socket events. */
|
|||
#define vSetField16( pxBase, xType, xField, usValue ) \
|
||||
{ \
|
||||
( ( uint8_t* )( pxBase ) ) [ offsetof( xType, xField ) + 0 ] = ( uint8_t ) ( ( usValue ) >> 8 ); \
|
||||
( ( uint8_t* )( pxBase ) ) [ offsetof( xType, xField ) + 1 ] = ( uint8_t ) ( ( usValue ) & 0xff ); \
|
||||
( ( uint8_t* )( pxBase ) ) [ offsetof( xType, xField ) + 1 ] = ( uint8_t ) ( ( usValue ) & 0xffU ); \
|
||||
}
|
||||
|
||||
#define vSetField32( pxBase, xType, xField, ulValue ) \
|
||||
{ \
|
||||
( (uint8_t*)( pxBase ) ) [ offsetof( xType, xField ) + 0 ] = ( uint8_t ) ( ( ulValue ) >> 24 ); \
|
||||
( (uint8_t*)( pxBase ) ) [ offsetof( xType, xField ) + 1 ] = ( uint8_t ) ( ( ( ulValue ) >> 16 ) & 0xff ); \
|
||||
( (uint8_t*)( pxBase ) ) [ offsetof( xType, xField ) + 2 ] = ( uint8_t ) ( ( ( ulValue ) >> 8 ) & 0xff ); \
|
||||
( (uint8_t*)( pxBase ) ) [ offsetof( xType, xField ) + 3 ] = ( uint8_t ) ( ( ulValue ) & 0xff ); \
|
||||
( (uint8_t*)( pxBase ) ) [ offsetof( xType, xField ) + 1 ] = ( uint8_t ) ( ( ( ulValue ) >> 16 ) & 0xffU ); \
|
||||
( (uint8_t*)( pxBase ) ) [ offsetof( xType, xField ) + 2 ] = ( uint8_t ) ( ( ( ulValue ) >> 8 ) & 0xffU ); \
|
||||
( (uint8_t*)( pxBase ) ) [ offsetof( xType, xField ) + 3 ] = ( uint8_t ) ( ( ulValue ) & 0xffU ); \
|
||||
}
|
||||
|
||||
#define vFlip_16( left, right ) \
|
||||
|
@ -384,17 +392,17 @@ socket events. */
|
|||
uint16_t tmp = (left); \
|
||||
(left) = (right); \
|
||||
(right) = tmp; \
|
||||
} while (0)
|
||||
} while ( ipFALSE_BOOL )
|
||||
|
||||
#define vFlip_32( left, right ) \
|
||||
do { \
|
||||
uint32_t tmp = (left); \
|
||||
(left) = (right); \
|
||||
(right) = tmp; \
|
||||
} while (0)
|
||||
} while ( ipFALSE_BOOL )
|
||||
|
||||
#ifndef ARRAY_SIZE
|
||||
#define ARRAY_SIZE(x) (BaseType_t)(sizeof(x)/sizeof(x)[0])
|
||||
#define ARRAY_SIZE(x) ( ( BaseType_t ) ( sizeof( x ) / sizeof( ( x )[ 0 ] ) ) )
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -434,11 +442,11 @@ eFrameProcessingResult_t eConsiderFrameForProcessing( const uint8_t * const pucE
|
|||
/*
|
||||
* Return the checksum generated over xDataLengthBytes from pucNextData.
|
||||
*/
|
||||
uint16_t usGenerateChecksum( uint32_t ulSum, const uint8_t * pucNextData, size_t uxDataLengthBytes );
|
||||
uint16_t usGenerateChecksum( uint16_t usSum, const uint8_t * pucNextData, size_t uxByteCount );
|
||||
|
||||
/* Socket related private functions. */
|
||||
|
||||
/*
|
||||
/*
|
||||
* The caller must ensure that pxNetworkBuffer->xDataLength is the UDP packet
|
||||
* payload size (excluding packet headers) and that the packet in pucEthernetBuffer
|
||||
* is at least the size of UDPPacket_t.
|
||||
|
@ -448,7 +456,7 @@ BaseType_t xProcessReceivedUDPPacket( NetworkBufferDescriptor_t *pxNetworkBuffer
|
|||
/*
|
||||
* Initialize the socket list data structures for TCP and UDP.
|
||||
*/
|
||||
BaseType_t vNetworkSocketsInit( void );
|
||||
void vNetworkSocketsInit( void );
|
||||
|
||||
/*
|
||||
* Returns pdTRUE if the IP task has been created and is initialised. Otherwise
|
||||
|
@ -601,7 +609,8 @@ typedef struct UDPSOCKET
|
|||
#endif /* ipconfigUSE_CALLBACKS */
|
||||
} IPUDPSocket_t;
|
||||
|
||||
typedef enum eSOCKET_EVENT {
|
||||
/* Formally typedef'd as eSocketEvent_t. */
|
||||
enum eSOCKET_EVENT {
|
||||
eSOCKET_RECEIVE = 0x0001,
|
||||
eSOCKET_SEND = 0x0002,
|
||||
eSOCKET_ACCEPT = 0x0004,
|
||||
|
@ -610,7 +619,7 @@ typedef enum eSOCKET_EVENT {
|
|||
eSOCKET_CLOSED = 0x0020,
|
||||
eSOCKET_INTR = 0x0040,
|
||||
eSOCKET_ALL = 0x007F,
|
||||
} eSocketEvent_t;
|
||||
};
|
||||
|
||||
typedef struct xSOCKET
|
||||
{
|
||||
|
@ -695,7 +704,7 @@ void vReturnEthernetFrame( NetworkBufferDescriptor_t * pxNetworkBuffer, BaseType
|
|||
* The TCP driver needs to bind a socket at the moment a listening socket
|
||||
* creates a new connected socket
|
||||
*/
|
||||
BaseType_t vSocketBind( FreeRTOS_Socket_t *pxSocket, struct freertos_sockaddr * pxAddress, size_t uxAddressLength, BaseType_t xInternal );
|
||||
BaseType_t vSocketBind( FreeRTOS_Socket_t *pxSocket, struct freertos_sockaddr * pxBindAddress, size_t uxAddressLength, BaseType_t xInternal );
|
||||
|
||||
/*
|
||||
* Internal function to add streaming data to a TCP socket. If ulIn == true,
|
||||
|
@ -714,6 +723,7 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t *pxSocket );
|
|||
/*
|
||||
* Some helping function, their meaning should be clear
|
||||
*/
|
||||
/* coverity[misra_c_2012_rule_2_2_violation] */
|
||||
static portINLINE uint32_t ulChar2u32 (const uint8_t *apChr);
|
||||
static portINLINE uint32_t ulChar2u32 (const uint8_t *apChr)
|
||||
{
|
||||
|
@ -753,13 +763,13 @@ BaseType_t xSendEventToIPTask( eIPEvent_t eEvent );
|
|||
* eIPEvent_t eEventType;
|
||||
* void *pvData;
|
||||
*/
|
||||
BaseType_t xSendEventStructToIPTask( const IPStackEvent_t *pxEvent, TickType_t xTimeout );
|
||||
BaseType_t xSendEventStructToIPTask( const IPStackEvent_t *pxEvent, TickType_t uxTimeout );
|
||||
|
||||
/*
|
||||
* Returns a pointer to the original NetworkBuffer from a pointer to a UDP
|
||||
* payload buffer.
|
||||
*/
|
||||
NetworkBufferDescriptor_t *pxUDPPayloadBuffer_to_NetworkBuffer( void *pvBuffer );
|
||||
NetworkBufferDescriptor_t *pxUDPPayloadBuffer_to_NetworkBuffer( const void * pvBuffer );
|
||||
|
||||
#if( ipconfigZERO_COPY_TX_DRIVER != 0 )
|
||||
/*
|
||||
|
@ -778,9 +788,6 @@ NetworkBufferDescriptor_t *pxUDPPayloadBuffer_to_NetworkBuffer( void *pvBuffer )
|
|||
void vTCPStateChange( FreeRTOS_Socket_t *pxSocket, enum eTCP_STATE eTCPState );
|
||||
#endif /* ipconfigUSE_TCP */
|
||||
|
||||
/*_RB_ Should this be part of the public API? */
|
||||
void FreeRTOS_netstat( void );
|
||||
|
||||
/* Returns pdTRUE is this function is called from the IP-task */
|
||||
BaseType_t xIsCallingFromIPTask( void );
|
||||
|
||||
|
@ -789,11 +796,16 @@ BaseType_t xIsCallingFromIPTask( void );
|
|||
typedef struct xSOCKET_SET
|
||||
{
|
||||
EventGroupHandle_t xSelectGroup;
|
||||
BaseType_t bApiCalled; /* True if the API was calling the private vSocketSelect */
|
||||
FreeRTOS_Socket_t *pxSocket;
|
||||
} SocketSelect_t;
|
||||
|
||||
extern void vSocketSelect( SocketSelect_t *pxSocketSelect );
|
||||
extern void vSocketSelect( SocketSelect_t *pxSocketSet );
|
||||
|
||||
/* Define the data that must be passed for a 'eSocketSelectEvent'. */
|
||||
typedef struct xSocketSelectMessage
|
||||
{
|
||||
TaskHandle_t xTaskhandle;
|
||||
SocketSelect_t *pxSocketSet;
|
||||
} SocketSelectMessage_t;
|
||||
|
||||
#endif /* ipconfigSUPPORT_SELECT_FUNCTION */
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* FreeRTOS+TCP V2.2.0
|
||||
* FreeRTOS+TCP V2.2.1
|
||||
* 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
|
||||
|
@ -180,6 +180,8 @@ struct freertos_sockaddr
|
|||
uint32_t sin_addr;
|
||||
};
|
||||
|
||||
extern const char *FreeRTOS_inet_ntoa( uint32_t ulIPAddress, char *pcBuffer );
|
||||
|
||||
#if ipconfigBYTE_ORDER == pdFREERTOS_LITTLE_ENDIAN
|
||||
|
||||
#define FreeRTOS_inet_addr_quick( ucOctet0, ucOctet1, ucOctet2, ucOctet3 ) \
|
||||
|
@ -188,13 +190,6 @@ struct freertos_sockaddr
|
|||
( ( ( uint32_t ) ( ucOctet1 ) ) << 8UL ) | \
|
||||
( ( uint32_t ) ( ucOctet0 ) ) )
|
||||
|
||||
#define FreeRTOS_inet_ntoa( ulIPAddress, pucBuffer ) \
|
||||
sprintf( ( char * ) ( pucBuffer ), "%u.%u.%u.%u", \
|
||||
( ( unsigned ) ( ( ulIPAddress ) & 0xffUL ) ), \
|
||||
( ( unsigned ) ( ( ( ulIPAddress ) >> 8 ) & 0xffUL ) ), \
|
||||
( ( unsigned ) ( ( ( ulIPAddress ) >> 16 ) & 0xffUL ) ),\
|
||||
( ( unsigned ) ( ( ulIPAddress ) >> 24 ) ) )
|
||||
|
||||
#else /* ipconfigBYTE_ORDER */
|
||||
|
||||
#define FreeRTOS_inet_addr_quick( ucOctet0, ucOctet1, ucOctet2, ucOctet3 ) \
|
||||
|
@ -203,23 +198,18 @@ struct freertos_sockaddr
|
|||
( ( ( uint32_t ) ( ucOctet2 ) ) << 8UL ) | \
|
||||
( ( uint32_t ) ( ucOctet3 ) ) )
|
||||
|
||||
#define FreeRTOS_inet_ntoa( ulIPAddress, pucBuffer ) \
|
||||
sprintf( ( char * ) ( pucBuffer ), "%u.%u.%u.%u", \
|
||||
( ( unsigned ) ( ( ulIPAddress ) >> 24 ) ), \
|
||||
( ( unsigned ) ( ( ( ulIPAddress ) >> 16 ) & 0xffUL ) ),\
|
||||
( ( unsigned ) ( ( ( ulIPAddress ) >> 8 ) & 0xffUL ) ), \
|
||||
( ( unsigned ) ( ( ulIPAddress ) & 0xffUL ) ) )
|
||||
|
||||
#endif /* ipconfigBYTE_ORDER */
|
||||
|
||||
/* The socket type itself. */
|
||||
struct xSOCKET;
|
||||
typedef struct xSOCKET *Socket_t;
|
||||
|
||||
/* The SocketSet_t type is the equivalent to the fd_set type used by the
|
||||
Berkeley API. */
|
||||
struct xSOCKET_SET;
|
||||
typedef struct xSOCKET_SET *SocketSet_t;
|
||||
#if( ipconfigSUPPORT_SELECT_FUNCTION == 1 )
|
||||
/* The SocketSet_t type is the equivalent to the fd_set type used by the
|
||||
Berkeley API. */
|
||||
struct xSOCKET_SET;
|
||||
typedef struct xSOCKET_SET *SocketSet_t;
|
||||
#endif /* ( ipconfigSUPPORT_SELECT_FUNCTION == 1 ) */
|
||||
|
||||
/**
|
||||
* FULL, UP-TO-DATE AND MAINTAINED REFERENCE DOCUMENTATION FOR ALL THESE
|
||||
|
@ -227,21 +217,23 @@ typedef struct xSOCKET_SET *SocketSet_t;
|
|||
* http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/FreeRTOS_TCP_API_Functions.html
|
||||
*/
|
||||
Socket_t FreeRTOS_socket( BaseType_t xDomain, BaseType_t xType, BaseType_t xProtocol );
|
||||
int32_t FreeRTOS_recvfrom( Socket_t xSocket, void *pvBuffer, size_t xBufferLength, BaseType_t xFlags, struct freertos_sockaddr *pxSourceAddress, socklen_t *pxSourceAddressLength );
|
||||
int32_t FreeRTOS_sendto( Socket_t xSocket, const void *pvBuffer, size_t xTotalDataLength, BaseType_t xFlags, const struct freertos_sockaddr *pxDestinationAddress, socklen_t xDestinationAddressLength );
|
||||
BaseType_t FreeRTOS_bind( Socket_t xSocket, struct freertos_sockaddr *pxAddress, socklen_t xAddressLength );
|
||||
int32_t FreeRTOS_recvfrom( Socket_t xSocket, void *pvBuffer, size_t uxBufferLength, BaseType_t xFlags, struct freertos_sockaddr *pxSourceAddress, socklen_t *pxSourceAddressLength );
|
||||
int32_t FreeRTOS_sendto( Socket_t xSocket, const void *pvBuffer, size_t uxTotalDataLength, BaseType_t xFlags, const struct freertos_sockaddr *pxDestinationAddress, socklen_t xDestinationAddressLength );
|
||||
BaseType_t FreeRTOS_bind( Socket_t xSocket, struct freertos_sockaddr const * pxAddress, socklen_t xAddressLength );
|
||||
|
||||
/* function to get the local address and IP port */
|
||||
size_t FreeRTOS_GetLocalAddress( Socket_t xSocket, struct freertos_sockaddr *pxAddress );
|
||||
|
||||
/* Made available when ipconfigETHERNET_DRIVER_FILTERS_PACKETS is set to 1. */
|
||||
BaseType_t xPortHasUDPSocket( uint16_t usPortNr );
|
||||
#if( ipconfigETHERNET_DRIVER_FILTERS_PACKETS == 1 )
|
||||
/* Returns true if an UDP socket exists bound to mentioned port number. */
|
||||
BaseType_t xPortHasUDPSocket( uint16_t usPortNr );
|
||||
#endif
|
||||
|
||||
#if ipconfigUSE_TCP == 1
|
||||
|
||||
BaseType_t FreeRTOS_connect( Socket_t xClientSocket, struct freertos_sockaddr *pxAddress, socklen_t xAddressLength );
|
||||
BaseType_t FreeRTOS_listen( Socket_t xSocket, BaseType_t xBacklog );
|
||||
BaseType_t FreeRTOS_recv( Socket_t xSocket, void *pvBuffer, size_t xBufferLength, BaseType_t xFlags );
|
||||
BaseType_t FreeRTOS_recv( Socket_t xSocket, void *pvBuffer, size_t uxBufferLength, BaseType_t xFlags );
|
||||
BaseType_t FreeRTOS_send( Socket_t xSocket, const void *pvBuffer, size_t uxDataLength, BaseType_t xFlags );
|
||||
Socket_t FreeRTOS_accept( Socket_t xServerSocket, struct freertos_sockaddr *pxAddress, socklen_t *pxAddressLength );
|
||||
BaseType_t FreeRTOS_shutdown (Socket_t xSocket, BaseType_t xHow);
|
||||
|
@ -258,11 +250,15 @@ BaseType_t FreeRTOS_shutdown (Socket_t xSocket, BaseType_t xHow);
|
|||
/* Return the remote address and IP port. */
|
||||
BaseType_t FreeRTOS_GetRemoteAddress( Socket_t xSocket, struct freertos_sockaddr *pxAddress );
|
||||
|
||||
/* returns pdTRUE if TCP socket is connected */
|
||||
BaseType_t FreeRTOS_issocketconnected( Socket_t xSocket );
|
||||
#if( ipconfigUSE_TCP == 1 )
|
||||
|
||||
/* returns the actual size of MSS being used */
|
||||
BaseType_t FreeRTOS_mss( Socket_t xSocket );
|
||||
/* returns pdTRUE if TCP socket is connected */
|
||||
BaseType_t FreeRTOS_issocketconnected( Socket_t xSocket );
|
||||
|
||||
/* returns the actual size of MSS being used */
|
||||
BaseType_t FreeRTOS_mss( Socket_t xSocket );
|
||||
|
||||
#endif
|
||||
|
||||
/* for internal use only: return the connection status */
|
||||
BaseType_t FreeRTOS_connstatus( Socket_t xSocket );
|
||||
|
@ -275,9 +271,11 @@ BaseType_t FreeRTOS_maywrite( Socket_t xSocket );
|
|||
* rx_size returns the number of bytes available in the Rx buffer
|
||||
* tx_space returns the free space in the Tx buffer
|
||||
*/
|
||||
BaseType_t FreeRTOS_rx_size( Socket_t xSocket );
|
||||
BaseType_t FreeRTOS_tx_space( Socket_t xSocket );
|
||||
BaseType_t FreeRTOS_tx_size( Socket_t xSocket );
|
||||
#if( ipconfigUSE_TCP == 1 )
|
||||
BaseType_t FreeRTOS_rx_size( Socket_t xSocket );
|
||||
BaseType_t FreeRTOS_tx_space( Socket_t xSocket );
|
||||
BaseType_t FreeRTOS_tx_size( Socket_t xSocket );
|
||||
#endif
|
||||
|
||||
/* Returns the number of outstanding bytes in txStream. */
|
||||
/* The function FreeRTOS_outstanding() was already implemented
|
||||
|
@ -298,58 +296,88 @@ uint8_t *FreeRTOS_get_tx_head( Socket_t xSocket, BaseType_t *pxLength );
|
|||
|
||||
#endif /* ipconfigUSE_TCP */
|
||||
|
||||
/*
|
||||
* Connect / disconnect handler for a TCP socket
|
||||
* For example:
|
||||
* static void vMyConnectHandler (Socket_t xSocket, BaseType_t ulConnected)
|
||||
* {
|
||||
* }
|
||||
* F_TCP_UDP_Handler_t xHnd = { vMyConnectHandler };
|
||||
* FreeRTOS_setsockopt( sock, 0, FREERTOS_SO_TCP_CONN_HANDLER, ( void * ) &xHnd, sizeof( xHnd ) );
|
||||
*/
|
||||
#if( ipconfigUSE_CALLBACKS != 0 )
|
||||
/*
|
||||
* Connect / disconnect handler for a TCP socket
|
||||
* For example:
|
||||
* static void vMyConnectHandler (Socket_t xSocket, BaseType_t ulConnected)
|
||||
* {
|
||||
* }
|
||||
* F_TCP_UDP_Handler_t xHnd = { vMyConnectHandler };
|
||||
* FreeRTOS_setsockopt( sock, 0, FREERTOS_SO_TCP_CONN_HANDLER, ( void * ) &xHnd, sizeof( xHnd ) );
|
||||
*/
|
||||
|
||||
#ifdef __COVERITY__
|
||||
typedef void (* FOnConnected_t )( Socket_t xSocket, BaseType_t ulConnected );
|
||||
#else
|
||||
typedef void (* FOnConnected_t )( Socket_t, BaseType_t );
|
||||
#endif
|
||||
|
||||
typedef void (* FOnConnected_t )( Socket_t /* xSocket */, BaseType_t /* ulConnected */ );
|
||||
/*
|
||||
* Reception handler for a TCP socket
|
||||
* A user-proved function will be called on reception of a message
|
||||
* If the handler returns a positive number, the messages will not be stored
|
||||
* For example:
|
||||
* static BaseType_t xOnTCPReceive( Socket_t xSocket, void * pData, size_t uxLength )
|
||||
* {
|
||||
* // handle the message
|
||||
* return 1;
|
||||
* }
|
||||
* F_TCP_UDP_Handler_t xHand = { xOnTCPReceive };
|
||||
* FreeRTOS_setsockopt( sock, 0, FREERTOS_SO_TCP_RECV_HANDLER, ( void * ) &xHand, sizeof( xHand ) );
|
||||
*/
|
||||
#ifdef __COVERITY__
|
||||
typedef BaseType_t (* FOnTCPReceive_t )( Socket_t xSocket, void * pData, size_t xLength );
|
||||
typedef void (* FOnTCPSent_t )( Socket_t xSocket, size_t xLength );
|
||||
#else
|
||||
typedef BaseType_t (* FOnTCPReceive_t )( Socket_t, void *, size_t );
|
||||
typedef void (* FOnTCPSent_t )( Socket_t, size_t );
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Reception handler for a UDP socket
|
||||
* A user-proved function will be called on reception of a message
|
||||
* If the handler returns a positive number, the messages will not be stored
|
||||
*/
|
||||
#ifdef __COVERITY__
|
||||
typedef BaseType_t (* FOnUDPReceive_t ) (Socket_t xSocket, void * pData, size_t xLength,
|
||||
const struct freertos_sockaddr * pxFrom, const struct freertos_sockaddr * pxDest );
|
||||
typedef void (* FOnUDPSent_t )( Socket_t xSocket, size_t xLength );
|
||||
#else
|
||||
typedef BaseType_t (* FOnUDPReceive_t ) (Socket_t, void *, size_t,
|
||||
const struct freertos_sockaddr *, const struct freertos_sockaddr *);
|
||||
typedef void (* FOnUDPSent_t )( Socket_t, size_t);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Reception handler for a TCP socket
|
||||
* A user-proved function will be called on reception of a message
|
||||
* If the handler returns a positive number, the messages will not be stored
|
||||
* For example:
|
||||
* static BaseType_t xOnTCPReceive( Socket_t xSocket, void * pData, size_t xLength )
|
||||
* {
|
||||
* // handle the message
|
||||
* return 1;
|
||||
* }
|
||||
* F_TCP_UDP_Handler_t xHand = { xOnTCPReceive };
|
||||
* FreeRTOS_setsockopt( sock, 0, FREERTOS_SO_TCP_RECV_HANDLER, ( void * ) &xHand, sizeof( xHand ) );
|
||||
*/
|
||||
typedef BaseType_t (* FOnTCPReceive_t )( Socket_t /* xSocket */, void * /* pData */, size_t /* xLength */ );
|
||||
typedef void (* FOnTCPSent_t )( Socket_t /* xSocket */, size_t /* xLength */ );
|
||||
typedef union xTCP_UDP_HANDLER
|
||||
{
|
||||
FOnConnected_t pxOnTCPConnected; /* FREERTOS_SO_TCP_CONN_HANDLER */
|
||||
FOnTCPReceive_t pxOnTCPReceive; /* FREERTOS_SO_TCP_RECV_HANDLER */
|
||||
FOnTCPSent_t pxOnTCPSent; /* FREERTOS_SO_TCP_SENT_HANDLER */
|
||||
FOnUDPReceive_t pxOnUDPReceive; /* FREERTOS_SO_UDP_RECV_HANDLER */
|
||||
FOnUDPSent_t pxOnUDPSent; /* FREERTOS_SO_UDP_SENT_HANDLER */
|
||||
} F_TCP_UDP_Handler_t;
|
||||
#endif /* ( ipconfigUSE_CALLBACKS != 0 ) */
|
||||
|
||||
/*
|
||||
* Reception handler for a UDP socket
|
||||
* A user-proved function will be called on reception of a message
|
||||
* If the handler returns a positive number, the messages will not be stored
|
||||
*/
|
||||
typedef BaseType_t (* FOnUDPReceive_t ) (Socket_t /* xSocket */, void * /* pData */, size_t /* xLength */,
|
||||
const struct freertos_sockaddr * /* pxFrom */, const struct freertos_sockaddr * /* pxDest */ );
|
||||
typedef void (* FOnUDPSent_t )( Socket_t /* xSocket */, size_t /* xLength */ );
|
||||
|
||||
|
||||
typedef union xTCP_UDP_HANDLER
|
||||
{
|
||||
FOnConnected_t pxOnTCPConnected; /* FREERTOS_SO_TCP_CONN_HANDLER */
|
||||
FOnTCPReceive_t pxOnTCPReceive; /* FREERTOS_SO_TCP_RECV_HANDLER */
|
||||
FOnTCPSent_t pxOnTCPSent; /* FREERTOS_SO_TCP_SENT_HANDLER */
|
||||
FOnUDPReceive_t pxOnUDPReceive; /* FREERTOS_SO_UDP_RECV_HANDLER */
|
||||
FOnUDPSent_t pxOnUDPSent; /* FREERTOS_SO_UDP_SENT_HANDLER */
|
||||
} F_TCP_UDP_Handler_t;
|
||||
|
||||
BaseType_t FreeRTOS_setsockopt( Socket_t xSocket, int32_t lLevel, int32_t lOptionName, const void *pvOptionValue, size_t xOptionLength );
|
||||
BaseType_t FreeRTOS_setsockopt( Socket_t xSocket, int32_t lLevel, int32_t lOptionName, const void *pvOptionValue, size_t uxOptionLength );
|
||||
BaseType_t FreeRTOS_closesocket( Socket_t xSocket );
|
||||
uint32_t FreeRTOS_gethostbyname( const char *pcHostName );
|
||||
|
||||
/* The following function header should be placed in FreeRTOS_DNS.h.
|
||||
It is kept here because some applications expect it in FreeRTOS_Sockets.h.*/
|
||||
#ifndef __COVERITY__
|
||||
uint32_t FreeRTOS_gethostbyname( const char *pcHostName );
|
||||
#endif
|
||||
|
||||
BaseType_t FreeRTOS_inet_pton( BaseType_t xAddressFamily, const char *pcSource, void *pvDestination );
|
||||
const char *FreeRTOS_inet_ntop( BaseType_t xAddressFamily, const void *pvSource, char *pcDestination, socklen_t uxSize );
|
||||
|
||||
/* Convert a null-terminated string in dot-decimal-notation (d.d.d.d) to a 32-bit unsigned integer. */
|
||||
uint32_t FreeRTOS_inet_addr( const char * pcIPAddress );
|
||||
|
||||
BaseType_t FreeRTOS_inet_pton4( const char *pcSource, void *pvDestination );
|
||||
const char *FreeRTOS_inet_ntop4( const void *pvSource, char *pcDestination, socklen_t uxSize );
|
||||
|
||||
|
||||
/*
|
||||
* For the web server: borrow the circular Rx buffer for inspection
|
||||
* HTML driver wants to see if a sequence of 13/10/13/10 is available
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* FreeRTOS+TCP V2.2.0
|
||||
* FreeRTOS+TCP V2.2.1
|
||||
* 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
|
||||
|
@ -52,10 +52,10 @@ static portINLINE void vStreamBufferClear( StreamBuffer_t *pxBuffer );
|
|||
static portINLINE void vStreamBufferClear( StreamBuffer_t *pxBuffer )
|
||||
{
|
||||
/* Make the circular buffer empty */
|
||||
pxBuffer->uxHead = 0u;
|
||||
pxBuffer->uxTail = 0u;
|
||||
pxBuffer->uxFront = 0u;
|
||||
pxBuffer->uxMid = 0u;
|
||||
pxBuffer->uxHead = 0U;
|
||||
pxBuffer->uxTail = 0U;
|
||||
pxBuffer->uxFront = 0U;
|
||||
pxBuffer->uxMid = 0U;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
|
@ -65,7 +65,7 @@ static portINLINE size_t uxStreamBufferSpace( const StreamBuffer_t *pxBuffer, co
|
|||
/* Returns the space between uxLower and uxUpper, which equals to the distance minus 1 */
|
||||
size_t uxCount;
|
||||
|
||||
uxCount = pxBuffer->LENGTH + uxUpper - uxLower - 1u;
|
||||
uxCount = pxBuffer->LENGTH + uxUpper - uxLower - 1U;
|
||||
if( uxCount >= pxBuffer->LENGTH )
|
||||
{
|
||||
uxCount -= pxBuffer->LENGTH;
|
||||
|
@ -145,12 +145,13 @@ static portINLINE void vStreamBufferMoveMid( StreamBuffer_t *pxBuffer, size_t ux
|
|||
{
|
||||
/* Increment uxMid, but no further than uxHead */
|
||||
size_t uxSize = uxStreamBufferMidSpace( pxBuffer );
|
||||
size_t uxMoveCount = uxCount;
|
||||
|
||||
if( uxCount > uxSize )
|
||||
if( uxMoveCount > uxSize )
|
||||
{
|
||||
uxCount = uxSize;
|
||||
uxMoveCount = uxSize;
|
||||
}
|
||||
pxBuffer->uxMid += uxCount;
|
||||
pxBuffer->uxMid += uxMoveCount;
|
||||
if( pxBuffer->uxMid >= pxBuffer->LENGTH )
|
||||
{
|
||||
pxBuffer->uxMid -= pxBuffer->LENGTH;
|
||||
|
@ -165,7 +166,7 @@ BaseType_t xReturn;
|
|||
size_t uxTail = pxBuffer->uxTail;
|
||||
|
||||
/* Returns true if ( uxLeft < uxRight ) */
|
||||
if( ( uxLeft < uxTail ) ^ ( uxRight < uxTail ) )
|
||||
if( ( ( ( uxLeft < uxTail ) ? 1U : 0U ) ^ ( ( uxRight < uxTail ) ? 1U : 0U ) ) != 0U )
|
||||
{
|
||||
if( uxRight < uxTail )
|
||||
{
|
||||
|
@ -211,7 +212,7 @@ size_t uxSize = uxStreamBufferGetSize( pxBuffer );
|
|||
* pucData - A pointer to the data to be added.
|
||||
* uxCount - The number of bytes to add.
|
||||
*/
|
||||
size_t uxStreamBufferAdd( StreamBuffer_t *pxBuffer, size_t uxOffset, const uint8_t *pucData, size_t uxCount );
|
||||
size_t uxStreamBufferAdd( StreamBuffer_t *pxBuffer, size_t uxOffset, const uint8_t *pucData, size_t uxByteCount );
|
||||
|
||||
/*
|
||||
* Read bytes from a stream buffer.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* FreeRTOS+TCP V2.2.0
|
||||
* FreeRTOS+TCP V2.2.1
|
||||
* 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
|
||||
|
@ -30,13 +30,13 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
BaseType_t xProcessReceivedTCPPacket( NetworkBufferDescriptor_t *pxNetworkBuffer );
|
||||
BaseType_t xProcessReceivedTCPPacket( NetworkBufferDescriptor_t *pxDescriptor );
|
||||
|
||||
typedef enum eTCP_STATE {
|
||||
/* Comments about the TCP states are borrowed from the very useful
|
||||
* Wiki page:
|
||||
* http://en.wikipedia.org/wiki/Transmission_Control_Protocol */
|
||||
eCLOSED = 0u, /* 0 (server + client) no connection state at all. */
|
||||
eCLOSED = 0U, /* 0 (server + client) no connection state at all. */
|
||||
eTCP_LISTEN, /* 1 (server) waiting for a connection request
|
||||
from any remote TCP and port. */
|
||||
eCONNECT_SYN, /* 2 (client) internal state: socket wants to send
|
||||
|
@ -50,11 +50,11 @@ typedef enum eTCP_STATE {
|
|||
or an acknowledgement of the connection termination request previously sent. */
|
||||
eFIN_WAIT_2, /* 7 (server + client) waiting for a connection termination request from the remote TCP. */
|
||||
eCLOSE_WAIT, /* 8 (server + client) waiting for a connection termination request from the local user. */
|
||||
eCLOSING, /* (server + client) waiting for a connection termination request acknowledgement from the remote TCP. */
|
||||
eLAST_ACK, /* 9 (server + client) waiting for an acknowledgement of the connection termination request
|
||||
eCLOSING, /* 9 (server + client) waiting for a connection termination request acknowledgement from the remote TCP. */
|
||||
eLAST_ACK, /*10 (server + client) waiting for an acknowledgement of the connection termination request
|
||||
previously sent to the remote TCP
|
||||
(which includes an acknowledgement of its connection termination request). */
|
||||
eTIME_WAIT, /* 10 (either server or client) waiting for enough time to pass to be sure the remote TCP received the
|
||||
eTIME_WAIT, /*11 (either server or client) waiting for enough time to pass to be sure the remote TCP received the
|
||||
acknowledgement of its connection termination request. [According to RFC 793 a connection can
|
||||
stay in TIME-WAIT for a maximum of four minutes known as a MSL (maximum segment lifetime).] */
|
||||
} eIPTCPState_t;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* FreeRTOS+TCP V2.2.0
|
||||
* FreeRTOS+TCP V2.2.1
|
||||
* 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
|
||||
|
@ -35,9 +35,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern BaseType_t xTCPWindowLoggingLevel;
|
||||
|
||||
typedef struct xTCPTimer
|
||||
/* The name xTCPTimer was already use as the name of an IP-timer. */
|
||||
typedef struct xTCPTimerStruct
|
||||
{
|
||||
uint32_t ulBorn;
|
||||
} TCPTimer_t;
|
||||
|
@ -64,7 +63,7 @@ typedef struct xTCP_SEGMENT
|
|||
} u;
|
||||
#if( ipconfigUSE_TCP_WIN != 0 )
|
||||
struct xLIST_ITEM xQueueItem; /* TX only: segments can be linked in one of three queues: xPriorityQueue, xTxQueue, and xWaitQueue */
|
||||
struct xLIST_ITEM xListItem; /* With this item the segment can be connected to a list, depending on who is owning it */
|
||||
struct xLIST_ITEM xSegmentItem; /* With this item the segment can be connected to a list, depending on who is owning it */
|
||||
#endif
|
||||
} TCPSegment_t;
|
||||
|
||||
|
@ -80,9 +79,9 @@ typedef struct xTCP_WINSIZE
|
|||
*/
|
||||
/* Keep this as a multiple of 4 */
|
||||
#if( ipconfigUSE_TCP_WIN == 1 )
|
||||
#define ipSIZE_TCP_OPTIONS 16u
|
||||
#define ipSIZE_TCP_OPTIONS 16U
|
||||
#else
|
||||
#define ipSIZE_TCP_OPTIONS 12u
|
||||
#define ipSIZE_TCP_OPTIONS 12U
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -149,7 +148,7 @@ void vTCPWindowCreate( TCPWindow_t *pxWindow, uint32_t ulRxWindowLength,
|
|||
|
||||
/* Destroy a window (always returns NULL)
|
||||
* It will free some resources: a collection of segments */
|
||||
void vTCPWindowDestroy( TCPWindow_t *pxWindow );
|
||||
void vTCPWindowDestroy( TCPWindow_t const * pxWindow );
|
||||
|
||||
/* Initialize a window */
|
||||
void vTCPWindowInit( TCPWindow_t *pxWindow, uint32_t ulAckNumber, uint32_t ulSequenceNumber, uint32_t ulMSS );
|
||||
|
@ -167,16 +166,9 @@ void vTCPSegmentCleanup( void );
|
|||
* But pxWindow->ackno should always be used to set "BUF->ackno" */
|
||||
int32_t lTCPWindowRxCheck( TCPWindow_t *pxWindow, uint32_t ulSequenceNumber, uint32_t ulLength, uint32_t ulSpace );
|
||||
|
||||
/* When lTCPWindowRxCheck returned false, please call store for this unexpected data */
|
||||
BaseType_t xTCPWindowRxStore( TCPWindow_t *pxWindow, uint32_t ulSequenceNumber, uint32_t ulLength );
|
||||
|
||||
/* This function will be called as soon as a FIN is received. It will return true
|
||||
* if there are no 'open' reception segments */
|
||||
BaseType_t xTCPWindowRxEmpty( TCPWindow_t *pxWindow );
|
||||
|
||||
/* _HT_ Temporary function for testing/debugging
|
||||
* Not used at this moment */
|
||||
void vTCPWinShowSegments( TCPWindow_t *pxWindow, BaseType_t bForRx );
|
||||
BaseType_t xTCPWindowRxEmpty( const TCPWindow_t *pxWindow );
|
||||
|
||||
/*=============================================================================
|
||||
*
|
||||
|
@ -188,12 +180,12 @@ void vTCPWinShowSegments( TCPWindow_t *pxWindow, BaseType_t bForRx );
|
|||
int32_t lTCPWindowTxAdd( TCPWindow_t *pxWindow, uint32_t ulLength, int32_t lPosition, int32_t lMax );
|
||||
|
||||
/* Check data to be sent and calculate the time period we may sleep */
|
||||
BaseType_t xTCPWindowTxHasData( TCPWindow_t *pxWindow, uint32_t ulWindowSize, TickType_t *pulDelay );
|
||||
BaseType_t xTCPWindowTxHasData( TCPWindow_t const * pxWindow, uint32_t ulWindowSize, TickType_t *pulDelay );
|
||||
|
||||
/* See if anything is left to be sent
|
||||
* Function will be called when a FIN has been received. Only when the TX window is clean,
|
||||
* it will return pdTRUE */
|
||||
BaseType_t xTCPWindowTxDone( TCPWindow_t *pxWindow );
|
||||
BaseType_t xTCPWindowTxDone( const TCPWindow_t *pxWindow );
|
||||
|
||||
/* Fetches data to be sent.
|
||||
* apPos will point to a location with the circular data buffer: txStream */
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* FreeRTOS+TCP V2.2.0
|
||||
* FreeRTOS+TCP V2.2.1
|
||||
* 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
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* FreeRTOS+TCP V2.2.0
|
||||
* FreeRTOS+TCP V2.2.1
|
||||
* 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
|
||||
|
@ -64,6 +64,7 @@ already been made. */
|
|||
#define pdFREERTOS_ERRNO_ENOTEMPTY 90 /* Directory not empty */
|
||||
#define pdFREERTOS_ERRNO_ENAMETOOLONG 91 /* File or path name too long */
|
||||
#define pdFREERTOS_ERRNO_EOPNOTSUPP 95 /* Operation not supported on transport endpoint */
|
||||
#define pdFREERTOS_ERRNO_EAFNOSUPPORT 97 /* Address family not supported by protocol */
|
||||
#define pdFREERTOS_ERRNO_ENOBUFS 105 /* No buffer space available */
|
||||
#define pdFREERTOS_ERRNO_ENOPROTOOPT 109 /* Protocol not available */
|
||||
#define pdFREERTOS_ERRNO_EADDRINUSE 112 /* Address already in use */
|
||||
|
@ -81,9 +82,15 @@ already been made. */
|
|||
itself. */
|
||||
#define pdFREERTOS_LITTLE_ENDIAN 0
|
||||
#define pdFREERTOS_BIG_ENDIAN 1
|
||||
|
||||
#else
|
||||
#ifndef pdFREERTOS_ERRNO_EAFNOSUPPORT
|
||||
#define pdFREERTOS_ERRNO_EAFNOSUPPORT 97 /* Address family not supported by protocol */
|
||||
#endif /* pdFREERTOS_ERRNO_EAFNOSUPPORT */
|
||||
#endif /* pdFREERTOS_ERRNO_NONE */
|
||||
|
||||
/* Translate a pdFREERTOS_ERRNO code to a human readable string. */
|
||||
const char *FreeRTOS_strerror_r( BaseType_t xErrnum, char *pcBuffer, size_t uxLength );
|
||||
|
||||
#endif /* FREERTOS_ERRNO_TCP */
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* FreeRTOS+TCP V2.2.0
|
||||
* FreeRTOS+TCP V2.2.1
|
||||
* 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
|
||||
|
@ -190,4 +190,44 @@ http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_IP_Trace.html */
|
|||
#define iptraceSENDTO_DATA_TOO_LONG()
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigUSE_TCP_MEM_STATS
|
||||
#define ipconfigUSE_TCP_MEM_STATS 0
|
||||
#endif
|
||||
|
||||
#if( ipconfigUSE_TCP_MEM_STATS == 0 )
|
||||
|
||||
/* See tools/tcp_mem_stat.c */
|
||||
|
||||
#ifndef iptraceMEM_STATS_CREATE
|
||||
#define iptraceMEM_STATS_CREATE( xMemType, pxObject, uxSize )
|
||||
#endif
|
||||
|
||||
#ifndef iptraceMEM_STATS_DELETE
|
||||
#define iptraceMEM_STATS_DELETE( pxObject )
|
||||
#endif
|
||||
|
||||
#ifndef iptraceMEM_STATS_CLOSE
|
||||
#define iptraceMEM_STATS_CLOSE()
|
||||
#endif
|
||||
|
||||
#endif /* ( ipconfigUSE_TCP_MEM_STATS != 0 ) */
|
||||
|
||||
#ifndef ipconfigUSE_DUMP_PACKETS
|
||||
#define ipconfigUSE_DUMP_PACKETS 0
|
||||
#endif
|
||||
|
||||
#if( ipconfigUSE_DUMP_PACKETS == 0 )
|
||||
|
||||
/* See tools/tcp_dump_packets.c */
|
||||
|
||||
#ifndef iptraceDUMP_INIT
|
||||
#define iptraceDUMP_INIT( pcFileName, pxEntries )
|
||||
#endif
|
||||
|
||||
#ifndef iptraceDUMP_PACKET
|
||||
#define iptraceDUMP_PACKET( pucBuffer, uxLength, xIncoming )
|
||||
#endif
|
||||
|
||||
#endif /* ( ipconfigUSE_DUMP_PACKETS != 0 ) */
|
||||
|
||||
#endif /* UDP_TRACE_MACRO_DEFAULTS_H */
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* FreeRTOS+TCP V2.2.0
|
||||
* FreeRTOS+TCP V2.2.1
|
||||
* 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
|
||||
|
@ -46,7 +46,7 @@ UBaseType_t uxGetNumberOfFreeNetworkBuffers( void );
|
|||
UBaseType_t uxGetMinimumFreeNetworkBuffers( void );
|
||||
|
||||
/* Copy a network buffer into a bigger buffer. */
|
||||
NetworkBufferDescriptor_t *pxDuplicateNetworkBufferWithDescriptor( NetworkBufferDescriptor_t * const pxNetworkBuffer,
|
||||
NetworkBufferDescriptor_t *pxDuplicateNetworkBufferWithDescriptor( const NetworkBufferDescriptor_t * const pxNetworkBuffer,
|
||||
size_t uxNewLength);
|
||||
|
||||
/* Increase the size of a Network Buffer.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* FreeRTOS+TCP V2.2.0
|
||||
* FreeRTOS+TCP V2.2.1
|
||||
* 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
|
||||
|
@ -30,10 +30,16 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* NOTE PUBLIC API FUNCTIONS. */
|
||||
/* INTERNAL API FUNCTIONS. */
|
||||
BaseType_t xNetworkInterfaceInitialise( void );
|
||||
BaseType_t xNetworkInterfaceOutput( NetworkBufferDescriptor_t * const pxNetworkBuffer, BaseType_t xReleaseAfterSend );
|
||||
/* coverity[misra_c_2012_rule_8_6_violation] */
|
||||
/* "vNetworkInterfaceAllocateRAMToBuffers" is declared but never defined.
|
||||
The following function is only used when BufferAllocation_1.c is linked in the project. */
|
||||
void vNetworkInterfaceAllocateRAMToBuffers( NetworkBufferDescriptor_t pxNetworkBuffers[ ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS ] );
|
||||
|
||||
/* "xGetPhyLinkStatus" is provided by the network driver. */
|
||||
/* coverity[misra_c_2012_rule_8_6_violation] */
|
||||
BaseType_t xGetPhyLinkStatus( void );
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* dump_packets.c
|
||||
* Used in the PC/Win project to dump Ethernet packets, along with some description.
|
||||
*/
|
||||
|
||||
#ifndef DUMP_PACKETS_H
|
||||
|
||||
|
||||
#define DUMP_PACKETS_H
|
||||
|
||||
#ifndef dumpMAX_DUMP_ENTRIES
|
||||
#define dumpMAX_DUMP_ENTRIES 16
|
||||
#endif
|
||||
|
||||
#define flag_ICMP4 0x00000001UL
|
||||
#define flag_ICMP6 0x00000002UL
|
||||
#define flag_UDP 0x00000004UL
|
||||
#define flag_TCP 0x00000008UL
|
||||
#define flag_DNS 0x00000010UL
|
||||
#define flag_REPLY 0x00000020UL
|
||||
#define flag_REQUEST 0x00000040UL
|
||||
#define flag_SYN 0x00000080UL
|
||||
#define flag_FIN 0x00000100UL
|
||||
#define flag_RST 0x00000200UL
|
||||
#define flag_ACK 0x00000400UL
|
||||
#define flag_IN 0x00000800UL
|
||||
#define flag_OUT 0x00001000UL
|
||||
#define flag_FRAME_ARP 0x00002000UL
|
||||
#define flag_ARP 0x00004000UL
|
||||
#define flag_UNKNOWN 0x00008000UL
|
||||
#define flag_FRAME_4 0x00010000UL
|
||||
#define flag_FRAME_6 0x00020000UL
|
||||
#define flag_Unknown_FRAME 0x00040000UL
|
||||
|
||||
typedef struct xDumpEntry
|
||||
{
|
||||
uint32_t ulMask;
|
||||
size_t uxMax;
|
||||
size_t uxCount;
|
||||
} DumpEntry_t;
|
||||
|
||||
typedef struct xDumpEntries
|
||||
{
|
||||
size_t uxEntryCount;
|
||||
DumpEntry_t xEntries[ dumpMAX_DUMP_ENTRIES ];
|
||||
} DumpEntries_t;
|
||||
|
||||
/*
|
||||
|
||||
*/
|
||||
|
||||
#if( ipconfigUSE_DUMP_PACKETS != 0 )
|
||||
|
||||
extern void dump_packet_init( const char *pcFileName, DumpEntries_t *pxEntries );
|
||||
#define iptraceDUMP_INIT( pcFileName, pxEntries ) \
|
||||
dump_packet_init( pcFileName, pxEntries )
|
||||
|
||||
extern void dump_packet( const uint8_t *pucBuffer, size_t uxLength, BaseType_t xIncoming );
|
||||
#define iptraceDUMP_PACKET( pucBuffer, uxLength, xIncoming ) \
|
||||
dump_packet( pucBuffer, uxLength, xIncoming )
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* tcp_mem_stats.h
|
||||
*/
|
||||
|
||||
|
||||
#ifndef TCP_MEM_STATS_H
|
||||
|
||||
#define TCP_MEM_STATS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum xTCP_MEMORY
|
||||
{
|
||||
tcpSOCKET_TCP,
|
||||
tcpSOCKET_UDP,
|
||||
tcpSOCKET_SET,
|
||||
tcpSEMAPHORE,
|
||||
tcpRX_STREAM_BUFFER,
|
||||
tcpTX_STREAM_BUFFER,
|
||||
tcpNETWORK_BUFFER,
|
||||
} TCP_MEMORY_t;
|
||||
|
||||
#if( ipconfigUSE_TCP_MEM_STATS != 0 )
|
||||
|
||||
void vTCPMemStatCreate( TCP_MEMORY_t xMemType, void *pxObject, size_t uxSize );
|
||||
|
||||
void vTCPMemStatDelete( void *pxObject );
|
||||
|
||||
void vTCPMemStatClose( void );
|
||||
|
||||
#define iptraceMEM_STATS_CREATE( xMemType, pxObject, uxSize ) \
|
||||
vTCPMemStatCreate( xMemType, pxObject, uxSize )
|
||||
|
||||
#define iptraceMEM_STATS_DELETE( pxObject ) \
|
||||
vTCPMemStatDelete( pxObject )
|
||||
|
||||
#define iptraceMEM_STATS_CLOSE() \
|
||||
vTCPMemStatClose()
|
||||
#else
|
||||
|
||||
/* The header file 'IPTraceMacroDefaults.h' will define the default empty macro's. */
|
||||
|
||||
#endif /* ipconfigUSE_TCP_MEM_STATS != 0 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* TCP_MEM_STATS_H */
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue