Skip to contentSkip to conversation

HCI forwarding

Bluez-devel radeX 2 participants 8 messages Jan 2, 2005 Bluetooth drivers

lore
Share & tools
lore

radeX

author
#0 lore raw

Hi everybody:

I've been months reading the bluez source and learning about the bluetooth specification, plus other documents (the correct coding style, Wireless Technologies Congress 2003 and other documents by Marcel holtmann)

I'm developing an application to connect two Bluetooth-enabled phones via internet using two Bluetooth-enabled PCs both connected to internet. I mean that I can transmit files and play Bluetooth multiplayer games to my friend that is 25 miles away like if it were in my device's Bluetooth radio range. (I know that ping times would be very ugly!).

I use a raw socket as hcidump does, then I send the data trough TCP to the other peer, when received is sent over Bluetooth hoping that the other device receives it, this is more complex than it seems since bluez handles and answers all HCI requests, i.e (when a device performs a SDP request to find a service UUID bluez handles and answers the request) but this is not correct for my application, hci responses and data acks may be received via TCP from the other peer, in other words: no bluez support, only HCI frames sniffing, sending, receiving and transmitting. Now my questions are:

- Can I send HCI frames with a raw socket ?

- How can I tell the bluez stack not to answer HCI requests
(receiving only, leave the sends to me).

- Is there a better way to make this application?

Any help would be greatly appreciated.

Thanks in advance and happy new year.

maintainer
#1 lore raw

Hi,

Quoted 5 lines

I=FFm developing an application to connect two Bluetooth-enabled phones via internet using two Bluetooth-enabled PCs both connected to internet. I mean that I can transmit files and play Bluetooth multiplayer games to my friend that is 25 miles away like if it were in my device=FFs Bluetooth radio range. (I know that ping times would b=

e

Quoted 7 lines

very ugly!).
=20
I use a raw socket as hcidump does, then I send the data trough TCP to the other peer, when received is sent over Bluetooth hoping that the other device receives it, this is more complex than it seems since bluez handles and answers all HCI requests, i.e (when a device performs a SDP request to find a service UUID bluez handles and

Quoted 8 lines

answers the request) but this is not correct for my application, hci responses and data acks may be received via TCP from the other peer, in other words: no bluez support, only HCI frames sniffing, sending, receiving and transmitting. Now my questions are:
=20
=20
=20
- Can I send HCI frames with a raw socket ?

yes, you can.

Quoted 2 lines

- How can I tell the bluez stack not to answer HCI requests
(receiving only, leave the sends to me).

Set the device into raw mode. This should stop any processing.

Quoted 1 line

- Is there a better way to make this application?

Use the hci_vhci driver.

Regards

Marcel

-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

author
#2 lore raw
Quoted 1 line

Set the device into raw mode. This should stop any processing.

Thanks, this really helped, with de hci device in raw mode now bluez does not attend the hci requests, but... how do I transmit hci frames?, simply by using send() function with the raw socket? (I'm doing this. I hope the frames to be sent to all bt devices in range of my usb dongle).

Quoted 1 line

Use the hci_vhci driver.

How would be useful the virtual hci driver for this purpose? Did you mean that I must set a virtual hci device for receiving and transmitting hci traffic?, would it work even if hci_vhci is not attached to a real bt radio?

- Will do all game and application traffic (L2CAP and RFCOMM connections are used only) go trough the hci traffic I'm forwarding? (I've seen that device discovery (COD detection, clock offset....) is not sniffed with the raw socket).

I think that's all.

Regards.

Thank you very much - I'll give you credit in the authors section. ;)

-----Mensaje original-----
De: [email protected] [mailto:[email protected]] En nombre de Marcel Holtmann
Enviado el: domingo, 02 de enero de 2005 12:39
Para: BlueZ Mailing List
Asunto: Re: [Bluez-devel] HCI forwarding

Hi,

Quoted 19 lines

I'm developing an application to connect two Bluetooth-enabled phones via internet using two Bluetooth-enabled PCs both connected to internet. I mean that I can transmit files and play Bluetooth multiplayer games to my friend that is 25 miles away like if it were in my device's Bluetooth radio range. (I know that ping times would be very ugly!).

I use a raw socket as hcidump does, then I send the data trough TCP to the other peer, when received is sent over Bluetooth hoping that the other device receives it, this is more complex than it seems since bluez handles and answers all HCI requests, i.e (when a device performs a SDP request to find a service UUID bluez handles and answers the request) but this is not correct for my application, hci responses and data acks may be received via TCP from the other peer, in other words: no bluez support, only HCI frames sniffing, sending, receiving and transmitting. Now my questions are:

Quoted 1 line

- Can I send HCI frames with a raw socket ?

yes, you can.

Quoted 2 lines

- How can I tell the bluez stack not to answer HCI requests
(receiving only, leave the sends to me).

Set the device into raw mode. This should stop any processing.

Quoted 1 line

- Is there a better way to make this application?

Use the hci_vhci driver.

Regards

Marcel

-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

maintainer
#3 lore raw

Hi,

Quoted 6 lines
Quoted 1 line

Set the device into raw mode. This should stop any processing.

Thanks, this really helped, with de hci device in raw mode now bluez does not attend the hci requests, but... how do I transmit hci frames?, simply by using send() function with the raw socket? (I'm doing this. I hope the frames to be sent to all bt devices in range of my usb dongle).

the HCI is for using the local Bluetooth chip. You can deal with HCI interfaces of remote chips. You write HCI commands and read HCI event on the HCI raw socket.

Quoted 5 lines
Quoted 1 line

Use the hci_vhci driver.

How would be useful the virtual hci driver for this purpose? Did you mean that I must set a virtual hci device for receiving and transmitting hci traffic?, would it work even if hci_vhci is not attached to a real bt radio?

Look at hciemu. It uses hci_vhci to emulate a Bluetooth device.

Quoted 4 lines

- Will do all game and application traffic (L2CAP and RFCOMM connections are used only) go trough the hci traffic I'm forwarding? (I've seen that device discovery (COD detection, clock offset....) is not sniffed with the raw socket).

Parts of this are LMP or lower. You won't get them.

Regards

Marcel

-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

author
#4 lore raw

Understood!
Device detection is not a problem since bluez does it for me (I only have to set the local class of device to the correct value (0x500204) in order to deceiving mobile phones in both sides). I conform with forwarding L2CAP and RFCOMM profile connection data, SDP and the rest of necessary HCI commands and events to make possible a long-distance L2CAP / RFCOMM session.

Is this possible in this way?, In other?, Am I wrong?
(I wrote the app sniffing and forwarding hci frames (it seems that "works") but I had no chance for testing it).

Hciemu reading in progess ;)

Regards.

-----Mensaje original-----
De: [email protected] [mailto:[email protected]] En nombre de Marcel Holtmann
Enviado el: domingo, 02 de enero de 2005 18:32
Para: BlueZ Mailing List
Asunto: RE: [Bluez-devel] HCI forwarding

Hi,

Quoted 4 lines
Quoted 1 line

Set the device into raw mode. This should stop any processing.

Thanks, this really helped, with de hci device in raw mode now bluez does not attend the hci requests, but... how do I transmit hci frames?, simply

by

Quoted 2 lines

using send() function with the raw socket? (I'm doing this. I hope the frames to be sent to all bt devices in range of my usb dongle).

the HCI is for using the local Bluetooth chip. You can deal with HCI interfaces of remote chips. You write HCI commands and read HCI event on the HCI raw socket.

Quoted 5 lines
Quoted 1 line

Use the hci_vhci driver.

How would be useful the virtual hci driver for this purpose? Did you mean that I must set a virtual hci device for receiving and transmitting hci traffic?, would it work even if hci_vhci is not attached to a real bt

radio?

Look at hciemu. It uses hci_vhci to emulate a Bluetooth device.

Quoted 1 line

- Will do all game and application traffic (L2CAP and RFCOMM connections

are

Quoted 1 line

used only) go trough the hci traffic I'm forwarding? (I've seen that

device

Quoted 2 lines

discovery (COD detection, clock offset....) is not sniffed with the raw socket).

Parts of this are LMP or lower. You won't get them.

Regards

Marcel

-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

maintainer
#5 lore raw

Hi,

Quoted 5 lines

Device detection is not a problem since bluez does it for me (I only have to set the local class of device to the correct value (0x500204) in order to deceiving mobile phones in both sides). I conform with forwarding L2CAP and RFCOMM profile connection data, SDP and the rest of necessary HCI commands and events to make possible a long-distance L2CAP / RFCOMM session.

forwarding L2CAP channels or also ACL data packets is very easy. However the ACL MTU should match. The role switches might be a little tricky. Forwarding the HCI commands and events is not that easy. You must keep an eye on the flow control mechanism of HCI, but this is all still doable and there are more ways for doing it.

Quoted 3 lines

Is this possible in this way?, In other?, Am I wrong?
(I wrote the app sniffing and forwarding hci frames (it seems that "works") but I had no chance for testing it).

It is possible and the best way depends on what you wanna do. Basically I used L2CAP and RFCOMM forwarding a lot of this to crack protocol stuff that was going on between some devices. Best example is the Nokia PhoNet protocol.

Regards

Marcel

-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

author
#6 lore raw

Hi again Marcel:

Ok, I'll keep track of the ACL MTU's.

I'm a little lost in other implementation point:
If we have the A peer and B peer connected trough tcp, Imagine that the A phone wants to connect B one, then it inquires and finds the hci device of the A PC and sends the connection requests and all other stuff, these data is sniffed with the A raw socket and forwarded to the B PC by TCP where is sent over B's hci device again, but... hci frames from A phone may be sent to the A PC's hci device's bluetooth address, not to B phone's Bluetooth address, may this be a problem? Would I need to parse the frames to change the destination address or change the A hci device address to B phone's address and B one to A phone address?

Can I change the local chip BT address?

I'll try to get more familiar with this low-level Bluetooth stuff.

Thank you for spending your time helping me.

-----Mensaje original-----
De: [email protected] [mailto:[email protected]] En nombre de Marcel Holtmann
Enviado el: domingo, 02 de enero de 2005 20:21
Para: BlueZ Mailing List
Asunto: RE: [Bluez-devel] HCI forwarding

Hi,

Quoted 1 line

Device detection is not a problem since bluez does it for me (I only have

to

Quoted 2 lines

set the local class of device to the correct value (0x500204) in order to deceiving mobile phones in both sides). I conform with forwarding L2CAP

and

Quoted 2 lines

RFCOMM profile connection data, SDP and the rest of necessary HCI commands and events to make possible a long-distance L2CAP / RFCOMM session.

forwarding L2CAP channels or also ACL data packets is very easy. However the ACL MTU should match. The role switches might be a little tricky. Forwarding the HCI commands and events is not that easy. You must keep an eye on the flow control mechanism of HCI, but this is all still doable and there are more ways for doing it.

Quoted 2 lines

Is this possible in this way?, In other?, Am I wrong? (I wrote the app sniffing and forwarding hci frames (it seems that

"works")

Quoted 1 line

but I had no chance for testing it).

It is possible and the best way depends on what you wanna do. Basically I used L2CAP and RFCOMM forwarding a lot of this to crack protocol stuff that was going on between some devices. Best example is the Nokia PhoNet protocol.

Regards

Marcel

-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

maintainer
#7 lore raw

Hi,

Quoted 10 lines

I'm a little lost in other implementation point:
If we have the A peer and B peer connected trough tcp, Imagine that the A phone wants to connect B one, then it inquires and finds the hci device of the A PC and sends the connection requests and all other stuff, these data is sniffed with the A raw socket and forwarded to the B PC by TCP where is sent over B's hci device again, but... hci frames from A phone may be sent to the A PC's hci device's bluetooth address, not to B phone's Bluetooth address, may this be a problem? Would I need to parse the frames to change the destination address or change the A hci device address to B phone's address and B one to A phone address?

maybe you need to map the ACL connection handle.

Quoted 1 line

Can I change the local chip BT address?

If you now the specific vendor address and if it is not a ROM chip then you can. Ask the manufacturer for details.

Regards

Marcel

-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel