Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / Tizen.Network.Connection / Interop / Interop.Connection.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 using System;
18 using System.Runtime.InteropServices;
19 using Tizen.Network.Connection;
20
21 internal static partial class Interop
22 {
23     internal static partial class Connection
24     {
25         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
26         public delegate void ConnectionTypeChangedCallback(ConnectionType type, IntPtr userData);
27         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
28         public delegate void EthernetCableStateChangedCallback(EthernetCableState state, IntPtr userData);
29         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
30         public delegate void ConnectionAddressChangedCallback(IntPtr ipv4, IntPtr ipv6, IntPtr userData);
31         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
32         public delegate void ConnectionCallback(ConnectionError result, IntPtr userData);
33         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
34         public delegate bool IPv6AddressCallback(IntPtr ipv6, IntPtr userData);
35
36         [DllImport(Libraries.Connection, EntryPoint = "connection_create")]
37         public static extern int Create(out IntPtr handle);
38
39         [DllImport(Libraries.Connection, EntryPoint = "connection_destroy")]
40         public static extern int Destroy(IntPtr handle);
41
42         [DllImport(Libraries.Connection, EntryPoint = "connection_get_type")]
43         public static extern int GetType(IntPtr handle, out int type);
44
45         [DllImport(Libraries.Connection, EntryPoint = "connection_get_ip_address")]
46         public static extern int GetIPAddress(IntPtr handle, int family, out IntPtr address);
47
48         [DllImport(Libraries.Connection, EntryPoint = "connection_foreach_ipv6_address")]
49         public static extern int GetAllIPv6Addresses(IntPtr handle, int type, IPv6AddressCallback callback, IntPtr userData);
50
51         [DllImport(Libraries.Connection, EntryPoint = "connection_get_proxy")]
52         public static extern int GetProxy(IntPtr handle, int family, out IntPtr address);
53
54         [DllImport(Libraries.Connection, EntryPoint = "connection_get_mac_address")]
55         public static extern int GetMacAddress(IntPtr handle, int family, out IntPtr address);
56
57         [DllImport(Libraries.Connection, EntryPoint = "connection_get_wifi_state")]
58         public static extern int GetWiFiState(IntPtr handle, out int state);
59
60         [DllImport(Libraries.Connection, EntryPoint = "connection_get_cellular_state")]
61         public static extern int GetCellularState(IntPtr handle, out int state);
62
63         [DllImport(Libraries.Connection, EntryPoint = "connection_get_ethernet_state")]
64         public static extern int GetEthernetState(IntPtr handle, out int state);
65
66         [DllImport(Libraries.Connection, EntryPoint = "connection_get_ethernet_cable_state")]
67         public static extern int GetEthernetCableState(IntPtr handle, out int state);
68
69         [DllImport(Libraries.Connection, EntryPoint = "connection_get_bt_state")]
70         public static extern int GetBtState(IntPtr handle, out int state);
71
72         [DllImport(Libraries.Connection, EntryPoint = "connection_get_statistics")]
73         public static extern int GetStatistics(IntPtr handle, int connectionType, int statisticsType, out long size);
74
75         [DllImport(Libraries.Connection, EntryPoint = "connection_reset_statistics")]
76         public static extern int ResetStatistics(IntPtr handle, int connectionType, int statisticsType);
77
78         [DllImport(Libraries.Connection, EntryPoint = "connection_add_route_entry")]
79         public static extern int AddRoute(IntPtr handle, AddressFamily family, string interfaceName, string address, string gateway);
80
81         [DllImport(Libraries.Connection, EntryPoint = "connection_remove_route_entry")]
82         public static extern int RemoveRoute(IntPtr handle, AddressFamily family, string interfaceName, string address, string gateway);
83
84         [DllImport(Libraries.Connection, EntryPoint = "connection_set_type_changed_cb")]
85         public static extern int SetTypeChangedCallback(IntPtr handle, ConnectionTypeChangedCallback callback, IntPtr userData);
86
87         [DllImport(Libraries.Connection, EntryPoint = "connection_set_ip_address_changed_cb")]
88         public static extern int SetIPAddressChangedCallback(IntPtr handle, ConnectionAddressChangedCallback callback, IntPtr userData);
89
90         [DllImport(Libraries.Connection, EntryPoint = "connection_set_ethernet_cable_state_chaged_cb")]
91         public static extern int SetEthernetCableStateChagedCallback(IntPtr handle, EthernetCableStateChangedCallback callback, IntPtr userData);
92
93         [DllImport(Libraries.Connection, EntryPoint = "connection_set_proxy_address_changed_cb")]
94         public static extern int SetProxyAddressChangedCallback(IntPtr handle, ConnectionAddressChangedCallback callback, IntPtr userData);
95
96         [DllImport(Libraries.Connection, EntryPoint = "connection_unset_type_changed_cb")]
97         public static extern int UnsetTypeChangedCallback(IntPtr handle);
98
99         [DllImport(Libraries.Connection, EntryPoint = "connection_unset_ip_address_changed_cb")]
100         public static extern int UnsetIPAddressChangedCallback(IntPtr handle);
101
102         [DllImport(Libraries.Connection, EntryPoint = "connection_unset_ethernet_cable_state_chaged_cb")]
103         public static extern int UnsetEthernetCableStateChagedCallback(IntPtr handle);
104
105         [DllImport(Libraries.Connection, EntryPoint = "connection_unset_proxy_address_changed_cb")]
106         public static extern int UnsetProxyAddressChangedCallback(IntPtr handle);
107
108         [DllImport(Libraries.Connection, EntryPoint = "connection_add_profile")]
109         public static extern int AddProfile(IntPtr handle, IntPtr profileHandle);
110
111         [DllImport(Libraries.Connection, EntryPoint = "connection_remove_profile")]
112         public static extern int RemoveProfile(IntPtr handle, IntPtr profileHandle);
113
114         [DllImport(Libraries.Connection, EntryPoint = "connection_update_profile")]
115         public static extern int UpdateProfile(IntPtr handle, IntPtr profileHandle);
116
117         [DllImport(Libraries.Connection, EntryPoint = "connection_get_default_cellular_service_profile")]
118         public static extern int GetDefaultCellularServiceProfile(IntPtr handle, int type, out IntPtr profileHandle);
119
120         [DllImport(Libraries.Connection, EntryPoint = "connection_get_current_profile")]
121         public static extern int GetCurrentProfile(IntPtr handle, out IntPtr profileHandle);
122
123         [DllImport(Libraries.Connection, EntryPoint = "connection_open_profile")]
124         public static extern int OpenProfile(IntPtr handle, IntPtr profileHandle, ConnectionCallback callback, IntPtr userData);
125
126         [DllImport(Libraries.Connection, EntryPoint = "connection_close_profile")]
127         public static extern int CloseProfile(IntPtr handle, IntPtr profileHandle, ConnectionCallback callback, IntPtr userData);
128
129         [DllImport(Libraries.Connection, EntryPoint = "connection_reset_profile")]
130         public static extern int ResetProfile(IntPtr handle, int Option, int Id, ConnectionCallback callback, IntPtr userData);
131
132         [DllImport(Libraries.Connection, EntryPoint = "connection_set_default_cellular_service_profile_async")]
133         public static extern int SetDefaultCellularServiceProfileAsync(IntPtr handle, int Type, IntPtr profileHandle, ConnectionCallback callback, IntPtr userData);
134
135         [DllImport(Libraries.Connection, EntryPoint = "connection_get_profile_iterator")]
136         public static extern int GetProfileIterator(IntPtr handle, int type, out IntPtr iterHandle);
137
138         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_iterator_next")]
139         public static extern int GetNextProfileIterator(IntPtr iterHandle, out IntPtr profileHandle);
140
141         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_iterator_has_next")]
142         public static extern bool HasNextProfileIterator(IntPtr iterHandle);
143
144         [DllImport(Libraries.Connection, EntryPoint = "connection_destroy_profile_iterator")]
145         public static extern int DestroyProfileIterator(IntPtr iterHandle);
146     }
147
148     internal static partial class ConnectionProfile
149     {
150         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
151         public delegate void ProfileStateChangedCallback(ProfileState type, IntPtr userData);
152
153         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_create")]
154         public static extern int Create(int ProfileType, string Keyword, out IntPtr profileHandle);
155
156         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_clone")]
157         public static extern int Clone(out IntPtr cloneHandle, IntPtr profileHandle);
158
159         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_destroy")]
160         public static extern int Destroy(IntPtr profileHandle);
161
162         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_id")]
163         public static extern int GetId(IntPtr profileHandle, out IntPtr profileId);
164
165         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_name")]
166         public static extern int GetName(IntPtr profileHandle, out IntPtr name);
167
168         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_type")]
169         public static extern int GetType(IntPtr profileHandle, out int type);
170
171         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_network_interface_name")]
172         public static extern int GetNetworkInterfaceName(IntPtr profileHandle, out IntPtr interfaceName);
173
174         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_state")]
175         public static extern int GetState(IntPtr profileHandle, out int type);
176
177         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_ipv6_state")]
178         public static extern int GetIPv6State(IntPtr profileHandle, out int type);
179
180         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_ip_config_type")]
181         public static extern int GetIPConfigType(IntPtr profileHandle, int family, out int type);
182
183         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_proxy_type")]
184         public static extern int GetProxyType(IntPtr profileHandle, out int type);
185
186         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_ip_address")]
187         public static extern int GetIPAddress(IntPtr profileHandle, int family, out IntPtr address);
188
189         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_subnet_mask")]
190         public static extern int GetSubnetMask(IntPtr profileHandle, int family, out IntPtr address);
191
192         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_gateway_address")]
193         public static extern int GetGatewayAddress(IntPtr profileHandle, int family, out IntPtr address);
194
195         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_dns_address")]
196         public static extern int GetDnsAddress(IntPtr profileHandle, int order, int Family, out IntPtr address);
197
198         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_proxy_address")]
199         public static extern int GetProxyAddress(IntPtr profileHandle, int family, out IntPtr address);
200
201         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_prefix_length")]
202         public static extern int GetPrefixLength(IntPtr profileHandle, int family, out int length);
203
204         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_dns_config_type")]
205         public static extern int GetDnsConfigType(IntPtr profileHandle, int family, out int type);
206
207         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_dhcp_server_address")]
208         public static extern int GetDhcpServerAddress(IntPtr profileHandle, AddressFamily family, out string dhcpServerAddress);
209
210         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_refresh")]
211         public static extern int Refresh(IntPtr profileHandle);
212
213         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_ip_config_type")]
214         public static extern int SetIPConfigType(IntPtr profileHandle, int family, int type);
215
216         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_proxy_type")]
217         public static extern int SetProxyType(IntPtr profileHandle, int type);
218
219         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_ip_address")]
220         public static extern int SetIPAddress(IntPtr profileHandle, int family, string address);
221
222         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_subnet_mask")]
223         public static extern int SetSubnetMask(IntPtr profileHandle, int family, string address);
224
225         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_gateway_address")]
226         public static extern int SetGatewayAddress(IntPtr profileHandle, int family, string address);
227
228         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_dns_address")]
229         public static extern int SetDnsAddress(IntPtr profileHandle, int order, int family, string address);
230
231         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_proxy_address")]
232         public static extern int SetProxyAddress(IntPtr profileHandle, int family, string address);
233
234         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_prefix_length")]
235         public static extern int SetPrefixLength(IntPtr profileHandle, int family, int length);
236
237         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_dns_config_type")]
238         public static extern int SetDnsConfigType(IntPtr profileHandle, int family, int type);
239
240         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_state_changed_cb")]
241         public static extern int SetStateChangeCallback(IntPtr profileHandle, ProfileStateChangedCallback callback, IntPtr userData);
242
243         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_unset_state_changed_cb")]
244         public static extern int UnsetStateChangeCallback(IntPtr profileHandle);
245     }
246
247     internal static partial class ConnectionCellularProfile
248     {
249         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_cellular_service_type")]
250         public static extern int GetServiceType(IntPtr profileHandle, out int type);
251
252         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_cellular_apn")]
253         public static extern int GetApn(IntPtr profileHandle, out IntPtr apn);
254
255         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_cellular_auth_info")]
256         public static extern int GetAuthInfo(IntPtr profileHandle, out int authType, out string name, out string password);
257
258         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_cellular_home_url")]
259         public static extern int GetHomeUrl(IntPtr profileHandle, out IntPtr homeUrl);
260
261         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_cellular_pdn_type")]
262         public static extern int GetPdnType(IntPtr profileHandle, out int pdnType);
263
264         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_cellular_roam_pdn_type")]
265         public static extern int GetRoamingPdnType(IntPtr profileHandle, out int roamPdnType);
266
267         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_is_cellular_roaming")]
268         public static extern int IsRoaming(IntPtr profileHandle, out bool roaming);
269
270         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_is_cellular_hidden")]
271         public static extern int IsHidden(IntPtr profileHandle, out bool hidden);
272
273         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_is_cellular_editable")]
274         public static extern int IsEditable(IntPtr profileHandle, out bool editable);
275
276         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_is_cellular_default")]
277         public static extern int IsDefault(IntPtr profileHandle, out bool isDefault);
278
279         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_cellular_service_type")]
280         public static extern int SetServiceType(IntPtr profileHandle, int type);
281
282         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_cellular_apn")]
283         public static extern int SetApn(IntPtr profileHandle, string apn);
284
285         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_cellular_auth_info")]
286         public static extern int SetAuthInfo(IntPtr profileHandle, int authType, string name, string password);
287
288         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_cellular_home_url")]
289         public static extern int SetHomeUrl(IntPtr profileHandle, string homeUrl);
290
291         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_cellular_pdn_type")]
292         public static extern int SetPdnType(IntPtr profileHandle, int pdnType);
293
294         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_cellular_roam_pdn_type")]
295         public static extern int SetRoamingPdnType(IntPtr profileHandle, int roamPdnType);
296     }
297
298     internal static partial class ConnectionWiFiProfile
299     {
300         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_essid")]
301         public static extern int GetEssid(IntPtr profileHandle, out IntPtr essid);
302
303         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_bssid")]
304         public static extern int GetBssid(IntPtr profileHandle, out IntPtr bssid);
305
306         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_rssi")]
307         public static extern int GetRssi(IntPtr profileHandle, out int rssi);
308
309         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_frequency")]
310         public static extern int GetFrequency(IntPtr profileHandle, out int frequency);
311
312         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_max_speed")]
313         public static extern int GetMaxSpeed(IntPtr profileHandle, out int maxSpeed);
314
315         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_security_type")]
316         public static extern int GetSecurityType(IntPtr profileHandle, out int type);
317
318         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_encryption_type")]
319         public static extern int GetEncryptionType(IntPtr profileHandle, out int type);
320
321         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_is_wifi_passphrase_required")]
322         public static extern int IsRequiredPassphrase(IntPtr profileHandle, out bool required);
323
324         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_wifi_passphrase")]
325         public static extern int SetPassphrase(IntPtr profileHandle, string passphrase);
326
327         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_is_wifi_wps_supported")]
328         public static extern int IsSupportedWps(IntPtr profileHandle, out bool supported);
329     }
330         
331     internal static partial class Libc
332     {
333         [DllImport(Libraries.Libc, EntryPoint = "free")]
334         public static extern void Free(IntPtr userData);
335
336     }
337 }