Correct destination network behaviour
-
a device should only respond to messages (who is service) where the destination bacnet network matches.
currently the stack does not know anything about bacnet networks.
adding the needed information is simple:public LocalDevice(int deviceId, String broadcastAddress, String localBindAddress, int localBACnetwork) { messageControl = new IpMessageControl(localBACnetwork); ... /code] and the class IpMessageControl needs a new member variable: [code] private static int localBACnetwork; /** * constructor with configured bacnet network number * * @param localBACnetwork */ public IpMessageControl(int localBACnetwork) { IpMessageControl.localBACnetwork = localBACnetwork; }
the check is simple, in the function parsAPDU the destination network has to be verified.
after:// Network layer protocol control information. See 6.2.2 NPCI npci = new NPCI(queue); if (npci.getVersion() != 1) throw new MessageValidationAssertionException("Invalid protocol version: " + npci.getVersion()); if (npci.isNetworkMessage()) return null; // throw new MessageValidationAssertionException("Network messages are not supported");
add the following check:
// detect the 'correct' bacnet work and do not respond to foreign networks requests if (npci.hasDestinationInfo()) { int bacNet = npci.getDestinationNetwork(); if (localBACnetwork > 0 && localBACnetwork != bacNet && bacNet != 65535 && bacNet > 0 ) { return null; } }
now you are able to pass a few more btl tests.
and the upper code has been tested.robert
-
Looks fine to me. I checked in changes that reflect your code.