diff mbox series

[BlueZ,v2,1/7] obexd: Add PSM support to session create

Message ID 20240912174921.386856-2-frederic.danis@collabora.com (mailing list archive)
State Superseded
Headers show
Series Add BIP for AVRCP covert art OBEX client | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/CheckPatch success CheckPatch PASS
tedd_an/GitLint success Gitlint PASS
tedd_an/BuildEll success Build ELL PASS
tedd_an/BluezMake success Bluez Make PASS
tedd_an/MakeCheck success Bluez Make Check PASS
tedd_an/MakeDistcheck success Make Distcheck PASS
tedd_an/CheckValgrind success Check Valgrind PASS
tedd_an/CheckSmatch success CheckSparse PASS
tedd_an/bluezmakeextell success Make External ELL PASS
tedd_an/IncrementalBuild success Incremental Build PASS
tedd_an/ScanBuild warning ScanBuild: obexd/client/bip-avrcp.c:119:3: warning: Value stored to 'reply' is never read reply = g_dbus_create_error(message, ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ obexd/client/bip-avrcp.c:141:9: warning: Access to field 'message' results in a dereference of a null pointer (loaded from variable 'err') err->message); ^~~~~~~~~~~~ obexd/client/bip-avrcp.c:162:3: warning: Value stored to 'reply' is never read reply = g_dbus_create_error(message, ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ obexd/client/bip-avrcp.c:181:9: warning: Access to field 'message' results in a dereference of a null pointer (loaded from variable 'err') err->message); ^~~~~~~~~~~~ obexd/client/bip-avrcp.c:322:10: warning: Potential leak of memory pointed to by 'encoding' reply = g_dbus_create_error(message, ERROR_INTERFACE ".Failed", "%s", ^~~~~~~~~~~~~~~~~~~ obexd/client/bip-avrcp.c:322:10: warning: Potential leak of memory pointed to by 'pixel' reply = g_dbus_create_error(message, ERROR_INTERFACE ".Failed", "%s", ^~~~~~~~~~~~~~~~~~~ 6 warnings generated. profiles/audio/avrcp.c:1942:2: warning: Value stored to 'operands' is never read operands += sizeof(*pdu); ^ ~~~~~~~~~~~~ 1 warning generated.

Commit Message

Frédéric Danis Sept. 12, 2024, 5:49 p.m. UTC
An OBEX session can be connected to a RFCOMM channel or a L2CAP PSM.
---
 doc/org.bluez.obex.Client.rst  |  4 ++++
 doc/org.bluez.obex.Session.rst |  5 +++++
 obexd/client/manager.c         | 14 ++++++++++----
 obexd/client/session.c         | 27 ++++++++++++++++++++++++---
 obexd/client/session.h         |  1 +
 5 files changed, 44 insertions(+), 7 deletions(-)

Comments

bluez.test.bot@gmail.com Sept. 12, 2024, 10:37 p.m. UTC | #1
This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=889869

---Test result---

Test Summary:
CheckPatch                    FAIL      4.87 seconds
GitLint                       FAIL      2.45 seconds
BuildEll                      PASS      25.39 seconds
BluezMake                     PASS      1704.84 seconds
MakeCheck                     PASS      21.99 seconds
MakeDistcheck                 PASS      193.14 seconds
CheckValgrind                 PASS      274.95 seconds
CheckSmatch                   PASS      356.90 seconds
bluezmakeextell               PASS      120.03 seconds
IncrementalBuild              PASS      11587.97 seconds
ScanBuild                     WARNING   1015.75 seconds

Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script
Output:
[BlueZ,v2,5/7] obexd: Add GetImageProperties to bip-avrcp
WARNING:COMMIT_LOG_LONG_LINE: Possible unwrapped commit description (prefer a maximum 75 chars per line)
#78: 
[2] https://github.com/enkait/Basic-Imaging-Profile-in-obexd/blob/gsoc_final/plugins/bip_util.c

WARNING:ONE_SEMICOLON: Statements terminations use 1 semicolon
#366: FILE: obexd/client/bip-common.c:132:
+	return g_ascii_strtoll(size, NULL, 10);;

/github/workspace/src/src/13802399.patch total: 0 errors, 2 warnings, 926 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

/github/workspace/src/src/13802399.patch has style problems, please review.

NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.


##############################
Test: GitLint - FAIL
Desc: Run gitlint
Output:
[BlueZ,v2,4/7] obexd: Add BIP client for AVRCP cover art download.

WARNING: I3 - ignore-body-lines: gitlint will be switching from using Python regex 'match' (match beginning) to 'search' (match anywhere) semantics. Please review your ignore-body-lines.regex option accordingly. To remove this warning, set general.regex-style-search=True. More details: https://jorisroovers.github.io/gitlint/configuration/#regex-style-search
1: T3 Title has trailing punctuation (.): "[BlueZ,v2,4/7] obexd: Add BIP client for AVRCP cover art download."
[BlueZ,v2,5/7] obexd: Add GetImageProperties to bip-avrcp

WARNING: I3 - ignore-body-lines: gitlint will be switching from using Python regex 'match' (match beginning) to 'search' (match anywhere) semantics. Please review your ignore-body-lines.regex option accordingly. To remove this warning, set general.regex-style-search=True. More details: https://jorisroovers.github.io/gitlint/configuration/#regex-style-search
10: B1 Line exceeds max length (95>80): "[2] https://github.com/enkait/Basic-Imaging-Profile-in-obexd/blob/gsoc_final/plugins/bip_util.c"
##############################
Test: ScanBuild - WARNING
Desc: Run Scan Build
Output:
obexd/client/bip-avrcp.c:119:3: warning: Value stored to 'reply' is never read
                reply = g_dbus_create_error(message,
                ^       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
obexd/client/bip-avrcp.c:141:9: warning: Access to field 'message' results in a dereference of a null pointer (loaded from variable 'err')
                                                                err->message);
                                                                ^~~~~~~~~~~~
obexd/client/bip-avrcp.c:162:3: warning: Value stored to 'reply' is never read
                reply = g_dbus_create_error(message,
                ^       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
obexd/client/bip-avrcp.c:181:9: warning: Access to field 'message' results in a dereference of a null pointer (loaded from variable 'err')
                                                                err->message);
                                                                ^~~~~~~~~~~~
obexd/client/bip-avrcp.c:322:10: warning: Potential leak of memory pointed to by 'encoding'
        reply = g_dbus_create_error(message, ERROR_INTERFACE ".Failed", "%s",
                ^~~~~~~~~~~~~~~~~~~
obexd/client/bip-avrcp.c:322:10: warning: Potential leak of memory pointed to by 'pixel'
        reply = g_dbus_create_error(message, ERROR_INTERFACE ".Failed", "%s",
                ^~~~~~~~~~~~~~~~~~~
6 warnings generated.
profiles/audio/avrcp.c:1942:2: warning: Value stored to 'operands' is never read
        operands += sizeof(*pdu);
        ^           ~~~~~~~~~~~~
1 warning generated.



---
Regards,
Linux Bluetooth
diff mbox series

Patch

diff --git a/doc/org.bluez.obex.Client.rst b/doc/org.bluez.obex.Client.rst
index 9f77a9abc..5ae7cc5e8 100644
--- a/doc/org.bluez.obex.Client.rst
+++ b/doc/org.bluez.obex.Client.rst
@@ -52,6 +52,10 @@  object CreateSession(string destination, dict args)
 
 		Channel to be used.
 
+	:uint16 PSM:
+
+		L2CAP PSM to be used.
+
 	Possible errors:
 
 	:org.bluez.obex.Error.InvalidArguments:
diff --git a/doc/org.bluez.obex.Session.rst b/doc/org.bluez.obex.Session.rst
index 1cef9a53d..fc5f14e5d 100644
--- a/doc/org.bluez.obex.Session.rst
+++ b/doc/org.bluez.obex.Session.rst
@@ -50,6 +50,11 @@  byte Channel [readonly]
 
 	Bluetooth channel
 
+uint16 PSM [readonly]
+```````````````````````
+
+	Bluetooth L2CAP PSM
+
 string Target [readonly]
 ````````````````````````
 
diff --git a/obexd/client/manager.c b/obexd/client/manager.c
index ad1fbb04a..52c00fb0c 100644
--- a/obexd/client/manager.c
+++ b/obexd/client/manager.c
@@ -107,7 +107,8 @@  done:
 }
 
 static int parse_device_dict(DBusMessageIter *iter,
-		const char **source, const char **target, uint8_t *channel)
+		const char **source, const char **target, uint8_t *channel,
+		uint16_t *psm)
 {
 	while (dbus_message_iter_get_arg_type(iter) == DBUS_TYPE_DICT_ENTRY) {
 		DBusMessageIter entry, value;
@@ -130,6 +131,10 @@  static int parse_device_dict(DBusMessageIter *iter,
 			if (g_str_equal(key, "Channel") == TRUE)
 				dbus_message_iter_get_basic(&value, channel);
 			break;
+		case DBUS_TYPE_UINT16:
+			if (g_str_equal(key, "PSM") == TRUE)
+				dbus_message_iter_get_basic(&value, psm);
+			break;
 		}
 
 		dbus_message_iter_next(iter);
@@ -160,6 +165,7 @@  static DBusMessage *create_session(DBusConnection *connection,
 	struct send_data *data;
 	const char *source = NULL, *dest = NULL, *target = NULL;
 	uint8_t channel = 0;
+	uint16_t psm = 0;
 
 	dbus_message_iter_init(message, &iter);
 	if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
@@ -175,8 +181,8 @@  static DBusMessage *create_session(DBusConnection *connection,
 
 	dbus_message_iter_recurse(&iter, &dict);
 
-	parse_device_dict(&dict, &source, &target, &channel);
-	if (dest == NULL || target == NULL)
+	parse_device_dict(&dict, &source, &target, &channel, &psm);
+	if (dest == NULL || target == NULL || (channel && psm))
 		return g_dbus_create_error(message,
 				ERROR_INTERFACE ".InvalidArguments", NULL);
 
@@ -188,7 +194,7 @@  static DBusMessage *create_session(DBusConnection *connection,
 	data->connection = dbus_connection_ref(connection);
 	data->message = dbus_message_ref(message);
 
-	session = obc_session_create(source, dest, target, channel,
+	session = obc_session_create(source, dest, target, channel, psm,
 					dbus_message_get_sender(message),
 					create_callback, data);
 	if (session != NULL) {
diff --git a/obexd/client/session.c b/obexd/client/session.c
index 7d8ebb04e..13a834e14 100644
--- a/obexd/client/session.c
+++ b/obexd/client/session.c
@@ -88,6 +88,7 @@  struct obc_session {
 	char *source;
 	char *destination;
 	uint8_t channel;
+	uint16_t psm;
 	struct obc_transport *transport;
 	struct obc_driver *driver;
 	char *path;		/* Session path */
@@ -471,6 +472,7 @@  static struct obc_session *session_find(const char *source,
 						const char *destination,
 						const char *service,
 						uint8_t channel,
+						uint16_t psm,
 						const char *owner)
 {
 	GSList *l;
@@ -490,6 +492,9 @@  static struct obc_session *session_find(const char *source,
 		if (channel && session->channel != channel)
 			continue;
 
+		if (psm && session->psm != psm)
+			continue;
+
 		if (g_strcmp0(owner, session->owner))
 			continue;
 
@@ -541,8 +546,9 @@  static int session_connect(struct obc_session *session,
 	}
 
 	session->id = transport->connect(session->source, session->destination,
-					driver->uuid, session->channel,
-					transport_func, callback);
+			driver->uuid,
+			session->channel ? session->channel : session->psm,
+			transport_func, callback);
 	if (session->id == 0) {
 		obc_session_unref(callback->session);
 		g_free(callback);
@@ -558,6 +564,7 @@  struct obc_session *obc_session_create(const char *source,
 						const char *destination,
 						const char *service,
 						uint8_t channel,
+						uint16_t psm,
 						const char *owner,
 						session_callback_t function,
 						void *user_data)
@@ -570,7 +577,8 @@  struct obc_session *obc_session_create(const char *source,
 	if (destination == NULL)
 		return NULL;
 
-	session = session_find(source, destination, service, channel, owner);
+	session = session_find(source, destination, service, channel, psm,
+				owner);
 	if (session != NULL)
 		goto proceed;
 
@@ -598,6 +606,7 @@  struct obc_session *obc_session_create(const char *source,
 	session->source = g_strdup(source);
 	session->destination = g_strdup(destination);
 	session->channel = channel;
+	session->psm = psm;
 	session->queue = g_queue_new();
 	session->folder = g_strdup("/");
 
@@ -762,6 +771,17 @@  static gboolean get_channel(const GDBusPropertyTable *property,
 	return TRUE;
 }
 
+static gboolean get_psm(const GDBusPropertyTable *property,
+					DBusMessageIter *iter, void *data)
+{
+	struct obc_session *session = data;
+
+	dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16,
+							&session->psm);
+
+	return TRUE;
+}
+
 static const GDBusMethodTable session_methods[] = {
 	{ GDBUS_ASYNC_METHOD("GetCapabilities",
 				NULL, GDBUS_ARGS({ "capabilities", "s" }),
@@ -794,6 +814,7 @@  static const GDBusPropertyTable session_properties[] = {
 	{ "Source", "s", get_source, NULL, source_exists },
 	{ "Destination", "s", get_destination },
 	{ "Channel", "y", get_channel },
+	{ "PSM", "q", get_psm },
 	{ "Target", "s", get_target, NULL, target_exists },
 	{ }
 };
diff --git a/obexd/client/session.h b/obexd/client/session.h
index 2c646df1a..19c3f3687 100644
--- a/obexd/client/session.h
+++ b/obexd/client/session.h
@@ -22,6 +22,7 @@  struct obc_session *obc_session_create(const char *source,
 						const char *destination,
 						const char *service,
 						uint8_t channel,
+						uint16_t psm,
 						const char *owner,
 						session_callback_t function,
 						void *user_data);