Changeset 5358 for source/ariba
- Timestamp:
- Jul 26, 2009, 5:17:30 PM (15 years ago)
- Location:
- source/ariba
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
source/ariba/SideportListener.cpp
r5316 r5358 41 41 #include "ariba/overlay/BaseOverlay.h" 42 42 #include "ariba/overlay/LinkDescriptor.h" 43 #include "ariba/utility/addressing/endpoint_set.hpp" 43 44 44 45 using ariba::overlay::LinkDescriptor; … … 82 83 83 84 bool SideportListener::isRelayedNode(const NodeID& node){ 85 if( overlay == NULL ) return false; 84 86 85 87 BOOST_FOREACH( LinkDescriptor* link, overlay->links ){ 86 87 if( (!link->localRelay.isUnspecified()) && link->remoteRelay == node && link->up) { 88 if( (!link->localRelay.isUnspecified()) && link->remoteRelay == node && link->up) 88 89 return true; 89 }90 91 90 } 92 91 … … 95 94 96 95 bool SideportListener::isRelayingNode(const NodeID& node){ 96 if( overlay == NULL ) return false; 97 97 98 98 BOOST_FOREACH( LinkDescriptor* link, overlay->links ){ 99 100 if( (!link->localRelay.isUnspecified()) && link->localRelay == node && link->up) { 99 if( (!link->localRelay.isUnspecified()) && link->localRelay == node && link->up) 101 100 return true; 102 }103 104 101 } 105 102 … … 108 105 109 106 SideportListener::Protocol SideportListener::getReachabilityProtocol(const NodeID& node){ 110 return (SideportListener::Protocol)(ipv4 | tcp); 107 int ret = SideportListener::undefined; 108 if( overlay == NULL ) return (Protocol)ret; 109 110 using namespace ariba::addressing; 111 112 BOOST_FOREACH( LinkDescriptor* link, overlay->links ){ 113 if(link->remoteNode == node){ 114 if(overlay->bc == NULL) continue; 115 116 BaseCommunication::LinkDescriptor& bclink = 117 overlay->bc->queryLocalLink(link->communicationId); 118 119 if(bclink.isUnspecified()) continue; 120 if(bclink.localLocator == NULL) continue; 121 122 const address_v* locator = bclink.remoteLocator; 123 124 if( locator->instanceof<tcpip_endpoint>() ){ 125 126 tcpip_endpoint tcpip = *locator; 127 128 ret |= SideportListener::tcp; 129 130 if( tcpip.address().is_v4() ) 131 ret |= SideportListener::ipv4; 132 133 if( tcpip.address().is_v6() ) 134 ret |= SideportListener::ipv6; 135 136 }else if( locator->instanceof<rfcomm_endpoint>() ){ 137 ret |= SideportListener::rfcomm; 138 } 139 } 140 } 141 142 return (Protocol)ret; 143 //return (SideportListener::Protocol)(ipv4 | tcp); 111 144 } 112 145 -
source/ariba/communication/BaseCommunication.h
r5284 r5358 95 95 96 96 namespace ariba { 97 class SideportListener; 98 } 99 100 namespace ariba { 97 101 namespace communication { 98 102 … … 114 118 * @author Sebastian Mies, Christoph Mayer 115 119 */ 116 class BaseCommunication: public NetworkChangeInterface, 117 public SystemEventListener, public transport_listener { 120 class BaseCommunication: 121 public NetworkChangeInterface, 122 public SystemEventListener, 123 public transport_listener { 124 118 125 use_logging_h(BaseCommunication); 126 friend class ariba::SideportListener; 119 127 120 128 public: -
source/ariba/overlay/OverlayBootstrap.cpp
r5344 r5358 64 64 65 65 manager.registerCallback( this ); 66 //manager.registerModule( BootstrapManager::BootstrapTypePeriodicBroadcast );67 manager.registerModule( BootstrapManager::BootstrapTypeBluetoothSdp );66 manager.registerModule( BootstrapManager::BootstrapTypePeriodicBroadcast ); 67 //manager.registerModule( BootstrapManager::BootstrapTypeBluetoothSdp ); 68 68 } 69 69 … … 76 76 77 77 manager.unregisterCallback( this ); 78 //manager.unregisterModule( BootstrapManager::BootstrapTypePeriodicBroadcast );79 manager.unregisterModule( BootstrapManager::BootstrapTypeBluetoothSdp );78 manager.unregisterModule( BootstrapManager::BootstrapTypePeriodicBroadcast ); 79 //manager.unregisterModule( BootstrapManager::BootstrapTypeBluetoothSdp ); 80 80 } 81 81 -
source/ariba/utility/bootstrap/modules/bluetoothsdp/BluetoothSdp.cpp
r5344 r5358 283 283 284 284 for (i = 0; i < num_rsp; i++) { 285 286 285 address = (ii + i)->bdaddr; 287 logging_debug("found peer " << ba2string(&address) << ", querying SDP.") 286 287 string saddress = ba2string(&address); 288 string sname = ba2name(&address, sock); 289 290 logging_debug("found peer [" << saddress << "] [" << sname << "]"); 288 291 289 292 // TODO: sdp_search can be very slow, fork it! 290 sdp_search( address);293 sdp_search( address, sname ); 291 294 } 292 295 … … 295 298 296 299 int nextscan = (rand() % 40) + 5; 297 logging_debug(" Next sdp scan in " << nextscan << " seconds");298 299 scan_timer_.expires_from_now( boost::posix_time::seconds(nextscan));300 scan_timer_.async_wait( boost::bind(&BluetoothSdp::bt_scan, this));301 } 302 303 void BluetoothSdp::sdp_search(bdaddr_t target ) {300 logging_debug("next sdp scan in " << nextscan << " seconds"); 301 302 scan_timer_.expires_from_now( boost::posix_time::seconds(nextscan) ); 303 scan_timer_.async_wait( boost::bind(&BluetoothSdp::bt_scan, this) ); 304 } 305 306 void BluetoothSdp::sdp_search(bdaddr_t target, string devicename) { 304 307 305 308 /* … … 315 318 uint8_t port = 0; 316 319 320 // connect to the SDP server running on the remote machine 321 logging_debug("querying services from bt device [" 322 << ba2string(&target) << "] [" << devicename << "]"); 323 317 324 // prepare the buffers for the attributes 318 325 char name[256], info1[256], info2[256], info3[256]; 319 326 320 // connect to the SDP server running on the remote machine321 logging_debug("querying services from bt device " << ba2string(&target));322 327 session = sdp_connect(BDADDR_ANY, &target, SDP_RETRY_IF_BUSY); 323 328 … … 377 382 } 378 383 379 string BluetoothSdp::ba2string(bdaddr_t *ba) {384 string BluetoothSdp::ba2string(bdaddr_t* ba) { 380 385 /* 381 386 * Returns a string holding the bt adress in human readable form. … … 388 393 } 389 394 395 string BluetoothSdp::ba2name(bdaddr_t* ba, int sock){ 396 397 char name[256] = {0}; 398 memset(name, 0, sizeof(name)); 399 400 if( hci_read_remote_name(sock, ba, sizeof(name), name, 0) < 0 ) 401 strcpy(name, "unknown"); 402 403 string result = name; 404 return result; 405 } 406 390 407 #endif // HAVE_BLUETOOTH_BLUETOOTH_H 391 408 -
source/ariba/utility/bootstrap/modules/bluetoothsdp/BluetoothSdp.h
r5316 r5358 85 85 #ifdef HAVE_BLUETOOTH_BLUETOOTH_H 86 86 void bt_scan(); 87 void sdp_search(bdaddr_t target); 88 string ba2string(bdaddr_t *ba); 87 void sdp_search(bdaddr_t target, string devicename); 88 string ba2string(bdaddr_t* ba); 89 string ba2name(bdaddr_t* ba, int sock); 89 90 90 91 sdp_session_t *sdp_session_; -
source/ariba/utility/system/StartupWrapper.cpp
r5344 r5358 98 98 { 99 99 log4cxx::LoggerPtr logger(log4cxx::Logger::getRootLogger()); 100 logger->setLevel(log4cxx::Level::get Warn());100 logger->setLevel(log4cxx::Level::getDebug()); 101 101 } 102 102 103 103 // set up again an individual level if you like 104 /* 104 105 { 105 106 log4cxx::LoggerPtr logger(log4cxx::Logger::getLogger("PingPong")); … … 122 123 logger->setLevel(log4cxx::Level::getDebug()); 123 124 } 125 */ 124 126 125 127 //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
Note:
See TracChangeset
for help on using the changeset viewer.