Skip to contentSkip to conversation

bluetooth: Rename DUN GW plugin

PATCH In review Frédéric Danis 2 participants 4 messages Mar 12, 2013 – Mar 21, 2013 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 bluetooth: Rename DUN GW plugin

As BlueZ 5 introduced backwards incompatible API changes, and we want to keep support for BlueZ 4 based DUN GW plugin for some time, we need to separate DUN GW plugin which is based on BlueZ 4 from the one based on BlueZ 5.

The dun_gw.c plugin is renamed to dun_gw_bluez4. This will make it easy to add a DUN GW plugin for BlueZ 5.

---
 Makefile.am                           |    4 ++--
 plugins/{dun_gw.c => dun_gw_bluez4.c} |    5 +++--
 2 files changed, 5 insertions(+), 4 deletions(-)
 rename plugins/{dun_gw.c => dun_gw_bluez4.c} (96%)
Makefile.am +2 -2
index 3b998af..bf4806b 100644
@@ -425,8 +425,8 @@ builtin_sources += plugins/hfp_hf_bluez4.c plugins/bluez4.h
 builtin_modules += hfp_ag_bluez4
 builtin_sources += plugins/hfp_ag_bluez4.c plugins/bluez4.h
 
-builtin_modules += dun_gw
-builtin_sources += plugins/dun_gw.c plugins/bluez4.h
+builtin_modules += dun_gw_bluez4
+builtin_sources += plugins/dun_gw_bluez4.c plugins/bluez4.h
 
 builtin_modules += connman
 builtin_sources += plugins/connman.c
plugins/dun_gw_bluez4.c renamed from plugins/dun_gw.c +3 -2
similarity index 96%
rename from plugins/dun_gw.c
rename to plugins/dun_gw_bluez4.c
index fc8bde4..a1de7a4 100644
@@ -167,5 +167,6 @@ static void dun_gw_exit(void)
 	}
 }
 
-OFONO_PLUGIN_DEFINE(dun_gw, "Dial-up Networking Profile Plugins", VERSION,
-			OFONO_PLUGIN_PRIORITY_DEFAULT, dun_gw_init, dun_gw_exit)
+OFONO_PLUGIN_DEFINE(dun_gw_bluez4, "Dial-up Networking Profile Plugins",
+				VERSION, OFONO_PLUGIN_PRIORITY_DEFAULT,
+				dun_gw_init, dun_gw_exit)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v2 2/2 dun_gw: Add BlueZ 5 version

This patch adds initial implementation of the D-Bus Profile1 interface and methods responsible for handling Bluetooth connections.

The DUN GW profile interface is registered as soon as a GPRS capable modem is registered in oFono.

---
 Makefile.am             |    3 +
 plugins/bluez5.h        |    1 +
 plugins/dun_gw_bluez5.c |  235 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 239 insertions(+)
 create mode 100644 plugins/dun_gw_bluez5.c
Makefile.am +3 -0
index bf4806b..ebe20bd 100644
@@ -443,6 +443,9 @@ builtin_sources += plugins/hfp_hf_bluez5.c plugins/bluez5.h
 
 builtin_modules += hfp_ag_bluez5
 builtin_sources += plugins/hfp_ag_bluez5.c plugins/bluez5.h
+
+builtin_modules += dun_gw_bluez5
+builtin_sources += plugins/dun_gw_bluez5.c plugins/bluez5.h
 endif
 endif
 endif
plugins/bluez5.h +1 -0
index 573a54c..5b8c1f5 100644
@@ -25,6 +25,7 @@
 #define BLUEZ_DEVICE_INTERFACE		BLUEZ_SERVICE ".Device1"
 #define BLUEZ_ERROR_INTERFACE		BLUEZ_SERVICE ".Error"
 
+#define DUN_GW_UUID	"00001103-0000-1000-8000-00805f9b34fb"
 #define HFP_HS_UUID	"0000111e-0000-1000-8000-00805f9b34fb"
 #define HFP_AG_UUID	"0000111f-0000-1000-8000-00805f9b34fb"
 
plugins/dun_gw_bluez5.c new file +235 -0

235 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#3 lore raw
In reply to Frédéric Danis

Hi Fred,

Quoted 5 lines · Frédéric Danis

As BlueZ 5 introduced backwards incompatible API changes, and we want to keep support for BlueZ 4 based DUN GW plugin for some time, we need to separate DUN GW plugin which is based on BlueZ 4 from the one based on BlueZ 5.

Quoted 7 lines

The dun_gw.c plugin is renamed to dun_gw_bluez4. This will make it easy to add a DUN GW plugin for BlueZ 5.

---
  Makefile.am                           |    4 ++--
  plugins/{dun_gw.c =>  dun_gw_bluez4.c} |    5 +++--
  2 files changed, 5 insertions(+), 4 deletions(-)

rename plugins/{dun_gw.c => dun_gw_bluez4.c} (96%)

Patch has been applied, thanks.

Regards,
-Denis

#2 lore raw

Re: [PATCH v2 2/2] dun_gw: Add BlueZ 5 version

In reply to Frédéric Danis

Hi Fred,

Quoted 12 lines · Frédéric Danis

This patch adds initial implementation of the D-Bus Profile1 interface and methods responsible for handling Bluetooth connections.

The DUN GW profile interface is registered as soon as a GPRS capable modem is registered in oFono.

---
  Makefile.am             |    3 +
  plugins/bluez5.h        |    1 +
  plugins/dun_gw_bluez5.c |  235 +++++++++++++++++++++++++++++++++++++++++++++++
  3 files changed, 239 insertions(+)

create mode 100644 plugins/dun_gw_bluez5.c

I applied this patch, but I had to fix a minor issue afterwards:

Quoted 24 lines
plugins/dun_gw_bluez5.c new file +24 -0
+static DBusMessage *profile_new_connection(DBusConnection *conn,
+						DBusMessage *msg, void *data)
+{
+	DBusMessageIter entry;
+	const char *device;
+	int fd;
+	struct ofono_emulator *em;
+	struct ofono_modem *modem;
+
+	DBG("Profile handler NewConnection");
+
+	if (dbus_message_iter_init(msg,&entry) == FALSE)
+		goto invalid;
+
+	if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_OBJECT_PATH)
+		goto invalid;
+
+	dbus_message_iter_get_basic(&entry,&device);
+	dbus_message_iter_next(&entry);
+
+	if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_UNIX_FD)
+		goto invalid;
+
+	dbus_message_iter_get_basic(&entry,&fd);

plugins/dun_gw_bluez5.c line 85

Quoted 10 lines
plugins/dun_gw_bluez5.c new file +10 -0
+	dbus_message_iter_next(&entry);
+
+	if (fd<  0)
+		goto invalid;
+
+	DBG("%s", device);
+
+	/* Pick the first powered modem */
+	modem = modems->data;
+	if (modem == NULL) {

We should be checking for modems == NULL, not modems->data

plugins/dun_gw_bluez5.c line 89

Quoted 4 lines
plugins/dun_gw_bluez5.c new file +4 -0
+		close(fd);
+		return g_dbus_create_error(msg, BLUEZ_ERROR_INTERFACE
+						".Rejected",
+						"No voice call capable modem");

This was changed to read '...GPRS capable modem'.

Quoted 11 lines
plugins/dun_gw_bluez5.c new file +11 -0
+	}
+
+	DBG("Picked modem %p for emulator", modem);
+
+	em = ofono_emulator_create(modem, OFONO_EMULATOR_TYPE_DUN);
+	if (em == NULL) {
+		close(fd);
+		return g_dbus_create_error(msg, BLUEZ_ERROR_INTERFACE
+						".Rejected",
+						"Not enough resources");
+	}

plugins/dun_gw_bluez5.c line 110

Quoted 10 lines
plugins/dun_gw_bluez5.c new file +10 -0
+
+	ofono_emulator_register(em, fd);
+
+	return dbus_message_new_method_return(msg);
+
+invalid:
+	return g_dbus_create_error(msg, BLUEZ_ERROR_INTERFACE ".Rejected",
+					"Invalid arguments in method call");
+}
+

Regards,
-Denis