aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/bnep/core.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2006-07-06 07:09:02 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2006-09-28 21:01:26 -0400
commit0a85b964e141a4b8db6eaf500ceace12f8f52f93 (patch)
tree8479bdc23230d7c1fa581af15199d7bef7268231 /net/bluetooth/bnep/core.c
parentb219e3ac66183fc9771b94af931fb5fd41d586ec (diff)
[Bluetooth] Integrate services into the driver model
This patch integrates the services of the Bluetooth protocols RFCOMM, BNEP and HIDP into the driver model. This makes it possible to assign the virtual TTY, network and input devices to a specific Bluetooth connection. Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/bnep/core.c')
-rw-r--r--net/bluetooth/bnep/core.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c
index e620061fb50f..2312d050eeed 100644
--- a/net/bluetooth/bnep/core.c
+++ b/net/bluetooth/bnep/core.c
@@ -51,6 +51,7 @@
51#include <asm/unaligned.h> 51#include <asm/unaligned.h>
52 52
53#include <net/bluetooth/bluetooth.h> 53#include <net/bluetooth/bluetooth.h>
54#include <net/bluetooth/hci_core.h>
54#include <net/bluetooth/l2cap.h> 55#include <net/bluetooth/l2cap.h>
55 56
56#include "bnep.h" 57#include "bnep.h"
@@ -515,6 +516,26 @@ static int bnep_session(void *arg)
515 return 0; 516 return 0;
516} 517}
517 518
519static struct device *bnep_get_device(struct bnep_session *session)
520{
521 bdaddr_t *src = &bt_sk(session->sock->sk)->src;
522 bdaddr_t *dst = &bt_sk(session->sock->sk)->dst;
523 struct hci_dev *hdev;
524 struct hci_conn *conn;
525
526 hdev = hci_get_route(dst, src);
527 if (!hdev)
528 return NULL;
529
530 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, dst);
531 if (!conn)
532 return NULL;
533
534 hci_dev_put(hdev);
535
536 return &conn->dev;
537}
538
518int bnep_add_connection(struct bnep_connadd_req *req, struct socket *sock) 539int bnep_add_connection(struct bnep_connadd_req *req, struct socket *sock)
519{ 540{
520 struct net_device *dev; 541 struct net_device *dev;
@@ -534,7 +555,6 @@ int bnep_add_connection(struct bnep_connadd_req *req, struct socket *sock)
534 if (!dev) 555 if (!dev)
535 return -ENOMEM; 556 return -ENOMEM;
536 557
537
538 down_write(&bnep_session_sem); 558 down_write(&bnep_session_sem);
539 559
540 ss = __bnep_get_session(dst); 560 ss = __bnep_get_session(dst);
@@ -551,7 +571,7 @@ int bnep_add_connection(struct bnep_connadd_req *req, struct socket *sock)
551 memcpy(s->eh.h_source, &dst, ETH_ALEN); 571 memcpy(s->eh.h_source, &dst, ETH_ALEN);
552 memcpy(dev->dev_addr, s->eh.h_dest, ETH_ALEN); 572 memcpy(dev->dev_addr, s->eh.h_dest, ETH_ALEN);
553 573
554 s->dev = dev; 574 s->dev = dev;
555 s->sock = sock; 575 s->sock = sock;
556 s->role = req->role; 576 s->role = req->role;
557 s->state = BT_CONNECTED; 577 s->state = BT_CONNECTED;
@@ -568,6 +588,8 @@ int bnep_add_connection(struct bnep_connadd_req *req, struct socket *sock)
568 bnep_set_default_proto_filter(s); 588 bnep_set_default_proto_filter(s);
569#endif 589#endif
570 590
591 SET_NETDEV_DEV(dev, bnep_get_device(s));
592
571 err = register_netdev(dev); 593 err = register_netdev(dev);
572 if (err) { 594 if (err) {
573 goto failed; 595 goto failed;