CARPLAY版本整理
This commit is contained in:
@ -0,0 +1,321 @@
|
||||
/*
|
||||
* FreeRTOS Kernel V10.4.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
|
||||
* 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
|
||||
*/
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* See the following URL for configuration information.
|
||||
* http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_IP_Configuration.html
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef FREERTOS_IP_CONFIG_H
|
||||
#define FREERTOS_IP_CONFIG_H
|
||||
|
||||
/* Set to 1 to print out debug messages. If ipconfigHAS_DEBUG_PRINTF is set to
|
||||
* 1 then FreeRTOS_debug_printf should be defined to the function used to print
|
||||
* out the debugging messages. */
|
||||
#define ipconfigHAS_DEBUG_PRINTF 0
|
||||
#if ( ipconfigHAS_DEBUG_PRINTF == 1 )
|
||||
#define FreeRTOS_debug_printf( X ) printf X
|
||||
//configPRINTF( X )
|
||||
#endif
|
||||
|
||||
/* Set to 1 to print out non debugging messages, for example the output of the
|
||||
* FreeRTOS_netstat() command, and ping replies. If ipconfigHAS_PRINTF is set to 1
|
||||
* then FreeRTOS_printf should be set to the function used to print out the
|
||||
* messages. */
|
||||
#define ipconfigHAS_PRINTF 1
|
||||
#if ( ipconfigHAS_PRINTF == 1 )
|
||||
#define FreeRTOS_printf( X ) configPRINTF( X )
|
||||
#endif
|
||||
|
||||
/* Define the byte order of the target MCU (the MCU FreeRTOS+TCP is executing
|
||||
* on). Valid options are pdFREERTOS_BIG_ENDIAN and pdFREERTOS_LITTLE_ENDIAN. */
|
||||
#define ipconfigBYTE_ORDER pdFREERTOS_LITTLE_ENDIAN
|
||||
|
||||
/* If the network card/driver includes checksum offloading (IP/TCP/UDP checksums)
|
||||
* then set ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM to 1 to prevent the software
|
||||
* stack repeating the checksum calculations. */
|
||||
#define ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM 1
|
||||
|
||||
/* Several API's will block until the result is known, or the action has been
|
||||
* performed, for example FreeRTOS_send() and FreeRTOS_recv(). The timeouts can be
|
||||
* set per socket, using setsockopt(). If not set, the times below will be
|
||||
* used as defaults. */
|
||||
#define ipconfigSOCK_DEFAULT_RECEIVE_BLOCK_TIME ( 5000 )
|
||||
#define ipconfigSOCK_DEFAULT_SEND_BLOCK_TIME ( 5000 )
|
||||
|
||||
/* Include support for DNS caching. For TCP, having a small DNS cache is very
|
||||
* useful. When a cache is present, ipconfigDNS_REQUEST_ATTEMPTS can be kept low
|
||||
* and also DNS may use small timeouts. If a DNS reply comes in after the DNS
|
||||
* socket has been destroyed, the result will be stored into the cache. The next
|
||||
* call to FreeRTOS_gethostbyname() will return immediately, without even creating
|
||||
* a socket.
|
||||
*/
|
||||
#define ipconfigUSE_DNS_CACHE ( 1 )
|
||||
#define ipconfigDNS_CACHE_ADDRESSES_PER_ENTRY ( 6 )
|
||||
#define ipconfigDNS_REQUEST_ATTEMPTS ( 2 )
|
||||
|
||||
/* The IP stack executes it its own task (although any application task can make
|
||||
* use of its services through the published sockets API). ipconfigUDP_TASK_PRIORITY
|
||||
* sets the priority of the task that executes the IP stack. The priority is a
|
||||
* standard FreeRTOS task priority so can take any value from 0 (the lowest
|
||||
* priority) to (configMAX_PRIORITIES - 1) (the highest priority).
|
||||
* configMAX_PRIORITIES is a standard FreeRTOS configuration parameter defined in
|
||||
* FreeRTOSConfig.h, not FreeRTOSIPConfig.h. Consideration needs to be given as to
|
||||
* the priority assigned to the task executing the IP stack relative to the
|
||||
* priority assigned to tasks that use the IP stack. */
|
||||
#define ipconfigIP_TASK_PRIORITY ( configMAX_PRIORITIES - 2 )
|
||||
|
||||
/* The size, in words (not bytes), of the stack allocated to the FreeRTOS+TCP
|
||||
* task. This setting is less important when the FreeRTOS Win32 simulator is used
|
||||
* as the Win32 simulator only stores a fixed amount of information on the task
|
||||
* stack. FreeRTOS includes optional stack overflow detection, see:
|
||||
* http://www.freertos.org/Stacks-and-stack-overflow-checking.html. */
|
||||
#define ipconfigIP_TASK_STACK_SIZE_WORDS ( configMINIMAL_STACK_SIZE * 5 )
|
||||
|
||||
/* ipconfigRAND32() is called by the IP stack to generate random numbers for
|
||||
* things such as a DHCP transaction number or initial sequence number. Random
|
||||
* number generation is performed via this macro to allow applications to use their
|
||||
* own random number generation method. For example, it might be possible to
|
||||
* generate a random number by sampling noise on an analogue input. */
|
||||
extern uint32_t ulRand();
|
||||
#define ipconfigRAND32() ulRand()
|
||||
|
||||
/* If ipconfigUSE_NETWORK_EVENT_HOOK is set to 1 then FreeRTOS+TCP will call the
|
||||
* network event hook at the appropriate times. If ipconfigUSE_NETWORK_EVENT_HOOK
|
||||
* is not set to 1 then the network event hook will never be called. See:
|
||||
* http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_UDP/API/vApplicationIPNetworkEventHook.shtml.
|
||||
*/
|
||||
#define ipconfigUSE_NETWORK_EVENT_HOOK 0
|
||||
|
||||
/* Sockets have a send block time attribute. If FreeRTOS_sendto() is called but
|
||||
* a network buffer cannot be obtained then the calling task is held in the Blocked
|
||||
* state (so other tasks can continue to executed) until either a network buffer
|
||||
* becomes available or the send block time expires. If the send block time expires
|
||||
* then the send operation is aborted. The maximum allowable send block time is
|
||||
* capped to the value set by ipconfigMAX_SEND_BLOCK_TIME_TICKS. Capping the
|
||||
* maximum allowable send block time prevents prevents a deadlock occurring when
|
||||
* all the network buffers are in use and the tasks that process (and subsequently
|
||||
* free) the network buffers are themselves blocked waiting for a network buffer.
|
||||
* ipconfigMAX_SEND_BLOCK_TIME_TICKS is specified in RTOS ticks. A time in
|
||||
* milliseconds can be converted to a time in ticks by dividing the time in
|
||||
* milliseconds by portTICK_PERIOD_MS. */
|
||||
#define ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS ( 5000U / portTICK_PERIOD_MS )
|
||||
|
||||
/* If ipconfigUSE_DHCP is 1 then FreeRTOS+TCP will attempt to retrieve an IP
|
||||
* address, netmask, DNS server address and gateway address from a DHCP server. If
|
||||
* ipconfigUSE_DHCP is 0 then FreeRTOS+TCP will use a static IP address. The
|
||||
* stack will revert to using the static IP address even when ipconfigUSE_DHCP is
|
||||
* set to 1 if a valid configuration cannot be obtained from a DHCP server for any
|
||||
* reason. The static configuration used is that passed into the stack by the
|
||||
* FreeRTOS_IPInit() function call. */
|
||||
#define ipconfigUSE_DHCP 1
|
||||
#define ipconfigDHCP_REGISTER_HOSTNAME 0
|
||||
#define ipconfigDHCP_USES_UNICAST 1
|
||||
|
||||
/* If ipconfigDHCP_USES_USER_HOOK is set to 1 then the application writer must
|
||||
* provide an implementation of the DHCP callback function,
|
||||
* xApplicationDHCPUserHook(). */
|
||||
#define ipconfigUSE_DHCP_HOOK 1
|
||||
|
||||
/* When ipconfigUSE_DHCP is set to 1, DHCP requests will be sent out at
|
||||
* increasing time intervals until either a reply is received from a DHCP server
|
||||
* and accepted, or the interval between transmissions reaches
|
||||
* ipconfigMAXIMUM_DISCOVER_TX_PERIOD. The IP stack will revert to using the
|
||||
* static IP address passed as a parameter to FreeRTOS_IPInit() if the
|
||||
* re-transmission time interval reaches ipconfigMAXIMUM_DISCOVER_TX_PERIOD without
|
||||
* a DHCP reply being received. */
|
||||
#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD \
|
||||
( 120000U / portTICK_PERIOD_MS )
|
||||
|
||||
/* The ARP cache is a table that maps IP addresses to MAC addresses. The IP
|
||||
* stack can only send a UDP message to a remove IP address if it knowns the MAC
|
||||
* address associated with the IP address, or the MAC address of the router used to
|
||||
* contact the remote IP address. When a UDP message is received from a remote IP
|
||||
* address the MAC address and IP address are added to the ARP cache. When a UDP
|
||||
* message is sent to a remote IP address that does not already appear in the ARP
|
||||
* cache then the UDP message is replaced by a ARP message that solicits the
|
||||
* required MAC address information. ipconfigARP_CACHE_ENTRIES defines the maximum
|
||||
* number of entries that can exist in the ARP table at any one time. */
|
||||
#define ipconfigARP_CACHE_ENTRIES 6
|
||||
|
||||
/* ARP requests that do not result in an ARP response will be re-transmitted a
|
||||
* maximum of ipconfigMAX_ARP_RETRANSMISSIONS times before the ARP request is
|
||||
* aborted. */
|
||||
#define ipconfigMAX_ARP_RETRANSMISSIONS ( 5 )
|
||||
|
||||
/* ipconfigMAX_ARP_AGE defines the maximum time between an entry in the ARP
|
||||
* table being created or refreshed and the entry being removed because it is stale.
|
||||
* New ARP requests are sent for ARP cache entries that are nearing their maximum
|
||||
* age. ipconfigMAX_ARP_AGE is specified in tens of seconds, so a value of 150 is
|
||||
* equal to 1500 seconds (or 25 minutes). */
|
||||
#define ipconfigMAX_ARP_AGE 150
|
||||
|
||||
/* Implementing FreeRTOS_inet_addr() necessitates the use of string handling
|
||||
* routines, which are relatively large. To save code space the full
|
||||
* FreeRTOS_inet_addr() implementation is made optional, and a smaller and faster
|
||||
* alternative called FreeRTOS_inet_addr_quick() is provided. FreeRTOS_inet_addr()
|
||||
* takes an IP in decimal dot format (for example, "192.168.0.1") as its parameter.
|
||||
* FreeRTOS_inet_addr_quick() takes an IP address as four separate numerical octets
|
||||
* (for example, 192, 168, 0, 1) as its parameters. If
|
||||
* ipconfigINCLUDE_FULL_INET_ADDR is set to 1 then both FreeRTOS_inet_addr() and
|
||||
* FreeRTOS_indet_addr_quick() are available. If ipconfigINCLUDE_FULL_INET_ADDR is
|
||||
* not set to 1 then only FreeRTOS_indet_addr_quick() is available. */
|
||||
#define ipconfigINCLUDE_FULL_INET_ADDR 1
|
||||
|
||||
/* ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS defines the total number of network buffer that
|
||||
* are available to the IP stack. The total number of network buffers is limited
|
||||
* to ensure the total amount of RAM that can be consumed by the IP stack is capped
|
||||
* to a pre-determinable value. */
|
||||
#define ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS 60
|
||||
|
||||
/* A FreeRTOS queue is used to send events from application tasks to the IP
|
||||
* stack. ipconfigEVENT_QUEUE_LENGTH sets the maximum number of events that can
|
||||
* be queued for processing at any one time. The event queue must be a minimum of
|
||||
* 5 greater than the total number of network buffers. */
|
||||
#define ipconfigEVENT_QUEUE_LENGTH \
|
||||
( ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS + 5 )
|
||||
|
||||
/* The address of a socket is the combination of its IP address and its port
|
||||
* number. FreeRTOS_bind() is used to manually allocate a port number to a socket
|
||||
* (to 'bind' the socket to a port), but manual binding is not normally necessary
|
||||
* for client sockets (those sockets that initiate outgoing connections rather than
|
||||
* wait for incoming connections on a known port number). If
|
||||
* ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 1 then calling
|
||||
* FreeRTOS_sendto() on a socket that has not yet been bound will result in the IP
|
||||
* stack automatically binding the socket to a port number from the range
|
||||
* socketAUTO_PORT_ALLOCATION_START_NUMBER to 0xffff. If
|
||||
* ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 0 then calling FreeRTOS_sendto()
|
||||
* on a socket that has not yet been bound will result in the send operation being
|
||||
* aborted. */
|
||||
#define ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND 1
|
||||
|
||||
/* Defines the Time To Live (TTL) values used in outgoing UDP packets. */
|
||||
#define ipconfigUDP_TIME_TO_LIVE 128
|
||||
/* Also defined in FreeRTOSIPConfigDefaults.h. */
|
||||
#define ipconfigTCP_TIME_TO_LIVE 128
|
||||
|
||||
/* USE_TCP: Use TCP and all its features. */
|
||||
#define ipconfigUSE_TCP ( 1 )
|
||||
|
||||
/* USE_WIN: Let TCP use windowing mechanism. */
|
||||
#define ipconfigUSE_TCP_WIN ( 1 )
|
||||
|
||||
/* The MTU is the maximum number of bytes the payload of a network frame can
|
||||
* contain. For normal Ethernet V2 frames the maximum MTU is 1500. Setting a
|
||||
* lower value can save RAM, depending on the buffer management scheme used. If
|
||||
* ipconfigCAN_FRAGMENT_OUTGOING_PACKETS is 1 then (ipconfigNETWORK_MTU - 28) must
|
||||
* be divisible by 8. */
|
||||
#define ipconfigNETWORK_MTU 1500U
|
||||
|
||||
/* Set ipconfigUSE_DNS to 1 to include a basic DNS client/resolver. DNS is used
|
||||
* through the FreeRTOS_gethostbyname() API function. */
|
||||
#define ipconfigUSE_DNS 0
|
||||
|
||||
/* If ipconfigREPLY_TO_INCOMING_PINGS is set to 1 then the IP stack will
|
||||
* generate replies to incoming ICMP echo (ping) requests. */
|
||||
#define ipconfigREPLY_TO_INCOMING_PINGS 1
|
||||
|
||||
/* If ipconfigSUPPORT_OUTGOING_PINGS is set to 1 then the
|
||||
* FreeRTOS_SendPingRequest() API function is available. */
|
||||
#define ipconfigSUPPORT_OUTGOING_PINGS 1
|
||||
|
||||
/* If ipconfigSUPPORT_SELECT_FUNCTION is set to 1 then the FreeRTOS_select()
|
||||
* (and associated) API function is available. */
|
||||
#define ipconfigSUPPORT_SELECT_FUNCTION 1
|
||||
|
||||
/* If ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES is set to 1 then Ethernet frames
|
||||
* that are not in Ethernet II format will be dropped. This option is included for
|
||||
* potential future IP stack developments. */
|
||||
#define ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES 1
|
||||
|
||||
/* If ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES is set to 1 then it is the
|
||||
* responsibility of the Ethernet interface to filter out packets that are of no
|
||||
* interest. If the Ethernet interface does not implement this functionality, then
|
||||
* set ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES to 0 to have the IP stack
|
||||
* perform the filtering instead (it is much less efficient for the stack to do it
|
||||
* because the packet will already have been passed into the stack). If the
|
||||
* Ethernet driver does all the necessary filtering in hardware then software
|
||||
* filtering can be removed by using a value other than 1 or 0. */
|
||||
#define ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES 1
|
||||
|
||||
/* The windows simulator cannot really simulate MAC interrupts, and needs to
|
||||
* block occasionally to allow other tasks to run. */
|
||||
#define configWINDOWS_MAC_INTERRUPT_SIMULATOR_DELAY ( 20 / portTICK_PERIOD_MS )
|
||||
|
||||
/* Advanced only: in order to access 32-bit fields in the IP packets with
|
||||
* 32-bit memory instructions, all packets will be stored 32-bit-aligned,
|
||||
* plus 16-bits. This has to do with the contents of the IP-packets: all
|
||||
* 32-bit fields are 32-bit-aligned, plus 16-bit. */
|
||||
#define ipconfigPACKET_FILLER_SIZE 2U
|
||||
|
||||
/* Define the size of the pool of TCP window descriptors. On the average, each
|
||||
* TCP socket will use up to 2 x 6 descriptors, meaning that it can have 2 x 6
|
||||
* outstanding packets (for Rx and Tx). When using up to 10 TP sockets
|
||||
* simultaneously, one could define TCP_WIN_SEG_COUNT as 120. */
|
||||
#define ipconfigTCP_WIN_SEG_COUNT 240
|
||||
|
||||
/* Each TCP socket has a circular buffers for Rx and Tx, which have a fixed
|
||||
* maximum size. Define the size of Rx buffer for TCP sockets. */
|
||||
#define ipconfigTCP_RX_BUFFER_LENGTH ( 10000 )
|
||||
|
||||
/* Define the size of Tx buffer for TCP sockets. */
|
||||
#define ipconfigTCP_TX_BUFFER_LENGTH ( 10000 )
|
||||
|
||||
/* When using call-back handlers, the driver may check if the handler points to
|
||||
* real program memory (RAM or flash) or just has a random non-zero value. */
|
||||
#define ipconfigIS_VALID_PROG_ADDRESS( x ) ( ( x ) != NULL )
|
||||
|
||||
/* Include support for TCP keep-alive messages. */
|
||||
#define ipconfigTCP_KEEP_ALIVE ( 1 )
|
||||
#define ipconfigTCP_KEEP_ALIVE_INTERVAL ( 20 ) /* Seconds. */
|
||||
|
||||
/* The socket semaphore is used to unblock the MQTT task. */
|
||||
#define ipconfigSOCKET_HAS_USER_SEMAPHORE ( 1 )
|
||||
|
||||
#define ipconfigSOCKET_HAS_USER_WAKE_CALLBACK ( 1 )
|
||||
#define ipconfigUSE_CALLBACKS ( 0 )
|
||||
|
||||
|
||||
#define portINLINE inline
|
||||
|
||||
#define USE_IPERF 1
|
||||
#define ipconfigIPERF_DOES_ECHO_UDP 1
|
||||
|
||||
#define ipconfigIPERF_VERSION 3
|
||||
#define ipconfigIPERF_STACK_SIZE_IPERF_TASK 680
|
||||
|
||||
#define ipconfigIPERF_TX_BUFSIZE ( 26 * ipconfigTCP_MSS )
|
||||
#define ipconfigIPERF_TX_WINSIZE ( 26 )
|
||||
#define ipconfigIPERF_RX_BUFSIZE ( 48 * ipconfigTCP_MSS )
|
||||
#define ipconfigIPERF_RX_WINSIZE ( 48 )
|
||||
|
||||
/* The iperf module declares a character buffer to store its send data. */
|
||||
#define ipconfigIPERF_RECV_BUFFER_SIZE ( 36 * ipconfigTCP_MSS )
|
||||
|
||||
#define ipconfigSUPPORT_SIGNALS 1
|
||||
#endif /* FREERTOS_IP_CONFIG_H */
|
@ -0,0 +1,629 @@
|
||||
/*
|
||||
* FreeRTOS+TCP V2.3.2 LTS Patch 1
|
||||
* Copyright (C) 2020 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://www.FreeRTOS.org
|
||||
* http://aws.amazon.com/freertos
|
||||
*
|
||||
* 1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
#ifndef FREERTOS_DEFAULT_IP_CONFIG_H
|
||||
#define FREERTOS_DEFAULT_IP_CONFIG_H
|
||||
|
||||
/* The error numbers defined in this file will be moved to the core FreeRTOS
|
||||
* code in future versions of FreeRTOS - at which time the following header file
|
||||
* will be removed. */
|
||||
#include "FreeRTOS_errno_TCP.h"
|
||||
|
||||
/* This file provides default values for configuration options that are missing
|
||||
* from the FreeRTOSIPConfig.h configuration header file. */
|
||||
|
||||
/* These macros are used to define away static keyword for CBMC proofs */
|
||||
#ifndef _static
|
||||
#define _static static
|
||||
#endif
|
||||
|
||||
/* Ensure defined configuration constants are using the most up to date naming. */
|
||||
#ifdef tcpconfigIP_TIME_TO_LIVE
|
||||
#error now called: ipconfigTCP_TIME_TO_LIVE
|
||||
#endif
|
||||
|
||||
#ifdef updconfigIP_TIME_TO_LIVE
|
||||
#error now called: ipconfigUDP_TIME_TO_LIVE
|
||||
#endif
|
||||
|
||||
#ifdef ipFILLER_SIZE
|
||||
#error now called: ipconfigPACKET_FILLER_SIZE
|
||||
#endif
|
||||
|
||||
#ifdef dnsMAX_REQUEST_ATTEMPTS
|
||||
#error now called: ipconfigDNS_REQUEST_ATTEMPTS
|
||||
#endif
|
||||
|
||||
#ifdef ipconfigUDP_TASK_PRIORITY
|
||||
#error now called: ipconfigIP_TASK_PRIORITY
|
||||
#endif
|
||||
|
||||
#ifdef ipconfigUDP_TASK_STACK_SIZE_WORDS
|
||||
#error now called: ipconfigIP_TASK_STACK_SIZE_WORDS
|
||||
#endif
|
||||
|
||||
#ifdef ipconfigDRIVER_INCLUDED_RX_IP_FILTERING
|
||||
#error now called: ipconfigETHERNET_DRIVER_FILTERS_PACKETS
|
||||
#endif
|
||||
|
||||
#ifdef ipconfigMAX_SEND_BLOCK_TIME_TICKS
|
||||
#error now called: ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS
|
||||
#endif
|
||||
|
||||
#ifdef ipconfigUSE_RECEIVE_CONNECT_CALLBACKS
|
||||
#error now called: ipconfigUSE_CALLBACKS
|
||||
#endif
|
||||
|
||||
#ifdef ipconfigNUM_NETWORK_BUFFERS
|
||||
#error now called: ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS
|
||||
#endif
|
||||
|
||||
#ifdef ipconfigTCP_HANG_PROT
|
||||
#error now called: ipconfigTCP_HANG_PROTECTION
|
||||
#endif
|
||||
|
||||
#ifdef ipconfigTCP_HANG_PROT_TIME
|
||||
#error now called: ipconfigTCP_HANG_PROTECTION_TIME
|
||||
#endif
|
||||
|
||||
#ifdef FreeRTOS_lprintf
|
||||
#error now called: FreeRTOS_debug_printf
|
||||
#endif
|
||||
|
||||
#if ( ipconfigEVENT_QUEUE_LENGTH < ( ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS + 5 ) )
|
||||
#error The ipconfigEVENT_QUEUE_LENGTH parameter must be at least ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS + 5
|
||||
#endif
|
||||
|
||||
#if ( ipconfigNETWORK_MTU < 46 )
|
||||
#error ipconfigNETWORK_MTU must be at least 46.
|
||||
#endif
|
||||
|
||||
#ifdef ipconfigBUFFER_ALLOC_FIXED_SIZE
|
||||
#error ipconfigBUFFER_ALLOC_FIXED_SIZE was dropped and replaced by a const value, declared in BufferAllocation[12].c
|
||||
#endif
|
||||
|
||||
#ifdef ipconfigNIC_SEND_PASSES_DMA
|
||||
#error now called: ipconfigZERO_COPY_TX_DRIVER
|
||||
#endif
|
||||
|
||||
#ifdef HAS_TX_CRC_OFFLOADING
|
||||
|
||||
/* _HT_ As these macro names have changed, throw an error
|
||||
* if they're still defined. */
|
||||
#error now called: ipconfigHAS_TX_CRC_OFFLOADING
|
||||
#endif
|
||||
|
||||
#ifdef HAS_RX_CRC_OFFLOADING
|
||||
#error now called: ipconfigHAS_RX_CRC_OFFLOADING
|
||||
#endif
|
||||
|
||||
#ifdef ipconfigTCP_RX_BUF_LEN
|
||||
#error ipconfigTCP_RX_BUF_LEN is now called ipconfigTCP_RX_BUFFER_LENGTH
|
||||
#endif
|
||||
|
||||
#ifdef ipconfigTCP_TX_BUF_LEN
|
||||
#error ipconfigTCP_TX_BUF_LEN is now called ipconfigTCP_TX_BUFFER_LENGTH
|
||||
#endif
|
||||
|
||||
#ifdef ipconfigDHCP_USES_USER_HOOK
|
||||
#error ipconfigDHCP_USES_USER_HOOK and its associated callback have been superseded - see http: /*www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_IP_Configuration.html#ipconfigUSE_DHCP_HOOK */
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigUSE_TCP
|
||||
#define ipconfigUSE_TCP ( 1 )
|
||||
#endif
|
||||
|
||||
#if ipconfigUSE_TCP
|
||||
|
||||
/* Include support for TCP scaling windows */
|
||||
#ifndef ipconfigUSE_TCP_WIN
|
||||
#define ipconfigUSE_TCP_WIN ( 1 )
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigTCP_WIN_SEG_COUNT
|
||||
#define ipconfigTCP_WIN_SEG_COUNT ( 256 )
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigIGNORE_UNKNOWN_PACKETS
|
||||
|
||||
/* When non-zero, TCP will not send RST packets in reply to
|
||||
* TCP packets which are unknown, or out-of-order. */
|
||||
#define ipconfigIGNORE_UNKNOWN_PACKETS ( 0 )
|
||||
#endif
|
||||
#endif /* if ipconfigUSE_TCP */
|
||||
|
||||
/*
|
||||
* For debugging/logging: check if the port number is used for telnet
|
||||
* Some events will not be logged for telnet connections
|
||||
* because it would produce logging about the transmission of the logging...
|
||||
* 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 )
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef ipconfigSOCK_DEFAULT_RECEIVE_BLOCK_TIME
|
||||
#define ipconfigSOCK_DEFAULT_RECEIVE_BLOCK_TIME portMAX_DELAY
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigSOCK_DEFAULT_SEND_BLOCK_TIME
|
||||
#define ipconfigSOCK_DEFAULT_SEND_BLOCK_TIME portMAX_DELAY
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef ipconfigDNS_RECEIVE_BLOCK_TIME_TICKS
|
||||
#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 )
|
||||
#endif
|
||||
|
||||
/*
|
||||
* FreeRTOS debug logging routine (proposal)
|
||||
* The macro will be called in the printf() style. Users can define
|
||||
* their own logging routine as:
|
||||
*
|
||||
* #define FreeRTOS_debug_printf( MSG ) my_printf MSG
|
||||
*
|
||||
* The FreeRTOS_debug_printf() must be thread-safe but does not have to be
|
||||
* interrupt-safe.
|
||||
*/
|
||||
#ifdef ipconfigHAS_DEBUG_PRINTF
|
||||
#if ( ipconfigHAS_DEBUG_PRINTF == 0 )
|
||||
#ifdef FreeRTOS_debug_printf
|
||||
#error Do not define FreeRTOS_debug_print if ipconfigHAS_DEBUG_PRINTF is set to 0
|
||||
#endif /* ifdef FreeRTOS_debug_printf */
|
||||
#endif /* ( ipconfigHAS_DEBUG_PRINTF == 0 ) */
|
||||
#endif /* ifdef ipconfigHAS_DEBUG_PRINTF */
|
||||
|
||||
#ifndef FreeRTOS_debug_printf
|
||||
#define FreeRTOS_debug_printf( MSG ) do {} while( ipFALSE_BOOL )
|
||||
#define ipconfigHAS_DEBUG_PRINTF 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
* FreeRTOS general logging routine (proposal)
|
||||
* Used in some utility functions such as FreeRTOS_netstat() and FreeRTOS_PrintARPCache()
|
||||
*
|
||||
* #define FreeRTOS_printf( MSG ) my_printf MSG
|
||||
*
|
||||
* The FreeRTOS_printf() must be thread-safe but does not have to be interrupt-safe
|
||||
*/
|
||||
#ifdef ipconfigHAS_PRINTF
|
||||
#if ( ipconfigHAS_PRINTF == 0 )
|
||||
#ifdef FreeRTOS_printf
|
||||
#error Do not define FreeRTOS_print if ipconfigHAS_PRINTF is set to 0
|
||||
#endif /* ifdef FreeRTOS_debug_printf */
|
||||
#endif /* ( ipconfigHAS_PRINTF == 0 ) */
|
||||
#endif /* ifdef ipconfigHAS_PRINTF */
|
||||
|
||||
#ifndef FreeRTOS_printf
|
||||
#define FreeRTOS_printf( MSG ) do {} while( ipFALSE_BOOL )
|
||||
#define ipconfigHAS_PRINTF 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
* In cases where a lot of logging is produced, FreeRTOS_flush_logging( )
|
||||
* will be called to give the logging module a chance to flush the data
|
||||
* An example of this is the netstat command, which produces many lines of logging
|
||||
*/
|
||||
#ifndef FreeRTOS_flush_logging
|
||||
#define FreeRTOS_flush_logging() do {} while( ipFALSE_BOOL )
|
||||
#endif
|
||||
|
||||
/* Malloc functions. Within most applications of FreeRTOS, the couple
|
||||
* pvPortMalloc()/vPortFree() will be used.
|
||||
* If there is also SDRAM, the user may decide to use a different memory
|
||||
* allocator:
|
||||
* MallocLarge is used to allocate large TCP buffers (for Rx/Tx)
|
||||
* MallocSocket is used to allocate the space for the sockets
|
||||
*/
|
||||
#ifndef pvPortMallocLarge
|
||||
#define pvPortMallocLarge( x ) pvPortMalloc( x )
|
||||
#endif
|
||||
|
||||
#ifndef vPortFreeLarge
|
||||
#define vPortFreeLarge( ptr ) vPortFree( ptr )
|
||||
#endif
|
||||
|
||||
#ifndef pvPortMallocSocket
|
||||
#define pvPortMallocSocket( x ) pvPortMalloc( x )
|
||||
#endif
|
||||
|
||||
#ifndef vPortFreeSocket
|
||||
#define vPortFreeSocket( ptr ) vPortFree( ptr )
|
||||
#endif
|
||||
|
||||
/*
|
||||
* At several places within the library, random numbers are needed:
|
||||
* - DHCP: For creating a DHCP transaction number
|
||||
* - TCP: Set the Initial Sequence Number: this is the value of the first outgoing
|
||||
* sequence number being used when connecting to a peer.
|
||||
* Having a well randomized ISN is important to avoid spoofing
|
||||
* - UDP/TCP: for setting the first port number to be used, in case a socket
|
||||
* uses a 'random' or anonymous port number
|
||||
*/
|
||||
#ifndef ipconfigRAND32
|
||||
#define ipconfigRAND32() rand()
|
||||
#endif
|
||||
|
||||
/* --------------------------------------------------------
|
||||
* End of: HT Added some macro defaults for the PLUS-UDP project
|
||||
* -------------------------------------------------------- */
|
||||
|
||||
#ifndef ipconfigUSE_NETWORK_EVENT_HOOK
|
||||
#define ipconfigUSE_NETWORK_EVENT_HOOK 0
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS
|
||||
#define ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS ( pdMS_TO_TICKS( 20U ) )
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigARP_CACHE_ENTRIES
|
||||
#define ipconfigARP_CACHE_ENTRIES 10
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigMAX_ARP_RETRANSMISSIONS
|
||||
#define ipconfigMAX_ARP_RETRANSMISSIONS ( 5U )
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigMAX_ARP_AGE
|
||||
#define ipconfigMAX_ARP_AGE 150U
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigUSE_ARP_REVERSED_LOOKUP
|
||||
#define ipconfigUSE_ARP_REVERSED_LOOKUP 0
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigUSE_ARP_REMOVE_ENTRY
|
||||
#define ipconfigUSE_ARP_REMOVE_ENTRY 0
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigINCLUDE_FULL_INET_ADDR
|
||||
#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
|
||||
|
||||
#ifndef ipconfigEVENT_QUEUE_LENGTH
|
||||
#define ipconfigEVENT_QUEUE_LENGTH ( ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS + 5 )
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND
|
||||
#define ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND 1
|
||||
#endif
|
||||
|
||||
/* Configuration to control whether packets with IP options,
|
||||
* received over the network, should be passed up to the
|
||||
* software stack OR should be dropped.
|
||||
* If set to 1, the stack accepts IP packets that contain IP options, but does
|
||||
* not process the options (IP options are not supported).
|
||||
* If set to 0, the stack will drop IP packets that contain IP options.
|
||||
*/
|
||||
#ifndef ipconfigIP_PASS_PACKETS_WITH_IP_OPTIONS
|
||||
#define ipconfigIP_PASS_PACKETS_WITH_IP_OPTIONS 1
|
||||
#endif
|
||||
|
||||
/* Configuration to control whether UDP packets with
|
||||
* checksum value of zero should be passed up the software
|
||||
* stack OR should be dropped.
|
||||
* If set to 1, the stack will accept UDP packets that have their checksum
|
||||
* value set to 0.
|
||||
* If set to 0, the stack will drop UDP packets that have their checksum value
|
||||
* set to 0.
|
||||
*/
|
||||
#ifndef ipconfigUDP_PASS_ZERO_CHECKSUM_PACKETS
|
||||
#define ipconfigUDP_PASS_ZERO_CHECKSUM_PACKETS 0
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigUDP_TIME_TO_LIVE
|
||||
#define ipconfigUDP_TIME_TO_LIVE 128
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigTCP_TIME_TO_LIVE
|
||||
#define ipconfigTCP_TIME_TO_LIVE 128
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigUDP_MAX_RX_PACKETS
|
||||
|
||||
/* Make positive to define the maximum number of packets which will be buffered
|
||||
* for each UDP socket.
|
||||
* Can be overridden with the socket option FREERTOS_SO_UDP_MAX_RX_PACKETS
|
||||
*/
|
||||
#define ipconfigUDP_MAX_RX_PACKETS 0U
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigUSE_DHCP
|
||||
#define ipconfigUSE_DHCP 1
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigUSE_DHCP_HOOK
|
||||
#define ipconfigUSE_DHCP_HOOK 0
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigDHCP_FALL_BACK_AUTO_IP
|
||||
|
||||
/*
|
||||
* Only applicable when DHCP is in use:
|
||||
* If no DHCP server responds, use "Auto-IP" : the
|
||||
* device will allocate a random LinkLayer IP address.
|
||||
*/
|
||||
#define ipconfigDHCP_FALL_BACK_AUTO_IP ( 0 )
|
||||
#endif
|
||||
|
||||
#if ( ipconfigDHCP_FALL_BACK_AUTO_IP != 0 )
|
||||
#define ipconfigARP_USE_CLASH_DETECTION 1
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigARP_USE_CLASH_DETECTION
|
||||
#define ipconfigARP_USE_CLASH_DETECTION 0
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigNETWORK_MTU
|
||||
#define ipconfigNETWORK_MTU 1500
|
||||
#else
|
||||
#if ipconfigNETWORK_MTU > ( SIZE_MAX >> 1 )
|
||||
#undef ipconfigNETWORK_MTU
|
||||
#define ipconfigNETWORK_MTU ( SIZE_MAX >> 1 )
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigTCP_MSS
|
||||
#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
|
||||
* have a fixed maximum size.
|
||||
* 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 */
|
||||
#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 */
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigMAXIMUM_DISCOVER_TX_PERIOD
|
||||
#ifdef _WINDOWS_
|
||||
#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD ( pdMS_TO_TICKS( 999U ) )
|
||||
#else
|
||||
#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD ( pdMS_TO_TICKS( 30000U ) )
|
||||
#endif /* _WINDOWS_ */
|
||||
#endif /* ipconfigMAXIMUM_DISCOVER_TX_PERIOD */
|
||||
|
||||
#if ( ipconfigUSE_DNS == 0 )
|
||||
/* The DNS module will not be included. */
|
||||
#if ( ( ipconfigUSE_LLMNR != 0 ) || ( ipconfigUSE_NBNS != 0 ) )
|
||||
/* LLMNR and NBNS depend on DNS because those protocols share a lot of code. */
|
||||
#error When either LLMNR or NBNS is used, ipconfigUSE_DNS must be defined
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigUSE_DNS
|
||||
#define ipconfigUSE_DNS 1
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigDNS_REQUEST_ATTEMPTS
|
||||
#define ipconfigDNS_REQUEST_ATTEMPTS 5
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigUSE_DNS_CACHE
|
||||
#define ipconfigUSE_DNS_CACHE 0
|
||||
#endif
|
||||
|
||||
#if ( ipconfigUSE_DNS_CACHE != 0 )
|
||||
#ifndef ipconfigDNS_CACHE_NAME_LENGTH
|
||||
|
||||
/* Per https://tools.ietf.org/html/rfc1035, 253 is the maximum string length
|
||||
* of a DNS name. The following default accounts for a null terminator. */
|
||||
#define ipconfigDNS_CACHE_NAME_LENGTH 254U
|
||||
#endif
|
||||
|
||||
#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
|
||||
|
||||
#ifndef ipconfigUSE_LLMNR
|
||||
/* Include support for LLMNR: Link-local Multicast Name Resolution (non-Microsoft) */
|
||||
#define ipconfigUSE_LLMNR ( 0 )
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigREPLY_TO_INCOMING_PINGS
|
||||
#define ipconfigREPLY_TO_INCOMING_PINGS 1
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigSUPPORT_OUTGOING_PINGS
|
||||
#define ipconfigSUPPORT_OUTGOING_PINGS 1
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES
|
||||
#define ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES 1
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES
|
||||
#define ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES 1
|
||||
#endif
|
||||
|
||||
#ifndef configINCLUDE_TRACE_RELATED_CLI_COMMANDS
|
||||
#define ipconfigINCLUDE_EXAMPLE_FREERTOS_PLUS_TRACE_CALLS 0
|
||||
#else
|
||||
#define ipconfigINCLUDE_EXAMPLE_FREERTOS_PLUS_TRACE_CALLS configINCLUDE_TRACE_RELATED_CLI_COMMANDS
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM
|
||||
#define ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM ( 0 )
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigETHERNET_DRIVER_FILTERS_PACKETS
|
||||
#define ipconfigETHERNET_DRIVER_FILTERS_PACKETS ( 0 )
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigWATCHDOG_TIMER
|
||||
|
||||
/* This macro will be called in every loop the IP-task makes. It may be
|
||||
* replaced by user-code that triggers a watchdog */
|
||||
#define ipconfigWATCHDOG_TIMER()
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigUSE_CALLBACKS
|
||||
#define ipconfigUSE_CALLBACKS ( 0 )
|
||||
#endif
|
||||
|
||||
#if ( ipconfigUSE_CALLBACKS != 0 )
|
||||
#ifndef ipconfigIS_VALID_PROG_ADDRESS
|
||||
|
||||
/* Replace this macro with a test returning non-zero if the memory pointer to by x
|
||||
* is valid memory which can contain executable code
|
||||
* In fact this is an extra safety measure: if a handler points to invalid memory,
|
||||
* it will not be called
|
||||
*/
|
||||
#define ipconfigIS_VALID_PROG_ADDRESS( x ) ( ( x ) != NULL )
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigHAS_INLINE_FUNCTIONS
|
||||
#define ipconfigHAS_INLINE_FUNCTIONS ( 1 )
|
||||
#endif
|
||||
|
||||
#ifndef portINLINE
|
||||
#define portINLINE inline
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigZERO_COPY_TX_DRIVER
|
||||
|
||||
/* When non-zero, the buffers passed to the SEND routine may be passed
|
||||
* to DMA. As soon as sending is ready, the buffers must be released by
|
||||
* calling vReleaseNetworkBufferAndDescriptor(), */
|
||||
#define ipconfigZERO_COPY_TX_DRIVER ( 0 )
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigZERO_COPY_RX_DRIVER
|
||||
|
||||
/* This define doesn't mean much to the driver, except that it makes
|
||||
* sure that pxPacketBuffer_to_NetworkBuffer() will be included. */
|
||||
#define ipconfigZERO_COPY_RX_DRIVER ( 0 )
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM
|
||||
#define ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM 0
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM
|
||||
#define ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM 0
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigDHCP_REGISTER_HOSTNAME
|
||||
#define ipconfigDHCP_REGISTER_HOSTNAME 0
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigSOCKET_HAS_USER_SEMAPHORE
|
||||
#define ipconfigSOCKET_HAS_USER_SEMAPHORE 0
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigSOCKET_HAS_USER_WAKE_CALLBACK
|
||||
#define ipconfigSOCKET_HAS_USER_WAKE_CALLBACK 0
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigSUPPORT_SELECT_FUNCTION
|
||||
#define ipconfigSUPPORT_SELECT_FUNCTION 0
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigTCP_KEEP_ALIVE
|
||||
#define ipconfigTCP_KEEP_ALIVE 0
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigDNS_USE_CALLBACKS
|
||||
#define ipconfigDNS_USE_CALLBACKS 0
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigSUPPORT_SIGNALS
|
||||
#define ipconfigSUPPORT_SIGNALS 0
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigUSE_NBNS
|
||||
#define ipconfigUSE_NBNS 0
|
||||
#endif
|
||||
|
||||
/* As an attack surface reduction for ports that listen for inbound
|
||||
* connections, hang protection can help reduce the impact of SYN floods. */
|
||||
#ifndef ipconfigTCP_HANG_PROTECTION
|
||||
#define ipconfigTCP_HANG_PROTECTION 1
|
||||
#endif
|
||||
|
||||
/* Non-activity timeout is expressed in seconds. */
|
||||
#ifndef ipconfigTCP_HANG_PROTECTION_TIME
|
||||
#define ipconfigTCP_HANG_PROTECTION_TIME 30U
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigTCP_IP_SANITY
|
||||
#define ipconfigTCP_IP_SANITY 0
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigARP_STORES_REMOTE_ADDRESSES
|
||||
#define ipconfigARP_STORES_REMOTE_ADDRESSES 0
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigBUFFER_PADDING
|
||||
|
||||
/* 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 0U
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigPACKET_FILLER_SIZE
|
||||
#define ipconfigPACKET_FILLER_SIZE 2U
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigSELECT_USES_NOTIFY
|
||||
#define ipconfigSELECT_USES_NOTIFY 0
|
||||
#endif
|
||||
|
||||
#endif /* FREERTOS_DEFAULT_IP_CONFIG_H */
|
@ -0,0 +1,147 @@
|
||||
/*
|
||||
* FreeRTOS+TCP V2.3.2 LTS Patch 1
|
||||
* Copyright (C) 2020 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. */
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Structure for one row in the ARP cache table.
|
||||
*/
|
||||
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;
|
||||
|
||||
/*
|
||||
* 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 gratuitous 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 );
|
||||
|
||||
/* 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
|
||||
|
||||
|
||||
#endif /* FREERTOS_ARP_H */
|
@ -0,0 +1,122 @@
|
||||
/*
|
||||
* FreeRTOS+TCP V2.3.2 LTS Patch 1
|
||||
* Copyright (C) 2020 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"
|
||||
|
||||
#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. */
|
||||
eDHCPPhaseFinished
|
||||
} 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;
|
||||
#endif /* #if( ipconfigUSE_DHCP_HOOK != 0 ) */
|
||||
|
||||
/* DHCP state machine states. */
|
||||
typedef enum
|
||||
{
|
||||
eInitialWait = 0, /**< Initial state: open a socket and wait a short time. */
|
||||
eWaitingSendFirstDiscover, /**< 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. */
|
||||
eSendDHCPRequest, /**< Sendto failed earlier, resend the request to lease the IP-address offered. */
|
||||
#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; /**< The ID of the DHCP transaction */
|
||||
uint32_t ulOfferedIPAddress; /**< The IP address offered by the DHCP server */
|
||||
uint32_t ulDHCPServerAddress; /**< The IP address of the DHCP server */
|
||||
uint32_t ulLeaseTime; /**< The time for which the current IP address is leased */
|
||||
TickType_t xDHCPTxTime; /**< The time at which a DHCP request was sent. */
|
||||
TickType_t xDHCPTxPeriod; /**< The maximum time that the client will wait for a reply. */
|
||||
BaseType_t xUseBroadcast; /**< Try both without and with the broadcast flag */
|
||||
eDHCPState_t eDHCPState; /**< Maintains the DHCP state machine state. */
|
||||
};
|
||||
|
||||
typedef struct xDHCP_DATA DHCPData_t;
|
||||
|
||||
/* Returns the current state of a DHCP process. */
|
||||
eDHCPState_t eGetDHCPState( void );
|
||||
|
||||
/*
|
||||
* Send a message to the IP-task, which will call vDHCPProcess().
|
||||
*
|
||||
*/
|
||||
BaseType_t xSendDHCPEvent( void );
|
||||
|
||||
/*
|
||||
* NOT A PUBLIC API FUNCTION.
|
||||
* It will be called when the DHCP timer expires, or when
|
||||
* data has been received on the DHCP socket.
|
||||
*/
|
||||
void vDHCPProcess( BaseType_t xReset,
|
||||
eDHCPState_t eExpectedState );
|
||||
|
||||
/* Internal call: returns true if socket is the current DHCP socket */
|
||||
BaseType_t xIsDHCPSocket( Socket_t xSocket );
|
||||
|
||||
#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" */
|
||||
#endif
|
||||
|
||||
#endif /* FREERTOS_DHCP_H */
|
@ -0,0 +1,38 @@
|
||||
|
||||
#ifndef _DHCPSERVER_H
|
||||
#define _DHCPSERVER_H
|
||||
|
||||
#ifndef DHCPSERVER_LEASE_TIME
|
||||
#define DHCPSERVER_LEASE_TIME (864000)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Start DHCP server.
|
||||
|
||||
Static IP of server should already be set and network interface enabled.
|
||||
|
||||
first_client_addr is the IP address of the first lease to be handed
|
||||
to a client. Subsequent lease addresses are calculated by
|
||||
incrementing the final octet of the IPv4 address, up to max_leases.
|
||||
*/
|
||||
void dhcpserver_start(const uint8_t ucIPAddress[4], uint32_t first_client_addr, uint8_t max_leases);
|
||||
|
||||
|
||||
/* Stop DHCP server.
|
||||
*/
|
||||
void dhcpserver_stop(void);
|
||||
|
||||
/* Set a router address to send as an option. */
|
||||
void dhcpserver_set_router(uint32_t router);
|
||||
|
||||
/* Set a DNS address to send as an option. */
|
||||
void dhcpserver_set_dns(uint32_t dns);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -0,0 +1,151 @@
|
||||
/*
|
||||
* FreeRTOS+TCP V2.3.2 LTS Patch 1
|
||||
* Copyright (C) 2020 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_DNS_H
|
||||
#define FREERTOS_DNS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Application level configuration options. */
|
||||
#include "FreeRTOSIPConfig.h"
|
||||
#include "IPTraceMacroDefaults.h"
|
||||
|
||||
|
||||
/* The Link-local Multicast Name Resolution (LLMNR)
|
||||
* is included.
|
||||
* Note that a special MAC address is required in addition to the NIC's actual
|
||||
* MAC address: 01:00:5E:00:00:FC
|
||||
*
|
||||
* The target IP address will be 224.0.0.252
|
||||
*/
|
||||
#if ( ipconfigBYTE_ORDER == pdFREERTOS_BIG_ENDIAN )
|
||||
#define ipLLMNR_IP_ADDR 0xE00000FCUL
|
||||
#else
|
||||
#define ipLLMNR_IP_ADDR 0xFC0000E0UL
|
||||
#endif /* ipconfigBYTE_ORDER == pdFREERTOS_BIG_ENDIAN */
|
||||
|
||||
#define ipLLMNR_PORT 5355 /* Standard LLMNR port. */
|
||||
#define ipDNS_PORT 53 /* Standard DNS port. */
|
||||
#define ipDHCP_CLIENT 67
|
||||
#define ipDHCP_SERVER 68
|
||||
#define ipNBNS_PORT 137 /* NetBIOS Name Service. */
|
||||
#define ipNBDGM_PORT 138 /* Datagram Service, not included. */
|
||||
|
||||
#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( 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 */
|
||||
|
||||
#if ( ipconfigUSE_NBNS != 0 )
|
||||
|
||||
/*
|
||||
* Inspect a NetBIOS Names-Service message. If the name matches with ours
|
||||
* (xApplicationDNSQueryHook returns true) an answer will be sent back.
|
||||
* Note that LLMNR is a better protocol for name services on a LAN as it is
|
||||
* less polluted
|
||||
*/
|
||||
uint32_t ulNBNSHandlePacket( NetworkBufferDescriptor_t * pxNetworkBuffer );
|
||||
|
||||
#endif /* ipconfigUSE_NBNS */
|
||||
|
||||
#if ( ipconfigUSE_DNS_CACHE != 0 )
|
||||
|
||||
/* 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( void );
|
||||
|
||||
#endif /* ipconfigUSE_DNS_CACHE != 0 */
|
||||
|
||||
#if ( ipconfigDNS_USE_CALLBACKS != 0 )
|
||||
|
||||
/*
|
||||
* Users may define this type of function as a callback.
|
||||
* It will be called when a DNS reply is received or when a timeout has been reached.
|
||||
*/
|
||||
typedef void (* FOnDNSEvent ) ( const char * /* pcName */,
|
||||
void * /* pvSearchID */,
|
||||
uint32_t /* ulIPAddress */ );
|
||||
|
||||
/*
|
||||
* Asynchronous version of gethostbyname()
|
||||
* xTimeout is in units of ms.
|
||||
*/
|
||||
uint32_t FreeRTOS_gethostbyname_a( const char * pcHostName,
|
||||
FOnDNSEvent pCallback,
|
||||
void * pvSearchID,
|
||||
TickType_t uxTimeout );
|
||||
void FreeRTOS_gethostbyname_cancel( void * pvSearchID );
|
||||
|
||||
#endif /* if ( ipconfigDNS_USE_CALLBACKS != 0 ) */
|
||||
|
||||
/*
|
||||
* 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" */
|
||||
#endif
|
||||
|
||||
#endif /* FREERTOS_DNS_H */
|
@ -0,0 +1,434 @@
|
||||
/*
|
||||
* FreeRTOS+TCP V2.3.2 LTS Patch 1
|
||||
* Copyright (C) 2020 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_IP_H
|
||||
#define FREERTOS_IP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
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.
|
||||
* These defines come before including 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.
|
||||
*/
|
||||
/* This function is defined generally by the application. */
|
||||
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 ( 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 )
|
||||
|
||||
|
||||
/* 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.
|
||||
*
|
||||
* In order to get a 32-bit alignment of network packets, an offset of 2 bytes
|
||||
* would be desirable, as defined by ipconfigPACKET_FILLER_SIZE. So the malloc'd
|
||||
* buffer will have the following contents:
|
||||
* uint32_t pointer; // word-aligned
|
||||
* uchar_8 filler[6];
|
||||
* << ETH-header >> // half-word-aligned
|
||||
* uchar_8 dest[6]; // start of pucEthernetBuffer
|
||||
* uchar_8 dest[6];
|
||||
* uchar16_t type;
|
||||
* << IP-header >> // word-aligned
|
||||
* uint8_t ucVersionHeaderLength;
|
||||
* etc
|
||||
*/
|
||||
|
||||
#if ( ipconfigBUFFER_PADDING != 0 )
|
||||
#define ipBUFFER_PADDING ipconfigBUFFER_PADDING
|
||||
#else
|
||||
#define ipBUFFER_PADDING ( 8U + ipconfigPACKET_FILLER_SIZE )
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The structure used to store buffers and pass them around the network stack.
|
||||
* Buffers can be in use by the stack, in use by the network interface hardware
|
||||
* driver, or free (not in use).
|
||||
*/
|
||||
typedef struct xNETWORK_BUFFER
|
||||
{
|
||||
ListItem_t xBufferListItem; /**< Used to reference the buffer form the free buffer list or a socket. */
|
||||
uint32_t ulIPAddress; /**< Source or destination IP address, depending on usage scenario. */
|
||||
uint8_t * pucEthernetBuffer; /**< Pointer to the start of the Ethernet frame. */
|
||||
size_t xDataLength; /**< Starts by holding the total Ethernet frame length, then the UDP/TCP payload length. */
|
||||
uint16_t usPort; /**< Source or destination port, depending on usage scenario. */
|
||||
uint16_t usBoundPort; /**< The port to which a transmitting socket is bound. */
|
||||
#if ( ipconfigUSE_LINKED_RX_MESSAGES != 0 )
|
||||
struct xNETWORK_BUFFER * pxNextBuffer; /**< Possible optimisation for expert users - requires network driver support. */
|
||||
#endif
|
||||
} NetworkBufferDescriptor_t;
|
||||
|
||||
#include "pack_struct_start.h"
|
||||
|
||||
/**
|
||||
* MAC address structure.
|
||||
*/
|
||||
struct xMAC_ADDRESS
|
||||
{
|
||||
uint8_t ucBytes[ ipMAC_ADDRESS_LENGTH_BYTES ]; /**< Byte array of the MAC address */
|
||||
};
|
||||
#include "pack_struct_end.h"
|
||||
|
||||
typedef struct xMAC_ADDRESS MACAddress_t;
|
||||
|
||||
typedef enum eNETWORK_EVENTS
|
||||
{
|
||||
eNetworkUp, /* The network is configured. */
|
||||
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. */
|
||||
eInvalidChecksum, /**< A reply was received for an outgoing ping but the checksum of the reply was incorrect. */
|
||||
eInvalidData /**< A reply was received to an outgoing ping but the payload of the reply was not correct. */
|
||||
} ePingReplyStatus_t;
|
||||
|
||||
/**
|
||||
* The software timer struct for various IP functions
|
||||
*/
|
||||
typedef struct xIP_TIMER
|
||||
{
|
||||
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; /**< The timeout value. */
|
||||
TickType_t ulRemainingTime; /**< The amount of time remaining. */
|
||||
TickType_t ulReloadTime; /**< The value of reload time. */
|
||||
} IPTimer_t;
|
||||
|
||||
|
||||
/* Endian related definitions. */
|
||||
#if ( ipconfigBYTE_ORDER == pdFREERTOS_LITTLE_ENDIAN )
|
||||
|
||||
/* FreeRTOS_htons / FreeRTOS_htonl: some platforms might have built-in versions
|
||||
* using a single instruction so allow these versions to be overridden. */
|
||||
#ifndef FreeRTOS_htons
|
||||
#define FreeRTOS_htons( usIn ) ( ( uint16_t ) ( ( ( usIn ) << 8U ) | ( ( usIn ) >> 8U ) ) )
|
||||
#endif
|
||||
|
||||
#ifndef FreeRTOS_htonl
|
||||
#define FreeRTOS_htonl( ulIn ) \
|
||||
( \
|
||||
( uint32_t ) \
|
||||
( \
|
||||
( ( ( ( uint32_t ) ( ulIn ) ) ) << 24 ) | \
|
||||
( ( ( ( uint32_t ) ( ulIn ) ) & 0x0000ff00UL ) << 8 ) | \
|
||||
( ( ( ( uint32_t ) ( ulIn ) ) & 0x00ff0000UL ) >> 8 ) | \
|
||||
( ( ( ( uint32_t ) ( ulIn ) ) ) >> 24 ) \
|
||||
) \
|
||||
)
|
||||
#endif /* ifndef FreeRTOS_htonl */
|
||||
|
||||
#else /* ipconfigBYTE_ORDER */
|
||||
|
||||
#define FreeRTOS_htons( x ) ( ( uint16_t ) ( x ) )
|
||||
#define FreeRTOS_htonl( x ) ( ( uint32_t ) ( x ) )
|
||||
|
||||
#endif /* ipconfigBYTE_ORDER == pdFREERTOS_LITTLE_ENDIAN */
|
||||
|
||||
#define FreeRTOS_ntohs( x ) FreeRTOS_htons( x )
|
||||
#define FreeRTOS_ntohl( x ) FreeRTOS_htonl( x )
|
||||
|
||||
#if ( ipconfigHAS_INLINE_FUNCTIONS == 1 )
|
||||
|
||||
static portINLINE int32_t FreeRTOS_max_int32( int32_t a,
|
||||
int32_t b );
|
||||
static portINLINE uint32_t FreeRTOS_max_uint32( uint32_t a,
|
||||
uint32_t b );
|
||||
static portINLINE int32_t FreeRTOS_min_int32( int32_t a,
|
||||
int32_t b );
|
||||
static portINLINE uint32_t FreeRTOS_min_uint32( uint32_t a,
|
||||
uint32_t b );
|
||||
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 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_min_BaseType( BaseType_t a,
|
||||
BaseType_t b )
|
||||
{
|
||||
return ( a <= b ) ? a : b;
|
||||
}
|
||||
|
||||
#else /* if ( ipconfigHAS_INLINE_FUNCTIONS == 1 ) */
|
||||
|
||||
#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 ) )
|
||||
|
||||
/* 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_min_BaseType( a, b ) ( ( ( BaseType_t ) ( a ) ) <= ( ( BaseType_t ) ( b ) ) ? ( ( BaseType_t ) ( a ) ) : ( ( BaseType_t ) ( b ) ) )
|
||||
|
||||
#endif /* ipconfigHAS_INLINE_FUNCTIONS */
|
||||
|
||||
#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 ( 1U )
|
||||
#define pdFALSE_UNSIGNED ( 0U )
|
||||
#define ipTRUE_BOOL ( 1 == 1 )
|
||||
#define ipFALSE_BOOL ( 1 == 2 )
|
||||
#endif
|
||||
|
||||
/*
|
||||
* FULL, UP-TO-DATE AND MAINTAINED REFERENCE DOCUMENTATION FOR ALL THESE
|
||||
* FUNCTIONS IS AVAILABLE ON THE FOLLOWING URL:
|
||||
* http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/FreeRTOS_TCP_API_Functions.html
|
||||
*/
|
||||
BaseType_t FreeRTOS_IPInit( const uint8_t ucIPAddress[ ipIP_ADDRESS_LENGTH_BYTES ],
|
||||
const uint8_t ucNetMask[ ipIP_ADDRESS_LENGTH_BYTES ],
|
||||
const uint8_t ucGatewayAddress[ 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 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 ] );
|
||||
#if ( ipconfigUSE_NETWORK_EVENT_HOOK == 1 )
|
||||
/* 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 );
|
||||
void FreeRTOS_SetGatewayAddress( uint32_t ulGatewayAddress );
|
||||
uint32_t FreeRTOS_GetGatewayAddress( void );
|
||||
uint32_t FreeRTOS_GetDNSServerAddress( void );
|
||||
uint32_t FreeRTOS_GetNetmask( void );
|
||||
void FreeRTOS_OutputARPRequest( uint32_t ulIPAddress );
|
||||
BaseType_t FreeRTOS_IsNetworkUp( void );
|
||||
|
||||
#if ( ipconfigCHECK_IP_QUEUE_SPACE != 0 )
|
||||
UBaseType_t uxGetMinimumIPQueueSpace( void );
|
||||
#endif
|
||||
|
||||
#if ( ipconfigHAS_PRINTF != 0 )
|
||||
extern void vPrintResourceStats( void );
|
||||
#else
|
||||
#define vPrintResourceStats() do {} while( ipFALSE_BOOL )
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Defined in FreeRTOS_Sockets.c
|
||||
* //_RB_ Don't think this comment is correct. If this is for internal use only it should appear after all the public API functions and not start with FreeRTOS_.
|
||||
* Socket has had activity, reset the timer so it will not be closed
|
||||
* because of inactivity
|
||||
*/
|
||||
#if ( ( ipconfigHAS_DEBUG_PRINTF != 0 ) || ( ipconfigHAS_PRINTF != 0 ) )
|
||||
const char * FreeRTOS_GetTCPStateName( UBaseType_t ulState );
|
||||
#endif
|
||||
|
||||
/* _HT_ Temporary: show all valid ARP entries
|
||||
*/
|
||||
#if ( ipconfigHAS_PRINTF != 0 ) || ( ipconfigHAS_DEBUG_PRINTF != 0 )
|
||||
void FreeRTOS_PrintARPCache( void );
|
||||
#endif
|
||||
|
||||
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. */
|
||||
/* Typically this function is defined in a user module. */
|
||||
const char * pcApplicationHostnameHook( void );
|
||||
|
||||
#endif /* ipconfigDHCP_REGISTER_HOSTNAME */
|
||||
|
||||
|
||||
/* This xApplicationGetRandomNumber() will set *pulNumber to a random number,
|
||||
* and return pdTRUE. When the random number generator is broken, it shall return
|
||||
* pdFALSE.
|
||||
* 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. */
|
||||
|
||||
/* "xApplicationGetRandomNumber" is declared but never defined, because it may
|
||||
* be defined in a user module. */
|
||||
extern BaseType_t xApplicationGetRandomNumber( uint32_t * pulNumber );
|
||||
|
||||
/* For backward compatibility define old structure names to the newer equivalent
|
||||
* structure name. */
|
||||
#ifndef ipconfigENABLE_BACKWARD_COMPATIBILITY
|
||||
#define ipconfigENABLE_BACKWARD_COMPATIBILITY 1
|
||||
#endif
|
||||
|
||||
#if ( ipconfigENABLE_BACKWARD_COMPATIBILITY == 1 )
|
||||
#define xIPStackEvent_t IPStackEvent_t
|
||||
#define xNetworkBufferDescriptor_t NetworkBufferDescriptor_t
|
||||
#define xMACAddress_t MACAddress_t
|
||||
#define xWinProperties_t WinProperties_t
|
||||
#define xSocket_t Socket_t
|
||||
#define xSocketSet_t SocketSet_t
|
||||
#define ipSIZE_OF_IP_HEADER ipSIZE_OF_IPv4_HEADER
|
||||
|
||||
/* Since August 2016, the public types and fields below have changed name:
|
||||
* abbreviations TCP/UDP are now written in capitals, and type names now end with "_t". */
|
||||
#define FOnConnected FOnConnected_t
|
||||
#define FOnTcpReceive FOnTCPReceive_t
|
||||
#define FOnTcpSent FOnTCPSent_t
|
||||
#define FOnUdpReceive FOnUDPReceive_t
|
||||
#define FOnUdpSent FOnUDPSent_t
|
||||
|
||||
#define pOnTcpConnected pxOnTCPConnected
|
||||
#define pOnTcpReceive pxOnTCPReceive
|
||||
#define pOnTcpSent pxOnTCPSent
|
||||
#define pOnUdpReceive pxOnUDPReceive
|
||||
#define pOnUdpSent pxOnUDPSent
|
||||
|
||||
#define FOnUdpSent FOnUDPSent_t
|
||||
#define FOnTcpSent FOnTCPSent_t
|
||||
#endif /* ipconfigENABLE_BACKWARD_COMPATIBILITY */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
void setDhcpClientState(BaseType_t on);
|
||||
int getDhcpClientState();
|
||||
void dump_net_pack(NetworkBufferDescriptor_t * pxNetworkBuffer, int port, int is_send);
|
||||
#endif /* FREERTOS_IP_H */
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,520 @@
|
||||
/*
|
||||
* FreeRTOS+TCP V2.3.2 LTS Patch 1
|
||||
* Copyright (C) 2020 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_SOCKETS_H
|
||||
#define FREERTOS_SOCKETS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Standard includes. */
|
||||
#include <string.h>
|
||||
|
||||
/* Application level configuration options. */
|
||||
#include "FreeRTOSIPConfig.h"
|
||||
|
||||
#ifndef FREERTOS_IP_CONFIG_H
|
||||
#error FreeRTOSIPConfig.h has not been included yet
|
||||
#endif
|
||||
|
||||
/* Event bit definitions are required by the select functions. */
|
||||
#include "event_groups.h"
|
||||
|
||||
#ifndef INC_FREERTOS_H
|
||||
#error FreeRTOS.h must be included before FreeRTOS_Sockets.h.
|
||||
#endif
|
||||
|
||||
#ifndef INC_TASK_H
|
||||
#ifndef TASK_H /* For compatibility with older FreeRTOS versions. */
|
||||
#error The FreeRTOS header file task.h must be included before FreeRTOS_Sockets.h.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Assigned to an Socket_t variable when the socket is not valid, probably
|
||||
* because it could not be created. */
|
||||
#define FREERTOS_INVALID_SOCKET ( ( Socket_t ) ~0U )
|
||||
|
||||
/* API function error values. As errno is supported, the FreeRTOS sockets
|
||||
* functions return error codes rather than just a pass or fail indication. */
|
||||
|
||||
/* HT: Extended the number of error codes, gave them positive values and if possible
|
||||
* the corresponding found in errno.h
|
||||
* In case of an error, API's will still return negative numbers, e.g.
|
||||
* return -pdFREERTOS_ERRNO_EWOULDBLOCK;
|
||||
* in case an operation would block */
|
||||
|
||||
/* The following defines are obsolete, please use -pdFREERTOS_ERRNO_Exxx */
|
||||
|
||||
#define FREERTOS_SOCKET_ERROR ( -1 )
|
||||
#define FREERTOS_EWOULDBLOCK ( -pdFREERTOS_ERRNO_EWOULDBLOCK )
|
||||
#define FREERTOS_EINVAL ( -pdFREERTOS_ERRNO_EINVAL )
|
||||
#define FREERTOS_EADDRNOTAVAIL ( -pdFREERTOS_ERRNO_EADDRNOTAVAIL )
|
||||
#define FREERTOS_EADDRINUSE ( -pdFREERTOS_ERRNO_EADDRINUSE )
|
||||
#define FREERTOS_ENOBUFS ( -pdFREERTOS_ERRNO_ENOBUFS )
|
||||
#define FREERTOS_ENOPROTOOPT ( -pdFREERTOS_ERRNO_ENOPROTOOPT )
|
||||
#define FREERTOS_ECLOSED ( -pdFREERTOS_ERRNO_ENOTCONN )
|
||||
|
||||
/* Values for the parameters to FreeRTOS_socket(), inline with the Berkeley
|
||||
* standard. See the documentation of FreeRTOS_socket() for more information. */
|
||||
#define FREERTOS_AF_INET ( 2 )
|
||||
#define FREERTOS_AF_INET6 ( 10 )
|
||||
#define FREERTOS_SOCK_DGRAM ( 2 )
|
||||
#define FREERTOS_IPPROTO_UDP ( 17 )
|
||||
|
||||
#define FREERTOS_SOCK_STREAM ( 1 )
|
||||
#define FREERTOS_IPPROTO_TCP ( 6 )
|
||||
|
||||
/* IP packet of type "Any local network"
|
||||
* can be used in stead of TCP for testing with sockets in raw mode
|
||||
*/
|
||||
#define FREERTOS_IPPROTO_USR_LAN ( 63 )
|
||||
|
||||
/* A bit value that can be passed into the FreeRTOS_sendto() function as part of
|
||||
* the flags parameter. Setting the FREERTOS_ZERO_COPY in the flags parameter
|
||||
* indicates that the zero copy interface is being used. See the documentation for
|
||||
* FreeRTOS_sockets() for more information. */
|
||||
#define FREERTOS_ZERO_COPY ( 1 )
|
||||
|
||||
/* Values that can be passed in the option name parameter of calls to
|
||||
* FreeRTOS_setsockopt(). */
|
||||
#define FREERTOS_SO_RCVTIMEO ( 0 ) /* Used to set the receive time out. */
|
||||
#define FREERTOS_SO_SNDTIMEO ( 1 ) /* Used to set the send time out. */
|
||||
#define FREERTOS_SO_UDPCKSUM_OUT ( 2 ) /* Used to turn the use of the UDP checksum by a socket on or off. This also doubles as part of an 8-bit bitwise socket option. */
|
||||
#if ( ipconfigSOCKET_HAS_USER_SEMAPHORE == 1 )
|
||||
#define FREERTOS_SO_SET_SEMAPHORE ( 3 ) /* Used to set a user's semaphore */
|
||||
#endif
|
||||
#define FREERTOS_SO_SNDBUF ( 4 ) /* Set the size of the send buffer (TCP only) */
|
||||
#define FREERTOS_SO_RCVBUF ( 5 ) /* Set the size of the receive buffer (TCP only) */
|
||||
|
||||
#if ipconfigUSE_CALLBACKS == 1
|
||||
#define FREERTOS_SO_TCP_CONN_HANDLER ( 6 ) /* Install a callback for (dis) connection events. Supply pointer to 'F_TCP_UDP_Handler_t' (see below) */
|
||||
#define FREERTOS_SO_TCP_RECV_HANDLER ( 7 ) /* Install a callback for receiving TCP data. Supply pointer to 'F_TCP_UDP_Handler_t' (see below) */
|
||||
#define FREERTOS_SO_TCP_SENT_HANDLER ( 8 ) /* Install a callback for sending TCP data. Supply pointer to 'F_TCP_UDP_Handler_t' (see below) */
|
||||
#define FREERTOS_SO_UDP_RECV_HANDLER ( 9 ) /* Install a callback for receiving UDP data. Supply pointer to 'F_TCP_UDP_Handler_t' (see below) */
|
||||
#define FREERTOS_SO_UDP_SENT_HANDLER ( 10 ) /* Install a callback for sending UDP data. Supply pointer to 'F_TCP_UDP_Handler_t' (see below) */
|
||||
#endif /* ipconfigUSE_CALLBACKS */
|
||||
|
||||
#define FREERTOS_SO_REUSE_LISTEN_SOCKET ( 11 ) /* When a listening socket gets connected, do not create a new one but re-use it */
|
||||
#define FREERTOS_SO_CLOSE_AFTER_SEND ( 12 ) /* As soon as the last byte has been transmitted, finalise the connection */
|
||||
#define FREERTOS_SO_WIN_PROPERTIES ( 13 ) /* Set all buffer and window properties in one call, parameter is pointer to WinProperties_t */
|
||||
#define FREERTOS_SO_SET_FULL_SIZE ( 14 ) /* Refuse to send packets smaller than MSS */
|
||||
|
||||
#define FREERTOS_SO_STOP_RX ( 15 ) /* Temporarily hold up reception, used by streaming client */
|
||||
|
||||
#if ( ipconfigUDP_MAX_RX_PACKETS > 0 )
|
||||
#define FREERTOS_SO_UDP_MAX_RX_PACKETS ( 16 ) /* This option helps to limit the maximum number of packets a UDP socket will buffer */
|
||||
#endif
|
||||
|
||||
#if ( ipconfigSOCKET_HAS_USER_WAKE_CALLBACK == 1 )
|
||||
#define FREERTOS_SO_WAKEUP_CALLBACK ( 17 )
|
||||
#endif
|
||||
|
||||
#define FREERTOS_SO_SET_LOW_HIGH_WATER ( 18 )
|
||||
|
||||
#define FREERTOS_NOT_LAST_IN_FRAGMENTED_PACKET ( 0x80 ) /* For internal use only, but also part of an 8-bit bitwise value. */
|
||||
#define FREERTOS_FRAGMENTED_PACKET ( 0x40 ) /* For internal use only, but also part of an 8-bit bitwise value. */
|
||||
|
||||
/* Values for flag for FreeRTOS_shutdown(). */
|
||||
#define FREERTOS_SHUT_RD ( 0 ) /* Not really at this moment, just for compatibility of the interface */
|
||||
#define FREERTOS_SHUT_WR ( 1 )
|
||||
#define FREERTOS_SHUT_RDWR ( 2 )
|
||||
|
||||
/* Values for flag for FreeRTOS_recv(). */
|
||||
#define FREERTOS_MSG_OOB ( 2 ) /* process out-of-band data */
|
||||
#define FREERTOS_MSG_PEEK ( 4 ) /* peek at incoming message */
|
||||
#define FREERTOS_MSG_DONTROUTE ( 8 ) /* send without using routing tables */
|
||||
#define FREERTOS_MSG_DONTWAIT ( 16 ) /* Can be used with recvfrom(), sendto(), recv(), and send(). */
|
||||
|
||||
|
||||
/**
|
||||
* Structure to hold the properties of Tx/Rx buffers and windows.
|
||||
*/
|
||||
typedef struct xWIN_PROPS
|
||||
{
|
||||
/* Properties of the Tx buffer and Tx window */
|
||||
int32_t lTxBufSize; /**< Unit: bytes */
|
||||
int32_t lTxWinSize; /**< Unit: MSS */
|
||||
|
||||
/* Properties of the Rx buffer and Rx window */
|
||||
int32_t lRxBufSize; /**< Unit: bytes */
|
||||
int32_t lRxWinSize; /**< Unit: MSS */
|
||||
} WinProperties_t;
|
||||
|
||||
/**
|
||||
* Structure to pass for the 'FREERTOS_SO_SET_LOW_HIGH_WATER' option
|
||||
*/
|
||||
typedef struct xLOW_HIGH_WATER
|
||||
{
|
||||
size_t uxLittleSpace; /**< Send a STOP when buffer space drops below X bytes */
|
||||
size_t uxEnoughSpace; /**< Send a GO when buffer space grows above X bytes */
|
||||
} LowHighWater_t;
|
||||
|
||||
/* For compatibility with the expected Berkeley sockets naming. */
|
||||
#define socklen_t uint32_t
|
||||
|
||||
/**
|
||||
* For this limited implementation, only two members are required in the
|
||||
* Berkeley style sockaddr structure.
|
||||
*/
|
||||
struct freertos_sockaddr
|
||||
{
|
||||
/* _HT_ On 32- and 64-bit architectures, the addition of the two uint8_t
|
||||
* fields doesn't make the structure bigger, due to alignment.
|
||||
* The fields are inserted as a preparation for IPv6. */
|
||||
|
||||
/* sin_len and sin_family not used in the IPv4-only release. */
|
||||
uint8_t sin_len; /**< length of this structure. */
|
||||
uint8_t sin_family; /**< FREERTOS_AF_INET. */
|
||||
uint16_t sin_port; /**< The port */
|
||||
uint32_t sin_addr; /**< The IP address */
|
||||
};
|
||||
|
||||
|
||||
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 ) \
|
||||
( ( ( ( uint32_t ) ( ucOctet3 ) ) << 24UL ) | \
|
||||
( ( ( uint32_t ) ( ucOctet2 ) ) << 16UL ) | \
|
||||
( ( ( uint32_t ) ( ucOctet1 ) ) << 8UL ) | \
|
||||
( ( uint32_t ) ( ucOctet0 ) ) )
|
||||
|
||||
#else /* ipconfigBYTE_ORDER */
|
||||
|
||||
#define FreeRTOS_inet_addr_quick( ucOctet0, ucOctet1, ucOctet2, ucOctet3 ) \
|
||||
( ( ( ( uint32_t ) ( ucOctet0 ) ) << 24UL ) | \
|
||||
( ( ( uint32_t ) ( ucOctet1 ) ) << 16UL ) | \
|
||||
( ( ( uint32_t ) ( ucOctet2 ) ) << 8UL ) | \
|
||||
( ( uint32_t ) ( ucOctet3 ) ) )
|
||||
|
||||
#endif /* ipconfigBYTE_ORDER */
|
||||
|
||||
/* The socket type itself. */
|
||||
struct xSOCKET;
|
||||
typedef struct xSOCKET * Socket_t;
|
||||
typedef struct xSOCKET const * ConstSocket_t;
|
||||
|
||||
static portINLINE BaseType_t xSocketValid( Socket_t xSocket )
|
||||
{
|
||||
BaseType_t xReturnValue = pdFALSE;
|
||||
|
||||
/*
|
||||
* There are two values which can indicate an invalid socket:
|
||||
* FREERTOS_INVALID_SOCKET and NULL. In order to compare against
|
||||
* both values, the code cannot be compliant with rule 11.4,
|
||||
* hence the Coverity suppression statement below.
|
||||
*/
|
||||
/* coverity[misra_c_2012_rule_11_4_violation] */
|
||||
if( ( xSocket != FREERTOS_INVALID_SOCKET ) && ( xSocket != NULL ) )
|
||||
{
|
||||
xReturnValue = pdTRUE;
|
||||
}
|
||||
|
||||
return xReturnValue;
|
||||
}
|
||||
|
||||
#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
|
||||
* FUNCTIONS IS AVAILABLE ON THE FOLLOWING URL:
|
||||
* 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 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( ConstSocket_t xSocket,
|
||||
struct freertos_sockaddr * pxAddress );
|
||||
|
||||
#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 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 );
|
||||
|
||||
#if ( ipconfigSUPPORT_SIGNALS != 0 )
|
||||
/* Send a signal to the task which is waiting for a given socket. */
|
||||
BaseType_t FreeRTOS_SignalSocket( Socket_t xSocket );
|
||||
|
||||
/* Send a signal to the task which reads from this socket (FromISR
|
||||
* version). */
|
||||
BaseType_t FreeRTOS_SignalSocketFromISR( Socket_t xSocket,
|
||||
BaseType_t * pxHigherPriorityTaskWoken );
|
||||
#endif /* ipconfigSUPPORT_SIGNALS */
|
||||
|
||||
/* Return the remote address and IP port. */
|
||||
BaseType_t FreeRTOS_GetRemoteAddress( ConstSocket_t xSocket,
|
||||
struct freertos_sockaddr * pxAddress );
|
||||
|
||||
#if ( ipconfigUSE_TCP == 1 )
|
||||
|
||||
/* Returns pdTRUE if TCP socket is connected. */
|
||||
BaseType_t FreeRTOS_issocketconnected( ConstSocket_t xSocket );
|
||||
|
||||
/* Returns the actual size of MSS being used. */
|
||||
BaseType_t FreeRTOS_mss( ConstSocket_t xSocket );
|
||||
|
||||
#endif /* ( ipconfigUSE_TCP == 1 ) */
|
||||
|
||||
/* For internal use only: return the connection status. */
|
||||
BaseType_t FreeRTOS_connstatus( ConstSocket_t xSocket );
|
||||
|
||||
/* Returns the number of bytes that may be added to txStream */
|
||||
BaseType_t FreeRTOS_maywrite( ConstSocket_t xSocket );
|
||||
|
||||
/*
|
||||
* Two helper functions, mostly for testing
|
||||
* rx_size returns the number of bytes available in the Rx buffer
|
||||
* tx_space returns the free space in the Tx buffer
|
||||
*/
|
||||
#if ( ipconfigUSE_TCP == 1 )
|
||||
BaseType_t FreeRTOS_rx_size( ConstSocket_t xSocket );
|
||||
BaseType_t FreeRTOS_tx_space( ConstSocket_t xSocket );
|
||||
BaseType_t FreeRTOS_tx_size( ConstSocket_t xSocket );
|
||||
#endif
|
||||
|
||||
/* Returns the number of outstanding bytes in txStream. */
|
||||
|
||||
/* The function FreeRTOS_outstanding() was already implemented
|
||||
* FreeRTOS_tx_size(). */
|
||||
#define FreeRTOS_outstanding( xSocket ) FreeRTOS_tx_size( xSocket )
|
||||
|
||||
/* Returns the number of bytes in the socket's rxStream. */
|
||||
|
||||
/* The function FreeRTOS_recvcount() was already implemented
|
||||
* FreeRTOS_rx_size(). */
|
||||
#define FreeRTOS_recvcount( xSocket ) FreeRTOS_rx_size( xSocket )
|
||||
|
||||
/*
|
||||
* For advanced applications only:
|
||||
* Get a direct pointer to the circular transmit buffer.
|
||||
* '*pxLength' will contain the number of bytes that may be written.
|
||||
*/
|
||||
uint8_t * FreeRTOS_get_tx_head( ConstSocket_t xSocket,
|
||||
BaseType_t * pxLength );
|
||||
|
||||
#endif /* ipconfigUSE_TCP */
|
||||
|
||||
#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
|
||||
|
||||
/*
|
||||
* 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 /* ifdef __COVERITY__ */
|
||||
|
||||
/*
|
||||
* 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 /* ifdef __COVERITY__ */
|
||||
|
||||
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 ) */
|
||||
|
||||
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 );
|
||||
|
||||
/* 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
|
||||
*/
|
||||
const struct xSTREAM_BUFFER * FreeRTOS_get_rx_buf( ConstSocket_t xSocket );
|
||||
|
||||
void FreeRTOS_netstat( void );
|
||||
|
||||
#if ipconfigSUPPORT_SELECT_FUNCTION == 1
|
||||
|
||||
/* For FD_SET and FD_CLR, a combination of the following bits can be used: */
|
||||
|
||||
typedef enum eSELECT_EVENT
|
||||
{
|
||||
eSELECT_READ = 0x0001,
|
||||
eSELECT_WRITE = 0x0002,
|
||||
eSELECT_EXCEPT = 0x0004,
|
||||
eSELECT_INTR = 0x0008,
|
||||
eSELECT_ALL = 0x000F,
|
||||
/* Reserved for internal use: */
|
||||
eSELECT_CALL_IP = 0x0010,
|
||||
/* end */
|
||||
} eSelectEvent_t;
|
||||
|
||||
SocketSet_t FreeRTOS_CreateSocketSet( void );
|
||||
void FreeRTOS_DeleteSocketSet( SocketSet_t xSocketSet );
|
||||
void FreeRTOS_FD_SET( Socket_t xSocket,
|
||||
SocketSet_t xSocketSet,
|
||||
EventBits_t xBitsToSet );
|
||||
void FreeRTOS_FD_CLR( Socket_t xSocket,
|
||||
SocketSet_t xSocketSet,
|
||||
EventBits_t xBitsToClear );
|
||||
EventBits_t FreeRTOS_FD_ISSET( Socket_t xSocket,
|
||||
SocketSet_t xSocketSet );
|
||||
BaseType_t FreeRTOS_select( SocketSet_t xSocketSet,
|
||||
TickType_t xBlockTimeTicks );
|
||||
|
||||
#endif /* ipconfigSUPPORT_SELECT_FUNCTION */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* FREERTOS_SOCKETS_H */
|
@ -0,0 +1,266 @@
|
||||
/*
|
||||
* FreeRTOS+TCP V2.3.2 LTS Patch 1
|
||||
* Copyright (C) 2020 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
|
||||
*/
|
||||
|
||||
/*
|
||||
* FreeRTOS_Stream_Buffer.h
|
||||
*
|
||||
* A circular character buffer
|
||||
* An implementation of a circular buffer without a length field
|
||||
* If LENGTH defines the size of the buffer, a maximum of (LENGTH-1) bytes can be stored
|
||||
* In order to add or read data from the buffer, memcpy() will be called at most 2 times
|
||||
*/
|
||||
|
||||
#ifndef FREERTOS_STREAM_BUFFER_H
|
||||
|
||||
#define FREERTOS_STREAM_BUFFER_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* structure to store all the details of a stream buffer.
|
||||
*/
|
||||
typedef struct xSTREAM_BUFFER
|
||||
{
|
||||
volatile size_t uxTail; /**< next item to read */
|
||||
volatile size_t uxMid; /**< iterator within the valid items */
|
||||
volatile size_t uxHead; /**< next position store a new item */
|
||||
volatile size_t uxFront; /**< iterator within the free space */
|
||||
size_t LENGTH; /**< const value: number of reserved elements */
|
||||
uint8_t ucArray[ sizeof( size_t ) ]; /**< array big enough to store any pointer address */
|
||||
} StreamBuffer_t;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static portINLINE size_t uxStreamBufferSpace( const StreamBuffer_t * pxBuffer,
|
||||
const size_t uxLower,
|
||||
const size_t uxUpper );
|
||||
static portINLINE size_t uxStreamBufferSpace( const StreamBuffer_t * pxBuffer,
|
||||
const size_t uxLower,
|
||||
const size_t uxUpper )
|
||||
{
|
||||
/* Returns the space between uxLower and uxUpper, which equals to the distance minus 1 */
|
||||
size_t uxCount;
|
||||
|
||||
uxCount = pxBuffer->LENGTH + uxUpper - uxLower - 1U;
|
||||
|
||||
if( uxCount >= pxBuffer->LENGTH )
|
||||
{
|
||||
uxCount -= pxBuffer->LENGTH;
|
||||
}
|
||||
|
||||
return uxCount;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static portINLINE size_t uxStreamBufferDistance( const StreamBuffer_t * pxBuffer,
|
||||
const size_t uxLower,
|
||||
const size_t uxUpper );
|
||||
static portINLINE size_t uxStreamBufferDistance( const StreamBuffer_t * pxBuffer,
|
||||
const size_t uxLower,
|
||||
const size_t uxUpper )
|
||||
{
|
||||
/* Returns the distance between uxLower and uxUpper */
|
||||
size_t uxCount;
|
||||
|
||||
uxCount = pxBuffer->LENGTH + uxUpper - uxLower;
|
||||
|
||||
if( uxCount >= pxBuffer->LENGTH )
|
||||
{
|
||||
uxCount -= pxBuffer->LENGTH;
|
||||
}
|
||||
|
||||
return uxCount;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static portINLINE size_t uxStreamBufferGetSpace( const StreamBuffer_t * pxBuffer );
|
||||
static portINLINE size_t uxStreamBufferGetSpace( const StreamBuffer_t * pxBuffer )
|
||||
{
|
||||
/* Returns the number of items which can still be added to uxHead
|
||||
* before hitting on uxTail */
|
||||
size_t uxHead = pxBuffer->uxHead;
|
||||
size_t uxTail = pxBuffer->uxTail;
|
||||
|
||||
return uxStreamBufferSpace( pxBuffer, uxHead, uxTail );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static portINLINE size_t uxStreamBufferFrontSpace( const StreamBuffer_t * pxBuffer );
|
||||
static portINLINE size_t uxStreamBufferFrontSpace( const StreamBuffer_t * pxBuffer )
|
||||
{
|
||||
/* Distance between uxFront and uxTail
|
||||
* or the number of items which can still be added to uxFront,
|
||||
* before hitting on uxTail */
|
||||
|
||||
size_t uxFront = pxBuffer->uxFront;
|
||||
size_t uxTail = pxBuffer->uxTail;
|
||||
|
||||
return uxStreamBufferSpace( pxBuffer, uxFront, uxTail );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static portINLINE size_t uxStreamBufferGetSize( const StreamBuffer_t * pxBuffer );
|
||||
static portINLINE size_t uxStreamBufferGetSize( const StreamBuffer_t * pxBuffer )
|
||||
{
|
||||
/* Returns the number of items which can be read from uxTail
|
||||
* before reaching uxHead */
|
||||
size_t uxHead = pxBuffer->uxHead;
|
||||
size_t uxTail = pxBuffer->uxTail;
|
||||
|
||||
return uxStreamBufferDistance( pxBuffer, uxTail, uxHead );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static portINLINE size_t uxStreamBufferMidSpace( const StreamBuffer_t * pxBuffer );
|
||||
static portINLINE size_t uxStreamBufferMidSpace( const StreamBuffer_t * pxBuffer )
|
||||
{
|
||||
/* Returns the distance between uxHead and uxMid */
|
||||
size_t uxHead = pxBuffer->uxHead;
|
||||
size_t uxMid = pxBuffer->uxMid;
|
||||
|
||||
return uxStreamBufferDistance( pxBuffer, uxMid, uxHead );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static portINLINE void vStreamBufferMoveMid( StreamBuffer_t * pxBuffer,
|
||||
size_t uxCount );
|
||||
static portINLINE void vStreamBufferMoveMid( StreamBuffer_t * pxBuffer,
|
||||
size_t uxCount )
|
||||
{
|
||||
/* Increment uxMid, but no further than uxHead */
|
||||
size_t uxSize = uxStreamBufferMidSpace( pxBuffer );
|
||||
size_t uxMoveCount = uxCount;
|
||||
|
||||
if( uxMoveCount > uxSize )
|
||||
{
|
||||
uxMoveCount = uxSize;
|
||||
}
|
||||
|
||||
pxBuffer->uxMid += uxMoveCount;
|
||||
|
||||
if( pxBuffer->uxMid >= pxBuffer->LENGTH )
|
||||
{
|
||||
pxBuffer->uxMid -= pxBuffer->LENGTH;
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static portINLINE BaseType_t xStreamBufferLessThenEqual( const StreamBuffer_t * pxBuffer,
|
||||
const size_t uxLeft,
|
||||
const size_t uxRight );
|
||||
static portINLINE BaseType_t xStreamBufferLessThenEqual( const StreamBuffer_t * pxBuffer,
|
||||
const size_t uxLeft,
|
||||
const size_t uxRight )
|
||||
{
|
||||
BaseType_t xReturn;
|
||||
size_t uxTail = pxBuffer->uxTail;
|
||||
|
||||
/* Returns true if ( uxLeft < uxRight ) */
|
||||
if( ( ( ( uxLeft < uxTail ) ? 1U : 0U ) ^ ( ( uxRight < uxTail ) ? 1U : 0U ) ) != 0U )
|
||||
{
|
||||
if( uxRight < uxTail )
|
||||
{
|
||||
xReturn = pdTRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
xReturn = pdFALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( uxLeft <= uxRight )
|
||||
{
|
||||
xReturn = pdTRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
xReturn = pdFALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return xReturn;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static portINLINE size_t uxStreamBufferGetPtr( StreamBuffer_t * pxBuffer,
|
||||
uint8_t ** ppucData );
|
||||
static portINLINE size_t uxStreamBufferGetPtr( StreamBuffer_t * pxBuffer,
|
||||
uint8_t ** ppucData )
|
||||
{
|
||||
size_t uxNextTail = pxBuffer->uxTail;
|
||||
size_t uxSize = uxStreamBufferGetSize( pxBuffer );
|
||||
|
||||
*ppucData = pxBuffer->ucArray + uxNextTail;
|
||||
|
||||
return FreeRTOS_min_uint32( uxSize, pxBuffer->LENGTH - uxNextTail );
|
||||
}
|
||||
|
||||
/*
|
||||
* Add bytes to a stream buffer.
|
||||
*
|
||||
* pxBuffer - The buffer to which the bytes will be added.
|
||||
* uxOffset - If uxOffset > 0, data will be written at an offset from uxHead
|
||||
* while uxHead will not be moved yet.
|
||||
* 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 uxByteCount );
|
||||
|
||||
/*
|
||||
* Read bytes from a stream buffer.
|
||||
*
|
||||
* pxBuffer - The buffer from which the bytes will be read.
|
||||
* uxOffset - Can be used to read data located at a certain offset from 'uxTail'.
|
||||
* pucData - A pointer to the buffer into which data will be read.
|
||||
* uxMaxCount - The number of bytes to read.
|
||||
* xPeek - If set to pdTRUE the data will remain in the buffer.
|
||||
*/
|
||||
size_t uxStreamBufferGet( StreamBuffer_t * pxBuffer,
|
||||
size_t uxOffset,
|
||||
uint8_t * pucData,
|
||||
size_t uxMaxCount,
|
||||
BaseType_t xPeek );
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* !defined( FREERTOS_STREAM_BUFFER_H ) */
|
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* FreeRTOS+TCP V2.3.2 LTS Patch 1
|
||||
* Copyright (C) 2020 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_TCP_IP_H
|
||||
#define FREERTOS_TCP_IP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
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. */
|
||||
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
|
||||
* a connect */
|
||||
eSYN_FIRST, /* 3 (server) Just created, must ACK the SYN request. */
|
||||
eSYN_RECEIVED, /* 4 (server) waiting for a confirming connection request
|
||||
* acknowledgement after having both received and sent a connection request. */
|
||||
eESTABLISHED, /* 5 (server + client) an open connection, data received can be
|
||||
* delivered to the user. The normal state for the data transfer phase of the connection. */
|
||||
eFIN_WAIT_1, /* 6 (server + client) waiting for a connection termination request from the remote TCP,
|
||||
* 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, /* 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, /*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;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* FREERTOS_TCP_IP_H */
|
@ -0,0 +1,237 @@
|
||||
/*
|
||||
* FreeRTOS+TCP V2.3.2 LTS Patch 1
|
||||
* Copyright (C) 2020 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
|
||||
*/
|
||||
|
||||
/*
|
||||
* FreeRTOS_TCP_WIN.c
|
||||
* Module which handles the TCP windowing schemes for FreeRTOS-PLUS-TCP
|
||||
*/
|
||||
|
||||
#ifndef FREERTOS_TCP_WIN_H
|
||||
#define FREERTOS_TCP_WIN_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The name xTCPTimer was already use as the name of an IP-timer.
|
||||
*/
|
||||
typedef struct xTCPTimerStruct
|
||||
{
|
||||
uint32_t ulBorn; /**< The time when this timer is created. */
|
||||
} TCPTimer_t;
|
||||
|
||||
/**
|
||||
* Structure to hold the information about a TCP segment.
|
||||
*/
|
||||
typedef struct xTCP_SEGMENT
|
||||
{
|
||||
uint32_t ulSequenceNumber; /**< The sequence number of the first byte in this packet */
|
||||
int32_t lMaxLength; /**< Maximum space, number of bytes which can be stored in this segment */
|
||||
int32_t lDataLength; /**< Actual number of bytes */
|
||||
int32_t lStreamPos; /**< reference to the [t|r]xStream of the socket */
|
||||
TCPTimer_t xTransmitTimer; /**< saves a timestamp at the moment this segment gets transmitted (TX only) */
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint32_t
|
||||
ucTransmitCount : 8, /**< Number of times the segment has been transmitted, used to calculate the RTT */
|
||||
ucDupAckCount : 8, /**< Counts the number of times that a higher segment was ACK'd. After 3 times a Fast Retransmission takes place */
|
||||
bOutstanding : 1, /**< It the peer's turn, we're just waiting for an ACK */
|
||||
bAcked : 1, /**< This segment has been acknowledged */
|
||||
bIsForRx : 1; /**< pdTRUE if segment is used for reception */
|
||||
} bits;
|
||||
uint32_t ulFlags;
|
||||
} u; /**< Use a union to store the 32-bit flag field and the breakdown in the same location. */
|
||||
#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 xSegmentItem; /**< With this item the segment can be connected to a list, depending on who is owning it */
|
||||
#endif
|
||||
} TCPSegment_t;
|
||||
|
||||
/**
|
||||
* Structure to store the Rx/Tx window length.
|
||||
*/
|
||||
typedef struct xTCP_WINSIZE
|
||||
{
|
||||
uint32_t ulRxWindowLength; /**< The size of the receive window. */
|
||||
uint32_t ulTxWindowLength; /**< The size of the send window. */
|
||||
} TCPWinSize_t;
|
||||
|
||||
|
||||
/*
|
||||
* If TCP time-stamps are being used, they will occupy 12 bytes in
|
||||
* each packet, and thus the message space will become smaller
|
||||
*/
|
||||
/* Keep this as a multiple of 4 */
|
||||
#if ( ipconfigUSE_TCP_WIN == 1 )
|
||||
#define ipSIZE_TCP_OPTIONS 16U
|
||||
#else
|
||||
#define ipSIZE_TCP_OPTIONS 12U
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Every TCP connection owns a TCP window for the administration of all packets
|
||||
* It owns two sets of segment descriptors, incoming and outgoing
|
||||
*/
|
||||
typedef struct xTCP_WINDOW
|
||||
{
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint32_t
|
||||
bHasInit : 1, /**< The window structure has been initialised */
|
||||
bSendFullSize : 1, /**< May only send packets with a size equal to MSS (for optimisation) */
|
||||
bTimeStamps : 1; /**< Socket is supposed to use TCP time-stamps. This depends on the */
|
||||
} bits; /**< party which opens the connection */
|
||||
uint32_t ulFlags;
|
||||
} u; /**< Use a union to store the 32-bit flag field and the breakdown at the same place. */
|
||||
TCPWinSize_t xSize; /**< Size of the TCP window. */
|
||||
struct
|
||||
{
|
||||
uint32_t ulFirstSequenceNumber; /**< Logging & debug: the first segment received/sent in this connection
|
||||
* for Tx: initial send sequence number (ISS)
|
||||
* for Rx: initial receive sequence number (IRS) */
|
||||
uint32_t ulCurrentSequenceNumber; /**< Tx/Rx: the oldest sequence number not yet confirmed, also SND.UNA / RCV.NXT
|
||||
* In other words: the sequence number of the left side of the sliding window */
|
||||
uint32_t ulFINSequenceNumber; /**< The sequence number which carried the FIN flag */
|
||||
uint32_t ulHighestSequenceNumber; /**< Sequence number of the right-most byte + 1 */
|
||||
} rx, /**< Structure for the receiver for TCP. */
|
||||
tx; /**< Structure for the transmitter for TCP. */
|
||||
|
||||
uint32_t ulOurSequenceNumber; /**< The SEQ number we're sending out */
|
||||
uint32_t ulUserDataLength; /**< Number of bytes in Rx buffer which may be passed to the user, after having received a 'missing packet' */
|
||||
uint32_t ulNextTxSequenceNumber; /**< The sequence number given to the next byte to be added for transmission */
|
||||
int32_t lSRTT; /**< Smoothed Round Trip Time, it may increment quickly and it decrements slower */
|
||||
uint8_t ucOptionLength; /**< Number of valid bytes in ulOptionsData[] */
|
||||
#if ( ipconfigUSE_TCP_WIN == 1 )
|
||||
List_t xPriorityQueue; /**< Priority queue: segments which must be sent immediately */
|
||||
List_t xTxQueue; /**< Transmit queue: segments queued for transmission */
|
||||
List_t xWaitQueue; /**< Waiting queue: outstanding segments */
|
||||
TCPSegment_t * pxHeadSegment; /**< points to a segment which has not been transmitted and it's size is still growing (user data being added) */
|
||||
uint32_t ulOptionsData[ ipSIZE_TCP_OPTIONS / sizeof( uint32_t ) ]; /**< Contains the options we send out */
|
||||
List_t xTxSegments; /**< A linked list of all transmission segments, sorted on sequence number */
|
||||
List_t xRxSegments; /**< A linked list of reception segments, order depends on sequence of arrival */
|
||||
#else
|
||||
/* For tiny TCP, there is only 1 outstanding TX segment */
|
||||
TCPSegment_t xTxSegment; /**< Priority queue */
|
||||
#endif
|
||||
uint16_t usOurPortNumber; /**< Mostly for debugging/logging: our TCP port number */
|
||||
uint16_t usPeerPortNumber; /**< debugging/logging: the peer's TCP port number */
|
||||
uint16_t usMSS; /**< Current accepted MSS */
|
||||
uint16_t usMSSInit; /**< MSS as configured by the socket owner */
|
||||
} TCPWindow_t;
|
||||
|
||||
|
||||
|
||||
/*=============================================================================
|
||||
*
|
||||
* Creation and destruction
|
||||
*
|
||||
*=============================================================================*/
|
||||
|
||||
/* Create and initialize a window */
|
||||
void vTCPWindowCreate( TCPWindow_t * pxWindow,
|
||||
uint32_t ulRxWindowLength,
|
||||
uint32_t ulTxWindowLength,
|
||||
uint32_t ulAckNumber,
|
||||
uint32_t ulSequenceNumber,
|
||||
uint32_t ulMSS );
|
||||
|
||||
/* Destroy a window (always returns NULL)
|
||||
* It will free some resources: a collection of segments */
|
||||
void vTCPWindowDestroy( TCPWindow_t const * pxWindow );
|
||||
|
||||
/* Initialize a window */
|
||||
void vTCPWindowInit( TCPWindow_t * pxWindow,
|
||||
uint32_t ulAckNumber,
|
||||
uint32_t ulSequenceNumber,
|
||||
uint32_t ulMSS );
|
||||
|
||||
/* Clean up allocated segments. Should only be called when FreeRTOS+TCP will no longer be used. */
|
||||
void vTCPSegmentCleanup( void );
|
||||
|
||||
/*=============================================================================
|
||||
*
|
||||
* Rx functions
|
||||
*
|
||||
*=============================================================================*/
|
||||
|
||||
/* if true may be passed directly to user (segment expected and window is empty)
|
||||
* 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 );
|
||||
|
||||
/* 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( const TCPWindow_t * pxWindow );
|
||||
|
||||
/*=============================================================================
|
||||
*
|
||||
* Tx functions
|
||||
*
|
||||
*=============================================================================*/
|
||||
|
||||
/* Adds data to the Tx-window */
|
||||
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 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( const TCPWindow_t * pxWindow );
|
||||
|
||||
/* Fetches data to be sent.
|
||||
* plPosition will point to a location with the circular data buffer: txStream */
|
||||
uint32_t ulTCPWindowTxGet( TCPWindow_t * pxWindow,
|
||||
uint32_t ulWindowSize,
|
||||
int32_t * plPosition );
|
||||
|
||||
/* Receive a normal ACK */
|
||||
uint32_t ulTCPWindowTxAck( TCPWindow_t * pxWindow,
|
||||
uint32_t ulSequenceNumber );
|
||||
|
||||
/* Receive a SACK option */
|
||||
uint32_t ulTCPWindowTxSack( TCPWindow_t * pxWindow,
|
||||
uint32_t ulFirst,
|
||||
uint32_t ulLast );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* FREERTOS_TCP_WIN_H */
|
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* FreeRTOS+TCP V2.3.2 LTS Patch 1
|
||||
* Copyright (C) 2020 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_UDP_IP_H
|
||||
#define FREERTOS_UDP_IP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Application level configuration options. */
|
||||
#include "FreeRTOSIPConfig.h"
|
||||
#include "FreeRTOSIPConfigDefaults.h"
|
||||
#include "IPTraceMacroDefaults.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* FREERTOS_UDP_IP_H */
|
@ -0,0 +1,96 @@
|
||||
/*
|
||||
* FreeRTOS+TCP V2.3.2 LTS Patch 1
|
||||
* Copyright (C) 2020 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_ERRNO_TCP
|
||||
#define FREERTOS_ERRNO_TCP
|
||||
|
||||
/* The following definitions will be included in the core FreeRTOS code in
|
||||
* future versions of FreeRTOS - hence the 'pd' (ProjDefs) prefix - at which time
|
||||
* this file will be removed. */
|
||||
|
||||
/* The following errno values are used by FreeRTOS+ components, not FreeRTOS
|
||||
* itself. */
|
||||
|
||||
/* For future compatibility (see comment above), check the definitions have not
|
||||
* already been made. */
|
||||
#ifndef pdFREERTOS_ERRNO_NONE
|
||||
#define pdFREERTOS_ERRNO_NONE 0 /* No errors */
|
||||
#define pdFREERTOS_ERRNO_ENOENT 2 /* No such file or directory */
|
||||
#define pdFREERTOS_ERRNO_EINTR 4 /* Interrupted system call */
|
||||
#define pdFREERTOS_ERRNO_EIO 5 /* I/O error */
|
||||
#define pdFREERTOS_ERRNO_ENXIO 6 /* No such device or address */
|
||||
#define pdFREERTOS_ERRNO_EBADF 9 /* Bad file number */
|
||||
#define pdFREERTOS_ERRNO_EAGAIN 11 /* No more processes */
|
||||
#define pdFREERTOS_ERRNO_EWOULDBLOCK 11 /* Operation would block */
|
||||
#define pdFREERTOS_ERRNO_ENOMEM 12 /* Not enough memory */
|
||||
#define pdFREERTOS_ERRNO_EACCES 13 /* Permission denied */
|
||||
#define pdFREERTOS_ERRNO_EFAULT 14 /* Bad address */
|
||||
#define pdFREERTOS_ERRNO_EBUSY 16 /* Mount device busy */
|
||||
#define pdFREERTOS_ERRNO_EEXIST 17 /* File exists */
|
||||
#define pdFREERTOS_ERRNO_EXDEV 18 /* Cross-device link */
|
||||
#define pdFREERTOS_ERRNO_ENODEV 19 /* No such device */
|
||||
#define pdFREERTOS_ERRNO_ENOTDIR 20 /* Not a directory */
|
||||
#define pdFREERTOS_ERRNO_EISDIR 21 /* Is a directory */
|
||||
#define pdFREERTOS_ERRNO_EINVAL 22 /* Invalid argument */
|
||||
#define pdFREERTOS_ERRNO_ENOSPC 28 /* No space left on device */
|
||||
#define pdFREERTOS_ERRNO_ESPIPE 29 /* Illegal seek */
|
||||
#define pdFREERTOS_ERRNO_EROFS 30 /* Read only file system */
|
||||
#define pdFREERTOS_ERRNO_EUNATCH 42 /* Protocol driver not attached */
|
||||
#define pdFREERTOS_ERRNO_EBADE 50 /* Invalid exchange */
|
||||
#define pdFREERTOS_ERRNO_EFTYPE 79 /* Inappropriate file type or format */
|
||||
#define pdFREERTOS_ERRNO_ENMFILE 89 /* No more files */
|
||||
#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 */
|
||||
#define pdFREERTOS_ERRNO_ETIMEDOUT 116 /* Connection timed out */
|
||||
#define pdFREERTOS_ERRNO_EINPROGRESS 119 /* Connection already in progress */
|
||||
#define pdFREERTOS_ERRNO_EALREADY 120 /* Socket already connected */
|
||||
#define pdFREERTOS_ERRNO_EADDRNOTAVAIL 125 /* Address not available */
|
||||
#define pdFREERTOS_ERRNO_EISCONN 127 /* Socket is already connected */
|
||||
#define pdFREERTOS_ERRNO_ENOTCONN 128 /* Socket is not connected */
|
||||
#define pdFREERTOS_ERRNO_ENOMEDIUM 135 /* No medium inserted */
|
||||
#define pdFREERTOS_ERRNO_EILSEQ 138 /* An invalid UTF-16 sequence was encountered. */
|
||||
#define pdFREERTOS_ERRNO_ECANCELED 140 /* Operation canceled. */
|
||||
|
||||
/* The following endian values are used by FreeRTOS+ components, not FreeRTOS
|
||||
* itself. */
|
||||
#define pdFREERTOS_LITTLE_ENDIAN 0
|
||||
#define pdFREERTOS_BIG_ENDIAN 1
|
||||
#else /* ifndef pdFREERTOS_ERRNO_NONE */
|
||||
#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 */
|
@ -0,0 +1,243 @@
|
||||
/*
|
||||
* FreeRTOS+TCP V2.3.2 LTS Patch 1
|
||||
* Copyright (C) 2020 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
|
||||
*/
|
||||
|
||||
/* This file provides default (empty) implementations for any IP trace macros
|
||||
* that are not defined by the user. See
|
||||
* http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_IP_Trace.html */
|
||||
|
||||
#ifndef UDP_TRACE_MACRO_DEFAULTS_H
|
||||
#define UDP_TRACE_MACRO_DEFAULTS_H
|
||||
|
||||
#ifndef iptraceNETWORK_DOWN
|
||||
#define iptraceNETWORK_DOWN()
|
||||
#endif
|
||||
|
||||
#ifndef iptraceNETWORK_BUFFER_RELEASED
|
||||
#define iptraceNETWORK_BUFFER_RELEASED( pxBufferAddress )
|
||||
#endif
|
||||
|
||||
#ifndef iptraceNETWORK_BUFFER_OBTAINED
|
||||
#define iptraceNETWORK_BUFFER_OBTAINED( pxBufferAddress )
|
||||
#endif
|
||||
|
||||
#ifndef iptraceNETWORK_BUFFER_OBTAINED_FROM_ISR
|
||||
#define iptraceNETWORK_BUFFER_OBTAINED_FROM_ISR( pxBufferAddress )
|
||||
#endif
|
||||
|
||||
#ifndef iptraceNETWORK_INTERFACE_INPUT
|
||||
/* An Ethernet packet has been received. */
|
||||
#define iptraceNETWORK_INTERFACE_INPUT( uxDataLength, pucEthernetBuffer )
|
||||
#endif
|
||||
|
||||
#ifndef iptraceNETWORK_INTERFACE_OUTPUT
|
||||
/* An Ethernet packet will be sent. */
|
||||
#define iptraceNETWORK_INTERFACE_OUTPUT( uxDataLength, pucEthernetBuffer )
|
||||
#endif
|
||||
|
||||
#ifndef iptraceFAILED_TO_OBTAIN_NETWORK_BUFFER
|
||||
#define iptraceFAILED_TO_OBTAIN_NETWORK_BUFFER()
|
||||
#endif
|
||||
|
||||
#ifndef iptraceFAILED_TO_OBTAIN_NETWORK_BUFFER_FROM_ISR
|
||||
#define iptraceFAILED_TO_OBTAIN_NETWORK_BUFFER_FROM_ISR()
|
||||
#endif
|
||||
|
||||
#ifndef iptraceCREATING_ARP_REQUEST
|
||||
#define iptraceCREATING_ARP_REQUEST( ulIPAddress )
|
||||
#endif
|
||||
|
||||
#ifndef iptraceARP_TABLE_ENTRY_WILL_EXPIRE
|
||||
#define iptraceARP_TABLE_ENTRY_WILL_EXPIRE( ulIPAddress )
|
||||
#endif
|
||||
|
||||
#ifndef iptraceARP_TABLE_ENTRY_EXPIRED
|
||||
#define iptraceARP_TABLE_ENTRY_EXPIRED( ulIPAddress )
|
||||
#endif
|
||||
|
||||
#ifndef iptraceARP_TABLE_ENTRY_CREATED
|
||||
#define iptraceARP_TABLE_ENTRY_CREATED( ulIPAddress, ucMACAddress )
|
||||
#endif
|
||||
|
||||
#ifndef iptraceSENDING_UDP_PACKET
|
||||
#define iptraceSENDING_UDP_PACKET( ulIPAddress )
|
||||
#endif
|
||||
|
||||
#ifndef iptracePACKET_DROPPED_TO_GENERATE_ARP
|
||||
#define iptracePACKET_DROPPED_TO_GENERATE_ARP( ulIPAddress )
|
||||
#endif
|
||||
|
||||
#ifndef iptraceICMP_PACKET_RECEIVED
|
||||
#define iptraceICMP_PACKET_RECEIVED()
|
||||
#endif
|
||||
|
||||
#ifndef iptraceSENDING_PING_REPLY
|
||||
#define iptraceSENDING_PING_REPLY( ulIPAddress )
|
||||
#endif
|
||||
|
||||
#ifndef traceARP_PACKET_RECEIVED
|
||||
#define traceARP_PACKET_RECEIVED()
|
||||
#endif
|
||||
|
||||
#ifndef iptracePROCESSING_RECEIVED_ARP_REPLY
|
||||
#define iptracePROCESSING_RECEIVED_ARP_REPLY( ulIPAddress )
|
||||
#endif
|
||||
|
||||
#ifndef iptraceSENDING_ARP_REPLY
|
||||
#define iptraceSENDING_ARP_REPLY( ulIPAddress )
|
||||
#endif
|
||||
|
||||
#ifndef iptraceFAILED_TO_CREATE_SOCKET
|
||||
#define iptraceFAILED_TO_CREATE_SOCKET()
|
||||
#endif
|
||||
|
||||
#ifndef iptraceFAILED_TO_CREATE_EVENT_GROUP
|
||||
#define iptraceFAILED_TO_CREATE_EVENT_GROUP()
|
||||
#endif
|
||||
|
||||
#ifndef iptraceRECVFROM_DISCARDING_BYTES
|
||||
#define iptraceRECVFROM_DISCARDING_BYTES( xNumberOfBytesDiscarded )
|
||||
#endif
|
||||
|
||||
#ifndef iptraceETHERNET_RX_EVENT_LOST
|
||||
#define iptraceETHERNET_RX_EVENT_LOST()
|
||||
#endif
|
||||
|
||||
#ifndef iptraceSTACK_TX_EVENT_LOST
|
||||
#define iptraceSTACK_TX_EVENT_LOST( xEvent )
|
||||
#endif
|
||||
|
||||
#ifndef iptraceNETWORK_EVENT_RECEIVED
|
||||
#define iptraceNETWORK_EVENT_RECEIVED( eEvent )
|
||||
#endif
|
||||
|
||||
#ifndef iptraceBIND_FAILED
|
||||
#define iptraceBIND_FAILED( xSocket, usPort )
|
||||
#endif
|
||||
|
||||
#ifndef iptraceDHCP_REQUESTS_FAILED_USING_DEFAULT_IP_ADDRESS
|
||||
#define iptraceDHCP_REQUESTS_FAILED_USING_DEFAULT_IP_ADDRESS( ulIPAddress )
|
||||
#endif
|
||||
|
||||
#ifndef iptraceSENDING_DHCP_DISCOVER
|
||||
#define iptraceSENDING_DHCP_DISCOVER()
|
||||
#endif
|
||||
|
||||
#ifndef iptraceSENDING_DHCP_REQUEST
|
||||
#define iptraceSENDING_DHCP_REQUEST()
|
||||
#endif
|
||||
|
||||
#ifndef iptraceDHCP_SUCCEDEED
|
||||
#define iptraceDHCP_SUCCEDEED( address )
|
||||
#endif
|
||||
|
||||
#ifndef iptraceNETWORK_INTERFACE_TRANSMIT
|
||||
#define iptraceNETWORK_INTERFACE_TRANSMIT()
|
||||
#endif
|
||||
|
||||
#ifndef iptraceNETWORK_INTERFACE_RECEIVE
|
||||
#define iptraceNETWORK_INTERFACE_RECEIVE()
|
||||
#endif
|
||||
|
||||
#ifndef iptraceSENDING_DNS_REQUEST
|
||||
#define iptraceSENDING_DNS_REQUEST()
|
||||
#endif
|
||||
|
||||
#ifndef iptraceWAITING_FOR_TX_DMA_DESCRIPTOR
|
||||
#define iptraceWAITING_FOR_TX_DMA_DESCRIPTOR()
|
||||
#endif
|
||||
|
||||
#ifndef ipconfigINCLUDE_EXAMPLE_FREERTOS_PLUS_TRACE_CALLS
|
||||
#define ipconfigINCLUDE_EXAMPLE_FREERTOS_PLUS_TRACE_CALLS 0
|
||||
#endif
|
||||
|
||||
#ifndef iptraceFAILED_TO_NOTIFY_SELECT_GROUP
|
||||
#define iptraceFAILED_TO_NOTIFY_SELECT_GROUP( xSocket )
|
||||
#endif
|
||||
|
||||
#ifndef pvPortMallocSocket
|
||||
#define pvPortMallocSocket( xSize ) pvPortMalloc( ( xSize ) )
|
||||
#endif
|
||||
|
||||
#ifndef iptraceRECVFROM_TIMEOUT
|
||||
#define iptraceRECVFROM_TIMEOUT()
|
||||
#endif
|
||||
|
||||
#ifndef iptraceRECVFROM_INTERRUPTED
|
||||
#define iptraceRECVFROM_INTERRUPTED()
|
||||
#endif
|
||||
|
||||
#ifndef iptraceNO_BUFFER_FOR_SENDTO
|
||||
#define iptraceNO_BUFFER_FOR_SENDTO()
|
||||
#endif
|
||||
|
||||
#ifndef iptraceSENDTO_SOCKET_NOT_BOUND
|
||||
#define iptraceSENDTO_SOCKET_NOT_BOUND()
|
||||
#endif
|
||||
|
||||
#ifndef iptraceSENDTO_DATA_TOO_LONG
|
||||
#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 */
|
@ -0,0 +1,76 @@
|
||||
/*
|
||||
* FreeRTOS+TCP V2.3.2 LTS Patch 1
|
||||
* Copyright (C) 2020 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 NETWORK_BUFFER_MANAGEMENT_H
|
||||
#define NETWORK_BUFFER_MANAGEMENT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* NOTE PUBLIC API FUNCTIONS. */
|
||||
BaseType_t xNetworkBuffersInitialise( void );
|
||||
NetworkBufferDescriptor_t * pxGetNetworkBufferWithDescriptor( size_t xRequestedSizeBytes,
|
||||
TickType_t xBlockTimeTicks );
|
||||
|
||||
/* The definition of the below function is only available if BufferAllocation_2.c has been linked into the source. */
|
||||
NetworkBufferDescriptor_t * pxNetworkBufferGetFromISR( size_t xRequestedSizeBytes );
|
||||
void vReleaseNetworkBufferAndDescriptor( NetworkBufferDescriptor_t * const pxNetworkBuffer );
|
||||
|
||||
/* The definition of the below function is only available if BufferAllocation_2.c has been linked into the source. */
|
||||
BaseType_t vNetworkBufferReleaseFromISR( NetworkBufferDescriptor_t * const pxNetworkBuffer );
|
||||
uint8_t * pucGetNetworkBuffer( size_t * pxRequestedSizeBytes );
|
||||
void vReleaseNetworkBuffer( uint8_t * pucEthernetBuffer );
|
||||
|
||||
/* Get the current number of free network buffers. */
|
||||
UBaseType_t uxGetNumberOfFreeNetworkBuffers( void );
|
||||
|
||||
/* Get the lowest number of free network buffers. */
|
||||
UBaseType_t uxGetMinimumFreeNetworkBuffers( void );
|
||||
|
||||
/* Copy a network buffer into a bigger buffer. */
|
||||
NetworkBufferDescriptor_t * pxDuplicateNetworkBufferWithDescriptor( const NetworkBufferDescriptor_t * const pxNetworkBuffer,
|
||||
size_t uxNewLength );
|
||||
|
||||
/* Increase the size of a Network Buffer.
|
||||
* In case BufferAllocation_2.c is used, the new space must be allocated. */
|
||||
NetworkBufferDescriptor_t * pxResizeNetworkBufferWithDescriptor( NetworkBufferDescriptor_t * pxNetworkBuffer,
|
||||
size_t xNewSizeBytes );
|
||||
|
||||
#if ipconfigTCP_IP_SANITY
|
||||
|
||||
/*
|
||||
* Check if an address is a valid pointer to a network descriptor
|
||||
* by looking it up in the array of network descriptors
|
||||
*/
|
||||
UBaseType_t bIsValidNetworkDescriptor( const NetworkBufferDescriptor_t * pxDesc );
|
||||
BaseType_t prvIsFreeBuffer( const NetworkBufferDescriptor_t * pxDescr );
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* NETWORK_BUFFER_MANAGEMENT_H */
|
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* FreeRTOS+TCP V2.3.2 LTS Patch 1
|
||||
* Copyright (C) 2020 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 NETWORK_INTERFACE_H
|
||||
#define NETWORK_INTERFACE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* INTERNAL API FUNCTIONS. */
|
||||
BaseType_t xNetworkInterfaceInitialise( void );
|
||||
BaseType_t xNetworkInterfaceOutput( NetworkBufferDescriptor_t * const pxNetworkBuffer,
|
||||
BaseType_t xReleaseAfterSend );
|
||||
|
||||
/* The following function is defined only when BufferAllocation_1.c is linked in the project. */
|
||||
void vNetworkInterfaceAllocateRAMToBuffers( NetworkBufferDescriptor_t pxNetworkBuffers[ ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS ] );
|
||||
|
||||
/* The following function is defined only when BufferAllocation_1.c is linked in the project. */
|
||||
BaseType_t xGetPhyLinkStatus( void );
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* NETWORK_INTERFACE_H */
|
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* iperf_task.c
|
||||
*/
|
||||
|
||||
#ifndef IPERF_TASK_H_
|
||||
|
||||
#define IPERF_TASK_H_
|
||||
|
||||
/* This function will start a task that will handl all IPERF requests from outside.
|
||||
Call it after the IP-stack is up and running. */
|
||||
#define ipconfigIPERF_HAS_TCP 1
|
||||
#define ipconfigIPERF_HAS_UDP 1
|
||||
|
||||
void vIPerfInstall( void );
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user