mgmt: Add support for remote_name event

This commit is contained in:
Johan Hedberg 2011-03-30 12:24:42 +03:00
parent c76086fd59
commit 56fe067384
2 changed files with 33 additions and 0 deletions

View File

@ -281,3 +281,9 @@ struct mgmt_ev_device_found {
int8_t rssi;
uint8_t eir[HCI_MAX_EIR_LENGTH];
} __packed;
#define MGMT_EV_REMOTE_NAME 0x0013
struct mgmt_ev_remote_name {
bdaddr_t bdaddr;
uint8_t name[MGMT_MAX_NAME_LENGTH];
} __packed;

View File

@ -1292,6 +1292,30 @@ static void mgmt_device_found(int sk, uint16_t index, void *buf, size_t len)
btd_event_device_found(&info->bdaddr, &ev->bdaddr, cls, ev->rssi, eir);
}
static void mgmt_remote_name(int sk, uint16_t index, void *buf, size_t len)
{
struct mgmt_ev_remote_name *ev = buf;
struct controller_info *info;
char addr[18];
if (len < sizeof(*ev)) {
error("Too small mgmt_remote_name packet");
return;
}
if (index > max_index) {
error("Unexpected index %u in remote_name event", index);
return;
}
info = &controllers[index];
ba2str(&ev->bdaddr, addr);
DBG("hci%u addr %s, name %s", index, addr, ev->name);
btd_event_remote_name(&info->bdaddr, &ev->bdaddr, 0, (char *) ev->name);
}
static gboolean mgmt_event(GIOChannel *io, GIOCondition cond, gpointer user_data)
{
char buf[MGMT_BUF_SIZE];
@ -1390,6 +1414,9 @@ static gboolean mgmt_event(GIOChannel *io, GIOCondition cond, gpointer user_data
case MGMT_EV_DEVICE_FOUND:
mgmt_device_found(sk, index, buf + MGMT_HDR_SIZE, len);
break;
case MGMT_EV_REMOTE_NAME:
mgmt_remote_name(sk, index, buf + MGMT_HDR_SIZE, len);
break;
default:
error("Unknown Management opcode %u (index %u)", opcode, index);
break;