Menu

Responding only to Unicast Confirmed Requests

2020-09-25
2023-09-13
  • Mladen Bajšić

    Mladen Bajšić - 2020-09-25

    Currently my BACnet server implementation responds to unicast confirmed requests and local confirmed broadcasts. It discards global broadcasts, which is good. I need to disable local confirmed broadcasts. for example when receiving read property. Where and how is this accomplished? Stack version used is 0.8.7.

     

    Last edit: Mladen Bajšić 2020-09-25
    • Steve Karg

      Steve Karg - 2020-09-30

      The npdu_handler() is responsible for ignoring broadcasts. 0.8.7 uses the following code:

                      if ((dest.net == BACNET_BROADCAST_NETWORK) &&
                          ((pdu[apdu_offset] & 0xF0) ==
                              PDU_TYPE_CONFIRMED_SERVICE_REQUEST)) {
                          /* hack for 5.4.5.1 - IDLE */
                          /* ConfirmedBroadcastReceived */
                          /* then enter IDLE - ignore the PDU */
                      } else {
                          apdu_handler(src, &pdu[apdu_offset],
                              (uint16_t) (pdu_len - apdu_offset));
                      }
      
       
  • Vasyl

    Vasyl - 2023-09-13

    Hi!
    I have a similar issue in my BACnet server implementation. It responds to Global and Local confirmed requests. It is because the stack isn't able to parse the destination address of the request. I have changed some functionality in bvlc .c sourse file to parse all data from the UDP socket to get the destination address of the request. Then I handle it in NPDU handler as shown below. It works properly now. Could you please advise, whether it good solution or it can affect the BACnet stack, or maybe you know a better solution?

     
  • Steve Karg

    Steve Karg - 2023-09-13

    In the BVLC handler, I added bvlc_broadcast_handler() function to handle the incoming Broadcast destination from the datalink, so that the code remains layered:

    int bvlc_broadcast_handler(BACNET_IP_ADDRESS *addr,
        BACNET_ADDRESS *src,
        uint8_t *npdu,
        uint16_t npdu_len)
    {
        int offset = 0;
        uint8_t message_type = 0;
        uint16_t message_length = 0;
        int header_len = 0;
    
        debug_print_bip("Received Broadcast", addr);
        header_len =
            bvlc_decode_header(npdu, npdu_len, &message_type, &message_length);
        if (header_len == 4) {
            switch (message_type) {
                case BVLC_ORIGINAL_UNICAST_NPDU:
                    /* drop unicast when sent as a broadcast */
                    debug_print_bip("Dropped BVLC (Original Unicast)", addr);
                    break;
                default:
                    offset = bvlc_handler(addr, src, npdu, npdu_len);
                    break;
            }
        }
    
        return offset;
    }
    

    See https://sourceforge.net/p/bacnet/src/ci/master/tree/src/bacnet/basic/bbmd/h_bbmd.c

     

Log in to post a comment.