Bluetooth: Better integrate NuttX Bluetooth IOCTL commands and NetBSD IOCTL commands. Stanardize naming.
This commit is contained in:
parent
39e393fa5f
commit
cab7ba8b8f
@ -64,6 +64,8 @@
|
|||||||
|
|
||||||
/* NetBSD IOCTL commands ****************************************************/
|
/* NetBSD IOCTL commands ****************************************************/
|
||||||
/* All of the following use an argument of type struct btreg_s:
|
/* All of the following use an argument of type struct btreg_s:
|
||||||
|
*
|
||||||
|
* Bluetooth Information Queries
|
||||||
*
|
*
|
||||||
* SIOCGBTINFO
|
* SIOCGBTINFO
|
||||||
* Get Bluetooth device Info. Given the device name, fill in the btreq_s
|
* Get Bluetooth device Info. Given the device name, fill in the btreq_s
|
||||||
@ -77,92 +79,96 @@
|
|||||||
* will be returned. Otherwise, the next device will be returned until
|
* will be returned. Otherwise, the next device will be returned until
|
||||||
* no more devices are found when the call will fail, with error ENXIO.
|
* no more devices are found when the call will fail, with error ENXIO.
|
||||||
* Thus, you can cycle through all devices in the system.
|
* Thus, you can cycle through all devices in the system.
|
||||||
* SIOCSBTFLAGS
|
|
||||||
* Set Bluetooth device Flags. Not all flags are settable.
|
|
||||||
* SIOCGBTFEAT
|
* SIOCGBTFEAT
|
||||||
* Get Bluetooth device Features. This returns the cached basic (page 0)
|
* Get Bluetooth device Features. This returns the cached basic (page 0)
|
||||||
* and extended (page 1 & 2) features.
|
* and extended (page 1 & 2) features.
|
||||||
* SIOCSBTPOLICY
|
|
||||||
* Set Bluetooth device Link Policy bits.
|
|
||||||
* SIOCSBTPTYPE
|
|
||||||
* Set Bluetooth device Packet Types. You can only set packet types that
|
|
||||||
* the device supports.
|
|
||||||
* SIOCGBTSTATS
|
|
||||||
* Read device statistics.
|
|
||||||
* SIOCZBTSTATS
|
|
||||||
* Read device statistics, and zero them.
|
|
||||||
*
|
|
||||||
* NOTE: These are here for reference. None of the NetBSD IOCTL commands
|
|
||||||
* have been implemented in NuttX.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define SIOCGBTINFO _WLIOC(WL_BLUETOOTHFIRST + 0)
|
#define SIOCGBTINFO _WLIOC(WL_BLUETOOTHFIRST + 0)
|
||||||
#define SIOCGBTINFOA _WLIOC(WL_BLUETOOTHFIRST + 1)
|
#define SIOCGBTINFOA _WLIOC(WL_BLUETOOTHFIRST + 1)
|
||||||
#define SIOCNBTINFO _WLIOC(WL_BLUETOOTHFIRST + 2)
|
#define SIOCNBTINFO _WLIOC(WL_BLUETOOTHFIRST + 2)
|
||||||
#define SIOCSBTFLAGS _WLIOC(WL_BLUETOOTHFIRST + 3)
|
#define SIOCGBTFEAT _WLIOC(WL_BLUETOOTHFIRST + 3)
|
||||||
#define SIOCGBTFEAT _WLIOC(WL_BLUETOOTHFIRST + 4)
|
|
||||||
|
/* Set Flags, Link Policy, and Packet Types
|
||||||
|
*
|
||||||
|
* SIOCSBTFLAGS
|
||||||
|
* Set Bluetooth device Flags. Not all flags are settable.
|
||||||
|
* SIOCSBTPOLICY
|
||||||
|
* Set Bluetooth device Link Policy bits.
|
||||||
|
* SIOCSBTPTYPE
|
||||||
|
* Set Bluetooth device Packet Types. You can only set packet types that
|
||||||
|
* the device supports.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define SIOCSBTFLAGS _WLIOC(WL_BLUETOOTHFIRST + 4)
|
||||||
#define SIOCSBTPOLICY _WLIOC(WL_BLUETOOTHFIRST + 5)
|
#define SIOCSBTPOLICY _WLIOC(WL_BLUETOOTHFIRST + 5)
|
||||||
#define SIOCSBTPTYPE _WLIOC(WL_BLUETOOTHFIRST + 6)
|
#define SIOCSBTPTYPE _WLIOC(WL_BLUETOOTHFIRST + 6)
|
||||||
|
|
||||||
|
/* Get Statistics:
|
||||||
|
*
|
||||||
|
* SIOCGBTSTATS
|
||||||
|
* Read device statistics.
|
||||||
|
* SIOCZBTSTATS
|
||||||
|
* Read device statistics, and zero them.
|
||||||
|
*/
|
||||||
|
|
||||||
#define SIOCGBTSTATS _WLIOC(WL_BLUETOOTHFIRST + 7)
|
#define SIOCGBTSTATS _WLIOC(WL_BLUETOOTHFIRST + 7)
|
||||||
#define SIOCZBTSTATS _WLIOC(WL_BLUETOOTHFIRST + 8)
|
#define SIOCZBTSTATS _WLIOC(WL_BLUETOOTHFIRST + 8)
|
||||||
|
|
||||||
/* NuttX-specific IOCTL commands. *******************************************/
|
/* NuttX-specific IOCTL commands. *******************************************/
|
||||||
/* SIOCBT_ADVERTISESTART
|
/* All of the following use an argument of type struct btreg_s: */
|
||||||
|
|
||||||
|
/* SIOCBTADVSTART
|
||||||
* Description: Set advertisement data, scan response data,
|
* Description: Set advertisement data, scan response data,
|
||||||
* advertisement parameters and start advertising.
|
* advertisement parameters and start advertising.
|
||||||
* Input: Pointer to read-write instance of struct
|
* Input: Pointer to read-btreq_s instance of struct btreq_s.
|
||||||
* bt_advertisestart_s.
|
|
||||||
* Output: None
|
* Output: None
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define SIOCBT_ADVERTISESTART _WLIOC(WL_BLUETOOTHFIRST + 9)
|
#define SIOCBTADVSTART _WLIOC(WL_BLUETOOTHFIRST + 9)
|
||||||
|
|
||||||
/* SIOCBT_ADVERTISESTOP
|
/* SIOCBTADVSTOP
|
||||||
* Description: Stop advertising.
|
* Description: Stop advertising.
|
||||||
* Input: A reference to a write-able instance of struct
|
* Input: A reference to a write-able instance of struct btreq_s.
|
||||||
* bt_scanstop_s.
|
|
||||||
* Output: None
|
* Output: None
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define SIOCBT_ADVERTISESTOP _WLIOC(WL_BLUETOOTHFIRST + 10)
|
#define SIOCBTADVSTOP _WLIOC(WL_BLUETOOTHFIRST + 10)
|
||||||
|
|
||||||
/* SIOCBT_SCANSTART
|
/* SIOCBTSCANSTART
|
||||||
* Description: Start LE scanning. Buffered scan results may be
|
* Description: Start LE scanning. Buffered scan results may be
|
||||||
* obtained via SIOCBT_SCANGET
|
* obtained via SIOCBTSCANGET
|
||||||
* Input: A read-only referent to struct bt_scanstart_s.
|
* Input: A read-only referent to struct btreq_s.
|
||||||
* Output: None
|
* Output: None
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define SIOCBT_SCANSTART _WLIOC(WL_BLUETOOTHFIRST + 11)
|
#define SIOCBTSCANSTART _WLIOC(WL_BLUETOOTHFIRST + 11)
|
||||||
|
|
||||||
/* SIOCBT_SCANGET
|
/* SIOCBTSCANGET
|
||||||
* Description: Return scan results buffered since the call time that
|
* Description: Return scan results buffered since the call time that
|
||||||
* the SIOCBT_SCANGET command was invoked.
|
* the SIOCBTSCANGET command was invoked.
|
||||||
* Input: A reference to a write-able instance of struct
|
* Input: A reference to a write-able instance of struct btreq_s.
|
||||||
* bt_scanresult_s.
|
|
||||||
* Output: Buffered scan result results are returned in the user-
|
* Output: Buffered scan result results are returned in the user-
|
||||||
* provided buffer space.
|
* provided buffer space.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define SIOCBT_SCANGET _WLIOC(WL_BLUETOOTHFIRST + 12)
|
#define SIOCBTSCANGET _WLIOC(WL_BLUETOOTHFIRST + 12)
|
||||||
|
|
||||||
/* SIOCBT_SCANSTOP
|
/* SIOCBTSCANSTOP
|
||||||
* Description: Stop LE scanning and discard any buffered results.
|
* Description: Stop LE scanning and discard any buffered results.
|
||||||
* Input: A reference to a write-able instance of struct
|
* Input: A reference to a read-only instance of struct btreq_s.
|
||||||
* bt_scanstop_s.
|
|
||||||
* Output: None
|
* Output: None
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define SIOCBT_SCANSTOP _WLIOC(WL_BLUETOOTHFIRST + 13)
|
#define SIOCBTSCANSTOP _WLIOC(WL_BLUETOOTHFIRST + 13)
|
||||||
|
|
||||||
/* SIOCBT_SECURITY
|
/* SIOCBTSECURITY
|
||||||
* Description: Enable security for a connection.
|
* Description: Enable security for a connection.
|
||||||
* Input: A reference to a write-able instance of struct
|
* Input: A reference to a write-able instance of struct btreq_s.
|
||||||
* bt_security_s.
|
|
||||||
* Output: None
|
* Output: None
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define SIOCBT_SECURITY _WLIOC(WL_BLUETOOTHFIRST + 14)
|
#define SIOCBTSECURITY _WLIOC(WL_BLUETOOTHFIRST + 14)
|
||||||
|
|
||||||
/* Definitions associated with struct btreg_s *******************************/
|
/* Definitions associated with struct btreg_s *******************************/
|
||||||
/* struct btreq_s union field accessors */
|
/* struct btreq_s union field accessors */
|
||||||
@ -178,9 +184,23 @@
|
|||||||
#define btr_packet_type btru.btri.btri_packet_type
|
#define btr_packet_type btru.btri.btri_packet_type
|
||||||
#define btr_max_acl btru.btri.btri_max_acl
|
#define btr_max_acl btru.btri.btri_max_acl
|
||||||
#define btr_max_sco btru.btri.btri_max_sco
|
#define btr_max_sco btru.btri.btri_max_sco
|
||||||
|
|
||||||
#define btr_features0 btru.btrf.btrf_page0
|
#define btr_features0 btru.btrf.btrf_page0
|
||||||
#define btr_features1 btru.btrf.btrf_page1
|
#define btr_features1 btru.btrf.btrf_page1
|
||||||
#define btr_features2 btru.btrf.btrf_page2
|
#define btr_features2 btru.btrf.btrf_page2
|
||||||
|
|
||||||
|
#define btr_advtype btru.btras.btras_advtype
|
||||||
|
#define btr_advad btru.btras.btras_advad
|
||||||
|
#define btr_advas btru.btras.btras_advsd
|
||||||
|
|
||||||
|
#define btr_dupenable btru.btrss.btrss_dupenable
|
||||||
|
|
||||||
|
#define btr_nrsp btru.btrsr.brtsr_nrsp
|
||||||
|
#define btr_rsp btru.btrsr.btrsr_rsp
|
||||||
|
|
||||||
|
#define btr_secaddr btru.btrse.btrse_secaddr
|
||||||
|
#define btr_seclevel btru.btrse.btrse_seclevel
|
||||||
|
|
||||||
#define btr_stats btru.btrs
|
#define btr_stats btru.btrs
|
||||||
|
|
||||||
/* btr_flags */
|
/* btr_flags */
|
||||||
@ -201,9 +221,21 @@
|
|||||||
* Public Types
|
* Public Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/* Common structure for Bluetooth IOCTL commands */
|
/* Write-able data that accompanies the SIOCBTSCANGET IOCTL command */
|
||||||
|
|
||||||
struct bt_stats
|
struct bt_scanresponse_s
|
||||||
|
{
|
||||||
|
char sr_name[HCI_DEVNAME_SIZE]; /* Device name */
|
||||||
|
bt_addr_le_t sr_addr; /* Advertiser LE address and type */
|
||||||
|
int8_t sr_rssi; /* Strength of advertiser signal */
|
||||||
|
uint8_t sr_type; /* Type of advertising response */
|
||||||
|
uint8_t sr_len; /* Length of advertiser data */
|
||||||
|
uint8_t sr_data[CONFIG_BLUETOOTH_MAXSCANDATA];
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Bluetooth statistics */
|
||||||
|
|
||||||
|
struct bt_stats_s
|
||||||
{
|
{
|
||||||
uint32_t err_tx;
|
uint32_t err_tx;
|
||||||
uint32_t err_rx;
|
uint32_t err_rx;
|
||||||
@ -217,11 +249,15 @@ struct bt_stats
|
|||||||
uint32_t byte_rx;
|
uint32_t byte_rx;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Common structure for Bluetooth IOCTL commands */
|
||||||
|
|
||||||
struct btreq_s
|
struct btreq_s
|
||||||
{
|
{
|
||||||
char btr_name[HCI_DEVNAME_SIZE]; /* Device name */
|
char btr_name[HCI_DEVNAME_SIZE]; /* Device name */
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
|
/* Bluetooth information used by most NetBSD IOCTL commands */
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
bt_addr_t btri_bdaddr; /* Device bdaddr */
|
bt_addr_t btri_bdaddr; /* Device bdaddr */
|
||||||
@ -236,83 +272,70 @@ struct btreq_s
|
|||||||
uint16_t btri_max_acl; /* max ACL buffers */
|
uint16_t btri_max_acl; /* max ACL buffers */
|
||||||
uint16_t btri_max_sco; /* max SCO buffers */
|
uint16_t btri_max_sco; /* max SCO buffers */
|
||||||
} btri;
|
} btri;
|
||||||
|
|
||||||
|
/* Bluetooth Features */
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
uint8_t btrf_page0[HCI_FEATURES_SIZE]; /* basic */
|
uint8_t btrf_page0[HCI_FEATURES_SIZE]; /* basic */
|
||||||
uint8_t btrf_page1[HCI_FEATURES_SIZE]; /* extended page 1 */
|
uint8_t btrf_page1[HCI_FEATURES_SIZE]; /* extended page 1 */
|
||||||
uint8_t btrf_page2[HCI_FEATURES_SIZE]; /* extended page 2 */
|
uint8_t btrf_page2[HCI_FEATURES_SIZE]; /* extended page 2 */
|
||||||
} btrf;
|
} btrf;
|
||||||
struct bt_stats btrs; /* unit stats */
|
|
||||||
|
/* Read-only data that accompanies the SIOCBTADVSTART IOCTL command.
|
||||||
|
* Advertising types are defined in bt_hci.h. NOTE that btras_ad and
|
||||||
|
* btras_sd pointers to the beginning of a list of "Extended Inquire
|
||||||
|
* Responses". Each list is terminated with a dummy, NULL entry
|
||||||
|
* identified with a length of zero.
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint8_t btras_advtype; /* Advertising type */
|
||||||
|
FAR struct bt_eir_s *btras_advad; /* Data for advertisement packets */
|
||||||
|
FAR struct bt_eir_s *btras_advsd; /* Data for scan response packets */
|
||||||
|
} btras;
|
||||||
|
|
||||||
|
/* NOTE: No additional data accompanies the SIOCBTADVSTOP */
|
||||||
|
|
||||||
|
/* The read-only data that accompanies the SIOCBTSCANSTART IOCTL
|
||||||
|
* command.
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
bool btrss_dupenable; /* True: enable duplicate filtering */
|
||||||
|
} btrss;
|
||||||
|
|
||||||
|
/* Write-able data that accompanies the SIOCBTSCANGET IOCTL command */
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint8_t brtsr_nrsp; /* Input: Max number of responses
|
||||||
|
* Return: Actual number of responses */
|
||||||
|
|
||||||
|
/* Reference to a beginning of an array in user memory in which to
|
||||||
|
* return the scan response data. The size of the array is
|
||||||
|
* btrsr_nrsp.
|
||||||
|
*/
|
||||||
|
|
||||||
|
FAR struct bt_scanresponse_s *btrsr_rsp;
|
||||||
|
} btrsr;
|
||||||
|
|
||||||
|
/* NOTE: No additional data accompanies the SIOCBTSCANSTOP */
|
||||||
|
|
||||||
|
/* Read-only data that accompanies the SIOCBTSECURITY IOCTL command */
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
bt_addr_le_t btrse_secaddr; /* BLE address */
|
||||||
|
enum bt_security_e btrse_seclevel; /* Security level */
|
||||||
|
} btrse;
|
||||||
|
|
||||||
|
struct bt_stats_s btrs; /* Unit statistics */
|
||||||
} btru;
|
} btru;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Read-only data that accompanies the SIOCBT_ADVERTISESTART IOCTL command.
|
|
||||||
* Advertising types are defined in bt_hci.h.
|
|
||||||
*/
|
|
||||||
|
|
||||||
struct bt_advertisestart_s
|
|
||||||
{
|
|
||||||
char as_name[HCI_DEVNAME_SIZE]; /* Device name */
|
|
||||||
uint8_t as_type; /* Advertising type */
|
|
||||||
FAR struct bt_eir_s as_ad; /* Data for advertisement packets */
|
|
||||||
FAR struct bt_eir_s as_sd; /* Data for scan response packets */
|
|
||||||
};
|
|
||||||
|
|
||||||
/* The read-only data that accompanies the SIOCBT_SCANSTOP IOCTL command */
|
|
||||||
|
|
||||||
struct bt_advertisestop_s
|
|
||||||
{
|
|
||||||
char at_name[HCI_DEVNAME_SIZE]; /* Device name */
|
|
||||||
};
|
|
||||||
|
|
||||||
/* The read-only data that accompanies the SIOCBT_SCANSTART IOCTL command */
|
|
||||||
|
|
||||||
struct bt_scanstart_s
|
|
||||||
{
|
|
||||||
char ss_name[HCI_DEVNAME_SIZE]; /* Device name */
|
|
||||||
bool ss_dupenable; /* True: enable duplicate filtering */
|
|
||||||
};
|
|
||||||
|
|
||||||
/* The read-only data that accompanies the SIOCBT_SCANSTOP IOCTL command */
|
|
||||||
|
|
||||||
struct bt_scanstop_s
|
|
||||||
{
|
|
||||||
char st_name[HCI_DEVNAME_SIZE]; /* Device name */
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Write-able data that accompanies the SIOCBT_SCANGET IOCTL command */
|
|
||||||
|
|
||||||
struct bt_scanresponse_s
|
|
||||||
{
|
|
||||||
char sr_name[HCI_DEVNAME_SIZE]; /* Device name */
|
|
||||||
bt_addr_le_t sr_addr; /* Advertiser LE address and type */
|
|
||||||
int8_t sr_rssi; /* Strength of advertiser signal */
|
|
||||||
uint8_t sr_type; /* Type of advertising response */
|
|
||||||
uint8_t sr_len; /* Length of advertiser data */
|
|
||||||
uint8_t sr_data[CONFIG_BLUETOOTH_MAXSCANDATA];
|
|
||||||
};
|
|
||||||
|
|
||||||
struct bt_scanresult_s
|
|
||||||
{
|
|
||||||
char sr_name[HCI_DEVNAME_SIZE]; /* Device name */
|
|
||||||
uint8_t sr_nrsp; /* Input: Max number of responses
|
|
||||||
* Return: Actual number of responses */
|
|
||||||
struct bt_scanresponse_s sr_rsp[1];
|
|
||||||
};
|
|
||||||
|
|
||||||
#define SIZEOF_BT_SCANRESULT_S(n) \
|
|
||||||
(sizeof(struct bt_scanresult_s) + \
|
|
||||||
((n) - 1) * sizeof(struct bt_scanresponse_s))
|
|
||||||
|
|
||||||
/* Read-only data that accompanies the SIOCBT_SECURITY IOCTL command */
|
|
||||||
|
|
||||||
struct bt_security_s
|
|
||||||
{
|
|
||||||
char se_name[HCI_DEVNAME_SIZE]; /* Device name */
|
|
||||||
bt_addr_le_t se_addr; /* BLE address */
|
|
||||||
enum bt_security_e se_level; /* Security level */
|
|
||||||
};
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Function Prototypes
|
* Public Function Prototypes
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
@ -72,18 +72,16 @@
|
|||||||
# include <nuttx/wireless/wireless.h>
|
# include <nuttx/wireless/wireless.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_NETDEV_IOCTL) && defined(CONFIG_NET_6LOWPAN)
|
#ifdef CONFIG_WIRELESS_BLUETOOTH
|
||||||
# ifdef CONFIG_WIRELESS_BLUETOOTH
|
# include <nuttx/wireless/bt_ioctl.h>
|
||||||
# include <nuttx/wireless/bt_ioctl.h>
|
#endif
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifdef CONFIG_WIRELESS_IEEE802154
|
#ifdef CONFIG_WIRELESS_IEEE802154
|
||||||
# include <nuttx/wireless/ieee802154/ieee802154_mac.h>
|
# include <nuttx/wireless/ieee802154/ieee802154_mac.h>
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
# ifdef CONFIG_WIRELESS_PKTRADIO
|
#ifdef CONFIG_WIRELESS_PKTRADIO
|
||||||
# include <nuttx/wireless/pktradio.h>
|
# include <nuttx/wireless/pktradio.h>
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "arp/arp.h"
|
#include "arp/arp.h"
|
||||||
@ -114,6 +112,31 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#undef HAVE_IEEE802154_IOCTL
|
||||||
|
#undef HAVE_PKTRADIO_IOCTL
|
||||||
|
#undef HAVE_BLUETOOTH_IOCTL
|
||||||
|
|
||||||
|
#ifdef CONFIG_NETDEV_IOCTL
|
||||||
|
/* IEEE 802.15.4 6LoWPAN or raw packet support */
|
||||||
|
|
||||||
|
#if defined(CONFIG_NET_IEEE802154) || (defined(CONFIG_NET_6LOWPAN) && \
|
||||||
|
defined(CONFIG_WIRELESS_IEEE802154))
|
||||||
|
# define HAVE_IEEE802154_IOCTL 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* pktradio raw packet support not implemented */
|
||||||
|
|
||||||
|
#if defined(CONFIG_NET_6LOWPAN) && defined(CONFIG_WIRELESS_PKTRADIO)
|
||||||
|
# define HAVE_PKTRADIO_IOCTL 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Bluetooth 6LoWPAN support not implemented */
|
||||||
|
|
||||||
|
#if defined(CONFIG_NET_BLUETOOTH)
|
||||||
|
# define HAVE_BLUETOOTH_IOCTL 1
|
||||||
|
#endif
|
||||||
|
#endif /* CONFIG_NETDEV_IOCTL */
|
||||||
|
|
||||||
/* This is really kind of bogus.. When asked for an IP address, this is
|
/* This is really kind of bogus.. When asked for an IP address, this is
|
||||||
* family that is returned in the ifr structure. Probably could just skip
|
* family that is returned in the ifr structure. Probably could just skip
|
||||||
* this since the address family has nothing to do with the Ethernet address.
|
* this since the address family has nothing to do with the Ethernet address.
|
||||||
@ -375,7 +398,7 @@ static void ioctl_set_ipv6addr(FAR net_ipv6addr_t outaddr,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: netdev_iee802154_ioctl
|
* Name: netdev_bluetooth_ioctl
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Perform Bluetooth network device specific operations.
|
* Perform Bluetooth network device specific operations.
|
||||||
@ -392,14 +415,13 @@ static void ioctl_set_ipv6addr(FAR net_ipv6addr_t outaddr,
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#if defined(CONFIG_NETDEV_IOCTL) && defined(CONFIG_NET_6LOWPAN) && \
|
#ifdef HAVE_BLUETOOTH_IOCTL
|
||||||
defined(CONFIG_WIRELESS_BLUETOOTH)
|
static int netdev_bluetooth_ioctl(FAR struct socket *psock, int cmd,
|
||||||
static int netdev_iee802154_ioctl(FAR struct socket *psock, int cmd,
|
|
||||||
unsigned long arg)
|
unsigned long arg)
|
||||||
{
|
{
|
||||||
FAR struct net_driver_s *dev;
|
FAR struct net_driver_s *dev;
|
||||||
FAR char *ifname;
|
FAR char *ifname;
|
||||||
int ret = -ENOTTY;
|
int ret = -EINVAL;
|
||||||
|
|
||||||
if (arg != 0ul)
|
if (arg != 0ul)
|
||||||
{
|
{
|
||||||
@ -409,10 +431,10 @@ static int netdev_iee802154_ioctl(FAR struct socket *psock, int cmd,
|
|||||||
* command
|
* command
|
||||||
*/
|
*/
|
||||||
|
|
||||||
FAR struct bluetooth_ifreq_s *cmddata =
|
FAR struct btreq_s *btreq =
|
||||||
(FAR struct bluetooth_ifreq_s *)((uintptr_t)arg);
|
(FAR struct btreq_s *)((uintptr_t)arg);
|
||||||
|
|
||||||
ifname = cmddata->ifr_name;
|
ifname = btreq->btr_name;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -424,6 +446,8 @@ static int netdev_iee802154_ioctl(FAR struct socket *psock, int cmd,
|
|||||||
/* Find the device with this name */
|
/* Find the device with this name */
|
||||||
|
|
||||||
dev = netdev_findbyname(ifname);
|
dev = netdev_findbyname(ifname);
|
||||||
|
ret = -ENODEV;
|
||||||
|
|
||||||
if (dev != NULL && dev->d_lltype == NET_LL_BLUETOOTH)
|
if (dev != NULL && dev->d_lltype == NET_LL_BLUETOOTH)
|
||||||
{
|
{
|
||||||
/* Perform the device IOCTL */
|
/* Perform the device IOCTL */
|
||||||
@ -454,8 +478,7 @@ static int netdev_iee802154_ioctl(FAR struct socket *psock, int cmd,
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#if defined(CONFIG_NETDEV_IOCTL) && defined(CONFIG_NET_6LOWPAN) && \
|
#ifdef HAVE_IEEE802154_IOCTL
|
||||||
defined(CONFIG_WIRELESS_IEEE802154)
|
|
||||||
static int netdev_iee802154_ioctl(FAR struct socket *psock, int cmd,
|
static int netdev_iee802154_ioctl(FAR struct socket *psock, int cmd,
|
||||||
unsigned long arg)
|
unsigned long arg)
|
||||||
{
|
{
|
||||||
@ -496,7 +519,7 @@ static int netdev_iee802154_ioctl(FAR struct socket *psock, int cmd,
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* HAVE_IEEE802154_IOCTL */
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: netdev_pktradio_ioctl
|
* Name: netdev_pktradio_ioctl
|
||||||
@ -516,8 +539,7 @@ static int netdev_iee802154_ioctl(FAR struct socket *psock, int cmd,
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#if defined(CONFIG_NETDEV_IOCTL) && defined(CONFIG_NET_6LOWPAN) && \
|
#ifdef HAVE_PKTRADIO_IOCTL
|
||||||
defined(CONFIG_WIRELESS_PKTRADIO)
|
|
||||||
static int netdev_pktradio_ioctl(FAR struct socket *psock, int cmd,
|
static int netdev_pktradio_ioctl(FAR struct socket *psock, int cmd,
|
||||||
unsigned long arg)
|
unsigned long arg)
|
||||||
{
|
{
|
||||||
@ -559,7 +581,7 @@ static int netdev_pktradio_ioctl(FAR struct socket *psock, int cmd,
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* HAVE_PKTRADIO_IOCTL */
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: netdev_wifr_ioctl
|
* Name: netdev_wifr_ioctl
|
||||||
@ -1472,23 +1494,31 @@ int psock_ioctl(FAR struct socket *psock, int cmd, unsigned long arg)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_NETDEV_IOCTL) && defined(CONFIG_NET_6LOWPAN)
|
#ifdef HAVE_IEEE802154_IOCTL
|
||||||
#ifdef CONFIG_WIRELESS_IEEE802154
|
/* Check for a IEEE802.15.4 network device IOCTL command */
|
||||||
/* Check for a IEEE802.15.4 network device command */
|
|
||||||
|
|
||||||
if (ret == -ENOTTY)
|
if (ret == -ENOTTY)
|
||||||
{
|
{
|
||||||
ret = netdev_iee802154_ioctl(psock, cmd, arg);
|
ret = netdev_iee802154_ioctl(psock, cmd, arg);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_WIRELESS_PKTRADIO
|
|
||||||
/* Check for a non-IEEE802.15.4 packet radio network device command */
|
#ifdef HAVE_PKTRADIO_IOCTL
|
||||||
|
/* Check for a non-IEEE802.15.4 packet radio network device IOCTL command */
|
||||||
|
|
||||||
if (ret == -ENOTTY)
|
if (ret == -ENOTTY)
|
||||||
{
|
{
|
||||||
ret = netdev_pktradio_ioctl(psock, cmd, arg);
|
ret = netdev_pktradio_ioctl(psock, cmd, arg);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_BLUETOOTH_IOCTL
|
||||||
|
/* Check for Bluetooth network device IOCTL command */
|
||||||
|
|
||||||
|
if (ret == -ENOTTY)
|
||||||
|
{
|
||||||
|
ret = netdev_bluetooth_ioctl(psock, cmd, arg);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_NET_IGMP
|
#ifdef CONFIG_NET_IGMP
|
||||||
|
@ -1536,7 +1536,7 @@ int bt_start_advertising(uint8_t type, FAR const struct bt_eir_s *ad,
|
|||||||
FAR struct bt_hci_cp_le_set_adv_parameters_s *set_param;
|
FAR struct bt_hci_cp_le_set_adv_parameters_s *set_param;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!ad)
|
if (ad == NULL)
|
||||||
{
|
{
|
||||||
goto send_scan_rsp;
|
goto send_scan_rsp;
|
||||||
}
|
}
|
||||||
@ -1551,7 +1551,7 @@ int bt_start_advertising(uint8_t type, FAR const struct bt_eir_s *ad,
|
|||||||
|
|
||||||
memset(set_data, 0, sizeof(*set_data));
|
memset(set_data, 0, sizeof(*set_data));
|
||||||
|
|
||||||
for (i = 0; ad[i].len; i++)
|
for (i = 0; ad[i].len > 0; i++)
|
||||||
{
|
{
|
||||||
/* Check if ad fit in the remaining buffer */
|
/* Check if ad fit in the remaining buffer */
|
||||||
|
|
||||||
@ -1567,7 +1567,7 @@ int bt_start_advertising(uint8_t type, FAR const struct bt_eir_s *ad,
|
|||||||
bt_hci_cmd_send(BT_HCI_OP_LE_SET_ADV_DATA, buf);
|
bt_hci_cmd_send(BT_HCI_OP_LE_SET_ADV_DATA, buf);
|
||||||
|
|
||||||
send_scan_rsp:
|
send_scan_rsp:
|
||||||
if (!sd)
|
if (sd == NULL)
|
||||||
{
|
{
|
||||||
goto send_set_param;
|
goto send_set_param;
|
||||||
}
|
}
|
||||||
@ -1583,7 +1583,7 @@ send_scan_rsp:
|
|||||||
|
|
||||||
memset(scan_rsp, 0, sizeof(*scan_rsp));
|
memset(scan_rsp, 0, sizeof(*scan_rsp));
|
||||||
|
|
||||||
for (i = 0; sd[i].len; i++)
|
for (i = 0; sd[i].len > 0; i++)
|
||||||
{
|
{
|
||||||
/* Check if ad fit in the remaining buffer */
|
/* Check if ad fit in the remaining buffer */
|
||||||
|
|
||||||
|
@ -183,18 +183,20 @@ static void btnet_scan_callback(FAR const bt_addr_le_t *addr, int8_t rssi,
|
|||||||
* cached scan results.
|
* cached scan results.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* Scan result data
|
* result - Location to return the scan result data
|
||||||
|
* maxrsp - The maximum number of responses that can be returned.
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* None
|
* On success, the actual number of scan results obtain is returned. A
|
||||||
|
* negated errno value is returned on any failure.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int btnet_scan_result(FAR struct bt_scanresult_s *result)
|
static int btnet_scan_result(FAR struct bt_scanresponse_s *result,
|
||||||
|
uint8_t maxrsp)
|
||||||
{
|
{
|
||||||
uint8_t head;
|
uint8_t head;
|
||||||
uint8_t tail;
|
uint8_t tail;
|
||||||
uint8_t maxrsp;
|
|
||||||
uint8_t nrsp;
|
uint8_t nrsp;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -217,7 +219,6 @@ static int btnet_scan_result(FAR struct bt_scanresult_s *result)
|
|||||||
|
|
||||||
head = g_scanstate.bs_head;
|
head = g_scanstate.bs_head;
|
||||||
tail = g_scanstate.bs_tail;
|
tail = g_scanstate.bs_tail;
|
||||||
maxrsp = result->sr_nrsp;
|
|
||||||
|
|
||||||
for (nrsp = 0; nrsp < maxrsp && head != tail; nrsp++)
|
for (nrsp = 0; nrsp < maxrsp && head != tail; nrsp++)
|
||||||
{
|
{
|
||||||
@ -227,7 +228,7 @@ static int btnet_scan_result(FAR struct bt_scanresult_s *result)
|
|||||||
/* Copy data from the head index into the user buffer */
|
/* Copy data from the head index into the user buffer */
|
||||||
|
|
||||||
src = (FAR const uint8_t *)&g_scanstate.bs_rsp[head];
|
src = (FAR const uint8_t *)&g_scanstate.bs_rsp[head];
|
||||||
dest = (FAR uint8_t *)&result->sr_rsp[nrsp];
|
dest = (FAR uint8_t *)&result[nrsp];
|
||||||
memcpy(dest, src, sizeof(struct bt_scanresponse_s));
|
memcpy(dest, src, sizeof(struct bt_scanresponse_s));
|
||||||
|
|
||||||
/* Increment the head index */
|
/* Increment the head index */
|
||||||
@ -239,9 +240,8 @@ static int btnet_scan_result(FAR struct bt_scanresult_s *result)
|
|||||||
}
|
}
|
||||||
|
|
||||||
g_scanstate.bs_head = head;
|
g_scanstate.bs_head = head;
|
||||||
result->sr_nrsp = nrsp;
|
|
||||||
nxsem_post(&g_scanstate.bs_exclsem);
|
nxsem_post(&g_scanstate.bs_exclsem);
|
||||||
return OK;
|
return nrsp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -273,40 +273,40 @@ int btnet_ioctl(FAR struct net_driver_s *dev, int cmd, unsigned long arg)
|
|||||||
|
|
||||||
switch (cmd)
|
switch (cmd)
|
||||||
{
|
{
|
||||||
/* SIOCBT_ADVERTISESTART
|
/* SIOCBTADVSTART
|
||||||
* Description: Set advertisement data, scan response data,
|
* Description: Set advertisement data, scan response data,
|
||||||
* advertisement parameters and start advertising.
|
* advertisement parameters and start advertising.
|
||||||
* Input: Pointer to read-write instance of struct
|
* Input: Pointer to read-only instance of struct btreq_s.
|
||||||
* bt_advertisestart_s.
|
|
||||||
* Output: None
|
* Output: None
|
||||||
*/
|
*/
|
||||||
|
|
||||||
case SIOCBT_ADVERTISESTART:
|
case SIOCBTADVSTART:
|
||||||
{
|
{
|
||||||
FAR struct bt_advertisestart_s *adv =
|
FAR struct btreq_s *btreq =
|
||||||
(FAR struct bt_advertisestart_s *)((uintptr_t)arg);
|
(FAR struct btreq_s *)((uintptr_t)arg);
|
||||||
|
|
||||||
if (adv == NULL)
|
if (btreq == NULL)
|
||||||
{
|
{
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ret = bt_start_advertising(adv->as_type, &adv->as_ad,
|
ret = bt_start_advertising(btreq->btr_advtype,
|
||||||
&adv->as_sd);
|
btreq->btr_advad,
|
||||||
|
btreq->btr_advad);
|
||||||
wlinfo("Start advertising: %d\n", ret);
|
wlinfo("Start advertising: %d\n", ret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* SIOCBT_ADVERTISESTOP
|
/* SIOCBTADVSTOP
|
||||||
* Description: Stop advertising.
|
* Description: Stop advertising.
|
||||||
* Input: A reference to a write-able instance of struct
|
* Input: A reference to a write-able instance of struct
|
||||||
* bt_scanstop_s.
|
* btreq_s.
|
||||||
* Output: None
|
* Output: None
|
||||||
*/
|
*/
|
||||||
|
|
||||||
case SIOCBT_ADVERTISESTOP:
|
case SIOCBTADVSTOP:
|
||||||
{
|
{
|
||||||
wlinfo("Stop advertising\n");
|
wlinfo("Stop advertising\n");
|
||||||
bt_stop_advertising();
|
bt_stop_advertising();
|
||||||
@ -314,19 +314,19 @@ int btnet_ioctl(FAR struct net_driver_s *dev, int cmd, unsigned long arg)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* SIOCBT_SCANSTART
|
/* SIOCBTSCANSTART
|
||||||
* Description: Start LE scanning. Buffered scan results may be
|
* Description: Start LE scanning. Buffered scan results may be
|
||||||
* obtained via SIOCBT_SCANGET
|
* obtained via SIOCBTSCANGET
|
||||||
* Input: A read-only referent to struct bt_scanstart_s.
|
* Input: A read-only referent to struct btreq_s.
|
||||||
* Output: None
|
* Output: None
|
||||||
*/
|
*/
|
||||||
|
|
||||||
case SIOCBT_SCANSTART:
|
case SIOCBTSCANSTART:
|
||||||
{
|
{
|
||||||
FAR struct bt_scanstart_s *start =
|
FAR struct btreq_s *btreq =
|
||||||
(FAR struct bt_scanstart_s *)((uintptr_t)arg);
|
(FAR struct btreq_s *)((uintptr_t)arg);
|
||||||
|
|
||||||
if (start == NULL)
|
if (btreq == NULL)
|
||||||
{
|
{
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
}
|
}
|
||||||
@ -346,7 +346,7 @@ int btnet_ioctl(FAR struct net_driver_s *dev, int cmd, unsigned long arg)
|
|||||||
g_scanstate.bs_head = 0;
|
g_scanstate.bs_head = 0;
|
||||||
g_scanstate.bs_tail = 0;
|
g_scanstate.bs_tail = 0;
|
||||||
|
|
||||||
ret = bt_start_scanning(start->ss_dupenable,
|
ret = bt_start_scanning(btreq->btr_dupenable,
|
||||||
btnet_scan_callback);
|
btnet_scan_callback);
|
||||||
wlinfo("Start scan: %d\n", ret);
|
wlinfo("Start scan: %d\n", ret);
|
||||||
|
|
||||||
@ -359,40 +359,46 @@ int btnet_ioctl(FAR struct net_driver_s *dev, int cmd, unsigned long arg)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* SIOCBT_SCANGET
|
/* SIOCBTSCANGET
|
||||||
* Description: Return scan results buffered since the call time
|
* Description: Return scan results buffered since the call time
|
||||||
* that the SIOCBT_SCANGET command was invoked.
|
* that the SIOCBTSCANGET command was invoked.
|
||||||
* Input: A reference to a write-able instance of struct
|
* Input: A reference to a write-able instance of struct
|
||||||
* bt_scanresult_s.
|
* btreq_s.
|
||||||
* Output: Buffered scan result results are returned in the
|
* Output: Buffered scan result results are returned in the
|
||||||
* user-provided buffer space.
|
* user-provided buffer space.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
case SIOCBT_SCANGET:
|
case SIOCBTSCANGET:
|
||||||
{
|
{
|
||||||
FAR struct bt_scanresult_s *result =
|
FAR struct btreq_s *btreq =
|
||||||
(FAR struct bt_scanresult_s *)((uintptr_t)arg);
|
(FAR struct btreq_s *)((uintptr_t)arg);
|
||||||
|
|
||||||
if (result == NULL)
|
if (btreq == NULL)
|
||||||
{
|
{
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ret = btnet_scan_result(result);
|
ret = btnet_scan_result(btreq->btr_rsp, btreq->btr_nrsp);
|
||||||
wlinfo("Get scan results: %d\n", ret);
|
wlinfo("Get scan results: %d\n", ret);
|
||||||
|
|
||||||
|
if (ret >= 0)
|
||||||
|
{
|
||||||
|
btreq->btr_nrsp = ret;
|
||||||
|
ret = OK;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* SIOCBT_SCANSTOP
|
/* SIOCBTSCANSTOP
|
||||||
* Description: Stop LE scanning and discard any buffered results.
|
* Description: Stop LE scanning and discard any buffered results.
|
||||||
* Input: A reference to a write-able instance of struct
|
* Input: A reference to a read-only instance of struct
|
||||||
* bt_scanstop_s.
|
* btreq_s.
|
||||||
* Output: None
|
* Output: None
|
||||||
*/
|
*/
|
||||||
|
|
||||||
case SIOCBT_SCANSTOP:
|
case SIOCBTSCANSTOP:
|
||||||
{
|
{
|
||||||
/* Stop scanning */
|
/* Stop scanning */
|
||||||
|
|
||||||
@ -404,19 +410,19 @@ int btnet_ioctl(FAR struct net_driver_s *dev, int cmd, unsigned long arg)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* SIOCBT_SECURITY
|
/* SIOCBTSECURITY
|
||||||
* Description: Enable security for a connection.
|
* Description: Enable security for a connection.
|
||||||
* Input: A reference to a write-able instance of struct
|
* Input: A reference to a write-able instance of struct
|
||||||
* bt_security_s.
|
* btreq_s.
|
||||||
* Output: None
|
* Output: None
|
||||||
*/
|
*/
|
||||||
|
|
||||||
case SIOCBT_SECURITY:
|
case SIOCBTSECURITY:
|
||||||
{
|
{
|
||||||
FAR struct bt_security_s *sec =
|
FAR struct btreq_s *btreq =
|
||||||
(FAR struct bt_security_s *)((uintptr_t)arg);
|
(FAR struct btreq_s *)((uintptr_t)arg);
|
||||||
|
|
||||||
if (sec == NULL)
|
if (btreq == NULL)
|
||||||
{
|
{
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
}
|
}
|
||||||
@ -426,7 +432,7 @@ int btnet_ioctl(FAR struct net_driver_s *dev, int cmd, unsigned long arg)
|
|||||||
|
|
||||||
/* Get the connection associated with the provided LE address */
|
/* Get the connection associated with the provided LE address */
|
||||||
|
|
||||||
conn = bt_conn_lookup_addr_le(&sec->se_addr);
|
conn = bt_conn_lookup_addr_le(&btreq->btr_secaddr);
|
||||||
if (conn == NULL)
|
if (conn == NULL)
|
||||||
{
|
{
|
||||||
wlwarn("WARNING: Peer not connected\n");
|
wlwarn("WARNING: Peer not connected\n");
|
||||||
@ -434,7 +440,7 @@ int btnet_ioctl(FAR struct net_driver_s *dev, int cmd, unsigned long arg)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ret = bt_conn_security(conn, sec->se_level);
|
ret = bt_conn_security(conn, btreq->btr_seclevel);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
wlerr("ERROR: Security setting failed: %d\n", ret);
|
wlerr("ERROR: Security setting failed: %d\n", ret);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user