Add new properties 46/124346/4 submit/tizen/20170510.102854
authorchleun.moon <chleun.moon@samsung.com>
Tue, 11 Apr 2017 06:58:13 +0000 (15:58 +0900)
committerchleun.moon <chleun.moon@samsung.com>
Thu, 13 Apr 2017 06:13:56 +0000 (15:13 +0900)
1. Add GetAllIPv6Addresses() to WiFiNetwork
2. Add PrefixLength to WiFiAddressInformation
3. Add DnsConfigType to WiFiAddressInformation

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

index c204508..85f5418 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")]
@@ -329,4 +339,10 @@ internal static partial class Interop
             }
         }
     }
+
+    internal static partial class Libc
+    {
+        [DllImport(Libraries.Libc, EntryPoint = "free")]
+        public static extern void Free(IntPtr userData);
+    }
 }
index 94f003c..69c861e 100644 (file)
@@ -1,11 +1,11 @@
-{
-  "dependencies": {
-    "NETStandard.Library": "1.6.1",
-    "System.Threading.Thread": "4.3.0",
-    "Tizen": "1.0.2",
-    "Tizen.Network.Connection": "1.0.10"
-  },
-  "frameworks": {
-    "netstandard1.3": {}
-  }
-}
+{\r
+  "dependencies": {\r
+    "NETStandard.Library": "1.6.1",\r
+    "System.Threading.Thread": "4.3.0",\r
+    "Tizen": "1.0.2",\r
+    "Tizen.Network.Connection": "1.0.14"\r
+  },\r
+  "frameworks": {\r
+    "netstandard1.3": {}\r
+  }\r
+}\r
index 716a5df..fb6c63d 100755 (executable)
@@ -187,5 +187,54 @@ 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);
+                    WiFiErrorFactory.ThrowWiFiException(ret);
+                }
+                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);
+                }
+            }
+        }
+
+        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);
+                    WiFiErrorFactory.ThrowWiFiException(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);
+                }
+            }
+        }
     }
 }
index 49319bc..652a924 100755 (executable)
@@ -251,6 +251,36 @@ 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>
+        /// <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);
+            }
+
+            return ipList;
+        }
+
         internal WiFiNetwork(Interop.WiFi.SafeWiFiAPHandle apHandle)
         {
             _apHandle = apHandle;
index e3ccc1d..16c078c 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       csapi-network-wifi
 Summary:    Tizen Wi-Fi API for C#
-Version:    1.0.12
+Version:    1.0.13
 Release:    1
 Group:      Development/Libraries
 License:    Apache-2.0