2014-03-28 10:44:50

by Michal Labedzki

[permalink] [raw]
Subject: Missing Linux Bluetooth Headers

Hello,

Could you explain why Linux kernel do not provide any header files for
its sockets?

For example: "socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI)"
I do not need a userspace (BlueZ [and do not want it]) to communicate
with kernel, but no Linux headers is a problem. Add dependency to
BlueZ is ugly, because I do not depend on BlueZ, but Linux kernel.
Also BlueZ is not used in project like "libpcap".

I see that BlueZ have those headers in "lib" directory (sources).
Linux have them in "include/net/bluetooth" but they are not installed
(by "make headers_install").

I think Linux should provide Bluetooth headers files. I see that CAN
(#include <linux/can.h>) do that.

I see that you also try to synchronize with kernel side... (why you do
not use it?)

commit d22d083d6dd681f8d25eb806d4ec91853475ee06
Author: Gustavo Padovan <[email protected]>
AuthorDate: Thu Apr 5 16:22:55 2012 -0300
Commit: Johan Hedberg <[email protected]>
CommitDate: Thu Apr 5 22:30:31 2012 +0300

mgmt: update mgmt control channel id

kernel side has updated its control channel id from 1 to 3.
---
lib/hci.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/hci.h b/lib/hci.h
index 887a860..f7be92d 100644
--- a/lib/hci.h
+++ b/lib/hci.h
@@ -2288,8 +2288,8 @@ struct sockaddr_hci {
#define HCI_DEV_NONE 0xffff

#define HCI_CHANNEL_RAW 0
-#define HCI_CHANNEL_CONTROL 1
#define HCI_CHANNEL_MONITOR 2
+#define HCI_CHANNEL_CONTROL 3

struct hci_filter {
uint32_t type_mask;


--

Pozdrawiam / Best regards
-------------------------------------------------------------------------------------------------------------
Michał Łabędzki, Software Engineer
Tieto Corporation

Product Development Services

http://www.tieto.com / http://www.tieto.pl
---
ASCII: Michal Labedzki
location: Swobodna 1 Street, 50-088 Wrocław, Poland
room: 5.01 (desk next to 5.08)
---
Please note: The information contained in this message may be legally
privileged and confidential and protected from disclosure. If the
reader of this message is not the intended recipient, you are hereby
notified that any unauthorised use, distribution or copying of this
communication is strictly prohibited. If you have received this
communication in error, please notify us immediately by replying to
the message and deleting it from your computer. Thank You.
---
Please consider the environment before printing this e-mail.
---
Tieto Poland spółka z ograniczoną odpowiedzialnością z siedzibą w
Szczecinie, ul. Malczewskiego 26. Zarejestrowana w Sądzie Rejonowym
Szczecin-Centrum w Szczecinie, XIII Wydział Gospodarczy Krajowego
Rejestru Sądowego pod numerem 0000124858. NIP: 8542085557. REGON:
812023656. Kapitał zakładowy: 4 271500 PLN


2014-03-31 16:10:48

by Marcel Holtmann

[permalink] [raw]
Subject: Re: Missing Linux Bluetooth Headers

Hi Michal,

> So what external application should do? Add own copy of headers to
> sources or try use BlueZ copy of headers. I think that first option is
> better, because build dependency with BlueZ does not make
> implementation kernel-safe. I think about user try to use one version
> of libpcap and try to change kernel to older (there can be old kernel
> API).

for libpcap and sockaddr_hci and the HCI_CHANNEL_MONITOR, you should just add your own copy of these structs and defines. Do not even bother copying BlueZ headers. Just create the structs and defines by yourself and use them. We have done this internally inside BlueZ as well a few times.

A build or runtime dependency on libbluetooth is a bad idea. You can install libbluetooth if you build BlueZ with ?enable-library, but that library will be deprecated at some point. So might well just prepare yourself for it.

Regards

Marcel


2014-03-31 10:38:32

by Michal Labedzki

[permalink] [raw]
Subject: Re: Missing Linux Bluetooth Headers

So what external application should do? Add own copy of headers to
sources or try use BlueZ copy of headers. I think that first option is
better, because build dependency with BlueZ does not make
implementation kernel-safe. I think about user try to use one version
of libpcap and try to change kernel to older (there can be old kernel
API).

2014-03-28 17:08:35

by Marcel Holtmann

[permalink] [raw]
Subject: Re: Missing Linux Bluetooth Headers

Hi Michal,

> Could you explain why Linux kernel do not provide any header files for
> its sockets?

because we have Bluetooth support since 2.4.6 kernel and that is over 10 years old. Back in the days the kernel headers were done differently and including kernel headers was not as clean as it is today.

> For example: "socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI)"
> I do not need a userspace (BlueZ [and do not want it]) to communicate
> with kernel, but no Linux headers is a problem. Add dependency to
> BlueZ is ugly, because I do not depend on BlueZ, but Linux kernel.
> Also BlueZ is not used in project like "libpcap".
>
> I see that BlueZ have those headers in "lib" directory (sources).
> Linux have them in "include/net/bluetooth" but they are not installed
> (by "make headers_install").
>
> I think Linux should provide Bluetooth headers files. I see that CAN
> (#include <linux/can.h>) do that.

In the long term we should provide uapi header for Bluetooth. We just have not gotten there yet. Some of the current kernel headers are not clean. They can not be easily exported.

Regards

Marcel