Changeset 5358 for source/ariba


Ignore:
Timestamp:
Jul 26, 2009, 5:17:30 PM (15 years ago)
Author:
Christoph Mayer
Message:

sideport und sdp bootstrap

Location:
source/ariba
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • source/ariba/SideportListener.cpp

    r5316 r5358  
    4141#include "ariba/overlay/BaseOverlay.h"
    4242#include "ariba/overlay/LinkDescriptor.h"
     43#include "ariba/utility/addressing/endpoint_set.hpp"
    4344
    4445using ariba::overlay::LinkDescriptor;
     
    8283
    8384bool SideportListener::isRelayedNode(const NodeID& node){
     85        if( overlay == NULL ) return false;
    8486
    8587        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)
    8889                        return true;
    89                 }
    90 
    9190        }
    9291
     
    9594
    9695bool SideportListener::isRelayingNode(const NodeID& node){
     96        if( overlay == NULL ) return false;
    9797
    9898        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)
    101100                        return true;
    102                 }
    103 
    104101        }
    105102
     
    108105
    109106SideportListener::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);
    111144}
    112145
  • source/ariba/communication/BaseCommunication.h

    r5284 r5358  
    9595
    9696namespace ariba {
     97  class SideportListener;
     98}
     99
     100namespace ariba {
    97101namespace communication {
    98102
     
    114118 * @author Sebastian Mies, Christoph Mayer
    115119 */
    116 class BaseCommunication: public NetworkChangeInterface,
    117         public SystemEventListener, public transport_listener {
     120class BaseCommunication:
     121        public NetworkChangeInterface,
     122        public SystemEventListener,
     123        public transport_listener {
     124
    118125        use_logging_h(BaseCommunication);
     126        friend class ariba::SideportListener;
    119127
    120128public:
  • source/ariba/overlay/OverlayBootstrap.cpp

    r5344 r5358  
    6464
    6565        manager.registerCallback( this );
    66         //manager.registerModule( BootstrapManager::BootstrapTypePeriodicBroadcast );
    67         manager.registerModule( BootstrapManager::BootstrapTypeBluetoothSdp );
     66        manager.registerModule( BootstrapManager::BootstrapTypePeriodicBroadcast );
     67        //manager.registerModule( BootstrapManager::BootstrapTypeBluetoothSdp );
    6868}
    6969
     
    7676
    7777        manager.unregisterCallback( this );
    78         //manager.unregisterModule( BootstrapManager::BootstrapTypePeriodicBroadcast );
    79         manager.unregisterModule( BootstrapManager::BootstrapTypeBluetoothSdp );
     78        manager.unregisterModule( BootstrapManager::BootstrapTypePeriodicBroadcast );
     79        //manager.unregisterModule( BootstrapManager::BootstrapTypeBluetoothSdp );
    8080}
    8181
  • source/ariba/utility/bootstrap/modules/bluetoothsdp/BluetoothSdp.cpp

    r5344 r5358  
    283283
    284284        for (i = 0; i < num_rsp; i++) {
    285 
    286285                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 << "]");
    288291
    289292                // TODO: sdp_search can be very slow, fork it!
    290                 sdp_search(address);
     293                sdp_search( address, sname );
    291294        }
    292295
     
    295298
    296299        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
     306void BluetoothSdp::sdp_search(bdaddr_t target, string devicename) {
    304307
    305308        /*
     
    315318        uint8_t port = 0;
    316319
     320        // connect to the SDP server running on the remote machine
     321        logging_debug("querying services from bt device ["
     322                        << ba2string(&target) << "] [" << devicename << "]");
     323
    317324        // prepare the buffers for the attributes
    318325        char name[256], info1[256], info2[256], info3[256];
    319326
    320         // connect to the SDP server running on the remote machine
    321         logging_debug("querying services from bt device " << ba2string(&target));
    322327        session = sdp_connect(BDADDR_ANY, &target, SDP_RETRY_IF_BUSY);
    323328
     
    377382}
    378383
    379 string BluetoothSdp::ba2string(bdaddr_t *ba) {
     384string BluetoothSdp::ba2string(bdaddr_t* ba) {
    380385        /*
    381386         * Returns a string holding the bt adress in human readable form.
     
    388393}
    389394
     395string 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
    390407#endif // HAVE_BLUETOOTH_BLUETOOTH_H
    391408
  • source/ariba/utility/bootstrap/modules/bluetoothsdp/BluetoothSdp.h

    r5316 r5358  
    8585#ifdef HAVE_BLUETOOTH_BLUETOOTH_H
    8686        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);
    8990
    9091        sdp_session_t *sdp_session_;
  • source/ariba/utility/system/StartupWrapper.cpp

    r5344 r5358  
    9898        {
    9999                log4cxx::LoggerPtr logger(log4cxx::Logger::getRootLogger());
    100                 logger->setLevel(log4cxx::Level::getWarn());
     100                logger->setLevel(log4cxx::Level::getDebug());
    101101        }
    102102
    103103        // set up again an individual level if you like
     104        /*
    104105        {
    105106                log4cxx::LoggerPtr logger(log4cxx::Logger::getLogger("PingPong"));
     
    122123                        logger->setLevel(log4cxx::Level::getDebug());
    123124        }
     125        */
    124126
    125127        //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
Note: See TracChangeset for help on using the changeset viewer.