From 76260a994d9d9104b28942e51145bd0a092cdfb8 Mon Sep 17 00:00:00 2001 From: bacpack Date: Wed, 27 Oct 2010 14:50:52 +0000 Subject: [PATCH] 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. --- bacnet-stack/src/bip.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bacnet-stack/src/bip.c b/bacnet-stack/src/bip.c index 7cb6e092..1b78e8b0 100644 --- a/bacnet-stack/src/bip.c +++ b/bacnet-stack/src/bip.c @@ -312,8 +312,9 @@ uint16_t bip_receive( } } } else if (pdu[1] == BVLC_FORWARDED_NPDU) { - (void) decode_unsigned32(&pdu[4], (uint32_t *) & sin.sin_addr.s_addr); - (void) decode_unsigned16(&pdu[8], &sin.sin_port); + // next 2 lines - moved data is always in the network format + *(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)) && (sin.sin_port == htons(BIP_Port))) { /* ignore messages from me */