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
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
1c0b69678f
gobex: fix removing wrong id on transfer_free
...
If statement checks for get_id handle but was removing req_id.
2012-12-04 22:22:04 +01:00
Bartosz Szatkowski
b8cc54f1b9
gobex: Add "cd ../dir" handling in setpath
2012-12-04 22:22:04 +01:00
Luiz Augusto von Dentz
16e1f86a1e
gobex: make connection id check less strict
...
OBEX spec says:
Only the first packet in the request needs to contain the Connection
Id header...
If a Connection Id header is received with an invalid connection
identifier, it is recommended that the operation be rejected with the
response code (0xD3) “Service Unavailable”.
Since not all requests packets need to contain Connection Id header we
should only try to validate it in case a header is received.
Reported by Hendrik Sattler <post@hendrik-sattler.de>
2012-12-04 22:22:04 +01:00
Luiz Augusto von Dentz
ad8d85382f
gobex: fix sending Connection ID header in all requests
...
According to both OBEX and GOEP specs Connection ID should only be
included in the first packet of a request.
2012-12-04 22:22:04 +01:00
Luiz Augusto von Dentz
bc654c5048
gobex: fix not tracking received responses
...
obex->rx_last_op is only updated if there is no pending request which
means it only store last received request.
2012-12-04 22:22:04 +01:00
Luiz Augusto von Dentz
30b091c42e
gobex: fix checking connection id for ABORT
...
OBEX spec state that it is optional to send a Connection Id header in an
OBEX ABORT operation.
Reported by Hendrik Sattler <post@hendrik-sattler.de>
2012-12-04 22:22:03 +01:00
Luiz Augusto von Dentz
704d8b47a3
gobex: add check for connection id
...
Since gobex maintain the connection id of the session it is more
convenient to check whether the incoming request connection matches
before calling the application handlers.
2012-12-04 22:22:03 +01:00
Luiz Augusto von Dentz
206f64d3ed
gobex: remove extra define of G_OBEX_RSP_SUCCESS
2012-12-04 22:22:03 +01:00
Luiz Augusto von Dentz
bf8b55059e
gobex: dump data when G_OBEX_DEBUG_DATA is set
2012-12-04 22:22:03 +01:00
Luiz Augusto von Dentz
85db8f76c3
gobex: log packets using G_OBEX_DEBUG_PACKET
2012-12-04 22:22:03 +01:00
Luiz Augusto von Dentz
f6952b7e3a
gobex: log headers using G_OBEX_DEBUG_HEADER
2012-12-04 22:22:03 +01:00
Luiz Augusto von Dentz
48bbe41993
gobex: log transfers using G_OBEX_DEBUG_TRANSFER
2012-12-04 22:22:03 +01:00
Luiz Augusto von Dentz
6690cd3b76
gobex: log commands using G_OBEX_DEBUG_COMMAND
2012-12-04 22:22:03 +01:00
Luiz Augusto von Dentz
fffdbad4a8
gobex: log errors using G_OBEX_DEBUG_ERROR
2012-12-04 22:22:03 +01:00
Luiz Augusto von Dentz
54da6b6ad2
gobex: add initial support for debug
...
This adds support for debug using GOBEX_DEBUG environment variable.
2012-12-04 22:22:03 +01:00
Luiz Augusto von Dentz
e058d7a519
gobex: fix includes of config.h
2012-12-04 22:22:03 +01:00
Luiz Augusto von Dentz
745e460a58
gobex: add missing checks for config.h
2012-12-04 22:22:03 +01:00
Johan Hedberg
3a7f9049c0
gobex: Fix decoding byte array headers with too small length
...
Length values of less than 3 are invalid.
2012-12-04 22:22:03 +01:00
Johan Hedberg
1c2da64348
gobex: Remove g_obex_packet_find_header
...
This was exactly the same as g_obex_packet_get_header.
2012-12-04 22:22:03 +01:00
Johan Hedberg
81dd14a05e
gobex: Use larger timeout first packet in transfers
...
Frequently upon receiving the first packet servers will perform some
sort of user interaction to authorize the incoming request. It's
therefore wise to use a larger timeout for this first packet on the
client side.
2012-12-04 22:22:02 +01:00
Johan Hedberg
a2204214c2
gobex: Fix request timeout handling when aborting
2012-12-04 22:22:02 +01:00
Johan Hedberg
5b613d1174
gobex: Protect against user callback freeing internal objects
...
A user callback could potentially do things like g_obex_cancel_request
or g_obex_unref while we are inside the IO watch callback. It is
therefore important to ensure that we are in a consistent state when the
user callback returns.
2012-12-04 22:22:02 +01:00
Johan Hedberg
5c50f04098
gobex: Protect against transfer_complete callback removing the transfer
2012-12-04 22:22:02 +01:00
Johan Hedberg
91e0e1c324
gobex: Fix opcode for Action command convenience functions
2012-12-04 22:22:02 +01:00
Johan Hedberg
afc903b0f3
gobex: Add support for Action command header offset (0)
2012-12-04 22:22:02 +01:00
Johan Hedberg
4549f997e8
gobex: Add client transfer functions taking a pre-created GObexPacket
2012-12-04 22:22:02 +01:00
Johan Hedberg
003421aed2
gobex: Add OBEX packet header addition convenience functions
2012-12-04 22:22:02 +01:00
Johan Hedberg
e12802a76b
gobex: Add Action command convenience functions
2012-12-04 22:22:02 +01:00
Luiz Augusto von Dentz
c96d0645b3
gobex: fix setting final bit on PUT requests
...
Final bit should not be set when creating new request packets for PUT
since it may be not be the end of the body.
2012-12-04 22:22:02 +01:00
Luiz Augusto von Dentz
1e00bd8f5e
gobex: fix not handling unkown transport type
2012-12-04 22:22:02 +01:00
Jakub Adamek
f264b1c744
gobex: Fix encoding of empty unicode headers
...
According to IrOBEX:
"An empty Name header is defined as a Name header of length 3 (one byte
opcode + two byte length)."
The current code encodes an empty header with 5 bytes, including two
bytes of null-terminator.
This patch assumes that this definition of emptiness applies to all
unicode headers, not just the name header.
2012-12-04 22:22:02 +01:00
Daniele Forsi
f64fe4f401
gobex: Fix compilation when NEED_G_SLIST_FREE_FULL is defined
...
To use the replacement for g_slist_free_full() both compat.h and
glib-helper.h need to be included.
Fixes:
gobex/gobex.c:911: error: implicit declaration of function 'g_slist_free_full'
tools/obex-server-tool.c:344: error: implicit declaration of function ‘g_slist_free_full’
2012-12-04 22:22:02 +01:00
Johan Hedberg
6814998db7
gobex: Remove reduntant empty line
2012-12-04 22:22:02 +01:00
Johan Hedberg
1513406f59
gobex: Fix compilation error with GPOINTER_TO_UINT
...
Fixes the following issue seen on debian unstable:
gobex/gobex.c: In function 'handle_request':
gobex/gobex.c:646:50: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
2012-12-04 22:22:02 +01:00
Johan Hedberg
0528bfc1a0
gobex: Add support for returning -EAGAIN from producer callback
2012-12-04 22:22:02 +01:00
Johan Hedberg
f0598095d1
gobex: Premit raw OBEX error codes within G_OBEX_ERROR GError domain
2012-12-04 22:22:02 +01:00
Johan Hedberg
c38b06abda
gobex: Refactor get response parsing in transfer code
2012-12-04 22:22:02 +01:00
Johan Hedberg
234c29546d
gobex: Fix put request handling with final bit value
2012-12-04 22:22:01 +01:00
Johan Hedberg
d9ef079522
gobex: Add g_obex_packet_get_body convenience function
2012-12-04 22:22:01 +01:00
Johan Hedberg
b0341a13d5
gobex: Make use of g_obex_send_rsp where possible
2012-12-04 22:22:01 +01:00
Johan Hedberg
3352a36c11
gobex: Allow g_obex_send_rsp to take custom headers
2012-12-04 22:22:01 +01:00
Johan Hedberg
ddb69649e8
gobex: Merge gobex-transfer.h into gobex.h
2012-12-04 22:22:01 +01:00
Johan Hedberg
57e1082eb0
gobex: Use guint instead of gint for request callback id
2012-12-04 22:22:01 +01:00
Johan Hedberg
7ee5aede6e
gobex: Minor coding style fixes
2012-12-04 22:22:01 +01:00
Johan Hedberg
d713e186e5
gobex: Add g_obex_send_rsp convenience function
2012-12-04 22:22:01 +01:00
Johan Hedberg
c869ca28b8
gobex: Make use of va-args headers in higher level functions
2012-12-04 22:22:01 +01:00
Johan Hedberg
815218c7ef
gobex: Make transfer functions take va-args header lists
2012-12-04 22:22:01 +01:00
Johan Hedberg
58cd14d209
gobex: Remove _ID_ from header type definitions
2012-12-04 22:22:01 +01:00
Johan Hedberg
cdcde59687
gobex: Add va-args based packet creation support
2012-12-04 22:22:01 +01:00
Johan Hedberg
f8e95ce529
gobex: Make buffer parameter const for g_obex_header_new_bytes
2012-12-04 22:22:01 +01:00
Johan Hedberg
f5d10bf7cb
gobex: Remove unneeded data_policy from g_obex_header_new_bytes
2012-12-04 22:22:01 +01:00
Johan Hedberg
25faf4fc79
gobex: Allow calling g_obex_get_rsp later with custom headers
2012-12-04 22:22:01 +01:00
Johan Hedberg
7f5cb418d3
gobex: Ignore unexpected responses (which can occur when aborting)
2012-12-04 22:22:01 +01:00
Johan Hedberg
1760e5f5f5
gobex: Add g_obex_delete
2012-12-04 22:22:01 +01:00
Johan Hedberg
8554bc2a89
gobex: Add g_obex_mkdir
2012-12-04 22:22:01 +01:00
Johan Hedberg
1b609bec8e
gobex: Add g_obex_setpath
2012-12-04 22:22:00 +01:00
Johan Hedberg
8d7a30ff3e
gobex: Fix header offset lookup
2012-12-04 22:22:00 +01:00
Johan Hedberg
60263d9a33
gobex: Add g_obex_cancel_transfer
2012-12-04 22:22:00 +01:00
Johan Hedberg
5eb7afa856
gobex: Fix g_obex_get_rsp end of transfer handling
2012-12-04 22:22:00 +01:00
Johan Hedberg
42d94c84a2
gobex: Add support for suspend & resume
2012-12-04 22:22:00 +01:00
Johan Hedberg
98703e92d1
gobex: Add g_obex_get_rsp
2012-12-04 22:22:00 +01:00
Johan Hedberg
6abdccbf94
gobex: Add g_obex_get_req
2012-12-04 22:22:00 +01:00
Johan Hedberg
a2ced03a85
gobex: Don't call consumer callback if there is no data
2012-12-04 22:22:00 +01:00
Johan Hedberg
d070d17059
gobex: Add basic server-side put transfer support
2012-12-04 22:21:59 +01:00
Johan Hedberg
4fa31e1966
gobex: Fix typo
2012-12-04 22:21:59 +01:00
Johan Hedberg
0c9201a416
gobex: Fix also response code for on-demand data based packets
2012-12-04 22:21:59 +01:00
Johan Hedberg
10dfec83a1
gobex: Rename g_obex_put to g_obex_put_req
2012-12-04 22:21:59 +01:00
Johan Hedberg
7fee9ce693
gobex: Remove g_obex_set_request_function
2012-12-04 22:21:59 +01:00
Johan Hedberg
3f41b8b201
gobex: Add per-opcode request handlers
2012-12-04 22:21:59 +01:00
Johan Hedberg
2af993b895
gobex: Add type and name headers to the g_obex_put request
2012-12-04 22:21:59 +01:00
Johan Hedberg
b50f20a501
gobex: Use GObexDataProducer type instead of (custom) GObexPacketDataFunc
2012-12-04 22:21:59 +01:00
Johan Hedberg
0a4824ddb1
gobex: Make on-demand body headers a GObexPacket feature
2012-12-04 22:21:59 +01:00
Johan Hedberg
49514b2cc4
gobex: Track last received request internally and remove g_obex_response
2012-12-04 22:21:59 +01:00
Johan Hedberg
920c62df3e
gobex: Add initial transfer abstraction
2012-12-04 22:21:59 +01:00
Johan Hedberg
8888c5ae47
gobex: Fix end of body packets for on-demand headers
2012-12-04 22:21:59 +01:00
Johan Hedberg
ba377e0462
gobex: Don't stop sending data if a single packet fails to encode
2012-12-04 22:21:59 +01:00
Johan Hedberg
e6b2f2e4b7
gobex: Fix parsing over-sized packets
2012-12-04 22:21:59 +01:00
Johan Hedberg
67ad4a69a2
gobex: Rename GObexDisconnectFunc to simply GObexFunc
2012-12-04 22:21:59 +01:00
Johan Hedberg
714abdfc72
gobex: Make on-demand header callbacks able to fail cleanly
2012-12-04 22:21:59 +01:00
Johan Hedberg
2e49852cce
gobex: Use opcode instead of entire req in g_obex_response
2012-12-04 22:21:59 +01:00
Johan Hedberg
0fb35029cf
gobex: Add support for Connection ID header
2012-12-04 22:21:59 +01:00
Johan Hedberg
814b06ed67
gobex: Add g_obex_packet_find_header and g_obex_packet_prepend_header
2012-12-04 22:21:59 +01:00
Johan Hedberg
a470646232
gobex: Add convenience response sending function
2012-12-04 22:21:58 +01:00
Johan Hedberg
0794989ac8
gobex: Add convenience function for sending connect req
2012-12-04 22:21:58 +01:00
Johan Hedberg
11d5035505
gobex: Fix RX MTU setting
2012-12-04 22:21:58 +01:00
Johan Hedberg
9c3a8c372d
gobex: Fix minor (whitespace) coding style issue
2012-12-04 22:21:58 +01:00
Johan Hedberg
007fe21a23
gobex: Add missing g_set_error in header parsing
2012-12-04 22:21:58 +01:00
Johan Hedberg
7afc5a6f90
gobex: g_obex_new should create its own GIOChannel ref
2012-12-04 22:21:58 +01:00
Johan Hedberg
0a262129e4
gobex: Fix removing pending request timeout callback
2012-12-04 22:21:58 +01:00
Johan Hedberg
72dfb1af80
gobex: Remove superfluous return statement
2012-12-04 22:21:58 +01:00
Johan Hedberg
a3a72da600
gobex: Rename SRM Parameters definition to match spec.
2012-12-04 22:21:58 +01:00