Changeset 5638 for source


Ignore:
Timestamp:
Aug 4, 2009, 10:17:33 AM (15 years ago)
Author:
Christoph Mayer
Message:

adress detection aufgeräumt, network info für bleutooth, data stream (hopeful crash fix), logging auf maemo nur warn, ...

Location:
source/ariba
Files:
3 deleted
11 edited

Legend:

Unmodified
Added
Removed
  • source/ariba/Makefile.am

    r5630 r5638  
    245245
    246246libariba_la_SOURCES += \
    247   communication/networkinfo/AddressInformation.cpp \
     247  communication/networkinfo/AddressDiscovery.cpp \
    248248  communication/networkinfo/NetworkChangeDetection.cpp \
    249249  communication/networkinfo/NetworkInformation.cpp \
     
    251251
    252252nobase_libariba_la_HEADERS += \
    253   communication/networkinfo/AddressInformation.h \
     253  communication/networkinfo/AddressDiscovery.h \
    254254  communication/networkinfo/NetworkChangeDetection.h \
    255255  communication/networkinfo/NetworkChangeInterface.h \
  • source/ariba/communication/BaseCommunication.cpp

    r5636 r5638  
    3838
    3939#include "BaseCommunication.h"
     40#include "networkinfo/AddressDiscovery.h"
    4041
    4142#ifdef UNDERLAY_OMNET
     
    5152namespace ariba {
    5253namespace communication {
    53 
    54 #include "networkinfo/AddressDiscovery.hpp"
    5554
    5655use_logging_cpp(BaseCommunication);
     
    115114
    116115        logging_info( "Searching for local locators ..." );
    117         discover_endpoints(localDescriptor.getEndpoints());
     116        AddressDiscovery::discover_endpoints( localDescriptor.getEndpoints() );
    118117        logging_info( "Done. Local endpoints = " << localDescriptor.toString() );
    119118
  • source/ariba/communication/networkinfo/NetworkInformation.cpp

    r4843 r5638  
    3838
    3939#include "NetworkInformation.h"
     40#include "ariba/config.h"
     41
     42#ifdef HAVE_BLUETOOTH_BLUETOOTH_H
     43  #include <bluetooth/bluetooth.h>
     44  #include <bluetooth/hci.h>
     45  #include <bluetooth/hci_lib.h>
     46#endif
    4047
    4148namespace ariba {
     
    192199        } // for( ; i != iend; i++ )*/
    193200
     201        //
     202        // not we try to get bluetooth interfaces
     203        //
     204
     205#ifdef HAVE_BLUETOOTH_BLUETOOTH_H
     206
     207        int btsock = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI);
     208        if(btsock <  0){
     209                logging_error("failed getting bluetooth raw socket");
     210                return retlist;
     211        }
     212
     213        struct hci_dev_list_req* btlist = NULL;
     214        struct hci_dev_req* btdev = NULL;
     215
     216        btlist = (hci_dev_list_req*)malloc(HCI_MAX_DEV *
     217                        sizeof(struct hci_dev_list_req) + sizeof(struct hci_dev_req));
     218
     219        btlist->dev_num = HCI_MAX_DEV;
     220        btdev = btlist->dev_req;
     221
     222        if(ioctl(btsock, HCIGETDEVLIST, btlist) < 0){
     223                logging_error("failed getting requesting bluetooth devices");
     224                free(btlist);
     225                close(btsock);
     226                return retlist;
     227        }
     228
     229        btdev = btlist->dev_req;
     230
     231        for(int i=0; i<btlist->dev_num; i++, btdev++){
     232                struct hci_dev_info di;
     233                NetworkInterface interface;
     234
     235                if(hci_devinfo(btdev->dev_id, &di) < 0) continue;
     236                if(hci_test_bit(HCI_RAW, &di.flags)) continue;
     237
     238                interface.name = string(di.name);
     239                interface.index = di.dev_id;
     240                interface.mtu = di.sco_mtu;
     241                interface.isBroadcast = false;
     242                interface.isLoopback = false;
     243                interface.isMulticast = false;
     244                interface.isUp = hci_test_bit(HCI_UP, &di.flags);
     245                interface.isRunning = hci_test_bit(HCI_RUNNING, &di.flags);
     246
     247                retlist.push_back( interface );
     248        }
     249
     250        free(btlist);
     251        close(btsock);
     252#endif
     253
    194254        return retlist;
    195255}
  • source/ariba/communication/networkinfo/NetworkInterface.h

    r3690 r5638  
    6363        bool    isBroadcast;
    6464        bool    isMulticast;
    65         int     mtu;
    66         int     txQueueLen;
     65        int             mtu;
     66        int             txQueueLen;
    6767
    6868        static NetworkInterface UNDEFINED;
    6969
    70         inline bool operator==(const NetworkInterface& rh ){
     70        NetworkInterface& operator=(const NetworkInterface& rh){
     71                name            = rh.name;
     72                index           = rh.index;
     73                isRunning       = rh.isRunning;
     74                isUp            = rh.isUp;
     75                isLoopback      = rh.isLoopback;
     76                isBroadcast     = rh.isBroadcast;
     77                isMulticast     = rh.isMulticast;
     78                mtu             = rh.mtu;
     79                txQueueLen      = rh.txQueueLen;
     80                return *this;
     81        }
     82
     83        bool operator==(const NetworkInterface& rh ){
    7184                // equality means same name
    7285                return ( name.compare(rh.name) == 0 );
  • source/ariba/overlay/BaseOverlay.cpp

    r5624 r5638  
    127127                // get descriptor of first hop
    128128                rld = getDescriptor(rlid);
    129                 logging_force( rld );
     129                logging_info( rld );
    130130
    131131                // is first hop a relay path? yes-> try to find real link!
     
    154154                return NodeID::UNSPECIFIED;
    155155        else {
    156                 logging_force( "Returning relay node " << relayNode.toString() );
     156                logging_info( "Returning relay node " << relayNode.toString() );
    157157                return relayNode;
    158158        }
     
    810810                // if link is a relayed link ->convert to direct link
    811811                if (ld->relay) {
    812                         logging_force( "Converting to direct link: " << ld );
     812                        logging_info( "Converting to direct link: " << ld );
    813813                        ld->up = true;
    814814                        ld->relay = false;
     
    836836        LinkDescriptor* ld = getDescriptor(id, true);
    837837        if ( ld == NULL ) return; // not found? ->ignore!
    838         logging_force( "onLinkDown descriptor: " << ld );
     838        logging_info( "onLinkDown descriptor: " << ld );
    839839
    840840        // inform listeners about link down
     
    14261426                        logging_debug( "received keep-alive on link" );
    14271427                        if ( ld != NULL ) {
    1428                                 logging_force("Keep-Alive for "<< ld->overlayId);
     1428                                logging_info("Keep-Alive for "<< ld->overlayId);
    14291429                                ld->markAlive();
    14301430                        }
     
    14451445                                break;
    14461446                        }
    1447                         logging_force( "Received direct link convert notification for " << rld );
     1447                        logging_info( "Received direct link convert notification for " << rld );
    14481448
    14491449                        // set communcation link id and set it up
     
    15601560                        // missed more than four keep-alive messages (10 sec)? -> drop link
    15611561                        if (ld->keepAliveMissed > 4) {
    1562                                 logging_force( "Link connection request is stale, closing: " << ld );
     1562                                logging_info( "Link connection request is stale, closing: " << ld );
    15631563                                oldlinks.push_back( ld );
    15641564                                continue;
     
    15881588                        // missed more than four keep-alive messages (4 sec)? -> drop link
    15891589                        if (ld->keepAliveMissed >= 8) {
    1590                                 logging_force( "Link is stale, closing: " << ld );
     1590                                logging_info( "Link is stale, closing: " << ld );
    15911591                                oldlinks.push_back( ld );
    15921592                                continue;
     
    16021602
    16031603                if (!ld->communicationId.isUnspecified() && it != bootstrapLinks.end() ){
    1604                         logging_force( "Not dropping initiator link: " << ld );
     1604                        logging_info( "Not dropping initiator link: " << ld );
    16051605                        continue;
    16061606                }
    16071607*/
    1608                 logging_force( "Link timed out. Dropping " << ld );
     1608                logging_info( "Link timed out. Dropping " << ld );
    16091609                dropLink( ld->overlayId );
    16101610        }
     
    16181618void BaseOverlay::showLinkState() {
    16191619        int i=0;
    1620         logging_force("--- link state -------------------------------");
     1620        logging_info("--- link state -------------------------------");
    16211621        BOOST_FOREACH( LinkDescriptor* ld, links ) {
    1622                 logging_force("link " << i << ": " << ld);
     1622                logging_info("link " << i << ": " << ld);
    16231623                i++;
    16241624        }
    1625         logging_force("----------------------------------------------");
     1625        logging_info("----------------------------------------------");
    16261626}
    16271627
  • source/ariba/utility/bootstrap/modules/bluetoothsdp/BluetoothSdp.cpp

    r5633 r5638  
    4141#ifdef HAVE_BLUETOOTH_BLUETOOTH_H
    4242
    43         // Attribute descriptors for SDP
    44         // base was chosen randomly
    45         #define SDP_SPOVNET_BASE                        0x4000
    46         #define SDP_ATTR_SPOVNET_NAME           0x0000 + SDP_SPOVNET_BASE
    47         #define SDP_ATTR_SPOVNET_INFO1          0x0001 + SDP_SPOVNET_BASE
    48         #define SDP_ATTR_SPOVNET_INFO2          0x0002 + SDP_SPOVNET_BASE
    49         #define SDP_ATTR_SPOVNET_INFO3          0x0003 + SDP_SPOVNET_BASE
    50 
    51         // The SpoVNet unique identifier, this should be the same for all SpoVNet implementations
    52         const uint8_t svc_uuid_int[] = {0x59, 0x29, 0x24, 0x34, 0x69, 0x42, 0x11, 0xde, 0x94,
     43// Attribute descriptors for SDP
     44// base was chosen randomly
     45#define SDP_SPOVNET_BASE                        0x4000
     46#define SDP_ATTR_SPOVNET_NAME           0x0000 + SDP_SPOVNET_BASE
     47#define SDP_ATTR_SPOVNET_INFO1          0x0001 + SDP_SPOVNET_BASE
     48#define SDP_ATTR_SPOVNET_INFO2          0x0002 + SDP_SPOVNET_BASE
     49#define SDP_ATTR_SPOVNET_INFO3          0x0003 + SDP_SPOVNET_BASE
     50
     51// The SpoVNet unique identifier, this should be the same for all SpoVNet implementations
     52const uint8_t svc_uuid_int[] = {0x59, 0x29, 0x24, 0x34, 0x69, 0x42, 0x11, 0xde, 0x94,
    5353                0x3e, 0x00, 0x21, 0x5d, 0xb4, 0xd8, 0x54};
    5454
    55         const char *service_name = "SpoVNet";
    56         const char *svc_dsc = "www.ariba-underlay.org";
    57         const char *service_prov = "ITM Uni Karlsruhe";
     55const char *service_name = "SpoVNet";
     56const char *svc_dsc = "www.ariba-underlay.org";
     57const char *service_prov = "ITM Uni Karlsruhe";
    5858
    5959#endif // HAVE_BLUETOOTH_BLUETOOTH_H
     
    6767        BootstrapModule(_callback), scan_timer_(io_service_) {
    6868        srand( time(NULL) );
    69         found = false;
    7069#ifdef HAVE_BLUETOOTH_BLUETOOTH_H
    7170
     
    141140        uuid_t root_uuid, l2cap_uuid, rfcomm_uuid, svc_uuid, svc_class_uuid;
    142141        sdp_list_t *l2cap_list = 0, *rfcomm_list = 0, *root_list = 0, *proto_list =
    143         0, *access_proto_list = 0, *svc_class_list = 0, *profile_list = 0;
     142                0, *access_proto_list = 0, *svc_class_list = 0, *profile_list = 0;
    144143        sdp_data_t *channel = 0;
    145144        sdp_profile_desc_t profile;
     
    253252
    254253void BluetoothSdp::bt_scan() {
    255         /*
    256          * Scans for other bluetooth devices and starts a SDP search on them.
    257          */
    258 
    259         logging_debug("scanning for peers");
    260 
    261         inquiry_info *ii = NULL;
    262         int max_rsp, num_rsp;
    263         int dev_id, sock, len, flags;
    264         int i;
    265 
    266         bdaddr_t address;
    267         uint8_t channel;
    268 
    269         dev_id = hci_get_route(NULL);
    270         sock = hci_open_dev(dev_id);
    271         if (dev_id < 0 || sock < 0) {
    272                 logging_error("opening socket for device "
    273                                 << dev_id << " failed. can not scan for peers: " << strerror(errno));
    274                 return;
    275         }
    276 
    277         len = 8;
    278         max_rsp = 255;
    279         flags = IREQ_CACHE_FLUSH;
    280         ii = (inquiry_info*) malloc(max_rsp * sizeof(inquiry_info));
    281 
    282         num_rsp = hci_inquiry(dev_id, len, max_rsp, NULL, &ii, flags);
    283         if (num_rsp < 0)
    284                 logging_error("hci_inquiry failed with " << num_rsp << ": " << strerror(errno));
    285 
    286         for (i = 0; i < num_rsp; i++) {
    287                 address = (ii + i)->bdaddr;
    288 
    289                 string saddress = ba2string(&address);
    290                 string sname = ba2name(&address, sock);
    291 
    292                 logging_debug("found peer [" << saddress << "] [" << sname << "]");
    293                 sdp_search( address, sname );
    294         }
    295 
    296         free(ii);
    297         close(sock);
    298 
    299         if(!found){
    300                 int nextscan = (rand() % 30) + 5;
    301                 logging_debug("next sdp scan in " << nextscan << " seconds");
    302 
    303 
    304                 scan_timer_.expires_from_now( boost::posix_time::seconds(nextscan) );
    305                 scan_timer_.async_wait( boost::bind(&BluetoothSdp::bt_scan, this) );
    306         }
     254
     255        //
     256        // scan for devices if we have no active rfcomm connections running.
     257        // otherwise we would break existing connections due to chipping seq
     258        //
     259
     260        if(!haveConnections()){
     261
     262                /*
     263                 * Scans for other bluetooth devices and starts a SDP search on them.
     264                 */
     265
     266                logging_debug("scanning for peers");
     267
     268                inquiry_info *ii = NULL;
     269                int max_rsp, num_rsp;
     270                int dev_id, sock, len, flags;
     271                int i;
     272
     273                bdaddr_t address;
     274                uint8_t channel;
     275
     276                dev_id = hci_get_route(NULL);
     277                sock = hci_open_dev(dev_id);
     278                if (dev_id < 0 || sock < 0) {
     279                        logging_error("opening socket for device "
     280                                        << dev_id << " failed. can not scan for peers: " << strerror(errno));
     281                        return;
     282                }
     283
     284                len = 8;
     285                max_rsp = 255;
     286                flags = IREQ_CACHE_FLUSH;
     287                ii = (inquiry_info*) malloc(max_rsp * sizeof(inquiry_info));
     288
     289                num_rsp = hci_inquiry(dev_id, len, max_rsp, NULL, &ii, flags);
     290                if (num_rsp < 0)
     291                        logging_error("hci_inquiry failed with " << num_rsp << ": " << strerror(errno));
     292
     293                for (i = 0; i < num_rsp; i++) {
     294                        address = (ii + i)->bdaddr;
     295
     296                        string saddress = ba2string(&address);
     297                        string sname = ba2name(&address, sock);
     298
     299                        logging_debug("found peer [" << saddress << "] [" << sname << "]");
     300                        sdp_search( address, sname );
     301                }
     302
     303                free(ii);
     304                close(sock);
     305
     306        } else {
     307                logging_debug("have active rfcomm connectinos, not searching");
     308        }
     309
     310        int nextscan = (rand() % 30) + 5;
     311        logging_debug("next sdp scan try in " << nextscan << " seconds");
     312
     313        scan_timer_.expires_from_now( boost::posix_time::seconds(nextscan) );
     314        scan_timer_.async_wait( boost::bind(&BluetoothSdp::bt_scan, this) );
    307315}
    308316
     
    372380
    373381                                // Callback
    374                                 found = true;
    375382                                callback->onBootstrapServiceFound(name, info1, info2, info3);
    376383                        }
     
    410417}
    411418
     419bool BluetoothSdp::haveConnections(){
     420
     421        struct hci_conn_list_req* cl = NULL;
     422        struct hci_conn_info* ci = NULL;
     423
     424        int btsock = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI);
     425        if(btsock <  0){
     426                logging_error("failed getting bluetooth raw socket");
     427                return true; // return true to be safe here and not perform sdp scan
     428        }
     429
     430        cl = (struct hci_conn_list_req*)malloc(10 * sizeof(struct hci_conn_info) + sizeof(struct hci_conn_list_req));
     431
     432        cl->dev_id = hci_get_route(NULL);;
     433        cl->conn_num = 10;
     434        ci = cl->conn_info;
     435
     436        if(ioctl(btsock, HCIGETCONNLIST, (void*)cl)){
     437                logging_warn("could not get active rfcomm connections");
     438                return true; // return true to be safe here and not perform sdp scan
     439        }
     440
     441        bool haveconn = (cl->conn_num > 0);
     442        logging_error("we have " << cl->conn_num << " active connections");
     443        free(cl);
     444        close(btsock);
     445
     446        return haveconn;
     447}
     448
    412449#endif // HAVE_BLUETOOTH_BLUETOOTH_H
    413450
  • source/ariba/utility/bootstrap/modules/bluetoothsdp/BluetoothSdp.h

    r5632 r5638  
    9292        sdp_session_t *sdp_session_;
    9393        uint8_t channel_;
     94
     95        bool haveConnections();
    9496#endif // HAVE_BLUETOOTH_BLUETOOTH_H
    9597
     
    9799        boost::asio::deadline_timer scan_timer_;
    98100        boost::thread t_;
    99 
    100         bool found;
    101 
    102101};
    103102
  • source/ariba/utility/bootstrap/modules/periodicbroadcast/PeriodicBroadcast.h

    r5531 r5638  
    352352                                if( it != services->end() ){
    353353
     354                                        /*
    354355                                        it->second.setInfo1( msg.getInfo1() );
    355356                                        it->second.setInfo2( msg.getInfo2() );
    356357                                        it->second.setInfo3( msg.getInfo3() );
     358                                        */
    357359                                        it->second.setLastseen( time(NULL) );
    358360
  • source/ariba/utility/logging/Logging.h

    r5634 r5638  
    4444#include <log4cxx/logger.h>
    4545#include <log4cxx/basicconfigurator.h>
    46 #include "ariba/config.h"
    4746
    4847
     
    7170        log4cxx::LoggerPtr x::logger(log4cxx::Logger::getLogger(#x));
    7271
    73 #ifdef HAVE_MAEMO
    74 
    75   #define logging_trace(x)  {                                                             }
    76   #define logging_debug(x)  {                                                             }
    77   #define logging_info(x)   {                                                             }
    78   #define logging_warn(x)   {colorWarn;  LOG4CXX_WARN(logger,x);  colorDefault;           }
    79   #define logging_error(x)  {colorError; LOG4CXX_ERROR(logger,x); colorDefault;           }
    80   #define logging_force(x)  {                                                             }
    81   #define logging_fatal(x)  {colorError; LOG4CXX_FATAL(logger,x); colorDefault; exit(-1); }
    82 
    83 #else
    84 
    85   #define logging_trace(x)  {            LOG4CXX_TRACE(logger,x);                         }
    86   #define logging_debug(x)  {colorDebug; LOG4CXX_DEBUG(logger,x); colorDefault;           }
    87   #define logging_info(x)   {colorInfo;  LOG4CXX_INFO(logger,x);  colorDefault;           }
    88   #define logging_warn(x)   {colorWarn;  LOG4CXX_WARN(logger,x);  colorDefault;           }
    89   #define logging_error(x)  {colorError; LOG4CXX_ERROR(logger,x); colorDefault;           }
    90   #define logging_force(x)  {colorInfo;  LOG4CXX_INFO(logger,x);  colorDefault;           }
    91   #define logging_fatal(x)  {colorError; LOG4CXX_FATAL(logger,x); colorDefault; exit(-1); }
    92 
    93 #endif // HAVE_MAEMO
     72#define logging_trace(x)  {            LOG4CXX_TRACE(logger,x);                         }
     73#define logging_debug(x)  {colorDebug; LOG4CXX_DEBUG(logger,x); colorDefault;           }
     74#define logging_info(x)   {colorInfo;  LOG4CXX_INFO(logger,x);  colorDefault;           }
     75#define logging_warn(x)   {colorWarn;  LOG4CXX_WARN(logger,x);  colorDefault;           }
     76#define logging_error(x)  {colorError; LOG4CXX_ERROR(logger,x); colorDefault;           }
     77#define logging_fatal(x)  {colorError; LOG4CXX_FATAL(logger,x); colorDefault; exit(-1); }
    9478
    9579#endif //LOGGING_H__
  • source/ariba/utility/serialization/DataStream.hpp

    r5284 r5638  
    509509                                i++;
    510510                        }
    511                         if (isCharP) *text = strdup(s.c_str()); else *string = s;
     511                        if (isCharP) *text = strdup(s.c_str());
     512                        else string->assign(s);
    512513                }
    513514                sznMethodEnd()
  • source/ariba/utility/system/StartupWrapper.cpp

    r5614 r5638  
    3838
    3939#include "StartupWrapper.h"
     40#include "ariba/config.h"
    4041
    4142namespace ariba {
     
    131132        // DON'T SVN COMMIT YOUR CHANGED LOGGING! THE ABOVE CODE MUST REMAIN AS IS!
    132133        //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
     134
     135#ifdef HAVE_MAEMO
     136        log4cxx::LoggerPtr logger(log4cxx::Logger::getRootLogger());
     137        logger->setLevel(log4cxx::Level::getWarn());
     138#endif
    133139}
    134140
Note: See TracChangeset for help on using the changeset viewer.