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, ...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.