Fix warnings and update ReadMe (#1067)

Fix warnings and update ReadMe

Also, make the demo output comprehensible.

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
This commit is contained in:
Gaurav-Aggarwal-AWS 2023-08-10 10:41:12 +05:30 committed by GitHub
parent eefb87aa0d
commit 7b15146706
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 255 additions and 283 deletions

View file

@ -225,4 +225,8 @@
#define strncasecmp _strnicmp #define strncasecmp _strnicmp
#define strcmpi _strcmpi #define strcmpi _strcmpi
extern void vLoggingPrintf( const char * pcFormatString,
... );
#define configPRINTF( X ) vLoggingPrintf X
#endif /* FREERTOS_CONFIG_H */ #endif /* FREERTOS_CONFIG_H */

View file

@ -44,7 +44,7 @@ extern void vLoggingPrintf( const char * pcFormatString,
/* Set to 1 to print out debug messages. If ipconfigHAS_DEBUG_PRINTF is set to /* 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 * 1 then FreeRTOS_debug_printf should be defined to the function used to print
* out the debugging messages. */ * out the debugging messages. */
#define ipconfigHAS_DEBUG_PRINTF 1 #define ipconfigHAS_DEBUG_PRINTF 0
#if ( ipconfigHAS_DEBUG_PRINTF == 1 ) #if ( ipconfigHAS_DEBUG_PRINTF == 1 )
#define FreeRTOS_debug_printf( X ) vLoggingPrintf X #define FreeRTOS_debug_printf( X ) vLoggingPrintf X
#endif #endif
@ -53,7 +53,7 @@ extern void vLoggingPrintf( const char * pcFormatString,
* FreeRTOS_netstat() command, and ping replies. If ipconfigHAS_PRINTF is set to 1 * 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 * then FreeRTOS_printf should be set to the function used to print out the
* messages. */ * messages. */
#define ipconfigHAS_PRINTF 1 #define ipconfigHAS_PRINTF 0
#if ( ipconfigHAS_PRINTF == 1 ) #if ( ipconfigHAS_PRINTF == 1 )
#define FreeRTOS_printf( X ) vLoggingPrintf X #define FreeRTOS_printf( X ) vLoggingPrintf X
#endif #endif

View file

@ -159,7 +159,7 @@ void vLoggingInit( BaseType_t xLogToStdout,
/* Can only be called before the scheduler has started. */ /* Can only be called before the scheduler has started. */
configASSERT( xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED ); configASSERT( xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED );
#if ( ( ipconfigHAS_DEBUG_PRINTF == 1 ) || ( ipconfigHAS_PRINTF == 1 ) ) #if ( ( ipconfigHAS_DEBUG_PRINTF == 1 ) || ( ipconfigHAS_PRINTF == 1 ) || defined( configPRINTF ) )
{ {
HANDLE Win32Thread; HANDLE Win32Thread;
@ -215,7 +215,7 @@ void vLoggingInit( BaseType_t xLogToStdout,
SetThreadPriority( Win32Thread, THREAD_PRIORITY_IDLE ); SetThreadPriority( Win32Thread, THREAD_PRIORITY_IDLE );
} }
} }
#else /* if ( ( ipconfigHAS_DEBUG_PRINTF == 1 ) || ( ipconfigHAS_PRINTF == 1 ) ) */ #else /* if ( ( ipconfigHAS_DEBUG_PRINTF == 1 ) || ( ipconfigHAS_PRINTF == 1 ) || defined( configPRINTF ) ) */
{ {
/* FreeRTOSIPConfig is set such that no print messages will be output. /* FreeRTOSIPConfig is set such that no print messages will be output.
* Avoid compiler warnings about unused parameters. */ * Avoid compiler warnings about unused parameters. */
@ -225,7 +225,7 @@ void vLoggingInit( BaseType_t xLogToStdout,
( void ) usRemotePort; ( void ) usRemotePort;
( void ) ulRemoteIPAddress; ( void ) ulRemoteIPAddress;
} }
#endif /* ( ipconfigHAS_DEBUG_PRINTF == 1 ) || ( ipconfigHAS_PRINTF == 1 ) */ #endif /* ( ipconfigHAS_DEBUG_PRINTF == 1 ) || ( ipconfigHAS_PRINTF == 1 ) || defined( configPRINTF ) */
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/

View file

@ -1,192 +1,212 @@
# FreeRTOS+TCP IPv6 Multi-Endpoint Demo # FreeRTOS+TCP IPv6 Multi-Endpoint Demo
The IPv6_Multi_WinSim Visual studio demo showcases the Multiple Interfaces (or The IPv6_Multi_WinSim Visual studio demo showcases the Multiple Interfaces (or
rather the multiple endpoints) functionality of the FreeRTOS+TCP library. rather multiple endpoints) functionality of the FreeRTOS+TCP library.
The Windows Simulator environment doesn't actually have multiple The Windows Simulator environment doesn't actually have multiple
interfaces which can be used by FreeRTOS and thus, this demo shows interfaces which can be used by FreeRTOS and thus, this demo shows
the use of different endpoints which will be resolved by the OS having multiple the use of different endpoints (IP-addresses).
interfaces. It shows that the library will use different endpoints (IP-addresses)
to connect to IP-addresses on different subnets (or using different netmasks).
## Setting up the workspace ## Setting up the workspace
Clone the submodules used in the FreeRTOS repo: Clone the repo along with submodules used:
```
git clone https://github.com/FreeRTOS/FreeRTOS.git --recurse-submodules
```
If you have cloned the repo without using the `--recurse-submodules`
argument, you need to run:
``` ```
git submodule update --init --recursive git submodule update --init --recursive
``` ```
The FreeRTOS+TCP Multiple Interface Visual Studio project file is in the following The FreeRTOS+TCP Multiple Interface Visual Studio project file is
directory: `FreeRTOS-Plus\Demo\FreeRTOS_Plus_TCP_IPv6_Demo\IPv6_Multi_WinSim_demo` [FreeRTOS_Plus_TCP_IPv6_Multi.sln](FreeRTOS_Plus_TCP_IPv6_Multi.sln).
In FreeRTOS_Plus_TCP_IPv6_Multi.props, you will find a couple of macros that indicate
the location of source files:
- FREERTOS_SOURCE_DIR The kernel sources
- FREERTOS_INCLUDE_DIR The kernel header files
- DEMO_COMMON_SOURCE_DIR The location of the "common" directory of the demos
- PLUS_TCP_SOURCE_DIR The FreeRTOS+TCP source files
- PLUS_TCP_INCLUDE_DIR> The FreeRTOS+TCP header files
- UTILITIES_SOURCE_DIR The location of the tcp_utilities directory
You can changes these directory to let the project work with a different
source tree.
## Prerequisites ## Prerequisites
[Optional] Running IPv4 demo [FreeRTOS_Plus_TCP_Minimal_Windows_Simulator](https://github.com/FreeRTOS/FreeRTOS/tree/main/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Minimal_Windows_Simulator) 1. The host PC needs to be connected to the network using an Ethernet cable.
The instructions are provided on the following URL, see the ["Hardware Setup" and "Software Setup"](http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/examples_FreeRTOS_simulator.html). 2. Set `configNETWORK_INTERFACE_TYPE_TO_USE` in the [FreeRTOSConfig.h](FreeRTOSConfig.h)
This will give more hands on experience of running Echo server and client. file to the name of the network interface to use , e.g. "Realtek". You can run the
demo once to print all the available network interfaces.
For this demo, FreeRTOS configuration file *FreeRTOSConfig.h* needs to be updated as shown below : ## Running the demo
*Client Configuration* : This demo provides 4 examples:
1. `configIP_ADDR0/3` : Setup with client IP address, when DHCP is disabled. 1. The TCP Echo Client Example
2. `configNET_MASK0/3` : Setup with the appropriate network mask. 2. The TCP Echo Server Example
3. `configGATEWAY_ADDR0/3 ` : Setup with Default Gateway address of Client IP. 3. The UDP Echo Client Example
4. `configDNS_SERVER_ADDR0/3` : Setup wit DNS Server address of Client IP. 4. The CLI Example
*Server Configuration :* ### Running The TCP Echo Client Example
1. `configECHO_SERVER_ADDR_STRING` as an IPv6 Server IP address for IPv6
validation, it can be updated to IPv4 address for IPv4 validations.
2. `configECHO_SERVER_PORT` Needs to be setup for the Server port number.
Note that, as delivered, configUSE_DHCPv6 is set to 0, so a static IP address is used. 1. Set `mainCREATE_TCP_ECHO_TASKS_SINGLE` to 1 in the [main.c](main.c) file.
1. Clone the [FreeRTOS-Libraries-Integration-Tests](https://github.com/FreeRTOS/FreeRTOS-Libraries-Integration-Tests/tree/main)
repo on the host where you want to run the echo server:
```
git clone https://github.com/FreeRTOS/FreeRTOS-Libraries-Integration-Tests.git
```
1. Run the TCP echo server available at [tools/echo_server](https://github.com/FreeRTOS/FreeRTOS-Libraries-Integration-Tests/tree/main/tools/echo_server)
by running the following command:
```
go run echo_server.go
```
1. Set `configECHO_SERVER_ADDR_STRING` in the [FreeRTOSConfig.h](FreeRTOSConfig.h)
file to the IP address of host on which you started echo server in the above
step.
1. Set `configECHO_SERVER_PORT` in the [FreeRTOSConfig.h](FreeRTOSConfig.h)
file to the echo server port. If you followed step 1 and 2 above to run the
echo server, the port number is `9000` which can be changed in the
[config.json](https://github.com/FreeRTOS/FreeRTOS-Libraries-Integration-Tests/blob/main/tools/echo_server/config.json#L5)
file.
1. Build the project and run. You should see the output like the following:
```
161 18.678 [echo_00 ] -------- Starting New Iteration --------
162 18.916 [echo_00 ] FreeRTOS_connect returns 0
163 19.136 [echo_00 ] FreeRTOS_send: 3289/3289
164 19.376 [echo_00 ] Instance[0]: Good 27/27 shutdown 240
165 19.376 [echo_00 ] 3 x 3480 = 10440 Exchange 3289/3289
166 19.376 [echo_00 ] --------------------------------------
```
## Selecting the Examples to Run ### Running The TCP Echo Server Example
### The TCP client example: 1. Set `mainCREATE_TCP_ECHO_SERVER_TASK` to 1 in the [main.c](main.c) file.
1. Build the project and run.
```
0 0.167 [IP-task ] uxNetworkisUp = 1
1 0.167 [IP-task ] uxNetworkisUp = 2
2 1.727 [IP-task ] uxNetworkisUp = 3
3 1.727 [IP-task ] IPv4 address = 192.168.1.83
```
1. Echo server should now be running and ready to accept incoming connections
on port number 7. You can connect the echo server using any client. For example,
you can use `nc` command to connect:
```
nc 192.168.1.83 7
Hello
Hello
World
World
```
Note that `192.168.1.83` is the IP address assigned to one of our endpoints as
can be seen in the output of step 2. We send the string "Hello" and then "World"
and we get the same strings back.
This example can be enabled by setting the `mainCREATE_TCP_ECHO_TASKS_SINGLE` ### Running The UDP Echo Client Example
macro to 1 at the top of the project's main.c source file.
The example creates two RTOS tasks that send TCP echo requests to an external 1. Set `mainCREATE_UDP_ECHO_TASKS_SINGLE` to 1 in the [main.c](main.c) file.
echo server using the echo port set in FreeRTOSConfig.h, then wait to receive 1. Clone the [FreeRTOS-Libraries-Integration-Tests](https://github.com/FreeRTOS/FreeRTOS-Libraries-Integration-Tests/tree/main)
the echo reply within the same RTOS task. repo on the host where you want to run the echo server:
```
git clone https://github.com/FreeRTOS/FreeRTOS-Libraries-Integration-Tests.git
```
1. Set `use_udp` to `true` in the
[tools/echo_server/config.json](https://github.com/FreeRTOS/FreeRTOS-Libraries-Integration-Tests/blob/main/tools/echo_server/config.json) file.
1. Run the UDP echo server available at [tools/echo_server](https://github.com/FreeRTOS/FreeRTOS-Libraries-Integration-Tests/tree/main/tools/echo_server)
by running the following command:
```
go run echo_server.go
```
1. Set `configECHO_SERVER_ADDR_STRING` in the [FreeRTOSConfig.h](FreeRTOSConfig.h)
file to the IP address of host on which you started echo server in the above
step.
1. Set `configECHO_SERVER_PORT` in the [FreeRTOSConfig.h](FreeRTOSConfig.h)
file to the echo server port. If you followed step 1 and 2 above to run the
echo server, the port number is `9000` which can be changed in the
[config.json](https://github.com/FreeRTOS/FreeRTOS-Libraries-Integration-Tests/blob/main/tools/echo_server/config.json#L5)
file.
1. Build the project and run. You should see the output like the following:
```
12 15.722 [echo_00 ] -------- Starting New Iteration --------
13 15.880 [echo_00 ] [Echo Client] Data was received correctly.
14 17.880 [echo_00 ] [Echo Client] Data was received correctly.
15 19.620 [echo_00 ] [Echo Client] Data was received correctly.
16 21.380 [echo_00 ] [Echo Client] Data was received correctly.
17 23.160 [echo_00 ] [Echo Client] Data was received correctly.
18 24.840 [echo_00 ] Exchange (Sent/Received) : 100/99
19 24.840 [echo_00 ] --------------------------------------
```
The IP address of the echo server must be configured by updating the `configECHO_SERVER_ADDR_STRING` ### Running The CLI Example
as IPv4 or IPv6 address and server port number must be updated as `configECHO_SERVER_PORT` in FreeRTOSConfig.h.
The echo server must be enabled and not blocked by a firewall.
### The TCP server example: 1. Set `mainCREATE_CLI_TASK` to 1 in the [main.c](main.c) file.
1. Uncomment the commands that you want to execute in the
`pcCommandList` array in the [main.c](main.c) file. By default,
only the `ifconfig` command is enabled.
1. Set `ipconfigHAS_PRINTF` to 1 in the [FreeRTOSIPConfig.h](FreeRTOSIPConfig.h)
file.
1. Build the project and run. You should see the output like the following:
```
44 3.742 [cli ]
45 3.742 [cli ]
46 3.742 [cli ] /*==================== ifconfig (1/1) ====================*/
47 3.742 [cli ]
48 3.742 [cli ] Interface eth0
49 3.742 [cli ] IP-address : 192.168.1.83
50 3.742 [cli ] Default IP : 192.168.2.114
51 3.742 [cli ] End-point : up = yes method DHCP
52 3.742 [cli ] Net mask : 255.255.255.0
53 3.742 [cli ] GW : 192.168.1.1
54 3.742 [cli ] DNS-0 : 192.168.1.1
55 3.742 [cli ] DNS-1 : 0.0.0.0
56 3.742 [cli ] Broadcast : 192.168.1.255
57 3.742 [cli ] MAC address: 00-11-22-33-44-41
58 3.742 [cli ]
59 3.742 [cli ] IP-address : 2001:470:ed44::4d6d:0:3c15:0
60 3.742 [cli ] End-point : up = yes method static
61 3.742 [cli ] Prefix : 2001:470:ed44::/64
62 3.742 [cli ] GW : fe80::ba27:ebff:fe5a:d751
63 3.742 [cli ] DNS-0 : 2001:4860:4860::8888
64 3.742 [cli ] DNS-1 : fe80::1
65 3.742 [cli ] MAC address: 00-11-22-33-44-41
66 3.742 [cli ]
67 3.742 [cli ] IP-address : fe80::7009
68 3.742 [cli ] End-point : up = yes method static
69 3.742 [cli ] Prefix : fe80::/10
70 3.742 [cli ] GW : ::
71 3.742 [cli ] DNS-0 : ::
72 3.742 [cli ] DNS-1 : ::
73 3.742 [cli ] MAC address: 00-11-22-33-44-41
74 3.742 [cli ]
```
This example can be enabled by setting the `mainCREATE_TCP_ECHO_SERVER_TASK` ## Advanced Topics
macro to 1 at the top of the project's main.c source file.
This example creates an echo server that listens for echo requests on ### Using static IP configuration
the standard echo protocol port number 7. It then echos back any data
received on that connection.
### The UDP Echo Client example Set `ipconfigUSE_DHCP` to 0 and set the following in the
[FreeRTOSConfig.h](FreeRTOSConfig.h) file:
The demo also demonstrates a IPv4/IPv6 UDP echo client which can be enabled by * `configIP_ADDR0/3` : Set to the IP address. It is used when DHCP is disabled.
setting the `mainCREATE_UDP_ECHO_TASKS_SINGLE` macro to 1 in the main file. * `configNET_MASK0/3` : Set to the appropriate network mask.
* `configGATEWAY_ADDR0/3 ` : Set to the Default Gateway address.
* `configDNS_SERVER_ADDR0/3` : Set to the DNS Server address.
The UDP Echo Client creates a task and sends messages to the IP address and port Note that we have only tested this demo with `ipconfigUSE_DHCPv6`
defined as `configECHO_SERVER_ADDR_STRING` (either v4 or v6 address) set to 0.
and configECHO_SERVER_PORT respectively in the FreeRTOSConfig.h file and expect to
get echo of the messages back. There should be a UDP echo server running in the
given IP and port.
These RTOS tasks are self checking and will trigger a configASSERT() failure if they ### Enabling debug logs
detect a difference in the data that is received from that which was sent. As these
RTOS tasks use UDP, which can legitimately loose packets, they can cause configASSERT()
failures when they are executed in a less than perfect networking environment.
#### *Note* Sample TCP and UDP echo server can be found at the last section of ReadME. Set `ipconfigHAS_PRINTF` and `ipconfigHAS_DEBUG_PRINTF` to 1 in the
### The IPv6_Multi_WinSim_demo demo also performs some basic network activities: [FreeRTOSIPConfig.h](FreeRTOSIPConfig.h) file.
- ARP address resolution for IPv4 addresses on the LAN ### Using Zero Copy
- Neighbour Discovery for IPv6 addresses on the LAN
- Looking up a IPv4 or IPv6 address using DNS, either asynchronous or synchronous.
- Looking up a local host ( IPv4/6 ) using LLMNR ( not considered safe anymore )
- Talk with an NTP server and fetch the time using UDP, with IPv4/6
- Download a file from any public server using TCP/HTTP
- Ping any server on the web or on the LAN, , with IPv4 or IPv6
The demo can be easily adapted to your own needs. It works like a command line The UDP Echo Client demo also demonstrates the UDP zero copy which can be enabled
interface ( CLI ) that performs the above tasks. Although it is called a CLI, by setting `USE_ZERO_COPY` to 1 at the top of the
the demo does not have a STDIN. The commands are hard-coded in main.c pcCommandList. [UDPEchoClient_SingleTasks.c](UDPEchoClient_SingleTasks.c) file.
The pcCommandList options can be uncommented to run the commands. Here are some examples of ### Using the project in a different source tree
valid command lines, using the keywords “http”, “ping”, “dnsq”, and “ntp:
"http4 google.co.uk /index.html", The following macros in the [FreeRTOS_Plus_TCP_IPv6_Multi.props](FreeRTOS_Plus_TCP_IPv6_Multi.props)
"http6 amazon.com /index.html", file can be updated to se this project in a different source tree:
"ping4 10.0.1.10",
"ping6 2001:470:ec54::",
"dnsq4 yahoo.com",
"ping6 aws.com",
"ntp6a 2.europe.pool.ntp.org",
The last line will first lookup the mentioned NTP server, send a request, and wait * FREERTOS_SOURCE_DIR : The location of the FreeRTOS Kernel source files.
for a reply. The time will be printed in the logging. * FREERTOS_INCLUDE_DIR : The location of the FreeRTOS Kernel header files.
* DEMO_COMMON_SOURCE_DIR : The location of the "common" directory of the demos.
The keywords can have some single-letter suffices: 4 or 6 ( for IPv4/6 ), “a” to do * PLUS_TCP_SOURCE_DIR : The location of the FreeRTOS+TCP source files.
an asynchronous DNS lookup, and “c” to clear all caches before starting the task. * PLUS_TCP_INCLUDE_DIR> : The location of the FreeRTOS+TCP header files.
* UTILITIES_SOURCE_DIR : The location of the tcp_utilities directory.
## Sample Echo server
##### Prerequisites : [Install go](https://go.dev/doc/install)
#### Sample UDP server in Go:
``` go
// Filename: echo_server.go
// Run: go run echo_server.go <ip_address>:<port>
// Example IPv4: go run echo_server.go 192.168.1.2:9000
// Example IPv6: go run echo_server.go [fe80::1b99:a6bd:a344:b09d]:9000
package main
import (
"fmt"
"net"
"os"
)
func main() {
if len(os.Args) == 1 {
fmt.Println("Please provide host:port")
os.Exit(1)
}
// Resolve the string address to a UDP address
udpAddr, err := net.ResolveUDPAddr("udp", os.Args[1])
if err != nil {
fmt.Println(err)
os.Exit(1)
}
// Start listening for UDP packages on the given address
conn, err := net.ListenUDP("udp", udpAddr)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
// Read from UDP listener
for {
var buf [1024]byte
_, addr, err := conn.ReadFromUDP(buf[0:])
if err != nil {
fmt.Println(err)
return
}
fmt.Print(string(buf[0:]))
// Write back the message over UDP
conn.WriteToUDP([]byte(buf[0:]), addr)
}
}
```
The UDP Echo Client demo also demonstrates the UDP zero copy for both IPv4 and IPv6
(based on the IP type), it can be enabled by setting `USE_ZERO_COPY` macro of the
UDPEchoClient_SingleTasks.c file to 1.
#### Sample TCP server in Go:
[TCP Echo Server](https://github.com/FreeRTOS/FreeRTOS-Libraries-Integration-Tests/tree/main/tools/echo_server)

View file

@ -131,11 +131,11 @@
} }
} }
FreeRTOS_printf( ( "Started %d / %d tasks\n", ( int ) xCount, ( int ) echoNUM_ECHO_CLIENTS ) ); configPRINTF( ( "Started %d / %d tasks\n", ( int ) xCount, ( int ) echoNUM_ECHO_CLIENTS ) );
} }
else else
{ {
FreeRTOS_printf( ( "vStartTCPEchoClientTasks_SingleTasks: already started\n" ) ); configPRINTF( ( "vStartTCPEchoClientTasks_SingleTasks: already started\n" ) );
} }
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
@ -160,7 +160,7 @@
int32_t lLoopCount = 0UL; int32_t lLoopCount = 0UL;
const int32_t lMaxLoopCount = 1; const int32_t lMaxLoopCount = 1;
volatile uint32_t ulTxCount = 0UL; volatile uint32_t ulTxCount = 0UL;
BaseType_t xReceivedBytes, xReturned, xInstance; BaseType_t xReceivedBytes, xReturned = 0, xInstance;
BaseType_t lTransmitted, lStringLength; BaseType_t lTransmitted, lStringLength;
char * pcTransmittedString, * pcReceivedString; char * pcTransmittedString, * pcReceivedString;
WinProperties_t xWinProps; WinProperties_t xWinProps;
@ -225,6 +225,7 @@
for( ; ; ) for( ; ; )
{ {
configPRINTF( ( "-------- Starting New Iteration --------\n" ) );
BaseType_t xResult; BaseType_t xResult;
/* Create a TCP socket. */ /* Create a TCP socket. */
xSocket = FreeRTOS_socket( xFamily, FREERTOS_SOCK_STREAM, FREERTOS_IPPROTO_TCP ); xSocket = FreeRTOS_socket( xFamily, FREERTOS_SOCK_STREAM, FREERTOS_IPPROTO_TCP );
@ -242,7 +243,7 @@
/* Connect to the echo server. */ /* Connect to the echo server. */
xResult = FreeRTOS_connect( xSocket, &xEchoServerAddress, sizeof( xEchoServerAddress ) ); xResult = FreeRTOS_connect( xSocket, &xEchoServerAddress, sizeof( xEchoServerAddress ) );
FreeRTOS_printf( ( "FreeRTOS_connect returns %d\n", ( int ) xResult ) ); configPRINTF( ( "FreeRTOS_connect returns %d\n", ( int ) xResult ) );
if( xResult == 0 ) if( xResult == 0 )
{ {
@ -258,18 +259,12 @@
sprintf( pcTransmittedString, "TxRx message number %u", ( unsigned ) ulTxCount ); sprintf( pcTransmittedString, "TxRx message number %u", ( unsigned ) ulTxCount );
ulTxCount++; ulTxCount++;
if( lLoopCount == ( lMaxLoopCount - 1 ) )
{
BaseType_t xTrue = pdTRUE;
/* FreeRTOS_setsockopt( xSocket, 0, FREERTOS_SO_CLOSE_AFTER_SEND, &xTrue, sizeof( xTrue ) ); */
}
/* Send the string to the socket. */ /* Send the string to the socket. */
lTransmitted = FreeRTOS_send( xSocket, /* The socket being sent to. */ lTransmitted = FreeRTOS_send( xSocket, /* The socket being sent to. */
( void * ) pcTransmittedString, /* The data being sent. */ ( void * ) pcTransmittedString, /* The data being sent. */
lStringLength, /* The length of the data being sent. */ lStringLength, /* The length of the data being sent. */
0 ); /* No flags. */ 0 ); /* No flags. */
FreeRTOS_printf( ( "FreeRTOS_send: %u/%u\n", ( unsigned ) lTransmitted, ( unsigned ) lStringLength ) ); configPRINTF( ( "FreeRTOS_send: %u/%u\n", ( unsigned ) lTransmitted, ( unsigned ) lStringLength ) );
if( xIsFatalError( lTransmitted ) ) if( xIsFatalError( lTransmitted ) )
{ {
@ -302,7 +297,7 @@
if( xReturned == 0 ) if( xReturned == 0 )
{ {
/* Timed out. */ /* Timed out. */
FreeRTOS_printf( ( "recv returned %u\n", ( unsigned ) xReturned ) ); configPRINTF( ( "recv returned %u\n", ( unsigned ) xReturned ) );
break; break;
} }
@ -368,17 +363,18 @@
} while( uxDuration < xReceiveTimeOut ); } while( uxDuration < xReceiveTimeOut );
} }
FreeRTOS_printf( ( "Instance[%u]: Good %u/%u shutdown %u\n", configPRINTF( ( "Instance[%u]: Good %u/%u shutdown %u\n",
( unsigned ) xInstance, ( unsigned ) xInstance,
( unsigned ) ( ulTxRxCycles[ xInstance ] - ulTxRxFailures[ xInstance ] ), ( unsigned ) ( ulTxRxCycles[ xInstance ] - ulTxRxFailures[ xInstance ] ),
( unsigned ) ( ulTxRxCycles[ xInstance ] ), ( unsigned ) ( ulTxRxCycles[ xInstance ] ),
( unsigned ) uxDuration ) ); ( unsigned ) uxDuration ) );
FreeRTOS_printf( ( "%u x %u = %u Exchange %u/%u\n", configPRINTF( ( "%u x %u = %u Exchange %u/%u\n",
( unsigned ) echoBUFFER_SIZE_MULTIPLIER, ( unsigned ) echoBUFFER_SIZE_MULTIPLIER,
( unsigned ) echoBUFFER_SIZES, ( unsigned ) echoBUFFER_SIZES,
( unsigned ) ( echoBUFFER_SIZE_MULTIPLIER * echoBUFFER_SIZES ), ( unsigned ) ( echoBUFFER_SIZE_MULTIPLIER * echoBUFFER_SIZES ),
( unsigned ) xTotalSent, ( unsigned ) xTotalSent,
( unsigned ) xTotalRecv ) ); ( unsigned ) xTotalRecv ) );
configPRINTF( ( "--------------------------------------\n\n" ) );
/* Close this socket before looping back to create another. */ /* Close this socket before looping back to create another. */
FreeRTOS_closesocket( xSocket ); FreeRTOS_closesocket( xSocket );

View file

@ -25,7 +25,7 @@
*/ */
/* /*
* A set of tasks are created that send UDP echo requests to the * A set of tasks are created that send UDP echo requests to the
* IP address set by the configECHO_SERVER_ADDR0 to * IP address set by the configECHO_SERVER_ADDR0 to
* configECHO_SERVER_ADDR_STRING constant, then wait for and verify the reply * configECHO_SERVER_ADDR_STRING constant, then wait for and verify the reply
* *
@ -99,11 +99,11 @@ void vStartUDPEchoClientTasks_SingleTasks(uint16_t usTaskStackSize, UBaseType_t
xCount++; xCount++;
} }
} }
FreeRTOS_printf(("Started %d / %d tasks\n", (int)xCount, (int)echoNUM_ECHO_CLIENTS)); configPRINTF(("Started %d / %d tasks\n", (int)xCount, (int)echoNUM_ECHO_CLIENTS));
} }
else else
{ {
FreeRTOS_printf(("vStartUDPEchoClientTasks_SingleTasks: already started\n")); configPRINTF(("vStartUDPEchoClientTasks_SingleTasks: already started\n"));
} }
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
@ -159,6 +159,7 @@ static void prvUDPEchoClientTask(void* pvParameters)
for (;; ) for (;; )
{ {
configPRINTF( ( "-------- Starting New Iteration --------\n" ) );
/* Create a socket. */ /* Create a socket. */
xSocket = FreeRTOS_socket(xFamily, FREERTOS_SOCK_DGRAM, FREERTOS_IPPROTO_UDP); xSocket = FreeRTOS_socket(xFamily, FREERTOS_SOCK_DGRAM, FREERTOS_IPPROTO_UDP);
configASSERT(xSocket != FREERTOS_INVALID_SOCKET); configASSERT(xSocket != FREERTOS_INVALID_SOCKET);
@ -216,16 +217,15 @@ static void prvUDPEchoClientTask(void* pvParameters)
} }
else else
{ {
/* Keep a count of how many echo requests have been transmitted so
it can be compared to the number of echo replies received. It would
be expected to loose at least one to an ARP message the first time
the connection is created. */
ulTxCount++;
/* The send was successful. */ /* The send was successful. */
FreeRTOS_debug_printf(("[Echo Client] Data sent... \r\n")); FreeRTOS_debug_printf(("[Echo Client] Data sent... \r\n"));
} }
/* Keep a count of how many echo requests have been transmitted so
it can be compared to the number of echo replies received. It would
be expected to loose at least one to an ARP message the first time
the connection is created. */
ulTxCount++;
/* Receive data echoed back to the socket. ulFlags is zero, so the /* Receive data echoed back to the socket. ulFlags is zero, so the
zero copy option is not being used and the received data will be zero copy option is not being used and the received data will be
copied into the buffer pointed to by cRxString. xAddressLength is copied into the buffer pointed to by cRxString. xAddressLength is
@ -271,7 +271,10 @@ static void prvUDPEchoClientTask(void* pvParameters)
{ {
/* The echo reply was received without error. */ /* The echo reply was received without error. */
ulRxCount++; ulRxCount++;
FreeRTOS_debug_printf(("[Echo Client] Data was received correctly.\r\n")); if( ( ulRxCount % 10 ) == 0 )
{
configPRINTF(("[Echo Client] Data was received correctly.\r\n"));
}
} }
else else
{ {
@ -284,6 +287,9 @@ static void prvUDPEchoClientTask(void* pvParameters)
} }
} }
configPRINTF( ( "Exchange (Sent/Received) : %u/%u\n", ulTxCount, ulRxCount ) );
configPRINTF( ( "--------------------------------------\n\n" ) );
/* Pause for a short while to ensure the network is not too /* Pause for a short while to ensure the network is not too
congested. */ congested. */
vTaskDelay(echoLOOP_DELAY); vTaskDelay(echoLOOP_DELAY);

View file

@ -75,7 +75,7 @@ $(DEMO_COMMON_SOURCE_DIR)\logging\include;
..\common\Logging\windows ..\common\Logging\windows
</AdditionalIncludeDirectories> </AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;WINVER=0x400;_CRT_SECURE_NO_WARNINGS;ipconfigUSE_PCAP=1;_NO_CRT_STDIO_INLINE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;WINVER=0x400;_CRT_SECURE_NO_WARNINGS;ipconfigUSE_PCAP=1;_NO_CRT_STDIO_INLINE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild> <MinimalRebuild>false</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<PrecompiledHeaderOutputFile>.\Debug/WIN32.pch</PrecompiledHeaderOutputFile> <PrecompiledHeaderOutputFile>.\Debug/WIN32.pch</PrecompiledHeaderOutputFile>
@ -85,7 +85,7 @@ $(DEMO_COMMON_SOURCE_DIR)\logging\include;
<WarningLevel>Level4</WarningLevel> <WarningLevel>Level4</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner> <SuppressStartupBanner>true</SuppressStartupBanner>
<DisableLanguageExtensions>false</DisableLanguageExtensions> <DisableLanguageExtensions>false</DisableLanguageExtensions>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<AdditionalOptions>/wd4210 /wd4127 /wd4214 /wd4201 /wd4244 /wd4310 %(AdditionalOptions)</AdditionalOptions> <AdditionalOptions>/wd4210 /wd4127 /wd4214 /wd4201 /wd4244 /wd4310 %(AdditionalOptions)</AdditionalOptions>
<BrowseInformation>true</BrowseInformation> <BrowseInformation>true</BrowseInformation>
<PrecompiledHeader>NotUsing</PrecompiledHeader> <PrecompiledHeader>NotUsing</PrecompiledHeader>
@ -155,7 +155,9 @@ $(DEMO_COMMON_SOURCE_DIR)\logging\include;
<ItemGroup> <ItemGroup>
<ClCompile Include="$(UTILITIES_SOURCE_DIR)\date_and_time.c" /> <ClCompile Include="$(UTILITIES_SOURCE_DIR)\date_and_time.c" />
<ClCompile Include="$(UTILITIES_SOURCE_DIR)\http_client_test.c" /> <ClCompile Include="$(UTILITIES_SOURCE_DIR)\http_client_test.c" />
<ClCompile Include="$(UTILITIES_SOURCE_DIR)\plus_tcp_demo_cli.c" /> <ClCompile Include="$(UTILITIES_SOURCE_DIR)\plus_tcp_demo_cli.c">
<AdditionalOptions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">/wd4068 %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<ClCompile Include="$(UTILITIES_SOURCE_DIR)\tcp_dump_packets.c" /> <ClCompile Include="$(UTILITIES_SOURCE_DIR)\tcp_dump_packets.c" />
<ClCompile Include="..\..\..\Source\FreeRTOS-Plus-TCP\source\FreeRTOS_BitConfig.c" /> <ClCompile Include="..\..\..\Source\FreeRTOS-Plus-TCP\source\FreeRTOS_BitConfig.c" />
<ClCompile Include="..\..\..\Source\FreeRTOS-Plus-TCP\source\FreeRTOS_IPv4.c" /> <ClCompile Include="..\..\..\Source\FreeRTOS-Plus-TCP\source\FreeRTOS_IPv4.c" />

View file

@ -96,13 +96,14 @@
* expected to echo back the data, which, the created tasks receives. * expected to echo back the data, which, the created tasks receives.
* *
*/ */
#define mainCREATE_TCP_ECHO_TASKS_SINGLE 1 /* 1 */ #define mainCREATE_TCP_ECHO_TASKS_SINGLE 1
#define mainCREATE_TCP_ECHO_SERVER_TASK 0 #define mainCREATE_TCP_ECHO_SERVER_TASK 0
#define mainCREATE_UDP_ECHO_TASKS_SINGLE 0 #define mainCREATE_UDP_ECHO_TASKS_SINGLE 0
#define mainCREATE_CLI_TASK 0
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
/* Define a task that is used to start and monitor several tests. */ /* Define a task that is used to start and monitor several tests. */
static void prvServerWorkTask( void * pvArgument ); static void prvCliTask( void * pvArgument );
/* Let this task run at a low priority. */ /* Let this task run at a low priority. */
#define mainTCP_SERVER_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 ) #define mainTCP_SERVER_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
@ -234,7 +235,6 @@ int main( void )
IPv6_Address_t xIPAddress; IPv6_Address_t xIPAddress;
IPv6_Address_t xPrefix; IPv6_Address_t xPrefix;
IPv6_Address_t xGateWay; IPv6_Address_t xGateWay;
IPv6_Address_t xDNSServer1, xDNSServer2;
FreeRTOS_inet_pton6( "2001:470:ed44::", xPrefix.ucBytes ); FreeRTOS_inet_pton6( "2001:470:ed44::", xPrefix.ucBytes );
@ -316,8 +316,6 @@ int main( void )
FreeRTOS_IPInit_Multi(); FreeRTOS_IPInit_Multi();
xTaskCreate( prvServerWorkTask, "SvrWork", mainTCP_SERVER_STACK_SIZE, NULL, mainTCP_SERVER_TASK_PRIORITY, NULL );
/* Start the RTOS scheduler. */ /* Start the RTOS scheduler. */
FreeRTOS_debug_printf( ( "vTaskStartScheduler\r\n" ) ); FreeRTOS_debug_printf( ( "vTaskStartScheduler\r\n" ) );
vTaskStartScheduler(); vTaskStartScheduler();
@ -408,6 +406,7 @@ void vApplicationIPNetworkEventHook_Multi( eIPCallbackEvent_t eNetworkEvent,
#if ( mainCREATE_TCP_ECHO_SERVER_TASK == 1 ) #if ( mainCREATE_TCP_ECHO_SERVER_TASK == 1 )
{ {
extern void vStartSimpleTCPServerTasks( uint16_t usStackSize, UBaseType_t uxPriority );
vStartSimpleTCPServerTasks( mainECHO_SERVER_TASK_STACK_SIZE, mainECHO_SERVER_TASK_PRIORITY ); vStartSimpleTCPServerTasks( mainECHO_SERVER_TASK_STACK_SIZE, mainECHO_SERVER_TASK_PRIORITY );
} }
#endif #endif
@ -418,15 +417,21 @@ void vApplicationIPNetworkEventHook_Multi( eIPCallbackEvent_t eNetworkEvent,
} }
#endif #endif
#if ( mainCREATE_CLI_TASK == 1 )
{
xTaskCreate( prvCliTask, "cli", mainTCP_SERVER_STACK_SIZE, NULL, mainTCP_SERVER_TASK_PRIORITY, NULL );
}
#endif
xTasksAlreadyCreated = pdTRUE; xTasksAlreadyCreated = pdTRUE;
} }
FreeRTOS_printf( ( "uxNetworkisUp = %u\n", ( unsigned ) uxNetworkisUp ) ); configPRINTF( ( "uxNetworkisUp = %u\n", ( unsigned ) uxNetworkisUp ) );
if( pxEndPoint->bits.bIPv6 == 0U ) if( pxEndPoint->bits.bIPv6 == 0U )
{ {
*ipLOCAL_IP_ADDRESS_POINTER = pxEndPoint->ipv4_settings.ulIPAddress; *ipLOCAL_IP_ADDRESS_POINTER = pxEndPoint->ipv4_settings.ulIPAddress;
FreeRTOS_printf( ( "IPv4 address = %xip\n", FreeRTOS_ntohl( pxEndPoint->ipv4_settings.ulIPAddress ) ) ); configPRINTF( ( "IPv4 address = %xip\n", FreeRTOS_ntohl( pxEndPoint->ipv4_settings.ulIPAddress ) ) );
} }
/* Print out the network configuration, which may have come from a DHCP /* Print out the network configuration, which may have come from a DHCP
@ -512,7 +517,7 @@ static void prvMiscInitialisation( void )
BaseType_t xDone = pdFALSE; BaseType_t xDone = pdFALSE;
BaseType_t bDNS_IPv6 = ( pxEndPoint->usDNSType == dnsTYPE_AAAA_HOST ) ? 1 : 0; BaseType_t bDNS_IPv6 = ( pxEndPoint->usDNSType == dnsTYPE_AAAA_HOST ) ? 1 : 0;
FreeRTOS_printf( ( "Wanted v%c got v%c\n", bDNS_IPv6 ? '6' : '4', pxEndPoint->bits.bIPv6 ? '6' : '4' ) ); configPRINTF( ( "Wanted v%c got v%c\n", bDNS_IPv6 ? '6' : '4', pxEndPoint->bits.bIPv6 ? '6' : '4' ) );
if( ( pxEndPoint->usDNSType == dnsTYPE_ANY_HOST ) || if( ( pxEndPoint->usDNSType == dnsTYPE_ANY_HOST ) ||
( ( pxEndPoint->usDNSType == dnsTYPE_AAAA_HOST ) == ( pxEndPoint->bits.bIPv6 != 0U ) ) ) ( ( pxEndPoint->usDNSType == dnsTYPE_AAAA_HOST ) == ( pxEndPoint->bits.bIPv6 != 0U ) ) )
@ -547,11 +552,11 @@ static void prvMiscInitialisation( void )
if( pxEndPoint->bits.bIPv6 != 0 ) if( pxEndPoint->bits.bIPv6 != 0 )
{ {
FreeRTOS_printf( ( "%s address %pip\n", xDone ? "Success" : "Failed", pxEndPoint->ipv6_settings.xIPAddress.ucBytes ) ); configPRINTF( ( "%s address %pip\n", xDone ? "Success" : "Failed", pxEndPoint->ipv6_settings.xIPAddress.ucBytes ) );
} }
else else
{ {
FreeRTOS_printf( ( "%s address %xip\n", xDone ? "Success" : "Failed", ( unsigned ) FreeRTOS_ntohl( pxEndPoint->ipv4_settings.ulIPAddress ) ) ); configPRINTF( ( "%s address %xip\n", xDone ? "Success" : "Failed", ( unsigned ) FreeRTOS_ntohl( pxEndPoint->ipv4_settings.ulIPAddress ) ) );
} }
return xDone; return xDone;
@ -570,6 +575,9 @@ static void prvMiscInitialisation( void )
* by mainDEVICE_NICK_NAME. */ * by mainDEVICE_NICK_NAME. */
const char * serviceName = ( strstr( pcName, ".local" ) != NULL ) ? "mDNS" : "LLMNR"; const char * serviceName = ( strstr( pcName, ".local" ) != NULL ) ? "mDNS" : "LLMNR";
/* Suppress warnings when FreeRTOS_printf is not defined. */
( void ) serviceName;
if( strncasecmp( pcName, "bong", 4 ) == 0 ) if( strncasecmp( pcName, "bong", 4 ) == 0 )
{ {
#if ( ipconfigUSE_IPv6 != 0 ) #if ( ipconfigUSE_IPv6 != 0 )
@ -662,7 +670,7 @@ const char * pcCommandList[] =
/* "arpqc 192.168.2.10", */ /* "arpqc 192.168.2.10", */
/* "arpqc 172.217.194.100", */ /* "arpqc 172.217.194.100", */
/* "arpqc 2404:6800:4003:c0f::5e", */ /* "arpqc 2404:6800:4003:c0f::5e", */
"ifconfig", "ifconfig",
/* "udp 192.168.2.255@2402 Hello", */ /* "udp 192.168.2.255@2402 Hello", */
/* "udp 192.168.2.255@2402 Hello", */ /* "udp 192.168.2.255@2402 Hello", */
/* "udp 192.168.2.255@2402 Hello", */ /* "udp 192.168.2.255@2402 Hello", */
@ -701,13 +709,12 @@ const char * pcCommandList[] =
/* "ntp6a 2.europe.pool.ntp.org", */ /* "ntp6a 2.europe.pool.ntp.org", */
}; };
static void prvServerWorkTask( void * pvArgument ) static void prvCliTask( void * pvArgument )
{ {
BaseType_t xCommandIndex = 0; BaseType_t xCommandIndex = 0;
Socket_t xSocket;
( void ) pvArgument; ( void ) pvArgument;
FreeRTOS_printf( ( "prvServerWorkTask started\n" ) ); configPRINTF( ( "prvCliTask started\n" ) );
xServerSemaphore = xSemaphoreCreateBinary(); xServerSemaphore = xSemaphoreCreateBinary();
configASSERT( xServerSemaphore != NULL ); configASSERT( xServerSemaphore != NULL );
@ -723,20 +730,6 @@ static void prvServerWorkTask( void * pvArgument )
xDNS_IP_Preference = xPreferenceIPv6; xDNS_IP_Preference = xPreferenceIPv6;
{
xSocket = FreeRTOS_socket( FREERTOS_AF_INET, FREERTOS_SOCK_DGRAM, FREERTOS_IPPROTO_UDP );
struct freertos_sockaddr xAddress;
( void ) memset( &( xAddress ), 0, sizeof( xAddress ) );
xAddress.sin_family = FREERTOS_AF_INET6;
xAddress.sin_port = FreeRTOS_htons( 5000U );
BaseType_t xReturn = FreeRTOS_bind( xSocket, &xAddress, ( socklen_t ) sizeof( xAddress ) );
FreeRTOS_printf( ( "Open socket %d bind = %d\n", xSocketValid( xSocket ), xReturn ) );
TickType_t xTimeoutTime = pdMS_TO_TICKS( 10U );
FreeRTOS_setsockopt( xSocket, 0, FREERTOS_SO_RCVTIMEO, &xTimeoutTime, sizeof( TickType_t ) );
}
for( ; ; ) for( ; ; )
{ {
char pcCommand[ 129 ]; char pcCommand[ 129 ];
@ -752,76 +745,20 @@ static void prvServerWorkTask( void * pvArgument )
} }
/* vTaskDelay( pdMS_TO_TICKS( 1000U ) ); */ /* vTaskDelay( pdMS_TO_TICKS( 1000U ) ); */
FreeRTOS_printf( ( "\n" ) ); configPRINTF( ( "\n" ) );
snprintf( pcCommand, sizeof( pcCommand ), "%s", pcCommandList[ xCommandIndex ] ); snprintf( pcCommand, sizeof( pcCommand ), "%s", pcCommandList[ xCommandIndex ] );
FreeRTOS_printf( ( "\n" ) ); configPRINTF( ( "\n" ) );
FreeRTOS_printf( ( "/*==================== %s (%d/%d) ====================*/\n", configPRINTF( ( "/*==================== %s (%d/%d) ====================*/\n",
pcCommand, xCommandIndex + 1, ARRAY_SIZE( pcCommandList ) ) ); pcCommand, xCommandIndex + 1, ARRAY_SIZE( pcCommandList ) ) );
FreeRTOS_printf( ( "\n" ) ); configPRINTF( ( "\n" ) );
xHandleTestingCommand( pcCommand, sizeof( pcCommand ) ); xHandleTestingCommand( pcCommand, sizeof( pcCommand ) );
xCommandIndex++; xCommandIndex++;
} }
else if( xCommandIndex == ARRAY_SIZE( pcCommandList ) ) else
{ {
FreeRTOS_printf( ( "Server task now ready.\n" ) ); /* All the commands are handled - delete this task. */
vTaskDelete( NULL );
#if ( ipconfigUSE_NTP_DEMO != 0 )
/* if (xNTPTaskIsRunning() != pdFALSE) */
{
/* Ask once more for the current time. */
/* vStartNTPTask(0U, 0U); */
}
#endif
/*vTaskDelete( NULL ); */
xCommandIndex++;
}
{
char pcBuffer[ 1500 ];
struct freertos_sockaddr xSourceAddress;
socklen_t xLength = sizeof( socklen_t );
int32_t rc = FreeRTOS_recvfrom( xSocket, pcBuffer, sizeof( pcBuffer ), 0, &xSourceAddress, &xLength );
if( rc > 0 )
{
if( xSourceAddress.sin_family == FREERTOS_AF_INET6 )
{
FreeRTOS_printf( ( "Recv UDP %d bytes from %pip port %u\n", rc, xSourceAddress.sin_address.xIP_IPv6.ucBytes, FreeRTOS_ntohs( xSourceAddress.sin_port ) ) );
}
else
{
FreeRTOS_printf( ( "Recv UDP %d bytes from %xip port %u\n", rc, FreeRTOS_ntohl( xSourceAddress.sin_address.ulIP_IPv4 ), FreeRTOS_ntohs( xSourceAddress.sin_port ) ) );
}
if( rc == 14 )
{
static BaseType_t xDone = 0;
if( xDone == 3 )
{
BaseType_t xIPv6 = ( xSourceAddress.sin_family == FREERTOS_AF_INET6 ) ? pdTRUE : pdFALSE;
FreeRTOS_printf( ( "%d: Clear %s table\n", xDone, xIPv6 ? "ND" : "ARP" ) );
if( xIPv6 == pdTRUE )
{
FreeRTOS_ClearND();
}
else
{
FreeRTOS_ClearARP( NULL );
}
xDone = 0;
}
else
{
xDone++;
}
}
}
} }
} }
} }
@ -901,7 +838,7 @@ void vOutputChar( const char cChar,
/* uint16_t usIdentifier) */ /* uint16_t usIdentifier) */
/*{ */ /*{ */
/* ( void ) eStatus; */ /* ( void ) eStatus; */
/* FreeRTOS_printf( ( "vApplicationPingReplyHook called for %04x\n", usIdentifier ) ); */ /* configPRINTF( ( "vApplicationPingReplyHook called for %04x\n", usIdentifier ) ); */
/*} */ /*} */
#endif #endif
@ -919,6 +856,7 @@ void vOutputChar( const char cChar,
void handle_user_test( char * pcBuffer ) void handle_user_test( char * pcBuffer )
{ {
( void ) pcBuffer;
} }
void show_single_addressinfo( const char * pcFormat, void show_single_addressinfo( const char * pcFormat,
@ -944,11 +882,11 @@ void show_single_addressinfo( const char * pcFormat,
if( pcFormat != NULL ) if( pcFormat != NULL )
{ {
FreeRTOS_printf( ( pcFormat, cBuffer ) ); configPRINTF( ( pcFormat, cBuffer ) );
} }
else else
{ {
FreeRTOS_printf( ( "Address: %s\n", cBuffer ) ); configPRINTF( ( "Address: %s\n", cBuffer ) );
} }
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
@ -969,7 +907,7 @@ void show_addressinfo( const struct freertos_addrinfo * pxAddress )
ptr = ptr->ai_next; ptr = ptr->ai_next;
} }
/* In case the function 'FreeRTOS_printf()` is not implemented. */ /* In case the function 'configPRINTF()` is not implemented. */
( void ) xIndex; ( void ) xIndex;
} }
static BaseType_t xDNSResult = -2; static BaseType_t xDNSResult = -2;
@ -977,6 +915,9 @@ static void vDNSEvent( const char * pcName,
void * pvSearchID, void * pvSearchID,
struct freertos_addrinfo * pxAddrInfo ) struct freertos_addrinfo * pxAddrInfo )
{ {
( void ) pcName;
( void ) pvSearchID;
FreeRTOS_printf( ( "vDNSEvent: called with %p\n", pxAddrInfo ) ); FreeRTOS_printf( ( "vDNSEvent: called with %p\n", pxAddrInfo ) );
showAddressInfo( pxAddrInfo ); showAddressInfo( pxAddrInfo );
@ -990,7 +931,6 @@ static void dns_test( const char * pcHostName )
{ {
uint32_t ulID = uxRand32(); uint32_t ulID = uxRand32();
BaseType_t rc; BaseType_t rc;
TickType_t uxTimeout = pdMS_TO_TICKS( 2000U );
FreeRTOS_dnsclear(); FreeRTOS_dnsclear();

View file

@ -1003,7 +1003,7 @@ const char * mkSize( unsigned long long aSize,
#if defined( _NO_CRT_STDIO_INLINE ) #if defined( _NO_CRT_STDIO_INLINE )
int _vfscanf_l( _Inout_ FILE * const _Stream, int _vfscanf_l( _Inout_ FILE * const _Stream,
char const * const _Format, char const * const _Format,
const _Locale, const _locale_t _Locale,
va_list _ArgList ) va_list _ArgList )
{ {
return __stdio_common_vfscanf( return __stdio_common_vfscanf(

View file

@ -247,6 +247,7 @@ void vStartNTPTask( uint16_t usTaskStackSize,
xStatus = EStatusAsking; xStatus = EStatusAsking;
( void ) pvSearchID; ( void ) pvSearchID;
( void ) pcName;
if( pxAddress == NULL ) if( pxAddress == NULL )
{ {
@ -431,6 +432,7 @@ static void prvReadTime( struct SNtpPacket * pxPacket )
#if ( USE_PLUS_FAT != 0 ) #if ( USE_PLUS_FAT != 0 )
FreeRTOS_gmtime_r( &uxCurrentSeconds, &xTimeStruct ); FreeRTOS_gmtime_r( &uxCurrentSeconds, &xTimeStruct );
#else #else
extern struct tm * gmtime_r( const time_t * pxTime, struct tm * tmStruct );
gmtime_r( &uxCurrentSeconds, &xTimeStruct ); gmtime_r( &uxCurrentSeconds, &xTimeStruct );
#endif /* ( USE_PLUS_FAT != 0 ) */ #endif /* ( USE_PLUS_FAT != 0 ) */

View file

@ -30,7 +30,9 @@
#include <ws2tcpip.h> #include <ws2tcpip.h>
#ifndef __MINGW32__ #ifndef __MINGW32__
#define IN_MULTICAST( a ) IN_CLASSD( a ) #ifndef IN_MULTICAST
#define IN_MULTICAST( a ) IN_CLASSD( a )
#endif
#endif #endif
#define IN_EXPERIMENTAL( a ) ( ( ( ( u_int32_t ) ( a ) ) & 0xf0000000 ) == 0xf0000000 ) #define IN_EXPERIMENTAL( a ) ( ( ( ( u_int32_t ) ( a ) ) & 0xf0000000 ) == 0xf0000000 )