gobex: add option to set input/output MTU to test-client
Subsystems (2)
Luiz Augusto von Dentz
maintainerPATCH v2 1/3 gobex: add option to set input/output MTU to test-client
From: Luiz Augusto von Dentz <[email protected]>
--- tools/test-client.c | 30 ++++++++++-------------------- 1 files changed, 10 insertions(+), 20 deletions(-)
tools/test-client.c +10 -20
@@ -43,6 +43,8 @@ static gboolean option_bluetooth = FALSE;static char *option_source =NULL ;static char *option_dest =NULL ;static int option_channel =-1 ; +static int option_imtu =-1 ; +static int option_omtu =-1 ;static void sig_term (int sig) {
@@ -67,6 +69,10 @@ static GOptionEntry options[] = { &option_packet, "Packet based transport" }, {"stream" ,'s' ,G_OPTION_FLAG_REVERSE ,G_OPTION_ARG_NONE , &option_packet, "Stream based transport" }, + { "input-mtu", 'i', 0, G_OPTION_ARG_INT, + &option_imtu, "Transport input MTU", "MTU" }, + { "output-mtu", 'o', 0, G_OPTION_ARG_INT, + &option_omtu, "Transport output MTU", "MTU" }, { NULL }, };
@@ -269,8 +275,7 @@ static void disconn_func(GObex *obex, GError *err, gpointer user_data)g_main_loop_quit (main_loop); } -static void transport_connect (GIOChannel *io,GObexTransportType transport, -gssize rx_mtu,gssize tx_mtu) +static void transport_connect (GIOChannel *io,GObexTransportType transport) {GIOChannel *input;GIOCondition events;
@@ -278,7 +283,7 @@ static void transport_connect(GIOChannel *io, GObexTransportType transport,g_io_channel_set_flags (io,G_IO_FLAG_NONBLOCK ,NULL );g_io_channel_set_close_on_unref (io, TRUE); - obex =g_obex_new (io, transport, rx_mtu, tx_mtu); + obex =g_obex_new (io, transport, option_imtu, option_omtu);g_obex_set_disconnect_function (obex, disconn_func,NULL ); input =g_io_channel_unix_new (STDIN_FILENO );
@@ -320,7 +325,7 @@ static GIOChannel *unix_connect(GObexTransportType transport)g_print ("Unix socket created: %d\n" , sk); -transport_connect (io, transport,-1 ,-1 ); +transport_connect (io, transport);return io; }
@@ -328,30 +333,15 @@ static GIOChannel *unix_connect(GObexTransportType transport)static void conn_callback (GIOChannel *io,GError *err,gpointer user_data) {GObexTransportType transport =GPOINTER_TO_UINT (user_data); -guint16 imtu =4096 , omtu =32767 ;if (err !=NULL ) {g_printerr ("%s\n" , err->message);return ; } -if (transport ==G_OBEX_TRANSPORT_PACKET ) { -GError *err =NULL ; - -if (!bt_io_get (io,BT_IO_L2CAP , &err, -BT_IO_OPT_OMTU , &omtu, -BT_IO_OPT_IMTU , &imtu, -BT_IO_OPT_INVALID )) { -g_printerr ("%s\n" , err->message); -g_clear_error (&err); -exit (EXIT_FAILURE ); - }else -g_print ("imtu=%u, omtu=%u\n" , imtu, omtu); - } -g_print ("Bluetooth socket connected\n" ); -transport_connect (io, transport, imtu, omtu); +transport_connect (io, transport); }static GIOChannel *bluetooth_connect (GObexTransportType transport)
Signature · 1 line
1.7.6
Luiz Augusto von Dentz
maintainerPATCH v2 2/3 gobex: add option to set input/output MTU to test-server
From: Luiz Augusto von Dentz <[email protected]>
--- tools/test-server.c | 74 +++++++++++++++++++++++++++------------------------ 1 files changed, 39 insertions(+), 35 deletions(-)
tools/test-server.c +39 -35
@@ -45,6 +45,8 @@ static GSList *clients = NULL;static gboolean option_packet = FALSE;static gboolean option_bluetooth = FALSE;static int option_channel =-1 ; +static int option_imtu =-1 ; +static int option_omtu =-1 ;static char *option_root =NULL ;static void sig_term (int sig)
@@ -66,6 +68,10 @@ static GOptionEntry options[] = { &option_packet, "Stream based transport" }, {"root" ,'r' ,0 ,G_OPTION_ARG_STRING , &option_root, "Root dir", "/..." }, + { "input-mtu", 'i', 0, G_OPTION_ARG_INT, + &option_imtu, "Transport input MTU", "MTU" }, + { "output-mtu", 'o', 0, G_OPTION_ARG_INT, + &option_omtu, "Transport output MTU", "MTU" }, { NULL }, };
@@ -158,8 +164,12 @@ static void handle_put(GObex *obex, GObexPacket *req, gpointer user_data)static gssize send_data (void *buf,gsize len,gpointer user_data) {struct transfer_data *data = user_data; +gssize ret; -return read (data->fd, buf, len); + ret =read (data->fd, buf, len); +g_print ("sending %zu bytes of data\n" , ret); + +return ret; }static void handle_get (GObex *obex,GObexPacket *req,gpointer user_data)
@@ -220,14 +230,34 @@ static void handle_connect(GObex *obex, GObexPacket *req, gpointer user_data)g_obex_send (obex, rsp,NULL ); } +static void transport_accept (GIOChannel *io) +{ +GObex *obex; +GObexTransportType transport; + +g_io_channel_set_flags (io,G_IO_FLAG_NONBLOCK ,NULL ); +g_io_channel_set_close_on_unref (io, TRUE); + +if (option_packet) + transport =G_OBEX_TRANSPORT_PACKET ; +else + transport =G_OBEX_TRANSPORT_STREAM ; + + obex =g_obex_new (io, transport, option_imtu, option_omtu); +g_obex_set_disconnect_function (obex, disconn_func,NULL ); +g_obex_add_request_function (obex,G_OBEX_OP_PUT , handle_put,NULL ); +g_obex_add_request_function (obex,G_OBEX_OP_GET , handle_get,NULL ); +g_obex_add_request_function (obex,G_OBEX_OP_CONNECT , handle_connect, +NULL ); + clients =g_slist_append (clients, obex); +} +static gboolean unix_accept (GIOChannel *chan,GIOCondition cond,gpointer data) {struct sockaddr_un addr;socklen_t addrlen;int sk, cli_sk;GIOChannel *io; -GObex *obex; -GObexTransportType transport;if (cond &G_IO_NVAL )return FALSE;
@@ -253,48 +283,22 @@ static gboolean unix_accept(GIOChannel *chan, GIOCondition cond, gpointer data) io =g_io_channel_unix_new (cli_sk); -g_io_channel_set_flags (io,G_IO_FLAG_NONBLOCK ,NULL ); -g_io_channel_set_close_on_unref (io, TRUE); - -if (option_packet) - transport =G_OBEX_TRANSPORT_PACKET ; -else - transport =G_OBEX_TRANSPORT_STREAM ; - - obex =g_obex_new (io, transport,-1 ,-1 ); +transport_accept (io);g_io_channel_unref (io); -g_obex_set_disconnect_function (obex, disconn_func,NULL ); -g_obex_add_request_function (obex,G_OBEX_OP_PUT , handle_put,NULL ); -g_obex_add_request_function (obex,G_OBEX_OP_GET , handle_get,NULL ); -g_obex_add_request_function (obex,G_OBEX_OP_CONNECT , handle_connect, -NULL ); - clients =g_slist_append (clients, obex);return TRUE; }static void bluetooth_accept (GIOChannel *io,GError *err,gpointer data) { -GObex *obex; -GObexTransportType transport; +if (err) { +g_printerr ("accept: %s\n" , err->message); +return ; + }g_print ("Accepted new client connection on bluetooth socket\n" ); -g_io_channel_set_flags (io,G_IO_FLAG_NONBLOCK ,NULL ); -g_io_channel_set_close_on_unref (io, TRUE); - -if (option_packet) - transport =G_OBEX_TRANSPORT_PACKET ; -else - transport =G_OBEX_TRANSPORT_STREAM ; - - obex =g_obex_new (io, transport,-1 ,-1 ); -g_obex_set_disconnect_function (obex, disconn_func,NULL ); -g_obex_add_request_function (obex,G_OBEX_OP_PUT , handle_put,NULL ); -g_obex_add_request_function (obex,G_OBEX_OP_GET , handle_get,NULL ); -g_obex_add_request_function (obex,G_OBEX_OP_CONNECT , handle_connect, -NULL ); - clients =g_slist_append (clients, obex); +transport_accept (io); }static gboolean bluetooth_watch (GIOChannel *chan,GIOCondition cond,gpointer data)
Signature · 1 line
1.7.6
Luiz Augusto von Dentz
maintainerPATCH v2 3/3 client: port to gobex
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
This remove gwobex dependency of the client using gobex instead.
Based on initial work by Johan Hedberg <[email protected]>
--- Makefile.am | 2 +- client/driver.h | 2 +- client/ftp.c | 139 +++++++++++++------ client/pbap.c | 144 ++++++++++++++------ client/session.c | 76 ++++++++--- client/session.h | 8 +- client/sync.c | 3 + client/transfer.c | 390 ++++++++++++++++++++++++++++++---------------------- client/transfer.h | 5 +- 9 files changed, 494 insertions(+), 275 deletions(-)
Makefile.am +1 -1
@@ -123,7 +123,7 @@ service_in_files += client/obex-client.service.in libexec_PROGRAMS += client/obex-client client_obex_client_SOURCES = $(gdbus_sources) $(gobex_sources) \ - $(gwobex_sources) $(btio_sources) \ + $(btio_sources) \ client/main.c src/log.h src/log.c \ client/manager.h client/manager.c \ client/session.h client/session.c \
client/driver.h +1 -1
@@ -25,7 +25,7 @@ struct obc_driver {const char *service;const char *uuid;void *target; -int target_len; +gsize target_len;int (*probe) (struct obc_session *session);void (*remove) (struct obc_session *session); };
client/ftp.c +98 -41
236 lines not on this page · raw message
client/pbap.c +104 -40
194 lines not on this page · raw message
client/session.c +55 -21
149 lines not on this page · raw message
client/session.h +6 -2
@@ -21,12 +21,16 @@* */ +#include <stdint.h> #include <glib.h> #include <gdbus.h> -#include <gw-obex.h> +#include <gobex.h> struct obc_session ; +#define OBEX_IO_ERROR obex_io_error_quark() +GQuark obex_io_error_quark (void ); +typedef void (*session_callback_t ) (struct obc_session *session,GError *err,void *user_data);
@@ -52,7 +56,7 @@ const char *obc_session_get_agent(struct obc_session *session);const char *obc_session_get_path (struct obc_session *session);const char *obc_session_get_target (struct obc_session *session); -GwObex *obc_session_get_obex (struct obc_session *session); +GObex *obc_session_get_obex (struct obc_session *session);struct obc_transfer *obc_session_get_transfer (struct obc_session *session); void obc_session_add_transfer(struct obc_session *session,
client/sync.c +3 -0
@@ -38,6 +38,9 @@#include "driver.h" #include "sync.h" +#define OBEX_SYNC_UUID "IRMC-SYNC" +#define OBEX_SYNC_UUID_LEN 9 +#define SYNC_INTERFACE "org.openobex.Synchronization"#define ERROR_INF SYNC_INTERFACE ".Error"#define SYNC_UUID "00001104-0000-1000-8000-00805f9b34fb"
client/transfer.c +225 -165
544 lines not on this page · raw message
client/transfer.h +1 -4
@@ -21,8 +21,6 @@* */ -#include <gw-obex.h> -struct obc_transfer_params {guint8 *data;size_t size;
@@ -31,7 +29,7 @@ struct obc_transfer_params {struct obc_transfer ;typedef void (*transfer_callback_t ) (struct obc_transfer *transfer, -gint64 transferred,gint err, +gint64 transferred,GError *err,void *user_data); struct obc_transfer *obc_transfer_register(DBusConnection *conn,
@@ -47,7 +45,6 @@ int obc_transfer_get(struct obc_transfer *transfer, transfer_callback_t func, void *user_data);int obc_transfer_put (struct obc_transfer *transfer,transfer_callback_t func,void *user_data); -void obc_transfer_abort (struct obc_transfer *transfer);int obc_transfer_get_params (struct obc_transfer *transfer,struct obc_transfer_params *params);
Signature · 1 line
1.7.6
Re: [PATCH obexd 3/3 v2] client: port to gobex
Hi Luiz,
Quoted 5 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
This remove gwobex dependency of the client using gobex instead.
Based on initial work by Johan Hedberg <[email protected]>
Quoted 12 lines
--- Makefile.am | 2 +- client/driver.h | 2 +- client/ftp.c | 139 +++++++++++++------ client/pbap.c | 144 ++++++++++++++------ client/session.c | 76 ++++++++--- client/session.h | 8 +- client/sync.c | 3 + client/transfer.c | 390 ++++++++++++++++++++++++++++++---------------------- client/transfer.h | 5 +- 9 files changed, 494 insertions(+), 275 deletions(-)
Great job.
Take my "Ack", may it serve you well :-)
Cheers,
Signature · 1 line
Vinicius
Hi Luiz,
Quoted 3 lines · Luiz Augusto von Dentz
--- tools/test-client.c | 30 ++++++++++-------------------- 1 files changed, 10 insertions(+), 20 deletions(-)
All three patches applied. Thanks.
Johan