* [PATCH] obex-client-tool: Set the length header
@ 2014-04-22 5:08 Martin Kampas
2014-04-23 7:24 ` Luiz Augusto von Dentz
0 siblings, 1 reply; 6+ messages in thread
From: Martin Kampas @ 2014-04-22 5:08 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Martin Kampas
At least 'put' to other device with obexd v0.48 does not work without
this.
---
tools/obex-client-tool.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/tools/obex-client-tool.c b/tools/obex-client-tool.c
index 54dbcbb..7207c77 100644
--- a/tools/obex-client-tool.c
+++ b/tools/obex-client-tool.c
@@ -135,11 +135,19 @@ static void cmd_put(int argc, char **argv)
return;
}
+ struct stat st;
+ if (fstat(fd, &st) < 0) {
+ close(fd);
+ g_printerr("fstat: %s\n", strerror(errno));
+ return;
+ }
+
data = g_new0(struct transfer_data, 1);
data->fd = fd;
g_obex_put_req(obex, put_data_cb, transfer_complete, data, &err,
G_OBEX_HDR_NAME, argv[1],
+ G_OBEX_HDR_LENGTH, st.st_size,
G_OBEX_HDR_INVALID);
if (err != NULL) {
g_printerr("put failed: %s\n", err->message);
--
1.9.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] obex-client-tool: Set the length header
2014-04-22 5:08 [PATCH] obex-client-tool: Set the length header Martin Kampas
@ 2014-04-23 7:24 ` Luiz Augusto von Dentz
2014-04-23 7:54 ` Martin Kampas
0 siblings, 1 reply; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2014-04-23 7:24 UTC (permalink / raw)
To: Martin Kampas; +Cc: linux-bluetooth@vger.kernel.org
Hi Martin,
On Tue, Apr 22, 2014 at 8:08 AM, Martin Kampas <martin.kampas@tieto.com> wrote:
> At least 'put' to other device with obexd v0.48 does not work without
> this.
The patch itself is fine but there got to be something wrong with
obexd if it cannot accept a PUT without length, maybe it is the agent
that is rejecting it?
--
Luiz Augusto von Dentz
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] obex-client-tool: Set the length header
2014-04-23 7:24 ` Luiz Augusto von Dentz
@ 2014-04-23 7:54 ` Martin Kampas
2014-04-23 8:20 ` Luiz Augusto von Dentz
0 siblings, 1 reply; 6+ messages in thread
From: Martin Kampas @ 2014-04-23 7:54 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth@vger.kernel.org
Hi Luiz,
On Wednesday, April 23, 2014 10:24:17 AM Luiz Augusto von Dentz wrote:
> The patch itself is fine but there got to be something wrong with
> obexd if it cannot accept a PUT without length, maybe it is the agent
> that is rejecting it?
If I am not wrong it is rejected inside the opp plugin in opp_chkput() [1] (where OBJECT_SIZE_DELETE should be the initial value of obex_session::size), called from check_put() [2]
I also tried with an Android 4.1 device and got the same result.
BR,
Martin
[1] http://git.kernel.org/cgit/bluetooth/obexd.git/tree/plugins/opp.c?id=0.48#n122
[2] http://git.kernel.org/cgit/bluetooth/obexd.git/tree/src/obex.c?id=0.48#n918
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] obex-client-tool: Set the length header
2014-04-23 7:54 ` Martin Kampas
@ 2014-04-23 8:20 ` Luiz Augusto von Dentz
2014-04-23 8:28 ` Luiz Augusto von Dentz
0 siblings, 1 reply; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2014-04-23 8:20 UTC (permalink / raw)
To: Martin Kampas; +Cc: linux-bluetooth@vger.kernel.org
Hi Martin,
On Wed, Apr 23, 2014 at 10:54 AM, Martin Kampas <martin.kampas@tieto.com> wrote:
> Hi Luiz,
>
> On Wednesday, April 23, 2014 10:24:17 AM Luiz Augusto von Dentz wrote:
>> The patch itself is fine but there got to be something wrong with
>> obexd if it cannot accept a PUT without length, maybe it is the agent
>> that is rejecting it?
>
> If I am not wrong it is rejected inside the opp plugin in opp_chkput() [1] (where OBJECT_SIZE_DELETE should be the initial value of obex_session::size), called from check_put() [2]
>
> I also tried with an Android 4.1 device and got the same result.
>
> BR,
> Martin
>
> [1] http://git.kernel.org/cgit/bluetooth/obexd.git/tree/plugins/opp.c?id=0.48#n122
> [2] http://git.kernel.org/cgit/bluetooth/obexd.git/tree/src/obex.c?id=0.48#n918
Hmm, looks likes it is still broken, btw the proper check is probably
to check the existence of a body header and then set size to
OBJECT_SIZE_UNKNOWN before parse_length.
--
Luiz Augusto von Dentz
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] obex-client-tool: Set the length header
2014-04-23 8:20 ` Luiz Augusto von Dentz
@ 2014-04-23 8:28 ` Luiz Augusto von Dentz
2014-04-23 10:20 ` Martin Kampas
0 siblings, 1 reply; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2014-04-23 8:28 UTC (permalink / raw)
To: Martin Kampas; +Cc: linux-bluetooth@vger.kernel.org
Hi Martin,
On Wed, Apr 23, 2014 at 11:20 AM, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
> Hi Martin,
>
> On Wed, Apr 23, 2014 at 10:54 AM, Martin Kampas <martin.kampas@tieto.com> wrote:
>> Hi Luiz,
>>
>> On Wednesday, April 23, 2014 10:24:17 AM Luiz Augusto von Dentz wrote:
>>> The patch itself is fine but there got to be something wrong with
>>> obexd if it cannot accept a PUT without length, maybe it is the agent
>>> that is rejecting it?
>>
>> If I am not wrong it is rejected inside the opp plugin in opp_chkput() [1] (where OBJECT_SIZE_DELETE should be the initial value of obex_session::size), called from check_put() [2]
>>
>> I also tried with an Android 4.1 device and got the same result.
>>
>> BR,
>> Martin
>>
>> [1] http://git.kernel.org/cgit/bluetooth/obexd.git/tree/plugins/opp.c?id=0.48#n122
>> [2] http://git.kernel.org/cgit/bluetooth/obexd.git/tree/src/obex.c?id=0.48#n918
>
> Hmm, looks likes it is still broken, btw the proper check is probably
> to check the existence of a body header and then set size to
> OBJECT_SIZE_UNKNOWN before parse_length.
Try the with the following patch:
diff --git a/obexd/src/obex.c b/obexd/src/obex.c
index bd4770d..7b4634e 100644
--- a/obexd/src/obex.c
+++ b/obexd/src/obex.c
@@ -873,6 +873,10 @@ static void cmd_put(GObex *obex, GObexPacket
*req, gpointer user_data)
os->cmd = G_OBEX_OP_PUT;
+ /* Set size to unknown if a body header exists */
+ if (g_obex_packet_get_body(req))
+ os->size = OBJECT_SIZE_UNKNOWN;
+
parse_name(os, req);
parse_length(os, req);
parse_time(os, req);
--
Luiz Augusto von Dentz
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] obex-client-tool: Set the length header
2014-04-23 8:28 ` Luiz Augusto von Dentz
@ 2014-04-23 10:20 ` Martin Kampas
0 siblings, 0 replies; 6+ messages in thread
From: Martin Kampas @ 2014-04-23 10:20 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth@vger.kernel.org
Hi Luiz,
On Wednesday, April 23, 2014 11:28:55 AM Luiz Augusto von Dentz wrote:
> Try the with the following patch:
>
> diff --git a/obexd/src/obex.c b/obexd/src/obex.c
> index bd4770d..7b4634e 100644
> --- a/obexd/src/obex.c
> +++ b/obexd/src/obex.c
> @@ -873,6 +873,10 @@ static void cmd_put(GObex *obex, GObexPacket
> *req, gpointer user_data)
>
> os->cmd = G_OBEX_OP_PUT;
>
> + /* Set size to unknown if a body header exists */
> + if (g_obex_packet_get_body(req))
> + os->size = OBJECT_SIZE_UNKNOWN;
> +
> parse_name(os, req);
> parse_length(os, req);
> parse_time(os, req);
I tried your patch with the old obexd v0.48 and it worked (I am sorry I could not easily try with the newest obexd from bluez tree).
Both patches seems worth to apply - mine to make the obex-client-tool work with old buggy devices.
Here is your patch aligned for v0.48:
diff --git a/src/obex.c b/src/obex.c
index 9044961..5ae4ff1 100644
--- a/src/obex.c
+++ b/src/obex.c
@@ -961,6 +961,10 @@ static void cmd_put(GObex *obex, GObexPacket *req, gpointer user_data)
os->cmd = G_OBEX_OP_PUT;
+ /* Set size to unknown if a body header exists */
+ if (g_obex_packet_get_body(req))
+ os->size = OBJECT_SIZE_UNKNOWN;
+
parse_name(os, req);
parse_length(os, req);
parse_time(os, req);
--
BR,
Martin
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-04-23 10:20 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-22 5:08 [PATCH] obex-client-tool: Set the length header Martin Kampas
2014-04-23 7:24 ` Luiz Augusto von Dentz
2014-04-23 7:54 ` Martin Kampas
2014-04-23 8:20 ` Luiz Augusto von Dentz
2014-04-23 8:28 ` Luiz Augusto von Dentz
2014-04-23 10:20 ` Martin Kampas
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.