path: root/src/network/kernel/qnetworkinterface_win.cpp
diff options
authorShane Kearns <>2012-05-09 17:06:47 +0100
committerQt by Nokia <>2012-05-11 17:39:13 +0200
commitb72c8dd8a248d67b1192e3baa1fca07244a3719d (patch)
tree434191d0472fb555c6cf993e053eebcea14d0267 /src/network/kernel/qnetworkinterface_win.cpp
parent653bca19c70bda9aa6f058380694451fa3ed3a16 (diff)
Include scope ids in QHostAddress from QNetworkInterface
The scope ID is a required part of the address for link local addresses (to solve the problem of the same link local address being created by two machines on different networks). It is required to send packets to a link local address on Mac and Windows, although Linux multicasts if scope is missing. Task-number: QTBUG-25634 Change-Id: Ie2bb09df8d261eefcb81716bafeb1475f0bed5fe Reviewed-by: Martin Petersson <>
Diffstat (limited to 'src/network/kernel/qnetworkinterface_win.cpp')
1 files changed, 5 insertions, 2 deletions
diff --git a/src/network/kernel/qnetworkinterface_win.cpp b/src/network/kernel/qnetworkinterface_win.cpp
index d1d26598ac..1f4ac7ff7a 100644
--- a/src/network/kernel/qnetworkinterface_win.cpp
+++ b/src/network/kernel/qnetworkinterface_win.cpp
@@ -91,9 +91,12 @@ static QHostAddress addressFromSockaddr(sockaddr *sa)
if (sa->sa_family == AF_INET)
address.setAddress(htonl(((sockaddr_in *)sa)->sin_addr.s_addr));
- else if (sa->sa_family == AF_INET6)
+ else if (sa->sa_family == AF_INET6) {
address.setAddress(((qt_sockaddr_in6 *)sa)->sin6_addr.qt_s6_addr);
- else
+ int scope = ((qt_sockaddr_in6 *)sa)->sin6_scope_id;
+ if (scope)
+ address.setScopeId(QString::number(scope));
+ } else
qWarning("Got unknown socket family %d", sa->sa_family);
return address;