Discard confirmed APDU from original broadcast in BIP and BIP6 datalink (#149)
Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
This commit is contained in:
@@ -37,6 +37,7 @@
|
||||
#include <stdbool.h> /* for the standard bool type. */
|
||||
#include <string.h> /* for memcpy */
|
||||
#include "bacnet/bacdcode.h"
|
||||
#include "bacnet/npdu.h"
|
||||
#include "bacnet/datalink/bip.h"
|
||||
#include "bacnet/datalink/bvlc.h"
|
||||
#include "bacnet/basic/sys/debug.h"
|
||||
@@ -663,6 +664,7 @@ int bvlc_bbmd_disabled_handler(BACNET_IP_ADDRESS *addr,
|
||||
int function_len = 0;
|
||||
uint8_t *pdu = NULL;
|
||||
uint16_t pdu_len = 0;
|
||||
uint8_t *npdu = NULL;
|
||||
uint16_t npdu_len = 0;
|
||||
bool send_result = false;
|
||||
uint16_t offset = 0;
|
||||
@@ -765,8 +767,20 @@ int bvlc_bbmd_disabled_handler(BACNET_IP_ADDRESS *addr,
|
||||
if (function_len) {
|
||||
bvlc_ip_address_to_bacnet_local(src, addr);
|
||||
offset = header_len + function_len - npdu_len;
|
||||
debug_print_npdu(
|
||||
"Original-Broadcast-NPDU", offset, npdu_len);
|
||||
/* BTL test: verifies that the IUT will quietly discard any
|
||||
Confirmed-Request-PDU, whose destination address is a
|
||||
multicast or broadcast address, received from the
|
||||
network layer. */
|
||||
npdu = &mtu[offset];
|
||||
if (npdu_confirmed_service(npdu, npdu_len)) {
|
||||
offset = 0;
|
||||
debug_print_string(
|
||||
"Original-Broadcast-NPDU: "
|
||||
"Confirmed Service! Discard!");
|
||||
} else {
|
||||
debug_print_npdu(
|
||||
"Original-Broadcast-NPDU", offset, npdu_len);
|
||||
}
|
||||
} else {
|
||||
debug_print_string(
|
||||
"Original-Broadcast-NPDU: Unable to decode!");
|
||||
@@ -1075,9 +1089,21 @@ int bvlc_bbmd_enabled_handler(BACNET_IP_ADDRESS *addr,
|
||||
shall be sent directly to each foreign device currently in
|
||||
the BBMD's FDT also using the BVLL Forwarded-NPDU message. */
|
||||
npdu = &mtu[offset];
|
||||
bbmd_fdt_forward_npdu(addr, npdu, npdu_len, true);
|
||||
bbmd_bdt_forward_npdu(addr, npdu, npdu_len, true);
|
||||
debug_print_npdu("Original-Broadcast-NPDU", offset, npdu_len);
|
||||
/* BTL test: verifies that the IUT will quietly discard any
|
||||
Confirmed-Request-PDU, whose destination address is a
|
||||
multicast or broadcast address, received from the
|
||||
network layer. */
|
||||
if (npdu_confirmed_service(npdu, npdu_len)) {
|
||||
offset = 0;
|
||||
debug_print_string(
|
||||
"Original-Broadcast-NPDU: "
|
||||
"Confirmed Service! Discard!");
|
||||
} else {
|
||||
bbmd_fdt_forward_npdu(addr, npdu, npdu_len, true);
|
||||
bbmd_bdt_forward_npdu(addr, npdu, npdu_len, true);
|
||||
debug_print_npdu("Original-Broadcast-NPDU",
|
||||
offset, npdu_len);
|
||||
}
|
||||
} else {
|
||||
debug_print_string(
|
||||
"Original-Broadcast-NPDU: Unable to decode!");
|
||||
|
||||
@@ -615,6 +615,7 @@ int bvlc6_bbmd_disabled_handler(BACNET_IP6_ADDRESS *addr,
|
||||
int function_len = 0;
|
||||
uint8_t *pdu = NULL;
|
||||
uint16_t pdu_len = 0;
|
||||
uint8_t *npdu = NULL;
|
||||
uint16_t npdu_len = 0;
|
||||
bool send_result = false;
|
||||
uint16_t offset = 0;
|
||||
@@ -696,6 +697,18 @@ int bvlc6_bbmd_disabled_handler(BACNET_IP6_ADDRESS *addr,
|
||||
bbmd6_add_vmac(vmac_src, addr);
|
||||
bvlc6_vmac_address_set(src, vmac_src);
|
||||
offset = header_len + (function_len - npdu_len);
|
||||
/* BTL test: verifies that the IUT will quietly
|
||||
discard any Confirmed-Request-PDU, whose
|
||||
destination address is a multicast or
|
||||
broadcast address, received from the
|
||||
network layer. */
|
||||
npdu = &mtu[offset];
|
||||
if (npdu_confirmed_service(npdu, npdu_len)) {
|
||||
offset = 0;
|
||||
debug_printf(
|
||||
"BIP6: Original-Broadcast-NPDU: "
|
||||
"Confirmed Service! Discard!");
|
||||
}
|
||||
} else {
|
||||
debug_printf("BIP6: Original-Broadcast-NPDU: Unable to "
|
||||
"decode!\n");
|
||||
@@ -853,18 +866,30 @@ int bvlc6_bbmd_enabled_handler(BACNET_IP6_ADDRESS *addr,
|
||||
if (function_len) {
|
||||
offset = header_len + (function_len - npdu_len);
|
||||
npdu = &mtu[offset];
|
||||
/* Upon receipt of a BVLL Original-Broadcast-NPDU
|
||||
message from the local multicast domain, a BBMD
|
||||
shall construct a BVLL Forwarded-NPDU message and
|
||||
unicast it to each entry in its BDT. In addition,
|
||||
the constructed BVLL Forwarded-NPDU message shall
|
||||
be unicast to each foreign device currently in
|
||||
the BBMD's FDT */
|
||||
BVLC6_Buffer_Len = bvlc6_encode_forwarded_npdu(
|
||||
&BVLC6_Buffer[0], sizeof(BVLC6_Buffer), vmac_src, addr,
|
||||
npdu, npdu_len);
|
||||
bbmd6_send_pdu_bdt(&BVLC6_Buffer[0], BVLC6_Buffer_Len);
|
||||
bbmd6_send_pdu_fdt(&BVLC6_Buffer[0], BVLC6_Buffer_Len);
|
||||
/* BTL test: verifies that the IUT will quietly
|
||||
discard any Confirmed-Request-PDU, whose
|
||||
destination address is a multicast or
|
||||
broadcast address, received from the
|
||||
network layer. */
|
||||
if (npdu_confirmed_service(npdu, npdu_len)) {
|
||||
offset = 0;
|
||||
debug_printf(
|
||||
"BIP6: Original-Broadcast-NPDU: "
|
||||
"Confirmed Service! Discard!");
|
||||
} else {
|
||||
/* Upon receipt of a BVLL Original-Broadcast-NPDU
|
||||
message from the local multicast domain, a BBMD
|
||||
shall construct a BVLL Forwarded-NPDU message and
|
||||
unicast it to each entry in its BDT. In addition,
|
||||
the constructed BVLL Forwarded-NPDU message shall
|
||||
be unicast to each foreign device currently in
|
||||
the BBMD's FDT */
|
||||
BVLC6_Buffer_Len = bvlc6_encode_forwarded_npdu(
|
||||
&BVLC6_Buffer[0], sizeof(BVLC6_Buffer), vmac_src,
|
||||
addr, npdu, npdu_len);
|
||||
bbmd6_send_pdu_bdt(&BVLC6_Buffer[0], BVLC6_Buffer_Len);
|
||||
bbmd6_send_pdu_fdt(&BVLC6_Buffer[0], BVLC6_Buffer_Len);
|
||||
}
|
||||
if (!bbmd6_address_match_self(addr)) {
|
||||
/* The Virtual MAC address table shall be updated
|
||||
using the respective parameter values of the
|
||||
|
||||
Reference in New Issue
Block a user