btashton commented on issue #1639:
URL:
https://github.com/apache/incubator-nuttx/issues/1639#issuecomment-682155770
What If we don't change `sock_intf_s` would you be open to having multiple
versions for the different socket protocols. The reason being that the HCI
socket is very different than L2CAP. For example it does not support
connections. The code is going to get really ugly handling both of these in
the same place. This is further complicated because with the bind there are
then multiple "channels" defined inside the address which changes how the
writes and reads are handled.
If we store the protocol inside the socket struct it is fairly easy to
handle the ioctl and socket option calls without changing sock_intf_s.
```
FAR const struct sock_intf_s *
net_sockif(sa_family_t family, int type, int protocol)
{
FAR const struct sock_intf_s *sockif = NULL;
switch (family)
{
#ifdef CONFIG_NET_BLUETOOTH
case PF_BLUETOOTH:
switch (protocol)
{
case BTPROTO_HCI:
sockif = &g_bluetooth_hcisockif;
break
case BTPROTO_L2CAP:
default:
sockif = &g_bluetooth_sockif;
break
}
break;
#endif
default:
nerr("ERROR: Address family unsupported: %d\n", family);
}
return sockif;
}
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]