Fix receive BVLL Forwarded-NPDU message: the received source address is in network data format and it has to be stored in the same format.
Note: the encode_ and decode_ functions are broken; they ignore host's endianness.
This commit is contained in:
@@ -312,8 +312,9 @@ uint16_t bip_receive(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (pdu[1] == BVLC_FORWARDED_NPDU) {
|
} else if (pdu[1] == BVLC_FORWARDED_NPDU) {
|
||||||
(void) decode_unsigned32(&pdu[4], (uint32_t *) & sin.sin_addr.s_addr);
|
// next 2 lines - moved data is always in the network format
|
||||||
(void) decode_unsigned16(&pdu[8], &sin.sin_port);
|
*(uint32_t *)&sin.sin_addr.s_addr = *(uint32_t *)&pdu[4];
|
||||||
|
*(uint16_t *)&sin.sin_port = *(uint16_t *)&pdu[8];
|
||||||
if ((sin.sin_addr.s_addr == htonl(BIP_Address.s_addr)) &&
|
if ((sin.sin_addr.s_addr == htonl(BIP_Address.s_addr)) &&
|
||||||
(sin.sin_port == htons(BIP_Port))) {
|
(sin.sin_port == htons(BIP_Port))) {
|
||||||
/* ignore messages from me */
|
/* ignore messages from me */
|
||||||
|
|||||||
Reference in New Issue
Block a user