* [PATCH 2/4] obex: extract src and dst address and store it
2013-05-27 23:07 [PATCH 1/4] session: only add Target if it exists Gustavo Padovan
@ 2013-05-27 23:07 ` Gustavo Padovan
2013-05-28 8:13 ` Luiz Augusto von Dentz
2013-05-27 23:07 ` [PATCH 3/4] session: add Source and Destination properties Gustavo Padovan
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: Gustavo Padovan @ 2013-05-27 23:07 UTC (permalink / raw)
To: linux-bluetooth; +Cc: emilio.pozuelo, Gustavo Padovan
From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
This commit creates src and dst members in obex_session to later use them
to export via Session D-Bus API.
---
obexd/src/obex-priv.h | 2 ++
obexd/src/obex.c | 8 ++++++++
2 files changed, 10 insertions(+)
diff --git a/obexd/src/obex-priv.h b/obexd/src/obex-priv.h
index 41854bc..90aa225 100644
--- a/obexd/src/obex-priv.h
+++ b/obexd/src/obex-priv.h
@@ -27,6 +27,8 @@ struct obex_session {
uint32_t id;
uint8_t cmd;
uint8_t action_id;
+ char src[18];
+ char dst[18];
char *name;
char *destname;
char *type;
diff --git a/obexd/src/obex.c b/obexd/src/obex.c
index a3e7b0e..b08a412 100644
--- a/obexd/src/obex.c
+++ b/obexd/src/obex.c
@@ -40,6 +40,7 @@
#include <inttypes.h>
#include <glib.h>
+#include <bluetooth.h>
#include <btio/btio.h>
#include <gobex/gobex.h>
@@ -1102,6 +1103,7 @@ int obex_session_start(GIOChannel *io, uint16_t tx_mtu, uint16_t rx_mtu,
GObex *obex;
GObexTransportType type;
static uint32_t id = 0;
+ bdaddr_t src, dst;
DBG("");
@@ -1134,6 +1136,12 @@ int obex_session_start(GIOChannel *io, uint16_t tx_mtu, uint16_t rx_mtu,
os->obex = obex;
os->io = g_io_channel_ref(io);
+ bt_io_get(io, NULL, BT_IO_OPT_SOURCE_BDADDR, &src,
+ BT_IO_OPT_DEST_BDADDR, &dst, BT_IO_OPT_INVALID);
+
+ ba2str(&src, os->src);
+ ba2str(&dst, os->dst);
+
sessions = g_slist_prepend(sessions, os);
return 0;
--
1.8.1.4
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH 2/4] obex: extract src and dst address and store it
2013-05-27 23:07 ` [PATCH 2/4] obex: extract src and dst address and store it Gustavo Padovan
@ 2013-05-28 8:13 ` Luiz Augusto von Dentz
0 siblings, 0 replies; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2013-05-28 8:13 UTC (permalink / raw)
To: Gustavo Padovan
Cc: linux-bluetooth@vger.kernel.org, emilio.pozuelo, Gustavo Padovan
Hi Gustavo,
On Mon, May 27, 2013 at 4:07 PM, Gustavo Padovan <gustavo@padovan.org> wrote:
> From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
>
> This commit creates src and dst members in obex_session to later use them
> to export via Session D-Bus API.
> ---
> obexd/src/obex-priv.h | 2 ++
> obexd/src/obex.c | 8 ++++++++
> 2 files changed, 10 insertions(+)
>
> diff --git a/obexd/src/obex-priv.h b/obexd/src/obex-priv.h
> index 41854bc..90aa225 100644
> --- a/obexd/src/obex-priv.h
> +++ b/obexd/src/obex-priv.h
> @@ -27,6 +27,8 @@ struct obex_session {
> uint32_t id;
> uint8_t cmd;
> uint8_t action_id;
> + char src[18];
> + char dst[18];
> char *name;
> char *destname;
> char *type;
> diff --git a/obexd/src/obex.c b/obexd/src/obex.c
> index a3e7b0e..b08a412 100644
> --- a/obexd/src/obex.c
> +++ b/obexd/src/obex.c
> @@ -40,6 +40,7 @@
> #include <inttypes.h>
>
> #include <glib.h>
> +#include <bluetooth.h>
> #include <btio/btio.h>
> #include <gobex/gobex.h>
>
> @@ -1102,6 +1103,7 @@ int obex_session_start(GIOChannel *io, uint16_t tx_mtu, uint16_t rx_mtu,
> GObex *obex;
> GObexTransportType type;
> static uint32_t id = 0;
> + bdaddr_t src, dst;
>
> DBG("");
>
> @@ -1134,6 +1136,12 @@ int obex_session_start(GIOChannel *io, uint16_t tx_mtu, uint16_t rx_mtu,
> os->obex = obex;
> os->io = g_io_channel_ref(io);
>
> + bt_io_get(io, NULL, BT_IO_OPT_SOURCE_BDADDR, &src,
> + BT_IO_OPT_DEST_BDADDR, &dst, BT_IO_OPT_INVALID);
> +
> + ba2str(&src, os->src);
> + ba2str(&dst, os->dst);
> +
> sessions = g_slist_prepend(sessions, os);
>
> return 0;
> --
> 1.8.1.4
I would prefer having this in the transport driver we just need to
extend with getsockname as getpeername is already supported, btw you
can use BT_IO_OPT_SOURCE and BT_IO_OPT_DEST directly so there is no
need to include bluetooth.h.
--
Luiz Augusto von Dentz
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 3/4] session: add Source and Destination properties
2013-05-27 23:07 [PATCH 1/4] session: only add Target if it exists Gustavo Padovan
2013-05-27 23:07 ` [PATCH 2/4] obex: extract src and dst address and store it Gustavo Padovan
@ 2013-05-27 23:07 ` Gustavo Padovan
2013-05-27 23:07 ` [PATCH 4/4] opp: Register Session interface for OPP transfers Gustavo Padovan
2013-05-28 8:37 ` [PATCH 1/4] session: only add Target if it exists Luiz Augusto von Dentz
3 siblings, 0 replies; 6+ messages in thread
From: Gustavo Padovan @ 2013-05-27 23:07 UTC (permalink / raw)
To: linux-bluetooth; +Cc: emilio.pozuelo, Gustavo Padovan
From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
This is useful when we want to know where a incoming OPP transfer, for
example, is from.
---
obexd/src/manager.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/obexd/src/manager.c b/obexd/src/manager.c
index b86565c..a116a3e 100644
--- a/obexd/src/manager.c
+++ b/obexd/src/manager.c
@@ -265,6 +265,30 @@ static DBusMessage *unregister_agent(DBusConnection *conn,
return dbus_message_new_method_return(msg);
}
+static gboolean get_source(const GDBusPropertyTable *property,
+ DBusMessageIter *iter, void *data)
+{
+ struct obex_session *os = data;
+ char *s;
+
+ s = os->src;
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &s);
+
+ return TRUE;
+}
+
+static gboolean get_destination(const GDBusPropertyTable *property,
+ DBusMessageIter *iter, void *data)
+{
+ struct obex_session *os = data;
+ char *s;
+
+ s = os->dst;
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &s);
+
+ return TRUE;
+}
+
static gboolean session_target_exists(const GDBusPropertyTable *property,
void *data)
{
@@ -529,6 +553,8 @@ static const GDBusPropertyTable transfer_properties[] = {
};
static const GDBusPropertyTable session_properties[] = {
+ { "Source", "s", get_source },
+ { "Destination", "s", get_destination },
{ "Target", "s", get_target, NULL, session_target_exists },
{ "Root", "s", get_root },
{ }
--
1.8.1.4
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 4/4] opp: Register Session interface for OPP transfers
2013-05-27 23:07 [PATCH 1/4] session: only add Target if it exists Gustavo Padovan
2013-05-27 23:07 ` [PATCH 2/4] obex: extract src and dst address and store it Gustavo Padovan
2013-05-27 23:07 ` [PATCH 3/4] session: add Source and Destination properties Gustavo Padovan
@ 2013-05-27 23:07 ` Gustavo Padovan
2013-05-28 8:37 ` [PATCH 1/4] session: only add Target if it exists Luiz Augusto von Dentz
3 siblings, 0 replies; 6+ messages in thread
From: Gustavo Padovan @ 2013-05-27 23:07 UTC (permalink / raw)
To: linux-bluetooth; +Cc: emilio.pozuelo, Gustavo Padovan
From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
The Session interface wasn't registered when a new transfer arrives.
---
obexd/plugins/opp.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/obexd/plugins/opp.c b/obexd/plugins/opp.c
index 97bf943..ee0204c 100644
--- a/obexd/plugins/opp.c
+++ b/obexd/plugins/opp.c
@@ -46,6 +46,8 @@
static void *opp_connect(struct obex_session *os, int *err)
{
+ manager_register_session(os);
+
if (err)
*err = 0;
@@ -154,6 +156,7 @@ static int opp_get(struct obex_session *os, void *user_data)
static void opp_disconnect(struct obex_session *os, void *user_data)
{
manager_unregister_transfer(user_data);
+ manager_unregister_session(os);
}
static void opp_reset(struct obex_session *os, void *user_data)
--
1.8.1.4
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH 1/4] session: only add Target if it exists
2013-05-27 23:07 [PATCH 1/4] session: only add Target if it exists Gustavo Padovan
` (2 preceding siblings ...)
2013-05-27 23:07 ` [PATCH 4/4] opp: Register Session interface for OPP transfers Gustavo Padovan
@ 2013-05-28 8:37 ` Luiz Augusto von Dentz
3 siblings, 0 replies; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2013-05-28 8:37 UTC (permalink / raw)
To: Gustavo Padovan
Cc: linux-bluetooth@vger.kernel.org, emilio.pozuelo, Gustavo Padovan
Hi Gustavo,
On Mon, May 27, 2013 at 4:07 PM, Gustavo Padovan <gustavo@padovan.org> wrote:
> From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
>
> ---
> obexd/src/manager.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/obexd/src/manager.c b/obexd/src/manager.c
> index b67567b..b86565c 100644
> --- a/obexd/src/manager.c
> +++ b/obexd/src/manager.c
> @@ -265,6 +265,14 @@ static DBusMessage *unregister_agent(DBusConnection *conn,
> return dbus_message_new_method_return(msg);
> }
>
> +static gboolean session_target_exists(const GDBusPropertyTable *property,
> + void *data)
> +{
> + struct obex_session *os = data;
> +
> + return os->service->target ? TRUE : FALSE;
> +}
> +
> static char *target2str(const uint8_t *t)
> {
> if (!t)
> @@ -521,7 +529,7 @@ static const GDBusPropertyTable transfer_properties[] = {
> };
>
> static const GDBusPropertyTable session_properties[] = {
> - { "Target", "s", get_target },
> + { "Target", "s", get_target, NULL, session_target_exists },
> { "Root", "s", get_root },
> { }
> };
> --
> 1.8.1.4
Patches 1/4 and 4/4 are now upstream, thanks.
--
Luiz Augusto von Dentz
^ permalink raw reply [flat|nested] 6+ messages in thread