summaryrefslogtreecommitdiffstats
path: root/src/network/kernel/qnetworkinterface_linux.cpp
Commit message (Collapse)AuthorAgeFilesLines
* QNetworkInterface/Linux: fix mismatch of pointer and pointeeThiago Macieira2023-07-111-3/+6
| | | | | | | | | | | | | | | | | It was hard to see the problem because of the lambda, combined with reinterpret_cast on the output of non-typesafe C macro. NLMSG_DATA returns a void*, so use static_cast to be sure not to do something wrong. This only affected the code that dealt with unexpected replies from the Linux kernel, which it doesn't send. So I don't expect this fixes any improper QNetworkInterface behavior. Found by CodeChecker. Pick-to: 6.5 6.6 Change-Id: I61b74deaf2514644a24efffd1770d75e5a4f2636 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Port from qAsConst() to std::as_const()Marc Mutz2022-10-111-1/+1
| | | | | | | | | | | | | | | | We've been requiring C++17 since Qt 6.0, and our qAsConst use finally starts to bother us (QTBUG-99313), so time to port away from it now. Since qAsConst has exactly the same semantics as std::as_const (down to rvalue treatment, constexpr'ness and noexcept'ness), there's really nothing more to it than a global search-and-replace, with manual unstaging of the actual definition and documentation in dist/, src/corelib/doc/ and src/corelib/global/. Task-number: QTBUG-99313 Change-Id: I4c7114444a325ad4e62d0fcbfd347d2bbfb21541 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Port from container.count()/length() to size()Marc Mutz2022-10-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is semantic patch using ClangTidyTransformator: auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o) makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'. <classes> are: // sequential: "QByteArray", "QList", "QQueue", "QStack", "QString", "QVarLengthArray", "QVector", // associative: "QHash", "QMultiHash", "QMap", "QMultiMap", "QSet", // Qt has no QMultiSet Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-161-38/+2
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* network: Fix typos in source code commentsJonas Kvinge2021-10-121-1/+1
| | | | | | Change-Id: Iff505451e3f00de2d753de0f1d891a73cf73ef0d Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QNetworkInterface/Linux: make the IFLA_OPER_STATE set IsRunningThiago Macieira2021-02-181-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | We were setting IsUp for both the ifinfomsg::ifi_flags field and IFLA_OPER_STATE message. Turns out the second matches the "RUNNING" state that ifconfig used to return (IFF_RUNNING from SIOCIFFLAGS). Example: $ ip link show vboxnet0 4: vboxnet0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT group default qlen 1000 link/ether 0a:00:27:00:00:00 brd ff:ff:ff:ff:ff:ff $ ifconfig vboxnet0 vboxnet0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 ether 0a:00:27:00:00:00 txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 In this example, ifconfig is not showing "RUNNING", so its "UP" matches iproute2's in the <> section (that's the interface's ifi_flags). In an interface that ifconfig shows RUNNING, iproute2 will show "state UP", which is the IFLA_OPER_STATE. Exception: looks like the loopback has IF_OPER_UNKNOWN. Change-Id: Ic90d8429a0eb4837971dfffd1664bfc3f4b4e030 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Skip IPv6 address if DAD failedTimur Pocheptsov2020-09-171-0/+3
| | | | | | | | | | Fixes: QTBUG-84256 Fixes: QTBUG-84253 Task-number: QTBUG-84254 Pick-to: 5.15 Change-Id: I6116c8a337cc85adbca1bbab2609d6627127fa46 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Port Q_STATIC_ASSERT(_X) to static_assertGiuseppe D'Angelo2020-06-191-2/+2
| | | | | | | | | | | | | | | | | There is no reason for keep using our macro now that we have C++17. The macro itself is left in for the moment being, as well as its detection logic, because it's needed for C code (not everything supports C11 yet). A few more cleanups will arrive in the next few patches. Note that this is a mere search/replace; some places were using double braces to work around the presence of commas in a macro, no attempt has been done to fix those. tst_qglobal had just some minor changes to keep testing the macro. Change-Id: I1c1c397d9f3e63db3338842bf350c9069ea57639 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix build for Android with android-clangLiang Qi2018-05-251-1/+1
| | | | | | | | | | | | | kernel/qnetworkinterface_linux.cpp:204:17: error: comparison of integers of different signs: '__u32' (aka 'unsigned int') and 'qsizetype' (aka 'int') [-Werror,-Wsign-compare] if (NLMSG_OK(hdr, len)) ^~~~~~~~~~~~~~~~~~ This amends 09cb23f342fd2eae7ca85a99fa0a10b7ab103443. Change-Id: Ib966a60b7a7117d63ed758cba7b556abd90eca0c Reviewed-by: Mikhail Svetkin <mikhail.svetkin@qt.io> Reviewed-by: BogDan Vatra <bogdan@kdab.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix build for Android with android-clangLiang Qi2018-05-161-2/+2
| | | | | | | | | | | | | kernel/qnetworkinterface_linux.cpp:172:18: error: comparison of integers of different signs: '__u32' (aka 'unsigned int') and 'qsizetype' (aka 'int') [-Werror,-Wsign-compare] if (!NLMSG_OK(hdr, len)) ^~~~~~~~~~~~~~~~~~ kernel/qnetworkinterface_linux.cpp:197:26: error: comparison of integers of different signs: '__u32' (aka 'unsigned int') and 'qsizetype' (aka 'int') [-Werror,-Wsign-compare] } while (NLMSG_OK(hdr, len)); ^~~~~~~~~~~~~~~~~~ Change-Id: I3d0a4efc9fc42dd9b0726f2b62ff494220b8026e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: BogDan Vatra <bogdan@kdab.com>
* Compile when using -no-feature-networkinterfaceAndy Shaw2018-04-181-0/+4
| | | | | | Change-Id: I12a808599dd1fecaebc2e85a96da27a044666009 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* QNetworkInterface/Linux: fix support for P-t-P tunnelsThiago Macieira2018-03-261-1/+8
| | | | | | | | | | | | | | | | The kernel stores the local address in IFA_LOCAL and the peer's address in IFA_ADDRESS. My testing with loopback, Ethernet, WiFi, OpenVPN TAP and TUN and Openconnect shows IFA_LOCAL is always passed and always correct, so we could have used just that, but let's leave the use of IFA_ADDRESS because that's also what all libcs' getifaddrs() do. [ChangeLog][QtNetwork][QNetworkInterface] Fixed a regression in reporting the local address of a point-to-point tunnel network interface. Task-number: QTBUG-67226 Change-Id: I04a43ee94975482f9e32fffd151eb393d1775580 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Merge remote-tracking branch 'origin/5.10' into devLars Knoll2018-01-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | Conflicts: .qmake.conf sc/corelib/io/qfsfileengine_p.h src/corelib/io/qstorageinfo_unix.cpp src/platformsupport/eglconvenience/qeglpbuffer_p.h src/platformsupport/input/libinput/qlibinputkeyboard.cpp src/platformsupport/input/libinput/qlibinputpointer.cpp src/plugins/platforms/cocoa/qcocoamenu.mm src/plugins/platforms/ios/qiosscreen.h src/plugins/platforms/ios/qioswindow.h src/plugins/platforms/ios/quiview.mm src/printsupport/dialogs/qpagesetupdialog_unix_p.h src/printsupport/dialogs/qprintpreviewdialog.cpp src/printsupport/widgets/qcupsjobwidget_p.h src/widgets/widgets/qmenu.cpp tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp Change-Id: Iecb4883122efe97ef0ed850271e6c51bab568e9c
* Fix signed/unsigned comparisonTimur Pocheptsov2017-12-211-1/+1
| | | | | | | | | It breaks a build if warnings are treated as errors. Task-number: QTBUG-65357 Change-Id: I42d5cbdbd90f831662a6decaebecebef5005e735 Reviewed-by: Sami Nurmenniemi <sami.nurmenniemi@qt.io> Reviewed-by: Liang Qi <liang.qi@qt.io>
* QNetworkInterface: add MTUThiago Macieira2017-11-071-0/+5
| | | | | | | | [ChangeLog][QtNetwork][QNetworkInterface] Added maxTransmissionUnit(). Change-Id: Iaf4157b7efa2416d898cfffd14d96b2970d6af87 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* QNetworkInterface: Add the DNS eligibilityThiago Macieira2017-11-071-1/+4
| | | | | | | | | [ChangeLog][QtNetwork][QNetworkInterface] Added dnsEligibility() to QNetworkAddressEntry to indicate whether the address is eligible or not for publication in DNS or similar mechanisms. Change-Id: Id3ae5f853d964358ac1ab19b525334a426e0e052 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* QNetworkInterface: add support for extracting address lifetimeThiago Macieira2017-11-071-0/+12
| | | | | | | | | [ChangeLog][QtNetwork][QNetworkInterface] Added preferredLifetime() and validityLifetime() to QNetworkAddressEntry that report the remaining lifetime of the address in the network interface. Change-Id: I292b84e2193979446e43344b0727642812cba630 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QNetworkInterface: Add type()Thiago Macieira2017-11-071-0/+64
| | | | | | | | [ChangeLog][QtNetwork][QNetworkInterface] Added type(). Change-Id: I7de033f80b0e4431b7f1ffff13f9a5592b5776e1 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QNetworkInterface: add a Linux backend directly using AF_NETLINKThiago Macieira2017-11-071-0/+359
This allows us a lot greater detail in getting information than relying on getifaddrs() function. It is also the only way of getting some extra information we'll need in the future, like address lifetimes. The parser will also be helpful if we want to add a network interface monitor in the future, though I currently have no clue how to do the equivalent on macOS and Windows. This commit does not remove the support for getifaddrs() on Linux, but I will no longer add features to it. Note that Android does not support getifaddrs(), so this may be an improvement if AF_NETLINK works there. Change-Id: I3868166e5efc45538544fffd14d8e6f993e1eb91 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>