2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 using System.Runtime.InteropServices;
19 using Tizen.Network.Connection;
21 internal static partial class Interop
23 internal static partial class Connection
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);
36 [DllImport(Libraries.Connection, EntryPoint = "connection_create")]
37 public static extern int Create(out IntPtr handle);
39 [DllImport(Libraries.Connection, EntryPoint = "connection_destroy")]
40 public static extern int Destroy(IntPtr handle);
42 [DllImport(Libraries.Connection, EntryPoint = "connection_get_type")]
43 public static extern int GetType(IntPtr handle, out int type);
45 [DllImport(Libraries.Connection, EntryPoint = "connection_get_ip_address")]
46 public static extern int GetIPAddress(IntPtr handle, int family, out IntPtr address);
48 [DllImport(Libraries.Connection, EntryPoint = "connection_foreach_ipv6_address")]
49 public static extern int GetAllIPv6Addresses(IntPtr handle, int type, IPv6AddressCallback callback, IntPtr userData);
51 [DllImport(Libraries.Connection, EntryPoint = "connection_get_proxy")]
52 public static extern int GetProxy(IntPtr handle, int family, out IntPtr address);
54 [DllImport(Libraries.Connection, EntryPoint = "connection_get_mac_address")]
55 public static extern int GetMacAddress(IntPtr handle, int family, out IntPtr address);
57 [DllImport(Libraries.Connection, EntryPoint = "connection_get_wifi_state")]
58 public static extern int GetWiFiState(IntPtr handle, out int state);
60 [DllImport(Libraries.Connection, EntryPoint = "connection_get_cellular_state")]
61 public static extern int GetCellularState(IntPtr handle, out int state);
63 [DllImport(Libraries.Connection, EntryPoint = "connection_get_ethernet_state")]
64 public static extern int GetEthernetState(IntPtr handle, out int state);
66 [DllImport(Libraries.Connection, EntryPoint = "connection_get_ethernet_cable_state")]
67 public static extern int GetEthernetCableState(IntPtr handle, out int state);
69 [DllImport(Libraries.Connection, EntryPoint = "connection_get_bt_state")]
70 public static extern int GetBtState(IntPtr handle, out int state);
72 [DllImport(Libraries.Connection, EntryPoint = "connection_get_statistics")]
73 public static extern int GetStatistics(IntPtr handle, int connectionType, int statisticsType, out long size);
75 [DllImport(Libraries.Connection, EntryPoint = "connection_reset_statistics")]
76 public static extern int ResetStatistics(IntPtr handle, int connectionType, int statisticsType);
78 [DllImport(Libraries.Connection, EntryPoint = "connection_set_type_changed_cb")]
79 public static extern int SetTypeChangedCallback(IntPtr handle, ConnectionTypeChangedCallback callback, IntPtr userData);
81 [DllImport(Libraries.Connection, EntryPoint = "connection_set_ip_address_changed_cb")]
82 public static extern int SetIPAddressChangedCallback(IntPtr handle, ConnectionAddressChangedCallback callback, IntPtr userData);
84 [DllImport(Libraries.Connection, EntryPoint = "connection_set_ethernet_cable_state_chaged_cb")]
85 public static extern int SetEthernetCableStateChagedCallback(IntPtr handle, EthernetCableStateChangedCallback callback, IntPtr userData);
87 [DllImport(Libraries.Connection, EntryPoint = "connection_set_proxy_address_changed_cb")]
88 public static extern int SetProxyAddressChangedCallback(IntPtr handle, ConnectionAddressChangedCallback callback, IntPtr userData);
90 [DllImport(Libraries.Connection, EntryPoint = "connection_unset_type_changed_cb")]
91 public static extern int UnsetTypeChangedCallback(IntPtr handle);
93 [DllImport(Libraries.Connection, EntryPoint = "connection_unset_ip_address_changed_cb")]
94 public static extern int UnsetIPAddressChangedCallback(IntPtr handle);
96 [DllImport(Libraries.Connection, EntryPoint = "connection_unset_ethernet_cable_state_chaged_cb")]
97 public static extern int UnsetEthernetCableStateChagedCallback(IntPtr handle);
99 [DllImport(Libraries.Connection, EntryPoint = "connection_unset_proxy_address_changed_cb")]
100 public static extern int UnsetProxyAddressChangedCallback(IntPtr handle);
102 [DllImport(Libraries.Connection, EntryPoint = "connection_add_profile")]
103 public static extern int AddProfile(IntPtr handle, IntPtr profileHandle);
105 [DllImport(Libraries.Connection, EntryPoint = "connection_remove_profile")]
106 public static extern int RemoveProfile(IntPtr handle, IntPtr profileHandle);
108 [DllImport(Libraries.Connection, EntryPoint = "connection_update_profile")]
109 public static extern int UpdateProfile(IntPtr handle, IntPtr profileHandle);
111 [DllImport(Libraries.Connection, EntryPoint = "connection_get_default_cellular_service_profile")]
112 public static extern int GetDefaultCellularServiceProfile(IntPtr handle, int type, out IntPtr profileHandle);
114 [DllImport(Libraries.Connection, EntryPoint = "connection_get_current_profile")]
115 public static extern int GetCurrentProfile(IntPtr handle, out IntPtr profileHandle);
117 [DllImport(Libraries.Connection, EntryPoint = "connection_open_profile")]
118 public static extern int OpenProfile(IntPtr handle, IntPtr profileHandle, ConnectionCallback callback, IntPtr userData);
120 [DllImport(Libraries.Connection, EntryPoint = "connection_close_profile")]
121 public static extern int CloseProfile(IntPtr handle, IntPtr profileHandle, ConnectionCallback callback, IntPtr userData);
123 [DllImport(Libraries.Connection, EntryPoint = "connection_reset_profile")]
124 public static extern int ResetProfile(IntPtr handle, int Option, int Id, ConnectionCallback callback, IntPtr userData);
126 [DllImport(Libraries.Connection, EntryPoint = "connection_set_default_cellular_service_profile_async")]
127 public static extern int SetDefaultCellularServiceProfileAsync(IntPtr handle, int Type, IntPtr profileHandle, ConnectionCallback callback, IntPtr userData);
129 [DllImport(Libraries.Connection, EntryPoint = "connection_get_profile_iterator")]
130 public static extern int GetProfileIterator(IntPtr handle, int type, out IntPtr iterHandle);
132 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_iterator_next")]
133 public static extern int GetNextProfileIterator(IntPtr iterHandle, out IntPtr profileHandle);
135 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_iterator_has_next")]
136 public static extern bool HasNextProfileIterator(IntPtr iterHandle);
138 [DllImport(Libraries.Connection, EntryPoint = "connection_destroy_profile_iterator")]
139 public static extern int DestroyProfileIterator(IntPtr iterHandle);
142 internal static partial class ConnectionProfile
144 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
145 public delegate void ProfileStateChangedCallback(ProfileState type, IntPtr userData);
147 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_create")]
148 public static extern int Create(int ProfileType, string Keyword, out IntPtr profileHandle);
150 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_clone")]
151 public static extern int Clone(out IntPtr cloneHandle, IntPtr profileHandle);
153 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_destroy")]
154 public static extern int Destroy(IntPtr profileHandle);
156 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_id")]
157 public static extern int GetId(IntPtr profileHandle, out IntPtr profileId);
159 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_name")]
160 public static extern int GetName(IntPtr profileHandle, out IntPtr name);
162 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_type")]
163 public static extern int GetType(IntPtr profileHandle, out int type);
165 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_network_interface_name")]
166 public static extern int GetNetworkInterfaceName(IntPtr profileHandle, out IntPtr interfaceName);
168 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_state")]
169 public static extern int GetState(IntPtr profileHandle, out int type);
171 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_ipv6_state")]
172 public static extern int GetIPv6State(IntPtr profileHandle, out int type);
174 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_ip_config_type")]
175 public static extern int GetIPConfigType(IntPtr profileHandle, int family, out int type);
177 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_proxy_type")]
178 public static extern int GetProxyType(IntPtr profileHandle, out int type);
180 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_ip_address")]
181 public static extern int GetIPAddress(IntPtr profileHandle, int family, out IntPtr address);
183 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_subnet_mask")]
184 public static extern int GetSubnetMask(IntPtr profileHandle, int family, out IntPtr address);
186 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_gateway_address")]
187 public static extern int GetGatewayAddress(IntPtr profileHandle, int family, out IntPtr address);
189 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_dns_address")]
190 public static extern int GetDnsAddress(IntPtr profileHandle, int order, int Family, out IntPtr address);
192 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_proxy_address")]
193 public static extern int GetProxyAddress(IntPtr profileHandle, int family, out IntPtr address);
195 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_prefix_length")]
196 public static extern int GetPrefixLength(IntPtr profileHandle, int family, out int length);
198 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_dns_config_type")]
199 public static extern int GetDnsConfigType(IntPtr profileHandle, int family, out int type);
201 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_refresh")]
202 public static extern int Refresh(IntPtr profileHandle);
204 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_ip_config_type")]
205 public static extern int SetIPConfigType(IntPtr profileHandle, int family, int type);
207 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_proxy_type")]
208 public static extern int SetProxyType(IntPtr profileHandle, int type);
210 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_ip_address")]
211 public static extern int SetIPAddress(IntPtr profileHandle, int family, string address);
213 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_subnet_mask")]
214 public static extern int SetSubnetMask(IntPtr profileHandle, int family, string address);
216 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_gateway_address")]
217 public static extern int SetGatewayAddress(IntPtr profileHandle, int family, string address);
219 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_dns_address")]
220 public static extern int SetDnsAddress(IntPtr profileHandle, int family, string address);
222 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_proxy_address")]
223 public static extern int SetProxyAddress(IntPtr profileHandle, int family, string address);
225 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_prefix_length")]
226 public static extern int SetPrefixLength(IntPtr profileHandle, int family, int length);
228 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_dns_config_type")]
229 public static extern int SetDnsConfigType(IntPtr profileHandle, int family, int type);
231 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_state_changed_cb")]
232 public static extern int SetStateChangeCallback(IntPtr profileHandle, ProfileStateChangedCallback callback, IntPtr userData);
234 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_unset_state_changed_cb")]
235 public static extern int UnsetStateChangeCallback(IntPtr profileHandle);
238 internal static partial class ConnectionCellularProfile
240 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_cellular_service_type")]
241 public static extern int GetServiceType(IntPtr profileHandle, out int type);
243 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_cellular_apn")]
244 public static extern int GetApn(IntPtr profileHandle, out IntPtr apn);
246 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_cellular_auth_info")]
247 public static extern int GetAuthInfo(IntPtr profileHandle, out int authType, out IntPtr name, out IntPtr password);
249 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_cellular_home_url")]
250 public static extern int GetHomeUrl(IntPtr profileHandle, out IntPtr homeUrl);
252 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_cellular_pdn_type")]
253 public static extern int GetPdnType(IntPtr profileHandle, out int pdnType);
255 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_cellular_roam_pdn_type")]
256 public static extern int GetRoamingPdnType(IntPtr profileHandle, out int roamPdnType);
258 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_is_cellular_roaming")]
259 public static extern int IsRoaming(IntPtr profileHandle, out bool roaming);
261 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_is_cellular_hidden")]
262 public static extern int IsHidden(IntPtr profileHandle, out bool hidden);
264 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_is_cellular_editable")]
265 public static extern int IsEditable(IntPtr profileHandle, out bool editable);
267 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_is_cellular_default")]
268 public static extern int IsDefault(IntPtr profileHandle, out bool isDefault);
270 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_cellular_service_type")]
271 public static extern int SetServiceType(IntPtr profileHandle, int type);
273 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_cellular_apn")]
274 public static extern int SetApn(IntPtr profileHandle, string apn);
276 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_cellular_auth_info")]
277 public static extern int SetAuthInfo(IntPtr profileHandle, int authType, string name, string password);
279 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_cellular_home_url")]
280 public static extern int SetHomeUrl(IntPtr profileHandle, string homeUrl);
282 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_cellular_pdn_type")]
283 public static extern int SetPdnType(IntPtr profileHandle, int pdnType);
285 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_cellular_roam_pdn_type")]
286 public static extern int SetRoamingPdnType(IntPtr profileHandle, int roamPdnType);
289 internal static partial class ConnectionWiFiProfile
291 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_essid")]
292 public static extern int GetEssid(IntPtr profileHandle, out IntPtr essid);
294 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_bssid")]
295 public static extern int GetBssid(IntPtr profileHandle, out IntPtr bssid);
297 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_rssi")]
298 public static extern int GetRssi(IntPtr profileHandle, out int rssi);
300 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_frequency")]
301 public static extern int GetFrequency(IntPtr profileHandle, out int frequency);
303 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_max_speed")]
304 public static extern int GetMaxSpeed(IntPtr profileHandle, out int maxSpeed);
306 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_security_type")]
307 public static extern int GetSecurityType(IntPtr profileHandle, out int type);
309 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_encryption_type")]
310 public static extern int GetEncryptionType(IntPtr profileHandle, out int type);
312 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_is_wifi_passphrase_required")]
313 public static extern int IsRequiredPassphrase(IntPtr profileHandle, out bool required);
315 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_wifi_passphrase")]
316 public static extern int SetPassphrase(IntPtr profileHandle, string passphrase);
318 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_is_wifi_wps_supported")]
319 public static extern int IsSupportedWps(IntPtr profileHandle, out bool supported);
322 internal static partial class Libc
324 [DllImport(Libraries.Libc, EntryPoint = "free")]
325 public static extern void Free(IntPtr userData);