00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #ifndef __MULTICAST_DNS_H
00040 #define __MULTICAST_DNS_H
00041
00042 #include "ariba/config.h"
00043
00044 #ifdef HAVE_AVAHI_CLIENT_CLIENT_H
00045 #include <avahi-client/client.h>
00046 #include <avahi-client/lookup.h>
00047 #include <avahi-client/publish.h>
00048 #include <avahi-common/alternative.h>
00049 #include <avahi-common/thread-watch.h>
00050 #include <avahi-common/malloc.h>
00051 #include <avahi-common/error.h>
00052 #include <avahi-common/timeval.h>
00053 #endif // HAVE_AVAHI_CLIENT_CLIENT_H
00054
00055 #include <iostream>
00056 #include <string>
00057 #include <map>
00058 #include <boost/thread/mutex.hpp>
00059 #include <boost/thread/thread.hpp>
00060 #include "ariba/utility/bootstrap/modules/BootstrapModule.h"
00061 #include "ariba/utility/logging/Logging.h"
00062
00063 using std::string;
00064 using std::map;
00065 using std::make_pair;
00066
00067 namespace ariba {
00068 namespace utility {
00069
00070 class MulticastDns : public BootstrapModule {
00071 use_logging_h(MulticastDns);
00072 public:
00073 MulticastDns(BootstrapInformationCallback* _callback);
00074 virtual ~MulticastDns();
00075
00076 virtual void start();
00077 virtual void stop();
00078
00079 virtual string getName();
00080 virtual string getInformation();
00081 virtual bool isFunctional();
00082 virtual void publishService(string name, string info1, string info2, string info3);
00083 virtual void revokeService(string name);
00084
00085 private:
00086 static const string serviceType;
00087
00088 #ifdef HAVE_AVAHI_CLIENT_CLIENT_H
00089
00090 AvahiClient* avahiclient;
00091 AvahiThreadedPoll* avahipoll;
00092 AvahiServiceBrowser* avahibrowser;
00093
00094 typedef map<string, AvahiEntryGroup*> AvahiGroupMap;
00095 AvahiGroupMap avahigroups;
00096
00097 static void client_callback(
00098 AvahiClient* client,
00099 AvahiClientState state,
00100 void* userdata
00101 );
00102
00103 static void entry_group_callback(
00104 AvahiEntryGroup* group,
00105 AvahiEntryGroupState state,
00106 void* userdata);
00107
00108 static void browse_callback(
00109 AvahiServiceBrowser* browser,
00110 AvahiIfIndex interface,
00111 AvahiProtocol protocol,
00112 AvahiBrowserEvent event,
00113 const char* name,
00114 const char* type,
00115 const char* domain,
00116 AvahiLookupResultFlags flags,
00117 void* userdata);
00118
00119 static void resolve_callback(
00120 AvahiServiceResolver* resolver,
00121 AvahiIfIndex interface,
00122 AvahiProtocol protocol,
00123 AvahiResolverEvent event,
00124 const char* name,
00125 const char* type,
00126 const char* domain,
00127 const char* host_name,
00128 const AvahiAddress* address,
00129 uint16_t port,
00130 AvahiStringList* txt,
00131 AvahiLookupResultFlags flags,
00132 void* userdata
00133 );
00134
00135 #endif // HAVE_AVAHI_CLIENT_CLIENT_H
00136
00137 };
00138
00139 }}
00140
00141 #endif // __MULTICAST_DNS_H