X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=avahi-sharp%2FClient.cs;h=e148ff30ba8f379e04b76a00ec49614d097b34ec;hb=a4c2edcece605452c4d72da36b8c39da5e514314;hp=c3584c59b13d450ab67649bf6811b937fd266c92;hpb=264700bf97de2e4430494cb41201950162fba020;p=catta diff --git a/avahi-sharp/Client.cs b/avahi-sharp/Client.cs index c3584c5..e148ff3 100644 --- a/avahi-sharp/Client.cs +++ b/avahi-sharp/Client.cs @@ -29,12 +29,18 @@ namespace Avahi { internal enum ResolverEvent { Found, - Timeout + Timeout, + NotFound, + Failure } internal enum BrowserEvent { Added, - Removed + Removed, + CacheExhausted, + AllForNow, + NotFound, + Failure } internal delegate int PollCallback (IntPtr ufds, uint nfds, int timeout); @@ -43,9 +49,9 @@ namespace Avahi public delegate void ClientStateHandler (object o, ClientState state); public enum Protocol { - Unspecified = 0, - IPv4 = 2, - IPv6 = 10 + Unspecified = -1, + IPv4 = 0, + IPv6 = 1 } public enum ClientState { @@ -55,6 +61,23 @@ namespace Avahi Collision, Disconnected = 100 } + + [Flags] + public enum LookupFlags { + None = 0, + UseWideArea = 1, + UseMulticast = 2, + NoTxt = 4, + NoAddress = 8 + } + + [Flags] + public enum LookupResultFlags { + None = 0, + Cached = 1, + WideArea = 2, + Multicast = 4 + } public class Client : IDisposable { @@ -108,6 +131,14 @@ namespace Avahi [DllImport ("avahi-common")] private static extern void avahi_simple_poll_quit (IntPtr spoll); + [DllImport ("avahi-client")] + private static extern uint avahi_client_get_local_service_cookie (IntPtr client); + + [DllImport ("avahi-client")] + private static extern int avahi_client_is_service_local (IntPtr client, int iface, Protocol proto, + IntPtr name, IntPtr type, IntPtr domain); + + [DllImport ("libc")] private static extern int poll(IntPtr ufds, uint nfds, int timeout); @@ -163,6 +194,15 @@ namespace Avahi } } + public uint LocalServiceCookie + { + get { + lock (this) { + return avahi_client_get_local_service_cookie (handle); + } + } + } + internal int LastError { get { @@ -210,6 +250,27 @@ namespace Avahi } } + public bool IsServiceLocal (ServiceInfo service) + { + return IsServiceLocal (service.NetworkInterface, service.Protocol, service.Name, + service.ServiceType, service.Domain); + } + + public bool IsServiceLocal (int iface, Protocol proto, string name, string type, string domain) + { + IntPtr namePtr = Utility.StringToPtr (name); + IntPtr typePtr = Utility.StringToPtr (type); + IntPtr domainPtr = Utility.StringToPtr (domain); + + int result = avahi_client_is_service_local (handle, iface, proto, namePtr, typePtr, domainPtr); + + Utility.Free (namePtr); + Utility.Free (typePtr); + Utility.Free (domainPtr); + + return result == 1; + } + internal void CheckError () { int error = LastError;