00001 #ifndef __XRDOUCAPPLEBONJOUR_HH__
00002 #define __XRDOUCAPPLEBONJOUR_HH__
00003
00004 #include <dns_sd.h>
00005 #include <list>
00006 #include "XrdOuc/XrdOucBonjour.hh"
00007 #include "XrdOuc/XrdOucString.hh"
00008 #include "XrdSys/XrdSysPthread.hh"
00009
00010
00011
00012
00013
00014 class XrdOucAppleBonjour : public XrdOucBonjour {
00015 private:
00016
00017 static XrdOucAppleBonjour *_Instance;
00018
00019
00020 static XrdSysMutex SingletonMutex;
00021
00022
00023
00024 XrdOucAppleBonjour();
00025 virtual ~XrdOucAppleBonjour();
00026 XrdOucAppleBonjour(const XrdOucAppleBonjour &) { }
00027 XrdOucAppleBonjour &operator=(const XrdOucAppleBonjour &) {
00028 return *this;
00029 }
00030
00031
00032
00033 friend class XrdOucAppleBonjourSingletonCleanup;
00034 class XrdOucAppleBonjourSingletonCleanup {
00035 public:
00036 ~XrdOucAppleBonjourSingletonCleanup();
00037 };
00038
00039 class XrdOucAppleBonjourSearchNode {
00040 private:
00041 const char * ServiceName;
00042
00043 public:
00044 XrdOucAppleBonjourSearchNode(const char * name) {
00045 ServiceName = name;
00046 }
00047 bool operator()(XrdOucBonjourNode * value);
00048 };
00049
00050
00051
00052
00053
00054 std::list<XrdOucBonjourRegisteredEntry *> ListOfRegistrations;
00055
00056
00057 static void RegisterReply(DNSServiceRef ref,
00058 DNSServiceFlags flags,
00059 DNSServiceErrorType error,
00060 const char * name,
00061 const char * regtype,
00062 const char * domain,
00063 void * context);
00064
00065 static void BrowseReply(DNSServiceRef ref,
00066 DNSServiceFlags flags,
00067 uint32_t interfaceIndex,
00068 DNSServiceErrorType error,
00069 const char * name,
00070 const char * regtype,
00071 const char * domain,
00072 void * context);
00073
00074 static void ResolveReply(DNSServiceRef ref,
00075 DNSServiceFlags flags,
00076 uint32_t interfaceIndex,
00077 DNSServiceErrorType error,
00078 const char * fullname,
00079 const char * hostname,
00080 uint16_t port,
00081 uint16_t txtLen,
00082 const unsigned char * txtVal,
00083 void * context);
00084
00085
00086
00087 pthread_t BrowseEventLoopThreadInfo;
00088 static void * BrowseEventLoopThread(void * context);
00089
00090 public:
00091
00092
00093 int RegisterService(XrdOucBonjourRecord &record,
00094 unsigned short port = 0);
00095
00096
00097
00098
00099
00100
00101 int SubscribeForUpdates(const char * servicetype,
00102 XrdOucBonjourUpdateCallback callback,
00103 void * context);
00104
00105
00106
00107
00108
00109
00110 int ResolveNodeInformation(XrdOucBonjourResolutionEntry * nodeAndCallback);
00111
00112
00113 static XrdOucAppleBonjour &getInstance();
00114 };
00115
00116
00117
00118
00119
00120 class XrdOucAppleBonjourFactory : public XrdOucBonjourFactory {
00121 XrdOucBonjour &GetBonjourManager() {
00122 return XrdOucAppleBonjour::getInstance();
00123 }
00124 };
00125
00126 #endif