Fixed BACnet/IP to handler remote network broadcast that is unicast to the router.

This commit is contained in:
skarg
2014-08-02 00:05:00 +00:00
parent 862d6622d7
commit 0be5ddce65
2 changed files with 22 additions and 5 deletions
+10 -2
View File
@@ -166,12 +166,20 @@ int bip_send_pdu(
mtu[0] = BVLL_TYPE_BACNET_IP;
bip_dest.sin_family = AF_INET;
if ((dest->net == BACNET_BROADCAST_NETWORK) || ((dest->net > 0) &&
(dest->len == 0)) || (dest->mac_len == 0)) {
if ((dest->net == BACNET_BROADCAST_NETWORK) || (dest->mac_len == 0)) {
/* broadcast */
address.s_addr = BIP_Broadcast_Address.s_addr;
port = BIP_Port;
mtu[1] = BVLC_ORIGINAL_BROADCAST_NPDU;
} else if ((dest->net > 0) && (dest->len == 0)) {
/* network specific broadcast */
if (dest->mac_len == 6) {
bip_decode_bip_address(dest, &address, &port);
} else {
address.s_addr = BIP_Broadcast_Address.s_addr;
port = BIP_Port;
}
mtu[1] = BVLC_ORIGINAL_BROADCAST_NPDU;
} else if (dest->mac_len == 6) {
bip_decode_bip_address(dest, &address, &port);
mtu[1] = BVLC_ORIGINAL_UNICAST_NPDU;
+12 -3
View File
@@ -1181,9 +1181,7 @@ int bvlc_send_pdu(
/* handle various broadcasts: */
/* mac_len = 0 is a broadcast address */
/* net = 0 indicates local, net = 65535 indicates global */
/* net > 0 and net < 65535 are network specific broadcast if len = 0 */
if ((dest->net == BACNET_BROADCAST_NETWORK) || ((dest->net > 0) &&
(dest->len == 0)) || (dest->mac_len == 0)) {
if ((dest->net == BACNET_BROADCAST_NETWORK) || (dest->mac_len == 0)) {
/* if we are a foreign device */
if (Remote_BBMD.sin_port) {
mtu[1] = BVLC_DISTRIBUTE_BROADCAST_TO_NETWORK;
@@ -1196,6 +1194,17 @@ int bvlc_send_pdu(
mtu[1] = BVLC_ORIGINAL_BROADCAST_NPDU;
debug_printf("BVLC: Sent Original-Broadcast-NPDU.\n");
}
} 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 */
bvlc_decode_bip_address(&dest->mac[0], &address, &port);
} else {
address.s_addr = bip_get_broadcast_addr();
port = bip_get_port();
}
mtu[1] = BVLC_ORIGINAL_BROADCAST_NPDU;
debug_printf("BVLC: Sent Original-Broadcast-NPDU.\n");
} else if (dest->mac_len == 6) {
/* valid unicast */
bvlc_decode_bip_address(&dest->mac[0], &address, &port);