Added check for DNET as part of address to make sure it is for us and not a network beyond us.
This commit is contained in:
+11
-4
@@ -40,6 +40,8 @@
|
|||||||
#include "bits.h"
|
#include "bits.h"
|
||||||
#include "npdu.h"
|
#include "npdu.h"
|
||||||
#include "apdu.h"
|
#include "apdu.h"
|
||||||
|
#define DEBUG_ENABLED 0
|
||||||
|
#include "debug.h"
|
||||||
|
|
||||||
#if PRINT_ENABLED
|
#if PRINT_ENABLED
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -381,17 +383,22 @@ void npdu_handler(
|
|||||||
apdu_offset = npdu_decode(&pdu[0], &dest, src, &npdu_data);
|
apdu_offset = npdu_decode(&pdu[0], &dest, src, &npdu_data);
|
||||||
if (npdu_data.network_layer_message) {
|
if (npdu_data.network_layer_message) {
|
||||||
/*FIXME: network layer message received! Handle it! */
|
/*FIXME: network layer message received! Handle it! */
|
||||||
#if PRINT_ENABLED
|
debug_printf("NPDU: Network Layer Message discarded!\n");
|
||||||
fprintf(stderr, "NPDU: Network Layer Message discarded!\n");
|
|
||||||
#endif
|
|
||||||
} else if ((apdu_offset > 0) && (apdu_offset <= pdu_len)) {
|
} else if ((apdu_offset > 0) && (apdu_offset <= pdu_len)) {
|
||||||
if ((npdu_data.protocol_version == BACNET_PROTOCOL_VERSION) &&
|
if ((npdu_data.protocol_version == BACNET_PROTOCOL_VERSION) &&
|
||||||
(dest.net == 0)) {
|
((dest.net == 0) || (dest.net == BACNET_BROADCAST_NETWORK))) {
|
||||||
/* only handle the version that we know how to handle */
|
/* only handle the version that we know how to handle */
|
||||||
/* and we are not a router, so ignore messages with
|
/* and we are not a router, so ignore messages with
|
||||||
routing information cause they are not for us */
|
routing information cause they are not for us */
|
||||||
apdu_handler(src, &pdu[apdu_offset],
|
apdu_handler(src, &pdu[apdu_offset],
|
||||||
(uint16_t) (pdu_len - apdu_offset));
|
(uint16_t) (pdu_len - apdu_offset));
|
||||||
|
} else {
|
||||||
|
if (dest.net) {
|
||||||
|
debug_printf("NPDU: DNET=%d. Discarded!\n", dest.net);
|
||||||
|
} else {
|
||||||
|
debug_printf("NPDU: BACnet Protocol Version=%d. Discarded!\n",
|
||||||
|
npdu_data.protocol_version);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user