linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Emeltchenko Andrei <Andrei.Emeltchenko.news@gmail.com>
To: Marcel Holtmann <marcel@holtmann.org>, linux-bluetooth@vger.kernel.org
Subject: Re: [RFCv2 01/20] Bluetooth: A2MP: Create A2MP socket
Date: Thu, 29 Dec 2011 13:23:36 +0200	[thread overview]
Message-ID: <20111229112334.GA3821@aemeltch-MOBL1> (raw)
In-Reply-To: <20111222181240.GF2730@joana>

Hi Marcel, Gustavo,

On Thu, Dec 22, 2011 at 04:12:40PM -0200, Gustavo Padovan wrote:
...
> > > +static struct socket *open_a2mp_sock(struct l2cap_conn *conn)
> > > +{
> > > +	int err;
> > > +	struct socket *sock;
> > > +	struct sockaddr_l2 addr;
> > > +	struct sock *sk;
> > > +
> > > +	err = sock_create_kern(PF_BLUETOOTH, SOCK_SEQPACKET,
> > > +					BTPROTO_L2CAP, &sock);
> > > +	if (err) {
> > > +		BT_ERR("sock_create_kern failed %d", err);
> > > +		return NULL;
> > > +	}
> > > +
> > > +	sk = sock->sk;
> > > +	memset(&addr, 0, sizeof(addr));
> > > +	bacpy(&addr.l2_bdaddr, conn->src);
> > > +	addr.l2_family = AF_BLUETOOTH;
> > > +	addr.l2_cid = L2CAP_CID_A2MP;
> > > +	err = kernel_bind(sock, (struct sockaddr *) &addr, sizeof(addr));
> > > +	if (err) {
> > > +		BT_ERR("kernel_bind failed %d", err);
> > > +		sock_release(sock);
> > > +		return NULL;
> > > +	}
> > > +
> > > +	l2cap_fixed_channel_config(sk);
> > > +
> > > +	memset(&addr, 0, sizeof(addr));
> > > +	bacpy(&addr.l2_bdaddr, conn->dst);
> > > +	addr.l2_family = AF_BLUETOOTH;
> > > +	addr.l2_cid = L2CAP_CID_A2MP;
> > > +	err = kernel_connect(sock, (struct sockaddr *) &addr, sizeof(addr),
> > > +							O_NONBLOCK);
> > > +	if ((err == 0) || (err == -EINPROGRESS))
> > > +		return sock;
> > > +	else {
> > > +		BT_ERR("kernel_connect failed %d", err);
> > > +		sock_release(sock);
> > > +		return NULL;
> > > +	}
> > > +}
> > 
> > And now I am confused. So either we use the socket inside the kernel
> > directly or we make internal calls to L2CAP. However this looks like a
> > really weird mix between we do whatever we please.
> > 
> > If this is has a long term plan that I am not away, I like to see these
> > parts properly commented in the code. Otherwise we end up in a disaster
> > area later on.
> 
> We can also understand this as another call to create a proper way to access
> L2CAP inside the kernel. A big part of the work to create such interface is
> done, though the hardest part was left to the final.

The main idea is to use existing code to handle L2CAP fixed channel
without L2CAP channel initialization (Connect Req/Rsp, ...). The amount of
code change is really small.

The other patch "[RFCv2 19/20] Bluetooth: A2MP: Handling fixed channel"
continues this idea.

Do you think that approach is a bit hackish? 

Best regards 
Andrei Emeltchenko 

> We could go L2CAP and fix this first and then create clean A2DP right from the
> beginning.
> 
> 	Gustavo

  reply	other threads:[~2011-12-29 11:23 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-22 11:06 [RFCv2 00/20] RFC Bluetooth A2MP implementation Emeltchenko Andrei
2011-12-22 11:06 ` [RFCv2 01/20] Bluetooth: A2MP: Create A2MP socket Emeltchenko Andrei
2011-12-22 17:18   ` Marcel Holtmann
2011-12-22 18:12     ` Gustavo Padovan
2011-12-29 11:23       ` Emeltchenko Andrei [this message]
2011-12-22 11:06 ` [PATCH] Bluetooth: A2MP: Manage incoming connections Emeltchenko Andrei
2011-12-22 11:06 ` [PATCH] Bluetooth: AMP: physical link struct definitions Emeltchenko Andrei
2011-12-22 12:25   ` Emeltchenko Andrei
2011-12-22 11:06 ` [RFCv2 02/20] Bluetooth: A2MP: Add data_ready and state_change Emeltchenko Andrei
2011-12-22 11:06 ` [RFCv2 03/20] Bluetooth: A2MP: AMP Manager basic functions Emeltchenko Andrei
2011-12-22 11:06 ` [RFCv2 04/20] Bluetooth: A2MP: Build and Send msg helpers Emeltchenko Andrei
2011-12-22 11:06 ` [RFCv2 05/20] Bluetooth: A2MP: Remove AMP manager in state_change Emeltchenko Andrei
2011-12-22 11:06 ` [RFCv2 06/20] Bluetooth: A2MP: AMP manager initialization Emeltchenko Andrei
2011-12-22 11:06 ` [RFCv2 07/20] Bluetooth: A2MP: Definitions for A2MP commands Emeltchenko Andrei
2011-12-22 11:06 ` [RFCv2 08/20] Bluetooth: A2MP: Define A2MP status codes Emeltchenko Andrei
2011-12-22 11:06 ` [RFCv2 09/20] Bluetooth: A2MP: Process A2MP messages Emeltchenko Andrei
2011-12-22 11:06 ` [RFCv2 10/20] Bluetooth: A2MP: Process A2MP Command Reject Emeltchenko Andrei
2011-12-22 11:06 ` [RFCv2 11/20] Bluetooth: A2MP: Helper functions to count HCI devs Emeltchenko Andrei
2011-12-22 11:06 ` [RFCv2 12/20] Bluetooth: A2MP: Process A2MP Discover Request Emeltchenko Andrei
2011-12-22 11:06 ` [RFCv2 13/20] Bluetooth: A2MP: Process A2MP Change Notify Emeltchenko Andrei
2011-12-22 11:06 ` [RFCv2 14/20] Bluetooth: A2MP: Process A2MP Get Info Request Emeltchenko Andrei
2011-12-22 11:06 ` [RFCv2 15/20] Bluetooth: A2MP: Process A2MP Get AMP Assoc Request Emeltchenko Andrei
2011-12-22 11:06 ` [RFCv2 16/20] Bluetooth: A2MP: Process A2MP Create Physlink Request Emeltchenko Andrei
2011-12-22 11:06 ` [RFCv2 17/20] Bluetooth: A2MP: Process A2MP Disc " Emeltchenko Andrei
2011-12-22 11:06 ` [RFCv2 18/20] Bluetooth: A2MP: Process A2MP Command Responses Emeltchenko Andrei
2011-12-22 11:06 ` [RFCv2 19/20] Bluetooth: A2MP: Handling fixed channel Emeltchenko Andrei
2011-12-22 11:06 ` [RFCv2 20/20] Bluetooth: A2MP: Manage incoming connections Emeltchenko Andrei

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20111229112334.GA3821@aemeltch-MOBL1 \
    --to=andrei.emeltchenko.news@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=marcel@holtmann.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).