mirror of
https://github.com/apache/nuttx.git
synced 2026-05-28 03:45:50 +08:00
Networking: Move net/inet/net_monitor.c to net/tcp/tcp_monitor.c in preparation for design change to fix monitoring of duplicated sockets.
This commit is contained in:
@@ -28,7 +28,7 @@ Status
|
|||||||
But I was initially able to load FLASH and debug using a Segger J-Link
|
But I was initially able to load FLASH and debug using a Segger J-Link
|
||||||
connected to the board as described below. But I think that some of
|
connected to the board as described below. But I think that some of
|
||||||
my initial code loads put the TMS570 in bad state (or worse). Now
|
my initial code loads put the TMS570 in bad state (or worse). Now
|
||||||
the NERROR LED is on. When I attempt to problem the FLASH, the J-Link
|
the NERROR LED is on. When I attempt to program the FLASH, the J-Link
|
||||||
software complains that the CPU is running too slowly and then times
|
software complains that the CPU is running too slowly and then times
|
||||||
out trying to erase the FLASH.
|
out trying to erase the FLASH.
|
||||||
|
|
||||||
|
|||||||
@@ -152,7 +152,9 @@ int work_queue(int qid, FAR struct work_s *work, worker_t worker,
|
|||||||
{
|
{
|
||||||
/* Cancel any pending work in the work stucture */
|
/* Cancel any pending work in the work stucture */
|
||||||
|
|
||||||
work_cancel(qid, work);
|
(void)work_cancel(qid, work);
|
||||||
|
|
||||||
|
/* Then queue the new work */
|
||||||
|
|
||||||
return work_qqueue(&g_usrwork, work, worker, arg, delay);
|
return work_qqueue(&g_usrwork, work, worker, arg, delay);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,10 +59,6 @@ endif
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifneq ($(CONFIG_NET_TCP_NO_STACK),y)
|
|
||||||
SOCK_CSRCS += inet_monitor.c
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Include inet build support
|
# Include inet build support
|
||||||
|
|
||||||
DEPPATH += --dep-path inet
|
DEPPATH += --dep-path inet
|
||||||
|
|||||||
@@ -128,75 +128,6 @@ struct socket; /* Forward reference */
|
|||||||
|
|
||||||
void inet_setipid(uint16_t id);
|
void inet_setipid(uint16_t id);
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: net_startmonitor
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Set up to receive TCP connection state changes for a given socket
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* psock - The socket of interest
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* On success, net_startmonitor returns OK; On any failure,
|
|
||||||
* net_startmonitor will return a negated errno value. The only failure
|
|
||||||
* that can occur is if the socket has already been closed and, in this
|
|
||||||
* case, -ENOTCONN is returned.
|
|
||||||
*
|
|
||||||
* Assumptions:
|
|
||||||
* The caller holds the network lock (if not, it will be locked momentarily
|
|
||||||
* by this function).
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#if defined(CONFIG_NET_TCP) && !defined(CONFIG_NET_TCP_NO_STACK)
|
|
||||||
int net_startmonitor(FAR struct socket *psock);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: net_stopmonitor
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Stop monitoring TCP connection changes for a given socket
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* conn - The TCP connection of interest
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* None
|
|
||||||
*
|
|
||||||
* Assumptions:
|
|
||||||
* The caller holds the network lock (if not, it will be locked momentarily
|
|
||||||
* by this function).
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#if defined(CONFIG_NET_TCP) && !defined(CONFIG_NET_TCP_NO_STACK)
|
|
||||||
void net_stopmonitor(FAR struct tcp_conn_s *conn);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: net_lostconnection
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Called when a loss-of-connection event has occurred.
|
|
||||||
*
|
|
||||||
* Parameters:
|
|
||||||
* psock The TCP socket structure associated.
|
|
||||||
* flags Set of connection events events
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* None
|
|
||||||
*
|
|
||||||
* Assumptions:
|
|
||||||
* The caller holds the network lock.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#if defined(CONFIG_NET_TCP) && !defined(CONFIG_NET_TCP_NO_STACK)
|
|
||||||
void net_lostconnection(FAR struct socket *psock, uint16_t flags);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: ipv4_getsockname and ipv6_sockname
|
* Name: ipv4_getsockname and ipv6_sockname
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -508,7 +508,7 @@ int inet_close(FAR struct socket *psock)
|
|||||||
|
|
||||||
/* Stop the network monitor */
|
/* Stop the network monitor */
|
||||||
|
|
||||||
net_stopmonitor(conn);
|
tcp_stop_monitor(conn);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ static void psock_teardown_callbacks(FAR struct tcp_connect_s *pstate,
|
|||||||
{
|
{
|
||||||
/* Failed to connect. Stop the connection event monitor */
|
/* Failed to connect. Stop the connection event monitor */
|
||||||
|
|
||||||
net_stopmonitor(conn);
|
tcp_stop_monitor(conn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* NET_TCP_HAVE_STACK */
|
#endif /* NET_TCP_HAVE_STACK */
|
||||||
@@ -413,16 +413,16 @@ static inline int psock_tcp_connect(FAR struct socket *psock,
|
|||||||
* the state of the connection up the connection event monitor.
|
* the state of the connection up the connection event monitor.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ret = net_startmonitor(psock);
|
ret = tcp_start_monitor(psock);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
/* net_startmonitor() can only fail on certain race
|
/* tcp_start_monitor() can only fail on certain race
|
||||||
* conditions where the connection was lost just before
|
* conditions where the connection was lost just before
|
||||||
* this function was called. That is not expected to
|
* this function was called. That is not expected to
|
||||||
* happen in this context, but just in case...
|
* happen in this context, but just in case...
|
||||||
*/
|
*/
|
||||||
|
|
||||||
net_lostconnection(psock, TCP_ABORT);
|
tcp_lost_connection(psock, TCP_ABORT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -745,7 +745,7 @@ static uint16_t inet_tcp_interrupt(FAR struct net_driver_s *dev,
|
|||||||
|
|
||||||
/* Handle loss-of-connection event */
|
/* Handle loss-of-connection event */
|
||||||
|
|
||||||
net_lostconnection(pstate->ir_sock, flags);
|
tcp_lost_connection(pstate->ir_sock, flags);
|
||||||
|
|
||||||
/* Check if the peer gracefully closed the connection. */
|
/* Check if the peer gracefully closed the connection. */
|
||||||
|
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ static uint16_t ack_interrupt(FAR struct net_driver_s *dev, FAR void *pvconn,
|
|||||||
|
|
||||||
nwarn("WARNING: Lost connection\n");
|
nwarn("WARNING: Lost connection\n");
|
||||||
|
|
||||||
net_lostconnection(pstate->snd_sock, flags);
|
tcp_lost_connection(pstate->snd_sock, flags);
|
||||||
pstate->snd_sent = -ENOTCONN;
|
pstate->snd_sent = -ENOTCONN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -349,7 +349,7 @@ static uint16_t sendfile_interrupt(FAR struct net_driver_s *dev, FAR void *pvcon
|
|||||||
|
|
||||||
nwarn("WARNING: Lost connection\n");
|
nwarn("WARNING: Lost connection\n");
|
||||||
|
|
||||||
net_lostconnection(pstate->snd_sock, flags);
|
tcp_lost_connection(pstate->snd_sock, flags);
|
||||||
pstate->snd_sent = -ENOTCONN;
|
pstate->snd_sent = -ENOTCONN;
|
||||||
goto end_wait;
|
goto end_wait;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -712,10 +712,10 @@ static int inet_accept(FAR struct socket *psock, FAR struct sockaddr *addr,
|
|||||||
* socket
|
* socket
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ret = net_startmonitor(newsock);
|
ret = tcp_start_monitor(newsock);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
/* net_startmonitor() can only fail on certain race conditions where
|
/* tcp_start_monitor() can only fail on certain race conditions where
|
||||||
* the connection was lost just before this function was called. Undo
|
* the connection was lost just before this function was called. Undo
|
||||||
* everything we have done and return a failure.
|
* everything we have done and return a failure.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -443,7 +443,7 @@ static uint16_t tcp_send_interrupt(FAR struct net_driver_s *dev,
|
|||||||
|
|
||||||
ninfo("Lost connection\n");
|
ninfo("Lost connection\n");
|
||||||
|
|
||||||
net_lostconnection(sinfo->s_sock, flags);
|
tcp_lost_connection(sinfo->s_sock, flags);
|
||||||
sinfo->s_result = -ENOTCONN;
|
sinfo->s_result = -ENOTCONN;
|
||||||
goto end_wait;
|
goto end_wait;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -58,7 +58,7 @@ endif
|
|||||||
|
|
||||||
NET_CSRCS += tcp_conn.c tcp_seqno.c tcp_devpoll.c tcp_finddev.c tcp_timer.c
|
NET_CSRCS += tcp_conn.c tcp_seqno.c tcp_devpoll.c tcp_finddev.c tcp_timer.c
|
||||||
NET_CSRCS += tcp_send.c tcp_input.c tcp_appsend.c tcp_listen.c
|
NET_CSRCS += tcp_send.c tcp_input.c tcp_appsend.c tcp_listen.c
|
||||||
NET_CSRCS += tcp_callback.c tcp_backlog.c tcp_ipselect.c
|
NET_CSRCS += tcp_monitor.c tcp_callback.c tcp_backlog.c tcp_ipselect.c
|
||||||
|
|
||||||
# TCP write buffering
|
# TCP write buffering
|
||||||
|
|
||||||
|
|||||||
@@ -528,6 +528,69 @@ int tcp_bind(FAR struct tcp_conn_s *conn, FAR const struct sockaddr *addr);
|
|||||||
|
|
||||||
int tcp_connect(FAR struct tcp_conn_s *conn, FAR const struct sockaddr *addr);
|
int tcp_connect(FAR struct tcp_conn_s *conn, FAR const struct sockaddr *addr);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: tcp_start_monitor
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Set up to receive TCP connection state changes for a given socket
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* psock - The socket of interest
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* On success, tcp_start_monitor returns OK; On any failure,
|
||||||
|
* tcp_start_monitor will return a negated errno value. The only failure
|
||||||
|
* that can occur is if the socket has already been closed and, in this
|
||||||
|
* case, -ENOTCONN is returned.
|
||||||
|
*
|
||||||
|
* Assumptions:
|
||||||
|
* The caller holds the network lock (if not, it will be locked momentarily
|
||||||
|
* by this function).
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int tcp_start_monitor(FAR struct socket *psock);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: tcp_stop_monitor
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Stop monitoring TCP connection changes for a given socket
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* conn - The TCP connection of interest
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Assumptions:
|
||||||
|
* The caller holds the network lock (if not, it will be locked momentarily
|
||||||
|
* by this function).
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void tcp_stop_monitor(FAR struct tcp_conn_s *conn);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: tcp_lost_connection
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Called when a loss-of-connection event has occurred.
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* psock The TCP socket structure associated.
|
||||||
|
* flags Set of connection events events
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Assumptions:
|
||||||
|
* The caller holds the network lock.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void tcp_lost_connection(FAR struct socket *psock, uint16_t flags);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: tcp_ipv4_select
|
* Name: tcp_ipv4_select
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* net/inet/net_monitor.c
|
* net/tcp/tcp_monitor.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007-2013 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2007-2013, 2017 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -47,9 +47,8 @@
|
|||||||
#include <nuttx/net/tcp.h>
|
#include <nuttx/net/tcp.h>
|
||||||
|
|
||||||
#include "devif/devif.h"
|
#include "devif/devif.h"
|
||||||
#include "tcp/tcp.h"
|
|
||||||
#include "socket/socket.h"
|
#include "socket/socket.h"
|
||||||
#include "inet/inet.h"
|
#include "tcp/tcp.h"
|
||||||
|
|
||||||
#ifdef NET_TCP_HAVE_STACK
|
#ifdef NET_TCP_HAVE_STACK
|
||||||
|
|
||||||
@@ -193,7 +192,7 @@ static uint16_t connection_event(FAR struct net_driver_s *dev,
|
|||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: net_startmonitor
|
* Name: tcp_start_monitor
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Set up to receive TCP connection state changes for a given socket
|
* Set up to receive TCP connection state changes for a given socket
|
||||||
@@ -202,8 +201,8 @@ static uint16_t connection_event(FAR struct net_driver_s *dev,
|
|||||||
* psock - The socket of interest
|
* psock - The socket of interest
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* On success, net_startmonitor returns OK; On any failure,
|
* On success, tcp_start_monitor returns OK; On any failure,
|
||||||
* net_startmonitor will return a negated errno value. The only failure
|
* tcp_start_monitor will return a negated errno value. The only failure
|
||||||
* that can occur is if the socket has already been closed and, in this
|
* that can occur is if the socket has already been closed and, in this
|
||||||
* case, -ENOTCONN is returned.
|
* case, -ENOTCONN is returned.
|
||||||
*
|
*
|
||||||
@@ -213,7 +212,7 @@ static uint16_t connection_event(FAR struct net_driver_s *dev,
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int net_startmonitor(FAR struct socket *psock)
|
int tcp_start_monitor(FAR struct socket *psock)
|
||||||
{
|
{
|
||||||
FAR struct tcp_conn_s *conn;
|
FAR struct tcp_conn_s *conn;
|
||||||
FAR struct devif_callback_s *cb;
|
FAR struct devif_callback_s *cb;
|
||||||
@@ -275,7 +274,7 @@ int net_startmonitor(FAR struct socket *psock)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: net_stopmonitor
|
* Name: tcp_stop_monitor
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Stop monitoring TCP connection changes for a given socket
|
* Stop monitoring TCP connection changes for a given socket
|
||||||
@@ -292,7 +291,7 @@ int net_startmonitor(FAR struct socket *psock)
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void net_stopmonitor(FAR struct tcp_conn_s *conn)
|
void tcp_stop_monitor(FAR struct tcp_conn_s *conn)
|
||||||
{
|
{
|
||||||
DEBUGASSERT(conn);
|
DEBUGASSERT(conn);
|
||||||
|
|
||||||
@@ -313,7 +312,7 @@ void net_stopmonitor(FAR struct tcp_conn_s *conn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: net_lostconnection
|
* Name: tcp_lost_connection
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Called when a loss-of-connection event has occurred.
|
* Called when a loss-of-connection event has occurred.
|
||||||
@@ -331,7 +330,7 @@ void net_stopmonitor(FAR struct tcp_conn_s *conn)
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void net_lostconnection(FAR struct socket *psock, uint16_t flags)
|
void tcp_lost_connection(FAR struct socket *psock, uint16_t flags)
|
||||||
{
|
{
|
||||||
DEBUGASSERT(psock != NULL && psock->s_conn != NULL);
|
DEBUGASSERT(psock != NULL && psock->s_conn != NULL);
|
||||||
|
|
||||||
@@ -342,7 +341,7 @@ void net_lostconnection(FAR struct socket *psock, uint16_t flags)
|
|||||||
|
|
||||||
/* Stop the network monitor */
|
/* Stop the network monitor */
|
||||||
|
|
||||||
net_stopmonitor((FAR struct tcp_conn_s *)psock->s_conn);
|
tcp_stop_monitor((FAR struct tcp_conn_s *)psock->s_conn);
|
||||||
net_unlock();
|
net_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,7 +124,7 @@ static uint16_t tcp_poll_interrupt(FAR struct net_driver_s *dev, FAR void *conn,
|
|||||||
{
|
{
|
||||||
/* Mark that the connection has been lost */
|
/* Mark that the connection has been lost */
|
||||||
|
|
||||||
net_lostconnection(info->psock, flags);
|
tcp_lost_connection(info->psock, flags);
|
||||||
eventset |= (POLLERR | POLLHUP);
|
eventset |= (POLLERR | POLLHUP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -515,7 +515,7 @@ static uint16_t psock_send_interrupt(FAR struct net_driver_s *dev,
|
|||||||
{
|
{
|
||||||
/* Report not connected */
|
/* Report not connected */
|
||||||
|
|
||||||
net_lostconnection(psock, flags);
|
tcp_lost_connection(psock, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free write buffers and terminate polling */
|
/* Free write buffers and terminate polling */
|
||||||
|
|||||||
@@ -400,7 +400,7 @@ static uint16_t tcpsend_interrupt(FAR struct net_driver_s *dev,
|
|||||||
|
|
||||||
ninfo("Lost connection\n");
|
ninfo("Lost connection\n");
|
||||||
|
|
||||||
net_lostconnection(pstate->snd_sock, flags);
|
tcp_lost_connection(pstate->snd_sock, flags);
|
||||||
pstate->snd_sent = -ENOTCONN;
|
pstate->snd_sent = -ENOTCONN;
|
||||||
goto end_wait;
|
goto end_wait;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ int work_queue(int qid, FAR struct work_s *work, worker_t worker,
|
|||||||
{
|
{
|
||||||
/* Cancel any pending work in the work stucture */
|
/* Cancel any pending work in the work stucture */
|
||||||
|
|
||||||
work_cancel(qid, work);
|
(void)work_cancel(qid, work);
|
||||||
|
|
||||||
/* Then queue the new work */
|
/* Then queue the new work */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user