Changeset 4836 for source/ariba
- Timestamp:
- Jul 9, 2009, 1:50:37 PM (15 years ago)
- Location:
- source/ariba
- Files:
-
- 2 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
source/ariba/Makefile.am
r4733 r4836 258 258 259 259 libariba_la_SOURCES += \ 260 overlay/BaseOverlay.cpp 261 262 nobase_libariba_la_HEADERS += \ 263 overlay/BaseOverlay.h 260 overlay/BaseOverlay.cpp \ 261 overlay/OverlayBootstrap.cpp 262 263 nobase_libariba_la_HEADERS += \ 264 overlay/BaseOverlay.h \ 265 overlay/OverlayBootstrap.h 264 266 265 267 #------------> overlay :: messages -
source/ariba/communication/EndpointDescriptor.cpp
r3705 r4836 63 63 } 64 64 65 EndpointDescriptor::EndpointDescriptor(const string str) { 66 using namespace boost::xpressive; 67 using namespace ariba::utility::string_format; 68 using namespace ariba::utility::Helper; 69 using namespace std; 70 71 locator = NULL; 72 isUnspec = true; 73 74 smatch match; 75 if (regex_search(str, match, robjects)) { 76 regex_nav nav = match; 77 for (int i=0; i<nav.size(); i++) { 78 string type = nav[i][robject_id].str(); 79 if (type=="ip") { 80 string ip = nav[i][robject_data].str(); 81 ip = ip.substr(1,ip.size()-2); 82 this->locator = new IPv4Locator(); 83 this->locator->setIP(ip); 84 this->isUnspec = false; 85 } else 86 if (type=="tcp") { 87 string port = nav[i][robject_data][rfields][1].str(); 88 port = port.substr(1,port.size()-2); 89 this->locator->setPort(stoi(port)); 90 } 91 } 92 } 93 } 94 65 95 EndpointDescriptor::~EndpointDescriptor() { 66 96 } … … 80 110 81 111 EndpointDescriptor* EndpointDescriptor::fromString( string str ) { 82 using namespace boost::xpressive; 83 using namespace ariba::utility::string_format; 84 using namespace ariba::utility::Helper; 85 using namespace std; 86 87 EndpointDescriptor* ep = NULL; 88 smatch match; 89 if (regex_search(str, match, robjects)) { 90 regex_nav nav = match; 91 for (int i=0; i<nav.size(); i++) { 92 string type = nav[i][robject_id].str(); 93 if (type=="ip") { 94 string ip = nav[i][robject_data].str(); 95 ip = ip.substr(1,ip.size()-2); 96 ep = new EndpointDescriptor(); 97 ep->locator = new IPv4Locator(); 98 ep->locator->setIP(ip); 99 ep->isUnspec = false; 100 } else 101 if (type=="tcp") { 102 string port = nav[i][robject_data][rfields][1].str(); 103 port = port.substr(1,port.size()-2); 104 ep->locator->setPort(stoi(port)); 105 } 106 } 107 } 108 return ep; 112 return new EndpointDescriptor( str ); 109 113 } 110 114 -
source/ariba/communication/EndpointDescriptor.h
r4625 r4836 69 69 EndpointDescriptor(const EndpointDescriptor& rh); 70 70 EndpointDescriptor(const Locator* _locator); 71 EndpointDescriptor(const string str); 71 72 72 73 /** -
source/ariba/overlay/BaseOverlay.cpp
r4762 r4836 112 112 " with nodeid " << nodeId.toString()); 113 113 114 spovnetId = id; 115 state = BaseOverlayStateJoinInitiated; 116 117 118 // 119 // start bootstrapping for spovnetid 120 // 121 122 overlayBootstrap.start( this, spovnetId, nodeId ); 123 overlayBootstrap.publish( bc->getEndpointDescriptor() ); 124 114 125 // 115 126 // contact the spovnet initiator and request … … 120 131 // but first, we have to establish a link to the initiator... 121 132 // 122 123 spovnetId = id;124 state = BaseOverlayStateJoinInitiated;125 133 126 134 initiatorLink = bc->establishLink( bootstrapEp ); -
source/ariba/overlay/BaseOverlay.h
r3712 r4836 63 63 #include "ariba/overlay/modules/OverlayFactory.h" 64 64 #include "ariba/overlay/modules/OverlayStructureEvents.h" 65 #include "ariba/overlay/OverlayBootstrap.h" 65 66 66 67 // forward declarations 67 68 namespace ariba { 68 class NodeListener;69 class CommunicationListener;70 class SideportListener;71 namespace utility {72 class OvlVis;73 }69 class NodeListener; 70 class CommunicationListener; 71 class SideportListener; 72 namespace utility { 73 class OvlVis; 74 } 74 75 } 75 76 … … 83 84 using std::deque; 84 85 86 // ariba interface 85 87 using ariba::NodeListener; 86 88 using ariba::CommunicationListener; 89 90 // overlay 91 using ariba::overlay::OverlayBootstrap; 87 92 88 93 // communication … … 497 502 JoiningNodes joiningNodes; 498 503 504 /** 505 * Bootstrapper for our spovnet 506 */ 507 OverlayBootstrap overlayBootstrap; 499 508 }; 500 509 -
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.