Changeset 7532 for source/ariba
- Timestamp:
- Feb 4, 2010, 5:29:37 PM (15 years ago)
- Location:
- source/ariba
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
source/ariba/AribaModule.cpp
r7468 r7532 43 43 #include <boost/regex.hpp> 44 44 #include <boost/foreach.hpp> 45 #include <boost/algorithm/string.hpp> 45 46 46 47 // ariba includes … … 58 59 59 60 use_logging_cpp(AribaModule); 61 const string AribaModule::BootstrapMechanismNames[5] = {"invalid", "static", "broadcast", "mdns", "sdp"}; 60 62 61 63 AribaModule::AribaModule() … … 69 71 string AribaModule::getBootstrapHints(const Name& spoVNetName) const { 70 72 std::ostringstream o; 73 int i=0; 71 74 BOOST_FOREACH( const BootstrapInfo& info, bootstrapNodes ) { 72 75 o << info.spovnetName.toString() << "{"; 73 int i=0; 76 if (i!=0) o << ","; 77 74 78 BOOST_FOREACH( const BootstrapNode& node, info.nodes ) { 75 if (i!=0) o << ","; 76 if( node.desc != NULL ) o << node.desc->toString(); 77 i++; 79 if( node.desc != NULL ) 80 o << node.desc->toString(); 81 else if(node.mechanism == BootstrapMechanismBroadcast 82 || node.mechanism == BootstrapMechanismMulticastDNS 83 || node.mechanism == BootstrapMechanismSDP){ 84 o << BootstrapMechanismNames[node.mechanism]; 85 if( !node.info.empty() ) o << "{" << node.info << "}"; 86 o << ";"; 87 } 78 88 } 79 89 o << "}"; 90 i++; 80 91 } 81 92 return o.str(); … … 87 98 using namespace ariba::utility::Helper; 88 99 using namespace std; 100 101 boost::erase_all(boot_info, " "); 102 boost::erase_all(boot_info, "\t"); 103 boost::erase_all(boot_info, "\n"); 104 boost::erase_all(boot_info, "\r"); 89 105 90 106 smatch match; … … 96 112 data = data.substr(1, data.size() - 2); 97 113 Name name(type); 114 115 // find static bootstrap info --> BootstrapMechanismStatic 98 116 EndpointDescriptor* desc = EndpointDescriptor::fromString(data); 99 logging_debug("Added bootstap info for " << type << ": " << desc->toString() ); 100 addBootstrapNode(name, desc); 101 } 102 } 117 addBootstrapNode(name, desc, "", BootstrapMechanismStatic); 118 119 // find automatic bootstrap info --> {BootstrapMechanismBroadcast, 120 // BootstrapMechanismMulticastDNS,BootstrapMechanismSDP} 121 typedef vector< string > split_vector_type; 122 split_vector_type splitvec; 123 boost::split( splitvec, data, boost::is_any_of(";") ); 124 for(unsigned int i=0; i<splitvec.size(); i++){ 125 string x = splitvec[i]; 126 split_vector_type innervec; 127 128 boost::split( innervec, x, boost::is_any_of("{}") ); 129 BootstrapNode node; 130 if(innervec.size() < 1) continue; 131 132 if(innervec[0] == BootstrapMechanismNames[BootstrapMechanismBroadcast]) 133 node.mechanism = BootstrapMechanismBroadcast; 134 else if(innervec[0] == BootstrapMechanismNames[BootstrapMechanismMulticastDNS]) 135 node.mechanism = BootstrapMechanismMulticastDNS; 136 else if(innervec[0] == BootstrapMechanismNames[BootstrapMechanismSDP]) 137 node.mechanism = BootstrapMechanismSDP; 138 else 139 continue; 140 141 if(innervec.size() > 1) 142 node.info = innervec[1]; 143 144 this->addBootstrapNode(name, node); 145 } 146 } 147 } 148 149 logging_info( "Added bootstrap hints: " << getBootstrapHints() ); 103 150 } 104 151 105 152 void AribaModule::addBootstrapNode(const Name& spovnet, 106 communication::EndpointDescriptor* desc) { 107 108 // set bootstrap node 109 BootstrapNode node; 110 node.timestamp = 0; 111 node.desc = desc; 153 communication::EndpointDescriptor* desc, const string& info, 154 const BootstrapMechanism& mechanism) { 155 BootstrapNode node(0, desc, mechanism, info); 156 addBootstrapNode(spovnet, node); 157 } 158 159 void AribaModule::addBootstrapNode(const Name& spovnet, const BootstrapNode& node){ 112 160 bool added = false; 113 161 … … 128 176 bootstrapNodes.push_back(info); 129 177 } 130 131 logging_debug( "Added bootstrap info: " << getBootstrapHints() );132 178 } 133 179 134 180 const communication::EndpointDescriptor* AribaModule::getBootstrapNode( 135 const Name& spovnet ) const {181 const Name& spovnet, const BootstrapMechanism mechanism) const { 136 182 BOOST_FOREACH( const BootstrapInfo& info, bootstrapNodes ) { 137 183 if( info.spovnetName == spovnet ) { 138 184 BOOST_FOREACH( const BootstrapNode& node, info.nodes ) { 139 if( node.desc != NULL ) return node.desc; 185 if( node.mechanism == mechanism && node.desc != NULL ) 186 return node.desc; 140 187 } 141 188 } 142 189 } 143 190 return NULL; 191 } 192 193 string AribaModule::getBootstrapInfo( 194 const Name& spovnet, const BootstrapMechanism mechanism) const { 195 BOOST_FOREACH( const BootstrapInfo& info, bootstrapNodes ) { 196 if( info.spovnetName == spovnet ) { 197 BOOST_FOREACH( const BootstrapNode& node, info.nodes ) { 198 if( node.mechanism == mechanism && node.desc != NULL ) 199 return node.info; 200 } 201 } 202 } 203 204 return string(); 205 } 206 207 vector<AribaModule::BootstrapMechanism> AribaModule::getBootstrapMechanisms( 208 const Name& spovnet) const { 209 vector<AribaModule::BootstrapMechanism> ret; 210 BOOST_FOREACH( const BootstrapInfo& info, bootstrapNodes ) { 211 if( info.spovnetName == spovnet ) { 212 BOOST_FOREACH( const BootstrapNode& node, info.nodes ) { 213 if(std::find(ret.begin(), ret.end(), node.mechanism) == ret.end()) 214 ret.push_back(node.mechanism); 215 } 216 } 217 } 218 return ret; 144 219 } 145 220 -
source/ariba/AribaModule.h
r5767 r7532 44 44 #include <ctime> 45 45 #include <cstdlib> 46 #include "ariba/utility/logging/Logging.h"46 #include <algorithm> 47 47 48 48 using std::vector; … … 156 156 157 157 private: 158 159 // bootstrap mechanisms 160 enum BootstrapMechanism { 161 BootstrapMechanismInvalid = 0, 162 BootstrapMechanismStatic = 1, 163 BootstrapMechanismBroadcast = 2, 164 BootstrapMechanismMulticastDNS = 3, 165 BootstrapMechanismSDP = 4, 166 }; 167 static const string BootstrapMechanismNames[5]; 168 158 169 // bootstrap node 159 170 class BootstrapNode { 160 171 public: 161 172 inline BootstrapNode() : 162 timestamp(0), desc(NULL) {173 timestamp(0), desc(NULL), mechanism(BootstrapMechanismInvalid), info("") { 163 174 164 175 } 165 176 inline BootstrapNode(const BootstrapNode& copy) : 166 timestamp(copy.timestamp), desc(copy.desc) { 167 } 168 inline BootstrapNode(uint32_t timestamp, 169 communication::EndpointDescriptor* desc) : 170 timestamp(timestamp), desc(desc) { 177 timestamp(copy.timestamp), desc(copy.desc), mechanism(copy.mechanism), info(copy.info) { 178 } 179 inline BootstrapNode( 180 uint32_t timestamp, 181 communication::EndpointDescriptor* desc, 182 BootstrapMechanism mechanism, string info) : 183 timestamp(timestamp), desc(desc), mechanism(mechanism), info(info) { 171 184 } 172 185 uint32_t timestamp; 173 186 communication::EndpointDescriptor* desc; 187 BootstrapMechanism mechanism; 188 string info; 174 189 }; 175 190 … … 192 207 protected: 193 208 // members 194 string bootstrapFile; //< file with bootstrap information 195 string endpoints; 209 string endpoints; //< local endpoints the ariba module is bound to 196 210 bool started; //< flag, if module has been started 197 211 198 212 // bootstrap node management 199 void addBootstrapNode(const Name& spovnet, 200 communication::EndpointDescriptor* desc); 213 void addBootstrapNode( 214 const Name& spovnet, 215 communication::EndpointDescriptor* desc, 216 const string& info, 217 const BootstrapMechanism& mechanism 218 ); 219 void addBootstrapNode( 220 const Name& spovnet, 221 const BootstrapNode& node 222 ); 223 224 vector<AribaModule::BootstrapMechanism> getBootstrapMechanisms( 225 const Name& spovnet 226 ) const; 227 201 228 const communication::EndpointDescriptor* getBootstrapNode( 202 const Name& spovnet) const; 229 const Name& spovnet, 230 const BootstrapMechanism mechanism 231 ) const; 232 233 string getBootstrapInfo( 234 const Name& spovnet, 235 const BootstrapMechanism mechanism 236 ) const; 203 237 204 238 communication::BaseCommunication* base_comm; -
source/ariba/Node.cpp
r7469 r7532 61 61 nodeId = generateNodeId(name); 62 62 63 const communication::EndpointDescriptor* ep =64 ariba_mod.getBootstrapNode(vnetname);65 66 63 // start base comm if not started 67 64 if( !ariba_mod.base_comm->isStarted() ) … … 74 71 base_overlay->joinSpoVNet( spovnetId ); 75 72 76 // join against further nodes 77 if( ep != NULL && ep->isUnspecified() == false ) 78 base_overlay->joinSpoVNet( spovnetId, *ep); 73 // join against static bootstrap points and 74 // start automatic bootstrapping modules 75 vector<AribaModule::BootstrapMechanism> mechanisms 76 = ariba_mod.getBootstrapMechanisms(vnetname); 77 78 vector<pair<BootstrapManager::BootstrapType,string> > internalmodules; 79 80 BOOST_FOREACH(AribaModule::BootstrapMechanism m, mechanisms){ 81 switch(m){ 82 case AribaModule::BootstrapMechanismStatic: 83 { 84 const communication::EndpointDescriptor* ep = 85 ariba_mod.getBootstrapNode(vnetname, m); 86 if( ep != NULL && ep->isUnspecified() == false ) 87 base_overlay->joinSpoVNet( spovnetId, *ep); 88 break; 89 } 90 case AribaModule::BootstrapMechanismBroadcast: 91 internalmodules.push_back(make_pair( 92 BootstrapManager::BootstrapTypePeriodicBroadcast, 93 ariba_mod.getBootstrapInfo(vnetname, m))); 94 break; 95 case AribaModule::BootstrapMechanismMulticastDNS: 96 internalmodules.push_back(make_pair( 97 BootstrapManager::BootstrapTypeMulticastDns, 98 ariba_mod.getBootstrapInfo(vnetname, m))); 99 break; 100 case AribaModule::BootstrapMechanismSDP: 101 internalmodules.push_back(make_pair( 102 BootstrapManager::BootstrapTypeBluetoothSdp, 103 ariba_mod.getBootstrapInfo(vnetname, m))); 104 break; 105 default: 106 break; 107 } 108 } 109 110 // start automatic overlay bootstrapping modules 111 base_overlay->startBootstrapModules(internalmodules); 112 113 // done 79 114 } 80 115 … … 101 136 102 137 void Node::leave() { 138 base_overlay->stopBootstrapModules(); 103 139 base_overlay->leaveSpoVNet(); 104 140 ariba_mod.base_comm->stop(); -
source/ariba/Node.h
r7469 r7532 50 50 #include <vector> 51 51 #include <iostream> 52 #include <boost/foreach.hpp> 52 53 #include "Module.h" 53 54 #include "Identifiers.h" -
source/ariba/overlay/BaseOverlay.cpp
r7018 r7532 824 824 } 825 825 826 827 826 //ovl.visShowNodeBubble ( ovlId, nodeId, "joining..." ); 828 827 logging_info( "Starting to join spovnet " << id.toString() << … … 830 829 831 830 if(bootstrapEp.isUnspecified() && state == BaseOverlayStateInvalid){ 831 832 //** FIRST STEP - MANDATORY */ 832 833 833 834 // bootstrap against ourselfs … … 842 843 //ovl.visChangeNodeColor( ovlId, nodeId, OvlVis::NODE_COLORS_GREEN ); 843 844 844 logging_debug("starting overlay bootstrap module");845 overlayBootstrap.start(this, spovnetId, nodeId);846 overlayBootstrap.publish(bc->getEndpointDescriptor());847 848 845 } else { 846 847 //** SECOND STEP - OPTIONAL */ 849 848 850 849 // bootstrap against another node … … 857 856 } 858 857 859 void BaseOverlay::leaveSpoVNet() { 860 861 logging_info( "Leaving spovnet " << spovnetId ); 862 bool ret = ( state != this->BaseOverlayStateInvalid ); 863 858 859 void BaseOverlay::startBootstrapModules(vector<pair<BootstrapManager::BootstrapType,string> > modules){ 860 logging_debug("starting overlay bootstrap module"); 861 overlayBootstrap.start(this, spovnetId, nodeId, modules); 862 overlayBootstrap.publish(bc->getEndpointDescriptor()); 863 } 864 865 void BaseOverlay::stopBootstrapModules(){ 864 866 logging_debug("stopping overlay bootstrap module"); 865 867 overlayBootstrap.stop(); 866 868 overlayBootstrap.revoke(); 869 } 870 871 void BaseOverlay::leaveSpoVNet() { 872 873 logging_info( "Leaving spovnet " << spovnetId ); 874 bool ret = ( state != this->BaseOverlayStateInvalid ); 867 875 868 876 logging_debug( "Dropping all auto-links" ); -
source/ariba/overlay/BaseOverlay.h
r6961 r7532 274 274 275 275 /** 276 * Start the bootstrap modules 277 */ 278 void startBootstrapModules(vector<pair<BootstrapManager::BootstrapType,string> > modules); 279 280 /** 281 * Stop the bootstrap modules 282 */ 283 void stopBootstrapModules(); 284 285 /** 276 286 * Let the node leave the SpoVNet. 277 287 */ -
source/ariba/overlay/OverlayBootstrap.cpp
r7491 r7532 66 66 } 67 67 68 void OverlayBootstrap::start(BaseOverlay* _overlay, const SpoVNetID& _spovnetid, const NodeID& _nodeid){ 68 void OverlayBootstrap::start(BaseOverlay* _overlay, 69 const SpoVNetID& _spovnetid, const NodeID& _nodeid, 70 vector<pair<BootstrapManager::BootstrapType,string> > modules){ 69 71 overlay = _overlay; 70 72 spovnetid = _spovnetid; … … 74 76 75 77 manager.registerCallback( this ); 76 manager.registerModule( BootstrapManager::BootstrapTypePeriodicBroadcast ); 77 //manager.registerModule( BootstrapManager::BootstrapTypeBluetoothSdp ); 78 //manager.registerModule( BootstrapManager::BootstrapTypeMulticastDns ); 78 79 typedef pair<BootstrapManager::BootstrapType,string> X; 80 BOOST_FOREACH( X i, modules){ 81 manager.registerModule( i.first, i.second ); 82 } 79 83 80 84 watchtimer.startWatchdog(); … … 89 93 90 94 manager.unregisterCallback( this ); 91 manager.unregisterModule( BootstrapManager::BootstrapTypePeriodicBroadcast ); 92 //manager.unregisterModule( BootstrapManager::BootstrapTypeBluetoothSdp ); 93 //manager.unregisterModule( BootstrapManager::BootstrapTypeMulticastDns ); 95 manager.unregisterAllModules(); 94 96 95 97 watchtimer.stopWatchdog(); -
source/ariba/overlay/OverlayBootstrap.h
r6919 r7532 44 44 #include <ctime> 45 45 #include <deque> 46 #include <vector> 46 47 #include <algorithm> 47 48 #include <boost/thread/mutex.hpp> 49 #include <boost/foreach.hpp> 48 50 #include "ariba/utility/logging/Logging.h" 49 51 #include "ariba/utility/types.h" … … 60 62 using std::deque; 61 63 using std::string; 64 using std::vector; 65 using std::pair; 62 66 using std::ostringstream; 63 67 using ariba::utility::SpoVNetID; … … 83 87 virtual ~OverlayBootstrap(); 84 88 85 void start(BaseOverlay* _overlay, const SpoVNetID& _spovnetid, const NodeID& _nodeid); 89 void start( 90 BaseOverlay* _overlay, 91 const SpoVNetID& _spovnetid, 92 const NodeID& _nodeid, 93 vector<pair<BootstrapManager::BootstrapType,string> > modules 94 ); 86 95 void stop(); 87 96 -
source/ariba/utility/bootstrap/BootstrapManager.cpp
r5953 r7532 54 54 } 55 55 56 BootstrapManager::RegistrationResult BootstrapManager::registerModule(BootstrapManager::BootstrapType type){ 56 BootstrapManager::RegistrationResult BootstrapManager::registerModule( 57 BootstrapManager::BootstrapType type, string info){ 57 58 58 59 boost::mutex::scoped_lock lock( modulesMutex ); … … 68 69 switch(type){ 69 70 case BootstrapTypeMulticastDns: 70 module = new MulticastDns(this );71 module = new MulticastDns(this, info); 71 72 break; 72 73 case BootstrapTypePeriodicBroadcast: 73 module = new PeriodicBroadcast(this );74 module = new PeriodicBroadcast(this, info); 74 75 break; 75 76 case BootstrapTypeBluetoothSdp: 76 module = new BluetoothSdp(this );77 module = new BluetoothSdp(this, info); 77 78 break; 78 79 } -
source/ariba/utility/bootstrap/BootstrapManager.h
r5953 r7532 85 85 86 86 RegistrationResult registerAllModules(); 87 RegistrationResult registerModule(BootstrapType type );87 RegistrationResult registerModule(BootstrapType type, string info=string("")); 88 88 RegistrationResult unregisterAllModules(); 89 89 RegistrationResult unregisterModule(BootstrapType type); -
source/ariba/utility/bootstrap/modules/bluetoothsdp/BluetoothSdp.cpp
r7043 r7532 72 72 OverlayBootstrap* BluetoothSdp::CONNECTION_CHECKER = NULL; 73 73 74 BluetoothSdp::BluetoothSdp(BootstrapInformationCallback* _callback ) :75 BootstrapModule(_callback), scan_timer_(io_service_) {74 BluetoothSdp::BluetoothSdp(BootstrapInformationCallback* _callback, string info) 75 : BootstrapModule(_callback), scan_timer_(io_service_) { 76 76 srand( time(NULL) ); 77 77 #ifdef HAVE_BLUETOOTH_BLUETOOTH_H … … 80 80 // of the info strings (as an attribute) 81 81 channel_ = 1; 82 83 82 #endif // HAVE_BLUETOOTH_BLUETOOTH_H 84 83 } -
source/ariba/utility/bootstrap/modules/bluetoothsdp/BluetoothSdp.h
r5967 r7532 80 80 static OverlayBootstrap* CONNECTION_CHECKER; 81 81 82 BluetoothSdp(BootstrapInformationCallback* _callback );82 BluetoothSdp(BootstrapInformationCallback* _callback, string info); 83 83 virtual ~BluetoothSdp(); 84 84 -
source/ariba/utility/bootstrap/modules/multicastdns/MulticastDns.cpp
r5284 r7532 46 46 use_logging_cpp(MulticastDns); 47 47 48 MulticastDns::MulticastDns(BootstrapInformationCallback* _callback) : BootstrapModule(_callback) { 48 MulticastDns::MulticastDns(BootstrapInformationCallback* _callback, string info) 49 : BootstrapModule(_callback) { 49 50 #ifdef HAVE_AVAHI_CLIENT_CLIENT_H 50 51 avahiclient = NULL; -
source/ariba/utility/bootstrap/modules/multicastdns/MulticastDns.h
r4836 r7532 71 71 use_logging_h(MulticastDns); 72 72 public: 73 MulticastDns(BootstrapInformationCallback* _callback );73 MulticastDns(BootstrapInformationCallback* _callback, string info); 74 74 virtual ~MulticastDns(); 75 75 -
source/ariba/utility/bootstrap/modules/periodicbroadcast/PeriodicBroadcast.cpp
r5838 r7532 63 63 const unsigned int PeriodicBroadcast::serverport_v6 = 5636; 64 64 65 PeriodicBroadcast::PeriodicBroadcast(BootstrapInformationCallback* _callback )65 PeriodicBroadcast::PeriodicBroadcast(BootstrapInformationCallback* _callback, string info) 66 66 : BootstrapModule(_callback), 67 67 server(io_service, &newRemoteServices, &newRemoteServicesMutex) { … … 108 108 109 109 boost::mutex::scoped_lock lock( localServicesMutex ); 110 if(name.empty()) return; 111 110 112 localServices.insert( std::make_pair(name, service) ); 111 113 } … … 113 115 void PeriodicBroadcast::revokeService(string name){ 114 116 boost::mutex::scoped_lock lock( localServicesMutex ); 117 if(name.empty()) return; 115 118 116 119 ServiceList::iterator i = localServices.find( name ); -
source/ariba/utility/bootstrap/modules/periodicbroadcast/PeriodicBroadcast.h
r6919 r7532 66 66 use_logging_h(PeriodicBroadcast); 67 67 public: 68 PeriodicBroadcast(BootstrapInformationCallback* _callback );68 PeriodicBroadcast(BootstrapInformationCallback* _callback, string info); 69 69 virtual ~PeriodicBroadcast(); 70 70 … … 275 275 276 276 PeriodicBroadcastMessage msg; 277 if(service.getName().empty()) return; 277 278 278 279 msg.setName( service.getName() ); … … 351 352 { // insert new found service 352 353 boost::mutex::scoped_lock lock( *servicesmutex ); 354 if(msg.getName().empty()) return; 353 355 354 356 ServiceList::iterator it = services->find( msg.getName() );
Note:
See TracChangeset
for help on using the changeset viewer.