Fixed the BACnet/IP broadcast messages to send as BVLC_ORIGINAL_BROADCAST_NPDU. Corrected comments about Broadcasts.

This commit is contained in:
skarg
2007-05-22 00:17:39 +00:00
parent 6140afa5c3
commit 8139ea6fa1
4 changed files with 16 additions and 14 deletions
+11 -9
View File
@@ -125,21 +125,23 @@ int bip_send_pdu(BACNET_ADDRESS * dest, /* destination address */
mtu[0] = BVLL_TYPE_BACNET_IP; mtu[0] = BVLL_TYPE_BACNET_IP;
bip_dest.sin_family = AF_INET; bip_dest.sin_family = AF_INET;
if (dest->mac_len == 6) { if (dest->net == BACNET_BROADCAST_NETWORK) {
/* broadcast */
bip_dest.sin_addr.s_addr = htonl(BIP_Broadcast_Address.s_addr);
bip_dest.sin_port = htons(BIP_Port);
memset(&(bip_dest.sin_zero), '\0', 8);
mtu[1] = BVLC_ORIGINAL_BROADCAST_NPDU;
} else if (dest->mac_len == 6) {
/* valid unicast */
(void) decode_unsigned32(&dest->mac[0], (void) decode_unsigned32(&dest->mac[0],
&(bip_dest.sin_addr.s_addr)); &(bip_dest.sin_addr.s_addr));
(void) decode_unsigned16(&dest->mac[4], &(bip_dest.sin_port)); (void) decode_unsigned16(&dest->mac[4], &(bip_dest.sin_port));
memset(&(bip_dest.sin_zero), '\0', 8); memset(&(bip_dest.sin_zero), '\0', 8);
mtu[1] = BVLC_ORIGINAL_UNICAST_NPDU; mtu[1] = BVLC_ORIGINAL_UNICAST_NPDU;
} } else {
/* broadcast */ /* invalid address */
else if (dest->mac_len == 0) {
bip_dest.sin_addr.s_addr = htonl(BIP_Broadcast_Address.s_addr);
bip_dest.sin_port = htons(BIP_Port);
memset(&(bip_dest.sin_zero), '\0', 8);
mtu[1] = BVLC_ORIGINAL_BROADCAST_NPDU;
} else
return -1; return -1;
}
mtu_len = 2; mtu_len = 2;
mtu_len += mtu_len +=
+2 -2
View File
@@ -350,7 +350,7 @@ void arcnet_get_my_address(BACNET_ADDRESS * my_address)
my_address->mac_len = 1; my_address->mac_len = 1;
my_address->mac[0] = ARCNET_MAC_Address; my_address->mac[0] = ARCNET_MAC_Address;
my_address->net = 0; /* local only, no routing */ my_address->net = 0; /* DNET=0 is local only, no routing */
my_address->len = 0; my_address->len = 0;
for (i = 0; i < MAX_MAC_LEN; i++) { for (i = 0; i < MAX_MAC_LEN; i++) {
my_address->adr[i] = 0; my_address->adr[i] = 0;
@@ -367,7 +367,7 @@ void arcnet_get_broadcast_address(BACNET_ADDRESS * dest)
dest->mac[0] = ARCNET_BROADCAST; dest->mac[0] = ARCNET_BROADCAST;
dest->mac_len = 1; dest->mac_len = 1;
dest->net = BACNET_BROADCAST_NETWORK; dest->net = BACNET_BROADCAST_NETWORK;
dest->len = 0; /* len=0 denotes broadcast address */ dest->len = 0; /* always zero when DNET is broadcast */
for (i = 0; i < MAX_MAC_LEN; i++) { for (i = 0; i < MAX_MAC_LEN; i++) {
dest->adr[i] = 0; dest->adr[i] = 0;
} }
+2 -2
View File
@@ -349,7 +349,7 @@ void ethernet_get_my_address(BACNET_ADDRESS * my_address)
my_address->mac[i] = Ethernet_MAC_Address[i]; my_address->mac[i] = Ethernet_MAC_Address[i];
my_address->mac_len++; my_address->mac_len++;
} }
my_address->net = 0; /* local only, no routing */ my_address->net = 0; /* DNET=0 is local only, no routing */
my_address->len = 0; my_address->len = 0;
for (i = 0; i < MAX_MAC_LEN; i++) { for (i = 0; i < MAX_MAC_LEN; i++) {
my_address->adr[i] = 0; my_address->adr[i] = 0;
@@ -368,7 +368,7 @@ void ethernet_get_broadcast_address(BACNET_ADDRESS * dest)
} }
dest->mac_len = 6; dest->mac_len = 6;
dest->net = BACNET_BROADCAST_NETWORK; dest->net = BACNET_BROADCAST_NETWORK;
dest->len = 0; /* denotes broadcast address */ dest->len = 0; /* always zero when DNET is broadcast */
for (i = 0; i < MAX_MAC_LEN; i++) { for (i = 0; i < MAX_MAC_LEN; i++) {
dest->adr[i] = 0; dest->adr[i] = 0;
} }
+1 -1
View File
@@ -315,7 +315,7 @@ void dlmstp_get_broadcast_address(BACNET_ADDRESS * dest)
dest->mac_len = 1; dest->mac_len = 1;
dest->mac[0] = MSTP_BROADCAST_ADDRESS; dest->mac[0] = MSTP_BROADCAST_ADDRESS;
dest->net = BACNET_BROADCAST_NETWORK; dest->net = BACNET_BROADCAST_NETWORK;
dest->len = 0; /* len=0 denotes broadcast address */ dest->len = 0; /* always zero when DNET is broadcast */
for (i = 0; i < MAX_MAC_LEN; i++) { for (i = 0; i < MAX_MAC_LEN; i++) {
dest->adr[i] = 0; dest->adr[i] = 0;
} }