When MAC address length is zero, assume it is a broadcast. Updated the MS/TP to understand this.
This commit is contained in:
@@ -1238,7 +1238,12 @@ int dlmstp_send_pdu(
|
|||||||
pkt->buffer[i] = pdu[i];
|
pkt->buffer[i] = pdu[i];
|
||||||
}
|
}
|
||||||
pkt->length = pdu_len;
|
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;
|
bytes_sent = pdu_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -987,7 +987,12 @@ int dlmstp_send_pdu(
|
|||||||
TransmitPacket = pdu;
|
TransmitPacket = pdu;
|
||||||
TransmitPacketLen = pdu_len;
|
TransmitPacketLen = pdu_len;
|
||||||
bytes_sent = 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;
|
MSTP_Flag.TransmitPacketPending = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1201,7 +1201,12 @@ int dlmstp_send_pdu(
|
|||||||
pkt->buffer[i] = pdu[i];
|
pkt->buffer[i] = pdu[i];
|
||||||
}
|
}
|
||||||
pkt->length = pdu_len;
|
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;
|
bytes_sent = pdu_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -161,7 +161,12 @@ int dlmstp_send_pdu(
|
|||||||
pkt->buffer[i] = pdu[i];
|
pkt->buffer[i] = pdu[i];
|
||||||
}
|
}
|
||||||
pkt->length = pdu_len;
|
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;
|
bytes_sent = pdu_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -105,10 +105,11 @@ int dlmstp_send_pdu(
|
|||||||
MSTP_Port.TxFrameType = FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY;
|
MSTP_Port.TxFrameType = FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY;
|
||||||
|
|
||||||
/* load destination MAC address */
|
/* load destination MAC address */
|
||||||
if (dest && dest->mac_len == 1) {
|
if (dest && dest->mac_len) {
|
||||||
MSTP_Port.TxDestination = dest->mac[0];
|
MSTP_Port.TxDestination = dest->mac[0];
|
||||||
} else {
|
} else {
|
||||||
return -2;
|
/* mac_len = 0 is a broadcast address */
|
||||||
|
MSTP_Port.TxDestination = MSTP_BROADCAST_ADDRESS;
|
||||||
}
|
}
|
||||||
dlmstp_get_my_address(&src);
|
dlmstp_get_my_address(&src);
|
||||||
if ((MAX_HEADER + pdu_len) > MAX_MPDU) {
|
if ((MAX_HEADER + pdu_len) > MAX_MPDU) {
|
||||||
|
|||||||
@@ -74,19 +74,17 @@ int dlmstp_send_pdu(
|
|||||||
unsigned mtu_len = 0;
|
unsigned mtu_len = 0;
|
||||||
|
|
||||||
if (MSTP_Port.TxReady == false) {
|
if (MSTP_Port.TxReady == false) {
|
||||||
if (npdu_data->confirmed_message)
|
if (npdu_data->confirmed_message) {
|
||||||
MSTP_Port.TxFrameType = FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY;
|
MSTP_Port.TxFrameType = FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY;
|
||||||
else
|
} else {
|
||||||
MSTP_Port.TxFrameType = FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY;
|
MSTP_Port.TxFrameType = FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY;
|
||||||
|
}
|
||||||
/* load destination MAC address */
|
/* load destination MAC address */
|
||||||
if (dest && dest->mac_len == 1) {
|
if (dest->mac_len) {
|
||||||
destination = dest->mac[0];
|
destination = dest->mac[0];
|
||||||
} else {
|
} else {
|
||||||
#if PRINT_ENABLED
|
/* mac_len = 0 is a broadcast address */
|
||||||
fprintf(stderr, "mstp: invalid destination MAC address!\n");
|
destination = MSTP_BROADCAST_ADDRESS;
|
||||||
#endif
|
|
||||||
return -2;
|
|
||||||
}
|
}
|
||||||
/* header len */
|
/* header len */
|
||||||
mtu_len = MAX_HEADER - 2 /* data crc */ ;
|
mtu_len = MAX_HEADER - 2 /* data crc */ ;
|
||||||
|
|||||||
@@ -1281,10 +1281,10 @@ int dlmstp_send_pdu(
|
|||||||
pkt->buffer[i] = pdu[i];
|
pkt->buffer[i] = pdu[i];
|
||||||
}
|
}
|
||||||
pkt->length = pdu_len;
|
pkt->length = pdu_len;
|
||||||
if (dest->mac_len == 0) {
|
if (dest && dest->mac_len) {
|
||||||
pkt->destination_mac = MSTP_BROADCAST_ADDRESS;
|
|
||||||
} else {
|
|
||||||
pkt->destination_mac = dest->mac[0];
|
pkt->destination_mac = dest->mac[0];
|
||||||
|
} else {
|
||||||
|
pkt->destination_mac = MSTP_BROADCAST_ADDRESS;
|
||||||
}
|
}
|
||||||
bytes_sent = pdu_len;
|
bytes_sent = pdu_len;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -291,10 +291,11 @@ uint16_t MSTP_Get_Send(
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* load destination MAC address */
|
/* 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];
|
destination = Transmit_Packet.address.mac[0];
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
destination = MSTP_BROADCAST_ADDRESS;
|
||||||
}
|
}
|
||||||
if ((MAX_HEADER + Transmit_Packet.pdu_len) > MAX_MPDU) {
|
if ((MAX_HEADER + Transmit_Packet.pdu_len) > MAX_MPDU) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -279,10 +279,10 @@ uint16_t MSTP_Get_Send(
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* load destination MAC address */
|
/* load destination MAC address */
|
||||||
if (Transmit_Packet.address.mac_len == 1) {
|
if (Transmit_Packet.address.mac_len) {
|
||||||
destination = Transmit_Packet.address.mac[0];
|
destination = Transmit_Packet.address.mac[0];
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
destination = MSTP_BROADCAST_ADDRESS;
|
||||||
}
|
}
|
||||||
if ((MAX_HEADER + Transmit_Packet.pdu_len) > MAX_MPDU) {
|
if ((MAX_HEADER + Transmit_Packet.pdu_len) > MAX_MPDU) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user