aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/mgmt.c
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2012-01-04 06:31:59 -0500
committerJohan Hedberg <johan.hedberg@intel.com>2012-02-13 10:01:19 -0500
commit561aafbcb2e3f8fee11d3781f866c7b4c4f93a28 (patch)
tree98fc5da4793bd16810a47450afe28e7304bdea8c /net/bluetooth/mgmt.c
parent32748db00228b67a5315a91e1a6dd2c54864d87b (diff)
Bluetooth: Add initial mgmt_confirm_name support
This patch adds initial support for mgmt_confirm_name. It adds the necessary tracking of the name state by extending the inquiry cache. The actual name resolving operation (to be done once inquiry is finished) is not yet part of this patch. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Acked-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/mgmt.c')
-rw-r--r--net/bluetooth/mgmt.c51
1 files changed, 50 insertions, 1 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 851cb19c55b1..39775119585a 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -1967,6 +1967,50 @@ failed:
1967 return err; 1967 return err;
1968} 1968}
1969 1969
1970static int confirm_name(struct sock *sk, u16 index, unsigned char *data,
1971 u16 len)
1972{
1973 struct mgmt_cp_confirm_name *cp = (void *) data;
1974 struct inquiry_entry *e;
1975 struct hci_dev *hdev;
1976 int err;
1977
1978 BT_DBG("hci%u", index);
1979
1980 if (len != sizeof(*cp))
1981 return cmd_status(sk, index, MGMT_OP_CONFIRM_NAME,
1982 MGMT_STATUS_INVALID_PARAMS);
1983
1984 hdev = hci_dev_get(index);
1985 if (!hdev)
1986 return cmd_status(sk, index, MGMT_OP_CONFIRM_NAME,
1987 MGMT_STATUS_INVALID_PARAMS);
1988
1989 hci_dev_lock(hdev);
1990
1991 e = hci_inquiry_cache_lookup_unknown(hdev, &cp->bdaddr);
1992 if (!e) {
1993 err = cmd_status (sk, index, MGMT_OP_CONFIRM_NAME,
1994 MGMT_STATUS_INVALID_PARAMS);
1995 goto failed;
1996 }
1997
1998 if (cp->name_known) {
1999 e->name_state = NAME_KNOWN;
2000 list_del(&e->list);
2001 } else {
2002 e->name_state = NAME_NEEDED;
2003 list_move(&e->list, &hdev->inq_cache.resolve);
2004 }
2005
2006 err = 0;
2007
2008failed:
2009 hci_dev_unlock(hdev);
2010
2011 return err;
2012}
2013
1970static int block_device(struct sock *sk, u16 index, unsigned char *data, 2014static int block_device(struct sock *sk, u16 index, unsigned char *data,
1971 u16 len) 2015 u16 len)
1972{ 2016{
@@ -2215,6 +2259,9 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen)
2215 case MGMT_OP_STOP_DISCOVERY: 2259 case MGMT_OP_STOP_DISCOVERY:
2216 err = stop_discovery(sk, index); 2260 err = stop_discovery(sk, index);
2217 break; 2261 break;
2262 case MGMT_OP_CONFIRM_NAME:
2263 err = confirm_name(sk, index, buf + sizeof(*hdr), len);
2264 break;
2218 case MGMT_OP_BLOCK_DEVICE: 2265 case MGMT_OP_BLOCK_DEVICE:
2219 err = block_device(sk, index, buf + sizeof(*hdr), len); 2266 err = block_device(sk, index, buf + sizeof(*hdr), len);
2220 break; 2267 break;
@@ -2689,7 +2736,8 @@ int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash,
2689} 2736}
2690 2737
2691int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, 2738int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
2692 u8 addr_type, u8 *dev_class, s8 rssi, u8 *eir) 2739 u8 addr_type, u8 *dev_class, s8 rssi,
2740 u8 cfm_name, u8 *eir)
2693{ 2741{
2694 struct mgmt_ev_device_found ev; 2742 struct mgmt_ev_device_found ev;
2695 2743
@@ -2698,6 +2746,7 @@ int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
2698 bacpy(&ev.addr.bdaddr, bdaddr); 2746 bacpy(&ev.addr.bdaddr, bdaddr);
2699 ev.addr.type = link_to_mgmt(link_type, addr_type); 2747 ev.addr.type = link_to_mgmt(link_type, addr_type);
2700 ev.rssi = rssi; 2748 ev.rssi = rssi;
2749 ev.confirm_name = cfm_name;
2701 2750
2702 if (eir) 2751 if (eir)
2703 memcpy(ev.eir, eir, sizeof(ev.eir)); 2752 memcpy(ev.eir, eir, sizeof(ev.eir));