Merge remote-tracking branch 'origin/master' into ieee802154

This commit is contained in:
Gregory Nutt 2017-05-14 16:37:10 -06:00
commit b10d2bbc8c
7 changed files with 145 additions and 48 deletions

View File

@ -65,14 +65,11 @@ CONFIG_DEBUG_INFO=y
# CONFIG_DEBUG_GRAPHICS is not set # CONFIG_DEBUG_GRAPHICS is not set
# CONFIG_DEBUG_LIB is not set # CONFIG_DEBUG_LIB is not set
# CONFIG_DEBUG_MM is not set # CONFIG_DEBUG_MM is not set
CONFIG_DEBUG_NET=y # CONFIG_DEBUG_NET is not set
CONFIG_DEBUG_NET_ERROR=y
CONFIG_DEBUG_NET_WARN=y
CONFIG_DEBUG_NET_INFO=y
CONFIG_DEBUG_WIRELESS=y CONFIG_DEBUG_WIRELESS=y
CONFIG_DEBUG_WIRELESS_ERROR=y CONFIG_DEBUG_WIRELESS_ERROR=y
CONFIG_DEBUG_WIRELESS_WARN=y CONFIG_DEBUG_WIRELESS_WARN=y
CONFIG_DEBUG_WIRELESS_INFO=y # CONFIG_DEBUG_WIRELESS_INFO is not set
# CONFIG_DEBUG_SCHED is not set # CONFIG_DEBUG_SCHED is not set
# #
@ -169,7 +166,6 @@ CONFIG_ARCH_CORTEXM3=y
# CONFIG_ARCH_CORTEXR7F is not set # CONFIG_ARCH_CORTEXR7F is not set
CONFIG_ARCH_FAMILY="armv7-m" CONFIG_ARCH_FAMILY="armv7-m"
CONFIG_ARCH_CHIP="stm32" CONFIG_ARCH_CHIP="stm32"
# CONFIG_ARCH_TOOLCHAIN_IAR is not set
# CONFIG_ARMV7M_USEBASEPRI is not set # CONFIG_ARMV7M_USEBASEPRI is not set
CONFIG_ARCH_HAVE_CMNVECTOR=y CONFIG_ARCH_HAVE_CMNVECTOR=y
# CONFIG_ARMV7M_CMNVECTOR is not set # CONFIG_ARMV7M_CMNVECTOR is not set
@ -569,6 +565,7 @@ CONFIG_STM32_SDIO_DMAPRIO=0x00010000
# #
# USB Device Configuration # USB Device Configuration
# #
# CONFIG_ARCH_TOOLCHAIN_IAR is not set
CONFIG_ARCH_TOOLCHAIN_GNU=y CONFIG_ARCH_TOOLCHAIN_GNU=y
# #
@ -870,7 +867,9 @@ CONFIG_NETDEVICES=y
# General Ethernet MAC Driver Options # General Ethernet MAC Driver Options
# #
# CONFIG_NETDEV_LOOPBACK is not set # CONFIG_NETDEV_LOOPBACK is not set
# CONFIG_NETDEV_TELNET is not set CONFIG_NETDEV_TELNET=y
CONFIG_TELNET_RXBUFFER_SIZE=256
CONFIG_TELNET_TXBUFFER_SIZE=256
# CONFIG_NETDEV_MULTINIC is not set # CONFIG_NETDEV_MULTINIC is not set
# CONFIG_ARCH_HAVE_NETDEV_STATISTICS is not set # CONFIG_ARCH_HAVE_NETDEV_STATISTICS is not set
CONFIG_NETDEV_LATEINIT=y CONFIG_NETDEV_LATEINIT=y
@ -892,7 +891,7 @@ CONFIG_NETDEV_LATEINIT=y
CONFIG_SERIAL=y CONFIG_SERIAL=y
# CONFIG_DEV_LOWCONSOLE is not set # CONFIG_DEV_LOWCONSOLE is not set
# CONFIG_SERIAL_REMOVABLE is not set # CONFIG_SERIAL_REMOVABLE is not set
CONFIG_SERIAL_CONSOLE=y # CONFIG_SERIAL_CONSOLE is not set
# CONFIG_16550_UART is not set # CONFIG_16550_UART is not set
# CONFIG_UART_SERIALDRIVER is not set # CONFIG_UART_SERIALDRIVER is not set
# CONFIG_UART0_SERIALDRIVER is not set # CONFIG_UART0_SERIALDRIVER is not set
@ -923,9 +922,9 @@ CONFIG_STANDARD_SERIAL=y
# CONFIG_SERIAL_DMA is not set # CONFIG_SERIAL_DMA is not set
# CONFIG_SERIAL_TIOCSERGSTRUCT is not set # CONFIG_SERIAL_TIOCSERGSTRUCT is not set
CONFIG_ARCH_HAVE_SERIAL_TERMIOS=y CONFIG_ARCH_HAVE_SERIAL_TERMIOS=y
CONFIG_USART1_SERIAL_CONSOLE=y # CONFIG_USART1_SERIAL_CONSOLE is not set
# CONFIG_OTHER_SERIAL_CONSOLE is not set # CONFIG_OTHER_SERIAL_CONSOLE is not set
# CONFIG_NO_SERIAL_CONSOLE is not set CONFIG_NO_SERIAL_CONSOLE=y
# #
# USART1 Configuration # USART1 Configuration
@ -966,11 +965,14 @@ CONFIG_SYSLOG_WRITE=y
# CONFIG_SYSLOG_BUFFER is not set # CONFIG_SYSLOG_BUFFER is not set
# CONFIG_SYSLOG_INTBUFFER is not set # CONFIG_SYSLOG_INTBUFFER is not set
# CONFIG_SYSLOG_TIMESTAMP is not set # CONFIG_SYSLOG_TIMESTAMP is not set
CONFIG_SYSLOG_SERIAL_CONSOLE=y # CONFIG_SYSLOG_SERIAL_CONSOLE is not set
# CONFIG_SYSLOG_CHAR is not set CONFIG_SYSLOG_CHAR=y
CONFIG_SYSLOG_CONSOLE=y # CONFIG_SYSLOG_CONSOLE is not set
# CONFIG_SYSLOG_NONE is not set # CONFIG_SYSLOG_NONE is not set
# CONFIG_SYSLOG_FILE is not set # CONFIG_SYSLOG_FILE is not set
# CONFIG_CONSOLE_SYSLOG is not set
CONFIG_SYSLOG_CHAR_CRLF=y
CONFIG_SYSLOG_DEVPATH="/dev/ttyS0"
# CONFIG_SYSLOG_CHARDEV is not set # CONFIG_SYSLOG_CHARDEV is not set
# #
@ -1076,7 +1078,6 @@ CONFIG_NET_ARPTAB_SIZE=16
CONFIG_NET_ARP_MAXAGE=120 CONFIG_NET_ARP_MAXAGE=120
# CONFIG_NET_ARP_IPIN is not set # CONFIG_NET_ARP_IPIN is not set
# CONFIG_NET_ARP_SEND is not set # CONFIG_NET_ARP_SEND is not set
# CONFIG_NET_ARP_DUMP is not set
# #
# User-space networking stack API # User-space networking stack API
@ -1293,7 +1294,6 @@ CONFIG_LIB_SENDFILE_BUFSIZE=512
# #
# CONFIG_C99_BOOL8 is not set # CONFIG_C99_BOOL8 is not set
CONFIG_HAVE_CXX=y CONFIG_HAVE_CXX=y
CONFIG_HAVE_CXXINITIALIZE=y
# CONFIG_CXX_NEWLONG is not set # CONFIG_CXX_NEWLONG is not set
# #
@ -1430,7 +1430,7 @@ CONFIG_NETUTILS_PING=y
CONFIG_NETUTILS_PING_SIGNO=13 CONFIG_NETUTILS_PING_SIGNO=13
# CONFIG_NETUTILS_PPPD is not set # CONFIG_NETUTILS_PPPD is not set
# CONFIG_NETUTILS_SMTP is not set # CONFIG_NETUTILS_SMTP is not set
# CONFIG_NETUTILS_TELNETD is not set CONFIG_NETUTILS_TELNETD=y
# CONFIG_NETUTILS_TFTPC is not set # CONFIG_NETUTILS_TFTPC is not set
# CONFIG_NETUTILS_WEBCLIENT is not set # CONFIG_NETUTILS_WEBCLIENT is not set
# CONFIG_NETUTILS_WEBSERVER is not set # CONFIG_NETUTILS_WEBSERVER is not set
@ -1533,8 +1533,7 @@ CONFIG_NSH_FILEIOSIZE=512
# #
# Console Configuration # Console Configuration
# #
CONFIG_NSH_CONSOLE=y # CONFIG_NSH_CONSOLE is not set
# CONFIG_NSH_ALTCONDEV is not set
CONFIG_NSH_ARCHINIT=y CONFIG_NSH_ARCHINIT=y
# #
@ -1567,8 +1566,20 @@ CONFIG_NSH_WAPI_ALG=3
CONFIG_NSH_WAPI_SSID="myApSSID" CONFIG_NSH_WAPI_SSID="myApSSID"
CONFIG_NSH_WAPI_PASSPHRASE="mySSIDpassphrase" CONFIG_NSH_WAPI_PASSPHRASE="mySSIDpassphrase"
CONFIG_NSH_MAX_ROUNDTRIP=20 CONFIG_NSH_MAX_ROUNDTRIP=20
#
# Telnet Configuration
#
CONFIG_NSH_TELNET=y
CONFIG_NSH_TELNETD_PORT=23
CONFIG_NSH_TELNETD_DAEMONPRIO=100
CONFIG_NSH_TELNETD_DAEMONSTACKSIZE=2048
CONFIG_NSH_TELNETD_CLIENTPRIO=100
CONFIG_NSH_TELNETD_CLIENTSTACKSIZE=2048
CONFIG_NSH_IOBUFFER_SIZE=512
# CONFIG_NSH_LOGIN is not set # CONFIG_NSH_LOGIN is not set
# CONFIG_NSH_CONSOLE_LOGIN is not set # CONFIG_NSH_CONSOLE_LOGIN is not set
# CONFIG_NSH_TELNET_LOGIN is not set
# #
# NxWidgets/NxWM # NxWidgets/NxWM
@ -1578,6 +1589,7 @@ CONFIG_NSH_MAX_ROUNDTRIP=20
# Platform-specific Support # Platform-specific Support
# #
# CONFIG_PLATFORM_CONFIGDATA is not set # CONFIG_PLATFORM_CONFIGDATA is not set
CONFIG_HAVE_CXXINITIALIZE=y
# #
# System Libraries and NSH Add-Ons # System Libraries and NSH Add-Ons

View File

@ -370,7 +370,6 @@ void bcmf_wl_scan_event_handler(FAR struct bcmf_dev_s *priv,
struct bcmf_event_s *event, unsigned int len) struct bcmf_event_s *event, unsigned int len)
{ {
uint32_t status; uint32_t status;
uint32_t reason;
uint32_t event_len; uint32_t event_len;
struct wl_escan_result *result; struct wl_escan_result *result;
struct wl_bss_info *bss; struct wl_bss_info *bss;
@ -387,7 +386,6 @@ void bcmf_wl_scan_event_handler(FAR struct bcmf_dev_s *priv,
} }
status = bcmf_getle32(&event->status); status = bcmf_getle32(&event->status);
reason = bcmf_getle32(&event->reason);
escan_result_len = bcmf_getle32(&event->len); escan_result_len = bcmf_getle32(&event->len);
len -= sizeof(struct bcmf_event_s); len -= sizeof(struct bcmf_event_s);
@ -464,7 +462,7 @@ wl_escan_result_processed:
/* Scan done */ /* Scan done */
wlinfo("escan done event %d %d\n", status, reason); wlinfo("escan done event %d %d\n", status, bcmf_getle32(&event->reason));
wd_cancel(priv->scan_timeout); wd_cancel(priv->scan_timeout);

View File

@ -177,7 +177,7 @@ int bcmf_netdev_alloc_tx_frame(FAR struct bcmf_dev_s *priv)
priv->cur_tx_frame = bcmf_bdc_allocate_frame(priv, MAX_NET_DEV_MTU, true); priv->cur_tx_frame = bcmf_bdc_allocate_frame(priv, MAX_NET_DEV_MTU, true);
if (!priv->cur_tx_frame) if (!priv->cur_tx_frame)
{ {
wlerr("Cannot allocate TX frame\n"); wlerr("ERROR: Cannot allocate TX frame\n");
return -ENOMEM; return -ENOMEM;
} }
@ -215,7 +215,7 @@ static int bcmf_transmit(FAR struct bcmf_dev_s *priv,
if (ret) if (ret)
{ {
wlerr("Failed to transmit frame\n"); wlerr("ERROR: Failed to transmit frame\n");
return -EIO; return -EIO;
} }
@ -392,7 +392,7 @@ static void bcmf_receive(FAR struct bcmf_dev_s *priv)
else else
#endif #endif
{ {
wlinfo("RX dropped\n"); wlerr("ERROR: RX dropped\n");
NETDEV_RXDROPPED(&priv->bc_dev); NETDEV_RXDROPPED(&priv->bc_dev);
priv->bus->free_frame(priv, frame); priv->bus->free_frame(priv, frame);
} }
@ -992,11 +992,11 @@ static int bcmf_ioctl(FAR struct net_driver_s *dev, int cmd,
switch (cmd) switch (cmd)
{ {
case SIOCSIWSCAN: case SIOCSIWSCAN:
ret = bcmf_wl_start_scan(priv, (struct ifreq *)arg); ret = bcmf_wl_start_scan(priv, (struct iwreq *)arg);
break; break;
case SIOCGIWSCAN: case SIOCGIWSCAN:
ret = bcmf_wl_get_scan_results(priv, (struct ifreq *)arg); ret = bcmf_wl_get_scan_results(priv, (struct iwreq *)arg);
break; break;
case SIOCSIFHWADDR: /* Set device MAC address */ case SIOCSIFHWADDR: /* Set device MAC address */

View File

@ -697,6 +697,19 @@ void tcp_timer(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn,
void tcp_listen_initialize(void); void tcp_listen_initialize(void);
/****************************************************************************
* Name: tcp_findlistener
*
* Description:
* Return the connection listener for connections on this port (if any)
*
* Assumptions:
* Called at interrupt level
*
****************************************************************************/
FAR struct tcp_conn_s *tcp_findlistener(uint16_t portno);
/**************************************************************************** /****************************************************************************
* Name: tcp_unlisten * Name: tcp_unlisten
* *

View File

@ -179,28 +179,35 @@ static void tcp_input(FAR struct net_driver_s *dev, unsigned int iplen)
conn = tcp_alloc_accept(dev, tcp); conn = tcp_alloc_accept(dev, tcp);
if (conn) if (conn)
{ {
/* The connection structure was successfully allocated. Now see if /* The connection structure was successfully allocated and has
* there is an application waiting to accept the connection (or at * been initialized in the TCP_SYN_RECVD state. The expected
* least queue it it for acceptance). * sequence of events is then the rest of the 3-way handshake:
*
* 1. We just received a TCP SYN packet from a remote host.
* 2. We will send the SYN-ACK response below (perhaps
* repeatedly in the event of a timeout)
* 3. Then we expect to receive an ACK from the remote host
* indicated the TCP socket connection is ESTABLISHED.
*
* Possible failure:
*
* 1. The ACK is never received. This will be handled by
* a timeout managed by tcp_timer().
* 2. The listener "unlistens()". This will be handled by
* the failure of tcp_accept_connection() when the ACK is
* received.
*/ */
conn->crefs = 1; conn->crefs = 1;
if (tcp_accept_connection(dev, conn, tmp16) != OK)
{
/* No, then we have to give the connection back and drop the packet */
conn->crefs = 0;
tcp_free(conn);
conn = NULL;
}
} }
if (!conn) if (!conn)
{ {
/* Either (1) all available connections are in use, or (2) there is no /* Either (1) all available connections are in use, or (2)
* application in place to accept the connection. We drop packet and hope that * there is no application in place to accept the connection.
* the remote end will retransmit the packet at a time when we * We drop packet and hope that the remote end will retransmit
* have more spare connections or someone waiting to accept the connection. * the packet at a time when we have more spare connections
* or someone waiting to accept the connection.
*/ */
#ifdef CONFIG_NET_STATISTICS #ifdef CONFIG_NET_STATISTICS
@ -462,8 +469,35 @@ found:
if ((flags & TCP_ACKDATA) != 0) if ((flags & TCP_ACKDATA) != 0)
{ {
/* The three way handshake is complete and the TCP connection
* is now in the ESTABLISHED state.
*/
conn->tcpstateflags = TCP_ESTABLISHED; conn->tcpstateflags = TCP_ESTABLISHED;
/* Wake up any listener waiting for a connection on this port */
if (tcp_accept_connection(dev, conn, tcp->destport) != OK)
{
/* No more listener for current port. We can free conn here
* because it has not been shared with upper layers yet as
* handshake is not complete
*/
nerr("Listen canceled while waiting for ACK on port %d\n",
tcp->destport);
/* Free the connection structure */
conn->crefs = 0;
tcp_free(conn);
conn = NULL;
/* And send a reset packet to the remote host. */
goto reset;
}
#ifdef CONFIG_NET_TCP_WRITE_BUFFERS #ifdef CONFIG_NET_TCP_WRITE_BUFFERS
conn->isn = tcp_getsequence(tcp->ackno); conn->isn = tcp_getsequence(tcp->ackno);
tcp_setsequence(conn->sndseq, conn->isn); tcp_setsequence(conn->sndseq, conn->isn);

View File

@ -257,7 +257,7 @@ int tcp_accept_connection(FAR struct net_driver_s *dev,
*/ */
listener = tcp_findlistener(portno); listener = tcp_findlistener(portno);
if (listener) if (listener != NULL)
{ {
/* Yes, there is a listener. Is it accepting connections now? */ /* Yes, there is a listener. Is it accepting connections now? */

View File

@ -218,17 +218,57 @@ void tcp_timer(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn,
goto done; goto done;
} }
#endif #endif
/* Should we close the connection? */ /* Check for a timeout on connection in the TCP_SYN_RCVD state.
* On such timeouts, we would normally resend the SYNACK until
* the ACK is received, completing the 3-way handshake. But if
* the retry count elapsed, then we must assume that no ACK is
* forthcoming and terminate the attempted connection.
*/
if ( if (conn->tcpstateflags == TCP_SYN_RCVD &&
conn->nrtx >= TCP_MAXSYNRTX)
{
FAR struct tcp_conn_s *listener;
conn->tcpstateflags = TCP_CLOSED;
ninfo("TCP state: TCP_CLOSED\n");
/* Find the listener for this connection. */
listener = tcp_findlistener(conn->lport);
if (listener != NULL)
{
/* We call tcp_callback() for the connection with
* TCP_TIMEDOUT to inform the listener that the
* connection has timed out.
*/
result = tcp_callback(dev, listener, TCP_TIMEDOUT);
}
/* We also send a reset packet to the remote host. */
tcp_send(dev, conn, TCP_RST | TCP_ACK, hdrlen);
/* Finally, we must free this TCP connection structure */
tcp_free(conn);
goto done;
}
/* Otherwise, check for a timeout on an established connection.
* If the retry count is exceeded in this case, we should
* close the connection.
*/
else if (
#ifdef CONFIG_NET_TCP_WRITE_BUFFERS #ifdef CONFIG_NET_TCP_WRITE_BUFFERS
conn->expired > 0 || conn->expired > 0 ||
#else #else
conn->nrtx == TCP_MAXRTX || conn->nrtx >= TCP_MAXRTX ||
#endif #endif
((conn->tcpstateflags == TCP_SYN_SENT || (conn->tcpstateflags == TCP_SYN_SENT &&
conn->tcpstateflags == TCP_SYN_RCVD) && conn->nrtx >= TCP_MAXSYNRTX)
conn->nrtx == TCP_MAXSYNRTX)
) )
{ {
conn->tcpstateflags = TCP_CLOSED; conn->tcpstateflags = TCP_CLOSED;