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.Nsd;
22 /// Interop class for NSD.
24 internal static partial class Interop
29 internal static partial class Nsd
31 internal static class Dnssd
34 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
35 internal delegate void ServiceRegisteredCallback(DnssdError result, uint service, IntPtr userData);
36 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
37 internal delegate void ServiceFoundCallback(DnssdServiceState state, uint service, IntPtr userData);
40 [DllImport(Libraries.Dnssd, EntryPoint = "dnssd_initialize")]
41 internal static extern int Initialize();
42 [DllImport(Libraries.Dnssd, EntryPoint = "dnssd_deinitialize")]
43 internal static extern int Deinitialize();
44 [DllImport(Libraries.Dnssd, EntryPoint = "dnssd_create_local_service")]
45 internal static extern int CreateService(string type, out uint service);
46 [DllImport(Libraries.Dnssd, EntryPoint = "dnssd_destroy_local_service")]
47 internal static extern int DestroyService(uint service);
48 [DllImport(Libraries.Dnssd, EntryPoint = "dnssd_service_set_name")]
49 internal static extern int SetName(uint service, string name);
50 [DllImport(Libraries.Dnssd, EntryPoint = "dnssd_service_set_port")]
51 internal static extern int SetPort(uint service, int port);
52 [DllImport(Libraries.Dnssd, EntryPoint = "dnssd_service_add_txt_record")]
53 internal static extern int AddTxtRecord(uint service, string key, ushort length, byte[] value);
54 [DllImport(Libraries.Dnssd, EntryPoint = "dnssd_service_remove_txt_record")]
55 internal static extern int RemoveTxtRecord(uint service, string key);
56 [DllImport(Libraries.Dnssd, EntryPoint = "dnssd_service_set_record")]
57 internal static extern int SetRecord(uint service, ushort type, ushort length, byte[] data);
58 [DllImport(Libraries.Dnssd, EntryPoint = "dnssd_service_unset_record")]
59 internal static extern int UnsetRecord(uint service, ushort type);
60 [DllImport(Libraries.Dnssd, EntryPoint = "dnssd_register_local_service")]
61 internal static extern int RegisterService(uint service, ServiceRegisteredCallback callback, IntPtr userData);
62 [DllImport(Libraries.Dnssd, EntryPoint = "dnssd_deregister_local_service")]
63 internal static extern int DeregisterService(uint service);
64 [DllImport(Libraries.Dnssd, EntryPoint = "dnssd_start_browsing_service")]
65 internal static extern int StartBrowsing(string type, out uint browser, ServiceFoundCallback callback, IntPtr userData);
66 [DllImport(Libraries.Dnssd, EntryPoint = "dnssd_stop_browsing_service")]
67 internal static extern int StopBrowsing(uint browser);
68 [DllImport(Libraries.Dnssd, EntryPoint = "dnssd_service_get_type")]
69 internal static extern int GetType(uint service, out string type);
70 [DllImport(Libraries.Dnssd, EntryPoint = "dnssd_service_get_name")]
71 internal static extern int GetName(uint service, out string name);
72 [DllImport(Libraries.Dnssd, EntryPoint = "dnssd_service_get_ip")]
73 internal static extern int GetIP(uint service, out string ipV4, out string ipV6);
74 [DllImport(Libraries.Dnssd, EntryPoint = "dnssd_service_get_port")]
75 internal static extern int GetPort(uint service, out int port);
76 [DllImport(Libraries.Dnssd, EntryPoint = "dnssd_service_get_all_txt_record")]
77 internal static extern int GetAllTxtRecord(uint service, out ushort length, out IntPtr value);
80 internal static class Ssdp
83 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
84 internal delegate void ServiceRegisteredCallback(SsdpError result, uint service, IntPtr userData);
85 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
86 internal delegate void ServiceFoundCallback(SsdpServiceState state, uint service, IntPtr userData);
89 [DllImport(Libraries.Ssdp, EntryPoint = "ssdp_initialize")]
90 internal static extern int Initialize();
91 [DllImport(Libraries.Ssdp, EntryPoint = "ssdp_deinitialize")]
92 internal static extern int Deinitialize();
93 [DllImport(Libraries.Ssdp, EntryPoint = "ssdp_create_local_service")]
94 internal static extern int CreateService(string target, out uint service);
95 [DllImport(Libraries.Ssdp, EntryPoint = "ssdp_destroy_local_service")]
96 internal static extern int DestroyService(uint service);
97 [DllImport(Libraries.Ssdp, EntryPoint = "ssdp_service_set_usn")]
98 internal static extern int SetUsn(uint service, string usn);
99 [DllImport(Libraries.Ssdp, EntryPoint = "ssdp_service_set_url")]
100 internal static extern int SetUrl(uint service, string url);
101 [DllImport(Libraries.Ssdp, EntryPoint = "ssdp_service_get_target")]
102 internal static extern int GetTarget(uint service, out string target);
103 [DllImport(Libraries.Ssdp, EntryPoint = "ssdp_service_get_usn")]
104 internal static extern int GetUsn(uint service, out string usn);
105 [DllImport(Libraries.Ssdp, EntryPoint = "ssdp_service_get_url")]
106 internal static extern int GetUrl(uint service, out string url);
107 [DllImport(Libraries.Ssdp, EntryPoint = "ssdp_register_local_service")]
108 internal static extern int RegisterService(uint service, ServiceRegisteredCallback callback, IntPtr userData);
109 [DllImport(Libraries.Ssdp, EntryPoint = "ssdp_deregister_local_service")]
110 internal static extern int DeregisterService(uint service);
111 [DllImport(Libraries.Ssdp, EntryPoint = "ssdp_start_browsing_service")]
112 internal static extern int StartBrowsing(string target, out uint browser, ServiceFoundCallback callback, IntPtr userData);
113 [DllImport(Libraries.Ssdp, EntryPoint = "ssdp_stop_browsing_service")]
114 internal static extern int StopBrowsing(uint browser);
117 internal static partial class Libc
119 [DllImport(Libraries.Libc, EntryPoint = "free")]
120 public static extern void Free(IntPtr userData);
123 internal static partial class Glib
125 [DllImport(Libraries.Glib, EntryPoint = "g_free", CallingConvention = CallingConvention.Cdecl)]
126 public static extern void Free(IntPtr userData);