ela-compil / BACnet

BACnet protocol library for .NET :satellite:
https://www.nuget.org/packages/bacnet/
MIT License
215 stars 95 forks source link

Problems running on Linux #93

Open cuican6 opened 2 years ago

cuican6 commented 2 years ago

hi . sometimes, networkcard in linux has two or more ipaddr, but in bacnet =>BacnetIpUdpProtocolTransport.cs=>GetAddressDefaultInterface method,two or more ipaddress is bad, in my submission,there canbe write return unicastAddresses.Length >= 1 ? unicastAddresses.First() : null; sir,tell me my proposal is correct? other,i binding ip in bacnetclient, BacnetClient client = new BacnetClient(.....,"192.168.1.200");in this ,i send whois ,can't receive response , no event of oniam trigger, but i confirm the package of whois has send, the other client (don't bind ip) has received message of i am. think you.

cuican6 commented 2 years ago

thank you

pocketbroadcast commented 2 years ago

Yes, I can confirm, this is a problem.

If there are multiple ip addresses configured for a single device the condition evaluates to false and the result is null as if there was no interface at all.

In case of multiple ip addresses configured, which one should be chosen? Any comments?

Nevertheless, resolving the default ip address is only used when we bind to any interface -> 0.0.0.0 -> imho if there are multiple ip addresses / subnets available this option is dangerous by default.

gralin commented 2 years ago

Thank you @cuican6 for reporting and @pocketbroadcast for checking this. It seems this address is only used to guess the correct broadcast address in case there is only one available interface address, otherwise it should return null so that default broadcast address is used. The original YABE code still has the same logic.

@pocketbroadcast I've added a suggestion for your PR