summaryrefslogtreecommitdiff
path: root/nuttx/net/socket/sendto.c
diff options
context:
space:
mode:
Diffstat (limited to 'nuttx/net/socket/sendto.c')
-rw-r--r--nuttx/net/socket/sendto.c63
1 files changed, 57 insertions, 6 deletions
diff --git a/nuttx/net/socket/sendto.c b/nuttx/net/socket/sendto.c
index c8e40c2ef..bced1ea82 100644
--- a/nuttx/net/socket/sendto.c
+++ b/nuttx/net/socket/sendto.c
@@ -295,7 +295,62 @@ static uint16_t sendto_interrupt(FAR struct net_driver_s *dev, FAR void *conn,
#endif
/****************************************************************************
- * Global Functions
+ * Function: sendto_txnotify
+ *
+ * Description:
+ * Notify the appropriate device driver that we are have data ready to
+ * be send (UDP)
+ *
+ * Parameters:
+ * psock - Socket state structure
+ * conn - The UDP connection structure
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+static inline void sendto_txnotify(FAR struct socket *psock,
+ FAR struct udp_conn_s *conn)
+{
+#ifdef CONFIG_NET_IPv4
+#ifdef CONFIG_NET_IPv6
+ /* If both IPv4 and IPv6 support are enabled, then we will need to select
+ * the device driver using the appropriate IP domain.
+ */
+
+ if (psock->domain == PF_INET)
+#endif
+ {
+ /* Notify the device driver that send data is available */
+
+#ifdef CONFIG_NET_MULTILINK
+ netdev_ipv4_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
+#else
+ netdev_ipv4_txnotify(conn->u.ipv4.raddr);
+#endif
+ }
+#endif /* CONFIG_NET_IPv4 */
+
+#ifdef CONFIG_NET_IPv6
+#ifdef CONFIG_NET_IPv4
+ else /* if (psock->domain == PF_INET6) */
+#endif /* CONFIG_NET_IPv4 */
+ {
+ /* Notify the device driver that send data is available */
+
+ DEBUGASSERT(psock->domain == PF_INET6);
+#ifdef CONFIG_NET_MULTILINK
+ netdev_ipv6_txnotify(conn->u.ipv6.laddr, conn->u.ipv6.raddr);
+#else
+ netdev_ipv6_txnotify(conn->u.ipv6.raddr);
+#endif
+ }
+#endif /* CONFIG_NET_IPv6 */
+}
+
+/****************************************************************************
+ * Public Functions
****************************************************************************/
/****************************************************************************
@@ -492,11 +547,7 @@ ssize_t psock_sendto(FAR struct socket *psock, FAR const void *buf,
/* Notify the device driver of the availability of TX data */
-#ifdef CONFIG_NET_MULTILINK
- netdev_ipv4_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
-#else
- netdev_ipv4_txnotify(conn->u.ipv4.raddr);
-#endif
+ sendto_txnotify(psock, conn);
/* Wait for either the receive to complete or for an error/timeout to occur.
* NOTES: (1) net_lockedwait will also terminate if a signal is received, (2)