add interface property to primary context
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
@@ -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
@@ -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
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
@@ -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
@@ -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
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
@@ -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
@@ -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
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
@@ -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
Re: [PATCH 2/4] add create/destroy_interface to ofono_gprs_context_driver
In reply to Martin XuHi 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
Xu
PATCH 1/1 add interface property to primary context
In reply to Martin XuHi:
"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.
Xu
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
Xu
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 thePC_iand create correspondingNetwork(First time, ConnMan will ask Ofono to create PC_i)
3. Once thePC_iattached ConnMan will create service
4. When user connects service, ConnMan will ask ofono to activatePC_i. WhenPC_iis 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
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