static inline void sendto_ipselect(FAR struct net_driver_s *dev, FAR struct sendto_s *pstate) { FAR struct socket *psock = pstate->st_sock; DEBUGASSERT(psock); /* Which domain the the socket support */ if (psock->s_domain == PF_INET) { /* Select the IPv4 domain */ udp_ipv4_select(dev); } else /* if (psock->s_domain == PF_INET6) */ { /* Select the IPv6 domain */ DEBUGASSERT(psock->s_domain == PF_INET6); udp_ipv4_select(dev); } }
void udp_poll(FAR struct net_driver_s *dev, FAR struct udp_conn_s *conn) { /* Verify that the UDP connection is valid */ if (conn->lport != 0) { /* Set up for the callback. We can't know in advance if the application * is going to send a IPv4 or an IPv6 packet, so this setup may not * actually be used. */ #if defined(CONFIG_NET_IPv4) udp_ipv4_select(dev); #else /* if defined(CONFIG_NET_IPv6) */ udp_ipv6_select(dev); #endif dev->d_len = 0; dev->d_sndlen = 0; /* Perform the application callback */ (void)udp_callback(dev, conn, UDP_POLL); /* If the application has data to send, setup the UDP/IP header */ if (dev->d_sndlen > 0) { udp_send(dev, conn); return; } } /* Make sure that d_len is zero meaning that there is nothing to be sent */ dev->d_len = 0; }