Commit Graph

161 Commits

Author SHA1 Message Date
Steven Siloti 0a9e2c965d invert logic in read_nl_sock for better clarity and reliability (#2101)
The seq and pid parameter are apparently used as a safety check in case
a stream of netlink messages is not properly terminated. I initially thought
that they represented the expected values of the incoming messages.
Instead seq is set to one-past the expected value and the loop aborts when
seq and pid match the message.

Inverting the logic so that reading continues as long as the seq and pid match
the incoming messages is, to me at least, more intuitive. It is also more
reliable since it does not rely on the next seq being strictly sequential. It
also catches unexpected messages preceding or interleaved with the expected
messages.

There seems to be a lot of confusion all across the internet over the
nlmsg_pid field. The changes here were made based on examination of the
kernel source and iproute2 (a common user of netlink).

The kernel does not read nlmsg_pid at all for routing messages.
Iproute2 sets it to zero unconditionally so I changed this code to do the same.
2017-06-25 10:29:32 -04:00
Steven Siloti 67a530f3ab only listen on preferred IPv6 addresses on Windows
We shouldn't listen on addresses which are duplicates, deprecated,
or tenative unless explicitly requested.

This is only supported on Windows for now because the Linux interface
to get this information is much less convenient for libtorrent to use.
As far as I've been able to determine, Linux only exposes this information
via the RTM_NEWADDR and RTM_GETADDR netlink messages. Currently libtorrent
uses getifaddrs() to enumerate network interfaces on Linux so this will
probably need to be changed to use netlink if available.

MacOS: ???
2017-05-30 07:38:12 -04:00
Arvid Norberg b60b3f164b Merge pull request #2027 from arvidn/RC_1_1
merged RC_1_1 into master
2017-05-24 23:30:24 -04:00
arvidn 432131e493 fix error reporting for enum_net_interfaces 2017-05-23 08:54:09 -04:00
arvidn a985773f4b fix previously faulty fix to enum_routes 2017-05-21 23:21:02 -04:00
arvidn 480bde9333 change formatting of namespace declarations 2017-04-12 14:26:35 -04:00
arvidn b367a0cd50 fix simulator build warnings 2017-04-02 20:48:36 -04:00
Alden Torres 1d1484d689 fixing remaining clang sign warnings (#1825)
fixing remaining clang sign warnings
2017-03-18 08:49:19 -04:00
Alden Torres a8b10a7449 more sign warnings fixes (#1775)
more sign warnings fixes
2017-03-09 07:46:52 -05:00
arvidn 3ffa3f2a08 merged RC_1_1 into master 2017-02-17 00:35:49 -05:00
arvidn 1300204ff1 back-port pavel's fix to ip_interface.name 2017-02-13 08:09:01 -05:00
pavel.pimenov 7e166ae9c4 Fix init ip_interface.name 2017-02-13 08:06:19 -05:00
arvidn 5971818969 merge RC_1_1 into master 2017-02-12 02:24:14 -05:00
arvidn 949d4cd12a fix regression in windows implementation of enum_net causing infinite loop 2017-02-11 19:09:21 -05:00
arvidn 964542e53b back-port ajax16384's fix to enum_net_interfaces on windows 2017-02-08 10:01:40 -05:00
Andrei Kurushin d7917c4382 consolidate address family checking (#1678)
consolidate address family checking, fix no IPV6 windows and netlink builds
2017-02-08 07:52:23 -05:00
arvidn 173951ec7f merged RC_1_1 into master 2017-01-21 02:28:29 -05:00
arvidn 3b9c65daf1 remove unused function, has_interface() 2017-01-16 15:14:47 -05:00
Alden Torres df6cb6a48d fixing sign-conversion warnings, part 4, minor refactor (#1549)
fixing sign-conversion warnings, part 4, minor refactor
2017-01-14 18:53:25 -05:00
Alden Torres c3d9614dfb minor code refactor and cleanup 2017-01-14 06:59:44 -05:00
Andrei Kurushin e10edb5e0b move LoadLibrary logic to new win_util module (#1464)
move LoadLibrary logic to new win_util module. use get_library_procedure as common windows dyn proc load routine
2016-12-28 10:12:20 -08:00
Andrei Kurushin 1ec5c69dcd minor code corrections (#1430)
use compact span cast. extend split_path api with only_first_part flag. use single loadlibrary and getprocaddress for IP helper
2016-12-26 22:45:48 -08:00
Alden Torres eaf99aa42b fixed more warnings of shorten-64-to-32 and sign-compare in android (#1425)
fixed more warnings of -Wshorten-64-to-32 in android. changed file_status to use std::time and disable warnings of NLMSG_OK in clang
2016-12-18 10:59:41 -05:00
Alden Torres f382936d56 headers, end of file, code cleanup 2016-12-12 23:36:45 -05:00
Alden Torres a05f0ba8a4 refactor for more modern struct initialization and use of api 2016-12-12 02:15:27 -05:00
Alden Torres d9f8d4b642 refactor to more use of auto c++11 keyword (#1404)
refactor to more use of auto c++11 keyword
2016-12-11 20:50:30 -05:00
Alden Torres dd7179fb10 added a few consts to arguments and local variables 2016-12-10 18:19:14 -05:00
Alden Torres e73435a77b fixed shorten-64-to-32 warnings for clang 2016-12-10 08:57:08 -05:00
Steven Siloti 07650c8558 set scope id when enumerating IPv6 addresses
This is necessary to be able to correctly match enumerated addresses
with those stored in listen_socket_t::local_endpoint when there is a
non-default zone id.
2016-11-23 01:09:05 -05:00
Arvid Norberg 5f7e2eb928 run undefined sanitier on travis/linux (#1134)
run undefined sanitizer on travis/linux. back-port ed25519 unit test from master
2016-10-08 12:29:46 -04:00
Alden Torres 4f6ea4a70d more session log and source code refactor 2016-09-20 11:24:24 -04:00
Alden Torres 3faa771843 removed use of boost::bind and boost::scoped_array (#1053) 2016-09-01 09:43:53 -04:00
Alden Torres fdfe69f414 fixed warnings and compilation issues (#980)
fixed warnings and compilation issues
2016-08-03 00:35:40 -04:00
Arvid Norberg e801d2e6de modernize replace deprecated headers (#897) 2016-07-09 23:17:55 -04:00
Arvid Norberg 770935cd46 modernize-use-nullptr (#894) 2016-07-09 16:26:26 -04:00
arvidn 3b2a527ffb Merge branch 'RC_1_1' 2016-06-22 00:41:02 -04:00
arvidn 763d313570 fix bug in enum_net() for BSD and Mac 2016-06-21 19:05:22 -04:00
Arvid Norberg 6aabe3762b general modernization (#836)
general modernization. use nullptr instead of NULL, use std::tuple instead of boost::tuple, transition some unordered set/map from boost to std. some clean-up of includes
2016-06-20 11:32:06 -04:00
Arvid Norberg cbeb7adbde fix .travis script to run simulations (#791)
fix .travis script to run simulations
2016-06-05 22:13:01 -04:00
Arvid Norberg 96999ad67f replace uses of boost::bind with std::bind and lambdas (#745) 2016-05-25 00:31:52 -04:00
arvidn 7c108e6c19 merged RC_1_1 into master 2016-05-09 00:30:30 -04:00
Arvid Norberg bcb359cef6 use unsigned long for ioctl commands (#705) 2016-05-06 08:08:49 -04:00
Andrei Kurushin 62eb956c54 fix x64 build with VS2015 UP2 compiler (#640)
fix VS2015 compiler warnings for: address-model=64, deprecated-functions=on, link=shared
2016-04-25 17:22:09 -04:00
Andrei Kurushin 7b5d48c02a fix default release build with VS2015 UP2 compiler warnings (#624)
* fix default release build with VS2015 UP2 compiler warnings
this will allow to successfully build:
bjam toolset=msvc-14.0 release deprecated-functions=off character-set=unicode link=static warnings-as-errors=on
2016-04-17 16:56:07 -04:00
arvidn aeb9f1c5dd fix bug in enum_net_interfaces 2016-02-29 18:14:10 -05:00
arvidn 828e79472d forward port enum_net MTU fix 2016-02-11 00:46:28 -05:00
arvidn 74554de330 forward port GetAdaptersAddresses from RC_1_0 and fix error categories in enum_net.cpp 2016-02-05 01:08:09 -05:00
arvidn 55024ccc4b forward port removal of special case for windows and mingw in get_default_gateway that appeared wrong 2016-01-31 21:14:15 -05:00
arvidn 1f9f588e75 merge copyright year update and changelog from RC_1_0 2016-01-17 18:57:46 -05:00
Steven Siloti bd0c237134 simulator: support IPv6 in enum_routes() 2015-10-29 20:43:51 -07:00
arvidn 234ac8adeb update libsimulator submodule with IPv6 support 2015-10-24 15:57:22 -04:00
arvidn 17c5759829 disable warning for unused command line argument and fix warnings. remove redundant travis build config. use new preprocessor on clang to avoid warnings 2015-09-06 22:55:41 -04:00
Alden Torres 88b1063f13 The constant siocgifmtu is used in the context of all these macros. 2015-08-26 17:46:54 -04:00
arvidn d8065b8941 fix some warnings 2015-08-21 14:03:16 +02:00
arvidn 26fecaf037 fix more warnings 2015-08-18 16:42:03 +02:00
arvidn 12da02ae52 fix some warnings 2015-08-18 09:33:00 -04:00
arvidn 4fa0aa62da simulate IP routes, interfaces and page size when building in simulation mode 2015-08-09 15:01:01 -04:00
arvidn 41533205be drop support for boost 1.35 and fix some more references to the asio namespace 2015-06-06 02:10:53 -04:00
arvidn 389ffc622c don't pull in the asio namespace in libtorrent. refer to it by boost::asio 2015-06-06 01:24:25 -04:00
Arvid Norberg d43f7b56a2 update copyright year 2015-06-03 05:18:48 +00:00
Arvid Norberg 9ee98b3ed1 fix build warnings 2015-05-18 05:04:55 +00:00
Arvid Norberg edfa38cd30 merged changes from RC_1_0 2014-11-17 03:41:01 +00:00
Arvid Norberg 7351389ce8 land libtorrent_aio branch in trunk 2014-07-06 19:18:00 +00:00
Arvid Norberg f8adec5ee0 merged enum_net fix from RC_0_16 2014-03-10 05:53:49 +00:00
Arvid Norberg a943fec777 update copyright 2014-02-23 19:12:25 +00:00
Arvid Norberg 18bf330615 merged enum_net typo fix from RC_0_16 2014-02-17 07:25:21 +00:00
Arvid Norberg 4e6b1cfbfb update copyright 2013-12-25 17:07:16 +00:00
Arvid Norberg f61b95f782 fix preprocessor typo 2012-10-21 15:19:23 +00:00
Arvid Norberg bff648a89e update copyright dates and add tool to do so 2012-10-02 03:16:33 +00:00
Arvid Norberg b8149ead5c OS/2 (eCS) support 2012-09-24 16:13:57 +00:00
Arvid Norberg 6a80638014 polish up ifreq support in enum_net_interrfaces 2012-05-13 18:48:10 +00:00
Arvid Norberg 36f7228001 support SIOCGIFCONF returning more interfaces than there's space in the supplied buffer 2012-05-13 04:43:22 +00:00
Arvid Norberg 32cd6e10b9 SIOCGIFCONF fix 2012-05-12 16:15:36 +00:00
Arvid Norberg 381f42bcf2 fix mingw build 2011-04-10 03:45:13 +00:00
Arvid Norberg 8aae74ea03 make enum_net use feature ifdefs instead of platform ifdefs 2011-04-09 03:49:46 +00:00
Arvid Norberg ca106ca4e0 some warning fixes and cleanup 2011-02-24 04:25:35 +00:00
Arvid Norberg 141ada013f fixed a whole bunch of build warnings on gcc and msvc, along with some fixes discovered along the way 2011-02-21 05:24:41 +00:00
Arvid Norberg d35670e53d generalize use of getifaddrs 2011-02-15 07:42:46 +00:00
Arvid Norberg b6b0970e16 use getifaddrs on linux to enumerate interfaces 2011-02-15 06:29:44 +00:00
Arvid Norberg 7508038337 cross compiling fixes 2011-02-14 04:12:26 +00:00
Arvid Norberg 94ef3eaf4b windows build fixes 2010-12-01 05:47:18 +00:00
Arvid Norberg e5f980d80d merged uTP branch into trunk (yay) 2010-11-29 01:33:05 +00:00
Arvid Norberg ddceb1487d fixed building with no IPv6 support 2009-11-27 18:46:29 +00:00
Arvid Norberg 6c67da08d6 split socket.hpp up in multiple headers to lower build time somewhat 2009-09-16 03:46:36 +00:00
Arvid Norberg db165942a7 oportunistic mingw fix 2009-06-30 23:03:54 +00:00
Arvid Norberg 1a6d2f86b9 add compile time option to disable IPv6 support 2009-03-31 07:45:54 +00:00
Arvid Norberg 3cdf9c87a8 fixed build errors on Solaris 2009-01-27 08:24:48 +00:00
Arvid Norberg df9b8753c9 fix to previous check-in 2008-08-16 23:02:03 +00:00
Arvid Norberg 55c79dd452 converting byte order of gateway and destinaton address when enumerating routes on linux 2008-08-16 22:49:46 +00:00
Arvid Norberg 5b28964c22 don't take the ip_interface vector by reference when it's returned by value 2008-08-16 21:26:23 +00:00
Andrew Resch aed8f355b0 Make libtorrent build with boost <1.35 2008-05-20 06:03:46 +00:00
Arvid Norberg 081953db51 enum_net windows fixes 2008-05-06 19:13:59 +00:00
Arvid Norberg 010d3b6e75 windows fix 2008-05-04 16:10:13 +00:00
Arvid Norberg c7e6c04705 switched over to asio from boost-1.35 2008-05-03 16:05:42 +00:00
Arvid Norberg c3b60f1b8f modified get_default_gateway to not take an interface 2008-04-28 02:20:40 +00:00
Arvid Norberg 3ec9a75d09 enum_routes fixes for linux 2008-04-28 01:23:11 +00:00
Arvid Norberg c2f7fb0fb4 added enum_routes to dump routing table 2008-04-28 00:20:59 +00:00
Arvid Norberg 8d5812011e update to enum_net 2008-04-27 04:51:28 +00:00
Arvid Norberg 6a7790cd28 added implementation for get_default_router for linux 2008-04-25 05:51:21 +00:00
Arvid Norberg e3c5001e80 fixed FreeBSD build. #284 2008-03-04 04:29:03 +00:00