sandwych-smartconfig icon indicating copy to clipboard operation
sandwych-smartconfig copied to clipboard

iOS15 broadcast IP 255.255.255.255 not allowed

Open szafranr opened this issue 4 years ago • 2 comments
trafficstars

Hi,

Could you provide change in this library? 255.255.255.255 broadcast address is ignored by iOS15

probably DatagramBroadcaster.cs method BroadcastAsync line with _broadcastTarget = ...

szafranr avatar Sep 23 '21 19:09 szafranr

Thanks for the bug report!

Sorry I didn't test this library on iOS.

Since SmartConfig protocol is all about the length of wireless packet, the broadcast address is not really important. Even if it's just a P2P data sending will do the trick.

I'll fix this problem ASAP.

oldrev avatar Sep 24 '21 09:09 oldrev

you can calculate broadcast IPAddress based on IP and mask provided

    public static IPAddress GetBroadcastAddress(IPAddress address, IPAddress mask)
    {
        uint ipAddress = BitConverter.ToUInt32(address.GetAddressBytes(), 0);
        uint ipMaskV4 = BitConverter.ToUInt32(mask.GetAddressBytes(), 0);
        uint broadCastIpAddress = ipAddress | ~ipMaskV4;

        return new IPAddress(BitConverter.GetBytes(broadCastIpAddress));
    }

szafranr avatar Sep 24 '21 18:09 szafranr