Commit e61162c2 authored by Lorenz Meier's avatar Lorenz Meier

Fix UDP link handling on IPV6 systems

parent 57d5f386
......@@ -42,9 +42,12 @@ This file is part of the QGROUNDCONTROL project
static bool is_ip(const QString& address)
{
int a,b,c,d;
if (sscanf(address.toStdString().c_str(), "%d.%d.%d.%d", &a, &b, &c, &d) != 4)
if (sscanf(address.toStdString().c_str(), "%d.%d.%d.%d", &a, &b, &c, &d) != 4
&& strcmp("::1", address.toStdString().c_str())) {
return false;
return true;
} else {
return true;
}
}
static QString get_ip_address(const QString& address)
......@@ -134,6 +137,10 @@ void UDPLink::removeHost(const QString& host)
void UDPLink::writeBytes(const char* data, qint64 size)
{
if (!_socket) {
return;
}
// Broadcast to all connected systems
QString host;
int port;
......@@ -349,7 +356,7 @@ void UDPConfiguration::addHost(const QString& host, int port)
} else {
QString ipAdd = get_ip_address(host);
if(ipAdd.isEmpty()) {
qWarning() << "UDP:" << "Could not resolve" << host;
qWarning() << "UDP:" << "Could not resolve host:" << host << "port:" << port;
} else {
_hosts[ipAdd] = port;
qDebug() << "UDP:" << "Adding Host:" << ipAdd << ":" << port;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment