From 33f67b50ead6154e77579c532618b6a56d3bd9b6 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Fri, 11 Jun 2010 09:12:06 +0300 Subject: [PATCH] ofono: do not use context path as network group identifier The ofono plugin was using context path as network group identifier which caused service path to end something like this: /profile/default/cellular_244053111242822_huawei2_primarycontext1 But the problem here is that with certain modems (like my Huawei E1552) the path will change every time the modem in replugged. This meant that a new connman service was created everytime and I had to enter APN everytime, instead of using the stored service which already had APN correctly set. Fix this by using only the last part from path, for example in this case primarycontext1: /profile/default/cellular_244053111242822_primarycontext1 Now with huawei modems the service id stays always the same as it should. --- plugins/ofono.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/plugins/ofono.c b/plugins/ofono.c index d0e4641..126d616 100644 --- a/plugins/ofono.c +++ b/plugins/ofono.c @@ -170,19 +170,16 @@ static struct connman_device_driver modem_driver = { static char *get_ident(const char *path) { - char *ident, *pos; + char *pos; if (*path != '/') return NULL; - ident = g_strdup(path + 1); - - pos = ident; - - while ((pos = strchr(pos, '/')) != NULL) - *pos = '_'; + pos = strrchr(path, '/'); + if (pos == NULL) + return NULL; - return ident; + return g_strdup(pos + 1); } static void create_service(struct connman_network *network) -- 2.7.4