2011-06-20 10:00:50

by Nami

[permalink] [raw]
Subject: [PATCH obexd 06/14] Add protocol member to distinguish OBEX Protocol.

---
plugins/bluetooth.c | 14 ++++++++++----
src/service.h | 7 +++++++
2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 632e148..6eb4048 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -456,10 +456,14 @@ static int request_service_authorization(struct bluetooth_service *service,

if (connection == NULL || any->path == NULL)
return -1;
-
- bt_io_get(io, BT_IO_RFCOMM, &err,
- BT_IO_OPT_SOURCE, source,
- BT_IO_OPT_INVALID);
+ if(service->driver->protocol == RFCOMM_OBEX)
+ bt_io_get(io, BT_IO_RFCOMM, &err,
+ BT_IO_OPT_SOURCE, source,
+ BT_IO_OPT_INVALID);
+ else
+ bt_io_get(io, BT_IO_L2CAP, &err,
+ BT_IO_OPT_SOURCE, source,
+ BT_IO_OPT_INVALID);
if (err) {
error("%s", err->message);
g_error_free(err);
@@ -505,6 +509,7 @@ static void confirm_event(GIOChannel *io, void *user_data)
error("bluetooth: Unable to find service");
goto drop;
}
+ service->driver->protocol = RFCOMM_OBEX;

if (service->driver->service != OBEX_OPP) {
if (request_service_authorization(service, io, address) < 0)
@@ -550,6 +555,7 @@ static void l2cap_confirm_event(GIOChannel *io, void *user_data)
error("bluetooth: Unable to find service");
goto drop;
}
+ service->driver->protocol = L2CAP_OBEX;
if (service->driver->service != OBEX_OPP) {
if (request_service_authorization(service, io, address) < 0)
goto drop;
diff --git a/src/service.h b/src/service.h
index 313b1f2..465be82 100644
--- a/src/service.h
+++ b/src/service.h
@@ -21,11 +21,18 @@
*
*/

+typedef enum {
+ RFCOMM_OBEX,
+ L2CAP_OBEX
+} Obex_Protocol;
+
+
struct obex_service_driver {
const char *name;
uint16_t service;
uint8_t channel;
uint16_t psm;
+ Obex_Protocol protocol;
const uint8_t *target;
unsigned int target_size;
const uint8_t *who;
--
1.7.1



2011-06-21 07:43:13

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCH obexd 06/14] Add protocol member to distinguish OBEX Protocol.

Hi Nami,

On Tue, Jun 21, 2011 at 10:14 AM, Li, Nami <[email protected]> wrote:
> Hi, Luiz
>>IMO It should have been named transport instead of protocol, but I don't think it should be exposed in the service driver, actually the transport driver should be the one responsible for authorization.
> ?Well, I think it named transport instead of protocol is really more suitable. Have you reviewed my patch 07/14? Cause I need to know transport type (RFCOMM or L2CAP) when set fd obex transport format (STREAM or SEQPACKET), so I add the member in service drive.

First lets get the OpenOBEX patches in so we have an idea how the API
will look like, then you can resend the patches so we can review and
figure out what is the best way to treat transport types.

--
Luiz Augusto von Dentz

2011-06-21 07:14:50

by Li, Nami

[permalink] [raw]
Subject: RE: [PATCH obexd 06/14] Add protocol member to distinguish OBEX Protocol.

Hi, Luiz
>IMO It should have been named transport instead of protocol, but I don't think it should be exposed in the service driver, actually the transport driver should be the one responsible for authorization.
Well, I think it named transport instead of protocol is really more suitable. Have you reviewed my patch 07/14? Cause I need to know transport type (RFCOMM or L2CAP) when set fd obex transport format (STREAM or SEQPACKET), so I add the member in service drive.

Thanks.
Nami


2011-06-20 10:49:00

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCH obexd 06/14] Add protocol member to distinguish OBEX Protocol.

Hi Nami,

On Mon, Jun 20, 2011 at 1:00 PM, Nami <[email protected]> wrote:
> ---
> ?plugins/bluetooth.c | ? 14 ++++++++++----
> ?src/service.h ? ? ? | ? ?7 +++++++
> ?2 files changed, 17 insertions(+), 4 deletions(-)
>
> diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
> index 632e148..6eb4048 100644
> --- a/plugins/bluetooth.c
> +++ b/plugins/bluetooth.c
> @@ -456,10 +456,14 @@ static int request_service_authorization(struct bluetooth_service *service,
>
> ? ? ? ?if (connection == NULL || any->path == NULL)
> ? ? ? ? ? ? ? ?return -1;
> -
> - ? ? ? bt_io_get(io, BT_IO_RFCOMM, &err,
> - ? ? ? ? ? ? ? ? ? ? ? BT_IO_OPT_SOURCE, source,
> - ? ? ? ? ? ? ? ? ? ? ? BT_IO_OPT_INVALID);
> + ? ? ? if(service->driver->protocol == RFCOMM_OBEX)
> + ? ? ? ? ? ? ? bt_io_get(io, BT_IO_RFCOMM, &err,
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? BT_IO_OPT_SOURCE, source,
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? BT_IO_OPT_INVALID);
> + ? ? ? else
> + ? ? ? ? ? ? ? bt_io_get(io, BT_IO_L2CAP, &err,
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? BT_IO_OPT_SOURCE, source,
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? BT_IO_OPT_INVALID);
> ? ? ? ?if (err) {
> ? ? ? ? ? ? ? ?error("%s", err->message);
> ? ? ? ? ? ? ? ?g_error_free(err);
> @@ -505,6 +509,7 @@ static void confirm_event(GIOChannel *io, void *user_data)
> ? ? ? ? ? ? ? ?error("bluetooth: Unable to find service");
> ? ? ? ? ? ? ? ?goto drop;
> ? ? ? ?}
> + ? ? ? service->driver->protocol = RFCOMM_OBEX;
>
> ? ? ? ?if (service->driver->service != OBEX_OPP) {
> ? ? ? ? ? ? ? ?if (request_service_authorization(service, io, address) < 0)
> @@ -550,6 +555,7 @@ static void l2cap_confirm_event(GIOChannel *io, void *user_data)
> ? ? ? ? ? ? ? ?error("bluetooth: Unable to find service");
> ? ? ? ? ? ? ? ?goto drop;
> ? ? ? ?}
> + ? ? ? service->driver->protocol = L2CAP_OBEX;
> ? ? ? ?if (service->driver->service != OBEX_OPP) {
> ? ? ? ? ? ? ? ?if (request_service_authorization(service, io, address) < 0)
> ? ? ? ? ? ? ? ? ? ? ? ?goto drop;
> diff --git a/src/service.h b/src/service.h
> index 313b1f2..465be82 100644
> --- a/src/service.h
> +++ b/src/service.h
> @@ -21,11 +21,18 @@
> ?*
> ?*/
>
> +typedef enum {
> + ? ? ? RFCOMM_OBEX,
> + ? ? ? L2CAP_OBEX
> +} Obex_Protocol;
> +
> +
> ?struct obex_service_driver {
> ? ? ? ?const char *name;
> ? ? ? ?uint16_t service;
> ? ? ? ?uint8_t channel;
> ? ? ? ?uint16_t psm;
> + ? ? ? Obex_Protocol protocol;
> ? ? ? ?const uint8_t *target;
> ? ? ? ?unsigned int target_size;
> ? ? ? ?const uint8_t *who;
> --
> 1.7.1
>
> --

IMO It should have been named transport instead of protocol, but I
don't think it should be exposed in the service driver, actually the
transport driver should be the one responsible for authorization.


--
Luiz Augusto von Dentz

2011-06-20 10:00:51

by Nami

[permalink] [raw]
Subject: [PATCH obexd 09/14] Add psm parameter for session_find.

---
client/session.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
mode change 100644 => 100755 client/session.c

diff --git a/client/session.c b/client/session.c
old mode 100644
new mode 100755
index dd08610..3db1c1d
--- a/client/session.c
+++ b/client/session.c
@@ -498,6 +498,7 @@ static struct session_data *session_find(const char *source,
const char *destination,
const char *service,
uint8_t channel,
+ uint16_t psm,
const char *owner)
{
GSList *l;
@@ -519,7 +520,8 @@ static struct session_data *session_find(const char *source,
if (g_strcmp0(service, session->service))
continue;

- if (channel && session->channel != channel)
+ if ((channel && session->channel != channel)
+ &&(psm && session->psm != psm))
continue;

if (g_strcmp0(owner, session->owner))
@@ -547,7 +549,7 @@ struct session_data *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) {
session_ref(session);
goto proceed;
--
1.7.1