I fully agree with this.  AF_BLUETOOTH is already in place, but it
only implements "BTPROTO_L2CAP" all of the GATT and
advertising/scanning related functionality is implemented over
"BTPROTO_HCI"

   #define BTPROTO_L2CAP
   <https://elixir.bootlin.com/linux/latest/C/ident/BTPROTO_L2CAP> 0
   #define BTPROTO_HCI
   <https://elixir.bootlin.com/linux/latest/C/ident/BTPROTO_HCI> 1
   #define BTPROTO_SCO
   <https://elixir.bootlin.com/linux/latest/C/ident/BTPROTO_SCO> 2
   #define BTPROTO_RFCOMM
   <https://elixir.bootlin.com/linux/latest/C/ident/BTPROTO_RFCOMM> 3
   #define BTPROTO_BNEP
   <https://elixir.bootlin.com/linux/latest/C/ident/BTPROTO_BNEP> 4
   #define BTPROTO_CMTP
   <https://elixir.bootlin.com/linux/latest/C/ident/BTPROTO_CMTP> 5
   #define BTPROTO_HIDP
   <https://elixir.bootlin.com/linux/latest/C/ident/BTPROTO_HIDP> 6
   #define BTPROTO_AVDTP
   <https://elixir.bootlin.com/linux/latest/C/ident/BTPROTO_AVDTP> 7

I have been thinking about how the socket interface would be implemented.  I believe that is one area were I could make a good contribution to this effort.

Currently, there is very little use of the socket protocol under net/. The only use of the protocol argument now is to verify that it has a valid value.

'struct socket' remembers the protocol family (PF_BLUTOOTH), and the socket type (SOCK_RAW), but not the protocol. So, the protocol field is essentially forgotten after the socket is instantiated.   In the proposed Bluetooth usage, we would have to extend the usage of the protocol in some fashion to accomplish what you suggest.

Two possibilities come to mind:

 * Separate network drivers for each protocol. The supported
   protocol(s?) would be passed to netdev_register() and would be used
   to match a socket interface with a network device. In this case, the
   BTPROTO_L2CAP and the BTPROTO_HCI support would be provided in
   separately registered drivers (which might be two registrations of
   the same driver exposing the two different "personalities" and two
   different netdriver_s structures).
 * A common network device for all protocols. This would require some
   mechanism for passing the protocol on a packet-by-packet basis, this
   would probably be a new field in both struct socket and struct
   netdriver_s. The protocol would probably need to be written into the
   netdriver_s structure instance along all other packet information. 
   That might be awkward under certain conditions.






Reply via email to