diff options
| author | 2008-08-12 11:05:23 +0000 | |
|---|---|---|
| committer | 2008-08-12 11:05:23 +0000 | |
| commit | 6a22805f3dfdc586c49b541106f1153de2f5a790 (patch) | |
| tree | d0099391fe5d9f646eb491d5a1fe0d4a0c41af29 /src/modules/upnp/ssdpconnection.cpp | |
| parent | implemented #116; (diff) | |
| download | KVIrc-6a22805f3dfdc586c49b541106f1153de2f5a790.tar.gz KVIrc-6a22805f3dfdc586c49b541106f1153de2f5a790.tar.bz2 KVIrc-6a22805f3dfdc586c49b541106f1153de2f5a790.zip | |
first reworking on upnp module: got it communicating with the router
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@2229 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src/modules/upnp/ssdpconnection.cpp')
| -rw-r--r-- | src/modules/upnp/ssdpconnection.cpp | 49 |
1 files changed, 33 insertions, 16 deletions
diff --git a/src/modules/upnp/ssdpconnection.cpp b/src/modules/upnp/ssdpconnection.cpp index 657f31eae..bc3e4a48a 100644 --- a/src/modules/upnp/ssdpconnection.cpp +++ b/src/modules/upnp/ssdpconnection.cpp @@ -65,11 +65,7 @@ void SsdpConnection::slotDataReceived() { qDebug() << "UPnP::SsdpConnection: received " << socket_->bytesAvailable() << " bytes." << endl; - // Get the HTTP-like content - // TODO: How to handle multiple packets arriving from different devices? - QByteArray response = socket_->readAll(); - - // Response from my Acatel router: + // Response from Diederik's Acatel router: // // HTTP/1.1 200 OK // CACHE-CONTROL:max-age=1800 @@ -80,20 +76,41 @@ void SsdpConnection::slotDataReceived() // USN:uuid:UPnP-SpeedTouch510-1_00-90-D0-8E-A1-6F::upnp:rootdevice // - QString sspdResponse = QString::fromUtf8(response.data(), response.size()); + // This is from a Zyxel router: + // + // HTTP/1.1 200 OK + // ST:urn:schemas-upnp-org:device:InternetGatewayDevice:1 + // USN:uuid:11111111-%04x-c0a8-fcb30002cf618c::urn:schemas-upnp-org:device:InternetGatewayDevice:1 + // Location:http://192.168.252.179:80/DeviceDescription.xml + // Cache-Control: max-age=480 + // Server: ZyXEL-RomPlug/4.51 UPnP/1.0 IGD/1.00 + // Ext: + + while (socket_->hasPendingDatagrams()) { + QByteArray datagram; + datagram.resize(socket_->pendingDatagramSize()); + socket_->readDatagram(datagram.data(), datagram.size()); + + qDebug("Received datagram: %s\n",datagram.data()); - // Find the location field manually, MimeMessage is not required - int locationStart = sspdResponse.find("LOCATION:",0,false); // case insensitive - int locationEnd = sspdResponse.find("\r\n",locationStart); + QString sspdResponse = QString::fromUtf8(datagram.data(), datagram.size()); - locationStart += 9; // length of field name - QString location = sspdResponse.mid(locationStart, locationEnd - locationStart); + // Find the location field manually, MimeMessage is not required + int locationStart = sspdResponse.find("LOCATION:",0,false); // case insensitive + int locationEnd = sspdResponse.find("\r\n",locationStart); - // Parse the URL syntax using KURL - QUrl url(location); + locationStart += 9; // length of field name + QString location = sspdResponse.mid(locationStart, locationEnd - locationStart); - // Emit success - emit deviceFound(url.host(), url.port(), url.path()); + // Parse the URL syntax using KURL + QUrl url(location); + + qDebug("Found internet gateway: %s\n", location.toUtf8().data()); + // Emit success + emit deviceFound(url.host(), url.port(), url.path()); + + + } } @@ -113,7 +130,7 @@ void SsdpConnection::queryDevices(int bindPort) "\r\n"; // Bind the socket to a certain port - bool success = socket_->bind(address, bindPort); + bool success = socket_->bind(bindPort); if(! success) { qDebug() << "UPnP::SsdpConnection: Failed to bind to port " << bindPort << "." << endl; |
