diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-20 20:43:29 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-20 20:43:29 -0400 |
commit | db6d8c7a4027b48d797b369a53f8470aaeed7063 (patch) | |
tree | e140c104a89abc2154e1f41a7db8ebecbb6fa0b4 /net/bluetooth/rfcomm | |
parent | 3a533374283aea50eab3976d8a6d30532175f009 (diff) | |
parent | fb65a7c091529bfffb1262515252c0d0f6241c5c (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6: (1232 commits)
iucv: Fix bad merging.
net_sched: Add size table for qdiscs
net_sched: Add accessor function for packet length for qdiscs
net_sched: Add qdisc_enqueue wrapper
highmem: Export totalhigh_pages.
ipv6 mcast: Omit redundant address family checks in ip6_mc_source().
net: Use standard structures for generic socket address structures.
ipv6 netns: Make several "global" sysctl variables namespace aware.
netns: Use net_eq() to compare net-namespaces for optimization.
ipv6: remove unused macros from net/ipv6.h
ipv6: remove unused parameter from ip6_ra_control
tcp: fix kernel panic with listening_get_next
tcp: Remove redundant checks when setting eff_sacks
tcp: options clean up
tcp: Fix MD5 signatures for non-linear skbs
sctp: Update sctp global memory limit allocations.
sctp: remove unnecessary byteshifting, calculate directly in big-endian
sctp: Allow only 1 listening socket with SO_REUSEADDR
sctp: Do not leak memory on multiple listen() calls
sctp: Support ipv6only AF_INET6 sockets.
...
Diffstat (limited to 'net/bluetooth/rfcomm')
-rw-r--r-- | net/bluetooth/rfcomm/core.c | 94 | ||||
-rw-r--r-- | net/bluetooth/rfcomm/sock.c | 25 | ||||
-rw-r--r-- | net/bluetooth/rfcomm/tty.c | 61 |
3 files changed, 134 insertions, 46 deletions
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c index 0c2c93735e93..6cfc7ba611b3 100644 --- a/net/bluetooth/rfcomm/core.c +++ b/net/bluetooth/rfcomm/core.c | |||
@@ -23,8 +23,6 @@ | |||
23 | 23 | ||
24 | /* | 24 | /* |
25 | * Bluetooth RFCOMM core. | 25 | * Bluetooth RFCOMM core. |
26 | * | ||
27 | * $Id: core.c,v 1.42 2002/10/01 23:26:25 maxk Exp $ | ||
28 | */ | 26 | */ |
29 | 27 | ||
30 | #include <linux/module.h> | 28 | #include <linux/module.h> |
@@ -53,7 +51,7 @@ | |||
53 | #define BT_DBG(D...) | 51 | #define BT_DBG(D...) |
54 | #endif | 52 | #endif |
55 | 53 | ||
56 | #define VERSION "1.8" | 54 | #define VERSION "1.10" |
57 | 55 | ||
58 | static int disable_cfc = 0; | 56 | static int disable_cfc = 0; |
59 | static int channel_mtu = -1; | 57 | static int channel_mtu = -1; |
@@ -230,6 +228,21 @@ static int rfcomm_l2sock_create(struct socket **sock) | |||
230 | return err; | 228 | return err; |
231 | } | 229 | } |
232 | 230 | ||
231 | static inline int rfcomm_check_link_mode(struct rfcomm_dlc *d) | ||
232 | { | ||
233 | struct sock *sk = d->session->sock->sk; | ||
234 | |||
235 | if (d->link_mode & (RFCOMM_LM_ENCRYPT | RFCOMM_LM_SECURE)) { | ||
236 | if (!hci_conn_encrypt(l2cap_pi(sk)->conn->hcon)) | ||
237 | return 1; | ||
238 | } else if (d->link_mode & RFCOMM_LM_AUTH) { | ||
239 | if (!hci_conn_auth(l2cap_pi(sk)->conn->hcon)) | ||
240 | return 1; | ||
241 | } | ||
242 | |||
243 | return 0; | ||
244 | } | ||
245 | |||
233 | /* ---- RFCOMM DLCs ---- */ | 246 | /* ---- RFCOMM DLCs ---- */ |
234 | static void rfcomm_dlc_timeout(unsigned long arg) | 247 | static void rfcomm_dlc_timeout(unsigned long arg) |
235 | { | 248 | { |
@@ -371,15 +384,23 @@ static int __rfcomm_dlc_open(struct rfcomm_dlc *d, bdaddr_t *src, bdaddr_t *dst, | |||
371 | d->addr = __addr(s->initiator, dlci); | 384 | d->addr = __addr(s->initiator, dlci); |
372 | d->priority = 7; | 385 | d->priority = 7; |
373 | 386 | ||
374 | d->state = BT_CONFIG; | 387 | d->state = BT_CONFIG; |
375 | rfcomm_dlc_link(s, d); | 388 | rfcomm_dlc_link(s, d); |
376 | 389 | ||
390 | d->out = 1; | ||
391 | |||
377 | d->mtu = s->mtu; | 392 | d->mtu = s->mtu; |
378 | d->cfc = (s->cfc == RFCOMM_CFC_UNKNOWN) ? 0 : s->cfc; | 393 | d->cfc = (s->cfc == RFCOMM_CFC_UNKNOWN) ? 0 : s->cfc; |
379 | 394 | ||
380 | if (s->state == BT_CONNECTED) | 395 | if (s->state == BT_CONNECTED) { |
381 | rfcomm_send_pn(s, 1, d); | 396 | if (rfcomm_check_link_mode(d)) |
397 | set_bit(RFCOMM_AUTH_PENDING, &d->flags); | ||
398 | else | ||
399 | rfcomm_send_pn(s, 1, d); | ||
400 | } | ||
401 | |||
382 | rfcomm_dlc_set_timer(d, RFCOMM_CONN_TIMEOUT); | 402 | rfcomm_dlc_set_timer(d, RFCOMM_CONN_TIMEOUT); |
403 | |||
383 | return 0; | 404 | return 0; |
384 | } | 405 | } |
385 | 406 | ||
@@ -1146,21 +1167,6 @@ static int rfcomm_recv_disc(struct rfcomm_session *s, u8 dlci) | |||
1146 | return 0; | 1167 | return 0; |
1147 | } | 1168 | } |
1148 | 1169 | ||
1149 | static inline int rfcomm_check_link_mode(struct rfcomm_dlc *d) | ||
1150 | { | ||
1151 | struct sock *sk = d->session->sock->sk; | ||
1152 | |||
1153 | if (d->link_mode & (RFCOMM_LM_ENCRYPT | RFCOMM_LM_SECURE)) { | ||
1154 | if (!hci_conn_encrypt(l2cap_pi(sk)->conn->hcon)) | ||
1155 | return 1; | ||
1156 | } else if (d->link_mode & RFCOMM_LM_AUTH) { | ||
1157 | if (!hci_conn_auth(l2cap_pi(sk)->conn->hcon)) | ||
1158 | return 1; | ||
1159 | } | ||
1160 | |||
1161 | return 0; | ||
1162 | } | ||
1163 | |||
1164 | static void rfcomm_dlc_accept(struct rfcomm_dlc *d) | 1170 | static void rfcomm_dlc_accept(struct rfcomm_dlc *d) |
1165 | { | 1171 | { |
1166 | struct sock *sk = d->session->sock->sk; | 1172 | struct sock *sk = d->session->sock->sk; |
@@ -1205,10 +1211,8 @@ static int rfcomm_recv_sabm(struct rfcomm_session *s, u8 dlci) | |||
1205 | if (rfcomm_check_link_mode(d)) { | 1211 | if (rfcomm_check_link_mode(d)) { |
1206 | set_bit(RFCOMM_AUTH_PENDING, &d->flags); | 1212 | set_bit(RFCOMM_AUTH_PENDING, &d->flags); |
1207 | rfcomm_dlc_set_timer(d, RFCOMM_AUTH_TIMEOUT); | 1213 | rfcomm_dlc_set_timer(d, RFCOMM_AUTH_TIMEOUT); |
1208 | return 0; | 1214 | } else |
1209 | } | 1215 | rfcomm_dlc_accept(d); |
1210 | |||
1211 | rfcomm_dlc_accept(d); | ||
1212 | } | 1216 | } |
1213 | return 0; | 1217 | return 0; |
1214 | } | 1218 | } |
@@ -1223,10 +1227,8 @@ static int rfcomm_recv_sabm(struct rfcomm_session *s, u8 dlci) | |||
1223 | if (rfcomm_check_link_mode(d)) { | 1227 | if (rfcomm_check_link_mode(d)) { |
1224 | set_bit(RFCOMM_AUTH_PENDING, &d->flags); | 1228 | set_bit(RFCOMM_AUTH_PENDING, &d->flags); |
1225 | rfcomm_dlc_set_timer(d, RFCOMM_AUTH_TIMEOUT); | 1229 | rfcomm_dlc_set_timer(d, RFCOMM_AUTH_TIMEOUT); |
1226 | return 0; | 1230 | } else |
1227 | } | 1231 | rfcomm_dlc_accept(d); |
1228 | |||
1229 | rfcomm_dlc_accept(d); | ||
1230 | } else { | 1232 | } else { |
1231 | rfcomm_send_dm(s, dlci); | 1233 | rfcomm_send_dm(s, dlci); |
1232 | } | 1234 | } |
@@ -1459,8 +1461,12 @@ static int rfcomm_recv_msc(struct rfcomm_session *s, int cr, struct sk_buff *skb | |||
1459 | clear_bit(RFCOMM_TX_THROTTLED, &d->flags); | 1461 | clear_bit(RFCOMM_TX_THROTTLED, &d->flags); |
1460 | 1462 | ||
1461 | rfcomm_dlc_lock(d); | 1463 | rfcomm_dlc_lock(d); |
1464 | |||
1465 | d->remote_v24_sig = msc->v24_sig; | ||
1466 | |||
1462 | if (d->modem_status) | 1467 | if (d->modem_status) |
1463 | d->modem_status(d, msc->v24_sig); | 1468 | d->modem_status(d, msc->v24_sig); |
1469 | |||
1464 | rfcomm_dlc_unlock(d); | 1470 | rfcomm_dlc_unlock(d); |
1465 | 1471 | ||
1466 | rfcomm_send_msc(s, 0, dlci, msc->v24_sig); | 1472 | rfcomm_send_msc(s, 0, dlci, msc->v24_sig); |
@@ -1636,7 +1642,11 @@ static void rfcomm_process_connect(struct rfcomm_session *s) | |||
1636 | d = list_entry(p, struct rfcomm_dlc, list); | 1642 | d = list_entry(p, struct rfcomm_dlc, list); |
1637 | if (d->state == BT_CONFIG) { | 1643 | if (d->state == BT_CONFIG) { |
1638 | d->mtu = s->mtu; | 1644 | d->mtu = s->mtu; |
1639 | rfcomm_send_pn(s, 1, d); | 1645 | if (rfcomm_check_link_mode(d)) { |
1646 | set_bit(RFCOMM_AUTH_PENDING, &d->flags); | ||
1647 | rfcomm_dlc_set_timer(d, RFCOMM_AUTH_TIMEOUT); | ||
1648 | } else | ||
1649 | rfcomm_send_pn(s, 1, d); | ||
1640 | } | 1650 | } |
1641 | } | 1651 | } |
1642 | } | 1652 | } |
@@ -1709,7 +1719,11 @@ static inline void rfcomm_process_dlcs(struct rfcomm_session *s) | |||
1709 | 1719 | ||
1710 | if (test_and_clear_bit(RFCOMM_AUTH_ACCEPT, &d->flags)) { | 1720 | if (test_and_clear_bit(RFCOMM_AUTH_ACCEPT, &d->flags)) { |
1711 | rfcomm_dlc_clear_timer(d); | 1721 | rfcomm_dlc_clear_timer(d); |
1712 | rfcomm_dlc_accept(d); | 1722 | if (d->out) { |
1723 | rfcomm_send_pn(s, 1, d); | ||
1724 | rfcomm_dlc_set_timer(d, RFCOMM_CONN_TIMEOUT); | ||
1725 | } else | ||
1726 | rfcomm_dlc_accept(d); | ||
1713 | if (d->link_mode & RFCOMM_LM_SECURE) { | 1727 | if (d->link_mode & RFCOMM_LM_SECURE) { |
1714 | struct sock *sk = s->sock->sk; | 1728 | struct sock *sk = s->sock->sk; |
1715 | hci_conn_change_link_key(l2cap_pi(sk)->conn->hcon); | 1729 | hci_conn_change_link_key(l2cap_pi(sk)->conn->hcon); |
@@ -1717,7 +1731,10 @@ static inline void rfcomm_process_dlcs(struct rfcomm_session *s) | |||
1717 | continue; | 1731 | continue; |
1718 | } else if (test_and_clear_bit(RFCOMM_AUTH_REJECT, &d->flags)) { | 1732 | } else if (test_and_clear_bit(RFCOMM_AUTH_REJECT, &d->flags)) { |
1719 | rfcomm_dlc_clear_timer(d); | 1733 | rfcomm_dlc_clear_timer(d); |
1720 | rfcomm_send_dm(s, d->dlci); | 1734 | if (!d->out) |
1735 | rfcomm_send_dm(s, d->dlci); | ||
1736 | else | ||
1737 | d->state = BT_CLOSED; | ||
1721 | __rfcomm_dlc_close(d, ECONNREFUSED); | 1738 | __rfcomm_dlc_close(d, ECONNREFUSED); |
1722 | continue; | 1739 | continue; |
1723 | } | 1740 | } |
@@ -1726,7 +1743,7 @@ static inline void rfcomm_process_dlcs(struct rfcomm_session *s) | |||
1726 | continue; | 1743 | continue; |
1727 | 1744 | ||
1728 | if ((d->state == BT_CONNECTED || d->state == BT_DISCONN) && | 1745 | if ((d->state == BT_CONNECTED || d->state == BT_DISCONN) && |
1729 | d->mscex == RFCOMM_MSCEX_OK) | 1746 | d->mscex == RFCOMM_MSCEX_OK) |
1730 | rfcomm_process_tx(d); | 1747 | rfcomm_process_tx(d); |
1731 | } | 1748 | } |
1732 | } | 1749 | } |
@@ -1954,7 +1971,8 @@ static void rfcomm_auth_cfm(struct hci_conn *conn, u8 status) | |||
1954 | list_for_each_safe(p, n, &s->dlcs) { | 1971 | list_for_each_safe(p, n, &s->dlcs) { |
1955 | d = list_entry(p, struct rfcomm_dlc, list); | 1972 | d = list_entry(p, struct rfcomm_dlc, list); |
1956 | 1973 | ||
1957 | if (d->link_mode & (RFCOMM_LM_ENCRYPT | RFCOMM_LM_SECURE)) | 1974 | if ((d->link_mode & (RFCOMM_LM_ENCRYPT | RFCOMM_LM_SECURE)) && |
1975 | !(conn->link_mode & HCI_LM_ENCRYPT) && !status) | ||
1958 | continue; | 1976 | continue; |
1959 | 1977 | ||
1960 | if (!test_and_clear_bit(RFCOMM_AUTH_PENDING, &d->flags)) | 1978 | if (!test_and_clear_bit(RFCOMM_AUTH_PENDING, &d->flags)) |
@@ -1988,6 +2006,14 @@ static void rfcomm_encrypt_cfm(struct hci_conn *conn, u8 status, u8 encrypt) | |||
1988 | list_for_each_safe(p, n, &s->dlcs) { | 2006 | list_for_each_safe(p, n, &s->dlcs) { |
1989 | d = list_entry(p, struct rfcomm_dlc, list); | 2007 | d = list_entry(p, struct rfcomm_dlc, list); |
1990 | 2008 | ||
2009 | if ((d->link_mode & (RFCOMM_LM_ENCRYPT | RFCOMM_LM_SECURE)) && | ||
2010 | (d->state == BT_CONNECTED || | ||
2011 | d->state == BT_CONFIG) && | ||
2012 | !status && encrypt == 0x00) { | ||
2013 | __rfcomm_dlc_close(d, ECONNREFUSED); | ||
2014 | continue; | ||
2015 | } | ||
2016 | |||
1991 | if (!test_and_clear_bit(RFCOMM_AUTH_PENDING, &d->flags)) | 2017 | if (!test_and_clear_bit(RFCOMM_AUTH_PENDING, &d->flags)) |
1992 | continue; | 2018 | continue; |
1993 | 2019 | ||
diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c index 5083adcbfae5..8a972b6ba85f 100644 --- a/net/bluetooth/rfcomm/sock.c +++ b/net/bluetooth/rfcomm/sock.c | |||
@@ -23,8 +23,6 @@ | |||
23 | 23 | ||
24 | /* | 24 | /* |
25 | * RFCOMM sockets. | 25 | * RFCOMM sockets. |
26 | * | ||
27 | * $Id: sock.c,v 1.24 2002/10/03 01:00:34 maxk Exp $ | ||
28 | */ | 26 | */ |
29 | 27 | ||
30 | #include <linux/module.h> | 28 | #include <linux/module.h> |
@@ -309,13 +307,13 @@ static struct sock *rfcomm_sock_alloc(struct net *net, struct socket *sock, int | |||
309 | sk->sk_destruct = rfcomm_sock_destruct; | 307 | sk->sk_destruct = rfcomm_sock_destruct; |
310 | sk->sk_sndtimeo = RFCOMM_CONN_TIMEOUT; | 308 | sk->sk_sndtimeo = RFCOMM_CONN_TIMEOUT; |
311 | 309 | ||
312 | sk->sk_sndbuf = RFCOMM_MAX_CREDITS * RFCOMM_DEFAULT_MTU * 10; | 310 | sk->sk_sndbuf = RFCOMM_MAX_CREDITS * RFCOMM_DEFAULT_MTU * 10; |
313 | sk->sk_rcvbuf = RFCOMM_MAX_CREDITS * RFCOMM_DEFAULT_MTU * 10; | 311 | sk->sk_rcvbuf = RFCOMM_MAX_CREDITS * RFCOMM_DEFAULT_MTU * 10; |
314 | 312 | ||
315 | sock_reset_flag(sk, SOCK_ZAPPED); | 313 | sock_reset_flag(sk, SOCK_ZAPPED); |
316 | 314 | ||
317 | sk->sk_protocol = proto; | 315 | sk->sk_protocol = proto; |
318 | sk->sk_state = BT_OPEN; | 316 | sk->sk_state = BT_OPEN; |
319 | 317 | ||
320 | bt_sock_link(&rfcomm_sk_list, sk); | 318 | bt_sock_link(&rfcomm_sk_list, sk); |
321 | 319 | ||
@@ -413,6 +411,8 @@ static int rfcomm_sock_connect(struct socket *sock, struct sockaddr *addr, int a | |||
413 | bacpy(&bt_sk(sk)->dst, &sa->rc_bdaddr); | 411 | bacpy(&bt_sk(sk)->dst, &sa->rc_bdaddr); |
414 | rfcomm_pi(sk)->channel = sa->rc_channel; | 412 | rfcomm_pi(sk)->channel = sa->rc_channel; |
415 | 413 | ||
414 | d->link_mode = rfcomm_pi(sk)->link_mode; | ||
415 | |||
416 | err = rfcomm_dlc_open(d, &bt_sk(sk)->src, &sa->rc_bdaddr, sa->rc_channel); | 416 | err = rfcomm_dlc_open(d, &bt_sk(sk)->src, &sa->rc_bdaddr, sa->rc_channel); |
417 | if (!err) | 417 | if (!err) |
418 | err = bt_sock_wait_state(sk, BT_CONNECTED, | 418 | err = bt_sock_wait_state(sk, BT_CONNECTED, |
@@ -688,6 +688,8 @@ static int rfcomm_sock_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
688 | copied += chunk; | 688 | copied += chunk; |
689 | size -= chunk; | 689 | size -= chunk; |
690 | 690 | ||
691 | sock_recv_timestamp(msg, sk, skb); | ||
692 | |||
691 | if (!(flags & MSG_PEEK)) { | 693 | if (!(flags & MSG_PEEK)) { |
692 | atomic_sub(chunk, &sk->sk_rmem_alloc); | 694 | atomic_sub(chunk, &sk->sk_rmem_alloc); |
693 | 695 | ||
@@ -793,15 +795,20 @@ static int rfcomm_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned lon | |||
793 | struct sock *sk = sock->sk; | 795 | struct sock *sk = sock->sk; |
794 | int err; | 796 | int err; |
795 | 797 | ||
796 | lock_sock(sk); | 798 | BT_DBG("sk %p cmd %x arg %lx", sk, cmd, arg); |
799 | |||
800 | err = bt_sock_ioctl(sock, cmd, arg); | ||
797 | 801 | ||
802 | if (err == -ENOIOCTLCMD) { | ||
798 | #ifdef CONFIG_BT_RFCOMM_TTY | 803 | #ifdef CONFIG_BT_RFCOMM_TTY |
799 | err = rfcomm_dev_ioctl(sk, cmd, (void __user *)arg); | 804 | lock_sock(sk); |
805 | err = rfcomm_dev_ioctl(sk, cmd, (void __user *) arg); | ||
806 | release_sock(sk); | ||
800 | #else | 807 | #else |
801 | err = -EOPNOTSUPP; | 808 | err = -EOPNOTSUPP; |
802 | #endif | 809 | #endif |
810 | } | ||
803 | 811 | ||
804 | release_sock(sk); | ||
805 | return err; | 812 | return err; |
806 | } | 813 | } |
807 | 814 | ||
diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c index 0a387f2eb7a9..d3340dd52bcf 100644 --- a/net/bluetooth/rfcomm/tty.c +++ b/net/bluetooth/rfcomm/tty.c | |||
@@ -23,8 +23,6 @@ | |||
23 | 23 | ||
24 | /* | 24 | /* |
25 | * RFCOMM TTY. | 25 | * RFCOMM TTY. |
26 | * | ||
27 | * $Id: tty.c,v 1.24 2002/10/03 01:54:38 holtmann Exp $ | ||
28 | */ | 26 | */ |
29 | 27 | ||
30 | #include <linux/module.h> | 28 | #include <linux/module.h> |
@@ -77,6 +75,8 @@ struct rfcomm_dev { | |||
77 | struct device *tty_dev; | 75 | struct device *tty_dev; |
78 | 76 | ||
79 | atomic_t wmem_alloc; | 77 | atomic_t wmem_alloc; |
78 | |||
79 | struct sk_buff_head pending; | ||
80 | }; | 80 | }; |
81 | 81 | ||
82 | static LIST_HEAD(rfcomm_dev_list); | 82 | static LIST_HEAD(rfcomm_dev_list); |
@@ -264,13 +264,34 @@ static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc) | |||
264 | init_waitqueue_head(&dev->wait); | 264 | init_waitqueue_head(&dev->wait); |
265 | tasklet_init(&dev->wakeup_task, rfcomm_tty_wakeup, (unsigned long) dev); | 265 | tasklet_init(&dev->wakeup_task, rfcomm_tty_wakeup, (unsigned long) dev); |
266 | 266 | ||
267 | skb_queue_head_init(&dev->pending); | ||
268 | |||
267 | rfcomm_dlc_lock(dlc); | 269 | rfcomm_dlc_lock(dlc); |
270 | |||
271 | if (req->flags & (1 << RFCOMM_REUSE_DLC)) { | ||
272 | struct sock *sk = dlc->owner; | ||
273 | struct sk_buff *skb; | ||
274 | |||
275 | BUG_ON(!sk); | ||
276 | |||
277 | rfcomm_dlc_throttle(dlc); | ||
278 | |||
279 | while ((skb = skb_dequeue(&sk->sk_receive_queue))) { | ||
280 | skb_orphan(skb); | ||
281 | skb_queue_tail(&dev->pending, skb); | ||
282 | atomic_sub(skb->len, &sk->sk_rmem_alloc); | ||
283 | } | ||
284 | } | ||
285 | |||
268 | dlc->data_ready = rfcomm_dev_data_ready; | 286 | dlc->data_ready = rfcomm_dev_data_ready; |
269 | dlc->state_change = rfcomm_dev_state_change; | 287 | dlc->state_change = rfcomm_dev_state_change; |
270 | dlc->modem_status = rfcomm_dev_modem_status; | 288 | dlc->modem_status = rfcomm_dev_modem_status; |
271 | 289 | ||
272 | dlc->owner = dev; | 290 | dlc->owner = dev; |
273 | dev->dlc = dlc; | 291 | dev->dlc = dlc; |
292 | |||
293 | rfcomm_dev_modem_status(dlc, dlc->remote_v24_sig); | ||
294 | |||
274 | rfcomm_dlc_unlock(dlc); | 295 | rfcomm_dlc_unlock(dlc); |
275 | 296 | ||
276 | /* It's safe to call __module_get() here because socket already | 297 | /* It's safe to call __module_get() here because socket already |
@@ -539,11 +560,16 @@ static void rfcomm_dev_data_ready(struct rfcomm_dlc *dlc, struct sk_buff *skb) | |||
539 | struct rfcomm_dev *dev = dlc->owner; | 560 | struct rfcomm_dev *dev = dlc->owner; |
540 | struct tty_struct *tty; | 561 | struct tty_struct *tty; |
541 | 562 | ||
542 | if (!dev || !(tty = dev->tty)) { | 563 | if (!dev) { |
543 | kfree_skb(skb); | 564 | kfree_skb(skb); |
544 | return; | 565 | return; |
545 | } | 566 | } |
546 | 567 | ||
568 | if (!(tty = dev->tty) || !skb_queue_empty(&dev->pending)) { | ||
569 | skb_queue_tail(&dev->pending, skb); | ||
570 | return; | ||
571 | } | ||
572 | |||
547 | BT_DBG("dlc %p tty %p len %d", dlc, tty, skb->len); | 573 | BT_DBG("dlc %p tty %p len %d", dlc, tty, skb->len); |
548 | 574 | ||
549 | tty_insert_flip_string(tty, skb->data, skb->len); | 575 | tty_insert_flip_string(tty, skb->data, skb->len); |
@@ -620,6 +646,30 @@ static void rfcomm_tty_wakeup(unsigned long arg) | |||
620 | tty_wakeup(tty); | 646 | tty_wakeup(tty); |
621 | } | 647 | } |
622 | 648 | ||
649 | static void rfcomm_tty_copy_pending(struct rfcomm_dev *dev) | ||
650 | { | ||
651 | struct tty_struct *tty = dev->tty; | ||
652 | struct sk_buff *skb; | ||
653 | int inserted = 0; | ||
654 | |||
655 | if (!tty) | ||
656 | return; | ||
657 | |||
658 | BT_DBG("dev %p tty %p", dev, tty); | ||
659 | |||
660 | rfcomm_dlc_lock(dev->dlc); | ||
661 | |||
662 | while ((skb = skb_dequeue(&dev->pending))) { | ||
663 | inserted += tty_insert_flip_string(tty, skb->data, skb->len); | ||
664 | kfree_skb(skb); | ||
665 | } | ||
666 | |||
667 | rfcomm_dlc_unlock(dev->dlc); | ||
668 | |||
669 | if (inserted > 0) | ||
670 | tty_flip_buffer_push(tty); | ||
671 | } | ||
672 | |||
623 | static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp) | 673 | static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp) |
624 | { | 674 | { |
625 | DECLARE_WAITQUEUE(wait, current); | 675 | DECLARE_WAITQUEUE(wait, current); |
@@ -684,6 +734,10 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp) | |||
684 | if (err == 0) | 734 | if (err == 0) |
685 | device_move(dev->tty_dev, rfcomm_get_device(dev)); | 735 | device_move(dev->tty_dev, rfcomm_get_device(dev)); |
686 | 736 | ||
737 | rfcomm_tty_copy_pending(dev); | ||
738 | |||
739 | rfcomm_dlc_unthrottle(dev->dlc); | ||
740 | |||
687 | return err; | 741 | return err; |
688 | } | 742 | } |
689 | 743 | ||
@@ -1114,6 +1168,7 @@ int rfcomm_init_ttys(void) | |||
1114 | rfcomm_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; | 1168 | rfcomm_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; |
1115 | rfcomm_tty_driver->init_termios = tty_std_termios; | 1169 | rfcomm_tty_driver->init_termios = tty_std_termios; |
1116 | rfcomm_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; | 1170 | rfcomm_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; |
1171 | rfcomm_tty_driver->init_termios.c_lflag &= ~ICANON; | ||
1117 | tty_set_operations(rfcomm_tty_driver, &rfcomm_ops); | 1172 | tty_set_operations(rfcomm_tty_driver, &rfcomm_ops); |
1118 | 1173 | ||
1119 | if (tty_register_driver(rfcomm_tty_driver)) { | 1174 | if (tty_register_driver(rfcomm_tty_driver)) { |