Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Bluetooth: Move HCI socket definitions into its own header file

All the HCI sockets and ioctl based definitions have been in a global
header file that also includes all the HCI protocol structures. To
make this a bit cleaner, move them into its own file.

This also adjusts fs/compat_ioctl.c to only include this new file
and not all the protocol structures that are not needed.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>

authored by

Marcel Holtmann and committed by
Johan Hedberg
f49daa81 12aa4f0a

+177 -150
+1 -1
fs/compat_ioctl.c
··· 59 59 #include <linux/gfp.h> 60 60 61 61 #include <net/bluetooth/bluetooth.h> 62 - #include <net/bluetooth/hci.h> 62 + #include <net/bluetooth/hci_sock.h> 63 63 #include <net/bluetooth/rfcomm.h> 64 64 65 65 #include <linux/capi.h>
-149
include/net/bluetooth/hci.h
··· 202 202 #define HCI_PERSISTENT_MASK (BIT(HCI_LE_SCAN) | BIT(HCI_PERIODIC_INQ) | \ 203 203 BIT(HCI_FAST_CONNECTABLE) | BIT(HCI_LE_ADV)) 204 204 205 - /* HCI ioctl defines */ 206 - #define HCIDEVUP _IOW('H', 201, int) 207 - #define HCIDEVDOWN _IOW('H', 202, int) 208 - #define HCIDEVRESET _IOW('H', 203, int) 209 - #define HCIDEVRESTAT _IOW('H', 204, int) 210 - 211 - #define HCIGETDEVLIST _IOR('H', 210, int) 212 - #define HCIGETDEVINFO _IOR('H', 211, int) 213 - #define HCIGETCONNLIST _IOR('H', 212, int) 214 - #define HCIGETCONNINFO _IOR('H', 213, int) 215 - #define HCIGETAUTHINFO _IOR('H', 215, int) 216 - 217 - #define HCISETRAW _IOW('H', 220, int) 218 - #define HCISETSCAN _IOW('H', 221, int) 219 - #define HCISETAUTH _IOW('H', 222, int) 220 - #define HCISETENCRYPT _IOW('H', 223, int) 221 - #define HCISETPTYPE _IOW('H', 224, int) 222 - #define HCISETLINKPOL _IOW('H', 225, int) 223 - #define HCISETLINKMODE _IOW('H', 226, int) 224 - #define HCISETACLMTU _IOW('H', 227, int) 225 - #define HCISETSCOMTU _IOW('H', 228, int) 226 - 227 - #define HCIBLOCKADDR _IOW('H', 230, int) 228 - #define HCIUNBLOCKADDR _IOW('H', 231, int) 229 - 230 - #define HCIINQUIRY _IOR('H', 240, int) 231 - 232 205 /* HCI timeouts */ 233 206 #define HCI_DISCONN_TIMEOUT msecs_to_jiffies(2000) /* 2 seconds */ 234 207 #define HCI_PAIRING_TIMEOUT msecs_to_jiffies(60000) /* 60 seconds */ ··· 1843 1870 #define hci_handle_pack(h, f) ((__u16) ((h & 0x0fff)|(f << 12))) 1844 1871 #define hci_handle(h) (h & 0x0fff) 1845 1872 #define hci_flags(h) (h >> 12) 1846 - 1847 - /* ---- HCI Sockets ---- */ 1848 - 1849 - /* Socket options */ 1850 - #define HCI_DATA_DIR 1 1851 - #define HCI_FILTER 2 1852 - #define HCI_TIME_STAMP 3 1853 - 1854 - /* CMSG flags */ 1855 - #define HCI_CMSG_DIR 0x0001 1856 - #define HCI_CMSG_TSTAMP 0x0002 1857 - 1858 - struct sockaddr_hci { 1859 - sa_family_t hci_family; 1860 - unsigned short hci_dev; 1861 - unsigned short hci_channel; 1862 - }; 1863 - #define HCI_DEV_NONE 0xffff 1864 - 1865 - #define HCI_CHANNEL_RAW 0 1866 - #define HCI_CHANNEL_USER 1 1867 - #define HCI_CHANNEL_MONITOR 2 1868 - #define HCI_CHANNEL_CONTROL 3 1869 - 1870 - struct hci_filter { 1871 - unsigned long type_mask; 1872 - unsigned long event_mask[2]; 1873 - __le16 opcode; 1874 - }; 1875 - 1876 - struct hci_ufilter { 1877 - __u32 type_mask; 1878 - __u32 event_mask[2]; 1879 - __le16 opcode; 1880 - }; 1881 - 1882 - #define HCI_FLT_TYPE_BITS 31 1883 - #define HCI_FLT_EVENT_BITS 63 1884 - #define HCI_FLT_OGF_BITS 63 1885 - #define HCI_FLT_OCF_BITS 127 1886 - 1887 - /* ---- HCI Ioctl requests structures ---- */ 1888 - struct hci_dev_stats { 1889 - __u32 err_rx; 1890 - __u32 err_tx; 1891 - __u32 cmd_tx; 1892 - __u32 evt_rx; 1893 - __u32 acl_tx; 1894 - __u32 acl_rx; 1895 - __u32 sco_tx; 1896 - __u32 sco_rx; 1897 - __u32 byte_rx; 1898 - __u32 byte_tx; 1899 - }; 1900 - 1901 - struct hci_dev_info { 1902 - __u16 dev_id; 1903 - char name[8]; 1904 - 1905 - bdaddr_t bdaddr; 1906 - 1907 - __u32 flags; 1908 - __u8 type; 1909 - 1910 - __u8 features[8]; 1911 - 1912 - __u32 pkt_type; 1913 - __u32 link_policy; 1914 - __u32 link_mode; 1915 - 1916 - __u16 acl_mtu; 1917 - __u16 acl_pkts; 1918 - __u16 sco_mtu; 1919 - __u16 sco_pkts; 1920 - 1921 - struct hci_dev_stats stat; 1922 - }; 1923 - 1924 - struct hci_conn_info { 1925 - __u16 handle; 1926 - bdaddr_t bdaddr; 1927 - __u8 type; 1928 - __u8 out; 1929 - __u16 state; 1930 - __u32 link_mode; 1931 - }; 1932 - 1933 - struct hci_dev_req { 1934 - __u16 dev_id; 1935 - __u32 dev_opt; 1936 - }; 1937 - 1938 - struct hci_dev_list_req { 1939 - __u16 dev_num; 1940 - struct hci_dev_req dev_req[0]; /* hci_dev_req structures */ 1941 - }; 1942 - 1943 - struct hci_conn_list_req { 1944 - __u16 dev_id; 1945 - __u16 conn_num; 1946 - struct hci_conn_info conn_info[0]; 1947 - }; 1948 - 1949 - struct hci_conn_info_req { 1950 - bdaddr_t bdaddr; 1951 - __u8 type; 1952 - struct hci_conn_info conn_info[0]; 1953 - }; 1954 - 1955 - struct hci_auth_info_req { 1956 - bdaddr_t bdaddr; 1957 - __u8 type; 1958 - }; 1959 - 1960 - struct hci_inquiry_req { 1961 - __u16 dev_id; 1962 - __u16 flags; 1963 - __u8 lap[3]; 1964 - __u8 length; 1965 - __u8 num_rsp; 1966 - }; 1967 - #define IREQ_CACHE_FLUSH 0x0001 1968 1873 1969 1874 #endif /* __HCI_H */
+1
include/net/bluetooth/hci_core.h
··· 26 26 #define __HCI_CORE_H 27 27 28 28 #include <net/bluetooth/hci.h> 29 + #include <net/bluetooth/hci_sock.h> 29 30 30 31 /* HCI priority */ 31 32 #define HCI_PRIO_MAX 7
+175
include/net/bluetooth/hci_sock.h
··· 1 + /* 2 + BlueZ - Bluetooth protocol stack for Linux 3 + Copyright (C) 2000-2001 Qualcomm Incorporated 4 + 5 + Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com> 6 + 7 + This program is free software; you can redistribute it and/or modify 8 + it under the terms of the GNU General Public License version 2 as 9 + published by the Free Software Foundation; 10 + 11 + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 12 + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. 14 + IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY 15 + CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES 16 + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 + 20 + ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 21 + COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS 22 + SOFTWARE IS DISCLAIMED. 23 + */ 24 + 25 + #ifndef __HCI_SOCK_H 26 + #define __HCI_SOCK_H 27 + 28 + /* Socket options */ 29 + #define HCI_DATA_DIR 1 30 + #define HCI_FILTER 2 31 + #define HCI_TIME_STAMP 3 32 + 33 + /* CMSG flags */ 34 + #define HCI_CMSG_DIR 0x0001 35 + #define HCI_CMSG_TSTAMP 0x0002 36 + 37 + struct sockaddr_hci { 38 + sa_family_t hci_family; 39 + unsigned short hci_dev; 40 + unsigned short hci_channel; 41 + }; 42 + #define HCI_DEV_NONE 0xffff 43 + 44 + #define HCI_CHANNEL_RAW 0 45 + #define HCI_CHANNEL_USER 1 46 + #define HCI_CHANNEL_MONITOR 2 47 + #define HCI_CHANNEL_CONTROL 3 48 + 49 + struct hci_filter { 50 + unsigned long type_mask; 51 + unsigned long event_mask[2]; 52 + __le16 opcode; 53 + }; 54 + 55 + struct hci_ufilter { 56 + __u32 type_mask; 57 + __u32 event_mask[2]; 58 + __le16 opcode; 59 + }; 60 + 61 + #define HCI_FLT_TYPE_BITS 31 62 + #define HCI_FLT_EVENT_BITS 63 63 + #define HCI_FLT_OGF_BITS 63 64 + #define HCI_FLT_OCF_BITS 127 65 + 66 + /* Ioctl defines */ 67 + #define HCIDEVUP _IOW('H', 201, int) 68 + #define HCIDEVDOWN _IOW('H', 202, int) 69 + #define HCIDEVRESET _IOW('H', 203, int) 70 + #define HCIDEVRESTAT _IOW('H', 204, int) 71 + 72 + #define HCIGETDEVLIST _IOR('H', 210, int) 73 + #define HCIGETDEVINFO _IOR('H', 211, int) 74 + #define HCIGETCONNLIST _IOR('H', 212, int) 75 + #define HCIGETCONNINFO _IOR('H', 213, int) 76 + #define HCIGETAUTHINFO _IOR('H', 215, int) 77 + 78 + #define HCISETRAW _IOW('H', 220, int) 79 + #define HCISETSCAN _IOW('H', 221, int) 80 + #define HCISETAUTH _IOW('H', 222, int) 81 + #define HCISETENCRYPT _IOW('H', 223, int) 82 + #define HCISETPTYPE _IOW('H', 224, int) 83 + #define HCISETLINKPOL _IOW('H', 225, int) 84 + #define HCISETLINKMODE _IOW('H', 226, int) 85 + #define HCISETACLMTU _IOW('H', 227, int) 86 + #define HCISETSCOMTU _IOW('H', 228, int) 87 + 88 + #define HCIBLOCKADDR _IOW('H', 230, int) 89 + #define HCIUNBLOCKADDR _IOW('H', 231, int) 90 + 91 + #define HCIINQUIRY _IOR('H', 240, int) 92 + 93 + /* Ioctl requests structures */ 94 + struct hci_dev_stats { 95 + __u32 err_rx; 96 + __u32 err_tx; 97 + __u32 cmd_tx; 98 + __u32 evt_rx; 99 + __u32 acl_tx; 100 + __u32 acl_rx; 101 + __u32 sco_tx; 102 + __u32 sco_rx; 103 + __u32 byte_rx; 104 + __u32 byte_tx; 105 + }; 106 + 107 + struct hci_dev_info { 108 + __u16 dev_id; 109 + char name[8]; 110 + 111 + bdaddr_t bdaddr; 112 + 113 + __u32 flags; 114 + __u8 type; 115 + 116 + __u8 features[8]; 117 + 118 + __u32 pkt_type; 119 + __u32 link_policy; 120 + __u32 link_mode; 121 + 122 + __u16 acl_mtu; 123 + __u16 acl_pkts; 124 + __u16 sco_mtu; 125 + __u16 sco_pkts; 126 + 127 + struct hci_dev_stats stat; 128 + }; 129 + 130 + struct hci_conn_info { 131 + __u16 handle; 132 + bdaddr_t bdaddr; 133 + __u8 type; 134 + __u8 out; 135 + __u16 state; 136 + __u32 link_mode; 137 + }; 138 + 139 + struct hci_dev_req { 140 + __u16 dev_id; 141 + __u32 dev_opt; 142 + }; 143 + 144 + struct hci_dev_list_req { 145 + __u16 dev_num; 146 + struct hci_dev_req dev_req[0]; /* hci_dev_req structures */ 147 + }; 148 + 149 + struct hci_conn_list_req { 150 + __u16 dev_id; 151 + __u16 conn_num; 152 + struct hci_conn_info conn_info[0]; 153 + }; 154 + 155 + struct hci_conn_info_req { 156 + bdaddr_t bdaddr; 157 + __u8 type; 158 + struct hci_conn_info conn_info[0]; 159 + }; 160 + 161 + struct hci_auth_info_req { 162 + bdaddr_t bdaddr; 163 + __u8 type; 164 + }; 165 + 166 + struct hci_inquiry_req { 167 + __u16 dev_id; 168 + __u16 flags; 169 + __u8 lap[3]; 170 + __u8 length; 171 + __u8 num_rsp; 172 + }; 173 + #define IREQ_CACHE_FLUSH 0x0001 174 + 175 + #endif /* __HCI_SOCK_H */