Changeset View
Changeset View
Standalone View
Standalone View
head/sys/netgraph/bluetooth/hci/ng_hci_misc.c
Show First 20 Lines • Show All 208 Lines • ▼ Show 20 Lines | while (!LIST_EMPTY(&unit->neighbors)) | ||||
ng_hci_free_neighbor(LIST_FIRST(&unit->neighbors)); | ng_hci_free_neighbor(LIST_FIRST(&unit->neighbors)); | ||||
} /* ng_hci_flush_neighbor_cache */ | } /* ng_hci_flush_neighbor_cache */ | ||||
/* | /* | ||||
* Lookup unit in neighbor cache | * Lookup unit in neighbor cache | ||||
*/ | */ | ||||
ng_hci_neighbor_p | ng_hci_neighbor_p | ||||
ng_hci_get_neighbor(ng_hci_unit_p unit, bdaddr_p bdaddr) | ng_hci_get_neighbor(ng_hci_unit_p unit, bdaddr_p bdaddr,int link_type) | ||||
{ | { | ||||
ng_hci_neighbor_p n = NULL; | ng_hci_neighbor_p n = NULL; | ||||
for (n = LIST_FIRST(&unit->neighbors); n != NULL; ) { | for (n = LIST_FIRST(&unit->neighbors); n != NULL; ) { | ||||
ng_hci_neighbor_p nn = LIST_NEXT(n, next); | ng_hci_neighbor_p nn = LIST_NEXT(n, next); | ||||
if (!ng_hci_neighbor_stale(n)) { | if (!ng_hci_neighbor_stale(n)) { | ||||
if (bcmp(&n->bdaddr, bdaddr, sizeof(*bdaddr)) == 0) | if (n->addrtype == link_type && | ||||
bcmp(&n->bdaddr, bdaddr, sizeof(*bdaddr)) == 0) | |||||
break; | break; | ||||
} else | } else | ||||
ng_hci_free_neighbor(n); /* remove old entry */ | ng_hci_free_neighbor(n); /* remove old entry */ | ||||
n = nn; | n = nn; | ||||
} | } | ||||
return (n); | return (n); | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | if (con != NULL) { | ||||
*/ | */ | ||||
con->con_handle = fake_con_handle ++; | con->con_handle = fake_con_handle ++; | ||||
if (fake_con_handle > 0x0fff) | if (fake_con_handle > 0x0fff) | ||||
fake_con_handle = 0x0f00; | fake_con_handle = 0x0f00; | ||||
con->link_type = link_type; | con->link_type = link_type; | ||||
if (con->link_type == NG_HCI_LINK_ACL) | if (con->link_type != NG_HCI_LINK_SCO) | ||||
NG_HCI_BUFF_ACL_TOTAL(unit->buffer, num_pkts); | NG_HCI_BUFF_ACL_TOTAL(unit->buffer, num_pkts); | ||||
else | else | ||||
NG_HCI_BUFF_SCO_TOTAL(unit->buffer, num_pkts); | NG_HCI_BUFF_SCO_TOTAL(unit->buffer, num_pkts); | ||||
NG_BT_ITEMQ_INIT(&con->conq, num_pkts); | NG_BT_ITEMQ_INIT(&con->conq, num_pkts); | ||||
ng_callout_init(&con->con_timo); | ng_callout_init(&con->con_timo); | ||||
Show All 12 Lines | |||||
{ | { | ||||
LIST_REMOVE(con, next); | LIST_REMOVE(con, next); | ||||
/* | /* | ||||
* If we have pending packets then assume that Host Controller has | * If we have pending packets then assume that Host Controller has | ||||
* flushed these packets and we can free them too | * flushed these packets and we can free them too | ||||
*/ | */ | ||||
if (con->link_type == NG_HCI_LINK_ACL) | if (con->link_type != NG_HCI_LINK_SCO) | ||||
NG_HCI_BUFF_ACL_FREE(con->unit->buffer, con->pending); | NG_HCI_BUFF_ACL_FREE(con->unit->buffer, con->pending); | ||||
else | else | ||||
NG_HCI_BUFF_SCO_FREE(con->unit->buffer, con->pending); | NG_HCI_BUFF_SCO_FREE(con->unit->buffer, con->pending); | ||||
NG_BT_ITEMQ_DESTROY(&con->conq); | NG_BT_ITEMQ_DESTROY(&con->conq); | ||||
bzero(con, sizeof(*con)); | bzero(con, sizeof(*con)); | ||||
free(con, M_NETGRAPH_HCI); | free(con, M_NETGRAPH_HCI); | ||||
▲ Show 20 Lines • Show All 174 Lines • Show Last 20 Lines |