move DTLS socket changes to LimitedNodeList

This commit is contained in:
Stephen Birarda 2014-04-16 11:25:35 -07:00
parent 55d540a0eb
commit a25ef58247
2 changed files with 14 additions and 12 deletions

View file

@ -66,18 +66,6 @@ DomainServer::DomainServer(int argc, char* argv[]) :
LimitedNodeList* nodeList = LimitedNodeList::getInstance();
#if defined(IP_DONTFRAG) || defined(IP_MTU_DISCOVER)
qDebug() << "Making required DTLS changes to NodeList DTLS socket.";
int socketHandle = LimitedNodeList::getInstance()->getDTLSSocket().socketDescriptor();
#if defined(IP_DONTFRAG)
int optValue = 1;
setsockopt(socketHandle, IPPROTO_IP, IP_DONTFRAG, (const void*) optValue, sizeof(optValue));
#elif defined(IP_MTU_DISCOVER)
int optValue = 1;
setsockopt(socketHandle, IPPROTO_IP, IP_MTU_DISCOVER, (const void*) optValue, sizeof(optValue));
#endif
#endif
// connect our socket to read datagrams received on the DTLS socket
connect(&nodeList->getDTLSSocket(), &QUdpSocket::readyRead, this, &DomainServer::readAvailableDTLSDatagrams);
}

View file

@ -105,6 +105,20 @@ QUdpSocket& LimitedNodeList::getDTLSSocket() {
_dtlsSocket = new QUdpSocket(this);
_dtlsSocket->bind(QHostAddress::AnyIPv4, 0, QAbstractSocket::DontShareAddress);
#if defined(IP_DONTFRAG) || defined(IP_MTU_DISCOVER)
qDebug() << "Making required DTLS changes to LimitedNodeList DTLS socket.";
int socketHandle = _dtlsSocket->socketDescriptor();
#if defined(IP_DONTFRAG)
int optValue = 1;
setsockopt(socketHandle, IPPROTO_IP, IP_DONTFRAG, (const void*) optValue, sizeof(optValue));
#elif defined(IP_MTU_DISCOVER)
int optValue = 1;
setsockopt(socketHandle, IPPROTO_IP, IP_MTU_DISCOVER, (const void*) optValue, sizeof(optValue));
#endif
#endif
qDebug() << "NodeList DTLS socket is listening on" << _dtlsSocket->localPort();
}