void update_service_classes(const bdaddr_t *bdaddr, uint8_t value) { struct hci_dev_list_req *dl; struct hci_dev_req *dr; int i, sk; sk = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI); if (sk < 0) return; dl = g_malloc0(HCI_MAX_DEV * sizeof(*dr) + sizeof(*dl)); dl->dev_num = HCI_MAX_DEV; dr = dl->dev_req; if (ioctl(sk, HCIGETDEVLIST, dl) < 0) { close(sk); g_free(dl); return; } dr = dl->dev_req; for (i = 0; i < dl->dev_num; i++, dr++) { struct hci_dev_info di; uint8_t cls[3]; int dd; if (hci_devinfo(dr->dev_id, &di) < 0) continue; if (hci_test_bit(HCI_RAW, &di.flags)) continue; if (get_device_class(di.dev_id, cls) < 0) continue; dd = hci_open_dev(di.dev_id); if (dd < 0) continue; set_service_classes(dd, cls, value); hci_close_dev(dd); update_adapter(di.dev_id); } g_free(dl); close(sk); }
void ethernetif_poll(struct netif *netif) { update_adapter(netif->state); /* Process the link status change */ switch (link_adapter(netif->state)) { case LINKEVENT_UP: { NOTIFY_LINKSTATE(netif,netif_set_link_up); break; } case LINKEVENT_DOWN: { NOTIFY_LINKSTATE(netif,netif_set_link_down); break; } } }