summaryrefslogtreecommitdiff
path: root/nuttx/net/accept.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-11-23 19:25:39 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-11-23 19:25:39 +0000
commit789f463db7fc2a1613374fb8ea45cdba6cc77136 (patch)
tree0c84443eb3f566978a47274ece15cd5ce03973a9 /nuttx/net/accept.c
parent403a4936c8fc3756003a28328c18c770bc914b6d (diff)
downloadpx4-nuttx-789f463db7fc2a1613374fb8ea45cdba6cc77136.tar.gz
px4-nuttx-789f463db7fc2a1613374fb8ea45cdba6cc77136.tar.bz2
px4-nuttx-789f463db7fc2a1613374fb8ea45cdba6cc77136.zip
Verified recvfrom()nuttx-3.2
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@402 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/net/accept.c')
-rw-r--r--nuttx/net/accept.c48
1 files changed, 47 insertions, 1 deletions
diff --git a/nuttx/net/accept.c b/nuttx/net/accept.c
index a348953f6..8c32eac3a 100644
--- a/nuttx/net/accept.c
+++ b/nuttx/net/accept.c
@@ -53,6 +53,10 @@
#include "net-internal.h"
/****************************************************************************
+ * Definitions
+ ****************************************************************************/
+
+/****************************************************************************
* Private Types
****************************************************************************/
@@ -77,6 +81,47 @@ struct accept_s
****************************************************************************/
/****************************************************************************
+ * Function: accept_tcpsender
+ *
+ * Description:
+ * Getting the sender's address from the UDP packet
+ *
+ * Parameters:
+ * conn - The newly accepted TCP connection
+ * pstate - the recvfrom state structure
+ *
+ * Returned Value:
+ * None
+ *
+ * Assumptions:
+ * Running at the interrupt level
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_NET_TCP
+static inline void accept_tcpsender(struct uip_conn *conn, struct accept_s *pstate)
+{
+ #ifdef CONFIG_NET_IPv6
+ FAR struct sockaddr_in6 *addr = pstate->acpt_addr;
+#else
+ FAR struct sockaddr_in *addr = pstate->acpt_addr;
+#endif
+
+ if (addr)
+ {
+ addr->sin_family = AF_INET;
+ addr->sin_port = conn->rport;
+
+#ifdef CONFIG_NET_IPv6
+ uip_ipaddr_copy(addr->sin_addr.s_addr, conn->ripaddr);
+#else
+ uip_ipaddr_copy(addr->sin_addr.s_addr, conn->ripaddr);
+#endif
+ }
+}
+#endif
+
+/****************************************************************************
* Function: accept_interrupt
*
* Description:
@@ -102,7 +147,8 @@ static int accept_interrupt(struct uip_conn *listener, struct uip_conn *conn)
if (pstate)
{
/* Get the connection address */
-#warning "need to return the address of the connection"
+
+ accept_tcpsender(conn, pstate);
/* Save the connection structure */