Fixed network specific original broadcast for IP in apps/router. (#976)

This commit is contained in:
Steve Karg
2025-05-05 21:46:01 -05:00
committed by GitHub
parent 0b6cdf5a28
commit 44d727c13b
+15 -2
View File
@@ -223,11 +223,25 @@ int dl_ip_send(
data->buff[0] = BVLL_TYPE_BACNET_IP;
bip_dest.sin_family = AF_INET;
if (dest->net == BACNET_BROADCAST_NETWORK) {
if ((dest->net == BACNET_BROADCAST_NETWORK) || (dest->mac_len == 0)) {
/* broadcast */
bip_dest.sin_addr.s_addr = data->broadcast_addr.s_addr;
bip_dest.sin_port = data->port;
data->buff[1] = BVLC_ORIGINAL_BROADCAST_NPDU;
} else if ((dest->net > 0) && (dest->len == 0)) {
/* net > 0 and net < 65535 are network specific broadcast if len = 0 */
if (dest->mac_len == 6) {
/* network specific broadcast to address */
memcpy(&bip_dest.sin_addr.s_addr, &dest->mac[0], 4);
memcpy(&bip_dest.sin_port, &dest->mac[4], 2);
data->buff[1] = BVLC_ORIGINAL_BROADCAST_NPDU;
} else {
/* broadcast */
bip_dest.sin_addr.s_addr = data->broadcast_addr.s_addr;
bip_dest.sin_port = data->port;
data->buff[1] = BVLC_ORIGINAL_BROADCAST_NPDU;
}
} else if (dest->mac_len == 6) {
memcpy(&bip_dest.sin_addr.s_addr, &dest->mac[0], 4);
memcpy(&bip_dest.sin_port, &dest->mac[4], 2);
@@ -236,7 +250,6 @@ int dl_ip_send(
/* invalid address */
return -1;
}
buff_len = 2;
buff_len += encode_unsigned16(
&data->buff[buff_len], (uint16_t)(pdu_len + 4 /*inclusive */));