Mono.Zeroconf – Diff between revs 1 and 2
?pathlinks?
Rev 1 | Rev 2 | |||
---|---|---|---|---|
Line 25... | Line 25... | |||
25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
|
26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
27 | // |
27 | // |
|
Line 28... | Line 28... | |||
28 | |
28 | |
|
- | 29 | using System; |
||
29 | using System; |
30 | using System.Text; |
|
Line 30... | Line 31... | |||
30 | using System.Runtime.InteropServices; |
31 | using System.Runtime.InteropServices; |
|
31 | |
32 | |
|
32 | namespace Mono.Zeroconf.Providers.Bonjour |
33 | namespace Mono.Zeroconf.Providers.Bonjour |
|
Line 48... | Line 49... | |||
48 | public static extern ServiceError DNSServiceCreateConnection(out ServiceRef sdRef); |
49 | public static extern ServiceError DNSServiceCreateConnection(out ServiceRef sdRef); |
|
Line 49... | Line 50... | |||
49 | |
50 | |
|
Line 50... | Line 51... | |||
50 | // DNSServiceBrowse |
51 | // DNSServiceBrowse |
|
51 | |
52 | |
|
52 | public delegate void DNSServiceBrowseReply(ServiceRef sdRef, ServiceFlags flags, uint interfaceIndex, |
53 | public delegate void DNSServiceBrowseReply(ServiceRef sdRef, ServiceFlags flags, uint interfaceIndex, |
|
Line 53... | Line 54... | |||
53 | ServiceError errorCode, string serviceName, string regtype, string replyDomain, |
54 | ServiceError errorCode, IntPtr serviceName, string regtype, string replyDomain, |
|
54 | IntPtr context); |
55 | IntPtr context); |
|
55 | |
56 | |
|
56 | [DllImport("dnssd.dll")] |
57 | [DllImport("dnssd.dll")] |
|
Line 57... | Line 58... | |||
57 | public static extern ServiceError DNSServiceBrowse(out ServiceRef sdRef, ServiceFlags flags, |
58 | public static extern ServiceError DNSServiceBrowse(out ServiceRef sdRef, ServiceFlags flags, |
|
Line 58... | Line 59... | |||
58 | uint interfaceIndex, string regtype, string domain, DNSServiceBrowseReply callBack, |
59 | uint interfaceIndex, string regtype, string domain, DNSServiceBrowseReply callBack, |
|
59 | IntPtr context); |
60 | IntPtr context); |
|
60 | |
61 | |
|
Line 61... | Line 62... | |||
61 | // DNSServiceResolve |
62 | // DNSServiceResolve |
|
62 | |
63 | |
|
63 | public delegate void DNSServiceResolveReply(ServiceRef sdRef, ServiceFlags flags, uint interfaceIndex, |
64 | public delegate void DNSServiceResolveReply(ServiceRef sdRef, ServiceFlags flags, uint interfaceIndex, |
|
64 | ServiceError errorCode, string fullname, string hosttarget, ushort port, ushort txtLen, |
65 | ServiceError errorCode, IntPtr fullname, string hosttarget, ushort port, ushort txtLen, |
|
Line 65... | Line 66... | |||
65 | IntPtr txtRecord, IntPtr context); |
66 | IntPtr txtRecord, IntPtr context); |
|
Line 66... | Line 67... | |||
66 | |
67 | |
|
67 | [DllImport("dnssd.dll")] |
68 | [DllImport("dnssd.dll")] |
|
- | 69 | public static extern ServiceError DNSServiceResolve(out ServiceRef sdRef, ServiceFlags flags, |
||
68 | public static extern ServiceError DNSServiceResolve(out ServiceRef sdRef, ServiceFlags flags, |
70 | uint interfaceIndex, byte[] name, string regtype, string domain, DNSServiceResolveReply callBack, |
|
69 | uint interfaceIndex, string name, string regtype, string domain, DNSServiceResolveReply callBack, |
71 | IntPtr context); |
|
70 | IntPtr context); |
72 | |
|
71 | |
73 | // DNSServiceRegister |
|
72 | // DNSServiceRegister |
74 | |
|
Line 73... | Line 75... | |||
73 | |
75 | public delegate void DNSServiceRegisterReply(ServiceRef sdRef, ServiceFlags flags, ServiceError errorCode, |
|
Line 74... | Line 76... | |||
74 | public delegate void DNSServiceRegisterReply(ServiceRef sdRef, ServiceFlags flags, ServiceError errorCode, |
76 | IntPtr name, string regtype, string domain, IntPtr context); |
|
Line 115... | Line 117... | |||
115 | [DllImport("dnssd.dll")] |
117 | [DllImport("dnssd.dll")] |
|
116 | public static extern IntPtr TXTRecordGetBytesPtr(IntPtr txtRecord); |
118 | public static extern IntPtr TXTRecordGetBytesPtr(IntPtr txtRecord); |
|
Line 117... | Line 119... | |||
117 | |
119 | |
|
118 | [DllImport("dnssd.dll")] |
120 | [DllImport("dnssd.dll")] |
|
- | 121 | public static extern ushort TXTRecordGetCount(ushort txtLen, IntPtr txtRecord); |
||
- | 122 | |
||
- | 123 | public static string Utf8toString(IntPtr ptr) |
||
- | 124 | { |
||
- | 125 | int len = 0; |
||
- | 126 | while (Marshal.ReadByte(ptr, len) != 0) |
||
- | 127 | { |
||
- | 128 | len++; |
||
- | 129 | } |
||
- | 130 | byte[] raw = new byte[len]; |
||
- | 131 | Marshal.Copy(ptr, raw, 0, len); |
||
- | 132 | return Encoding.UTF8.GetString(raw); |
||
119 | public static extern ushort TXTRecordGetCount(ushort txtLen, IntPtr txtRecord); |
133 | } |
|
120 | } |
134 | } |