diff --git a/btio/btio.c b/btio/btio.c
index af2276d..db37b99 100644
--- a/btio/btio.c
+++ b/btio/btio.c
case BT_IO_OPT_DEST_CHANNEL:
case BT_IO_OPT_HANDLE:
case BT_IO_OPT_CLASS:
+ case BT_IO_OPT_PHY:
default:
g_set_error(err, BT_IO_ERROR, EINVAL,
"Unknown option %d", opt);
return 0;
}
+static int get_phy(int sock, uint32_t *phy)
+{
+ socklen_t len;
+
+ len = sizeof(*phy);
+ if (getsockopt(sock, SOL_BLUETOOTH, BT_PHY, phy, &len) < 0)
+ return -errno;
+
+ return 0;
+}
+
static gboolean l2cap_get(int sock, GError **err, BtIOOption opt1,
va_list args)
{
uint16_t handle = 0;
socklen_t len;
gboolean flushable = FALSE, have_dst = FALSE;
- uint32_t priority;
+ uint32_t priority, phy;
if (!get_src(sock, &src, sizeof(src), err))
return FALSE;
}
*(va_arg(args, uint32_t *)) = priority;
break;
+ case BT_IO_OPT_PHY:
+ if (get_phy(sock, &phy) < 0) {
+ ERROR_FAILED(err, "get_phy", errno);
+ return FALSE;
+ }
+ *(va_arg(args, uint32_t *)) = phy;
+ break;
case BT_IO_OPT_INVALID:
case BT_IO_OPT_SOURCE_TYPE:
case BT_IO_OPT_CHANNEL:
socklen_t len;
uint8_t dev_class[3];
uint16_t handle = 0;
+ uint32_t phy;
if (!get_src(sock, &src, sizeof(src), err))
return FALSE;
}
memcpy(va_arg(args, uint8_t *), dev_class, 3);
break;
+ case BT_IO_OPT_PHY:
+ if (get_phy(sock, &phy) < 0) {
+ ERROR_FAILED(err, "get_phy", errno);
+ return FALSE;
+ }
+ *(va_arg(args, uint32_t *)) = phy;
+ break;
case BT_IO_OPT_SOURCE_TYPE:
case BT_IO_OPT_DEST_TYPE:
case BT_IO_OPT_KEY_SIZE:
socklen_t len;
uint8_t dev_class[3];
uint16_t handle = 0;
+ uint32_t phy;
len = sizeof(sco_opt);
memset(&sco_opt, 0, len);
}
memcpy(va_arg(args, uint8_t *), dev_class, 3);
break;
+ case BT_IO_OPT_PHY:
+ if (get_phy(sock, &phy) < 0) {
+ ERROR_FAILED(err, "get_phy", errno);
+ return FALSE;
+ }
+ *(va_arg(args, uint32_t *)) = phy;
+ break;
case BT_IO_OPT_SOURCE_TYPE:
case BT_IO_OPT_DEST_TYPE:
case BT_IO_OPT_DEFER_TIMEOUT:
diff --git a/btio/btio.h b/btio/btio.h
index 2dce9f0..41a017a 100644
--- a/btio/btio.h
+++ b/btio/btio.h
BT_IO_OPT_FLUSHABLE,
BT_IO_OPT_PRIORITY,
BT_IO_OPT_VOICE,
+ BT_IO_OPT_PHY,
} BtIOOption;
typedef enum {