Skip to contentSkip to conversation

add interface property to primary context

PATCH In review Martin Xu 3 participants 9 messages Nov 9, 2009 – Nov 10, 2009

lore
Share & tools
lore

Martin Xu

author
#0 lore raw

PATCH 1/4 add interface property to primary context

---
 include/gprs-context.h |    1 +
 src/gprs.c             |    4 ++++
 2 files changed, 5 insertions(+), 0 deletions(-)
include/gprs-context.h +1 -0
index c4ebd23..adb0820 100644
@@ -37,6 +37,7 @@ struct ofono_gprs_context;
 struct ofono_gprs_primary_context {
 	unsigned int cid;
 	int direction;
+	char *interface;
 	char apn[OFONO_GPRS_MAX_APN_LENGTH + 1];
 	char username[OFONO_GPRS_MAX_USERNAME_LENGTH + 1];
 	char password[OFONO_GPRS_MAX_PASSWORD_LENGTH + 1];
src/gprs.c +4 -0
index 0253109..18ae82a 100644
@@ -185,6 +185,10 @@ static DBusMessage *pri_get_properties(DBusConnection *conn,
 	ofono_dbus_dict_append(&dict, "Password", DBUS_TYPE_STRING,
 				&strvalue);
 
+	strvalue = ctx->context.interface;
+	ofono_dbus_dict_append(&dict, "Interface", DBUS_TYPE_STRING,
+				&strvalue);
+ 
 	dbus_message_iter_close_container(&iter, &dict);
 
 	return reply;
Signature · 1 line
1.6.1.3
author
#1 lore raw

PATCH 2/4 add create/destroy_interface to ofono_gprs_context_driver

---
 include/gprs-context.h |    4 ++++
 src/gprs.c             |   20 ++++++++++++++------
 2 files changed, 18 insertions(+), 6 deletions(-)
include/gprs-context.h +4 -0
index adb0820..b8c770d 100644
@@ -57,6 +57,10 @@ struct ofono_gprs_context_driver {
 	void (*deactivate_primary)(struct ofono_gprs_context *gc,
 					unsigned int id,
 					ofono_gprs_context_cb_t cb, void *data);
+	void (*create_interface)(struct ofono_gprs_context *gc,
+				struct ofono_gprs_primary_context *ctx);
+	void (*destroy_interface)(struct ofono_gprs_context *gc,
+				struct ofono_gprs_primary_context *ctx);
 };
 
 void ofono_gprs_context_deactivated(struct ofono_gprs_context *gc, unsigned id);
src/gprs.c +14 -6
index 18ae82a..60d26ec 100644
@@ -498,21 +498,29 @@ static struct pri_context *pri_context_create(struct ofono_gprs *gprs,
 						const char *name,
 						enum gprs_context_type type)
 {
-	struct pri_context *context = g_try_new0(struct pri_context, 1);
+	struct ofono_gprs_context *gc = gprs->context_driver;
+	struct pri_context *ctx = g_try_new0(struct pri_context, 1);
 
-	if (!context)
+	if (!ctx)
 		return NULL;
 
-	context->gprs = gprs;
-	strcpy(context->name, name);
-	context->type = type;
+	ctx->gprs = gprs;
+	strcpy(ctx->name, name);
+	ctx->type = type;
+
+	if (gc->driver->create_interface)
+		gc->driver->create_interface(gc, &ctx->context);
 
-	return context;
+	return ctx;
 }
 
 static void pri_context_destroy(gpointer userdata)
 {
 	struct pri_context *ctx = userdata;
+	struct ofono_gprs_context *gc = ctx->gprs->context_driver;
+
+	if (gc->driver->destroy_interface)
+		gc->driver->destroy_interface(gc, &ctx->context);
 
 	if (ctx->path)
 		g_free(ctx->path);
Signature · 1 line
1.6.1.3
author
#2 lore raw

PATCH 3/4 add function ofono_gprs_context_get_modem

---
 include/gprs-context.h |    2 ++
 src/gprs.c             |    5 +++++
 2 files changed, 7 insertions(+), 0 deletions(-)
include/gprs-context.h +2 -0
index b8c770d..2a788ef 100644
@@ -76,6 +76,8 @@ void ofono_gprs_context_remove(struct ofono_gprs_context *gc);
 void ofono_gprs_context_set_data(struct ofono_gprs_context *gc, void *data);
 void *ofono_gprs_context_get_data(struct ofono_gprs_context *gc);
 
+struct ofono_modem *ofono_gprs_context_get_modem(struct ofono_gprs_context *gc);
+
 #ifdef __cplusplus
 }
 #endif
src/gprs.c +5 -0
index 60d26ec..025b944 100644
@@ -1249,6 +1249,11 @@ void *ofono_gprs_context_get_data(struct ofono_gprs_context *gc)
 	return gc->driver_data;
 }
 
+struct ofono_modem *ofono_gprs_context_get_modem(struct ofono_gprs_context *gc)
+{
+	return __ofono_atom_get_modem(gc->atom);
+}
+
 int ofono_gprs_driver_register(const struct ofono_gprs_driver *d)
 {
 	DBG("driver: %p, name: %s", d, d->name);
Signature · 1 line
1.6.1.3
author
#3 lore raw

PATCH 4/4 add mbm_gprs_create/destroy_interface to mbm gprs_context_driver

---
 drivers/mbmmodem/gprs-context.c |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
drivers/mbmmodem/gprs-context.c +21 -0
index ecbafa0..d3e03b7 100644
@@ -172,6 +172,25 @@ error:
 	CALLBACK_WITH_FAILURE(cb, data);
 }
 
+static void mbm_gprs_create_interface(struct ofono_gprs_context *gc,
+					struct ofono_gprs_primary_context *ctx)
+{
+	const char *interface;
+	struct ofono_modem *modem = ofono_gprs_context_get_modem(gc);
+
+	interface = ofono_modem_get_string(modem, "NetworkInterface");
+
+	g_free(ctx->interface);
+	ctx->interface = g_strdup(interface);
+}
+
+static void mbm_gprs_destroy_interface(struct ofono_gprs_context *gc,
+					struct ofono_gprs_primary_context *ctx)
+{
+	g_free(ctx->interface);
+	ctx->interface = NULL;
+}
+
 static void e2nap_notifier(GAtResult *result, gpointer user_data)
 {
 	struct ofono_gprs_context *gc = user_data;
@@ -237,6 +256,8 @@ static struct ofono_gprs_context_driver driver = {
 	.remove			= mbm_gprs_context_remove,
 	.activate_primary	= mbm_gprs_activate_primary,
 	.deactivate_primary	= mbm_gprs_deactivate_primary,
+	.create_interface	= mbm_gprs_create_interface,
+	.destroy_interface	= mbm_gprs_destroy_interface,
 };
 
 void mbm_gprs_context_init()
Signature · 1 line
1.6.1.3
#4 lore raw

Re: [PATCH 2/4] add create/destroy_interface to ofono_gprs_context_driver

In reply to Martin Xu

Hi Martin,

include/gprs-context.h struct ofono_gprs_context_driver { · line 64

Quoted 9 lines
include/gprs-context.h +4 -0
@@ -57,6 +57,10 @@ struct ofono_gprs_context_driver {
 	void (*deactivate_primary)(struct ofono_gprs_context *gc,
 					unsigned int id,
 					ofono_gprs_context_cb_t cb, void *data);
+	void (*create_interface)(struct ofono_gprs_context *gc,
+				struct ofono_gprs_primary_context *ctx);
+	void (*destroy_interface)(struct ofono_gprs_context *gc,
+				struct ofono_gprs_primary_context *ctx);
 };

I suggest we don't do this, but instead notify the core of the interface name in 'activate_primary' callback, assuming the activate was successful.

Regards,
-Denis

#5 lore raw

PATCH 1/1 add interface property to primary context

In reply to Martin Xu

Hi:
"Interface" property of Primary Context is needed by ofono plugin for Connman.
These patches are used to implement "interface" property for Primary Context. Below is the way to implement it.
1. Create "interface" in Primary Context creating
2. Destroy "interface" in Primary Context destroying
3. "interface" is created/destroyed by ofono_gprs_context_driver
a) "interface" of MBM is inherited from NetworkInterface of modem which is exported from kernel
b) Others can use ofono_gprs_context_driver->create/destroy_interface() to create/destroy interface such as ppp0 and tun0.
Please review it.

#6 lore raw

How does ConnMan works with Ofono? RE: [PATCH */4] add interface property to primary context

Hi Marcel/Denis
In order to implement interface property. I think we need to clarify how does ConnMan work with Ofono firstly

In my opinion ConnMan and ofono works like below. Could you review and give out your opinions? Thanks!

PC_i: PrimaryContext_(internet type):
______________________________________
Ofono ConnMan
------------------------------------------------------------------

1.Modem device

  |
  | (create/load)
  |
  V
2.PC_i                     Network
  |
  |(powered up)
  |
  V
3.Attached PC_i----------->    Service (ready)
                         |
                         |(connect)
                         |
                         V 
4.Activated PC_i           Service (associated)
                         |
                         |(configure/dhcp)
                         |

V
5. Service (READY)

1. ConnMan detects the Modem from Ofono and create corresponding device
2. ConnMan detects the PC_i and create corresponding Network(First time, ConnMan will ask Ofono to create PC_i)
3. Once the PC_i attached ConnMan will create service
4. When user connects service, ConnMan will ask ofono to activate PC_i.
When PC_i is activated, Service in ConnMan is associated.
5. ConnMan will configure/dhcp to ipconfigure the service, and then service in READY state

#7 lore raw

RE: How does ConnMan works with Ofono? RE: [PATCH */4] add interface property to primary context

Quoted 13 lines

______________________________________
Ofono ConnMan
------------------------------------------------------------------

1.Modem device

  |
  | (create/load)
  |
  V
2.PC_i                     Network
  |
  |(powered up)
  |
Quoted 2 lines

V
3.Attached PC_i-----------> Service (ready)

3.Attached PC_i-----------> Service (idle)

Quoted 23 lines
                         |
                         |(connect)
                         |
                         V
4.Activated PC_i           Service (associated)
                         |
                         |(configure/dhcp)
                         |

V
5. Service (READY)

1. ConnMan detects the Modem from Ofono and create corresponding device
2. ConnMan detects the PC_i and create corresponding Network(First time, ConnMan will ask Ofono to create PC_i)
3. Once the PC_i attached ConnMan will create service
4. When user connects service, ConnMan will ask ofono to activate PC_i. When PC_i is activated, Service in ConnMan is associated.
5. ConnMan will configure/dhcp to ipconfigure the service, and then service in READY state
_______________________________________________
connman mailing list
connman(a)connman.net
http://lists.connman.net/listinfo/connman

#8 lore raw
In reply to Martin Xu

Hi Martin,

include/gprs-context.h struct ofono_gprs_context; · line 43

Quoted 8 lines
include/gprs-context.h +1 -0
@@ -37,6 +37,7 @@ struct ofono_gprs_context;
 struct ofono_gprs_primary_context {
 	unsigned int cid;
 	int direction;
+	char *interface;
 	char apn[OFONO_GPRS_MAX_APN_LENGTH + 1];
 	char username[OFONO_GPRS_MAX_USERNAME_LENGTH + 1];
 	char password[OFONO_GPRS_MAX_PASSWORD_LENGTH + 1];

Logically this does not belong here. It should be added to ofono_gprs_context, or perhaps to pri_context.

Regards,
-Denis