PDA

View Full Version : QUrl handle ipv6 zone id wrong



spachner
13th July 2016, 15:52
Hi,

I need to use an url with ipv6 zone id, which is usually written as address%zone_ID. Have a look at https://4sysops.com/archives/ipv6-tutorial-part-7-zone-id-and-unique-local-ipv6-unicast-addresses/.

For example: fe80::bd0f:a8bc:6480:238b%11

When passing this String to QUrl::setHost() the error is returned "Invalid IPv6 address" by QUrl::errorString() and QUrl::isValid() is false:

baseUrl->setHost("fe80::bd0f:a8bc:6480:238b%11");

Is this a bug in QT?

How to assign a ipv6 zone id to a QUrl?

regards

spachne

ChrisW67
15th July 2016, 09:39
I cannot see any provision for zone index in either QUrl or QHostAddress (and I see your Qt bug report 54746 (https://bugreports.qt.io/browse/QTBUG-54746)). Everything seems to treat an IPv6 address as 16 bytes. The syntax for the human-readable zone index is inconsistent (e.g. %1 on Windows, %eth0 on Linux) from platform to platform and would have to be treated as an opaque string, stored, and decoded when presented to a relevant part of QtNetwork. QUrl is part of QtCore and probably cannot decode or validate the network interface details without assuming there is a network.

spachner
15th July 2016, 10:48
Thanks for your reply.

I would not have problems when QT could not validate the zone id and would simply pass them as opaque string. Instead any url containg a zone id is rejected.

All I need is a HTTP post done by QT which is an equivatent to a curl call like "curl "http://fe80:0000:0000:0000:020f:8dff:fed0:0010%vctrlext:5 0000/...".

I am using QNetworkAccessManager::post() which takes QNetworkRequest() as argument which relies on QUrl and I am stuck.

regards

ChrisW67
15th July 2016, 11:09
The host doesn't have a unique local or global address?

spachner
15th July 2016, 13:31
No, that's why I am forced to use the zone id. Here is an article about: https://4sysops.com/archives/ipv6-tutorial-part-7-zone-id-and-unique-local-ipv6-unicast-addresses/

spachner

ChrisW67
15th July 2016, 23:27
I understand why a zone index might be required, but it should only essential if the client has more than one IPv6 interface and thus needs to make a choice.

In your environment is there a way to use a name instead of the address?

You might be interested in RFC 6874, ehich talks about the ugliness of zone indexes in URLs.
https://tools.ietf.org/html/rfc6874