Bluetooth: RFCOMM: Handle incoming dlc request

Handles SABM request to a valid dlci and sends UA response. If PN is
not negotiated for this dlci prior, then accept callback will be invoked
to profile. Dlc will be connected at this point and user can start
sending data over this dlc

> ACL Data RX: Handle 256 flags 0x02 dlen 8                                                                                                                                        [hci0] 210.138443
      Channel: 64 len 4 [PSM 3 mode 0] {chan 0}
      RFCOMM: Set Async Balance Mode (SABM) (0x2f)
         Address: 0x0b cr 1 dlci 0x02
         Control: 0x3f poll/final 1
         Length: 0
         FCS: 0x59
< ACL Data TX: Handle 256 flags 0x00 dlen 8                                                                                                                                        [hci0] 210.140102
      Channel: 64 len 4 [PSM 3 mode 0] {chan 0}
      RFCOMM: Unnumbered Ack (UA) (0x63)
         Address: 0x0b cr 1 dlci 0x02
         Control: 0x73 poll/final 1
         Length: 0
         FCS: 0x92

Change-Id: I6bf5efb811d3ca5b106c9dff67d3a50a74818956
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
This commit is contained in:
Jaganath Kanakkassery 2016-08-18 18:12:29 +05:30 committed by Johan Hedberg
commit d363b6896c

View file

@ -261,6 +261,15 @@ static int rfcomm_send_ua(struct bt_rfcomm_session *session, uint8_t dlci)
return bt_l2cap_chan_send(&session->br_chan.chan, buf);
}
static void rfcomm_dlc_connected(struct bt_rfcomm_dlc *dlc)
{
dlc->state = BT_RFCOMM_STATE_CONNECTED;
if (dlc->ops && dlc->ops->connected) {
dlc->ops->connected(dlc);
}
}
static void rfcomm_handle_sabm(struct bt_rfcomm_session *session, uint8_t dlci)
{
if (!dlci) {
@ -271,6 +280,21 @@ static void rfcomm_handle_sabm(struct bt_rfcomm_session *session, uint8_t dlci)
}
session->state = BT_RFCOMM_STATE_CONNECTED;
} else {
struct bt_rfcomm_dlc *dlc;
dlc = rfcomm_dlcs_lookup_dlci(session->dlcs, dlci);
if (!dlc) {
if (rfcomm_dlc_accept(session, dlci, &dlc) < 0) {
return;
}
}
if (rfcomm_send_ua(session, dlci) < 0) {
return;
}
rfcomm_dlc_connected(dlc);
}
}