diff options
author | jfrijters <jfrijters> | 2010-09-01 10:40:28 +0400 |
---|---|---|
committer | jfrijters <jfrijters> | 2010-09-01 10:40:28 +0400 |
commit | 9d87c806d02b1a75f03b79da15be3aac4a23a472 (patch) | |
tree | 09ff9f632eddc7a083b158035a7d8093723441a6 | |
parent | af9e7ae341e2bd82edfcee947d01a7c8fbb453b2 (diff) |
IPv6 addresses associated with NetworkInterface should have their scope and network interface set (when appropriate).
-rw-r--r-- | openjdk/map.xml | 48 | ||||
-rw-r--r-- | runtime/openjdk.cs | 28 |
2 files changed, 72 insertions, 4 deletions
diff --git a/openjdk/map.xml b/openjdk/map.xml index 95d6680e..6811c632 100644 --- a/openjdk/map.xml +++ b/openjdk/map.xml @@ -1418,13 +1418,59 @@ </body> </method> </class> + <class name="java.net.Inet6Address"> + <method name="_set" sig="(ILjava.net.NetworkInterface;)V" modifiers=""> + <body> + <ldarg_0 /> + <ldarg_1 /> + <stfld class="java.net.Inet6Address" name="scope_id" sig="I" /> + <ldarg_0 /> + <ldc_i4_1 /> + <stfld class="java.net.Inet6Address" name="scope_id_set" sig="Z" /> + <ldarg_0 /> + <ldarg_2 /> + <stfld class="java.net.Inet6Address" name="scope_ifname" sig="Ljava.net.NetworkInterface;" /> + <ret /> + </body> + </method> + </class> + <class name="java.net.InterfaceAddress"> + <method name="_set" sig="(Ljava.net.InetAddress;Ljava.net.Inet4Address;S)V" modifiers=""> + <body> + <ldarg_0 /> + <ldarg_1 /> + <stfld class="java.net.InterfaceAddress" name="address" sig="Ljava.net.InetAddress;" /> + <ldarg_0 /> + <ldarg_2 /> + <stfld class="java.net.InterfaceAddress" name="broadcast" sig="Ljava.net.Inet4Address;" /> + <ldarg_0 /> + <ldarg_3 /> + <stfld class="java.net.InterfaceAddress" name="maskLength" sig="S" /> + <ret /> + </body> + </method> + </class> <class name="java.net.NetworkInterface"> - <method name="_set" sig="(Ljava.lang.String;[Ljava.net.InterfaceAddress;[Ljava.net.NetworkInterface;)V" modifiers=""> + <method name="_set1" sig="(Ljava.lang.String;Ljava.lang.String;I)V" modifiers=""> <body> <ldarg_0 /> <ldarg_1 /> + <stfld class="java.net.NetworkInterface" name="name" sig="Ljava.lang.String;" /> + <ldarg_0 /> + <ldarg_2 /> <stfld class="java.net.NetworkInterface" name="displayName" sig="Ljava.lang.String;" /> <ldarg_0 /> + <ldarg_3 /> + <stfld class="java.net.NetworkInterface" name="index" sig="I" /> + <ret /> + </body> + </method> + <method name="_set2" sig="([Ljava.net.InetAddress;[Ljava.net.InterfaceAddress;[Ljava.net.NetworkInterface;)V" modifiers=""> + <body> + <ldarg_0 /> + <ldarg_1 /> + <stfld class="java.net.NetworkInterface" name="addrs" sig="[Ljava.net.InetAddress;" /> + <ldarg_0 /> <ldarg_2 /> <stfld class="java.net.NetworkInterface" name="bindings" sig="[Ljava.net.InterfaceAddress;" /> <ldarg_0 /> diff --git a/runtime/openjdk.cs b/runtime/openjdk.cs index 967d81fd..874f4541 100644 --- a/runtime/openjdk.cs +++ b/runtime/openjdk.cs @@ -3888,15 +3888,37 @@ namespace IKVM.NativeCode.java name = "net" + net++; break; } + jnNetworkInterface netif = new jnNetworkInterface(); + ret[i] = netif; + netif._set1(name, ifaces[i].Description, GetIndex(ifaces[i])); System.Net.NetworkInformation.UnicastIPAddressInformationCollection uipaic = ifaces[i].GetIPProperties().UnicastAddresses; jnInetAddress[] addresses = new jnInetAddress[uipaic.Count]; for (int j = 0; j < addresses.Length; j++) { - addresses[j] = InetAddress.ConvertIPAddress(uipaic[j].Address, null); + System.Net.IPAddress addr = uipaic[j].Address; + if (addr.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) + { + addresses[j] = new jnInet4Address(null, addr.GetAddressBytes()); + } + else + { + int scope = 0; + if (addr.IsIPv6LinkLocal || addr.IsIPv6SiteLocal) + { + scope = (int)addr.ScopeId; + } + jnInet6Address ia6 = new jnInet6Address(); + ia6.ipaddress = addr.GetAddressBytes(); + if (scope != 0) + { + ia6._set(scope, netif); + } + addresses[j] = ia6; + } } - ret[i] = new jnNetworkInterface(name, GetIndex(ifaces[i]), addresses); // TODO should implement bindings - ret[i]._set(ifaces[i].Description, new jnInterfaceAddress[0], new jnNetworkInterface[0]); + jnInterfaceAddress[] bindings = new jnInterfaceAddress[0]; + netif._set2(addresses, bindings, new jnNetworkInterface[0]); } NetworkInterfaceInfo nii = new NetworkInterfaceInfo(); nii.dotnetInterfaces = ifaces; |