Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 255818
b: refs/heads/master
c: 80808e4
h: refs/heads/master
v: v3
  • Loading branch information
Gustavo F. Padovan committed Jun 13, 2011
1 parent ddf2320 commit 04b99fb
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 16 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: dc50a06dac61d7ca7ddb3d9bb8921ca5d68f51b6
refs/heads/master: 80808e431e1ef25856457de82ce141bed6a6313a
12 changes: 9 additions & 3 deletions trunk/include/net/bluetooth/l2cap.h
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,15 @@ struct l2cap_chan {

struct list_head list;
struct list_head global_l;

void *data;
struct l2cap_ops *ops;
};

struct l2cap_ops {
char *name;

struct l2cap_chan *(*new_connection) (void *data);
};

struct l2cap_conn {
Expand Down Expand Up @@ -460,9 +469,6 @@ int l2cap_add_psm(struct l2cap_chan *chan, bdaddr_t *src, __le16 psm);
int l2cap_add_scid(struct l2cap_chan *chan, __u16 scid);

void l2cap_sock_kill(struct sock *sk);
void l2cap_sock_init(struct sock *sk, struct sock *parent);
struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock,
int proto, gfp_t prio);

struct l2cap_chan *l2cap_chan_create(struct sock *sk);
void l2cap_chan_close(struct l2cap_chan *chan, int reason);
Expand Down
17 changes: 7 additions & 10 deletions trunk/net/bluetooth/l2cap_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -842,18 +842,16 @@ static void l2cap_le_conn_ready(struct l2cap_conn *conn)
goto clean;
}

sk = l2cap_sock_alloc(sock_net(parent), NULL, BTPROTO_L2CAP, GFP_ATOMIC);
if (!sk)
chan = pchan->ops->new_connection(pchan->data);
if (!chan)
goto clean;

chan = l2cap_pi(sk)->chan;
sk = chan->sk;

write_lock_bh(&conn->chan_lock);

hci_conn_hold(conn->hcon);

l2cap_sock_init(sk, parent);

bacpy(&bt_sk(sk)->src, conn->src);
bacpy(&bt_sk(sk)->dst, conn->dst);

Expand Down Expand Up @@ -2329,10 +2327,12 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd
goto response;
}

sk = l2cap_sock_alloc(sock_net(parent), NULL, BTPROTO_L2CAP, GFP_ATOMIC);
if (!sk)
chan = pchan->ops->new_connection(pchan->data);
if (!chan)
goto response;

sk = chan->sk;

write_lock_bh(&conn->chan_lock);

/* Check if we already have channel with that dcid */
Expand All @@ -2345,9 +2345,6 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd

hci_conn_hold(conn->hcon);

chan = l2cap_pi(sk)->chan;

l2cap_sock_init(sk, parent);
bacpy(&bt_sk(sk)->src, conn->src);
bacpy(&bt_sk(sk)->dst, conn->dst);
chan->psm = psm;
Expand Down
29 changes: 27 additions & 2 deletions trunk/net/bluetooth/l2cap_sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#include <net/bluetooth/l2cap.h>

static const struct proto_ops l2cap_sock_ops;
static void l2cap_sock_init(struct sock *sk, struct sock *parent);
static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, int proto, gfp_t prio);

static int l2cap_sock_bind(struct socket *sock, struct sockaddr *addr, int alen)
{
Expand Down Expand Up @@ -773,6 +775,25 @@ static int l2cap_sock_release(struct socket *sock)
return err;
}

static struct l2cap_chan *l2cap_sock_new_connection_cb(void *data)
{
struct sock *sk, *parent = data;

sk = l2cap_sock_alloc(sock_net(parent), NULL, BTPROTO_L2CAP,
GFP_ATOMIC);
if (!sk)
return NULL;

l2cap_sock_init(sk, parent);

return l2cap_pi(sk)->chan;
}

static struct l2cap_ops l2cap_chan_ops = {
.name = "L2CAP Socket Interface",
.new_connection = l2cap_sock_new_connection_cb,
};

static void l2cap_sock_destruct(struct sock *sk)
{
BT_DBG("sk %p", sk);
Expand All @@ -781,7 +802,7 @@ static void l2cap_sock_destruct(struct sock *sk)
skb_queue_purge(&sk->sk_write_queue);
}

void l2cap_sock_init(struct sock *sk, struct sock *parent)
static void l2cap_sock_init(struct sock *sk, struct sock *parent)
{
struct l2cap_pinfo *pi = l2cap_pi(sk);
struct l2cap_chan *chan = pi->chan;
Expand Down Expand Up @@ -838,10 +859,14 @@ void l2cap_sock_init(struct sock *sk, struct sock *parent)
chan->force_reliable = 0;
chan->flushable = BT_FLUSHABLE_OFF;
chan->force_active = BT_POWER_FORCE_ACTIVE_ON;

}

/* Default config options */
chan->flush_to = L2CAP_DEFAULT_FLUSH_TO;

chan->data = sk;
chan->ops = &l2cap_chan_ops;
}

static struct proto l2cap_proto = {
Expand All @@ -850,7 +875,7 @@ static struct proto l2cap_proto = {
.obj_size = sizeof(struct l2cap_pinfo)
};

struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, int proto, gfp_t prio)
static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, int proto, gfp_t prio)
{
struct sock *sk;
struct l2cap_chan *chan;
Expand Down

0 comments on commit 04b99fb

Please sign in to comment.