From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============2957072381774871019==" MIME-Version: 1.0 From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Dalleau Subject: [PATCH 05/21] dun_gw: Add DUN server plugin for oFono Date: Wed, 12 Jan 2011 18:15:48 +0100 Message-ID: <1294852564-1258-6-git-send-email-frederic.dalleau@intel.com> In-Reply-To: <1294852564-1258-1-git-send-email-frederic.dalleau@intel.com> List-Id: To: ofono@ofono.org --===============2957072381774871019== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Zhenhua Zhang DUN server is probed when modem state changes to online. It registers DUN record to Bluetooth adapter and wait for incoming DUN connection. --- Makefile.am | 3 + plugins/dun_gw.c | 115 ++++++++++++++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 118 insertions(+), 0 deletions(-) create mode 100644 plugins/dun_gw.c diff --git a/Makefile.am b/Makefile.am index 5dcf253..58bf6c4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -291,6 +291,9 @@ builtin_sources +=3D plugins/bluetooth.c plugins/blueto= oth.h builtin_modules +=3D hfp builtin_sources +=3D plugins/hfp.c plugins/bluetooth.h = +builtin_modules +=3D dun_gw +builtin_sources +=3D $(btio_sources) plugins/dun_gw.c plugins/bluetooth.h + builtin_modules +=3D palmpre builtin_sources +=3D plugins/palmpre.c = diff --git a/plugins/dun_gw.c b/plugins/dun_gw.c new file mode 100644 index 0000000..803ae32 --- /dev/null +++ b/plugins/dun_gw.c @@ -0,0 +1,115 @@ +/* + * oFono - Open Source Telephony + * + * Copyright (C) 2010 Intel Corporation. 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 +#endif +#include +#include +#include +#include +#include + +#define OFONO_API_SUBJECT_TO_CHANGE +#include +#include +#include +#include + +#include "bluetooth.h" + +#define DUN_GW_CHANNEL 1 + +static struct server *server; + +static void dun_gw_connect_cb(GIOChannel *io, GError *err, gpointer user_d= ata) +{ + struct ofono_emulator *emulator =3D user_data; + + DBG(""); + + if (err) { + DBG("%s", err->message); + goto failed; + } + + if (ofono_emulator_enable(emulator, io) < 0) + goto failed; + + return; + +failed: + g_io_channel_shutdown(io, TRUE, NULL); + ofono_emulator_remove(emulator); + bluetooth_unregister_server(server); + server =3D NULL; +} + +static int dun_gw_probe(struct ofono_emulator *emulator, + struct ofono_modem *modem) +{ + struct ofono_atom *gprs; + + if (server) + return -1; + + DBG(""); + + gprs =3D __ofono_modem_find_atom(modem, OFONO_ATOM_TYPE_GPRS); + /* Make sure the modem has GPRS atom */ + if (!gprs) + return -1; + + server =3D bluetooth_register_server(DUN_GW, "Dial-Up Networking", + DUN_GW_CHANNEL, dun_gw_connect_cb, emulator); + + return 0; +} + +static void dun_gw_remove() +{ + if (server =3D=3D NULL) + return; + + DBG(""); + + bluetooth_unregister_server(server); + server =3D NULL; +} + +static struct ofono_emulator_driver emulator_driver =3D { + .name =3D "Dial-Up Networking", + .type =3D OFONO_ATOM_TYPE_EMULATOR_DUN, + .probe =3D dun_gw_probe, + .remove =3D dun_gw_remove, +}; + +static int dun_gw_init() +{ + return ofono_emulator_driver_register(&emulator_driver); +} + +static void dun_gw_exit() +{ + ofono_emulator_driver_unregister(&emulator_driver); +} + +OFONO_PLUGIN_DEFINE(dun_gw, "Dial-up Networking Profile Plugins", VERSION, + OFONO_PLUGIN_PRIORITY_DEFAULT, dun_gw_init, dun_gw_exit) -- = 1.7.1 --------------------------------------------------------------------- Intel Corporation SAS (French simplified joint stock company) Registered headquarters: "Les Montalets"- 2, rue de Paris, = 92196 Meudon Cedex, France Registration Number: 302 456 199 R.C.S. NANTERRE Capital: 4,572,000 Euros This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies. --===============2957072381774871019==--