private System.Net.IPEndPoint BBMDSentAdd(Net.IPEndPoint BBMD, Net.IPAddress Mask) { byte[] bm = Mask.GetAddressBytes(); byte[] bip = BBMD.Address.GetAddressBytes(); /* annotation in Steve Karg bacnet stack : * * The B/IP address to which the Forwarded-NPDU message is * sent is formed by inverting the broadcast distribution * mask in the BDT entry and logically ORing it with the * BBMD address of the same entry. This process * produces either the directed broadcast address of the remote * subnet or the unicast address of the BBMD on that subnet * depending on the contents of the broadcast distribution * mask. * * remark from me : * for instance remote BBMD 192.168.0.1 - mask 255.255.255.255 * messages are forward directly to 192.168.0.1 * remote BBMD 192.168.0.1 - mask 255.255.255.0 * messages are forward to 192.168.0.255, ie certainly the local broadcast * address, but these datagrams are generaly destroy by the final IP router */ for (int i = 0; i < bm.Length; i++) { bip[i] = (byte)(bip[i] | (~bm[i])); } return(new System.Net.IPEndPoint(new System.Net.IPAddress(bip), BBMD.Port)); }
// Used to initiate the BBMD & FD behaviour, if BBMD is null it start the FD activity only public void AddBBMDPeer(Net.IPEndPoint BBMD, Net.IPAddress Mask) { BBMD_FD_ServiceActivated = true; if (BBMD != null) { lock (BBMDs) BBMDs.Add(new KeyValuePair <System.Net.IPEndPoint, System.Net.IPAddress>(BBMD, Mask)); } }