[TCSACR-11] Add new properties
authorchleun.moon <chleun.moon@samsung.com>
Wed, 31 May 2017 01:44:03 +0000 (10:44 +0900)
committerchleun.moon <chleun.moon@samsung.com>
Fri, 2 Jun 2017 04:56:17 +0000 (13:56 +0900)
1. Add GetAllIPv6Addresses() to WiFiNetwork
2. Add PrefixLength to WiFiAddressInformation
3. Add DnsConfigType to WiFiAddressInformation

Change-Id: Iab80d5cdf9c8e04fe8989b89f1cb7d32220f7d36
Signed-off-by: cheoleun <chleun.moon@samsung.com>
packaging/csapi-network-wifi.spec
src/Tizen.Network.WiFi/Interop/Interop.WiFi.cs
src/Tizen.Network.WiFi/Tizen.Network.WiFi.csproj
src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiAddressInformation.cs
src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiNetwork.cs

index 83b1803..c081be4 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       csapi-network-wifi
 Summary:    Tizen Wi-Fi API for C#
-Version:    1.0.16
+Version:    1.0.17
 Release:    1
 Group:      Development/Libraries
 License:    Apache-2.0
index 049462d..d541abc 100755 (executable)
@@ -135,6 +135,8 @@ internal static partial class Interop
             internal static extern int SetIPConfigType(SafeWiFiAPHandle ap, int addressFamily, int ipConfigType);
             [DllImport(Libraries.WiFi, EntryPoint = "wifi_manager_ap_get_ip_address")]
             internal static extern int GetIPAddress(SafeWiFiAPHandle ap, int addressFamily, out IntPtr ipAddress);
+            [DllImport(Libraries.WiFi, EntryPoint = "wifi_manager_ap_foreach_ipv6_address")]
+            internal static extern int GetAllIPv6Addresses(SafeWiFiAPHandle ap, HandleCallback callback, IntPtr userData);
             [DllImport(Libraries.WiFi, EntryPoint = "wifi_manager_ap_set_ip_address")]
             internal static extern int SetIPAddress(SafeWiFiAPHandle ap, int addressFamily, string ipAddress);
             [DllImport(Libraries.WiFi, EntryPoint = "wifi_manager_ap_get_subnet_mask")]
@@ -157,6 +159,14 @@ internal static partial class Interop
             internal static extern int GetDnsAddress(SafeWiFiAPHandle ap, int order, int addressFamily, out IntPtr dnsAddress);
             [DllImport(Libraries.WiFi, EntryPoint = "wifi_manager_ap_set_dns_address")]
             internal static extern int SetDnsAddress(SafeWiFiAPHandle ap, int order, int addressFamily, string dnsAddress);
+            [DllImport(Libraries.WiFi, EntryPoint = "wifi_manager_ap_get_prefix_length")]
+            internal static extern int GetPrefixLength(SafeWiFiAPHandle ap, int addressFamily, out int length);
+            [DllImport(Libraries.WiFi, EntryPoint = "wifi_manager_ap_set_prefix_length")]
+            internal static extern int SetPrefixLength(SafeWiFiAPHandle ap, int addressFamily, int length);
+            [DllImport(Libraries.WiFi, EntryPoint = "wifi_manager_ap_get_dns_config_type")]
+            internal static extern int GetDnsConfigType(SafeWiFiAPHandle ap, int addressFamily, out int type);
+            [DllImport(Libraries.WiFi, EntryPoint = "wifi_manager_ap_set_dns_config_type")]
+            internal static extern int SetDnsConfigType(SafeWiFiAPHandle ap, int addressFamily, int type);
 
             ////Security Information
             [DllImport(Libraries.WiFi, EntryPoint = "wifi_manager_ap_get_security_type")]
index 0218275..832c85e 100644 (file)
@@ -1,4 +1,4 @@
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
 
   <PropertyGroup>
     <TargetFramework>netstandard1.3</TargetFramework>
@@ -12,7 +12,7 @@
   <ItemGroup>
     <PackageReference Include="System.Threading.Thread" Version="4.3.0" />
     <PackageReference Include="Tizen" Version="1.0.5" />
-    <PackageReference Include="Tizen.Network.Connection" Version="1.0.10" />
+    <PackageReference Include="Tizen.Network.Connection" Version="1.0.18" />
   </ItemGroup>
 
 </Project>
index 895ded4..52cbdaa 100755 (executable)
@@ -193,5 +193,53 @@ namespace Tizen.Network.WiFi
                 }
             }
         }
+
+        public int PrefixLength
+        {
+            get
+            {
+                int Value;
+                int ret = Interop.WiFi.AP.GetPrefixLength(_handle, (int)_family, out Value);
+                if (ret != (int)WiFiError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to get prefix length, " + (WiFiError)ret);
+                    return -1;
+                }
+                return Value;
+            }
+
+            set
+            {
+                int ret = Interop.WiFi.AP.SetPrefixLength(_handle, (int)_family, value);
+                if (ret != (int)WiFiError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to set prefix length, " + (WiFiError)ret);
+                    WiFiErrorFactory.ThrowWiFiException(ret, _handle.DangerousGetHandle());
+                }
+            }
+        }
+
+        public DnsConfigType DnsConfigType
+        {
+            get
+            {
+                int Value;
+                int ret = Interop.WiFi.AP.GetDnsConfigType(_handle, (int)_family, out Value);
+                if ((WiFiError)ret != WiFiError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to get DNS config type, " + (WiFiError)ret);
+                }
+                return (DnsConfigType)Value;
+            }
+            set
+            {
+                int ret = Interop.WiFi.AP.SetDnsConfigType(_handle, (int)_family, (int)value);
+                if ((WiFiError)ret != WiFiError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to set DNS config type, " + (WiFiError)ret);
+                    WiFiErrorFactory.ThrowWiFiException(ret, _handle.DangerousGetHandle());
+                }
+            }
+        }
     }
 }
index 896c497..1b4f8cf 100755 (executable)
@@ -271,6 +271,39 @@ namespace Tizen.Network.WiFi
             }
         }
 
+        /// <summary>
+        /// Gets the all IPv6 addresses of the access point
+        /// </summary>
+        /// <returns>A list of IPv6 addresses of the access point.</returns>
+        /// <feature>http://tizen.org/feature/network.wifi</feature>
+        /// <exception cref="NotSupportedException">Thrown when WiFi is not supported.</exception>
+        /// <exception cref="ArgumentException">Thrown when method is failed due to an invalid parameter.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
+        public IEnumerable<System.Net.IPAddress> GetAllIPv6Addresses()
+        {
+            Log.Debug(Globals.LogTag, "GetAllIPv6Addresses");
+            List<System.Net.IPAddress> ipList = new List<System.Net.IPAddress>();
+            Interop.WiFi.HandleCallback callback = (IntPtr ipv6Address, IntPtr userData) =>
+            {
+                if (ipv6Address != IntPtr.Zero)
+                {
+                    string ipv6 = Marshal.PtrToStringAnsi(ipv6Address);
+                    ipList.Add(System.Net.IPAddress.Parse(ipv6));
+                    return true;
+                }
+                return false;
+            };
+
+            int ret = Interop.WiFi.AP.GetAllIPv6Addresses(_apHandle, callback, IntPtr.Zero);
+            if (ret != (int)WiFiError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to get all IPv6 addresses, Error - " + (WiFiError)ret);
+                WiFiErrorFactory.ThrowWiFiException(ret, _apHandle.DangerousGetHandle());
+            }
+
+            return ipList;
+        }
+
         internal WiFiNetwork(Interop.WiFi.SafeWiFiAPHandle apHandle)
         {
             _apHandle = apHandle;