Commit Graph

117 Commits

Author SHA1 Message Date
Lucas De Marchi
f946c9e445 gobex: Get rid of gchar
Use plain char instead of gchar.
2013-05-02 09:02:31 +03:00
Lucas De Marchi
c1e4e183b5 gobex: Get rid of gint
Use plain int instead of gint. In glib gint is always a typedef to int,
so it's safe to use it even for callbacks with glib.
2013-05-01 09:04:21 +03:00
Lucas De Marchi
d073af52ea gobex: Use gcc builtin instead of g_atomic
g_atomic_* end up using G_STATIC_ASSERT, causing gcc 4.8 to yell due to
-Wunused-local-typedefs.

/usr/include/glib-2.0/glib/gmacros.h:162:53: error: typedef ‘_GStaticAssertCompileTimeAssertion_2’ locally defined but not used [-Werror=unused-local-typedefs]
 #define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1]

Most of the uses of atomic operations were wrong. They were fixed as
well. If we are using atomic operations, reading the variable again
later for logging is not an option, we should use the return of the
atomic function used to fetch the variable.
2013-04-09 07:01:58 +09:00
Johan Hedberg
30e2aaa3f8 gobex: Fix GPL version reference
These files (like everything else in the tree) should be GPL 2 or later
instead of GPL 2 only.
2013-02-15 16:25:29 +02:00
Johan Hedberg
b8779d2202 Revert "Ensure config.h is included by using CPPFLAGS"
This reverts commit 8a03376544.

The patch needs to be split up and the gdbus/ changes were bogus
compared to the original commit message.

Conflicts:
	Makefile.am
	Makefile.obexd
	profiles/cyclingspeed/cyclingspeed.c
	profiles/heartrate/heartrate.c
	src/error.c
2012-12-07 12:46:04 +02:00
Lucas De Marchi
8a03376544 Ensure config.h is included by using CPPFLAGS
Instead of trying to include config.h in each file over the tree and
possibly forgetting to include it, give a "-include config.h" argument
to the compiler so it's guaranteed that a) it will be included for all
source files and b) it will be the first header included.

gdbus/ directory is left out, since it would break other projects using
it.
2012-12-05 17:18:07 +02:00
Luiz Augusto von Dentz
696fad1853 gobex: Add debug option to apparam
This adds "apparam" to the debug options of GOBEX_DEBUG
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
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
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
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
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
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
Bartosz Szatkowski
d2b34b6a68 gobex: Add translating error codes to strings 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
bf8b55059e gobex: dump data when G_OBEX_DEBUG_DATA is set 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
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
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
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
e12802a76b gobex: Add Action command convenience functions 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
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
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
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
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
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
f5d10bf7cb gobex: Remove unneeded data_policy from g_obex_header_new_bytes 2012-12-04 22:22:01 +01:00