Allow binding QCoapClient to a network interface
Add a proper public property to QCoapClient class, and also add
the getter and setter to the QCoapConnection private class.
The code in QCoapConnection uses the new private APIs from QtNetwork
(added in qtbase/83fc4ff9c20eb922113e08ba8566e077ce44dea3) to bind
the UDP socket to a specific network interface.
Since the new private QtNetwork APIs are not fully functional on
macOS, this patch also implements additional filtering of the
incoming datagrams based on the specified network interface.
The QCoapConnection instance lives in a helper thread, so the
implementation stores the specified QNetworkInterface in both
QCoapConnection and QCoapClient, and uses invokeMethod() to transfer
the value from the client to the connection.
A different approach could be to store the network interface in the
connection only, and use a QMutex to synchronize access to it, but
due to the mentioned problem with macOS, we need to access the
QNetworkInterface instance in QCoapConnection when processing each
received datagram, so locking a mutex looks like too much overhead
in this case.
[ChangeLog][QCoapClient] Added a bindInterface property that can be
used to bind the communication to a specific network interface.
Done-with: Ivan Solovev <ivan.solovev@qt.io>
Fixes: QTBUG-139697
Change-Id: Ib64691d4f4787fcbc25240da31ff059c2bf326fe
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>