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_add_route_entry")]
79 public static extern int AddRoute(IntPtr handle, AddressFamily family, string interfaceName, string address, string gateway);
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);
84 [DllImport(Libraries.Connection, EntryPoint = "connection_set_type_changed_cb")]
85 public static extern int SetTypeChangedCallback(IntPtr handle, ConnectionTypeChangedCallback callback, IntPtr userData);
87 [DllImport(Libraries.Connection, EntryPoint = "connection_set_ip_address_changed_cb")]
88 public static extern int SetIPAddressChangedCallback(IntPtr handle, ConnectionAddressChangedCallback callback, IntPtr userData);
90 [DllImport(Libraries.Connection, EntryPoint = "connection_set_ethernet_cable_state_chaged_cb")]
91 public static extern int SetEthernetCableStateChagedCallback(IntPtr handle, EthernetCableStateChangedCallback callback, IntPtr userData);
93 [DllImport(Libraries.Connection, EntryPoint = "connection_set_proxy_address_changed_cb")]
94 public static extern int SetProxyAddressChangedCallback(IntPtr handle, ConnectionAddressChangedCallback callback, IntPtr userData);
96 [DllImport(Libraries.Connection, EntryPoint = "connection_unset_type_changed_cb")]
97 public static extern int UnsetTypeChangedCallback(IntPtr handle);
99 [DllImport(Libraries.Connection, EntryPoint = "connection_unset_ip_address_changed_cb")]
100 public static extern int UnsetIPAddressChangedCallback(IntPtr handle);
102 [DllImport(Libraries.Connection, EntryPoint = "connection_unset_ethernet_cable_state_chaged_cb")]
103 public static extern int UnsetEthernetCableStateChagedCallback(IntPtr handle);
105 [DllImport(Libraries.Connection, EntryPoint = "connection_unset_proxy_address_changed_cb")]
106 public static extern int UnsetProxyAddressChangedCallback(IntPtr handle);
108 [DllImport(Libraries.Connection, EntryPoint = "connection_add_profile")]
109 public static extern int AddProfile(IntPtr handle, IntPtr profileHandle);
111 [DllImport(Libraries.Connection, EntryPoint = "connection_remove_profile")]
112 public static extern int RemoveProfile(IntPtr handle, IntPtr profileHandle);
114 [DllImport(Libraries.Connection, EntryPoint = "connection_update_profile")]
115 public static extern int UpdateProfile(IntPtr handle, IntPtr profileHandle);
117 [DllImport(Libraries.Connection, EntryPoint = "connection_get_default_cellular_service_profile")]
118 public static extern int GetDefaultCellularServiceProfile(IntPtr handle, int type, out IntPtr profileHandle);
120 [DllImport(Libraries.Connection, EntryPoint = "connection_get_current_profile")]
121 public static extern int GetCurrentProfile(IntPtr handle, out IntPtr profileHandle);
123 [DllImport(Libraries.Connection, EntryPoint = "connection_open_profile")]
124 public static extern int OpenProfile(IntPtr handle, IntPtr profileHandle, ConnectionCallback callback, IntPtr userData);
126 [DllImport(Libraries.Connection, EntryPoint = "connection_close_profile")]
127 public static extern int CloseProfile(IntPtr handle, IntPtr profileHandle, ConnectionCallback callback, IntPtr userData);
129 [DllImport(Libraries.Connection, EntryPoint = "connection_reset_profile")]
130 public static extern int ResetProfile(IntPtr handle, int Option, int Id, ConnectionCallback callback, IntPtr userData);
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);
135 [DllImport(Libraries.Connection, EntryPoint = "connection_get_profile_iterator")]
136 public static extern int GetProfileIterator(IntPtr handle, int type, out IntPtr iterHandle);
138 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_iterator_next")]
139 public static extern int GetNextProfileIterator(IntPtr iterHandle, out IntPtr profileHandle);
141 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_iterator_has_next")]
142 public static extern bool HasNextProfileIterator(IntPtr iterHandle);
144 [DllImport(Libraries.Connection, EntryPoint = "connection_destroy_profile_iterator")]
145 public static extern int DestroyProfileIterator(IntPtr iterHandle);
148 internal static partial class ConnectionProfile
150 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
151 public delegate void ProfileStateChangedCallback(ProfileState type, IntPtr userData);
153 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_create")]
154 public static extern int Create(int ProfileType, string Keyword, out IntPtr profileHandle);
156 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_clone")]
157 public static extern int Clone(out IntPtr cloneHandle, IntPtr profileHandle);
159 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_destroy")]
160 public static extern int Destroy(IntPtr profileHandle);
162 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_id")]
163 public static extern int GetId(IntPtr profileHandle, out IntPtr profileId);
165 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_name")]
166 public static extern int GetName(IntPtr profileHandle, out IntPtr name);
168 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_type")]
169 public static extern int GetType(IntPtr profileHandle, out int type);
171 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_network_interface_name")]
172 public static extern int GetNetworkInterfaceName(IntPtr profileHandle, out IntPtr interfaceName);
174 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_state")]
175 public static extern int GetState(IntPtr profileHandle, out int type);
177 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_ipv6_state")]
178 public static extern int GetIPv6State(IntPtr profileHandle, out int type);
180 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_ip_config_type")]
181 public static extern int GetIPConfigType(IntPtr profileHandle, int family, out int type);
183 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_proxy_type")]
184 public static extern int GetProxyType(IntPtr profileHandle, out int type);
186 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_ip_address")]
187 public static extern int GetIPAddress(IntPtr profileHandle, int family, out IntPtr address);
189 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_subnet_mask")]
190 public static extern int GetSubnetMask(IntPtr profileHandle, int family, out IntPtr address);
192 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_gateway_address")]
193 public static extern int GetGatewayAddress(IntPtr profileHandle, int family, out IntPtr address);
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);
198 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_proxy_address")]
199 public static extern int GetProxyAddress(IntPtr profileHandle, int family, out IntPtr address);
201 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_prefix_length")]
202 public static extern int GetPrefixLength(IntPtr profileHandle, int family, out int length);
204 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_dns_config_type")]
205 public static extern int GetDnsConfigType(IntPtr profileHandle, int family, out int type);
207 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_dhcp_server_address")]
208 public static extern int GetDhcpServerAddress(IntPtr profileHandle, AddressFamily family, out string dhcpServerAddress);
210 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_refresh")]
211 public static extern int Refresh(IntPtr profileHandle);
213 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_ip_config_type")]
214 public static extern int SetIPConfigType(IntPtr profileHandle, int family, int type);
216 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_proxy_type")]
217 public static extern int SetProxyType(IntPtr profileHandle, int type);
219 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_ip_address")]
220 public static extern int SetIPAddress(IntPtr profileHandle, int family, string address);
222 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_subnet_mask")]
223 public static extern int SetSubnetMask(IntPtr profileHandle, int family, string address);
225 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_gateway_address")]
226 public static extern int SetGatewayAddress(IntPtr profileHandle, int family, string address);
228 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_dns_address")]
229 public static extern int SetDnsAddress(IntPtr profileHandle, int order, int family, string address);
231 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_proxy_address")]
232 public static extern int SetProxyAddress(IntPtr profileHandle, int family, string address);
234 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_prefix_length")]
235 public static extern int SetPrefixLength(IntPtr profileHandle, int family, int length);
237 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_dns_config_type")]
238 public static extern int SetDnsConfigType(IntPtr profileHandle, int family, int type);
240 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_state_changed_cb")]
241 public static extern int SetStateChangeCallback(IntPtr profileHandle, ProfileStateChangedCallback callback, IntPtr userData);
243 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_unset_state_changed_cb")]
244 public static extern int UnsetStateChangeCallback(IntPtr profileHandle);
247 internal static partial class ConnectionCellularProfile
249 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_cellular_service_type")]
250 public static extern int GetServiceType(IntPtr profileHandle, out int type);
252 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_cellular_apn")]
253 public static extern int GetApn(IntPtr profileHandle, out IntPtr apn);
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);
258 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_cellular_home_url")]
259 public static extern int GetHomeUrl(IntPtr profileHandle, out IntPtr homeUrl);
261 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_cellular_pdn_type")]
262 public static extern int GetPdnType(IntPtr profileHandle, out int pdnType);
264 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_cellular_roam_pdn_type")]
265 public static extern int GetRoamingPdnType(IntPtr profileHandle, out int roamPdnType);
267 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_is_cellular_roaming")]
268 public static extern int IsRoaming(IntPtr profileHandle, out bool roaming);
270 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_is_cellular_hidden")]
271 public static extern int IsHidden(IntPtr profileHandle, out bool hidden);
273 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_is_cellular_editable")]
274 public static extern int IsEditable(IntPtr profileHandle, out bool editable);
276 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_is_cellular_default")]
277 public static extern int IsDefault(IntPtr profileHandle, out bool isDefault);
279 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_cellular_service_type")]
280 public static extern int SetServiceType(IntPtr profileHandle, int type);
282 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_cellular_apn")]
283 public static extern int SetApn(IntPtr profileHandle, string apn);
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);
288 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_cellular_home_url")]
289 public static extern int SetHomeUrl(IntPtr profileHandle, string homeUrl);
291 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_cellular_pdn_type")]
292 public static extern int SetPdnType(IntPtr profileHandle, int pdnType);
294 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_cellular_roam_pdn_type")]
295 public static extern int SetRoamingPdnType(IntPtr profileHandle, int roamPdnType);
298 internal static partial class ConnectionWiFiProfile
300 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_essid")]
301 public static extern int GetEssid(IntPtr profileHandle, out IntPtr essid);
303 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_bssid")]
304 public static extern int GetBssid(IntPtr profileHandle, out IntPtr bssid);
306 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_rssi")]
307 public static extern int GetRssi(IntPtr profileHandle, out int rssi);
309 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_frequency")]
310 public static extern int GetFrequency(IntPtr profileHandle, out int frequency);
312 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_max_speed")]
313 public static extern int GetMaxSpeed(IntPtr profileHandle, out int maxSpeed);
315 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_security_type")]
316 public static extern int GetSecurityType(IntPtr profileHandle, out int type);
318 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_wifi_encryption_type")]
319 public static extern int GetEncryptionType(IntPtr profileHandle, out int type);
321 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_is_wifi_passphrase_required")]
322 public static extern int IsRequiredPassphrase(IntPtr profileHandle, out bool required);
324 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_wifi_passphrase")]
325 public static extern int SetPassphrase(IntPtr profileHandle, string passphrase);
327 [DllImport(Libraries.Connection, EntryPoint = "connection_profile_is_wifi_wps_supported")]
328 public static extern int IsSupportedWps(IntPtr profileHandle, out bool supported);
331 internal static partial class Libc
333 [DllImport(Libraries.Libc, EntryPoint = "free")]
334 public static extern void Free(IntPtr userData);