summaryrefslogtreecommitdiff
path: root/nuttx
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2015-01-17 18:18:19 -0600
committerGregory Nutt <gnutt@nuttx.org>2015-01-17 18:18:19 -0600
commit189b5eddca2641e86e7e9d9ab6ce3876cc68c7c9 (patch)
tree2fc4b4f2b9de505c03f95bac8af20d845b7db972 /nuttx
parentebd33f557b8dd7a7b28cf89e0fcc25a27a3307b3 (diff)
downloadpx4-nuttx-189b5eddca2641e86e7e9d9ab6ce3876cc68c7c9.tar.gz
px4-nuttx-189b5eddca2641e86e7e9d9ab6ce3876cc68c7c9.tar.bz2
px4-nuttx-189b5eddca2641e86e7e9d9ab6ce3876cc68c7c9.zip
Networking: Add IPv6 suppport to TCP application level sending logic
Diffstat (limited to 'nuttx')
-rw-r--r--nuttx/net/tcp/tcp_appsend.c62
1 files changed, 57 insertions, 5 deletions
diff --git a/nuttx/net/tcp/tcp_appsend.c b/nuttx/net/tcp/tcp_appsend.c
index ad4d43afb..a8f93fdd6 100644
--- a/nuttx/net/tcp/tcp_appsend.c
+++ b/nuttx/net/tcp/tcp_appsend.c
@@ -99,11 +99,37 @@
void tcp_appsend(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn,
uint16_t result)
{
+ uint8_t hdrlen;
+
/* Handle the result based on the application response */
nllvdbg("result: %04x d_sndlen: %d conn->unacked: %d\n",
result, dev->d_sndlen, conn->unacked);
+ /* Get the IP header length associated with the IP domain configured for
+ * this TCP connection.
+ */
+
+#ifdef CONFIG_NET_IPv4
+#ifdef CONFIG_NET_IPv6
+ if (conn->domain == PF_INET)
+#endif
+ {
+ DEBUGASSERT(IFF_IS_IPv4(dev->d_flags));
+ hdrlen = IPv4TCP_HDRLEN;
+ }
+#endif /* CONFIG_NET_IPv4 */
+
+#ifdef CONFIG_NET_IPv6
+#ifdef CONFIG_NET_IPv4
+ else
+#endif
+ {
+ DEBUGASSERT(IFF_IS_IPv6(dev->d_flags));
+ hdrlen = IPv6TCP_HDRLEN;
+ }
+#endif /* CONFIG_NET_IPv6 */
+
/* Check for connection aborted */
if ((result & TCP_ABORT) != 0)
@@ -112,7 +138,7 @@ void tcp_appsend(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn,
conn->tcpstateflags = TCP_CLOSED;
nllvdbg("TCP state: TCP_CLOSED\n");
- tcp_send(dev, conn, TCP_RST | TCP_ACK, IPv4TCP_HDRLEN);
+ tcp_send(dev, conn, TCP_RST | TCP_ACK, hdrlen);
}
/* Check for connection closed */
@@ -125,7 +151,7 @@ void tcp_appsend(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn,
nllvdbg("TCP state: TCP_FIN_WAIT_1\n");
dev->d_sndlen = 0;
- tcp_send(dev, conn, TCP_FIN | TCP_ACK, IPv4TCP_HDRLEN);
+ tcp_send(dev, conn, TCP_FIN | TCP_ACK, hdrlen);
}
/* None of the above */
@@ -185,10 +211,36 @@ void tcp_appsend(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn,
void tcp_rexmit(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn,
uint16_t result)
{
+ uint8_t hdrlen;
+
nllvdbg("result: %04x d_sndlen: %d conn->unacked: %d\n",
result, dev->d_sndlen, conn->unacked);
- /* If the application has data to be sent, or if the incoming packet had
+ /* Get the IP header length associated with the IP domain configured for
+ * this TCP connection.
+ */
+
+#ifdef CONFIG_NET_IPv4
+#ifdef CONFIG_NET_IPv6
+ if (conn->domain == PF_INET)
+#endif
+ {
+ DEBUGASSERT(IFF_IS_IPv4(dev->d_flags));
+ hdrlen = IPv4TCP_HDRLEN;
+ }
+#endif /* CONFIG_NET_IPv4 */
+
+#ifdef CONFIG_NET_IPv6
+#ifdef CONFIG_NET_IPv4
+ else
+#endif
+ {
+ DEBUGASSERT(IFF_IS_IPv6(dev->d_flags));
+ hdrlen = IPv6TCP_HDRLEN;
+ }
+#endif /* CONFIG_NET_IPv6 */
+
+ /* If the application has data to be sent, or if the incoming packet had
* new data in it, we must send out a packet.
*/
@@ -202,14 +254,14 @@ void tcp_rexmit(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn,
* the IP and TCP headers.
*/
- tcp_send(dev, conn, TCP_ACK | TCP_PSH, dev->d_sndlen + IPv4TCP_HDRLEN);
+ tcp_send(dev, conn, TCP_ACK | TCP_PSH, dev->d_sndlen + hdrlen);
}
/* If there is no data to send, just send out a pure ACK if one is requested`. */
else if ((result & TCP_SNDACK) != 0)
{
- tcp_send(dev, conn, TCP_ACK, IPv4TCP_HDRLEN);
+ tcp_send(dev, conn, TCP_ACK, hdrlen);
}
/* There is nothing to do -- drop the packet */