Commit Graph
79 Commits
Author SHA1 Message Date
Marek Habersack 59258ea3f0 Turns out some devices can have network interfaces without names.
If we encounter such a device we assign it an empty name followed by index number, so that we can
put any number of such devices in the dictionary and report them to the user.

Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=21741
2014-07-31 19:45:05 -04:00
Marek Habersack 303e42b130 Implement the Mono side of Android support for NetworkInterface.GetAllNetworkInterfaces ()
Added code to call Xamarin.Android internal implementation of getifaddrs/freeifaddrs to provide us
with the required information to fulfill the request.

Added a handful of Linux ARP hardware IDs which are considered to be tunnel devices and which may occur
on Android devices.

Part of fix for https://bugzilla.xamarin.com/show_bug.cgi?id=1969
2014-07-30 18:22:33 -04:00
Christian Hüning 5e43e5d6db - ADDED: Support to read out Interface flags on OS X
- ADDED: Implemented NetworkInterface property "OperationalStatus" to be UP, in case the IFF_UP flag is set
- ADDED: Implemented NetworkInterface property "SupportsMulticast" to be true, in case the IFF_MULTICAST flag is set

This change is released under the MIT license.
2014-06-05 14:09:11 +02:00
Miguel de Icaza 705da187cf [System] Fix build warnings 2014-05-04 17:15:18 -04:00
Sebastien Pouliot 0da4887478 [System] Exclude LinuxNetworkChange from MONOTOUCH build (since it won't work as the p/invoke are not present) 2014-01-23 16:57:11 -05:00
Aaron Bockover d075623275 bxc#13642: MacNetworkChange: implement using managed code
The previous version used SCNetworkReachability
in C inside libMonoPosixHelper. This was less
than ideal and made it more problematic for
supporting iOS as it doesn't actually link
MPH in.

Rewrite using P/Invokes directly into the
SCNetworkReachability APIs for Mac OS X and
iOS.

Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=13642
for iOS and Mac OS X.
2013-10-10 12:35:47 -04:00
Sebastien Pouliot d8bdd1f209 Do not bring Win32 or Linux specific code for iOS NetworkInterface 2013-05-13 11:10:11 -04:00
Aaron Bockover ed5d39b1d7 NetworkChange: Support Mac OS X (bcx#12038)
Refactor System.Net.NetworkingInformation in order
to support multiple "providers"; previously only
Linux was ever supported for this API.

This patch provides basic support for Mac OS X
via the SystemConfiguration framework's
SCNetworkReachability API.

bxc#12038
2013-05-01 17:49:44 -04:00
Sebastien Pouliot 52852db613 Use same name/casing for DllImport so we do not duplicate needlessly the extern entries in the metadata 2012-11-06 19:08:39 -05:00
Rolf Bjarne Kvinge 31f07a71fa Marshal sockaddrdl manually, since it contains a variable-length byte array. Fixes #7329. 2012-09-21 02:06:40 +02:00
Atsushi Eno 99d5e54c35 add Android-specific ping path. 2012-09-07 17:33:01 +09:00
Tomasz Żyźniewski d8e7d08c58 call the event after async operation's completed 2012-08-28 16:12:51 +02:00
Miguel de Icaza 8a5f02ff75 Remove more old compile defines 2012-07-18 22:27:21 -04:00
Marek Safar 5b82f0e08c Clean up some NET_2_0 2012-06-14 15:44:35 +01:00
Martin Baulig e0e29c6140 Add .NET 4.5 async methods to System.Net.NetworkInformation.Ping. 2012-06-02 19:42:40 +02:00
Miguel de Icaza f48ceb9860 [System] Removal of the NET_2_0 in the source code
Modulo the GUID in the assembly and the GUID embedded in some
field initializers that use the assembly GUID for their name, the
assemblies are idential before and after the patch.
2012-06-02 13:16:40 -04:00
Jonathan Pryor f12dacdc78 [System] Fix MacOsNetworkInterface.ImplGetAllNetworkInterfaces()
On my (cursed?) MacBook Pro, calling
System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()
results in an exception:

	System.ArgumentException: length
		at System.Array.Copy (System.Array sourceArray, Int32 sourceIndex, System.Array destinationArray, Int32 destinationIndex, Int32 length) [0x00000] in <filename unknown>:0
		at System.Net.NetworkInformation.MacOsNetworkInterface.ImplGetAllNetworkInterfaces () [0x00000] in <filename unknown>:0
		at System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces () [0x00000] in <filename unknown>:0

Some printfs later, and we see why:

	Array.Copy(array.Length=12, 3, array.Length=0, 0, 0)
	Array.Copy(array.Length=12, 4, array.Length=0, 0, 0)
	Array.Copy(array.Length=12, 4, array.Length=0, 0, 0)
	Array.Copy(array.Length=12, 3, array.Length=6, 0, 6)
	Array.Copy(array.Length=12, 3, array.Length=6, 0, 6)
	Array.Copy(array.Length=12, 3, array.Length=8, 0, 4)
	Array.Copy(array.Length=12, 4, array.Length=6, 0, 6)
	Array.Copy(array.Length=12, 8, array.Length=6, 0, 6)
	# BOOM!

(Apparently I have 8 interfaces: lo0, gif0, stf0, en0, en1, fw0, p2p0,
and vboxnet0.)

The problem is readily obvious: we're trying to read 6 bytes of data
when only 4 are available, and Array.Copy() complains appropriately.

The fix -- which looks to almost contradict a02076ba -- is to use
`sockaddrdl.sdl_data.Length - sockaddrdl.sdl_nlen` instead of
`sockaddrdl.sdl_data.Length - macAddress.Length` (or sdl_alen).
sdl_nlen is the offset into the source sockaddrdl.sdl_data array, and
in this case sockaddrdl.sdl_alen (the length of the destination
macAddress) isn't the same as sockaddrdl.sdl_nlen, hence the breakage.
2012-04-05 15:39:45 -04:00
Gonzalo Paniagua Javier c89f1eb275 Fix MAC address for Mac/iOS
The position of the first byte to copy was wrong.
	Fixes bug #2012.
2011-12-13 10:24:30 -05:00
Rodrigo Kumpera 7b3c9bed98 Fix marshaling of Win32_IN6_ADDR. 2011-11-05 13:00:09 -02:00
Jeffrey Stedfast 7715de7ad9 Implemented a shared way to do MacOSX detection in System.dll 2011-07-05 17:52:25 -04:00
Gonzalo Paniagua Javier 75d42f19f9 [NetworkInformation] Support network IP/status events
Add support for the events in NetworkChanged (linux-only).
2011-03-27 18:50:35 -04:00
Miguel de Icaza f6472ef0da [594642] System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces fix for MacOS X 2011-02-19 11:05:29 -05:00
Atsushi Eno 7cfbbb0878 Add some missing StructLayoutAttributes. 2010-09-29 22:00:38 +09:00
Atsushi Eno ecd96c968a Fix NetworkInterface marshaling size on OSX and avoid crash. 2010-09-06 16:29:26 +09:00
Atsushi Eno 0ac3ae2806 Fix pinvoked function name and marshaling of MIB stats. 2010-08-11 23:24:06 +09:00
Gonzalo Paniagua Javier 339909fd3f Proper tracking of ICMP requests and responses.
* Ping.cs: generates a random ICMP Identifier field per Echo to help
	match up pings and their responses. Now has valid TTL and timeouts apply to
	the correct pings.  Also fixed bugs were received Sequence and
	Identifier would be corrupt for values >255, and fixed corruption of
	the Data field.
	Patch by Michael Walsh that fixes bug #627330.
2010-08-09 13:23:15 -04:00
Gonzalo Paniagua Javier 1ae7d82d80 2010-07-05 Gonzalo Paniagua Javier <[email protected]>
* NetworkInterface.cs: avoid endless loop when a bad length is
	received for AF_PACKET. Fixes bug #601783.


svn path=/trunk/mcs/; revision=159921
2010-07-05 18:30:41 +00:00
Gonzalo Paniagua Javier 55671bd0b2 2010-06-22 Gonzalo Paniagua Javier <[email protected]>
* Ping.cs: we need to read the output to give the process time
	to start. Fixes bug #591136.


svn path=/trunk/mcs/; revision=159372
2010-06-22 20:10:26 +00:00
Marek Safar 4e0bf1356c 2010-03-25 Marek Safar <[email protected]>
* IPGlobalProperties.cs: Made Win32_IN6_ADDR verifiable.


svn path=/trunk/mcs/; revision=154208
2010-03-25 17:48:22 +00:00
Miguel de Icaza f47e5fe6a6 2010-03-20 Miguel de Icaza <[email protected]>
* Eliminate warnings in a bunch of places.

svn path=/trunk/mcs/; revision=153952
2010-03-20 23:09:06 +00:00
Miguel de Icaza 11ca00c93b 2010-03-19 Miguel de Icaza <[email protected]>
* Eliminate warnings in a bunch of places.

svn path=/trunk/mcs/; revision=153923
2010-03-19 21:46:30 +00:00
Carlos Alberto Cortez aa17d4e326 2009-12-07 Carlos Alberto Cortez <[email protected]>
* Ping.cs: Try to detect the path to the bin command, since different
	Unix systems store it in different places.
	Fixes #519272.


svn path=/trunk/mcs/; revision=147831
2009-12-08 05:08:05 +00:00
Gonzalo Paniagua Javier f789ba4acf 2009-10-06 Gonzalo Paniagua Javier <[email protected]>
* GatewayIPAddressInformationCollection.cs:
	* IPInterfaceProperties.cs: implement GatewayAddresses for linux.
	Original patch by Christoph von Wittich.
	Fixes bug #544640.


svn path=/trunk/mcs/; revision=143525
2009-10-06 16:25:54 +00:00
Gonzalo Paniagua Javier 00c833429f 2009-09-29 Gonzalo Paniagua Javier <[email protected]>
* Ping.cs: fix the check for a time-out return value from 'ping'.


svn path=/trunk/mcs/; revision=142820
2009-09-29 05:57:15 +00:00
Zoltan Varga 31bf33fc66 2009-09-24 Zoltan Varga <[email protected]>
* LinuxNetworkInterfaceMarshal.cs: Add StructLayout attribute to structures, so
	the aot compiler can generate PtrToStructure wrappers for them.

svn path=/trunk/mcs/; revision=142578
2009-09-24 14:34:43 +00:00
Gonzalo Paniagua Javier 454ccc913a 2009-09-19 Gonzalo Paniagua Javier <[email protected]>
* Ping.cs: if we receive a packet that is ignored, adjust the
	timeout. Fixes bug #538013.


svn path=/trunk/mcs/; revision=142250
2009-09-19 04:44:28 +00:00
Gonzalo Paniagua Javier bb4cd0d150 remove TODOs
svn path=/trunk/mcs/; revision=137760
2009-07-13 04:25:11 +00:00
Miguel de Icaza 8c27e9fd64 Add
svn path=/trunk/mcs/; revision=134283
2009-05-16 20:16:43 +00:00
Miguel de Icaza 9f53a9fd85 2009-05-16 Miguel de Icaza <[email protected]>
* Apply patch from Alex Shulgin
	<[email protected]> to support OSX in
	NetworkInformation classes.

svn path=/trunk/mcs/; revision=134277
2009-05-16 18:03:09 +00:00
Gonzalo Paniagua Javier 12f4ef3894 2009-05-03 Gonzalo Paniagua Javier <[email protected]>
* Ping.cs: we just need the address(es), not a host entry. This avoids
	querying the DNS server(s) when the target is an IP address.


svn path=/trunk/mcs/; revision=133459
2009-05-04 03:14:29 +00:00
Gonzalo Paniagua Javier db1184228b 2009-03-24 Gonzalo Paniagua Javier <[email protected]>
* Ping.cs: MacOS has different arguments for ping.
	Bug #486904 fixed.


svn path=/trunk/mcs/; revision=130154
2009-03-24 21:00:01 +00:00
Gonzalo Paniagua Javier dfb688280d 2009-01-26 Christian Prochnow <[email protected]>
* Ping.cs: ignore ICMP echo request packet in case we ping
	  localhost.

svn path=/trunk/mcs/; revision=124624
2009-01-27 03:51:13 +00:00
Atsushi Eno a87bb8333d 2009-01-11 Atsushi Enomoto <[email protected]>
* NetworkInformationPermission.cs,
	  NetworkInformationPermissionAttribute.cs : implement some,
	  otherwise it blocks compilation.


svn path=/trunk/mcs/; revision=122998
2009-01-11 19:05:41 +00:00
Gonzalo Paniagua Javier cd744f7acb 2008-12-20 Gonzalo Paniagua Javier <[email protected]>
* Ping.cs: use the new internal method in Socket to avoid having to
	throw exceptions when there's a timeout.


svn path=/trunk/mcs/; revision=121924
2008-12-20 10:53:59 +00:00
Gonzalo Paniagua Javier 28771e5482 2008-12-11 Gonzalo Paniagua Javier <[email protected]>
* Ping.cs: close the socket in SendPrivileged. Use Buffer.BlockCopy
	instead of Array.Copy. Return IPStatus.Unknown instead of throwing an
	exception for unknown status codes received.


svn path=/trunk/mcs/; revision=121278
2008-12-11 08:46:45 +00:00
Miguel de Icaza 54616d8862 2008-11-25 Atsushi Enomoto <[email protected]>
* Makefile : update old nunit options that break upgrade to 2.4.

2008-11-03 Gonzalo Paniagua Javier <[email protected]>

svn path=/trunk/mcs/; revision=120282
2008-11-29 20:25:30 +00:00
Gonzalo Paniagua Javier ec5069a12d 2008-11-29 Gonzalo Paniagua Javier <[email protected]>
* IPAddressCollection.cs: added an internal method to make the
	collection read-only.
	* IPInterfaceProperties.cs: read DNS client configuration from
	/etc/resolv.conf.
	* NetworkInterface.cs: dummy Speed property for linux.

	Bug #450211 fixed.


svn path=/trunk/mcs/; revision=120281
2008-11-29 19:09:46 +00:00
Gonzalo Paniagua Javier b3db36863a 2008-11-20 Gonzalo Paniagua Javier <[email protected]>
* Ping.cs: the time for the arguments of 'ping' is in seconds. Don't
	read the output of running the command, since we trust the return
	code.


svn path=/trunk/mcs/; revision=119534
2008-11-20 23:15:54 +00:00
Atsushi Eno 801ecd1e6e 2008-10-27 Atsushi Enomoto <[email protected]>
* Ping.cs : use privileged mode for non-unix. On Windows there is
	  no /usr/bin/ping.


svn path=/trunk/mcs/; revision=117210
2008-10-27 21:51:30 +00:00
Gonzalo Paniagua Javier 0ab75f9991 2008-10-04 Gonzalo Paniagua Javier <[email protected]>
* NetworkInterface.cs: detect wireless 802.11 on linux.


svn path=/trunk/mcs/; revision=114857
2008-10-05 02:01:08 +00:00