Commit 14b5aa71 authored by Gustavo F. Padovan's avatar Gustavo F. Padovan Committed by Marcel Holtmann

Bluetooth: Add sockopt configuration for txWindow on L2CAP

Now we can set/get Transmission Window size via sockopt.
Signed-off-by: default avatarGustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: default avatarJoão Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent 855666cc
...@@ -56,6 +56,7 @@ struct l2cap_options { ...@@ -56,6 +56,7 @@ struct l2cap_options {
__u16 flush_to; __u16 flush_to;
__u8 mode; __u8 mode;
__u8 fcs; __u8 fcs;
__u16 txwin_size;
}; };
#define L2CAP_CONNINFO 0x02 #define L2CAP_CONNINFO 0x02
...@@ -339,6 +340,7 @@ struct l2cap_pinfo { ...@@ -339,6 +340,7 @@ struct l2cap_pinfo {
__u8 ident; __u8 ident;
__u8 tx_win;
__u8 remote_tx_win; __u8 remote_tx_win;
__u8 remote_max_tx; __u8 remote_max_tx;
__u16 retrans_timeout; __u16 retrans_timeout;
......
...@@ -782,6 +782,7 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent) ...@@ -782,6 +782,7 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent)
pi->omtu = l2cap_pi(parent)->omtu; pi->omtu = l2cap_pi(parent)->omtu;
pi->mode = l2cap_pi(parent)->mode; pi->mode = l2cap_pi(parent)->mode;
pi->fcs = l2cap_pi(parent)->fcs; pi->fcs = l2cap_pi(parent)->fcs;
pi->tx_win = l2cap_pi(parent)->tx_win;
pi->sec_level = l2cap_pi(parent)->sec_level; pi->sec_level = l2cap_pi(parent)->sec_level;
pi->role_switch = l2cap_pi(parent)->role_switch; pi->role_switch = l2cap_pi(parent)->role_switch;
pi->force_reliable = l2cap_pi(parent)->force_reliable; pi->force_reliable = l2cap_pi(parent)->force_reliable;
...@@ -790,6 +791,7 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent) ...@@ -790,6 +791,7 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent)
pi->omtu = 0; pi->omtu = 0;
pi->mode = L2CAP_MODE_BASIC; pi->mode = L2CAP_MODE_BASIC;
pi->fcs = L2CAP_FCS_CRC16; pi->fcs = L2CAP_FCS_CRC16;
pi->tx_win = L2CAP_DEFAULT_TX_WINDOW;
pi->sec_level = BT_SECURITY_LOW; pi->sec_level = BT_SECURITY_LOW;
pi->role_switch = 0; pi->role_switch = 0;
pi->force_reliable = 0; pi->force_reliable = 0;
...@@ -1782,6 +1784,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, char __us ...@@ -1782,6 +1784,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, char __us
opts.flush_to = l2cap_pi(sk)->flush_to; opts.flush_to = l2cap_pi(sk)->flush_to;
opts.mode = l2cap_pi(sk)->mode; opts.mode = l2cap_pi(sk)->mode;
opts.fcs = l2cap_pi(sk)->fcs; opts.fcs = l2cap_pi(sk)->fcs;
opts.txwin_size = (__u16)l2cap_pi(sk)->tx_win;
len = min_t(unsigned int, sizeof(opts), optlen); len = min_t(unsigned int, sizeof(opts), optlen);
if (copy_from_user((char *) &opts, optval, len)) { if (copy_from_user((char *) &opts, optval, len)) {
...@@ -1793,6 +1796,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, char __us ...@@ -1793,6 +1796,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, char __us
l2cap_pi(sk)->omtu = opts.omtu; l2cap_pi(sk)->omtu = opts.omtu;
l2cap_pi(sk)->mode = opts.mode; l2cap_pi(sk)->mode = opts.mode;
l2cap_pi(sk)->fcs = opts.fcs; l2cap_pi(sk)->fcs = opts.fcs;
l2cap_pi(sk)->tx_win = (__u8)opts.txwin_size;
break; break;
case L2CAP_LM: case L2CAP_LM:
...@@ -1907,6 +1911,7 @@ static int l2cap_sock_getsockopt_old(struct socket *sock, int optname, char __us ...@@ -1907,6 +1911,7 @@ static int l2cap_sock_getsockopt_old(struct socket *sock, int optname, char __us
opts.flush_to = l2cap_pi(sk)->flush_to; opts.flush_to = l2cap_pi(sk)->flush_to;
opts.mode = l2cap_pi(sk)->mode; opts.mode = l2cap_pi(sk)->mode;
opts.fcs = l2cap_pi(sk)->fcs; opts.fcs = l2cap_pi(sk)->fcs;
opts.txwin_size = (__u16)l2cap_pi(sk)->tx_win;
len = min_t(unsigned int, len, sizeof(opts)); len = min_t(unsigned int, len, sizeof(opts));
if (copy_to_user(optval, (char *) &opts, len)) if (copy_to_user(optval, (char *) &opts, len))
...@@ -2324,7 +2329,7 @@ static int l2cap_build_conf_req(struct sock *sk, void *data) ...@@ -2324,7 +2329,7 @@ static int l2cap_build_conf_req(struct sock *sk, void *data)
case L2CAP_MODE_ERTM: case L2CAP_MODE_ERTM:
rfc.mode = L2CAP_MODE_ERTM; rfc.mode = L2CAP_MODE_ERTM;
rfc.txwin_size = L2CAP_DEFAULT_TX_WINDOW; rfc.txwin_size = pi->tx_win;
rfc.max_transmit = max_transmit; rfc.max_transmit = max_transmit;
rfc.retrans_timeout = 0; rfc.retrans_timeout = 0;
rfc.monitor_timeout = 0; rfc.monitor_timeout = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment