aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichał Narajowski <michal.narajowski@codecoup.pl>2016-09-19 14:25:53 -0400
committerMarcel Holtmann <marcel@holtmann.org>2016-09-19 14:33:27 -0400
commitcde7a863d36a4a629c111f37edc2297d6b822a82 (patch)
treec0f8281fa505143a10f370c536d5d1ee0000d513
parent7d5c11da1ff6389511c42448f59456373edfc103 (diff)
Bluetooth: Factor appending EIR to separate helper
This will also be used for Extended Information Event handling. Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl> Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
-rw-r--r--net/bluetooth/mgmt.c35
1 files changed, 22 insertions, 13 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 604c48142848..2b6fe10256b9 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -878,13 +878,32 @@ static inline u16 eir_append_data(u8 *eir, u16 eir_len, u8 type, u8 *data,
878 return eir_len; 878 return eir_len;
879} 879}
880 880
881static u16 append_eir_data_to_buf(struct hci_dev *hdev, u8 *eir)
882{
883 u16 eir_len = 0;
884 size_t name_len;
885
886 if (hci_dev_test_flag(hdev, HCI_BREDR_ENABLED))
887 eir_len = eir_append_data(eir, eir_len, EIR_CLASS_OF_DEV,
888 hdev->dev_class, 3);
889
890 name_len = strlen(hdev->dev_name);
891 eir_len = eir_append_data(eir, eir_len, EIR_NAME_COMPLETE,
892 hdev->dev_name, name_len);
893
894 name_len = strlen(hdev->short_name);
895 eir_len = eir_append_data(eir, eir_len, EIR_NAME_SHORT,
896 hdev->short_name, name_len);
897
898 return eir_len;
899}
900
881static int read_ext_controller_info(struct sock *sk, struct hci_dev *hdev, 901static int read_ext_controller_info(struct sock *sk, struct hci_dev *hdev,
882 void *data, u16 data_len) 902 void *data, u16 data_len)
883{ 903{
884 char buf[512]; 904 char buf[512];
885 struct mgmt_rp_read_ext_info *rp = (void *)buf; 905 struct mgmt_rp_read_ext_info *rp = (void *)buf;
886 u16 eir_len = 0; 906 u16 eir_len;
887 size_t name_len;
888 907
889 BT_DBG("sock %p %s", sk, hdev->name); 908 BT_DBG("sock %p %s", sk, hdev->name);
890 909
@@ -900,18 +919,8 @@ static int read_ext_controller_info(struct sock *sk, struct hci_dev *hdev,
900 rp->supported_settings = cpu_to_le32(get_supported_settings(hdev)); 919 rp->supported_settings = cpu_to_le32(get_supported_settings(hdev));
901 rp->current_settings = cpu_to_le32(get_current_settings(hdev)); 920 rp->current_settings = cpu_to_le32(get_current_settings(hdev));
902 921
903 if (hci_dev_test_flag(hdev, HCI_BREDR_ENABLED))
904 eir_len = eir_append_data(rp->eir, eir_len, EIR_CLASS_OF_DEV,
905 hdev->dev_class, 3);
906
907 name_len = strlen(hdev->dev_name);
908 eir_len = eir_append_data(rp->eir, eir_len, EIR_NAME_COMPLETE,
909 hdev->dev_name, name_len);
910
911 name_len = strlen(hdev->short_name);
912 eir_len = eir_append_data(rp->eir, eir_len, EIR_NAME_SHORT,
913 hdev->short_name, name_len);
914 922
923 eir_len = append_eir_data_to_buf(hdev, rp->eir);
915 rp->eir_len = cpu_to_le16(eir_len); 924 rp->eir_len = cpu_to_le16(eir_len);
916 925
917 hci_dev_unlock(hdev); 926 hci_dev_unlock(hdev);