Commit Graph

145 Commits

Author SHA1 Message Date
arvidn 1b2832e018 convert some for-loops into std algorithms 2018-11-27 19:43:01 +01:00
arvidn 3f87801142 fix some cppcheck warnings 2018-11-27 13:53:38 +01:00
arvidn 50ae1838e6 wrap inclusion of windows.h with appropriate defines 2018-11-21 10:09:23 +01:00
arvidn 5383854768 make span's and sha1_hash's index and size types signed (instead of unsigned). Specifically std::ptrdiff_t. In line with the direction of gsl span and reduce signed->unsigned casts 2018-11-16 14:06:22 +01:00
Arvid Norberg b90564d418 remove the IPv6 enable/disable build config 2018-08-19 22:20:54 +02:00
Arvid Norberg a477a53b80 simplify natpmp gateway and local address discovery 2018-07-29 13:10:36 +02:00
Alden Torres dfe47aa2a9 fixed sign implicit conversion warnings in new enum_net code (#3107) 2018-06-16 15:19:02 +02:00
Steven Siloti 78be52112f create a natpmp instance for each listen socket 2018-06-07 18:16:08 -07:00
Steven Siloti 496cf46b25 enum_routes fixes on Linux 2018-06-07 18:09:51 -07:00
Steven Siloti 4a578b1450 fix scope_id in enum_routes on Windows 2018-06-07 18:09:51 -07:00
Steven Siloti 72cf4fd9ea Remove UNC prefixes from device names on Windows 2018-06-07 18:09:51 -07:00
Steven Siloti 603e206f36 fix netmask of routes on Windows
The build_netmask function was incorrectly dividing the size of the bytes_type
by 8. Also use b.size() instead of sizeof for consistency.

I'm not 100% certain what the difference between DestinationPrefix.PrefixLength
and SitePrefixLength is. It looks like SitePrefixLength is something specific to
site-local addresses. Emperically I found DestinationPrefix.PrefixLength
contains reasonable values while SitePrefixLength is always zero.
2018-06-07 18:09:51 -07:00
Steven Siloti 9a48ef761e fix address of point-to-point interfaces (#3039) 2018-05-17 00:54:46 +02:00
arvidn f0227451a6 merged RC_1_1 into master 2018-04-13 01:47:41 +02:00
arvidn aaf9304a3b update year in copyright header 2018-04-09 09:04:33 +02:00
arvidn 32b2de8f17 merged RC_1_1 into master 2018-04-04 20:48:07 +02:00
Arvid Norberg 49ae7858a8 fix potential fd leak in enum_net_interfaces 2018-04-03 13:44:33 +02:00
arvidn 9df4d4b7f8 replace typedef with using. replace NULL with nullptr. cleanup page_aligned_allocator 2018-03-23 11:19:46 +01:00
Alexandre Janniaux 4f7b683eb0 fix if defined TORRENT_ANDROID
Fix malformed TORRENT_ANDROID macroprocessor tests, related to #2831
2018-03-14 09:32:18 +01:00
Alexandre Janniaux 2bc2f3af0f Add missing define for old android sdk (#2831)
define NETLINK_NO_ENOBUFS and IFA_D_DADFAILED if they don't exist
2018-03-09 22:37:21 +01:00
Alden Torres 421709f67f added friendly_name and description to ip_interface (#2799) 2018-02-19 11:46:35 +01:00
arvidn a0a63341c7 fix haiku build 2018-02-04 19:10:43 +01:00
arvidn e126d7bce0 move socket_type into aux-namespace 2018-01-29 08:33:45 +01:00
arvidn 89c6f0b4a8 merged RC_1_1 into master 2018-01-21 15:51:22 +01:00
arvidn 0ee6b7d142 build for iOS on travis 2018-01-18 22:37:37 +01:00
arvidn 65fef972a2 apply some c++11 modernization 2018-01-11 04:51:39 -05:00
arvidn 93bb84d94c some random cleanup 2017-09-13 08:28:46 +02:00
arvidn d59d394d5b remove residual mentions of mtu for interfaces 2017-08-20 22:34:20 +02:00
Alden Torres 66734e2e5b using if_indextoname instead of RTM_GETLINK to fill the interface name in enum_net_interfaces (#2253)
using if_indextoname instead of RTM_GETLINK to fill the interface name in enum_net_interfaces. removed IFA_LABEL switch case, removed ip_interface::mtu, master rebase
2017-08-20 10:55:59 +02:00
Alden Torres bde4718e3f typos, auto loop refactor and more std:: 2017-08-16 07:01:50 +02:00
arvidn 6b1037eff5 convert enum values that are just used as constants, to actual constants with the correct type 2017-08-04 15:23:20 +02:00
Alden Torres 285daa21a5 fixed another shorten-64-to-32 warning in netlink code 2017-07-03 13:53:15 -04:00
Alden Torres a78ec94184 fixed compilation warnings in enum_net netlink code 2017-06-29 15:48:28 -04:00
Steven Siloti bbf361336b Use netlink to enumerate network interfaces on linux (#2105)
* move getting a table dump over netlink to a separate function
* use netlink to enumerate network interfaces on linux
2017-06-27 00:34:24 -04:00
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