summaryrefslogtreecommitdiffstats
path: root/src/net
diff options
context:
space:
mode:
authorSebastien Braun2010-10-05 22:57:48 +0200
committerSebastien Braun2010-10-05 22:57:48 +0200
commit0cb19c0a597bfb7a6cac416fb5c0b0a89043081e (patch)
tree1c076c798ae6ce960bccde2e0aea675143d961d8 /src/net
parentFix SIGSEGV-generating lookup bug when incoming multicast transfers are retried (diff)
parent[PVSGUI] parsing cmdargs fixed (diff)
downloadpvs-0cb19c0a597bfb7a6cac416fb5c0b0a89043081e.tar.gz
pvs-0cb19c0a597bfb7a6cac416fb5c0b0a89043081e.tar.xz
pvs-0cb19c0a597bfb7a6cac416fb5c0b0a89043081e.zip
Merge remote branch 'openslx/master' into mcastft
Conflicts: CMakeLists.txt pvsmgr.qrc src/gui/clientConfigDialog.cpp src/gui/mainWindow.cpp src/gui/ui/mainwindow.ui src/gui/ui/mainwindowtouch.ui src/pvs.cpp src/pvs.h src/pvsDaemon.cpp src/pvsgui.cpp
Diffstat (limited to 'src/net')
-rw-r--r--src/net/SslServer.cpp4
-rw-r--r--src/net/pvsClientConnection.cpp2
-rw-r--r--src/net/pvsDiscoveredServer.cpp22
-rw-r--r--src/net/pvsListenServer.cpp7
-rw-r--r--src/net/pvsListenServer.h2
-rw-r--r--src/net/pvsLocalhostCommunicator.cpp6
-rw-r--r--src/net/pvsServerConnection.cpp2
-rw-r--r--src/net/pvsServiceBroadcast.cpp18
-rw-r--r--src/net/pvsServiceBroadcast.h2
-rw-r--r--src/net/pvsServiceDiscovery.cpp2
10 files changed, 40 insertions, 27 deletions
diff --git a/src/net/SslServer.cpp b/src/net/SslServer.cpp
index e353e0a..9940a61 100644
--- a/src/net/SslServer.cpp
+++ b/src/net/SslServer.cpp
@@ -59,7 +59,7 @@ void SslServer::incomingConnection(int socketDescriptor)
void SslServer :: sslErrors ( const QList<QSslError> & errors )
{
- printf("FIXME: SSL ERRORS on SERVER: %s\n", errors.begin()->errorString().toUtf8().data());
+ qDebug("FIXME: SSL ERRORS on SERVER: %s", qPrintable(errors.begin()->errorString()));
}
void SslServer::timerEvent (QTimerEvent* event)
@@ -98,7 +98,7 @@ bool SslServer::hasPendingConnections()
{
for (QList<QSslSocket*>::iterator it = _pending.begin(); it != _pending.end(); it++)
{
- printf("State: %d - Encrypted: %d\n", (int)(*it)->state(), (*it)->isEncrypted());
+ qDebug("State: %d - Encrypted: %d", (int)(*it)->state(), (*it)->isEncrypted());
if ((*it)->state() == QAbstractSocket::ConnectedState && (*it)->isEncrypted()) return true;
}
return false;
diff --git a/src/net/pvsClientConnection.cpp b/src/net/pvsClientConnection.cpp
index dff40d5..5354e95 100644
--- a/src/net/pvsClientConnection.cpp
+++ b/src/net/pvsClientConnection.cpp
@@ -134,7 +134,7 @@ bool PVSClientConnection::push_back_send(PVSMsg newMsg)
char *tmp = data;
if (!newMsg.getBinaryData(tmp, len))
{
- printf("Message empty. Ignored.\n");
+ qDebug("Message empty. Ignored.");
return false;
}
QByteArray ba;
diff --git a/src/net/pvsDiscoveredServer.cpp b/src/net/pvsDiscoveredServer.cpp
index dddb5a0..efa1506 100644
--- a/src/net/pvsDiscoveredServer.cpp
+++ b/src/net/pvsDiscoveredServer.cpp
@@ -48,7 +48,7 @@ void PVSDiscoveredServer::ssl_Error( const QList<QSslError> & errors )
}
//ConsoleLog writeNetwork(err.errorString().toUtf8().data());
//ConsoleLog writeNetwork("***** SSL ERROR, ABORTING *****");
- printf("Unhandled SSL Error in SD: %s\n", err.errorString().toUtf8().data());
+ qDebug("Unhandled SSL Error in SD: %s", qPrintable(err.errorString()));
return;
}
_socket->ignoreSslErrors();
@@ -70,30 +70,30 @@ void PVSDiscoveredServer::sock_connected()
QByteArray cert = _socket->peerCertificate().digest(QCryptographicHash::Sha1);
if (_socket->peerCertificate().isNull())
{
- printf("**** WARNING - PEER CERTIFICATE IS NULL ****\n");
+ qDebug("**** WARNING - PEER CERTIFICATE IS NULL ****");
}
else
{
- printf("%s\n", _socket->peerCertificate().subjectInfo(QSslCertificate::Organization).toUtf8().data());
- printf("%s\n", _socket->peerCertificate().subjectInfo(QSslCertificate::CommonName).toUtf8().data());
- printf("%s\n", _socket->peerCertificate().subjectInfo(QSslCertificate::LocalityName).toUtf8().data());
- printf("%s\n", _socket->peerCertificate().subjectInfo(QSslCertificate::OrganizationalUnitName ).toUtf8().data());
- printf("%s\n", _socket->peerCertificate().subjectInfo(QSslCertificate::CountryName ).toUtf8().data());
- printf("%s\n", _socket->peerCertificate().subjectInfo(QSslCertificate::StateOrProvinceName ).toUtf8().data());
+ qDebug("%s", qPrintable(_socket->peerCertificate().subjectInfo(QSslCertificate::Organization)));
+ qDebug("%s", qPrintable(_socket->peerCertificate().subjectInfo(QSslCertificate::CommonName)));
+ qDebug("%s", qPrintable(_socket->peerCertificate().subjectInfo(QSslCertificate::LocalityName)));
+ qDebug("%s", qPrintable(_socket->peerCertificate().subjectInfo(QSslCertificate::OrganizationalUnitName)));
+ qDebug("%s", qPrintable(_socket->peerCertificate().subjectInfo(QSslCertificate::CountryName)));
+ qDebug("%s", qPrintable(_socket->peerCertificate().subjectInfo(QSslCertificate::StateOrProvinceName)));
}
if (cert == _fingerprint && !_validated)
{
_validated = true;
emit validated(this);
- printf("Validated certificate of %s :)\n", _socket->peerAddress().toString().toUtf8().data());
+ qDebug("Validated certificate of %s :)", qPrintable(_socket->peerAddress().toString()));
}
else
{
- printf("Certificate of %s is invalid :(\n", _socket->peerAddress().toString().toUtf8().data());
+ qDebug("Certificate of %s is invalid :(", qPrintable(_socket->peerAddress().toString()));
QByteArray is, should;
is = cert.toBase64();
should = _fingerprint.toBase64();
- printf("Is %s and should be %s\n", is.data(), should.data());
+ qDebug("Is %s and should be %s", is.data(), should.data());
}
_socket->disconnectFromHost();
}
diff --git a/src/net/pvsListenServer.cpp b/src/net/pvsListenServer.cpp
index 1c1387b..90c2dfb 100644
--- a/src/net/pvsListenServer.cpp
+++ b/src/net/pvsListenServer.cpp
@@ -142,7 +142,7 @@ void PVSListenServer::timerEvent(QTimerEvent *event)
}
if (client->lastData() < refval)
{ // ping timeout
- printf("Ping timeout for client %s\n", client->getNameUser().toLocal8Bit().data());
+ qDebug("Ping timeout for client %s", qPrintable(client->getNameUser()));
if (disconnectClient(client))
break; // list was modified, iterator not valid anymore
}
@@ -294,9 +294,8 @@ void PVSListenServer::server_connectionRequest()
void PVSListenServer::handleClientMsg(unsigned int clientID, PVSMsg msg)
{
- printf("Got Message for client %ud: [%c][%s][%s]\n", clientID,
- (char) msg.getType(), msg.getIdent().toUtf8().data(),
- msg.getMessage().toUtf8().data());
+ qDebug("Got Message for client %ud: [%c][%s][%s]", clientID,
+ (char) msg.getType(), qPrintable(msg.getIdent()), qPrintable(msg.getMessage()));
msg.setSndID(clientID);
if (msg.getType() == PVSCOMMAND)
_commandDispatcher.fire(msg.getIdent(), msg);
diff --git a/src/net/pvsListenServer.h b/src/net/pvsListenServer.h
index 90d2a77..ca9977c 100644
--- a/src/net/pvsListenServer.h
+++ b/src/net/pvsListenServer.h
@@ -83,7 +83,7 @@ public:
template<class T> void addLoginHandler(QString ident, T* who, void (T :: *func)(PVSMsg))
{
- printf("Listener got added to LoginHandler\n");
+ qDebug("Listener got added to LoginHandler");
_loginDispatcher.addListener(ident, who, func);
};
template<class T> void removeLoginHandler(QString ident, T* who, void (T :: *func)(PVSMsg))
diff --git a/src/net/pvsLocalhostCommunicator.cpp b/src/net/pvsLocalhostCommunicator.cpp
index 199b39c..20783bb 100644
--- a/src/net/pvsLocalhostCommunicator.cpp
+++ b/src/net/pvsLocalhostCommunicator.cpp
@@ -83,7 +83,7 @@ void PVSLocalhostCommunicator::sendCommand(QString ident, QString cmd)
int len;
sender.getBinaryData(data, len);
QByteArray qba(data, len);
- printf("Sending %d bytes to daemon...\n", qba.length());
+ qDebug("Sending %d bytes to daemon...", qba.length());
qint64 result = _sock->writeDatagram(qba, localhost, localport);
_sock->waitForBytesWritten(100);
@@ -92,11 +92,11 @@ void PVSLocalhostCommunicator::sendCommand(QString ident, QString cmd)
{
if (result == -1)
{
- printf("Error sending PVSMsg to daemon: %s\n", _sock->errorString().toUtf8().data());
+ qDebug("Error sending PVSMsg to daemon: %s", qPrintable(_sock->errorString()));
}
else
{
- printf("Sent PVSMsg was incomplete.\n");
+ qDebug("Sent PVSMsg was incomplete.");
}
stop();
}
diff --git a/src/net/pvsServerConnection.cpp b/src/net/pvsServerConnection.cpp
index 04a1ef6..d187ce3 100644
--- a/src/net/pvsServerConnection.cpp
+++ b/src/net/pvsServerConnection.cpp
@@ -70,7 +70,7 @@ void PVSServerConnection::sslErrors ( const QList<QSslError> & errors )
for (QList<QSslError>::const_iterator it = errors.begin(); it != errors.end(); it++)
{
QSslError err = *it;
- printf("Connect SSL: %s\n", err.errorString().toUtf8().data());
+ qDebug("Connect SSL: %s", qPrintable(err.errorString()));
if (err.error() == QSslError::HostNameMismatch) continue; // We don't pay attention to hostnames for validation
if (err.error() == QSslError::SelfSignedCertificate) continue; // Also, this will always be the case; we check the fingerprint later
ConsoleLog writeNetwork(err.errorString().toUtf8().data());
diff --git a/src/net/pvsServiceBroadcast.cpp b/src/net/pvsServiceBroadcast.cpp
index cf15b5b..a861456 100644
--- a/src/net/pvsServiceBroadcast.cpp
+++ b/src/net/pvsServiceBroadcast.cpp
@@ -20,12 +20,22 @@
#include <cassert>
#include "src/util/serviceDiscoveryUtil.h"
+#include <QNetworkInterface>
+#include <QNetworkAddressEntry>
+
PVSServiceBroadcast::PVSServiceBroadcast()
{
_announce = NULL;
_timer = 0;
_broadcaster.bind(SD_PORT_CONSOLE);
- _everyone = QHostAddress(QHostAddress::Broadcast);
+
+ foreach (QNetworkInterface interface, QNetworkInterface::allInterfaces())
+ foreach (QNetworkAddressEntry entry, interface.addressEntries())
+ if (!entry.broadcast().isNull() && entry.broadcast().toString() != "127.255.255.255")
+ _everyone.append(entry.broadcast());
+
+ if (_everyone.isEmpty())
+ qDebug("ERROR: No broadcast address found");
}
PVSServiceBroadcast::~PVSServiceBroadcast()
@@ -47,5 +57,9 @@ void PVSServiceBroadcast::setFingerprint(QByteArray sha1)
void PVSServiceBroadcast::timerEvent(QTimerEvent *event)
{
if (_announce == NULL) return;
- _broadcaster.writeDatagram(*_announce, _everyone, SD_PORT_CLIENT);
+ foreach (QHostAddress bcast, _everyone)
+ {
+ qDebug("DEBUG: Broadcasting to %s:%i", qPrintable(bcast.toString()),SD_PORT_CLIENT);
+ _broadcaster.writeDatagram(*_announce, bcast, SD_PORT_CLIENT);
+ }
}
diff --git a/src/net/pvsServiceBroadcast.h b/src/net/pvsServiceBroadcast.h
index cf3f63d..a23370f 100644
--- a/src/net/pvsServiceBroadcast.h
+++ b/src/net/pvsServiceBroadcast.h
@@ -39,7 +39,7 @@ protected:
private:
QByteArray *_announce;
QUdpSocket _broadcaster;
- QHostAddress _everyone;
+ QList<QHostAddress> _everyone;
int _timer;
};
diff --git a/src/net/pvsServiceDiscovery.cpp b/src/net/pvsServiceDiscovery.cpp
index 0a99802..dd6b500 100644
--- a/src/net/pvsServiceDiscovery.cpp
+++ b/src/net/pvsServiceDiscovery.cpp
@@ -30,7 +30,7 @@ PVSServiceDiscovery::PVSServiceDiscovery(PVS* client)
bool ret = _sock.bind(SD_PORT_CLIENT);
if (!ret)
{
- printf("Could not open SERVICE DISCOVERY port\n");
+ qDebug("Could not open SERVICE DISCOVERY port");
exit(1);
}
connect(&_sock, SIGNAL(readyRead()), this, SLOT(sock_dataArrival()));