diff options
author | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-05-02 16:13:55 -0400 |
---|---|---|
committer | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-06-08 15:58:16 -0400 |
commit | 715ec005cd10c5d53109ffe513e4d403644e3e48 (patch) | |
tree | f4a996e3e1efebbe8388ba167cfa258ec0056798 /net/bluetooth/l2cap_sock.c | |
parent | 9a91a04a95d30a18909e2aec9d7b17b4c86088a7 (diff) |
Bluetooth: Add chan->chan_type struct member
chan_type says if our chan is raw(direclty access to HCI),
connection less or connection oriented.
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Diffstat (limited to 'net/bluetooth/l2cap_sock.c')
-rw-r--r-- | net/bluetooth/l2cap_sock.c | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index 0ecf214bd30e..2fcdf5eacb4d 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c | |||
@@ -162,7 +162,7 @@ static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr, int al | |||
162 | 162 | ||
163 | lock_sock(sk); | 163 | lock_sock(sk); |
164 | 164 | ||
165 | if ((sk->sk_type == SOCK_SEQPACKET || sk->sk_type == SOCK_STREAM) | 165 | if (chan->chan_type == L2CAP_CHAN_CONN_ORIENTED |
166 | && !(la.l2_psm || la.l2_cid)) { | 166 | && !(la.l2_psm || la.l2_cid)) { |
167 | err = -EINVAL; | 167 | err = -EINVAL; |
168 | goto done; | 168 | goto done; |
@@ -204,8 +204,8 @@ static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr, int al | |||
204 | } | 204 | } |
205 | 205 | ||
206 | /* PSM must be odd and lsb of upper byte must be 0 */ | 206 | /* PSM must be odd and lsb of upper byte must be 0 */ |
207 | if ((__le16_to_cpu(la.l2_psm) & 0x0101) != 0x0001 && | 207 | if ((__le16_to_cpu(la.l2_psm) & 0x0101) != 0x0001 && !la.l2_cid && |
208 | sk->sk_type != SOCK_RAW && !la.l2_cid) { | 208 | chan->chan_type != L2CAP_CHAN_RAW) { |
209 | err = -EINVAL; | 209 | err = -EINVAL; |
210 | goto done; | 210 | goto done; |
211 | } | 211 | } |
@@ -453,8 +453,8 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, ch | |||
453 | 453 | ||
454 | switch (optname) { | 454 | switch (optname) { |
455 | case BT_SECURITY: | 455 | case BT_SECURITY: |
456 | if (sk->sk_type != SOCK_SEQPACKET && sk->sk_type != SOCK_STREAM | 456 | if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED && |
457 | && sk->sk_type != SOCK_RAW) { | 457 | chan->chan_type != L2CAP_CHAN_RAW) { |
458 | err = -EINVAL; | 458 | err = -EINVAL; |
459 | break; | 459 | break; |
460 | } | 460 | } |
@@ -599,8 +599,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch | |||
599 | 599 | ||
600 | switch (optname) { | 600 | switch (optname) { |
601 | case BT_SECURITY: | 601 | case BT_SECURITY: |
602 | if (sk->sk_type != SOCK_SEQPACKET && sk->sk_type != SOCK_STREAM | 602 | if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED && |
603 | && sk->sk_type != SOCK_RAW) { | 603 | chan->chan_type != L2CAP_CHAN_RAW) { |
604 | err = -EINVAL; | 604 | err = -EINVAL; |
605 | break; | 605 | break; |
606 | } | 606 | } |
@@ -806,6 +806,7 @@ void l2cap_sock_init(struct sock *sk, struct sock *parent) | |||
806 | sk->sk_type = parent->sk_type; | 806 | sk->sk_type = parent->sk_type; |
807 | bt_sk(sk)->defer_setup = bt_sk(parent)->defer_setup; | 807 | bt_sk(sk)->defer_setup = bt_sk(parent)->defer_setup; |
808 | 808 | ||
809 | chan->chan_type = pchan->chan_type; | ||
809 | chan->imtu = pchan->imtu; | 810 | chan->imtu = pchan->imtu; |
810 | chan->omtu = pchan->omtu; | 811 | chan->omtu = pchan->omtu; |
811 | chan->conf_state = pchan->conf_state; | 812 | chan->conf_state = pchan->conf_state; |
@@ -818,6 +819,20 @@ void l2cap_sock_init(struct sock *sk, struct sock *parent) | |||
818 | chan->force_reliable = pchan->force_reliable; | 819 | chan->force_reliable = pchan->force_reliable; |
819 | chan->flushable = pchan->flushable; | 820 | chan->flushable = pchan->flushable; |
820 | } else { | 821 | } else { |
822 | |||
823 | switch (sk->sk_type) { | ||
824 | case SOCK_RAW: | ||
825 | chan->chan_type = L2CAP_CHAN_RAW; | ||
826 | break; | ||
827 | case SOCK_DGRAM: | ||
828 | chan->chan_type = L2CAP_CHAN_CONN_LESS; | ||
829 | break; | ||
830 | case SOCK_SEQPACKET: | ||
831 | case SOCK_STREAM: | ||
832 | chan->chan_type = L2CAP_CHAN_CONN_ORIENTED; | ||
833 | break; | ||
834 | } | ||
835 | |||
821 | chan->imtu = L2CAP_DEFAULT_MTU; | 836 | chan->imtu = L2CAP_DEFAULT_MTU; |
822 | chan->omtu = 0; | 837 | chan->omtu = 0; |
823 | if (!disable_ertm && sk->sk_type == SOCK_STREAM) { | 838 | if (!disable_ertm && sk->sk_type == SOCK_STREAM) { |