aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorGustavo F. Padovan <padovan@profusion.mobi>2011-02-04 00:02:31 -0500
committerGustavo F. Padovan <padovan@profusion.mobi>2011-02-07 22:43:31 -0500
commit6898325923f9571fbede3372dc490faa43b3258a (patch)
treebdfaadcad5862da390747be596d7a9581c414e94 /net
parent4e34c50bfe5ba87da1622cc7c6ed10712da255ad (diff)
Bluetooth: move l2cap_sock_recvmsg() to l2cap_sock.c
It causes the move of the declaration of 3 functions to l2cap.h: l2cap_get_ident(), l2cap_send_cmd(), l2cap_build_conf_req() Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Diffstat (limited to 'net')
-rw-r--r--net/bluetooth/l2cap_core.c49
-rw-r--r--net/bluetooth/l2cap_sock.c42
2 files changed, 45 insertions, 46 deletions
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 97327457b52d..3a0e42be89ea 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -72,7 +72,6 @@ static void l2cap_busy_work(struct work_struct *work);
72 72
73static void l2cap_sock_close(struct sock *sk); 73static void l2cap_sock_close(struct sock *sk);
74 74
75static int l2cap_build_conf_req(struct sock *sk, void *data);
76static struct sk_buff *l2cap_build_cmd(struct l2cap_conn *conn, 75static struct sk_buff *l2cap_build_cmd(struct l2cap_conn *conn,
77 u8 code, u8 ident, u16 dlen, void *data); 76 u8 code, u8 ident, u16 dlen, void *data);
78 77
@@ -311,7 +310,7 @@ static inline int l2cap_check_security(struct sock *sk)
311 auth_type); 310 auth_type);
312} 311}
313 312
314static inline u8 l2cap_get_ident(struct l2cap_conn *conn) 313u8 l2cap_get_ident(struct l2cap_conn *conn)
315{ 314{
316 u8 id; 315 u8 id;
317 316
@@ -333,7 +332,7 @@ static inline u8 l2cap_get_ident(struct l2cap_conn *conn)
333 return id; 332 return id;
334} 333}
335 334
336static inline void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, void *data) 335void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, void *data)
337{ 336{
338 struct sk_buff *skb = l2cap_build_cmd(conn, code, ident, len, data); 337 struct sk_buff *skb = l2cap_build_cmd(conn, code, ident, len, data);
339 u8 flags; 338 u8 flags;
@@ -1469,48 +1468,6 @@ done:
1469 return err; 1468 return err;
1470} 1469}
1471 1470
1472int l2cap_sock_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len, int flags)
1473{
1474 struct sock *sk = sock->sk;
1475
1476 lock_sock(sk);
1477
1478 if (sk->sk_state == BT_CONNECT2 && bt_sk(sk)->defer_setup) {
1479 struct l2cap_conn_rsp rsp;
1480 struct l2cap_conn *conn = l2cap_pi(sk)->conn;
1481 u8 buf[128];
1482
1483 sk->sk_state = BT_CONFIG;
1484
1485 rsp.scid = cpu_to_le16(l2cap_pi(sk)->dcid);
1486 rsp.dcid = cpu_to_le16(l2cap_pi(sk)->scid);
1487 rsp.result = cpu_to_le16(L2CAP_CR_SUCCESS);
1488 rsp.status = cpu_to_le16(L2CAP_CS_NO_INFO);
1489 l2cap_send_cmd(l2cap_pi(sk)->conn, l2cap_pi(sk)->ident,
1490 L2CAP_CONN_RSP, sizeof(rsp), &rsp);
1491
1492 if (l2cap_pi(sk)->conf_state & L2CAP_CONF_REQ_SENT) {
1493 release_sock(sk);
1494 return 0;
1495 }
1496
1497 l2cap_pi(sk)->conf_state |= L2CAP_CONF_REQ_SENT;
1498 l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ,
1499 l2cap_build_conf_req(sk, buf), buf);
1500 l2cap_pi(sk)->num_conf_req++;
1501
1502 release_sock(sk);
1503 return 0;
1504 }
1505
1506 release_sock(sk);
1507
1508 if (sock->type == SOCK_STREAM)
1509 return bt_sock_stream_recvmsg(iocb, sock, msg, len, flags);
1510
1511 return bt_sock_recvmsg(iocb, sock, msg, len, flags);
1512}
1513
1514int l2cap_sock_shutdown(struct socket *sock, int how) 1471int l2cap_sock_shutdown(struct socket *sock, int how)
1515{ 1472{
1516 struct sock *sk = sock->sk; 1473 struct sock *sk = sock->sk;
@@ -1760,7 +1717,7 @@ static inline __u8 l2cap_select_mode(__u8 mode, __u16 remote_feat_mask)
1760 } 1717 }
1761} 1718}
1762 1719
1763static int l2cap_build_conf_req(struct sock *sk, void *data) 1720int l2cap_build_conf_req(struct sock *sk, void *data)
1764{ 1721{
1765 struct l2cap_pinfo *pi = l2cap_pi(sk); 1722 struct l2cap_pinfo *pi = l2cap_pi(sk);
1766 struct l2cap_conf_req *req = data; 1723 struct l2cap_conf_req *req = data;
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index e2f14f1783f6..fa2bc5d85560 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -681,6 +681,48 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch
681 return err; 681 return err;
682} 682}
683 683
684static int l2cap_sock_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len, int flags)
685{
686 struct sock *sk = sock->sk;
687
688 lock_sock(sk);
689
690 if (sk->sk_state == BT_CONNECT2 && bt_sk(sk)->defer_setup) {
691 struct l2cap_conn_rsp rsp;
692 struct l2cap_conn *conn = l2cap_pi(sk)->conn;
693 u8 buf[128];
694
695 sk->sk_state = BT_CONFIG;
696
697 rsp.scid = cpu_to_le16(l2cap_pi(sk)->dcid);
698 rsp.dcid = cpu_to_le16(l2cap_pi(sk)->scid);
699 rsp.result = cpu_to_le16(L2CAP_CR_SUCCESS);
700 rsp.status = cpu_to_le16(L2CAP_CS_NO_INFO);
701 l2cap_send_cmd(l2cap_pi(sk)->conn, l2cap_pi(sk)->ident,
702 L2CAP_CONN_RSP, sizeof(rsp), &rsp);
703
704 if (l2cap_pi(sk)->conf_state & L2CAP_CONF_REQ_SENT) {
705 release_sock(sk);
706 return 0;
707 }
708
709 l2cap_pi(sk)->conf_state |= L2CAP_CONF_REQ_SENT;
710 l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ,
711 l2cap_build_conf_req(sk, buf), buf);
712 l2cap_pi(sk)->num_conf_req++;
713
714 release_sock(sk);
715 return 0;
716 }
717
718 release_sock(sk);
719
720 if (sock->type == SOCK_STREAM)
721 return bt_sock_stream_recvmsg(iocb, sock, msg, len, flags);
722
723 return bt_sock_recvmsg(iocb, sock, msg, len, flags);
724}
725
684static int l2cap_sock_release(struct socket *sock) 726static int l2cap_sock_release(struct socket *sock)
685{ 727{
686 struct sock *sk = sock->sk; 728 struct sock *sk = sock->sk;