typedef enum {
BT_IO_L2CAP,
- BT_IO_L2ERTM,
BT_IO_RFCOMM,
BT_IO_SCO,
BT_IO_INVALID,
static BtIOType bt_io_get_type(GIOChannel *io, GError **gerr)
{
int sk = g_io_channel_unix_get_fd(io);
- int domain, type, proto, err;
+ int domain, proto, err;
socklen_t len;
domain = 0;
return BT_IO_RFCOMM;
case BTPROTO_SCO:
return BT_IO_SCO;
- }
-
- type = 0;
- len = sizeof(type);
- err = getsockopt(sk, SOL_SOCKET, SO_TYPE, &type, &len);
- if (err < 0) {
- ERROR_FAILED(gerr, "getsockopt(SO_TYPE)", errno);
- return BT_IO_INVALID;
- }
-
- switch (proto) {
case BTPROTO_L2CAP:
- switch (type) {
- case SOCK_SEQPACKET:
- return BT_IO_L2CAP;
- case SOCK_STREAM:
- return BT_IO_L2ERTM;
- }
+ return BT_IO_L2CAP;
+ default:
+ g_set_error(gerr, BT_IO_ERROR, EINVAL,
+ "Unknown BtIO socket type");
+ return BT_IO_INVALID;
}
-
- g_set_error(gerr, BT_IO_ERROR, EINVAL, "Unknown BtIO socket type");
-
- return BT_IO_INVALID;
}
static void server_remove(struct server *server)
switch (type) {
case BT_IO_L2CAP:
- case BT_IO_L2ERTM:
return l2cap_get(sock, err, opt1, args);
case BT_IO_RFCOMM:
return rfcomm_get(sock, err, opt1, args);
switch (type) {
case BT_IO_L2CAP:
- case BT_IO_L2ERTM:
return l2cap_set(sock, opts.sec_level, opts.imtu, opts.omtu,
opts.mode, opts.master, opts.flushable,
opts.priority, err);
opts->priority, err))
goto failed;
break;
- case BT_IO_L2ERTM:
- sock = socket(PF_BLUETOOTH, SOCK_STREAM, BTPROTO_L2CAP);
- if (sock < 0) {
- ERROR_FAILED(err, "socket(STREAM, L2CAP)", errno);
- return NULL;
- }
- if (l2cap_bind(sock, &opts->src, server ? opts->psm : 0,
- opts->cid, err) < 0)
- goto failed;
- if (!l2cap_set(sock, opts->sec_level, opts->imtu, opts->omtu,
- opts->mode, opts->master, opts->flushable,
- opts->priority, err))
- goto failed;
- break;
case BT_IO_RFCOMM:
sock = socket(PF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);
if (sock < 0) {
if (opts->channel)
return BT_IO_RFCOMM;
- if (opts->mode)
- return BT_IO_L2ERTM;
-
if (opts->psm || opts->cid)
return BT_IO_L2CAP;
switch (type) {
case BT_IO_L2CAP:
- case BT_IO_L2ERTM:
err = l2cap_connect(sock, &opts.dst, opts.dst_type,
opts.psm, opts.cid);
break;