Changeset 5638 for source/ariba/communication/networkinfo
- Timestamp:
- Aug 4, 2009, 10:17:33 AM (15 years ago)
- Location:
- source/ariba/communication/networkinfo
- Files:
-
- 3 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
source/ariba/communication/networkinfo/NetworkInformation.cpp
r4843 r5638 38 38 39 39 #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 40 47 41 48 namespace ariba { … … 192 199 } // for( ; i != iend; i++ )*/ 193 200 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 194 254 return retlist; 195 255 } -
source/ariba/communication/networkinfo/NetworkInterface.h
r3690 r5638 63 63 bool isBroadcast; 64 64 bool isMulticast; 65 int mtu;66 int txQueueLen;65 int mtu; 66 int txQueueLen; 67 67 68 68 static NetworkInterface UNDEFINED; 69 69 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 ){ 71 84 // equality means same name 72 85 return ( name.compare(rh.name) == 0 );
Note:
See TracChangeset
for help on using the changeset viewer.