[Mono-osx] [Mono-dev] [PATCH] Simple implementation of network interface properties for Mac OS X

Alex Shulgin alexander.shulgin at yessoftware.com
Tue Jun 30 11:09:50 EDT 2009


Alex Shulgin wrote:
> Alex Shulgin wrote:
>> Hi,
>>
>> In the current version System.Net.NetworkInformation.NetworkInterface 
>> provides limited information about network interfaces on the system 
>> (their names only).
>>
>> The attached patch adds support for NetworkInterfaceType and 
>> GetPhysicalAddress() on Mac OS.
> 
> Oops, I've almost forgot about IPv6... and missed the added file 
> MacOsNetworkInterfaceMarshal.
> 
> Please see the fixed patch instead.

This worked fine, until one user reported a crash on Array.Copy in 
NetworkInformation.MacOsNetworkInterface.ImplGetAllNetworkInterfaces(). 
  I traced this down to that I believe is a problem with non-standard 
length interface name: thus the 12-byte buffer sockaddr_dl.sdl_data is 
not enough.

I've noticed that sockaddr_dl contains sdl_len member which holds the 
length of the whole sockaddr structure.  With that we can use 
Marshal.Copy instead of Array.Copy to access data past default 12-byte 
data array.  A patch against trunk is attached.

I didn't have a chance to try it with the problematic user, but still 
would like someone to review the patch and comment on it.

--
Alex
PS: is there more appropriate way to increment IntPtr value w/o using 
ToInt64()?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: macos-network-interfaces-impl-new.patch
Type: text/x-patch
Size: 859 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-osx/attachments/20090630/c15fc44a/attachment.bin 


More information about the Mono-osx mailing list