Bluetooth: RFCOMM: Handle DM from peer

Outgoing connection request would be rejected by peer because
of various reasons like server channel not registered etc.
This handles that by destroying the dlc and informing the same
to user.

< ACL Data TX: Handle 256 flags 0x00 dlen 18
      Channel: 64 len 14 [PSM 3 mode 0] {chan 0}
      RFCOMM: Unnumbered Info with Header Check (UIH) (0xef)
         Address: 0x03 cr 1 dlci 0x00
         Control: 0xef poll/final 0
         Length: 10
         FCS: 0x70
         MCC Message type: DLC Parameter Negotiation CMD (0x20)
           Length: 8
           dlci 4 frame_type 0 credit_flow 15 pri 0
           ack_timer 0 frame_size 30 max_retrans 0 credits 5

> ACL Data RX: Handle 256 flags 0x02 dlen 8
      Channel: 64 len 4 [PSM 3 mode 0] {chan 0}
      RFCOMM: Disconnect Mode (DM) (0x0f)
         Address: 0x13 cr 1 dlci 0x04
         Control: 0x1f poll/final 1
         Length: 0
         FCS: 0xbc

Change-Id: I98288db045001bb73ecfd54e7677d88b2bda9c13
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
This commit is contained in:
Jaganath Kanakkassery 2016-11-28 17:59:27 +05:30 committed by Johan Hedberg
commit 3ec7df34c1

View file

@ -865,6 +865,21 @@ static void rfcomm_handle_ua(struct bt_rfcomm_session *session, uint8_t dlci)
}
}
static void rfcomm_handle_dm(struct bt_rfcomm_session *session, uint8_t dlci)
{
struct bt_rfcomm_dlc *dlc;
BT_DBG("dlci %d", dlci);
dlc = rfcomm_dlcs_remove_dlci(session->dlcs, dlci);
if (!dlc) {
return;
}
rfcomm_dlc_disconnect(dlc);
rfcomm_session_disconnect(session);
}
static void rfcomm_handle_msc(struct bt_rfcomm_session *session,
struct net_buf *buf, uint8_t cr)
{
@ -1141,6 +1156,9 @@ static void rfcomm_recv(struct bt_l2cap_chan *chan, struct net_buf *buf)
case BT_RFCOMM_UA:
rfcomm_handle_ua(session, dlci);
break;
case BT_RFCOMM_DM:
rfcomm_handle_dm(session, dlci);
break;
default:
BT_WARN("Unknown/Unsupported RFCOMM Frame type 0x%02x",
frame_type);