private static unsafe AndroidNetworkInterface[] ToAndroidNetworkInterfaceArray(int interfaceCount, IntPtr networkInterfacesPtr, int addressCount, IntPtr addressPtr)
        {
            var networkInterfaces = new AndroidNetworkInterface[interfaceCount];

            var networkInterfaceInfo = (Interop.Sys.NetworkInterfaceInfo *)networkInterfacesPtr;

            for (int i = 0; i < interfaceCount; i++, networkInterfaceInfo++)
            {
                var name = Marshal.PtrToStringAnsi((IntPtr)networkInterfaceInfo->Name);
                networkInterfaces[i] = new AndroidNetworkInterface(name !, networkInterfaceInfo);
            }

            var addressInfo = (Interop.Sys.IpAddressInfo *)addressPtr;

            for (int i = 0; i < addressCount; i++, addressInfo++)
            {
                // there is usually just a handful of few network interfaces on Android devices
                // and this linear search does not have any impact on performance
                foreach (var networkInterface in networkInterfaces)
                {
                    if (networkInterface.Index == addressInfo->InterfaceIndex)
                    {
                        networkInterface.AddAddress(addressInfo);
                        break;
                    }
                }
            }

            return(networkInterfaces);
        }
 public AndroidIPv4InterfaceProperties(AndroidNetworkInterface androidNetworkInterface)
     : base(androidNetworkInterface)
 {
     Mtu = androidNetworkInterface._mtu;
 }
Exemplo n.º 3
0
 public AndroidIPv6InterfaceProperties(AndroidNetworkInterface androidNetworkInterface)
     : base(androidNetworkInterface)
 {
     _androidNetworkInterface = androidNetworkInterface;
 }
Exemplo n.º 4
0
 public AndroidIPInterfaceProperties(AndroidNetworkInterface ani)
     : base(ani, globalConfig: true)
 {
     _ipv4Properties = new AndroidIPv4InterfaceProperties(ani);
     _ipv6Properties = new AndroidIPv6InterfaceProperties(ani);
 }