Skip to content

Commit e7ec9d7

Browse files
zs39xiaoxiang781216
authored andcommitted
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 <[email protected]>
1 parent e49f4b2 commit e7ec9d7

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

net/udp/udp_input.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
*
7878
****************************************************************************/
7979

80-
#if defined(CONFIG_NET_SOCKOPTS) && defined(CONFIG_NET_BROADCAST)
80+
#ifdef CONFIG_NET_BROADCAST
8181
static bool udp_is_broadcast(FAR struct net_driver_s *dev)
8282
{
8383
/* 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)
329329

330330
ret = udp_input_conn(dev, conn, udpiplen);
331331
}
332+
#ifdef CONFIG_NET_BROADCAST
333+
else if (udp_is_broadcast(dev))
334+
{
335+
/* Due to RFC 1112, Section 7.2, we don't reply ICMP error
336+
* message when the destination address is broadcast/multicast.
337+
*/
338+
339+
dev->d_len = 0;
340+
}
341+
#endif
332342
else
333343
{
334344
nwarn("WARNING: No listener on UDP port\n");

0 commit comments

Comments
 (0)