mirror of
https://github.com/apache/nuttx.git
synced 2026-06-02 01:21:26 +08:00
net/netdev: add devif_loopback_out() to check the loopback case where a packet is being sent to itself. Modify the net driver to call this function in this case. This function will simply re-inject the packet back into the network and the network driver will not put anything on the wire.
This commit is contained in:
@@ -1046,6 +1046,8 @@ static int c5471_txpoll(struct net_driver_s *dev)
|
|||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_IPv6 */
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
|
|
||||||
|
if (!devif_loopback_out(&priv->c_dev))
|
||||||
|
{
|
||||||
/* Send the packet */
|
/* Send the packet */
|
||||||
|
|
||||||
c5471_transmit(priv);
|
c5471_transmit(priv);
|
||||||
@@ -1061,6 +1063,7 @@ static int c5471_txpoll(struct net_driver_s *dev)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* If zero is returned, the polling will continue until all connections have
|
/* If zero is returned, the polling will continue until all connections have
|
||||||
* been examined.
|
* been examined.
|
||||||
|
|||||||
@@ -600,6 +600,8 @@ static int imxrt_txpoll(struct net_driver_s *dev)
|
|||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_IPv6 */
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
|
|
||||||
|
if (!devif_loopback_out(&priv->dev))
|
||||||
|
{
|
||||||
/* Send the packet */
|
/* Send the packet */
|
||||||
|
|
||||||
imxrt_transmit(priv);
|
imxrt_transmit(priv);
|
||||||
@@ -615,6 +617,7 @@ static int imxrt_txpoll(struct net_driver_s *dev)
|
|||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* If zero is returned, the polling will continue until all connections have
|
/* If zero is returned, the polling will continue until all connections have
|
||||||
* been examined.
|
* been examined.
|
||||||
|
|||||||
@@ -571,6 +571,8 @@ static int kinetis_txpoll(struct net_driver_s *dev)
|
|||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_IPv6 */
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
|
|
||||||
|
if (!devif_loopback_out(&priv->dev))
|
||||||
|
{
|
||||||
/* Send the packet */
|
/* Send the packet */
|
||||||
|
|
||||||
kinetis_transmit(priv);
|
kinetis_transmit(priv);
|
||||||
@@ -586,6 +588,7 @@ static int kinetis_txpoll(struct net_driver_s *dev)
|
|||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* If zero is returned, the polling will continue until all connections have
|
/* If zero is returned, the polling will continue until all connections have
|
||||||
* been examined.
|
* been examined.
|
||||||
|
|||||||
@@ -716,6 +716,8 @@ static int lpc17_txpoll(struct net_driver_s *dev)
|
|||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_IPv6 */
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
|
|
||||||
|
if (!devif_loopback_out(&priv->lp_dev))
|
||||||
|
{
|
||||||
/* Send this packet. In this context, we know that there is space for
|
/* Send this packet. In this context, we know that there is space for
|
||||||
* at least one more packet in the descriptor list.
|
* at least one more packet in the descriptor list.
|
||||||
*/
|
*/
|
||||||
@@ -728,6 +730,7 @@ static int lpc17_txpoll(struct net_driver_s *dev)
|
|||||||
|
|
||||||
ret = lpc17_txdesc(priv);
|
ret = lpc17_txdesc(priv);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* If zero is returned, the polling will continue until all connections have
|
/* If zero is returned, the polling will continue until all connections have
|
||||||
* been examined.
|
* been examined.
|
||||||
|
|||||||
@@ -1165,6 +1165,8 @@ static int lpc43_txpoll(struct net_driver_s *dev)
|
|||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_IPv6 */
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
|
|
||||||
|
if (!devif_loopback_out(&priv->dev))
|
||||||
|
{
|
||||||
/* Send the packet */
|
/* Send the packet */
|
||||||
|
|
||||||
lpc43_transmit(priv);
|
lpc43_transmit(priv);
|
||||||
@@ -1205,6 +1207,7 @@ static int lpc43_txpoll(struct net_driver_s *dev)
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* If zero is returned, the polling will continue until all connections have
|
/* If zero is returned, the polling will continue until all connections have
|
||||||
* been examined.
|
* been examined.
|
||||||
|
|||||||
@@ -790,6 +790,8 @@ static int lpc54_eth_txpoll(struct net_driver_s *dev)
|
|||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_IPv6 */
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
|
|
||||||
|
if (!devif_loopback_out(&priv->eth_dev))
|
||||||
|
{
|
||||||
/* Send the packet */
|
/* Send the packet */
|
||||||
|
|
||||||
chan = lpc54_eth_getring(priv);
|
chan = lpc54_eth_getring(priv);
|
||||||
@@ -835,6 +837,7 @@ static int lpc54_eth_txpoll(struct net_driver_s *dev)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* If zero is returned, the polling will continue until all connections
|
/* If zero is returned, the polling will continue until all connections
|
||||||
* have been examined. If there is nothing to be sent, we will return to
|
* have been examined. If there is nothing to be sent, we will return to
|
||||||
|
|||||||
@@ -889,6 +889,8 @@ static int sam_txpoll(struct net_driver_s *dev)
|
|||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_IPv6 */
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
|
|
||||||
|
if (!devif_loopback_out(&priv->dev))
|
||||||
|
{
|
||||||
/* Send the packet */
|
/* Send the packet */
|
||||||
|
|
||||||
sam_transmit(priv);
|
sam_transmit(priv);
|
||||||
@@ -906,6 +908,7 @@ static int sam_txpoll(struct net_driver_s *dev)
|
|||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* If zero is returned, the polling will continue until all connections have
|
/* If zero is returned, the polling will continue until all connections have
|
||||||
* been examined.
|
* been examined.
|
||||||
|
|||||||
@@ -898,6 +898,8 @@ static int sam_txpoll(struct net_driver_s *dev)
|
|||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_IPv6 */
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
|
|
||||||
|
if (!devif_loopback_out(&priv->dev))
|
||||||
|
{
|
||||||
/* Send the packet */
|
/* Send the packet */
|
||||||
|
|
||||||
sam_transmit(priv);
|
sam_transmit(priv);
|
||||||
@@ -915,6 +917,7 @@ static int sam_txpoll(struct net_driver_s *dev)
|
|||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* If zero is returned, the polling will continue until all connections have
|
/* If zero is returned, the polling will continue until all connections have
|
||||||
* been examined.
|
* been examined.
|
||||||
|
|||||||
@@ -1233,6 +1233,8 @@ static int sam_txpoll(struct net_driver_s *dev)
|
|||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_IPv6 */
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
|
|
||||||
|
if (!devif_loopback_out(&priv->dev))
|
||||||
|
{
|
||||||
/* Send the packet */
|
/* Send the packet */
|
||||||
|
|
||||||
sam_transmit(priv);
|
sam_transmit(priv);
|
||||||
@@ -1250,6 +1252,7 @@ static int sam_txpoll(struct net_driver_s *dev)
|
|||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* If zero is returned, the polling will continue until all connections have
|
/* If zero is returned, the polling will continue until all connections have
|
||||||
* been examined.
|
* been examined.
|
||||||
|
|||||||
@@ -830,6 +830,8 @@ static int sam_txpoll(struct net_driver_s *dev)
|
|||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_IPv6 */
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
|
|
||||||
|
if (!devif_loopback_out(&priv->dev))
|
||||||
|
{
|
||||||
/* Send the packet */
|
/* Send the packet */
|
||||||
|
|
||||||
sam_transmit(priv);
|
sam_transmit(priv);
|
||||||
@@ -847,6 +849,7 @@ static int sam_txpoll(struct net_driver_s *dev)
|
|||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* If zero is returned, the polling will continue until all connections have
|
/* If zero is returned, the polling will continue until all connections have
|
||||||
* been examined.
|
* been examined.
|
||||||
|
|||||||
@@ -1547,6 +1547,8 @@ static int sam_txpoll(struct net_driver_s *dev)
|
|||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_IPv6 */
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
|
|
||||||
|
if (!devif_loopback_out(&priv->dev))
|
||||||
|
{
|
||||||
/* Send the packet */
|
/* Send the packet */
|
||||||
|
|
||||||
sam_transmit(priv, EMAC_QUEUE_0);
|
sam_transmit(priv, EMAC_QUEUE_0);
|
||||||
@@ -1564,6 +1566,7 @@ static int sam_txpoll(struct net_driver_s *dev)
|
|||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* If zero is returned, the polling will continue until all connections have
|
/* If zero is returned, the polling will continue until all connections have
|
||||||
* been examined.
|
* been examined.
|
||||||
|
|||||||
@@ -1271,6 +1271,8 @@ static int stm32_txpoll(struct net_driver_s *dev)
|
|||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_IPv6 */
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
|
|
||||||
|
if (!devif_loopback_out(&priv->dev))
|
||||||
|
{
|
||||||
/* Send the packet */
|
/* Send the packet */
|
||||||
|
|
||||||
stm32_transmit(priv);
|
stm32_transmit(priv);
|
||||||
@@ -1311,6 +1313,7 @@ static int stm32_txpoll(struct net_driver_s *dev)
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* If zero is returned, the polling will continue until all connections have
|
/* If zero is returned, the polling will continue until all connections have
|
||||||
* been examined.
|
* been examined.
|
||||||
|
|||||||
@@ -1305,6 +1305,8 @@ static int stm32_txpoll(struct net_driver_s *dev)
|
|||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_IPv6 */
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
|
|
||||||
|
if (!devif_loopback_out(&priv->dev))
|
||||||
|
{
|
||||||
/* Send the packet */
|
/* Send the packet */
|
||||||
|
|
||||||
stm32_transmit(priv);
|
stm32_transmit(priv);
|
||||||
@@ -1345,6 +1347,7 @@ static int stm32_txpoll(struct net_driver_s *dev)
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* If zero is returned, the polling will continue until all connections have
|
/* If zero is returned, the polling will continue until all connections have
|
||||||
* been examined.
|
* been examined.
|
||||||
|
|||||||
@@ -644,12 +644,15 @@ static int tiva_txpoll(struct net_driver_s *dev)
|
|||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_IPv6 */
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
|
|
||||||
|
if (!devif_loopback_out(&priv->ld_dev))
|
||||||
|
{
|
||||||
/* Send the packet. tiva_transmit() will return zero if the
|
/* Send the packet. tiva_transmit() will return zero if the
|
||||||
* packet was successfully handled.
|
* packet was successfully handled.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ret = tiva_transmit(priv);
|
ret = tiva_transmit(priv);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* If zero is returned, the polling will continue until all connections have
|
/* If zero is returned, the polling will continue until all connections have
|
||||||
* been examined.
|
* been examined.
|
||||||
|
|||||||
@@ -1273,6 +1273,8 @@ static int tiva_txpoll(struct net_driver_s *dev)
|
|||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_IPv6 */
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
|
|
||||||
|
if (!devif_loopback_out(&priv->dev))
|
||||||
|
{
|
||||||
/* Send the packet */
|
/* Send the packet */
|
||||||
|
|
||||||
tiva_transmit(priv);
|
tiva_transmit(priv);
|
||||||
@@ -1313,6 +1315,7 @@ static int tiva_txpoll(struct net_driver_s *dev)
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* If zero is returned, the polling will continue until all connections have
|
/* If zero is returned, the polling will continue until all connections have
|
||||||
* been examined.
|
* been examined.
|
||||||
|
|||||||
@@ -244,6 +244,8 @@ static int emac_txpoll(struct net_driver_s *dev)
|
|||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_IPv6 */
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
|
|
||||||
|
if (!devif_loopback_out(&priv->d_dev))
|
||||||
|
{
|
||||||
/* Send the packet */
|
/* Send the packet */
|
||||||
|
|
||||||
emac_transmit(priv);
|
emac_transmit(priv);
|
||||||
@@ -252,6 +254,7 @@ static int emac_txpoll(struct net_driver_s *dev)
|
|||||||
* return a non-zero value to terminate the poll.
|
* return a non-zero value to terminate the poll.
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* If zero is returned, the polling will continue until all connections have
|
/* If zero is returned, the polling will continue until all connections have
|
||||||
* been examined.
|
* been examined.
|
||||||
|
|||||||
@@ -1149,6 +1149,8 @@ static int pic32mx_txpoll(struct net_driver_s *dev)
|
|||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_IPv6 */
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
|
|
||||||
|
if (!devif_loopback_out(&priv->pd_dev))
|
||||||
|
{
|
||||||
/* Send this packet. In this context, we know that there is space for
|
/* Send this packet. In this context, we know that there is space for
|
||||||
* at least one more packet in the descriptor list.
|
* at least one more packet in the descriptor list.
|
||||||
*/
|
*/
|
||||||
@@ -1176,6 +1178,7 @@ static int pic32mx_txpoll(struct net_driver_s *dev)
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* If zero is returned, the polling will continue until all connections have
|
/* If zero is returned, the polling will continue until all connections have
|
||||||
* been examined.
|
* been examined.
|
||||||
|
|||||||
@@ -1176,6 +1176,8 @@ static int pic32mz_txpoll(struct net_driver_s *dev)
|
|||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_IPv6 */
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
|
|
||||||
|
if (!devif_loopback_out(&priv->pd_dev))
|
||||||
|
{
|
||||||
/* Send this packet. In this context, we know that there is space for
|
/* Send this packet. In this context, we know that there is space for
|
||||||
* at least one more packet in the descriptor list.
|
* at least one more packet in the descriptor list.
|
||||||
*/
|
*/
|
||||||
@@ -1203,6 +1205,7 @@ static int pic32mz_txpoll(struct net_driver_s *dev)
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* If zero is returned, the polling will continue until all connections have
|
/* If zero is returned, the polling will continue until all connections have
|
||||||
* been examined.
|
* been examined.
|
||||||
|
|||||||
@@ -334,6 +334,8 @@ static int misoc_net_txpoll(FAR struct net_driver_s *dev)
|
|||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_IPv6 */
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
|
|
||||||
|
if (!devif_loopback_out(&priv->misoc_net_dev))
|
||||||
|
{
|
||||||
/* Send the packet */
|
/* Send the packet */
|
||||||
|
|
||||||
misoc_net_transmit(priv);
|
misoc_net_transmit(priv);
|
||||||
@@ -342,6 +344,7 @@ static int misoc_net_txpoll(FAR struct net_driver_s *dev)
|
|||||||
* return a non-zero value to terminate the poll.
|
* return a non-zero value to terminate the poll.
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* If zero is returned, the polling will continue until all connections have
|
/* If zero is returned, the polling will continue until all connections have
|
||||||
* been examined.
|
* been examined.
|
||||||
|
|||||||
@@ -151,10 +151,13 @@ static int sim_txpoll(struct net_driver_s *dev)
|
|||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_IPv6 */
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
|
|
||||||
|
if (!devif_loopback_out(&g_sim_dev))
|
||||||
|
{
|
||||||
/* Send the packet */
|
/* Send the packet */
|
||||||
|
|
||||||
netdev_send(g_sim_dev.d_buf, g_sim_dev.d_len);
|
netdev_send(g_sim_dev.d_buf, g_sim_dev.d_len);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* If zero is returned, the polling will continue until all connections have
|
/* If zero is returned, the polling will continue until all connections have
|
||||||
* been examined.
|
* been examined.
|
||||||
|
|||||||
@@ -1147,12 +1147,15 @@ static int ez80emac_txpoll(struct net_driver_s *dev)
|
|||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_IPv6 */
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
|
|
||||||
|
if (!devif_loopback_out(&priv->dev))
|
||||||
|
{
|
||||||
/* Send the packet. ez80emac_transmit() will return zero if the
|
/* Send the packet. ez80emac_transmit() will return zero if the
|
||||||
* packet was successfully handled.
|
* packet was successfully handled.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ret = ez80emac_transmit(priv);
|
ret = ez80emac_transmit(priv);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* If zero is returned, the polling will continue until all connections have
|
/* If zero is returned, the polling will continue until all connections have
|
||||||
* been examined.
|
* been examined.
|
||||||
|
|||||||
@@ -819,6 +819,8 @@ static int dm9x_txpoll(struct net_driver_s *dev)
|
|||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_IPv6 */
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
|
|
||||||
|
if (!devif_loopback_out(&priv->dm_dev))
|
||||||
|
{
|
||||||
/* Send the packet */
|
/* Send the packet */
|
||||||
|
|
||||||
dm9x_transmit(priv);
|
dm9x_transmit(priv);
|
||||||
@@ -834,6 +836,7 @@ static int dm9x_txpoll(struct net_driver_s *dev)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* If zero is returned, the polling will continue until all connections have
|
/* If zero is returned, the polling will continue until all connections have
|
||||||
* been examined.
|
* been examined.
|
||||||
|
|||||||
@@ -1213,6 +1213,8 @@ static int enc_txpoll(struct net_driver_s *dev)
|
|||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_IPv6 */
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
|
|
||||||
|
if (!devif_loopback_out(&priv->dev))
|
||||||
|
{
|
||||||
/* Send the packet */
|
/* Send the packet */
|
||||||
|
|
||||||
enc_transmit(priv);
|
enc_transmit(priv);
|
||||||
@@ -1221,6 +1223,7 @@ static int enc_txpoll(struct net_driver_s *dev)
|
|||||||
|
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* If zero is returned, the polling will continue until all connections have
|
/* If zero is returned, the polling will continue until all connections have
|
||||||
* been examined.
|
* been examined.
|
||||||
|
|||||||
@@ -1194,10 +1194,13 @@ static int enc_txpoll(struct net_driver_s *dev)
|
|||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_IPv6 */
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
|
|
||||||
|
if (!devif_loopback_out(&priv->dev))
|
||||||
|
{
|
||||||
/* Send the packet */
|
/* Send the packet */
|
||||||
|
|
||||||
ret = enc_txenqueue(priv);
|
ret = enc_txenqueue(priv);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* If zero is returned, the polling will continue until all connections have
|
/* If zero is returned, the polling will continue until all connections have
|
||||||
* been examined.
|
* been examined.
|
||||||
|
|||||||
@@ -388,6 +388,8 @@ static int ftmac100_txpoll(struct net_driver_s *dev)
|
|||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_IPv6 */
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
|
|
||||||
|
if (!devif_loopback_out(&priv->ft_dev))
|
||||||
|
{
|
||||||
/* Send the packet */
|
/* Send the packet */
|
||||||
|
|
||||||
ftmac100_transmit(priv);
|
ftmac100_transmit(priv);
|
||||||
@@ -396,6 +398,7 @@ static int ftmac100_txpoll(struct net_driver_s *dev)
|
|||||||
* return a non-zero value to terminate the poll.
|
* return a non-zero value to terminate the poll.
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* If zero is returned, the polling will continue until all connections have
|
/* If zero is returned, the polling will continue until all connections have
|
||||||
* been examined.
|
* been examined.
|
||||||
|
|||||||
@@ -299,6 +299,13 @@ static int skel_txpoll(FAR struct net_driver_s *dev)
|
|||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_IPv6 */
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
|
|
||||||
|
/* Check if the network is sending this packet to the IP address of
|
||||||
|
* this device. If so, just loop the packet back into the network but
|
||||||
|
* don't attmpt to put it on the wire.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!devif_loopback_out(&priv->sk_dev))
|
||||||
|
{
|
||||||
/* Send the packet */
|
/* Send the packet */
|
||||||
|
|
||||||
skel_transmit(priv);
|
skel_transmit(priv);
|
||||||
@@ -307,6 +314,7 @@ static int skel_txpoll(FAR struct net_driver_s *dev)
|
|||||||
* return a non-zero value to terminate the poll.
|
* return a non-zero value to terminate the poll.
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* If zero is returned, the polling will continue until all connections have
|
/* If zero is returned, the polling will continue until all connections have
|
||||||
* been examined.
|
* been examined.
|
||||||
|
|||||||
@@ -404,9 +404,12 @@ static int slip_txpoll(FAR struct net_driver_s *dev)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if (priv->dev.d_len > 0)
|
if (priv->dev.d_len > 0)
|
||||||
|
{
|
||||||
|
if (!devif_loopback_out(&priv->dev))
|
||||||
{
|
{
|
||||||
slip_transmit(priv);
|
slip_transmit(priv);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* If zero is returned, the polling will continue until all connections have
|
/* If zero is returned, the polling will continue until all connections have
|
||||||
* been examined.
|
* been examined.
|
||||||
|
|||||||
@@ -400,6 +400,8 @@ static int cdcecm_txpoll(FAR struct net_driver_s *dev)
|
|||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_IPv6 */
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
|
|
||||||
|
if (!devif_loopback_out(&priv->dev))
|
||||||
|
{
|
||||||
/* Send the packet */
|
/* Send the packet */
|
||||||
|
|
||||||
cdcecm_transmit(priv);
|
cdcecm_transmit(priv);
|
||||||
@@ -410,6 +412,7 @@ static int cdcecm_txpoll(FAR struct net_driver_s *dev)
|
|||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* If zero is returned, the polling will continue until all connections
|
/* If zero is returned, the polling will continue until all connections
|
||||||
* have been examined.
|
* have been examined.
|
||||||
|
|||||||
@@ -994,8 +994,10 @@ static int rndis_txpoll(FAR struct net_driver_s *dev)
|
|||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_IPv6 */
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
|
|
||||||
|
if (!devif_loopback_out(&priv->netdev))
|
||||||
|
{
|
||||||
ret = rndis_transmit(priv);
|
ret = rndis_transmit(priv);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If zero is returned, the polling will continue until all connections have
|
/* If zero is returned, the polling will continue until all connections have
|
||||||
|
|||||||
@@ -473,6 +473,8 @@ static int bcmf_txpoll(FAR struct net_driver_s *dev)
|
|||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_IPv6 */
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
|
|
||||||
|
if (!devif_loopback_out(&priv->bc_dev))
|
||||||
|
{
|
||||||
/* Send the packet */
|
/* Send the packet */
|
||||||
|
|
||||||
bcmf_transmit(priv, priv->cur_tx_frame);
|
bcmf_transmit(priv, priv->cur_tx_frame);
|
||||||
@@ -484,6 +486,7 @@ static int bcmf_txpoll(FAR struct net_driver_s *dev)
|
|||||||
priv->cur_tx_frame = NULL;
|
priv->cur_tx_frame = NULL;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* If zero is returned, the polling will continue until all connections have
|
/* If zero is returned, the polling will continue until all connections have
|
||||||
* been examined.
|
* been examined.
|
||||||
|
|||||||
@@ -568,6 +568,23 @@ int devif_timer(FAR struct net_driver_s *dev, devif_poll_callback_t callback);
|
|||||||
void neighbor_out(FAR struct net_driver_s *dev);
|
void neighbor_out(FAR struct net_driver_s *dev);
|
||||||
#endif /* CONFIG_NET_IPv6 */
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: devif_loopback_out
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* This function should be called before sending out a packet. The function
|
||||||
|
* checks the destination address of the packet to see whether the target of
|
||||||
|
* packet is ourself and then consume the packet directly by calling input
|
||||||
|
* process functions.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Zero is returned if the packet don't loop back to ourself, otherwise
|
||||||
|
* a no zero value is returned.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int devif_loopback_out(FAR struct net_driver_s *dev);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Carrier detection
|
* Carrier detection
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
# Network device interface source files
|
# Network device interface source files
|
||||||
|
|
||||||
NET_CSRCS += devif_initialize.c devif_send.c devif_poll.c devif_callback.c
|
NET_CSRCS += devif_initialize.c devif_send.c devif_poll.c devif_callback.c
|
||||||
|
NET_CSRCS += devif_loopbackout.c
|
||||||
|
|
||||||
# Device driver IP packet receipt interfaces
|
# Device driver IP packet receipt interfaces
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,161 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* net/devif/devif_loopbackout.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2018 Pinecone Inc. All rights reserved.
|
||||||
|
* Author: Xiang Xiao <xiaoxiang@pinecone.net>
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||||
|
* used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include <nuttx/net/ip.h>
|
||||||
|
#include <nuttx/net/pkt.h>
|
||||||
|
#include <nuttx/net/netdev.h>
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/* This is a helper pointer for accessing the contents of the ip header */
|
||||||
|
|
||||||
|
#define IPv4BUF ((FAR struct ipv4_hdr_s *)(dev->d_buf + dev->d_llhdrlen))
|
||||||
|
#define IPv6BUF ((FAR struct ipv6_hdr_s *)(dev->d_buf + dev->d_llhdrlen))
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static bool is_loopback(FAR struct net_driver_s *dev)
|
||||||
|
{
|
||||||
|
if (dev->d_len > 0)
|
||||||
|
{
|
||||||
|
#ifdef CONFIG_NET_IPv4
|
||||||
|
if ((IPv4BUF->vhl & IP_VERSION_MASK) == IPv4_VERSION &&
|
||||||
|
net_ipv4addr_hdrcmp(IPv4BUF->destipaddr, &dev->d_ipaddr))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_IPv6
|
||||||
|
if ((IPv6BUF->vtc & IP_VERSION_MASK) == IPv6_VERSION &&
|
||||||
|
net_ipv6addr_hdrcmp(IPv6BUF->destipaddr, dev->d_ipv6addr))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: devif_loopback_out
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* This function should be called before sending out a packet. The function
|
||||||
|
* checks the destination address of the packet to see whether the target of
|
||||||
|
* packet is ourself and then consume the packet directly by calling input
|
||||||
|
* process functions.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Zero is returned if the packet don't loop back to ourself, otherwise
|
||||||
|
* a no zero value is returned.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int devif_loopback_out(FAR struct net_driver_s *dev)
|
||||||
|
{
|
||||||
|
if (!is_loopback(dev))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Loop while if there is data "sent" to ourself.
|
||||||
|
* Sending, of course, just means relaying back through the network.
|
||||||
|
*/
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
NETDEV_TXPACKETS(dev);
|
||||||
|
NETDEV_RXPACKETS(dev);
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_PKT
|
||||||
|
/* When packet sockets are enabled, feed the frame into the packet tap */
|
||||||
|
|
||||||
|
pkt_input(dev);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* We only accept IP packets of the configured type */
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_IPv4
|
||||||
|
if ((IPv4BUF->vhl & IP_VERSION_MASK) == IPv4_VERSION)
|
||||||
|
{
|
||||||
|
ninfo("IPv4 frame\n");
|
||||||
|
|
||||||
|
NETDEV_RXIPV4(dev);
|
||||||
|
ipv4_input(dev);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
#ifdef CONFIG_NET_IPv6
|
||||||
|
if ((IPv6BUF->vtc & IP_VERSION_MASK) == IPv6_VERSION)
|
||||||
|
{
|
||||||
|
ninfo("Iv6 frame\n");
|
||||||
|
|
||||||
|
NETDEV_RXIPV6(dev);
|
||||||
|
ipv6_input(dev);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
NETDEV_RXDROPPED(dev);
|
||||||
|
}
|
||||||
|
|
||||||
|
NETDEV_TXDONE(dev);
|
||||||
|
|
||||||
|
/* Add the data link header length for the next loop */
|
||||||
|
|
||||||
|
if (dev->d_len != 0)
|
||||||
|
{
|
||||||
|
dev->d_len += dev->d_llhdrlen;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (dev->d_len > 0);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user