All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [RFC 2/3] bluetooth: Add UUID for DUN.
  2011-07-07  8:45 ` [RFC 2/3] bluetooth: Add UUID for DUN Mario Tokarz
@ 2011-07-07  8:00   ` Denis Kenzior
  0 siblings, 0 replies; 8+ messages in thread
From: Denis Kenzior @ 2011-07-07  8:00 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 778 bytes --]

Hi Mario,

On 07/07/2011 03:45 AM, Mario Tokarz wrote:
> From: Mario Tokarz <mario.tokarz@bmw-carit.de>
> 
> ---
>  plugins/bluetooth.h |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
> index 7f9f810..f572e5d 100644
> --- a/plugins/bluetooth.h
> +++ b/plugins/bluetooth.h
> @@ -27,9 +27,11 @@
>  
>  #define DBUS_TIMEOUT 15
>  
> +#define DUN_GW_UUID	"00001103-0000-1000-8000-00805f9b34fb"
>  #define HFP_AG_UUID	"0000111f-0000-1000-8000-00805f9b34fb"
>  #define HFP_HS_UUID	"0000111e-0000-1000-8000-00805f9b34fb"
>  
> +

Why this empty line?

>  struct bluetooth_profile {
>  	const char *name;
>  	int (*probe)(const char *device, const char *dev_addr,

Regards,
-Denis

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFC 1/3] dunmodem: Add baseline for DUN modem driver.
  2011-07-07  8:45 ` [RFC 1/3] dunmodem: Add baseline for DUN modem driver Mario Tokarz
@ 2011-07-07  8:16   ` Denis Kenzior
  0 siblings, 0 replies; 8+ messages in thread
From: Denis Kenzior @ 2011-07-07  8:16 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 17185 bytes --]

Hi Mario,

On 07/07/2011 03:45 AM, Mario Tokarz wrote:
> From: Mario Tokarz <mario.tokarz@bmw-carit.de>
> 
> ---
>  Makefile.am                             |    8 ++
>  drivers/dunmodem/dunmodem.c             |   55 ++++++++
>  drivers/dunmodem/dunmodem.h             |   39 ++++++
>  drivers/dunmodem/gprs-context.c         |  207 +++++++++++++++++++++++++++++++
>  drivers/dunmodem/gprs.c                 |  101 +++++++++++++++
>  drivers/dunmodem/network-registration.c |   96 ++++++++++++++
>  6 files changed, 506 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/dunmodem/dunmodem.c
>  create mode 100644 drivers/dunmodem/dunmodem.h
>  create mode 100644 drivers/dunmodem/gprs-context.c
>  create mode 100644 drivers/dunmodem/gprs.c
>  create mode 100644 drivers/dunmodem/network-registration.c

Ideally this needs to be separated into four patches:

- One for adding stub dunmodem.[ch] + Makefile.am changes for it
- One for adding network-registration.c + Makefile.am
- One for adding gprs.c + Makefile.am
- One for adding gprs-context.c + Makefile.am

> 
> diff --git a/Makefile.am b/Makefile.am
> index ef6196b..c77a793 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -206,6 +206,14 @@ builtin_sources += drivers/atmodem/atutil.h \
>  			drivers/calypsomodem/voicecall.c \
>  			drivers/calypsomodem/stk.c
>  
> +builtin_modules += dunmodem
> +builtin_sources += drivers/atmodem/atutil.h \
> +			drivers/dunmodem/dunmodem.h \
> +			drivers/dunmodem/dunmodem.c \
> +			drivers/dunmodem/gprs.c \
> +			drivers/dunmodem/gprs-context.c \
> +			drivers/dunmodem/network-registration.c
> +
>  builtin_modules += hfpmodem
>  builtin_sources += drivers/atmodem/atutil.h \
>  			drivers/hfpmodem/hfpmodem.h \
> diff --git a/drivers/dunmodem/dunmodem.c b/drivers/dunmodem/dunmodem.c
> new file mode 100644
> index 0000000..79c07ec
> --- /dev/null
> +++ b/drivers/dunmodem/dunmodem.c
> @@ -0,0 +1,55 @@
> +/*
> + *
> + *  oFono - Open Source Telephony
> + *
> + *  Copyright (C) 2011  BMW Car IT GmbH. All rights reserved.
> + *
> + *  This program is free software; you can redistribute it and/or modify
> + *  it under the terms of the GNU General Public License version 2 as
> + *  published by the Free Software Foundation.
> + *
> + *  This program is distributed in the hope that it will be useful,
> + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
> + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + *  GNU General Public License for more details.
> + *
> + *  You should have received a copy of the GNU General Public License
> + *  along with this program; if not, write to the Free Software
> + *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
> + *
> + */
> +
> +#ifdef HAVE_CONFIG_H
> +#include <config.h>
> +#endif
> +
> +#include <stdio.h>
> +#include <string.h>
> +#include <errno.h>
> +#include <glib.h>
> +#include <gatchat.h>
> +
> +#define OFONO_API_SUBJECT_TO_CHANGE
> +#include <ofono/plugin.h>
> +#include <ofono/types.h>
> +
> +#include "dunmodem.h"
> +
> +static int dunmodem_init(void)
> +{
> +	dun_dt_netreg_init();
> +	dun_dt_gprs_init();
> +	dun_dt_gprs_context_init();
> +
> +	return 0;
> +}
> +
> +static void dunmodem_exit(void)
> +{
> +	dun_dt_gprs_context_exit();
> +	dun_dt_gprs_exit();
> +	dun_dt_netreg_exit();
> +}
> +
> +OFONO_PLUGIN_DEFINE(dunmodem, "Dial-up Network Modem Driver", VERSION,
> +		OFONO_PLUGIN_PRIORITY_DEFAULT, dunmodem_init, dunmodem_exit)
> diff --git a/drivers/dunmodem/dunmodem.h b/drivers/dunmodem/dunmodem.h
> new file mode 100644
> index 0000000..8802780
> --- /dev/null
> +++ b/drivers/dunmodem/dunmodem.h
> @@ -0,0 +1,39 @@
> +/*
> + *
> + *  oFono - Open Source Telephony
> + *
> + *  Copyright (C) 2011  BMW Car IT GmbH. All rights reserved.
> + *
> + *  This program is free software; you can redistribute it and/or modify
> + *  it under the terms of the GNU General Public License version 2 as
> + *  published by the Free Software Foundation.
> + *
> + *  This program is distributed in the hope that it will be useful,
> + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
> + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + *  GNU General Public License for more details.
> + *
> + *  You should have received a copy of the GNU General Public License
> + *  along with this program; if not, write to the Free Software
> + *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
> + *
> + */
> +
> +#include <drivers/atmodem/atutil.h>
> +#include "gatppp.h"
> +
> +struct dun_data {
> +	char *dun_path;
> +	char *tty;
> +	struct ofono_gprs *gprs;
> +	struct ofono_gprs_context *gc;
> +};

Should this be here or inside the dun_client plugin?  I don't see a need
to declare this structure in this header.

> +
> +extern void dun_dt_netreg_init(void);
> +extern void dun_dt_netreg_exit(void);
> +
> +extern void dun_dt_gprs_init(void);
> +extern void dun_dt_gprs_exit(void);
> +
> +extern void dun_dt_gprs_context_init(void);
> +extern void dun_dt_gprs_context_exit(void);
> diff --git a/drivers/dunmodem/gprs-context.c b/drivers/dunmodem/gprs-context.c
> new file mode 100644
> index 0000000..c479153
> --- /dev/null
> +++ b/drivers/dunmodem/gprs-context.c
> @@ -0,0 +1,207 @@
> +/*
> + *
> + *  oFono - Open Source Telephony
> + *
> + *  Copyright (C) 2008-2010  Intel Corporation. All rights reserved.
> + *  Copyright (C) 2011 BMW Car IT GmbH. All rights reserved.
> + *
> + *  This program is free software; you can redistribute it and/or modify
> + *  it under the terms of the GNU General Public License version 2 as
> + *  published by the Free Software Foundation.
> + *
> + *  This program is distributed in the hope that it will be useful,
> + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
> + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + *  GNU General Public License for more details.
> + *
> + *  You should have received a copy of the GNU General Public License
> + *  along with this program; if not, write to the Free Software
> + *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
> + *
> + */
> +
> +#ifdef HAVE_CONFIG_H
> +#include <config.h>
> +#endif
> +
> +#define _GNU_SOURCE
> +#include <string.h>
> +#include <stdlib.h>
> +#include <fcntl.h>
> +#include <stdio.h>
> +#include <errno.h>
> +#include <sys/stat.h>
> +
> +#include <glib.h>
> +
> +#include <ofono/log.h>
> +#include <ofono/modem.h>
> +#include <ofono/gprs-context.h>
> +
> +#include "gatchat.h"
> +#include "gatresult.h"
> +#include "gatppp.h"
> +#include <gattty.h>
> +
> +#include "dunmodem.h"
> +
> +static void ppp_debug(const char *str, void *data)
> +{
> +	ofono_info("%s: %s", (const char *) data, str);
> +}
> +
> +struct gprs_context_data {
> +	char *tty;
> +	GIOChannel *channel;
> +	GAtPPP *ppp;
> +};

In general it is a good idea to put structure declarations before
function bodies.

> +
> +static void ppp_connect(const char *interface, const char *local,
> +			const char *remote,
> +			const char *dns1, const char *dns2,
> +			gpointer user_data)
> +{
> +	struct ofono_gprs_context *gc = user_data;
> +
> +	DBG("PPP connected %p, %s, %s, %s, %s, %s",
> +		gc, interface, local, remote, dns1, dns2);
> +
> +	/* Update configuration here - this is where work continues. */
> +}
> +
> +static void ppp_disconnect(GAtPPPDisconnectReason reason, gpointer user_data)
> +{
> +	struct ofono_gprs_context *gc = user_data;
> +	struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc);
> +
> +	DBG("ppp disconnecting");
> +
> +	g_at_ppp_unref(gcd->ppp);
> +	gcd->ppp = NULL;
> +}
> +
> +static gboolean setup_ppp(struct ofono_gprs_context *gc)
> +{
> +	struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc);
> +	GAtIO *io;
> +
> +	DBG("");
> +
> +	gcd->ppp = g_at_ppp_new();
> +
> +	if (gcd->ppp == NULL)
> +		return FALSE;
> +
> +	/* Needs to be read from ENV var in final version */
> +	g_at_ppp_set_debug(gcd->ppp, ppp_debug, "PPP");
> +
> +	g_at_ppp_set_connect_function(gcd->ppp, ppp_connect, gc);
> +	g_at_ppp_set_disconnect_function(gcd->ppp, ppp_disconnect, gc);
> +
> +	io = g_at_io_new(gcd->channel);
> +	if (io == NULL)
> +		return FALSE;
> +
> +	DBG("Connection channel %p with io %p", gcd->channel, io);
> +	g_at_ppp_open(gcd->ppp, io);
> +
> +	DBG("PPP is open");
> +
> +	return TRUE;
> +}
> +
> +static void dun_dt_gprs_activate_primary(struct ofono_gprs_context *gc,
> +				const struct ofono_gprs_primary_context *ctx,
> +				ofono_gprs_context_cb_t cb, void *data)
> +{
> +	struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc);
> +	GIOChannel *channel;
> +	int fd;
> +
> +	DBG("tty for connection %s", gcd->tty);
> +
> +	fd = open(gcd->tty, O_RDWR);
> +	if (fd < 0)
> +		goto error;

So I see two problems here:

- Why are you opening a TTY here?  In general this is a bad idea.  Such
details should be abstracted away in the modem driver.  This is the
reason why e.g. atmodem atom drivers receive GAtChat objects and not raw
tty paths.

- You can't go into PPP mode right away, you actually need to issue an
ATD or some other command to enter online mode first.  In atmodem
gprs_context driver this is accomplished by issuing a +CGDATA command.
In classical BT DUN profile this would be done using a simple ATD.

> +
> +	channel = g_io_channel_unix_new(fd);
> +	DBG("Opened %s as channel %p with fd %d", gcd->tty, channel, fd);
> +
> +	if (channel == NULL)
> +		goto error;
> +
> +	gcd->channel = channel;
> +
> +	setup_ppp(gc);
> +
> +	return;
> +
> +error:
> +	CALLBACK_WITH_FAILURE(cb, data);
> +}
> +
> +static void dun_dt_gprs_deactivate_primary(struct ofono_gprs_context *gc,
> +						unsigned int cid,
> +						ofono_gprs_context_cb_t cb,
> +						void *data)
> +{
> +	struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc);
> +
> +	DBG("Disconnect PPP");
> +
> +	if (gcd->ppp == NULL)
> +		return;
> +
> +	g_at_ppp_shutdown(gcd->ppp);
> +}
> +
> +static int dun_dt_gprs_context_probe(struct ofono_gprs_context *gc,
> +					unsigned int vendor, void *data)
> +{
> +	struct dun_data *dd = data;
> +	struct gprs_context_data *gcd;

As discussed previously, you probably want to pass the GAtChat object
here as the userdata.

> +
> +	DBG("");
> +
> +	gcd = g_try_new0(struct gprs_context_data, 1);
> +	if (gcd == NULL)
> +		return -ENOMEM;
> +
> +	ofono_gprs_context_set_data(gc, gcd);
> +
> +	gcd->tty = g_strdup(dd->tty);
> +
> +	return 0;
> +}
> +
> +static void dun_dt_gprs_context_remove(struct ofono_gprs_context *gc)
> +{
> +	struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc);
> +
> +	DBG("%p", gc);
> +
> +	if (gcd->ppp)
> +		g_at_ppp_unref(gcd->ppp);
> +
> +	ofono_gprs_context_set_data(gc, NULL);
> +
> +	g_free(gcd);
> +}
> +
> +static struct ofono_gprs_context_driver driver = {
> +	.name			= "dunmodem",
> +	.probe			= dun_dt_gprs_context_probe,
> +	.remove		= dun_dt_gprs_context_remove,
> +	.activate_primary	= dun_dt_gprs_activate_primary,
> +	.deactivate_primary	= dun_dt_gprs_deactivate_primary,
> +};
> +
> +void dun_dt_gprs_context_init(void)
> +{
> +	ofono_gprs_context_driver_register(&driver);
> +}
> +
> +void dun_dt_gprs_context_exit(void)
> +{
> +	ofono_gprs_context_driver_unregister(&driver);
> +}
> diff --git a/drivers/dunmodem/gprs.c b/drivers/dunmodem/gprs.c
> new file mode 100644
> index 0000000..3fbde1a
> --- /dev/null
> +++ b/drivers/dunmodem/gprs.c
> @@ -0,0 +1,101 @@
> +/*
> + *
> + *  oFono - Open Source Telephony
> + *
> + *  Copyright (C) 2011  BMW Car IT GmbH. All rights reserved.
> + *
> + *  This program is free software; you can redistribute it and/or modify
> + *  it under the terms of the GNU General Public License version 2 as
> + *  published by the Free Software Foundation.
> + *
> + *  This program is distributed in the hope that it will be useful,
> + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
> + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + *  GNU General Public License for more details.
> + *
> + *  You should have received a copy of the GNU General Public License
> + *  along with this program; if not, write to the Free Software
> + *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
> + *
> + */
> +
> +#ifdef HAVE_CONFIG_H
> +#include <config.h>
> +#endif
> +
> +#define _GNU_SOURCE
> +#include <string.h>
> +#include <stdlib.h>
> +#include <stdio.h>
> +#include <errno.h>
> +
> +#include <glib.h>
> +
> +#include <ofono/log.h>
> +#include <ofono/modem.h>
> +#include <ofono/gprs.h>
> +
> +#include "gatchat.h"
> +#include "gatppp.h"
> +#include "gatresult.h"
> +
> +#include "dunmodem.h"
> +
> +static void dun_dt_gprs_set_attached(struct ofono_gprs *gprs, int attached,
> +						ofono_gprs_cb_t cb, void *data)
> +{
> +	DBG("");
> +
> +	CALLBACK_WITH_SUCCESS(cb, data);
> +}
> +
> +static gboolean dun_dt_gprs_finish_registration(gpointer user_data)
> +{
> +	struct ofono_gprs *gprs = user_data;
> +
> +	ofono_gprs_register(gprs);
> +
> +	return FALSE;
> +}
> +
> +static int dun_dt_gprs_probe(struct ofono_gprs *gprs,
> +					unsigned int vendor, void *data)
> +{
> +	DBG("");
> +
> +	g_timeout_add(500, dun_dt_gprs_finish_registration, gprs);
> +
> +	return 0;
> +}
> +
> +static void dun_dt_gprs_remove(struct ofono_gprs *gprs)
> +{
> +	DBG("");
> +}
> +
> +static void dun_dt_gprs_attached_status(struct ofono_gprs *gprs,
> +						ofono_gprs_status_cb_t cb,
> +						void *data)
> +{
> +	DBG("");
> +
> +	CALLBACK_WITH_SUCCESS(cb, 1, data);
> +}
> +
> +static struct ofono_gprs_driver driver = {
> +	.name			= "dunmodem",
> +	.probe			= dun_dt_gprs_probe,
> +	.remove		= dun_dt_gprs_remove,
> +	.set_attached		= dun_dt_gprs_set_attached,
> +	.attached_status	= dun_dt_gprs_attached_status,
> +};
> +
> +void dun_dt_gprs_init(void)
> +{
> +	ofono_gprs_driver_register(&driver);
> +}
> +
> +void dun_dt_gprs_exit(void)
> +{
> +	ofono_gprs_driver_unregister(&driver);
> +}
> diff --git a/drivers/dunmodem/network-registration.c b/drivers/dunmodem/network-registration.c
> new file mode 100644
> index 0000000..a9acec0
> --- /dev/null
> +++ b/drivers/dunmodem/network-registration.c
> @@ -0,0 +1,96 @@
> +/*
> + *
> + *  oFono - Open Source Telephony
> + *
> + *  Copyright (C) 2011  BMW Car IT GmbH. All rights reserved.
> + *
> + *  This program is free software; you can redistribute it and/or modify
> + *  it under the terms of the GNU General Public License version 2 as
> + *  published by the Free Software Foundation.
> + *
> + *  This program is distributed in the hope that it will be useful,
> + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
> + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + *  GNU General Public License for more details.
> + *
> + *  You should have received a copy of the GNU General Public License
> + *  along with this program; if not, write to the Free Software
> + *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
> + *
> + */
> +
> +#ifdef HAVE_CONFIG_H
> +#include <config.h>
> +#endif
> +
> +#define _GNU_SOURCE
> +#include <string.h>
> +#include <stdlib.h>
> +#include <stdio.h>
> +
> +#include <glib.h>
> +
> +#include <ofono/log.h>
> +#include <ofono/modem.h>
> +#include <ofono/netreg.h>
> +
> +#include "gatchat.h"
> +#include "gatppp.h"
> +#include "gatresult.h"
> +#include "common.h"
> +
> +#include "dunmodem.h"
> +
> +static gboolean dun_netreg_register(gpointer user_data)
> +{
> +	struct ofono_netreg *netreg = user_data;
> +
> +	DBG("");
> +
> +	ofono_netreg_register(netreg);
> +
> +	return FALSE;
> +}
> +
> +static int dun_netreg_probe(struct ofono_netreg *netreg, unsigned int vendor,
> +				void *user_data)
> +{
> +	struct dun_data *data = user_data;
> +
> +	DBG("%p", data);
> +
> +	g_idle_add(dun_netreg_register, netreg);
> +
> +	return 0;
> +}
> +
> +static void dun_netreg_remove(struct ofono_netreg *netreg)
> +{
> +	DBG("");
> +}
> +
> +static void dun_registration_status(struct ofono_netreg *netreg,
> +					ofono_netreg_status_cb_t cb,
> +					void *data)
> +{
> +	DBG("");
> +
> +	CALLBACK_WITH_SUCCESS(cb, 1, -1, -1, -1, netreg);
> +}
> +
> +static struct ofono_netreg_driver driver = {
> +	.name				= "dunmodem",
> +	.probe				= dun_netreg_probe,
> +	.remove				= dun_netreg_remove,
> +	.registration_status		= dun_registration_status
> +};
> +
> +void dun_dt_netreg_init(void)
> +{
> +	ofono_netreg_driver_register(&driver);
> +}
> +
> +void dun_dt_netreg_exit(void)
> +{
> +	ofono_netreg_driver_unregister(&driver);
> +}

Regards,
-Denis

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [RFC 0/3] Adding DUN support.
@ 2011-07-07  8:45 Mario Tokarz
  2011-07-07  8:45 ` [RFC 1/3] dunmodem: Add baseline for DUN modem driver Mario Tokarz
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Mario Tokarz @ 2011-07-07  8:45 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 3397 bytes --]

From: Mario Tokarz <mario.tokarz@bmw-carit.de>

Hi all,

find attached a first rudimentary implementation of DUN support for oFono.

The approach of bringing in DUN via an additional modem driver was
discussed before shortly on IRC. As I am new to open source in general
and oFono in this special case, I just wanted to make sure I am on the
right track here.

Basically, I 'faked' the network registration and try to bring up PPP
within the gprs-context.

ConnMan can find the context and bring it up (gprs-context.c).
Starting PPP the way I did it in the patch does not seem to work
though. It results in:

ofonod[25318]: PPP: lcp: pppcp_generate_event: current state 0:INITIAL
ofonod[25318]: PPP: event: 0 (Up), action: 2, new_state: 2 (CLOSED)
ofonod[25318]: PPP: lcp: pppcp_generate_event: current state 2:CLOSED
ofonod[25318]: PPP: event: 2 (Open), action: 1026, new_state: 6 (REQSENT)
ofonod[25318]: PPP: lcp: pppcp_initialize_restart_count: current state 2:CLOSED
ofonod[25318]: PPP: lcp: pppcp_send_configure_request: current state 2:CLOSED
ofonod[25318]: PPP: gatchat/gatppp.c:ppp_enter_phase() 1
ofonod[25318]: drivers/dunmodem/gprs-context.c:setup_ppp() PPP is open
ofonod[25318]: PPP: lcp: pppcp_timeout: current state 6:REQSENT
ofonod[25318]: PPP: lcp: pppcp_generate_event: current state 6:REQSENT
ofonod[25318]: PPP: event: 4 (TO+), action: 1006, new_state: 6 (REQSENT)
ofonod[25318]: PPP: lcp: pppcp_send_configure_request: current state 6:REQSENT
ofonod[25318]: PPP: lcp: pppcp_timeout: current state 6:REQSENT
ofonod[25318]: PPP: lcp: pppcp_generate_event: current state 6:REQSENT
ofonod[25318]: PPP: event: 4 (TO+), action: 1006, new_state: 6 (REQSENT)
ofonod[25318]: PPP: lcp: pppcp_send_configure_request: current state 6:REQSENT


I'm surely missing something obvious here, so I would be glad to get
some hints whether I am heading into the right direction.

One more note: As of now, ConnMan specifically queries the device it
finds via oFono as to whether it has a SIM active (the information is
only checked but not used in an other contex). I did not implement the
SIM interface for DUN, it does not seem to be needed. Still as a
result, a minor patch to ConnMan is needed in order to use the patch
(upto the point of trying to ocnnect to via PPP on RFCOMM).

I am going to push that topic also to the ConnMan list.

Thx,
Mario

Mario Tokarz (3):
  dunmodem: Add baseline for DUN modem driver.
  bluetooth: Add UUID for DUN.
  dun_dt: Add baseline for dun_dt plug-in.

 Makefile.am                             |   11 +
 drivers/dunmodem/dunmodem.c             |   55 +++++
 drivers/dunmodem/dunmodem.h             |   39 ++++
 drivers/dunmodem/gprs-context.c         |  207 +++++++++++++++++++
 drivers/dunmodem/gprs.c                 |  101 +++++++++
 drivers/dunmodem/network-registration.c |   96 +++++++++
 plugins/bluetooth.h                     |    2 +
 plugins/dun_dt.c                        |  337 +++++++++++++++++++++++++++++++
 8 files changed, 848 insertions(+), 0 deletions(-)
 create mode 100644 drivers/dunmodem/dunmodem.c
 create mode 100644 drivers/dunmodem/dunmodem.h
 create mode 100644 drivers/dunmodem/gprs-context.c
 create mode 100644 drivers/dunmodem/gprs.c
 create mode 100644 drivers/dunmodem/network-registration.c
 create mode 100644 plugins/dun_dt.c

-- 
1.7.4.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [RFC 1/3] dunmodem: Add baseline for DUN modem driver.
  2011-07-07  8:45 [RFC 0/3] Adding DUN support Mario Tokarz
@ 2011-07-07  8:45 ` Mario Tokarz
  2011-07-07  8:16   ` Denis Kenzior
  2011-07-07  8:45 ` [RFC 2/3] bluetooth: Add UUID for DUN Mario Tokarz
  2011-07-07  8:45 ` [RFC 3/3] dun_dt: Add baseline for dun_dt plug-in Mario Tokarz
  2 siblings, 1 reply; 8+ messages in thread
From: Mario Tokarz @ 2011-07-07  8:45 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 14877 bytes --]

From: Mario Tokarz <mario.tokarz@bmw-carit.de>

---
 Makefile.am                             |    8 ++
 drivers/dunmodem/dunmodem.c             |   55 ++++++++
 drivers/dunmodem/dunmodem.h             |   39 ++++++
 drivers/dunmodem/gprs-context.c         |  207 +++++++++++++++++++++++++++++++
 drivers/dunmodem/gprs.c                 |  101 +++++++++++++++
 drivers/dunmodem/network-registration.c |   96 ++++++++++++++
 6 files changed, 506 insertions(+), 0 deletions(-)
 create mode 100644 drivers/dunmodem/dunmodem.c
 create mode 100644 drivers/dunmodem/dunmodem.h
 create mode 100644 drivers/dunmodem/gprs-context.c
 create mode 100644 drivers/dunmodem/gprs.c
 create mode 100644 drivers/dunmodem/network-registration.c

diff --git a/Makefile.am b/Makefile.am
index ef6196b..c77a793 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -206,6 +206,14 @@ builtin_sources += drivers/atmodem/atutil.h \
 			drivers/calypsomodem/voicecall.c \
 			drivers/calypsomodem/stk.c
 
+builtin_modules += dunmodem
+builtin_sources += drivers/atmodem/atutil.h \
+			drivers/dunmodem/dunmodem.h \
+			drivers/dunmodem/dunmodem.c \
+			drivers/dunmodem/gprs.c \
+			drivers/dunmodem/gprs-context.c \
+			drivers/dunmodem/network-registration.c
+
 builtin_modules += hfpmodem
 builtin_sources += drivers/atmodem/atutil.h \
 			drivers/hfpmodem/hfpmodem.h \
diff --git a/drivers/dunmodem/dunmodem.c b/drivers/dunmodem/dunmodem.c
new file mode 100644
index 0000000..79c07ec
--- /dev/null
+++ b/drivers/dunmodem/dunmodem.c
@@ -0,0 +1,55 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2011  BMW Car IT GmbH. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <glib.h>
+#include <gatchat.h>
+
+#define OFONO_API_SUBJECT_TO_CHANGE
+#include <ofono/plugin.h>
+#include <ofono/types.h>
+
+#include "dunmodem.h"
+
+static int dunmodem_init(void)
+{
+	dun_dt_netreg_init();
+	dun_dt_gprs_init();
+	dun_dt_gprs_context_init();
+
+	return 0;
+}
+
+static void dunmodem_exit(void)
+{
+	dun_dt_gprs_context_exit();
+	dun_dt_gprs_exit();
+	dun_dt_netreg_exit();
+}
+
+OFONO_PLUGIN_DEFINE(dunmodem, "Dial-up Network Modem Driver", VERSION,
+		OFONO_PLUGIN_PRIORITY_DEFAULT, dunmodem_init, dunmodem_exit)
diff --git a/drivers/dunmodem/dunmodem.h b/drivers/dunmodem/dunmodem.h
new file mode 100644
index 0000000..8802780
--- /dev/null
+++ b/drivers/dunmodem/dunmodem.h
@@ -0,0 +1,39 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2011  BMW Car IT GmbH. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#include <drivers/atmodem/atutil.h>
+#include "gatppp.h"
+
+struct dun_data {
+	char *dun_path;
+	char *tty;
+	struct ofono_gprs *gprs;
+	struct ofono_gprs_context *gc;
+};
+
+extern void dun_dt_netreg_init(void);
+extern void dun_dt_netreg_exit(void);
+
+extern void dun_dt_gprs_init(void);
+extern void dun_dt_gprs_exit(void);
+
+extern void dun_dt_gprs_context_init(void);
+extern void dun_dt_gprs_context_exit(void);
diff --git a/drivers/dunmodem/gprs-context.c b/drivers/dunmodem/gprs-context.c
new file mode 100644
index 0000000..c479153
--- /dev/null
+++ b/drivers/dunmodem/gprs-context.c
@@ -0,0 +1,207 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2008-2010  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2011 BMW Car IT GmbH. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#define _GNU_SOURCE
+#include <string.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <errno.h>
+#include <sys/stat.h>
+
+#include <glib.h>
+
+#include <ofono/log.h>
+#include <ofono/modem.h>
+#include <ofono/gprs-context.h>
+
+#include "gatchat.h"
+#include "gatresult.h"
+#include "gatppp.h"
+#include <gattty.h>
+
+#include "dunmodem.h"
+
+static void ppp_debug(const char *str, void *data)
+{
+	ofono_info("%s: %s", (const char *) data, str);
+}
+
+struct gprs_context_data {
+	char *tty;
+	GIOChannel *channel;
+	GAtPPP *ppp;
+};
+
+static void ppp_connect(const char *interface, const char *local,
+			const char *remote,
+			const char *dns1, const char *dns2,
+			gpointer user_data)
+{
+	struct ofono_gprs_context *gc = user_data;
+
+	DBG("PPP connected %p, %s, %s, %s, %s, %s",
+		gc, interface, local, remote, dns1, dns2);
+
+	/* Update configuration here - this is where work continues. */
+}
+
+static void ppp_disconnect(GAtPPPDisconnectReason reason, gpointer user_data)
+{
+	struct ofono_gprs_context *gc = user_data;
+	struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc);
+
+	DBG("ppp disconnecting");
+
+	g_at_ppp_unref(gcd->ppp);
+	gcd->ppp = NULL;
+}
+
+static gboolean setup_ppp(struct ofono_gprs_context *gc)
+{
+	struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc);
+	GAtIO *io;
+
+	DBG("");
+
+	gcd->ppp = g_at_ppp_new();
+
+	if (gcd->ppp == NULL)
+		return FALSE;
+
+	/* Needs to be read from ENV var in final version */
+	g_at_ppp_set_debug(gcd->ppp, ppp_debug, "PPP");
+
+	g_at_ppp_set_connect_function(gcd->ppp, ppp_connect, gc);
+	g_at_ppp_set_disconnect_function(gcd->ppp, ppp_disconnect, gc);
+
+	io = g_at_io_new(gcd->channel);
+	if (io == NULL)
+		return FALSE;
+
+	DBG("Connection channel %p with io %p", gcd->channel, io);
+	g_at_ppp_open(gcd->ppp, io);
+
+	DBG("PPP is open");
+
+	return TRUE;
+}
+
+static void dun_dt_gprs_activate_primary(struct ofono_gprs_context *gc,
+				const struct ofono_gprs_primary_context *ctx,
+				ofono_gprs_context_cb_t cb, void *data)
+{
+	struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc);
+	GIOChannel *channel;
+	int fd;
+
+	DBG("tty for connection %s", gcd->tty);
+
+	fd = open(gcd->tty, O_RDWR);
+	if (fd < 0)
+		goto error;
+
+	channel = g_io_channel_unix_new(fd);
+	DBG("Opened %s as channel %p with fd %d", gcd->tty, channel, fd);
+
+	if (channel == NULL)
+		goto error;
+
+	gcd->channel = channel;
+
+	setup_ppp(gc);
+
+	return;
+
+error:
+	CALLBACK_WITH_FAILURE(cb, data);
+}
+
+static void dun_dt_gprs_deactivate_primary(struct ofono_gprs_context *gc,
+						unsigned int cid,
+						ofono_gprs_context_cb_t cb,
+						void *data)
+{
+	struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc);
+
+	DBG("Disconnect PPP");
+
+	if (gcd->ppp == NULL)
+		return;
+
+	g_at_ppp_shutdown(gcd->ppp);
+}
+
+static int dun_dt_gprs_context_probe(struct ofono_gprs_context *gc,
+					unsigned int vendor, void *data)
+{
+	struct dun_data *dd = data;
+	struct gprs_context_data *gcd;
+
+	DBG("");
+
+	gcd = g_try_new0(struct gprs_context_data, 1);
+	if (gcd == NULL)
+		return -ENOMEM;
+
+	ofono_gprs_context_set_data(gc, gcd);
+
+	gcd->tty = g_strdup(dd->tty);
+
+	return 0;
+}
+
+static void dun_dt_gprs_context_remove(struct ofono_gprs_context *gc)
+{
+	struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc);
+
+	DBG("%p", gc);
+
+	if (gcd->ppp)
+		g_at_ppp_unref(gcd->ppp);
+
+	ofono_gprs_context_set_data(gc, NULL);
+
+	g_free(gcd);
+}
+
+static struct ofono_gprs_context_driver driver = {
+	.name			= "dunmodem",
+	.probe			= dun_dt_gprs_context_probe,
+	.remove		= dun_dt_gprs_context_remove,
+	.activate_primary	= dun_dt_gprs_activate_primary,
+	.deactivate_primary	= dun_dt_gprs_deactivate_primary,
+};
+
+void dun_dt_gprs_context_init(void)
+{
+	ofono_gprs_context_driver_register(&driver);
+}
+
+void dun_dt_gprs_context_exit(void)
+{
+	ofono_gprs_context_driver_unregister(&driver);
+}
diff --git a/drivers/dunmodem/gprs.c b/drivers/dunmodem/gprs.c
new file mode 100644
index 0000000..3fbde1a
--- /dev/null
+++ b/drivers/dunmodem/gprs.c
@@ -0,0 +1,101 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2011  BMW Car IT GmbH. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#define _GNU_SOURCE
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+
+#include <glib.h>
+
+#include <ofono/log.h>
+#include <ofono/modem.h>
+#include <ofono/gprs.h>
+
+#include "gatchat.h"
+#include "gatppp.h"
+#include "gatresult.h"
+
+#include "dunmodem.h"
+
+static void dun_dt_gprs_set_attached(struct ofono_gprs *gprs, int attached,
+						ofono_gprs_cb_t cb, void *data)
+{
+	DBG("");
+
+	CALLBACK_WITH_SUCCESS(cb, data);
+}
+
+static gboolean dun_dt_gprs_finish_registration(gpointer user_data)
+{
+	struct ofono_gprs *gprs = user_data;
+
+	ofono_gprs_register(gprs);
+
+	return FALSE;
+}
+
+static int dun_dt_gprs_probe(struct ofono_gprs *gprs,
+					unsigned int vendor, void *data)
+{
+	DBG("");
+
+	g_timeout_add(500, dun_dt_gprs_finish_registration, gprs);
+
+	return 0;
+}
+
+static void dun_dt_gprs_remove(struct ofono_gprs *gprs)
+{
+	DBG("");
+}
+
+static void dun_dt_gprs_attached_status(struct ofono_gprs *gprs,
+						ofono_gprs_status_cb_t cb,
+						void *data)
+{
+	DBG("");
+
+	CALLBACK_WITH_SUCCESS(cb, 1, data);
+}
+
+static struct ofono_gprs_driver driver = {
+	.name			= "dunmodem",
+	.probe			= dun_dt_gprs_probe,
+	.remove		= dun_dt_gprs_remove,
+	.set_attached		= dun_dt_gprs_set_attached,
+	.attached_status	= dun_dt_gprs_attached_status,
+};
+
+void dun_dt_gprs_init(void)
+{
+	ofono_gprs_driver_register(&driver);
+}
+
+void dun_dt_gprs_exit(void)
+{
+	ofono_gprs_driver_unregister(&driver);
+}
diff --git a/drivers/dunmodem/network-registration.c b/drivers/dunmodem/network-registration.c
new file mode 100644
index 0000000..a9acec0
--- /dev/null
+++ b/drivers/dunmodem/network-registration.c
@@ -0,0 +1,96 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2011  BMW Car IT GmbH. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#define _GNU_SOURCE
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <glib.h>
+
+#include <ofono/log.h>
+#include <ofono/modem.h>
+#include <ofono/netreg.h>
+
+#include "gatchat.h"
+#include "gatppp.h"
+#include "gatresult.h"
+#include "common.h"
+
+#include "dunmodem.h"
+
+static gboolean dun_netreg_register(gpointer user_data)
+{
+	struct ofono_netreg *netreg = user_data;
+
+	DBG("");
+
+	ofono_netreg_register(netreg);
+
+	return FALSE;
+}
+
+static int dun_netreg_probe(struct ofono_netreg *netreg, unsigned int vendor,
+				void *user_data)
+{
+	struct dun_data *data = user_data;
+
+	DBG("%p", data);
+
+	g_idle_add(dun_netreg_register, netreg);
+
+	return 0;
+}
+
+static void dun_netreg_remove(struct ofono_netreg *netreg)
+{
+	DBG("");
+}
+
+static void dun_registration_status(struct ofono_netreg *netreg,
+					ofono_netreg_status_cb_t cb,
+					void *data)
+{
+	DBG("");
+
+	CALLBACK_WITH_SUCCESS(cb, 1, -1, -1, -1, netreg);
+}
+
+static struct ofono_netreg_driver driver = {
+	.name				= "dunmodem",
+	.probe				= dun_netreg_probe,
+	.remove				= dun_netreg_remove,
+	.registration_status		= dun_registration_status
+};
+
+void dun_dt_netreg_init(void)
+{
+	ofono_netreg_driver_register(&driver);
+}
+
+void dun_dt_netreg_exit(void)
+{
+	ofono_netreg_driver_unregister(&driver);
+}
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [RFC 2/3] bluetooth: Add UUID for DUN.
  2011-07-07  8:45 [RFC 0/3] Adding DUN support Mario Tokarz
  2011-07-07  8:45 ` [RFC 1/3] dunmodem: Add baseline for DUN modem driver Mario Tokarz
@ 2011-07-07  8:45 ` Mario Tokarz
  2011-07-07  8:00   ` Denis Kenzior
  2011-07-07  8:45 ` [RFC 3/3] dun_dt: Add baseline for dun_dt plug-in Mario Tokarz
  2 siblings, 1 reply; 8+ messages in thread
From: Mario Tokarz @ 2011-07-07  8:45 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 646 bytes --]

From: Mario Tokarz <mario.tokarz@bmw-carit.de>

---
 plugins/bluetooth.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
index 7f9f810..f572e5d 100644
--- a/plugins/bluetooth.h
+++ b/plugins/bluetooth.h
@@ -27,9 +27,11 @@
 
 #define DBUS_TIMEOUT 15
 
+#define DUN_GW_UUID	"00001103-0000-1000-8000-00805f9b34fb"
 #define HFP_AG_UUID	"0000111f-0000-1000-8000-00805f9b34fb"
 #define HFP_HS_UUID	"0000111e-0000-1000-8000-00805f9b34fb"
 
+
 struct bluetooth_profile {
 	const char *name;
 	int (*probe)(const char *device, const char *dev_addr,
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [RFC 3/3] dun_dt: Add baseline for dun_dt plug-in.
  2011-07-07  8:45 [RFC 0/3] Adding DUN support Mario Tokarz
  2011-07-07  8:45 ` [RFC 1/3] dunmodem: Add baseline for DUN modem driver Mario Tokarz
  2011-07-07  8:45 ` [RFC 2/3] bluetooth: Add UUID for DUN Mario Tokarz
@ 2011-07-07  8:45 ` Mario Tokarz
  2011-07-07 16:59   ` Gustavo Padovan
  2 siblings, 1 reply; 8+ messages in thread
From: Mario Tokarz @ 2011-07-07  8:45 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 9025 bytes --]

From: Mario Tokarz <mario.tokarz@bmw-carit.de>

---
 Makefile.am      |    3 +
 plugins/dun_dt.c |  337 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 340 insertions(+), 0 deletions(-)
 create mode 100644 plugins/dun_dt.c

diff --git a/Makefile.am b/Makefile.am
index c77a793..97698df 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -351,6 +351,9 @@ builtin_sources += plugins/hfp_ag.c plugins/bluetooth.h
 builtin_modules += dun_gw
 builtin_sources += plugins/dun_gw.c plugins/bluetooth.h
 
+builtin_modules += dun_dt
+builtin_sources += plugins/dun_dt.c plugins/bluetooth.h
+
 builtin_sources += $(btio_sources)
 builtin_cflags += @BLUEZ_CFLAGS@
 builtin_libadd += @BLUEZ_LIBS@
diff --git a/plugins/dun_dt.c b/plugins/dun_dt.c
new file mode 100644
index 0000000..98e2214
--- /dev/null
+++ b/plugins/dun_dt.c
@@ -0,0 +1,337 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2008-2010  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2010  ProFUSION embedded systems
+ *  Copyright (C) 2011  BMW Car IT GmbH. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <glib.h>
+#include <gatchat.h>
+#include <gattty.h>
+#include <gdbus.h>
+#include <ofono.h>
+
+#define OFONO_API_SUBJECT_TO_CHANGE
+#include <ofono/plugin.h>
+#include <ofono/log.h>
+#include <ofono/modem.h>
+#include <ofono/netreg.h>
+#include <ofono/voicecall.h>
+#include <ofono/gprs.h>
+#include <ofono/gprs-context.h>
+#include <ofono/call-volume.h>
+
+#include <drivers/dunmodem/dunmodem.h>
+
+#include <ofono/dbus.h>
+
+#include "bluetooth.h"
+
+#define BLUEZ_SERIAL_INTERFACE BLUEZ_SERVICE ".Serial"
+
+#ifndef DBUS_TYPE_UNIX_FD
+#define DBUS_TYPE_UNIX_FD -1
+#endif
+
+static DBusConnection *connection;
+static GHashTable *modem_hash;
+
+static int dun_dt_bt_probe(const char *device, const char *dev_addr,
+				const char *adapter_addr, const char *alias)
+{
+	struct ofono_modem *modem;
+	struct dun_data *data;
+	char buf[256];
+	char alias_buf[256];
+
+	DBG("");
+
+	/* We already have this device in our hash, ignore */
+	if (g_hash_table_lookup(modem_hash, device) != NULL)
+		return -EALREADY;
+
+	ofono_info("Using device: %s, devaddr: %s, adapter: %s",
+			device, dev_addr, adapter_addr);
+
+	strcpy(buf, "dun/");
+	bluetooth_create_path(dev_addr, adapter_addr, buf + 4, sizeof(buf) - 4);
+
+	modem = ofono_modem_create(buf, "dun_dt");
+	if (modem == NULL) {
+		DBG("Failed to create modem");
+		return -ENOMEM;
+	}
+
+	DBG("Modem %p", modem);
+
+	data = g_try_new0(struct dun_data, 1);
+	if (data == NULL)
+		goto free;
+
+	data->dun_path = g_strdup(device);
+	if (data->dun_path == NULL)
+		goto free;
+
+	ofono_modem_set_data(modem, data);
+
+	strcpy(alias_buf, "DUN ");
+	strcat(alias_buf, alias);
+	ofono_modem_set_name(modem, alias_buf);
+	ofono_modem_register(modem);
+
+	g_hash_table_insert(modem_hash, g_strdup(device), modem);
+	return 0;
+
+free:
+	g_free(data->dun_path);
+	data->dun_path = NULL;
+	g_free(data);
+	ofono_modem_remove(modem);
+
+	return -ENOMEM;
+
+}
+
+static gboolean dun_dt_remove_modem(gpointer key, gpointer value,
+				      gpointer user_data)
+{
+	struct ofono_modem *modem = value;
+	const char *device = key;
+	const char *prefix = user_data;
+
+	DBG("");
+
+	if (prefix && g_str_has_prefix(device, prefix) == FALSE)
+		return FALSE;
+
+	ofono_modem_remove(modem);
+
+	return TRUE;
+}
+
+static void dun_dt_bt_remove(const char *prefix)
+{
+	DBG("%s", prefix);
+
+	if (modem_hash == NULL)
+		return;
+
+	g_hash_table_foreach_remove(modem_hash, dun_dt_remove_modem,
+							(gpointer) prefix);
+}
+
+static void dun_dt_bt_set_alias(const char *device, const char *alias)
+{
+	struct ofono_modem *modem;
+
+	DBG("");
+
+	if (device == NULL || alias == NULL)
+		return;
+
+	modem =	g_hash_table_lookup(modem_hash, device);
+	if (modem == NULL)
+		return;
+
+	ofono_modem_set_name(modem, alias);
+}
+
+
+static void dun_dt_pre_sim(struct ofono_modem *modem)
+{
+	DBG("%p", modem);
+}
+
+static int dun_dt_probe(struct ofono_modem *modem)
+{
+	DBG("Probe %p", modem);
+
+	return 0;
+}
+
+
+static void dun_dt_post_sim(struct ofono_modem *modem)
+{
+	struct dun_data *dd = ofono_modem_get_data(modem);
+
+	DBG("%p, path %s, tty %s", modem, dd->dun_path, dd->tty);
+
+	ofono_netreg_create(modem, 0, "dunmodem", dd);
+
+	dd->gprs = ofono_gprs_create(modem, 0, "dunmodem", dd);
+	ofono_gprs_set_cid_range(dd->gprs, 1, 16);
+
+	dd->gc = ofono_gprs_context_create(modem, 0, "dunmodem", dd);
+
+	ofono_gprs_add_context(dd->gprs, dd->gc);
+}
+
+static void dun_dt_post_online(struct ofono_modem *modem)
+{
+	DBG("");
+}
+
+
+static void dun_dt_connect_reply(DBusPendingCall *call, gpointer user_data)
+{
+	struct ofono_modem *modem = user_data;
+	struct dun_data *data = ofono_modem_get_data(modem);
+	DBusMessage *reply = dbus_pending_call_steal_reply(call);
+	DBusError derr;
+	char *tty;
+
+
+	DBG("%p", modem);
+
+	dbus_error_init(&derr);
+	if (dbus_set_error_from_message(&derr, reply)) {
+		DBG("Connection to bt serial returned with error: %s, %s",
+			derr.name, derr.message);
+		dbus_error_free(&derr);
+		goto done;
+	}
+
+	dbus_message_get_args(reply, NULL, DBUS_TYPE_STRING, &tty,
+			DBUS_TYPE_INVALID);
+
+	DBG("BT via tty %s", tty);
+
+	data->tty = g_strdup(tty);
+
+	ofono_modem_set_powered(modem, TRUE);
+
+done:
+	dbus_message_unref(reply);
+}
+
+static int dun_dt_enable(struct ofono_modem *modem)
+{
+	struct dun_data *data = ofono_modem_get_data(modem);
+	char *profile = "dun";
+
+	DBG("Open Bluetooth Networking");
+
+	bluetooth_send_with_reply(data->dun_path,
+					BLUEZ_SERIAL_INTERFACE, "Connect",
+					dun_dt_connect_reply, modem,
+					NULL, DBUS_TIMEOUT,
+					DBUS_TYPE_STRING, &profile,
+					DBUS_TYPE_INVALID);
+
+	return -EINPROGRESS;
+}
+
+static void dun_dt_disconnect_reply(DBusPendingCall *call, gpointer user_data)
+{
+	struct ofono_modem *modem = user_data;
+
+	/* handle errors. */
+
+	ofono_modem_set_powered(modem, FALSE);
+}
+
+static int dun_dt_disable(struct ofono_modem *modem)
+{
+	struct dun_data *data = ofono_modem_get_data(modem);
+
+	DBG("Disconnect Bluetooth Networking");
+
+	bluetooth_send_with_reply(data->dun_path,
+					BLUEZ_SERIAL_INTERFACE, "Disconnect",
+					dun_dt_disconnect_reply, modem,
+					NULL, DBUS_TIMEOUT,
+					DBUS_TYPE_STRING, &data->tty,
+					DBUS_TYPE_INVALID);
+
+	return -EINPROGRESS;
+}
+
+static void dun_dt_set_online(struct ofono_modem *modem, ofono_bool_t online,
+			ofono_modem_online_cb_t cb, void *data) {
+	DBG("modem %p, online %d", modem, online);
+
+	CALLBACK_WITH_SUCCESS(cb, modem);
+}
+
+
+static struct ofono_modem_driver dun_dt_driver = {
+	.name		= "dun_dt",
+	.probe		= dun_dt_probe,
+	.enable	= dun_dt_enable,
+	.disable	= dun_dt_disable,
+	.set_online	= dun_dt_set_online,
+	.pre_sim	= dun_dt_pre_sim,
+	.post_sim	= dun_dt_post_sim,
+	.post_online	= dun_dt_post_online
+};
+
+static struct bluetooth_profile dun_dt_profile = {
+	.name		= "dun_dt",
+	.probe		= dun_dt_bt_probe,
+	.remove	= dun_dt_bt_remove,
+	.set_alias	= dun_dt_bt_set_alias,
+};
+
+static int dun_dt_init(void)
+{
+	int err;
+
+	DBG("");
+
+	if (DBUS_TYPE_UNIX_FD < 0)
+		return -EBADF;
+
+	connection = ofono_dbus_get_connection();
+
+	err = ofono_modem_driver_register(&dun_dt_driver);
+	if (err < 0)
+		return err;
+
+	err = bluetooth_register_uuid(DUN_GW_UUID, &dun_dt_profile);
+	if (err < 0) {
+		ofono_modem_driver_unregister(&dun_dt_driver);
+		return err;
+	}
+
+	modem_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
+						g_free, NULL);
+
+	return 0;
+}
+
+static void dun_dt_exit(void)
+{
+	DBG("");
+
+	bluetooth_unregister_uuid(DUN_GW_UUID);
+	ofono_modem_driver_unregister(&dun_dt_driver);
+
+	g_hash_table_destroy(modem_hash);
+}
+
+OFONO_PLUGIN_DEFINE(dun_dt, "Dial-up Networking Data Terminal Profile Plugins",
+			VERSION, OFONO_PLUGIN_PRIORITY_DEFAULT,
+			dun_dt_init, dun_dt_exit)
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [RFC 3/3] dun_dt: Add baseline for dun_dt plug-in.
  2011-07-07  8:45 ` [RFC 3/3] dun_dt: Add baseline for dun_dt plug-in Mario Tokarz
@ 2011-07-07 16:59   ` Gustavo Padovan
  2011-07-10 21:07     ` Mario Tokarz
  0 siblings, 1 reply; 8+ messages in thread
From: Gustavo Padovan @ 2011-07-07 16:59 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 4290 bytes --]

Hi Mario,

* Mario Tokarz <mario@tokarz.eu> [2011-07-07 10:45:23 +0200]:

> From: Mario Tokarz <mario.tokarz@bmw-carit.de>
> 
> ---
>  Makefile.am      |    3 +
>  plugins/dun_dt.c |  337 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 340 insertions(+), 0 deletions(-)
>  create mode 100644 plugins/dun_dt.c
> 
> diff --git a/Makefile.am b/Makefile.am
> index c77a793..97698df 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -351,6 +351,9 @@ builtin_sources += plugins/hfp_ag.c plugins/bluetooth.h
>  builtin_modules += dun_gw
>  builtin_sources += plugins/dun_gw.c plugins/bluetooth.h
>  
> +builtin_modules += dun_dt
> +builtin_sources += plugins/dun_dt.c plugins/bluetooth.h
> +
>  builtin_sources += $(btio_sources)
>  builtin_cflags += @BLUEZ_CFLAGS@
>  builtin_libadd += @BLUEZ_LIBS@
> diff --git a/plugins/dun_dt.c b/plugins/dun_dt.c
> new file mode 100644
> index 0000000..98e2214
> --- /dev/null
> +++ b/plugins/dun_dt.c
> @@ -0,0 +1,337 @@
> +/*
> + *
> + *  oFono - Open Source Telephony
> + *
> + *  Copyright (C) 2008-2010  Intel Corporation. All rights reserved.
> + *  Copyright (C) 2010  ProFUSION embedded systems

So this is mine as in the original code I wrote. Not from ProFUSION.
It was part of a Google Summer of Code project.

	Copyright (C) 2010 Gustavo Padovan <gustavo@padovan.org>

> + *  Copyright (C) 2011  BMW Car IT GmbH. All rights reserved.
> + *
> + *  This program is free software; you can redistribute it and/or modify
> + *  it under the terms of the GNU General Public License version 2 as
> + *  published by the Free Software Foundation.
> + *
> + *  This program is distributed in the hope that it will be useful,
> + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
> + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + *  GNU General Public License for more details.
> + *
> + *  You should have received a copy of the GNU General Public License
> + *  along with this program; if not, write to the Free Software
> + *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
> + *
> + */
> +
> +#ifdef HAVE_CONFIG_H
> +#include <config.h>
> +#endif
> +#include <string.h>
> +#include <stdlib.h>
> +#include <stdio.h>
> +#include <errno.h>
> +#include <glib.h>
> +#include <gatchat.h>
> +#include <gattty.h>
> +#include <gdbus.h>
> +#include <ofono.h>
> +
> +#define OFONO_API_SUBJECT_TO_CHANGE
> +#include <ofono/plugin.h>
> +#include <ofono/log.h>
> +#include <ofono/modem.h>
> +#include <ofono/netreg.h>
> +#include <ofono/voicecall.h>
> +#include <ofono/gprs.h>
> +#include <ofono/gprs-context.h>
> +#include <ofono/call-volume.h>

call-volume.h?

> +
> +#include <drivers/dunmodem/dunmodem.h>
> +
> +#include <ofono/dbus.h>
> +
> +#include "bluetooth.h"
> +
> +#define BLUEZ_SERIAL_INTERFACE BLUEZ_SERVICE ".Serial"
> +
> +#ifndef DBUS_TYPE_UNIX_FD
> +#define DBUS_TYPE_UNIX_FD -1
> +#endif
> +
> +static DBusConnection *connection;
> +static GHashTable *modem_hash;
> +
> +static int dun_dt_bt_probe(const char *device, const char *dev_addr,
> +				const char *adapter_addr, const char *alias)
> +{
> +	struct ofono_modem *modem;
> +	struct dun_data *data;
> +	char buf[256];
> +	char alias_buf[256];
> +
> +	DBG("");
> +
> +	/* We already have this device in our hash, ignore */
> +	if (g_hash_table_lookup(modem_hash, device) != NULL)
> +		return -EALREADY;
> +
> +	ofono_info("Using device: %s, devaddr: %s, adapter: %s",
> +			device, dev_addr, adapter_addr);
> +
> +	strcpy(buf, "dun/");
> +	bluetooth_create_path(dev_addr, adapter_addr, buf + 4, sizeof(buf) - 4);
> +
> +	modem = ofono_modem_create(buf, "dun_dt");
> +	if (modem == NULL) {
> +		DBG("Failed to create modem");
> +		return -ENOMEM;
> +	}
> +
> +	DBG("Modem %p", modem);
> +
> +	data = g_try_new0(struct dun_data, 1);
> +	if (data == NULL)
> +		goto free;
> +
> +	data->dun_path = g_strdup(device);
> +	if (data->dun_path == NULL)
> +		goto free;
> +
> +	ofono_modem_set_data(modem, data);
> +
> +	strcpy(alias_buf, "DUN ");
> +	strcat(alias_buf, alias);

Do you really need tell the user this is a DUN modem? It doesn't care.

	Gustavo

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFC 3/3] dun_dt: Add baseline for dun_dt plug-in.
  2011-07-07 16:59   ` Gustavo Padovan
@ 2011-07-10 21:07     ` Mario Tokarz
  0 siblings, 0 replies; 8+ messages in thread
From: Mario Tokarz @ 2011-07-10 21:07 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 1106 bytes --]

Hi Gustavo,

On Thu, Jul 07, 2011 at 01:59:32PM -0300 , Gustavo Padovan wrote:
> Hi Mario,
> 
> * Mario Tokarz <mario@tokarz.eu> [2011-07-07 10:45:23 +0200]:
> 
> > From: Mario Tokarz <mario.tokarz@bmw-carit.de>
> > --- /dev/null
> > +++ b/plugins/dun_dt.c
> > @@ -0,0 +1,337 @@
> > +/*
> > + *
> > + *  oFono - Open Source Telephony
> > + *
> > + *  Copyright (C) 2008-2010  Intel Corporation. All rights reserved.
> > + *  Copyright (C) 2010  ProFUSION embedded systems
> 
> So this is mine as in the original code I wrote. Not from ProFUSION.
> It was part of a Google Summer of Code project.
> 
> 	Copyright (C) 2010 Gustavo Padovan <gustavo@padovan.org>
> 

Ah, ok - sorry for that. I based it on plugins/hfp_hc.c, so maybe the
Copyright Notice would need update on that file as well?

> > +
> > +	strcpy(alias_buf, "DUN ");
> > +	strcat(alias_buf, alias);
> 
> Do you really need tell the user this is a DUN modem? It doesn't care.
> 

Hm, ok. I'll look into that again then. I will be back with an
update. 

Thanks for taking the time to look over that.
Mario

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-07-10 21:07 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-07  8:45 [RFC 0/3] Adding DUN support Mario Tokarz
2011-07-07  8:45 ` [RFC 1/3] dunmodem: Add baseline for DUN modem driver Mario Tokarz
2011-07-07  8:16   ` Denis Kenzior
2011-07-07  8:45 ` [RFC 2/3] bluetooth: Add UUID for DUN Mario Tokarz
2011-07-07  8:00   ` Denis Kenzior
2011-07-07  8:45 ` [RFC 3/3] dun_dt: Add baseline for dun_dt plug-in Mario Tokarz
2011-07-07 16:59   ` Gustavo Padovan
2011-07-10 21:07     ` Mario Tokarz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.