Commit Graph

11311 Commits

Author SHA1 Message Date
Luiz Augusto von Dentz
2476a6cb13 gobex: Add unit tests for GObexApparam API 2012-12-04 22:22:06 +01:00
Luiz Augusto von Dentz
32ffe8f9d6 gobex: Introduce GObexApparam API
GObexApparam abstract the handling of application parameter tags, it
can be used to read/parse application parameter header data using
g_obex_apparam_get_* functions or to generate the data using
g_obex_apparam_set_*.
2012-12-04 22:22:06 +01:00
Luiz Augusto von Dentz
4621a3573c gobex: Fix not printing debug messages when GOBEX_DEBUG is set
g_debug doesn't print anything if domain is not present in
G_MESSAGES_DEBUG.
2012-12-04 22:22:06 +01:00
Neal Peacock
a3bb0a6dc5 gobex: Change UTF name to standard 2012-12-04 22:22:06 +01:00
Szymon Janc
55626b774e gobex: Fix dead assignments in gobex-header.c
Values stored are never read.
2012-12-04 22:22:06 +01:00
Michał Poczwardowski
77a7ad6ae1 gobex: tools: Fix test-client error message put/get typo 2012-12-04 22:22:06 +01:00
Jaganath Kanakkassery
889a1a1400 gobex: Remove g_idle_add to exit main loop in test_stream_put_req_abort()
A callback is provided in g_obex_cancel_transfer() which will be called
when abort completes which exists the mail loop as well
2012-12-04 22:22:06 +01:00
Jaganath Kanakkassery
9095deb825 gobex: Add callback and userdata parameter to g_obex_cancel_transfer()
If callback is provided in g_obex_cancel_transfer() current complete
callback will be replaced by the new one and user will be informed
when abort completes.
2012-12-04 22:22:06 +01:00
Marcel Holtmann
cd8a24b9fa gobex: build: Remove glib-helper.h support 2012-12-04 22:22:06 +01:00
Luiz Augusto von Dentz
52b3354422 gobex: Fix unit test for PUT request followed by ABORT
gobex was actually used to respond not to request so the test is
renamed to test_stream_put_rsp_abort and a new test is created using
g_obex_put_req to initiate the request and g_obex_cancel_transfer to
abort it.
2012-12-04 22:22:06 +01:00
Mikel Astiz
45df7c0fe3 gobex: fix callback remove when canceling transfer
This code path could lead to situations where the callback is later
used, making the daemon crash.
2012-12-04 22:22:06 +01:00
Luiz Augusto von Dentz
75e50f781b gobex: Use ENOSYS to correspond to OBEX not implemented
ENOSYS correspond to function not implemented which is exactly what the
OBEX error code means.

Also since EINVAL means invalid argument that now map to OBEX bad request
2012-12-04 22:22:06 +01:00
Luiz Augusto von Dentz
faac92a4cb gobex: Translate posix error code to proper OBEX response opcode
This patch create a map between posix errors code and OBEX response
opcode and use it to generate a proper response in case a transfer
failed instead of always responding with internal error.
2012-12-04 22:22:05 +01:00
Luiz Augusto von Dentz
9e1e47425e gobex: tools: Fix test-server to use ERTM while on packet mode
OBEX should only be used with ERTM over L2CAP and set MTU properly
2012-12-04 22:22:05 +01:00
Luiz Augusto von Dentz
26ce1d484f gobex: tools: Fix test-client to use ERTM while on packet mode
OBEX should only be used with ERTM over L2CAP and set MTU properly
2012-12-04 22:22:05 +01:00
Jaganath Kanakkassery
b53a70510f gobex: Fix ABORT request not processing
G_OBEX_OP_ABORT is defined as 0x7f but error checking of opcode is
done for greater than 0x1f. So abort request is simply ignored.
2012-12-04 22:22:05 +01:00
Jaganath Kanakkassery
9166ea3ffd gobex: Add unit test for PUT request followed by ABORT 2012-12-04 22:22:05 +01:00
Luiz Augusto von Dentz
ae33bcb8a4 gobex: tools: Make test-server to use ERTM
If port is bigger than 31 and stream mode is selected then use ERTM
2012-12-04 22:22:05 +01:00
Luiz Augusto von Dentz
2a94607646 gobex: tools: Make test-client use ERTM
If port is bigger than 31 and stream mode is selected then use ERTM
2012-12-04 22:22:05 +01:00
Luiz Augusto von Dentz
a4f6139e72 gobex: fix automatically including SRM header in CONNECT responses
GOEP 2.0 test specification forbids the server to include SRM headers in
CONNECT response:

  "3.16 TP/SRM/BI-03-C Process an OBEX CONNECT request (incorrectly)
  containing a SRM header:

  • Expected Outcome
  Pass Verdict:
  – On receiving the invalid SRM header in the OBEX_CONNECT request, the
  IUT responds with a SUCCESS without a SRM header.
  – OBEX/L2CAP channel is established.
  Fail Verdict:
  – On receiving the invalid SRM header in the OBEX_CONNECT request, the
  IUT does not respond with a SUCCESS and/or includes a SRM header in the
  response.
  – OBEX/L2CAP channel is not established or OBEX/RFCOMM channel is
  established."
2012-12-04 22:22:05 +01:00
Luiz Augusto von Dentz
f55ddf7376 gobex: fix not disabling SRM when dealing with GET responses
While sending the final bit can be changed during encoding.
2012-12-04 22:22:05 +01:00
Jaganath Kanakkassery
7099bdd9ea gobex: Remove reduntant NULL assignment 2012-12-04 22:22:05 +01:00
Luiz Augusto von Dentz
34680daae1 gobex: fix unit test when using SOCK_SEQPACKET
Now that SRM is automatically configured when the transport type is
SOCK_SEQPACKET all tests that uses this transport are already testing
SRM so there is no need to keep adding the headers manually.

In addition to that remove the tests for SRM using SOCK_STREAM since
those are currently not supported without including the headers.
2012-12-04 22:22:05 +01:00
Luiz Augusto von Dentz
e85cc70c4f gobex: automatically use SRM when transport type is SOCK_SEQPACKET
This simplifies the applications so SRM setup phase became transparent
while using SOCK_SEQPACKET which is useful for GOEP 2.0 since in that
case we can only use SRM if the transport is L2CAP.

This also follows GOEP 2.0 Page 14 - 4.6 Using Single Response Mode:

  "The Server cannot issue an enable request, but can only issue a
  response to an enable request from the Client. SRM will remain in
  effect for the duration of the operation that enabled it (PUT or GET)
  ...
  SRM headers shall not be sent in CONNECT request or response packets."

and Page 22 - 5.4 Establishment of OBEX Connection:

  "SRM headers shall not be sent in the Connect request or response
  packets (note, this is to preserve backwards compatibility). SRM shall
  be enabled through Put and Get operations only."

So only in case of PUT or GET requests SRM is automatically configured,
applications can still enable it manually for other operations by adding
the headers like before but it is not recommended.

Note that it would be a good practice to indicate SRM support by using
value 0x02, but since that should happens during CONNECT command it is
not done automatically for requests when acting as a client, server
responding to indicate requests will automatically add SRM headers though.
2012-12-04 22:22:05 +01:00
Luiz Augusto von Dentz
f062c46212 gobex: handle Single Response Mode Parameters (SRMP) headers
Single Response Mode Parameters is a 1-byte quantity containing the
value for the parameters used for SRM.
2012-12-04 22:22:05 +01:00
Luiz Augusto von Dentz
6e7d00ceec gobex: handle Single Response Mode (SRM) headers
Single Response Mode (SRM) is a 1-byte quantity containing a value to
enable or disable SRM, as well as to indicate support for SRM.
2012-12-04 22:22:05 +01:00
Luiz Augusto von Dentz
c11d66be4c gobex: introduce g_obex_get_rsp_pkt
g_obex_get_rsp_pkt takes a response packet which sometimes is more
convenient for adding headers.
2012-12-04 22:22:05 +01:00
Luiz Augusto von Dentz
cd0af353a5 gobex: simplify naming of tests when transfering sequence of packets
Before random was used but the number of packets were not really random
so now seq is used instead.
2012-12-04 22:22:05 +01:00
Luiz Augusto von Dentz
ac5aedf446 gobex: add unit test for CONN followed by PUT request with SRM 2012-12-04 22:22:05 +01:00
Luiz Augusto von Dentz
2cc6193673 gobex: add unit test for GET request with SRM and SRMP additional wait 2012-12-04 22:22:05 +01:00
Luiz Augusto von Dentz
fc12e4ca63 gobex: add unit test for GET request with SRM and SRMP wait 2012-12-04 22:22:05 +01:00
Luiz Augusto von Dentz
2951b0d6be gobex: add unit test for GET response with SRM and SRMP wait 2012-12-04 22:22:05 +01:00
Luiz Augusto von Dentz
d3f6db2a6b gobex: add unit test for PUT response with SRM and SRMP wait 2012-12-04 22:22:05 +01:00
Luiz Augusto von Dentz
d4395a7e3b gobex: add unit test for PUT request with SRM and SRMP wait 2012-12-04 22:22:05 +01:00
Luiz Augusto von Dentz
4c305704fd gobex: add unit test for GET request with SRM 2012-12-04 22:22:05 +01:00
Luiz Augusto von Dentz
f2da5d46b5 gobex: add unit test for PUT response with SRM 2012-12-04 22:22:05 +01:00
Luiz Augusto von Dentz
5dbde0863d gobex: add unit test for GET response with SRM enable 2012-12-04 22:22:05 +01:00
Luiz Augusto von Dentz
cd3e6c9c61 gobex: add unit test for PUT request with SRM 2012-12-04 22:22:04 +01:00
Luiz Augusto von Dentz
74bb8e1474 gobex: add unit test for GET response with random data 2012-12-04 22:22:04 +01:00
Luiz Augusto von Dentz
80c602ba33 gobex: add unit test for GET request with random data 2012-12-04 22:22:04 +01:00
Luiz Augusto von Dentz
1e5b2ca160 gobex: add unit test for PUT response with random data 2012-12-04 22:22:04 +01:00
Luiz Augusto von Dentz
ab6b0ae829 gobex: reduce duplicated code in g_obex_put_req
g_obex_put_req is quite similar to g_obex_put_req_pkt so now it just
call it to avoid duplicating this code.
2012-12-04 22:22:04 +01:00
Luiz Augusto von Dentz
dd0e00c06f gobex: add defines for possible values of SRMP header
Also rename G_OBEX_HDR_SRM_PARAMETERS to just G_OBEX_HDR_SRMP as the spec
normally refer to it.
2012-12-04 22:22:04 +01:00
Luiz Augusto von Dentz
474d67b631 gobex: add defines for possible values of SRM header 2012-12-04 22:22:04 +01:00
Mikel Astiz
7dbc36186e gobex: fix transfer search in transfer_complete
The previous approach searched the transfer pointer itself, assuming
that the transfers has not been modified if the pointer is in the list.
However the callback could have removed the transfer and registered
another one, which can eventually point to the same memory location.

This is solved by looking for the transfer id instead of the pointer.
2012-12-04 22:22:04 +01:00
Bartosz Szatkowski
d2b34b6a68 gobex: Add translating error codes to strings 2012-12-04 22:22:04 +01:00
Luiz Augusto von Dentz
48497a481e gobex: add unit test for packet PUT request with random data 2012-12-04 22:22:04 +01:00
Luiz Augusto von Dentz
13564dd509 gobex: remove unused delay on test_put_req_random 2012-12-04 22:22:04 +01:00
Luiz Augusto von Dentz
19359ee369 gobex: fix wrong name of test_get_rsp_eagain 2012-12-04 22:22:04 +01:00
Luiz Augusto von Dentz
37cfa1cc4c gobex: always set CONNECTION_ID to 1 on unit tests
This simplify the creation of new test by not requiring different
variables for every connection response.
2012-12-04 22:22:04 +01:00