From e61162c285636aa3ba69888910b8a71825e65b20 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Thu, 28 May 2015 14:48:52 -0700 Subject: [PATCH] Fix UDP link handling on IPV6 systems --- src/comm/UDPLink.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/comm/UDPLink.cc b/src/comm/UDPLink.cc index 447c26aa0..5dc2a8170 100644 --- a/src/comm/UDPLink.cc +++ b/src/comm/UDPLink.cc @@ -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; -- 2.22.0