Diff between dbd9c3109e77088de3d7e35dec78524ba73d1ad4 and eb0214a462f5aa159a948a992e141f4d8ddf443d

Changed Files

File Additions Deletions Status
src/profile.c +21 -0 modified

Full Patch

diff --git a/src/profile.c b/src/profile.c
index 11bc058..338e903 100644
--- a/src/profile.c
+++ b/src/profile.c
@@ -698,6 +698,24 @@ static int connect_io(struct ext_io *conn, bdaddr_t *src, bdaddr_t *dst)
 	return 0;
 }
 
+static uint16_t get_goep_l2cap_psm(sdp_record_t *rec)
+{
+	sdp_data_t *data;
+
+	data = sdp_data_get(rec, SDP_ATTR_GOEP_L2CAP_PSM);
+	if (!data)
+		return 0;
+
+	if (data->dtd != SDP_UINT16)
+		return 0;
+
+	/* PSM must be odd and lsb of upper byte must be 0 */
+	if ((data->val.uint16 & 0x0101) != 0x0001)
+		return 0;
+
+	return data->val.uint16;
+}
+
 static void record_cb(sdp_list_t *recs, int err, gpointer user_data)
 {
 	struct ext_io *conn = user_data;
@@ -737,6 +755,9 @@ static void record_cb(sdp_list_t *recs, int err, gpointer user_data)
 		if (port > 0)
 			ext->chan = port;
 
+		if (ext->psm == 0 && sdp_get_proto_desc(protos, OBEX_UUID))
+			ext->psm = get_goep_l2cap_psm(rec);
+
 		sdp_list_foreach(protos, (sdp_list_func_t) sdp_list_free,
 									NULL);
 		sdp_list_free(protos, NULL);