summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Kraglak <marcin.kraglak@tieto.com>2014-01-10 10:18:14 +0100
committerJohan Hedberg <johan.hedberg@intel.com>2014-01-16 12:23:15 +0200
commit0c27ca7f4586ac3387343ad5d11fdf745bd8d75d (patch)
tree1cb849a01e736ba9c02aa983aa6e8f655ab845d7
parentd5439202daee29cd58d74de864c87728d227826c (diff)
emulator/bthost: Add initial rfcomm handling
This is initial rfcomm handling in bthost.
-rw-r--r--emulator/bthost.c67
1 files changed, 66 insertions, 1 deletions
diff --git a/emulator/bthost.c b/emulator/bthost.c
index fc1d81078..0f072599b 100644
--- a/emulator/bthost.c
+++ b/emulator/bthost.c
@@ -37,6 +37,7 @@
#include "src/shared/util.h"
#include "monitor/bt.h"
+#include "monitor/rfcomm.h"
#include "bthost.h"
/* ACL handle and flags pack/unpack */
@@ -1370,6 +1371,64 @@ static struct cid_hook *find_cid_hook(struct btconn *conn, uint16_t cid)
return NULL;
}
+static void rfcomm_sabm_recv(struct bthost *bthost, struct btconn *conn,
+ struct l2conn *l2conn, const void *data,
+ uint16_t len)
+{
+}
+
+static void rfcomm_disc_recv(struct bthost *bthost, struct btconn *conn,
+ struct l2conn *l2conn, const void *data,
+ uint16_t len)
+{
+}
+
+static void rfcomm_ua_recv(struct bthost *bthost, struct btconn *conn,
+ struct l2conn *l2conn, const void *data,
+ uint16_t len)
+{
+}
+
+static void rfcomm_dm_recv(struct bthost *bthost, struct btconn *conn,
+ struct l2conn *l2conn, const void *data,
+ uint16_t len)
+{
+}
+
+static void rfcomm_uih_recv(struct bthost *bthost, struct btconn *conn,
+ struct l2conn *l2conn, const void *data,
+ uint16_t len)
+{
+}
+
+static void process_rfcomm(struct bthost *bthost, struct btconn *conn,
+ struct l2conn *l2conn, const void *data,
+ uint16_t len)
+{
+ const struct rfcomm_hdr *hdr = data;
+
+ switch (RFCOMM_GET_TYPE(hdr->control)) {
+ case RFCOMM_SABM:
+ rfcomm_sabm_recv(bthost, conn, l2conn, data, len);
+ break;
+ case RFCOMM_DISC:
+ rfcomm_disc_recv(bthost, conn, l2conn, data, len);
+ break;
+ case RFCOMM_UA:
+ rfcomm_ua_recv(bthost, conn, l2conn, data, len);
+ break;
+ case RFCOMM_DM:
+ rfcomm_dm_recv(bthost, conn, l2conn, data, len);
+ break;
+ case RFCOMM_UIH:
+ rfcomm_uih_recv(bthost, conn, l2conn, data, len);
+ break;
+ default:
+ printf("Unknown frame type\n");
+ break;
+ }
+}
+
static void process_acl(struct bthost *bthost, const void *data, uint16_t len)
{
const struct bt_hci_acl_hdr *acl_hdr = data;
@@ -1377,6 +1436,7 @@ static void process_acl(struct bthost *bthost, const void *data, uint16_t len)
uint16_t handle, cid, acl_len, l2_len;
struct cid_hook *hook;
struct btconn *conn;
+ struct l2conn *l2conn;
const void *l2_data;
if (len < sizeof(*acl_hdr) + sizeof(*l2_hdr))
@@ -1415,7 +1475,12 @@ static void process_acl(struct bthost *bthost, const void *data, uint16_t len)
l2cap_le_sig(bthost, conn, l2_data, l2_len);
break;
default:
- printf("Packet for unknown CID 0x%04x (%u)\n", cid, cid);
+ l2conn = btconn_find_l2cap_conn_by_scid(conn, cid);
+ if (l2conn && l2conn->psm == 0x0003)
+ process_rfcomm(bthost, conn, l2conn, l2_data, l2_len);
+ else
+ printf("Packet for unknown CID 0x%04x (%u)\n", cid,
+ cid);
break;
}
}