summaryrefslogtreecommitdiff
path: root/nuttx/net/uip/uip_listen.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2009-09-16 20:28:30 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2009-09-16 20:28:30 +0000
commit9baa429e57191d588bf3534228c896dfe9e9e155 (patch)
tree2dfb466fc11d12508bd7934f96e8772b37570e32 /nuttx/net/uip/uip_listen.c
parentaf1a02c3618bf83b692d799a7ce1f21eabf5b72d (diff)
downloadpx4-nuttx-9baa429e57191d588bf3534228c896dfe9e9e155.tar.gz
px4-nuttx-9baa429e57191d588bf3534228c896dfe9e9e155.tar.bz2
px4-nuttx-9baa429e57191d588bf3534228c896dfe9e9e155.zip
Consulting wrong list to see if socket is listening for a connection
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2069 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/net/uip/uip_listen.c')
-rw-r--r--nuttx/net/uip/uip_listen.c62
1 files changed, 39 insertions, 23 deletions
diff --git a/nuttx/net/uip/uip_listen.c b/nuttx/net/uip/uip_listen.c
index f4dfdf6ff..95e43fea9 100644
--- a/nuttx/net/uip/uip_listen.c
+++ b/nuttx/net/uip/uip_listen.c
@@ -64,6 +64,43 @@ static struct uip_conn *uip_listenports[CONFIG_NET_MAX_LISTENPORTS];
****************************************************************************/
/****************************************************************************
+ * Function: uip_findlistener
+ *
+ * Description:
+ * Return the connection listener for connections on this port (if any)
+ *
+ * Assumptions:
+ * Called at interrupt level
+ *
+ ****************************************************************************/
+
+struct uip_conn *uip_findlistener(uint16 portno)
+{
+ int ndx;
+
+ /* Examine each connection structure in each slot of the listener list */
+
+ for (ndx = 0; ndx < CONFIG_NET_MAX_LISTENPORTS; ndx++)
+ {
+ /* Is this slot assigned? If so, does the connection have the same
+ * local port number?
+ */
+
+ struct uip_conn *conn = uip_listenports[ndx];
+ if (conn && conn->lport == portno)
+ {
+ /* Yes.. we found a listener on this port */
+
+ return conn;
+ }
+ }
+
+ /* No listener for this port */
+
+ return NULL;
+}
+
+/****************************************************************************
* Public Functions
****************************************************************************/
@@ -193,28 +230,7 @@ int uip_listen(struct uip_conn *conn)
boolean uip_islistener(uint16 portno)
{
- int ndx;
-
- /* Examine each connection structure in each slot of the listener list */
-
- for (ndx = 0; ndx < CONFIG_NET_MAX_LISTENPORTS; ndx++)
- {
- /* Is this slot assigned? If so, does the connection have the same
- * local port number?
- */
-
- struct uip_conn *conn = uip_listenports[ndx];
- if (conn && conn->lport == portno)
- {
- /* Yes.. we found a listener on this port */
-
- return TRUE;
- }
- }
-
- /* No listener for this port */
-
- return FALSE;
+ return uip_findlistener(portno) != NULL;
}
/****************************************************************************
@@ -238,7 +254,7 @@ int uip_accept(struct uip_driver_s *dev, struct uip_conn *conn, uint16 portno)
* connection.
*/
- listener = uip_tcplistener(portno);
+ listener = uip_findlistener(portno);
if (listener)
{
/* Yes, there is a listener. Is it accepting connections now? */