mirror of
https://github.com/apache/nuttx.git
synced 2026-05-27 19:36:35 +08:00
net/udp: Fixed the issue of sending ICMP error when the destination address is broadcast/multicast.
According to rfc1112, section 7.2: "An ICMP error message (Destination Unreachable, Time Exceeded, Parameter Problem, Source Quench, or Redirect) is never generated in response to a datagram destined to an IP host group." Signed-off-by: zhangshuai39 <zhangshuai39@xiaomi.com>
This commit is contained in:
+11
-1
@@ -77,7 +77,7 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#if defined(CONFIG_NET_SOCKOPTS) && defined(CONFIG_NET_BROADCAST)
|
#ifdef CONFIG_NET_BROADCAST
|
||||||
static bool udp_is_broadcast(FAR struct net_driver_s *dev)
|
static bool udp_is_broadcast(FAR struct net_driver_s *dev)
|
||||||
{
|
{
|
||||||
/* Check if the destination address is a broadcast/multicast address */
|
/* Check if the destination address is a broadcast/multicast address */
|
||||||
@@ -329,6 +329,16 @@ static int udp_input(FAR struct net_driver_s *dev, unsigned int iplen)
|
|||||||
|
|
||||||
ret = udp_input_conn(dev, conn, udpiplen);
|
ret = udp_input_conn(dev, conn, udpiplen);
|
||||||
}
|
}
|
||||||
|
#ifdef CONFIG_NET_BROADCAST
|
||||||
|
else if (udp_is_broadcast(dev))
|
||||||
|
{
|
||||||
|
/* Due to RFC 1112, Section 7.2, we don't reply ICMP error
|
||||||
|
* message when the destination address is broadcast/multicast.
|
||||||
|
*/
|
||||||
|
|
||||||
|
dev->d_len = 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
nwarn("WARNING: No listener on UDP port\n");
|
nwarn("WARNING: No listener on UDP port\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user