Changeset 4836 for source/ariba/utility/bootstrap
- Timestamp:
- Jul 9, 2009, 1:50:37 PM (15 years ago)
- Location:
- source/ariba/utility/bootstrap
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
source/ariba/utility/bootstrap/BootstrapInformationCallback.h
r4733 r4836 49 49 class BootstrapInformationCallback { 50 50 public: 51 virtual void onBootstrapServiceFound(string name, string info ) = 0;51 virtual void onBootstrapServiceFound(string name, string info1, string info2, string info3) = 0; 52 52 }; 53 53 -
source/ariba/utility/bootstrap/BootstrapManager.cpp
r4758 r4836 50 50 51 51 BootstrapManager::~BootstrapManager(){ 52 53 boost::mutex::scoped_lock lock( modulesMutex );54 55 while( modules.size() > 0 ){56 ModuleMap::iterator i = modules.begin();57 unregisterModule( i->first );58 }59 52 } 60 53 … … 96 89 } 97 90 98 BootstrapManager::RegistrationResult BootstrapManager::unregisterModule(BootstrapManager::BootstrapType type){ 91 BootstrapManager::RegistrationResult BootstrapManager::unregisterModule( 92 BootstrapManager::BootstrapType type){ 99 93 100 94 boost::mutex::scoped_lock lock( modulesMutex ); … … 113 107 } 114 108 115 void BootstrapManager::onBootstrapServiceFound(string name, string info){ 109 BootstrapManager::RegistrationResult BootstrapManager::registerAllModules(){ 110 RegistrationResult result = RegistrationSucceeded; 111 112 { // multicast dns 113 RegistrationResult resone = RegistrationSucceeded; 114 resone = registerModule(BootstrapTypeMulticastDns); 115 if(resone != RegistrationSucceeded) 116 result = resone; 117 } 118 119 { // todo 120 /* ... */ 121 } 122 123 return result; 124 } 125 126 BootstrapManager::RegistrationResult BootstrapManager::unregisterAllModules(){ 127 unregisterModule(BootstrapTypeMulticastDns); 128 /* todo ... */ 129 130 return RegistrationSucceeded; 131 } 132 133 void BootstrapManager::onBootstrapServiceFound(string name, string info1, string info2, string info3){ 116 134 117 135 BOOST_FOREACH( BootstrapInformationCallback* callback, callbacks ){ 118 callback->onBootstrapServiceFound(name, info );136 callback->onBootstrapServiceFound(name, info1, info2, info3); 119 137 } 120 138 } … … 132 150 } 133 151 134 void BootstrapManager::publish(string name, string info ){152 void BootstrapManager::publish(string name, string info1, string info2, string info3){ 135 153 boost::mutex::scoped_lock lock( modulesMutex ); 136 154 … … 141 159 logging_info("bootstrap manager publishing service " 142 160 << name << " on module " << i->second->getName()); 143 i->second->publishService(name, info );161 i->second->publishService(name, info1, info2, info3); 144 162 } 145 163 } 146 164 147 165 void BootstrapManager::revoke(string name){ 166 boost::mutex::scoped_lock lock( modulesMutex ); 167 148 168 ModuleMap::iterator i = modules.begin(); 149 169 ModuleMap::iterator iend = modules.end(); -
source/ariba/utility/bootstrap/BootstrapManager.h
r4733 r4836 73 73 74 74 enum BootstrapType { 75 BootstrapTypeMulticastDns, 75 BootstrapTypeMulticastDns, // use mDNS bootstrapping 76 76 }; 77 77 … … 82 82 }; 83 83 84 RegistrationResult registerAllModules(); 84 85 RegistrationResult registerModule(BootstrapType type); 86 RegistrationResult unregisterAllModules(); 85 87 RegistrationResult unregisterModule(BootstrapType type); 86 88 … … 88 90 void unregisterCallback(BootstrapInformationCallback* _callback); 89 91 90 void publish(string name, string info );92 void publish(string name, string info1, string info2, string info3); 91 93 void revoke(string name); 92 94 93 95 protected: 94 virtual void onBootstrapServiceFound(string name, string info );96 virtual void onBootstrapServiceFound(string name, string info1, string info2, string info3); 95 97 96 98 private: -
source/ariba/utility/bootstrap/modules/BootstrapModule.h
r4758 r4836 53 53 virtual ~BootstrapModule(); 54 54 55 // the module must run asynchronously in its own thread. 55 56 virtual void start() = 0; 56 57 virtual void stop() = 0; … … 60 61 virtual bool isFunctional() = 0; 61 62 62 virtual void publishService(string name, string info ) = 0;63 virtual void publishService(string name, string info1, string info2, string info3) = 0; 63 64 virtual void revokeService(string name) = 0; 64 65 -
source/ariba/utility/bootstrap/modules/multicastdns/MulticastDns.cpp
r4758 r4836 46 46 47 47 MulticastDns::MulticastDns(BootstrapInformationCallback* _callback) : BootstrapModule(_callback) { 48 #ifdef HAVE_ LIBAVAHI_CLIENT48 #ifdef HAVE_AVAHI_CLIENT_CLIENT_H 49 49 avahiclient = NULL; 50 50 avahipoll = NULL; 51 51 avahibrowser = NULL; 52 #endif // HAVE_ LIBAVAHI_CLIENT52 #endif // HAVE_AVAHI_CLIENT_CLIENT_H 53 53 } 54 54 … … 65 65 66 66 bool MulticastDns::isFunctional(){ 67 #ifdef HAVE_ LIBAVAHI_CLIENT67 #ifdef HAVE_AVAHI_CLIENT_CLIENT_H 68 68 return true; 69 69 #else … … 73 73 74 74 void MulticastDns::start(){ 75 #ifdef HAVE_ LIBAVAHI_CLIENT75 #ifdef HAVE_AVAHI_CLIENT_CLIENT_H 76 76 77 77 int error = 0; … … 110 110 avahi_threaded_poll_start( avahipoll ); 111 111 112 #endif // HAVE_ LIBAVAHI_CLIENT112 #endif // HAVE_AVAHI_CLIENT_CLIENT_H 113 113 } 114 114 115 115 void MulticastDns::stop(){ 116 #ifdef HAVE_ LIBAVAHI_CLIENT116 #ifdef HAVE_AVAHI_CLIENT_CLIENT_H 117 117 118 118 // … … 144 144 avahipoll = NULL; 145 145 146 #endif // HAVE_ LIBAVAHI_CLIENT147 } 148 149 void MulticastDns::publishService(string name, string info ){150 #ifdef HAVE_ LIBAVAHI_CLIENT146 #endif // HAVE_AVAHI_CLIENT_CLIENT_H 147 } 148 149 void MulticastDns::publishService(string name, string info1, string info2, string info3){ 150 #ifdef HAVE_AVAHI_CLIENT_CLIENT_H 151 151 152 152 if(name.length() > 63){ … … 198 198 NULL, // host name of our machine, let avahi find out 199 199 3333, // port number the service is on, just dummy, everything is encoded in TXT 200 info.c_str(), // arbitrary info 200 info1.c_str(), // arbitrary info 201 info2.c_str(), // arbitrary info 202 info3.c_str(), // arbitrary info 201 203 NULL); // make that this is the last info field 202 204 … … 219 221 avahi_threaded_poll_unlock(avahipoll); 220 222 221 #endif // HAVE_ LIBAVAHI_CLIENT223 #endif // HAVE_AVAHI_CLIENT_CLIENT_H 222 224 } 223 225 224 226 void MulticastDns::revokeService(string name){ 225 #ifdef HAVE_ LIBAVAHI_CLIENT227 #ifdef HAVE_AVAHI_CLIENT_CLIENT_H 226 228 227 229 avahi_threaded_poll_lock(avahipoll); … … 239 241 avahi_threaded_poll_unlock(avahipoll); 240 242 241 #endif // HAVE_ LIBAVAHI_CLIENT242 } 243 244 #ifdef HAVE_ LIBAVAHI_CLIENT243 #endif // HAVE_AVAHI_CLIENT_CLIENT_H 244 } 245 246 #ifdef HAVE_AVAHI_CLIENT_CLIENT_H 245 247 246 248 void MulticastDns::client_callback(AvahiClient* client, AvahiClientState state, void* userdata){ … … 395 397 396 398 char addr[AVAHI_ADDRESS_STR_MAX]; 397 char* text = NULL;398 399 399 400 avahi_address_snprint(addr, sizeof(addr), address); 400 text = avahi_string_list_to_string(txt); 401 402 string info1 = ""; 403 string info2 = ""; 404 string info3 = ""; 405 406 if(txt != NULL){ 407 char* cinfo = avahi_string_list_to_string(txt); 408 info1 = cinfo; 409 avahi_free(cinfo); 410 } 411 412 if(txt != NULL && avahi_string_list_get_next(txt) != NULL){ 413 char* cinfo = avahi_string_list_to_string( avahi_string_list_get_next(txt) ); 414 info2 = cinfo; 415 avahi_free(cinfo); 416 } 417 418 if(txt != NULL && avahi_string_list_get_next(txt) != NULL){ 419 char* cinfo = avahi_string_list_to_string( avahi_string_list_get_next(txt) ); 420 info3 = cinfo; 421 avahi_free(cinfo); 422 } 401 423 402 424 if(obj != NULL && obj->callback != NULL) 403 obj->callback->onBootstrapServiceFound(name, text); 404 405 avahi_free( text ); 425 obj->callback->onBootstrapServiceFound(name, info1, info2, info3); 426 406 427 break; 407 428 } … … 410 431 } 411 432 412 #endif // HAVE_ LIBAVAHI_CLIENT433 #endif // HAVE_AVAHI_CLIENT_CLIENT_H 413 434 414 435 }} //namespace ariba, utility -
source/ariba/utility/bootstrap/modules/multicastdns/MulticastDns.h
r4758 r4836 42 42 #include "ariba/config.h" 43 43 44 #ifdef HAVE_ LIBAVAHI_CLIENT44 #ifdef HAVE_AVAHI_CLIENT_CLIENT_H 45 45 #include <avahi-client/client.h> 46 46 #include <avahi-client/lookup.h> … … 51 51 #include <avahi-common/error.h> 52 52 #include <avahi-common/timeval.h> 53 #endif 53 #endif // HAVE_AVAHI_CLIENT_CLIENT_H 54 54 55 55 #include <iostream> … … 80 80 virtual string getInformation(); 81 81 virtual bool isFunctional(); 82 virtual void publishService(string name, string info );82 virtual void publishService(string name, string info1, string info2, string info3); 83 83 virtual void revokeService(string name); 84 84 … … 86 86 static const string serviceType; 87 87 88 #ifdef HAVE_ LIBAVAHI_CLIENT88 #ifdef HAVE_AVAHI_CLIENT_CLIENT_H 89 89 90 90 AvahiClient* avahiclient; … … 133 133 ); 134 134 135 #endif // HAVE_ LIBAVAHI_CLIENT135 #endif // HAVE_AVAHI_CLIENT_CLIENT_H 136 136 137 137 };
Note:
See TracChangeset
for help on using the changeset viewer.