Changeset View
Changeset View
Standalone View
Standalone View
head/sys/netgraph/bluetooth/hci/ng_hci_evnt.c
Show First 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | |||||
static int mode_change (ng_hci_unit_p, struct mbuf *); | static int mode_change (ng_hci_unit_p, struct mbuf *); | ||||
static int data_buffer_overflow (ng_hci_unit_p, struct mbuf *); | static int data_buffer_overflow (ng_hci_unit_p, struct mbuf *); | ||||
static int read_clock_offset_compl (ng_hci_unit_p, struct mbuf *); | static int read_clock_offset_compl (ng_hci_unit_p, struct mbuf *); | ||||
static int qos_violation (ng_hci_unit_p, struct mbuf *); | static int qos_violation (ng_hci_unit_p, struct mbuf *); | ||||
static int page_scan_mode_change (ng_hci_unit_p, struct mbuf *); | static int page_scan_mode_change (ng_hci_unit_p, struct mbuf *); | ||||
static int page_scan_rep_mode_change (ng_hci_unit_p, struct mbuf *); | static int page_scan_rep_mode_change (ng_hci_unit_p, struct mbuf *); | ||||
static int sync_con_queue (ng_hci_unit_p, ng_hci_unit_con_p, int); | static int sync_con_queue (ng_hci_unit_p, ng_hci_unit_con_p, int); | ||||
static int send_data_packets (ng_hci_unit_p, int, int); | static int send_data_packets (ng_hci_unit_p, int, int); | ||||
static int le_event (ng_hci_unit_p, struct mbuf *); | |||||
/* | /* | ||||
* Process HCI event packet | * Process HCI event packet | ||||
*/ | */ | ||||
int | int | ||||
ng_hci_process_event(ng_hci_unit_p unit, struct mbuf *event) | ng_hci_process_event(ng_hci_unit_p unit, struct mbuf *event) | ||||
{ | { | ||||
Show All 29 Lines | "%s: %s - got HCI event=%#x, length=%d\n", | ||||
case NG_HCI_EVENT_CON_PKT_TYPE_CHANGED: | case NG_HCI_EVENT_CON_PKT_TYPE_CHANGED: | ||||
case NG_HCI_EVENT_BT_LOGO: | case NG_HCI_EVENT_BT_LOGO: | ||||
case NG_HCI_EVENT_VENDOR: | case NG_HCI_EVENT_VENDOR: | ||||
case NG_HCI_EVENT_REMOTE_NAME_REQ_COMPL: | case NG_HCI_EVENT_REMOTE_NAME_REQ_COMPL: | ||||
case NG_HCI_EVENT_READ_REMOTE_VER_INFO_COMPL: | case NG_HCI_EVENT_READ_REMOTE_VER_INFO_COMPL: | ||||
/* These do not need post processing */ | /* These do not need post processing */ | ||||
NG_FREE_M(event); | NG_FREE_M(event); | ||||
break; | break; | ||||
case NG_HCI_EVENT_LE: | |||||
error = le_event(unit, event); | |||||
break; | |||||
case NG_HCI_EVENT_INQUIRY_RESULT: | case NG_HCI_EVENT_INQUIRY_RESULT: | ||||
error = inquiry_result(unit, event); | error = inquiry_result(unit, event); | ||||
break; | break; | ||||
case NG_HCI_EVENT_CON_COMPL: | case NG_HCI_EVENT_CON_COMPL: | ||||
error = con_compl(unit, event); | error = con_compl(unit, event); | ||||
break; | break; | ||||
▲ Show 20 Lines • Show All 110 Lines • ▼ Show 20 Lines | |||||
/* | /* | ||||
* Send data packets to the lower layer. | * Send data packets to the lower layer. | ||||
*/ | */ | ||||
static int | static int | ||||
send_data_packets(ng_hci_unit_p unit, int link_type, int limit) | send_data_packets(ng_hci_unit_p unit, int link_type, int limit) | ||||
{ | { | ||||
ng_hci_unit_con_p con = NULL, winner = NULL; | ng_hci_unit_con_p con = NULL, winner = NULL; | ||||
int reallink_type; | |||||
item_p item = NULL; | item_p item = NULL; | ||||
int min_pending, total_sent, sent, error, v; | int min_pending, total_sent, sent, error, v; | ||||
for (total_sent = 0; limit > 0; ) { | for (total_sent = 0; limit > 0; ) { | ||||
min_pending = 0x0fffffff; | min_pending = 0x0fffffff; | ||||
winner = NULL; | winner = NULL; | ||||
/* | /* | ||||
* Find the connection that has has data to send | * Find the connection that has has data to send | ||||
* and the smallest number of pending packets | * and the smallest number of pending packets | ||||
*/ | */ | ||||
LIST_FOREACH(con, &unit->con_list, next) { | LIST_FOREACH(con, &unit->con_list, next) { | ||||
if (con->link_type != link_type) | reallink_type = (con->link_type == NG_HCI_LINK_SCO)? | ||||
NG_HCI_LINK_SCO: NG_HCI_LINK_ACL; | |||||
if (reallink_type != link_type){ | |||||
continue; | continue; | ||||
} | |||||
if (NG_BT_ITEMQ_LEN(&con->conq) == 0) | if (NG_BT_ITEMQ_LEN(&con->conq) == 0) | ||||
continue; | continue; | ||||
if (con->pending < min_pending) { | if (con->pending < min_pending) { | ||||
winner = con; | winner = con; | ||||
min_pending = con->pending; | min_pending = con->pending; | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | "%s: %s - could not send data packet, handle=%d, error=%d\n", | ||||
winner->pending ++; | winner->pending ++; | ||||
NG_HCI_STAT_BYTES_SENT(unit->stat, v); | NG_HCI_STAT_BYTES_SENT(unit->stat, v); | ||||
} | } | ||||
/* | /* | ||||
* Sync connection queue for the winner | * Sync connection queue for the winner | ||||
*/ | */ | ||||
sync_con_queue(unit, winner, sent); | sync_con_queue(unit, winner, sent); | ||||
} | } | ||||
return (total_sent); | return (total_sent); | ||||
} /* send_data_packets */ | } /* send_data_packets */ | ||||
/* | /* | ||||
* Send flow control messages to the upper layer | * Send flow control messages to the upper layer | ||||
*/ | */ | ||||
static int | static int | ||||
sync_con_queue(ng_hci_unit_p unit, ng_hci_unit_con_p con, int completed) | sync_con_queue(ng_hci_unit_p unit, ng_hci_unit_con_p con, int completed) | ||||
{ | { | ||||
hook_p hook = NULL; | hook_p hook = NULL; | ||||
struct ng_mesg *msg = NULL; | struct ng_mesg *msg = NULL; | ||||
ng_hci_sync_con_queue_ep *state = NULL; | ng_hci_sync_con_queue_ep *state = NULL; | ||||
int error; | int error; | ||||
hook = (con->link_type == NG_HCI_LINK_ACL)? unit->acl : unit->sco; | hook = (con->link_type != NG_HCI_LINK_SCO)? unit->acl : unit->sco; | ||||
if (hook == NULL || NG_HOOK_NOT_VALID(hook)) | if (hook == NULL || NG_HOOK_NOT_VALID(hook)) | ||||
return (ENOTCONN); | return (ENOTCONN); | ||||
NG_MKMESSAGE(msg, NGM_HCI_COOKIE, NGM_HCI_SYNC_CON_QUEUE, | NG_MKMESSAGE(msg, NGM_HCI_COOKIE, NGM_HCI_SYNC_CON_QUEUE, | ||||
sizeof(*state), M_NOWAIT); | sizeof(*state), M_NOWAIT); | ||||
if (msg == NULL) | if (msg == NULL) | ||||
return (ENOMEM); | return (ENOMEM); | ||||
state = (ng_hci_sync_con_queue_ep *)(msg->data); | state = (ng_hci_sync_con_queue_ep *)(msg->data); | ||||
state->con_handle = con->con_handle; | state->con_handle = con->con_handle; | ||||
state->completed = completed; | state->completed = completed; | ||||
NG_SEND_MSG_HOOK(error, unit->node, msg, hook, 0); | NG_SEND_MSG_HOOK(error, unit->node, msg, hook, 0); | ||||
return (error); | return (error); | ||||
} /* sync_con_queue */ | } /* sync_con_queue */ | ||||
/* le meta event */ | |||||
/* Inquiry result event */ | |||||
static int | |||||
le_advertizing_report(ng_hci_unit_p unit, struct mbuf *event) | |||||
{ | |||||
ng_hci_le_advertising_report_ep *ep = NULL; | |||||
ng_hci_neighbor_p n = NULL; | |||||
bdaddr_t bdaddr; | |||||
int error = 0; | |||||
u_int8_t event_type; | |||||
u_int8_t addr_type; | |||||
NG_HCI_M_PULLUP(event, sizeof(*ep)); | |||||
if (event == NULL) | |||||
return (ENOBUFS); | |||||
ep = mtod(event, ng_hci_le_advertising_report_ep *); | |||||
m_adj(event, sizeof(*ep)); | |||||
for (; ep->num_reports > 0; ep->num_reports --) { | |||||
/* Get remote unit address */ | |||||
NG_HCI_M_PULLUP(event, sizeof(u_int8_t)); | |||||
event_type = *mtod(event, u_int8_t *); | |||||
m_adj(event, sizeof(u_int8_t)); | |||||
NG_HCI_M_PULLUP(event, sizeof(u_int8_t)); | |||||
addr_type = *mtod(event, u_int8_t *); | |||||
m_adj(event, sizeof(u_int8_t)); | |||||
m_copydata(event, 0, sizeof(bdaddr), (caddr_t) &bdaddr); | |||||
m_adj(event, sizeof(bdaddr)); | |||||
/* Lookup entry in the cache */ | |||||
n = ng_hci_get_neighbor(unit, &bdaddr, (addr_type) ? NG_HCI_LINK_LE_RANDOM:NG_HCI_LINK_LE_PUBLIC); | |||||
if (n == NULL) { | |||||
/* Create new entry */ | |||||
n = ng_hci_new_neighbor(unit); | |||||
if (n == NULL) { | |||||
error = ENOMEM; | |||||
break; | |||||
} | |||||
bcopy(&bdaddr, &n->bdaddr, sizeof(n->bdaddr)); | |||||
n->addrtype = (addr_type)? NG_HCI_LINK_LE_RANDOM : | |||||
NG_HCI_LINK_LE_PUBLIC; | |||||
} else | |||||
getmicrotime(&n->updated); | |||||
#if 0 | |||||
{ | |||||
/* | |||||
* TODO: Make these information | |||||
* Available from userland. | |||||
*/ | |||||
u_int8_t length_data; | |||||
char *rssi; | |||||
NG_HCI_M_PULLUP(event, sizeof(u_int8_t)); | |||||
length_data = *mtod(event, u_int8_t *); | |||||
m_adj(event, sizeof(u_int8_t)); | |||||
/*Advertizement data*/ | |||||
NG_HCI_M_PULLUP(event, length_data); | |||||
m_adj(event, length_data); | |||||
NG_HCI_M_PULLUP(event, sizeof(char )); | |||||
/*Get RSSI*/ | |||||
rssi = mtod(event, char *); | |||||
m_adj(event, sizeof(u_int8_t)); | |||||
} | |||||
#endif | |||||
} | |||||
NG_FREE_M(event); | |||||
return (error); | |||||
} /* inquiry_result */ | |||||
static int le_connection_complete(ng_hci_unit_p unit, struct mbuf *event) | |||||
{ | |||||
int error = 0; | |||||
ng_hci_le_connection_complete_ep *ep = NULL; | |||||
ng_hci_unit_con_p con = NULL; | |||||
int link_type; | |||||
uint8_t uclass[3] = {0,0,0};//dummy uclass | |||||
NG_HCI_M_PULLUP(event, sizeof(*ep)); | |||||
if (event == NULL) | |||||
return (ENOBUFS); | |||||
ep = mtod(event, ng_hci_le_connection_complete_ep *); | |||||
link_type = (ep->address_type)? NG_HCI_LINK_LE_RANDOM : | |||||
NG_HCI_LINK_LE_PUBLIC; | |||||
/* | |||||
* Find the first connection descriptor that matches the following: | |||||
* | |||||
* 1) con->link_type == link_type | |||||
* 2) con->state == NG_HCI_CON_W4_CONN_COMPLETE | |||||
* 3) con->bdaddr == ep->address | |||||
*/ | |||||
LIST_FOREACH(con, &unit->con_list, next) | |||||
if (con->link_type == link_type && | |||||
con->state == NG_HCI_CON_W4_CONN_COMPLETE && | |||||
bcmp(&con->bdaddr, &ep->address, sizeof(bdaddr_t)) == 0) | |||||
break; | |||||
/* | |||||
* Two possible cases: | |||||
* | |||||
* 1) We have found connection descriptor. That means upper layer has | |||||
* requested this connection via LP_CON_REQ message. In this case | |||||
* connection must have timeout set. If ng_hci_con_untimeout() fails | |||||
* then timeout message already went into node's queue. In this case | |||||
* ignore Connection_Complete event and let timeout deal with it. | |||||
* | |||||
* 2) We do not have connection descriptor. That means upper layer | |||||
* nas not requested this connection , (less likely) we gave up | |||||
* on this connection (timeout) or as node act as slave role. | |||||
* The most likely scenario is that | |||||
* we have received LE_Create_Connection command | |||||
* from the RAW hook | |||||
*/ | |||||
if (con == NULL) { | |||||
if (ep->status != 0) | |||||
goto out; | |||||
con = ng_hci_new_con(unit, link_type); | |||||
if (con == NULL) { | |||||
error = ENOMEM; | |||||
goto out; | |||||
} | |||||
con->state = NG_HCI_CON_W4_LP_CON_RSP; | |||||
ng_hci_con_timeout(con); | |||||
bcopy(&ep->address, &con->bdaddr, sizeof(con->bdaddr)); | |||||
error = ng_hci_lp_con_ind(con, uclass); | |||||
if (error != 0) { | |||||
ng_hci_con_untimeout(con); | |||||
ng_hci_free_con(con); | |||||
} | |||||
} else if ((error = ng_hci_con_untimeout(con)) != 0) | |||||
goto out; | |||||
/* | |||||
* Update connection descriptor and send notification | |||||
* to the upper layers. | |||||
*/ | |||||
con->con_handle = NG_HCI_CON_HANDLE(le16toh(ep->handle)); | |||||
con->encryption_mode = NG_HCI_ENCRYPTION_MODE_NONE; | |||||
ng_hci_lp_con_cfm(con, ep->status); | |||||
/* Adjust connection state */ | |||||
if (ep->status != 0) | |||||
ng_hci_free_con(con); | |||||
else { | |||||
con->state = NG_HCI_CON_OPEN; | |||||
/* | |||||
* Change link policy for the ACL connections. Enable all | |||||
* supported link modes. Enable Role switch as well if | |||||
* device supports it. | |||||
*/ | |||||
} | |||||
out: | |||||
NG_FREE_M(event); | |||||
return (error); | |||||
} | |||||
static int le_connection_update(ng_hci_unit_p unit, struct mbuf *event) | |||||
{ | |||||
int error = 0; | |||||
/*TBD*/ | |||||
NG_FREE_M(event); | |||||
return error; | |||||
} | |||||
static int | |||||
le_event(ng_hci_unit_p unit, struct mbuf *event) | |||||
{ | |||||
int error = 0; | |||||
ng_hci_le_ep *lep; | |||||
NG_HCI_M_PULLUP(event, sizeof(*lep)); | |||||
if(event ==NULL){ | |||||
return ENOBUFS; | |||||
} | |||||
lep = mtod(event, ng_hci_le_ep *); | |||||
m_adj(event, sizeof(*lep)); | |||||
switch(lep->subevent_code){ | |||||
case NG_HCI_LEEV_CON_COMPL: | |||||
le_connection_complete(unit, event); | |||||
break; | |||||
case NG_HCI_LEEV_ADVREP: | |||||
le_advertizing_report(unit, event); | |||||
break; | |||||
case NG_HCI_LEEV_CON_UPDATE_COMPL: | |||||
le_connection_update(unit, event); | |||||
break; | |||||
case NG_HCI_LEEV_READ_REMOTE_FEATURES_COMPL: | |||||
//TBD | |||||
/*FALLTHROUGH*/ | |||||
case NG_HCI_LEEV_LONG_TERM_KEY_REQUEST: | |||||
//TBD | |||||
/*FALLTHROUGH*/ | |||||
default: | |||||
NG_FREE_M(event); | |||||
} | |||||
return error; | |||||
} | |||||
/* Inquiry result event */ | /* Inquiry result event */ | ||||
static int | static int | ||||
inquiry_result(ng_hci_unit_p unit, struct mbuf *event) | inquiry_result(ng_hci_unit_p unit, struct mbuf *event) | ||||
{ | { | ||||
ng_hci_inquiry_result_ep *ep = NULL; | ng_hci_inquiry_result_ep *ep = NULL; | ||||
ng_hci_neighbor_p n = NULL; | ng_hci_neighbor_p n = NULL; | ||||
bdaddr_t bdaddr; | bdaddr_t bdaddr; | ||||
int error = 0; | int error = 0; | ||||
NG_HCI_M_PULLUP(event, sizeof(*ep)); | NG_HCI_M_PULLUP(event, sizeof(*ep)); | ||||
if (event == NULL) | if (event == NULL) | ||||
return (ENOBUFS); | return (ENOBUFS); | ||||
ep = mtod(event, ng_hci_inquiry_result_ep *); | ep = mtod(event, ng_hci_inquiry_result_ep *); | ||||
m_adj(event, sizeof(*ep)); | m_adj(event, sizeof(*ep)); | ||||
for (; ep->num_responses > 0; ep->num_responses --) { | for (; ep->num_responses > 0; ep->num_responses --) { | ||||
/* Get remote unit address */ | /* Get remote unit address */ | ||||
m_copydata(event, 0, sizeof(bdaddr), (caddr_t) &bdaddr); | m_copydata(event, 0, sizeof(bdaddr), (caddr_t) &bdaddr); | ||||
m_adj(event, sizeof(bdaddr)); | m_adj(event, sizeof(bdaddr)); | ||||
/* Lookup entry in the cache */ | /* Lookup entry in the cache */ | ||||
n = ng_hci_get_neighbor(unit, &bdaddr); | n = ng_hci_get_neighbor(unit, &bdaddr, NG_HCI_LINK_ACL); | ||||
if (n == NULL) { | if (n == NULL) { | ||||
/* Create new entry */ | /* Create new entry */ | ||||
n = ng_hci_new_neighbor(unit); | n = ng_hci_new_neighbor(unit); | ||||
if (n == NULL) { | if (n == NULL) { | ||||
error = ENOMEM; | error = ENOMEM; | ||||
break; | break; | ||||
} | } | ||||
} else | } else | ||||
getmicrotime(&n->updated); | getmicrotime(&n->updated); | ||||
bcopy(&bdaddr, &n->bdaddr, sizeof(n->bdaddr)); | bcopy(&bdaddr, &n->bdaddr, sizeof(n->bdaddr)); | ||||
n->addrtype = NG_HCI_LINK_ACL; | |||||
/* XXX call m_pullup here? */ | /* XXX call m_pullup here? */ | ||||
n->page_scan_rep_mode = *mtod(event, u_int8_t *); | n->page_scan_rep_mode = *mtod(event, u_int8_t *); | ||||
m_adj(event, sizeof(u_int8_t)); | m_adj(event, sizeof(u_int8_t)); | ||||
/* page_scan_period_mode */ | /* page_scan_period_mode */ | ||||
m_adj(event, sizeof(u_int8_t)); | m_adj(event, sizeof(u_int8_t)); | ||||
▲ Show 20 Lines • Show All 340 Lines • ▼ Show 20 Lines | if (con == NULL) { | ||||
NG_HCI_ALERT( | NG_HCI_ALERT( | ||||
"%s: %s - invalid connection handle=%d\n", | "%s: %s - invalid connection handle=%d\n", | ||||
__func__, NG_NODE_NAME(unit->node), h); | __func__, NG_NODE_NAME(unit->node), h); | ||||
error = ENOENT; | error = ENOENT; | ||||
goto out; | goto out; | ||||
} | } | ||||
/* Update cache entry */ | /* Update cache entry */ | ||||
n = ng_hci_get_neighbor(unit, &con->bdaddr); | n = ng_hci_get_neighbor(unit, &con->bdaddr, NG_HCI_LINK_ACL); | ||||
if (n == NULL) { | if (n == NULL) { | ||||
n = ng_hci_new_neighbor(unit); | n = ng_hci_new_neighbor(unit); | ||||
if (n == NULL) { | if (n == NULL) { | ||||
error = ENOMEM; | error = ENOMEM; | ||||
goto out; | goto out; | ||||
} | } | ||||
bcopy(&con->bdaddr, &n->bdaddr, sizeof(n->bdaddr)); | bcopy(&con->bdaddr, &n->bdaddr, sizeof(n->bdaddr)); | ||||
n->addrtype = NG_HCI_LINK_ACL; | |||||
} else | } else | ||||
getmicrotime(&n->updated); | getmicrotime(&n->updated); | ||||
bcopy(ep->features, n->features, sizeof(n->features)); | bcopy(ep->features, n->features, sizeof(n->features)); | ||||
} else | } else | ||||
NG_HCI_ERR( | NG_HCI_ERR( | ||||
"%s: %s - failed to read remote unit features, status=%d\n", | "%s: %s - failed to read remote unit features, status=%d\n", | ||||
__func__, NG_NODE_NAME(unit->node), ep->status); | __func__, NG_NODE_NAME(unit->node), ep->status); | ||||
▲ Show 20 Lines • Show All 130 Lines • ▼ Show 20 Lines | |||||
"%s: %s - pending packet counter is out of sync! " \ | "%s: %s - pending packet counter is out of sync! " \ | ||||
"handle=%d, pending=%d, ncp=%d\n", __func__, NG_NODE_NAME(unit->node), | "handle=%d, pending=%d, ncp=%d\n", __func__, NG_NODE_NAME(unit->node), | ||||
con->con_handle, con->pending, p); | con->con_handle, con->pending, p); | ||||
con->pending = 0; | con->pending = 0; | ||||
} | } | ||||
/* Update buffer descriptor */ | /* Update buffer descriptor */ | ||||
if (con->link_type == NG_HCI_LINK_ACL) | if (con->link_type != NG_HCI_LINK_SCO) | ||||
NG_HCI_BUFF_ACL_FREE(unit->buffer, p); | NG_HCI_BUFF_ACL_FREE(unit->buffer, p); | ||||
else | else | ||||
NG_HCI_BUFF_SCO_FREE(unit->buffer, p); | NG_HCI_BUFF_SCO_FREE(unit->buffer, p); | ||||
} else | } else | ||||
NG_HCI_ALERT( | NG_HCI_ALERT( | ||||
"%s: %s - invalid connection handle=%d\n", | "%s: %s - invalid connection handle=%d\n", | ||||
__func__, NG_NODE_NAME(unit->node), h); | __func__, NG_NODE_NAME(unit->node), h); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | if (con == NULL) { | ||||
NG_HCI_ALERT( | NG_HCI_ALERT( | ||||
"%s: %s - invalid connection handle=%d\n", | "%s: %s - invalid connection handle=%d\n", | ||||
__func__, NG_NODE_NAME(unit->node), h); | __func__, NG_NODE_NAME(unit->node), h); | ||||
error = ENOENT; | error = ENOENT; | ||||
goto out; | goto out; | ||||
} | } | ||||
/* Update cache entry */ | /* Update cache entry */ | ||||
n = ng_hci_get_neighbor(unit, &con->bdaddr); | n = ng_hci_get_neighbor(unit, &con->bdaddr, NG_HCI_LINK_ACL); | ||||
if (n == NULL) { | if (n == NULL) { | ||||
n = ng_hci_new_neighbor(unit); | n = ng_hci_new_neighbor(unit); | ||||
if (n == NULL) { | if (n == NULL) { | ||||
error = ENOMEM; | error = ENOMEM; | ||||
goto out; | goto out; | ||||
} | } | ||||
bcopy(&con->bdaddr, &n->bdaddr, sizeof(n->bdaddr)); | bcopy(&con->bdaddr, &n->bdaddr, sizeof(n->bdaddr)); | ||||
n->addrtype = NG_HCI_LINK_ACL; | |||||
} else | } else | ||||
getmicrotime(&n->updated); | getmicrotime(&n->updated); | ||||
n->clock_offset = le16toh(ep->clock_offset); | n->clock_offset = le16toh(ep->clock_offset); | ||||
} else | } else | ||||
NG_HCI_ERR( | NG_HCI_ERR( | ||||
"%s: %s - failed to Read Remote Clock Offset, status=%d\n", | "%s: %s - failed to Read Remote Clock Offset, status=%d\n", | ||||
__func__, NG_NODE_NAME(unit->node), ep->status); | __func__, NG_NODE_NAME(unit->node), ep->status); | ||||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | page_scan_mode_change(ng_hci_unit_p unit, struct mbuf *event) | ||||
NG_HCI_M_PULLUP(event, sizeof(*ep)); | NG_HCI_M_PULLUP(event, sizeof(*ep)); | ||||
if (event == NULL) | if (event == NULL) | ||||
return (ENOBUFS); | return (ENOBUFS); | ||||
ep = mtod(event, ng_hci_page_scan_mode_change_ep *); | ep = mtod(event, ng_hci_page_scan_mode_change_ep *); | ||||
/* Update cache entry */ | /* Update cache entry */ | ||||
n = ng_hci_get_neighbor(unit, &ep->bdaddr); | n = ng_hci_get_neighbor(unit, &ep->bdaddr, NG_HCI_LINK_ACL); | ||||
if (n == NULL) { | if (n == NULL) { | ||||
n = ng_hci_new_neighbor(unit); | n = ng_hci_new_neighbor(unit); | ||||
if (n == NULL) { | if (n == NULL) { | ||||
error = ENOMEM; | error = ENOMEM; | ||||
goto out; | goto out; | ||||
} | } | ||||
bcopy(&ep->bdaddr, &n->bdaddr, sizeof(n->bdaddr)); | bcopy(&ep->bdaddr, &n->bdaddr, sizeof(n->bdaddr)); | ||||
n->addrtype = NG_HCI_LINK_ACL; | |||||
} else | } else | ||||
getmicrotime(&n->updated); | getmicrotime(&n->updated); | ||||
n->page_scan_mode = ep->page_scan_mode; | n->page_scan_mode = ep->page_scan_mode; | ||||
out: | out: | ||||
NG_FREE_M(event); | NG_FREE_M(event); | ||||
return (error); | return (error); | ||||
Show All 9 Lines | page_scan_rep_mode_change(ng_hci_unit_p unit, struct mbuf *event) | ||||
NG_HCI_M_PULLUP(event, sizeof(*ep)); | NG_HCI_M_PULLUP(event, sizeof(*ep)); | ||||
if (event == NULL) | if (event == NULL) | ||||
return (ENOBUFS); | return (ENOBUFS); | ||||
ep = mtod(event, ng_hci_page_scan_rep_mode_change_ep *); | ep = mtod(event, ng_hci_page_scan_rep_mode_change_ep *); | ||||
/* Update cache entry */ | /* Update cache entry */ | ||||
n = ng_hci_get_neighbor(unit, &ep->bdaddr); | n = ng_hci_get_neighbor(unit, &ep->bdaddr, NG_HCI_LINK_ACL); | ||||
if (n == NULL) { | if (n == NULL) { | ||||
n = ng_hci_new_neighbor(unit); | n = ng_hci_new_neighbor(unit); | ||||
if (n == NULL) { | if (n == NULL) { | ||||
error = ENOMEM; | error = ENOMEM; | ||||
goto out; | goto out; | ||||
} | } | ||||
bcopy(&ep->bdaddr, &n->bdaddr, sizeof(n->bdaddr)); | bcopy(&ep->bdaddr, &n->bdaddr, sizeof(n->bdaddr)); | ||||
n->addrtype = NG_HCI_LINK_ACL; | |||||
} else | } else | ||||
getmicrotime(&n->updated); | getmicrotime(&n->updated); | ||||
n->page_scan_rep_mode = ep->page_scan_rep_mode; | n->page_scan_rep_mode = ep->page_scan_rep_mode; | ||||
out: | out: | ||||
NG_FREE_M(event); | NG_FREE_M(event); | ||||
return (error); | return (error); | ||||
} /* page_scan_rep_mode_change */ | } /* page_scan_rep_mode_change */ | ||||