heinbali01 wrote on Monday, May 21, 2018:
If I had the time, I should compile the library with all combinations of flags. In my case, I both have ipconfigUSE_DNS
and ipconfigUSE_NBNS
enabled, so I didn’t notice the problem.
In FreeRTOS_UDP_IP.c
, you should make this little change around line 67:
#include "FreeRTOS_Routing.h"
-#if( ipconfigUSE_DNS == 1 )
+#if( ipconfigUSE_DNS == 1 ) || ( ipconfigUSE_NBNS == 1 )
#include "FreeRTOS_DNS.h"
#endif
/* The expected IP version and header length coded into the IP header itself. */
I attached the FreeRTOSIPConfig.h
that I used for a Xilinx/Zynq project.
Note that ipconfigUSE_NETWORK_EVENT_HOOK
, the application Network Event hook, is very useful. When it is called for the first time with eNetworkEvent == eNetworkUp
, you can start the necessary TCP- and UDP-servers.
Note that in FreeRTOS+TCP/multi, the application hook will be called for every defined end-point.
#if( ipconfigMULTI_INTERFACE != 0 )
void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent, NetworkEndPoint_t *pxEndPoint )
#else
void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent )
#endif
{
}
Something about address binding: within FreeRTOS+TCP /multi, a port number can only be bound once. When binding a socket, the IP-address provided is ignored. So if you bind a socket to e.g. port number 5001, that server socket will receive connection requests from all interfaces. The function FreeRTOS_accept()
will tell you which client is connecting to your server.
An equivalent in Berkeley sockets is to bind a socket to the IP-address 0.0.0.0
.
xBindAddress.sin_len = sizeof( xBindAddress );
xBindAddress.sin_family = FREERTOS_AF_INET;
xBindAddress.sin_addr = 0ul;
xBindAddress.sin_port = FreeRTOS_htons( 5001 ); /* Bind to server port number. */
Regards,