When MAC address length is zero, assume it is a broadcast. Updated the MS/TP to understand this.

This commit is contained in:
skarg
2014-11-02 05:27:14 +00:00
parent cab93e9db4
commit 3fca74bcfb
9 changed files with 41 additions and 21 deletions
+6 -1
View File
@@ -1238,7 +1238,12 @@ int dlmstp_send_pdu(
pkt->buffer[i] = pdu[i];
}
pkt->length = pdu_len;
pkt->destination_mac = dest->mac[0];
if (dest && dest->mac_len) {
pkt->destination_mac = dest->mac[0];
} else {
/* mac_len = 0 is a broadcast address */
pkt->destination_mac = MSTP_BROADCAST_ADDRESS;
}
bytes_sent = pdu_len;
}
+6 -1
View File
@@ -987,7 +987,12 @@ int dlmstp_send_pdu(
TransmitPacket = pdu;
TransmitPacketLen = pdu_len;
bytes_sent = pdu_len;
TransmitPacketDest = dest->mac[0];
if (dest && dest->mac_len) {
TransmitPacketDest = dest->mac[0];
} else {
/* mac_len = 0 is a broadcast address */
TransmitPacketDest = MSTP_BROADCAST_ADDRESS;
}
MSTP_Flag.TransmitPacketPending = true;
}
+6 -1
View File
@@ -1201,7 +1201,12 @@ int dlmstp_send_pdu(
pkt->buffer[i] = pdu[i];
}
pkt->length = pdu_len;
pkt->destination_mac = dest->mac[0];
if (dest && dest->mac_len) {
pkt->destination_mac = dest->mac[0];
} else {
/* mac_len = 0 is a broadcast address */
pkt->destination_mac = MSTP_BROADCAST_ADDRESS;
}
bytes_sent = pdu_len;
}
+6 -1
View File
@@ -161,7 +161,12 @@ int dlmstp_send_pdu(
pkt->buffer[i] = pdu[i];
}
pkt->length = pdu_len;
pkt->destination_mac = dest->mac[0];
if (dest && dest->mac_len) {
pkt->destination_mac = dest->mac[0];
} else {
/* mac_len = 0 is a broadcast address */
pkt->destination_mac = MSTP_BROADCAST_ADDRESS;
}
bytes_sent = pdu_len;
}
+3 -2
View File
@@ -105,10 +105,11 @@ int dlmstp_send_pdu(
MSTP_Port.TxFrameType = FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY;
/* load destination MAC address */
if (dest && dest->mac_len == 1) {
if (dest && dest->mac_len) {
MSTP_Port.TxDestination = dest->mac[0];
} else {
return -2;
/* mac_len = 0 is a broadcast address */
MSTP_Port.TxDestination = MSTP_BROADCAST_ADDRESS;
}
dlmstp_get_my_address(&src);
if ((MAX_HEADER + pdu_len) > MAX_MPDU) {
+6 -8
View File
@@ -74,19 +74,17 @@ int dlmstp_send_pdu(
unsigned mtu_len = 0;
if (MSTP_Port.TxReady == false) {
if (npdu_data->confirmed_message)
if (npdu_data->confirmed_message) {
MSTP_Port.TxFrameType = FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY;
else
} else {
MSTP_Port.TxFrameType = FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY;
}
/* load destination MAC address */
if (dest && dest->mac_len == 1) {
if (dest->mac_len) {
destination = dest->mac[0];
} else {
#if PRINT_ENABLED
fprintf(stderr, "mstp: invalid destination MAC address!\n");
#endif
return -2;
/* mac_len = 0 is a broadcast address */
destination = MSTP_BROADCAST_ADDRESS;
}
/* header len */
mtu_len = MAX_HEADER - 2 /* data crc */ ;
+3 -3
View File
@@ -1281,10 +1281,10 @@ int dlmstp_send_pdu(
pkt->buffer[i] = pdu[i];
}
pkt->length = pdu_len;
if (dest->mac_len == 0) {
pkt->destination_mac = MSTP_BROADCAST_ADDRESS;
} else {
if (dest && dest->mac_len) {
pkt->destination_mac = dest->mac[0];
} else {
pkt->destination_mac = MSTP_BROADCAST_ADDRESS;
}
bytes_sent = pdu_len;
}
+3 -2
View File
@@ -291,10 +291,11 @@ uint16_t MSTP_Get_Send(
return 0;
}
/* load destination MAC address */
if (Transmit_Packet.address.mac_len == 1) {
/* load destination MAC address */
if (Transmit_Packet.address.mac_len) {
destination = Transmit_Packet.address.mac[0];
} else {
return 0;
destination = MSTP_BROADCAST_ADDRESS;
}
if ((MAX_HEADER + Transmit_Packet.pdu_len) > MAX_MPDU) {
return 0;
+2 -2
View File
@@ -279,10 +279,10 @@ uint16_t MSTP_Get_Send(
return 0;
}
/* load destination MAC address */
if (Transmit_Packet.address.mac_len == 1) {
if (Transmit_Packet.address.mac_len) {
destination = Transmit_Packet.address.mac[0];
} else {
return 0;
destination = MSTP_BROADCAST_ADDRESS;
}
if ((MAX_HEADER + Transmit_Packet.pdu_len) > MAX_MPDU) {
return 0;