Re: [PATCH] unit: Improve idmap.c unit test coverage

2018-01-18 Thread Denis Kenzior

Hi Slava,

On 01/18/2018 12:36 PM, Slava Monich wrote:

This brings function, line and branch coverage for idmap.c to 100%
---
  unit/test-idmap.c | 24 
  1 file changed, 24 insertions(+)



Applied, thanks.

Regards,
-Denis

___
ofono mailing list
ofono@ofono.org
https://lists.ofono.org/mailman/listinfo/ofono


[PATCH] unit: Improve idmap.c unit test coverage

2018-01-18 Thread Slava Monich
This brings function, line and branch coverage for idmap.c to 100%
---
 unit/test-idmap.c | 24 
 1 file changed, 24 insertions(+)

diff --git a/unit/test-idmap.c b/unit/test-idmap.c
index b072933..2d2e226 100644
--- a/unit/test-idmap.c
+++ b/unit/test-idmap.c
@@ -35,9 +35,12 @@ static void test_alloc(void)
idmap = idmap_new(2);
 
g_assert(idmap);
+   g_assert(idmap_get_min(idmap) == 1);
 
bit = idmap_alloc(idmap);
g_assert(bit == 1);
+   g_assert(idmap_find(idmap, bit));
+   g_assert(!idmap_find(idmap, idmap_get_max(idmap) + 1));
 
bit = idmap_alloc(idmap);
g_assert(bit == 2);
@@ -62,6 +65,12 @@ static void test_alloc(void)
bit = idmap_alloc(idmap);
g_assert(bit == 1);
 
+   idmap_put(idmap, 1);
+   idmap_take(idmap, 1);
+   idmap_take(idmap, 3);
+   bit = idmap_alloc(idmap);
+   g_assert(bit == 2);
+
idmap_free(idmap);
 }
 
@@ -80,9 +89,24 @@ static void test_alloc_next(void)
bit = idmap_alloc_next(idmap, 255);
g_assert(bit == 1);
 
+   while (idmap_alloc(idmap) < (sizeof(unsigned long) * 8) + 1);
+   bit = idmap_alloc_next(idmap, 1);
+   g_assert(bit == (sizeof(unsigned long) * 8) + 2);
+
+   idmap_free(idmap);
+
+   idmap = idmap_new(2);
+
+   g_assert(idmap);
+   g_assert(idmap_alloc_next(idmap, 0) == 3);
+   g_assert(idmap_alloc_next(idmap, 3) == 3);
+
bit = idmap_alloc_next(idmap, 1);
g_assert(bit == 2);
 
+   bit = idmap_alloc_next(idmap, 2);
+   g_assert(bit == 1);
+
idmap_free(idmap);
 }
 
-- 
1.9.1

___
ofono mailing list
ofono@ofono.org
https://lists.ofono.org/mailman/listinfo/ofono


Re: Huawei MS2131

2018-01-18 Thread Denis Kenzior

Hi Daniel,

On 01/18/2018 06:32 AM, Daniel Wagner wrote:

[16:18:50.215180] ofonod[3277]: Modem: < \r\n+CGREG: 1,"03B8","0EA971F9"\r\n
[16:18:50.315482] ofonod[3277]: Modem: < \r\n^SRVST: 2\r\n
[16:18:50.498603] ofonod[3277]: Modem: < \r\n+CREG: 1,"03B8","0EA971F9"\r\n
[16:19:39.357779] ofonod[3277]: Modem: < \r\n+CSQ: 27,99\r\n\r\nOK\r\n
[16:19:39.357843] ofonod[3277]: Modem: > AT&C0\r


You do seem to get network registration there at the end, but they only 
come on the Modem Port which is weird.  Also that last AT&C0 should be 
located right around the same place as the AT&C0 on the PCUI port, not 
much later in the log as it is now.  They're sent at the same time in 
sysinfo_enable_cb.


Something is weird with that hardware, almost like the Modem port isn't 
ready to send commands until much later.  Are you sure you have udevng 
detecting the right AT ports?


Regards,
-Denis
___
ofono mailing list
ofono@ofono.org
https://lists.ofono.org/mailman/listinfo/ofono


Re: [PATCH] dbus: Use dbus_validate_path

2018-01-18 Thread Denis Kenzior

Hi Slava,

On 01/18/2018 10:47 AM, Slava Monich wrote:

Instead of __ofono_dbus_valid_object_path
---
  plugins/push-notification.c |  2 +-
  plugins/smart-messaging.c   |  2 +-
  src/dbus.c  | 44 
  src/gnss.c  |  2 +-
  src/modem.c |  2 +-
  src/netmon.c|  2 +-
  src/ofono.h |  2 --
  src/stk.c   |  4 ++--
  8 files changed, 7 insertions(+), 53 deletions(-)



Applied, thanks.

Regards,
-Denis

___
ofono mailing list
ofono@ofono.org
https://lists.ofono.org/mailman/listinfo/ofono


[PATCH] dbus: Use dbus_validate_path

2018-01-18 Thread Slava Monich
Instead of __ofono_dbus_valid_object_path
---
 plugins/push-notification.c |  2 +-
 plugins/smart-messaging.c   |  2 +-
 src/dbus.c  | 44 
 src/gnss.c  |  2 +-
 src/modem.c |  2 +-
 src/netmon.c|  2 +-
 src/ofono.h |  2 --
 src/stk.c   |  4 ++--
 8 files changed, 7 insertions(+), 53 deletions(-)

diff --git a/plugins/push-notification.c b/plugins/push-notification.c
index ff388d9..f469f9e 100644
--- a/plugins/push-notification.c
+++ b/plugins/push-notification.c
@@ -96,7 +96,7 @@ static DBusMessage 
*push_notification_register_agent(DBusConnection *conn,
DBUS_TYPE_INVALID) == FALSE)
return __ofono_error_invalid_args(msg);
 
-   if (!__ofono_dbus_valid_object_path(agent_path))
+   if (!dbus_validate_path(agent_path, NULL))
return __ofono_error_invalid_format(msg);
 
pn->agent = sms_agent_new(AGENT_INTERFACE,
diff --git a/plugins/smart-messaging.c b/plugins/smart-messaging.c
index bbbdaa9..0c9700d 100644
--- a/plugins/smart-messaging.c
+++ b/plugins/smart-messaging.c
@@ -119,7 +119,7 @@ static DBusMessage 
*smart_messaging_register_agent(DBusConnection *conn,
DBUS_TYPE_INVALID) == FALSE)
return __ofono_error_invalid_args(msg);
 
-   if (!__ofono_dbus_valid_object_path(agent_path))
+   if (!dbus_validate_path(agent_path, NULL))
return __ofono_error_invalid_format(msg);
 
sm->agent = sms_agent_new(AGENT_INTERFACE,
diff --git a/src/dbus.c b/src/dbus.c
index 45becc1..3e1e162 100644
--- a/src/dbus.c
+++ b/src/dbus.c
@@ -456,50 +456,6 @@ void __ofono_dbus_pending_reply(DBusMessage **msg, 
DBusMessage *reply)
*msg = NULL;
 }
 
-gboolean __ofono_dbus_valid_object_path(const char *path)
-{
-   unsigned int i;
-   char c = '\0';
-
-   if (path == NULL)
-   return FALSE;
-
-   if (path[0] == '\0')
-   return FALSE;
-
-   if (path[0] && !path[1] && path[0] == '/')
-   return TRUE;
-
-   if (path[0] != '/')
-   return FALSE;
-
-   for (i = 0; path[i]; i++) {
-   if (path[i] == '/' && c == '/')
-   return FALSE;
-
-   c = path[i];
-
-   if (path[i] >= 'a' && path[i] <= 'z')
-   continue;
-
-   if (path[i] >= 'A' && path[i] <= 'Z')
-   continue;
-
-   if (path[i] >= '0' && path[i] <= '9')
-   continue;
-
-   if (path[i] == '_' || path[i] == '/')
-   continue;
-
-   return FALSE;
-   }
-
-   if (path[i-1] == '/')
-   return FALSE;
-
-   return TRUE;
-}
-
 DBusConnection *ofono_dbus_get_connection(void)
 {
return g_connection;
diff --git a/src/gnss.c b/src/gnss.c
index 97d1152..ba2a97b 100644
--- a/src/gnss.c
+++ b/src/gnss.c
@@ -135,7 +135,7 @@ static DBusMessage *gnss_register_agent(DBusConnection 
*conn,
&agent_path, DBUS_TYPE_INVALID) == FALSE)
return __ofono_error_invalid_args(msg);
 
-   if (!__ofono_dbus_valid_object_path(agent_path))
+   if (!dbus_validate_path(agent_path, NULL))
return __ofono_error_invalid_format(msg);
 
gnss->posr_agent = gnss_agent_new(agent_path,
diff --git a/src/modem.c b/src/modem.c
index 0c63d2c..d5fda7c 100644
--- a/src/modem.c
+++ b/src/modem.c
@@ -1876,7 +1876,7 @@ struct ofono_modem *ofono_modem_create(const char *name, 
const char *type)
else
snprintf(path, sizeof(path), "/%s", name);
 
-   if (__ofono_dbus_valid_object_path(path) == FALSE)
+   if (!dbus_validate_path(path, NULL))
return NULL;
 
modem = g_try_new0(struct ofono_modem, 1);
diff --git a/src/netmon.c b/src/netmon.c
index 3a49587..62e0ec0 100644
--- a/src/netmon.c
+++ b/src/netmon.c
@@ -353,7 +353,7 @@ static DBusMessage *netmon_register_agent(DBusConnection 
*conn,
DBUS_TYPE_INVALID) == FALSE)
return __ofono_error_invalid_args(msg);
 
-   if (!__ofono_dbus_valid_object_path(agent_path))
+   if (!dbus_validate_path(agent_path, NULL))
return __ofono_error_invalid_format(msg);
 
if (!period)
diff --git a/src/ofono.h b/src/ofono.h
index deb1b7c..ac3726d 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -76,8 +76,6 @@ DBusMessage *__ofono_error_from_error(const struct 
ofono_error *error,
 
 void __ofono_dbus_pending_reply(DBusMessage **msg, DBusMessage *reply);
 
-gboolean __ofono_dbus_valid_object_path(const char *path);
-
 struct ofono_watchlist_item {
unsigned int id;
void *notify;
diff --git a/src/stk.c b/src/stk.c
index 49d6365..9cdf2b1 100644
--- a/src/stk.c
+++ b/src/stk.c
@@ -722,7 +722,7 @@ s

Re: Huawei MS2131

2018-01-18 Thread Christophe Ronco

Hi Daniel,


On 01/18/2018 01:32 PM, Daniel Wagner wrote:

Hi,

Xingxing and I am trying to get the Huawei MS2131 working. After
swapping mdm with pcui interface, oFono starts to talk to the device.
I have a MS2131 and I am able to use it without any special patch in 
udevng.c


Manufacturer:huawei

Model:MS2131

Revision:21.751.17.00.00


I have a patch in usb-modeswitch for all Huaweï device to switch to PPP 
mode instead of Hi-Link mode but I don't think this change something 
with firmwares 21.XX.


I attach the debug output I have so that you can compare.


Best Regards,
Christophe
Jan 18 13:02:34 klk-lpbs-0504B4 daemon.info ofonod[853]: oFono version 1.21
Jan 18 13:02:34 klk-lpbs-0504B4 daemon.debug ofonod[853]: 
../ofono-1.21/src/plugin.c:__ofono_plugin_init() 
Jan 18 13:02:34 klk-lpbs-0504B4 daemon.debug ofonod[853]: 
../ofono-1.21/src/sim-password-provision.c:ofono_sim_password_provision_driver_register()
 driver: 0x13a088 name: PIN provisioning
Jan 18 13:02:34 klk-lpbs-0504B4 daemon.debug ofonod[853]: 
../ofono-1.21/src/gprs-provision.c:ofono_gprs_provision_driver_register() 
driver: 0x13a05c name: GPRS context provisioning
Jan 18 13:02:34 klk-lpbs-0504B4 daemon.debug ofonod[853]: 
../ofono-1.21/plugins/push-notification.c:push_notification_init() 
Jan 18 13:02:34 klk-lpbs-0504B4 daemon.debug ofonod[853]: 
../ofono-1.21/plugins/smart-messaging.c:smart_messaging_init() 
Jan 18 13:02:34 klk-lpbs-0504B4 daemon.debug ofonod[853]: 
../ofono-1.21/src/cdma-provision.c:ofono_cdma_provision_driver_register() 
driver: 0x13a030 name: CDMA provisioning
Jan 18 13:02:34 klk-lpbs-0504B4 daemon.debug ofonod[853]: 
../ofono-1.21/src/gprs-provision.c:ofono_gprs_provision_driver_register() 
driver: 0x13a004 name: Provisioning
Jan 18 13:02:34 klk-lpbs-0504B4 daemon.debug ofonod[853]: 
../ofono-1.21/plugins/xmm7xxx.c:xmm7xxx_init() 
Jan 18 13:02:34 klk-lpbs-0504B4 daemon.debug ofonod[853]: 
../ofono-1.21/src/modem.c:ofono_modem_driver_register() driver: 0x139fb4, name: 
xmm7xxx
Jan 18 13:02:34 klk-lpbs-0504B4 daemon.debug ofonod[853]: 
../ofono-1.21/src/modem.c:ofono_modem_driver_register() driver: 0x139f6c, name: 
ublox
Jan 18 13:02:34 klk-lpbs-0504B4 daemon.debug ofonod[853]: 
../ofono-1.21/src/modem.c:ofono_modem_driver_register() driver: 0x139f14, name: 
quectel
Jan 18 13:02:34 klk-lpbs-0504B4 daemon.debug ofonod[853]: 
../ofono-1.21/plugins/telit.c:telit_init() 
Jan 18 13:02:34 klk-lpbs-0504B4 daemon.debug ofonod[853]: 
../ofono-1.21/src/modem.c:ofono_modem_driver_register() driver: 0x139ec4, name: 
telit
Jan 18 13:02:34 klk-lpbs-0504B4 daemon.debug ofonod[853]: 
../ofono-1.21/plugins/connman.c:connman_init() 
Jan 18 13:02:34 klk-lpbs-0504B4 daemon.debug ofonod[853]: 
../ofono-1.21/src/private-network.c:ofono_private_network_driver_register() 
driver: 0x139e98, name: ConnMan Private Network
Jan 18 13:02:34 klk-lpbs-0504B4 daemon.debug ofonod[853]: 
../ofono-1.21/src/modem.c:ofono_modem_driver_register() driver: 0x139e50, name: 
sim900
Jan 18 13:02:34 klk-lpbs-0504B4 daemon.debug ofonod[853]: 
../ofono-1.21/src/modem.c:ofono_modem_driver_register() driver: 0x139e08, name: 
samsung
Jan 18 13:02:34 klk-lpbs-0504B4 daemon.debug ofonod[853]: 
../ofono-1.21/src/modem.c:ofono_modem_driver_register() driver: 0x139dc0, name: 
speedupcdma
Jan 18 13:02:34 klk-lpbs-0504B4 daemon.debug ofonod[853]: 
../ofono-1.21/src/modem.c:ofono_modem_driver_register() driver: 0x139d70, name: 
speedup
Jan 18 13:02:34 klk-lpbs-0504B4 daemon.debug ofonod[853]: 
../ofono-1.21/src/modem.c:ofono_modem_driver_register() driver: 0x139d28, name: 
alcatel
Jan 18 13:02:34 klk-lpbs-0504B4 daemon.debug ofonod[853]: 
../ofono-1.21/src/modem.c:ofono_modem_driver_register() driver: 0x139cd0, name: 
icera
Jan 18 13:02:34 klk-lpbs-0504B4 daemon.debug ofonod[853]: 
../ofono-1.21/src/modem.c:ofono_modem_driver_register() driver: 0x139c88, name: 
linktop
Jan 18 13:02:34 klk-lpbs-0504B4 daemon.debug ofonod[853]: 
../ofono-1.21/src/modem.c:ofono_modem_driver_register() driver: 0x139c40, name: 
nokiacdma
Jan 18 13:02:34 klk-lpbs-0504B4 daemon.debug ofonod[853]: 
../ofono-1.21/src/modem.c:ofono_modem_driver_register() driver: 0x139bf8, name: 
nokia
Jan 18 13:02:34 klk-lpbs-0504B4 daemon.debug ofonod[853]: 
../ofono-1.21/src/modem.c:ofono_modem_driver_register() driver: 0x139ba0, name: 
gemalto
Jan 18 13:02:34 klk-lpbs-0504B4 daemon.debug ofonod[853]: 
../ofono-1.21/src/modem.c:ofono_modem_driver_register() driver: 0x139b58, name: 
cinterion
Jan 18 13:02:34 klk-lpbs-0504B4 daemon.debug ofonod[853]: 
../ofono-1.21/src/modem.c:ofono_modem_driver_register() driver: 0x139ad0, name: 
ste
Jan 18 13:02:34 klk-lpbs-0504B4 daemon.debug ofonod[853]: 
../ofono-1.21/src/modem.c:ofono_modem_driver_register() driver: 0x139a78, name: 
ifx
Jan 18 13:02:34 klk-lpbs-0504B4 daemon.debug ofonod[853]: 
../ofono-1.21/src/modem.c:ofono_modem_driver_register() driver: 0x139a30, name: 
palmpre
Jan 18 13:02:34 klk-lpbs-0504B4 daemon.debug ofonod[853]: 
../ofono-1.21/src/modem.c:ofono_mode

Huawei MS2131

2018-01-18 Thread Daniel Wagner
Hi,

Xingxing and I am trying to get the Huawei MS2131 working. After 
swapping mdm with pcui interface, oFono starts to talk to the device.

--- a/plugins/udevng.c
+++ b/plugins/udevng.c
@@ -332,14 +332,14 @@ static gboolean setup_huawei(struct modem_info *modem)
g_strcmp0(info->interface, "255/2/1") == 0 ||
g_strcmp0(info->interface, "255/3/1") == 0 ||
g_strcmp0(info->interface, "255/1/49") == 0) {
-   mdm = info->devnode;
+   pcui = info->devnode;
} else if (g_strcmp0(info->label, "pcui") == 0 ||
g_strcmp0(info->interface, "255/1/2") == 0 ||
g_strcmp0(info->interface, "255/2/2") == 0 ||
g_strcmp0(info->interface, "255/2/18") == 0 ||
g_strcmp0(info->interface, "255/3/18") == 0 ||
g_strcmp0(info->interface, "255/1/50") == 0) {
-   pcui = info->devnode;
+   mdm = info->devnode;
} else if (g_strcmp0(info->label, "diag") == 0 ||
g_strcmp0(info->interface, "255/1/3") == 0 ||
g_strcmp0(info->interface, "255/2/3") == 0 ||


A enable-modem and online-modem later oFono gets stuck at netreg searching
for a network.

So to check if the modem and the SIM are working we played with wvdial:

root@iot2000-ebs:/etc# wvdial MS2131
--> WvDial: Internet dialer version 1.61
--> Initializing modem.
--> Sending: AT^NDISDUP=1,1
AT^NDISDUP=1,1
OK
--> Sending: AT+CGDCONT=1,"IP","web.vodafone.de"
AT+CGDCONT=1,"IP","web.vodafone.de"
OK
--> Modem initialized.
--> Configuration does not specify a valid phone number.


root@iot2000-ebs:/etc# ifup wwan0
udhcpc (v1.24.1) started
Sending discover...
Sending select for 100.92.86.33...
Lease of 100.92.86.33 obtained, lease time 518400
/etc/udhcpc.d/50default: Adding DNS 139.7.30.126
/etc/udhcpc.d/50default: Adding DNS 139.7.30.125

 

Stupid mode:
root@iot2000-ebs:/etc# wvdial MSSS
--> WvDial: Internet dialer version 1.61
--> Initializing modem.
--> Sending: ATZ
ATZ
OK
--> Sending: AT+CGDCONT=1,"IP","web.vodafone.de"
AT+CGDCONT=1,"IP","web.vodafone.de"
OK
--> Modem initialized.
--> Sending: ATDT*99***1#
--> Waiting for carrier.
ATDT*99***1#
CONNECT 2160
--> Carrier detected.  Starting PPP immediately.
--> Starting pppd at Thu Jan 18 08:51:33 2018
--> Pid of pppd: 942
PPP generic driver version 2.4.2
--> pppd: ▒e[07][08]
--> Using interface ppp0
--> pppd: ▒e[07][08]
--> pppd: ▒e[07][08]
--> pppd: ▒e[07][08]
--> pppd: ▒e[07][08]
PPP BSD Compression module registered
PPP Deflate Compression module registered
--> pppd: ▒e[07][08]
--> local  IP address 100.68.88.182
--> pppd: ▒e[07][08]
--> remote IP address 10.64.64.64
--> pppd: ▒e[07][08]
--> primary   DNS address 139.7.30.126
--> pppd: ▒e[07][08]
--> secondary DNS address 139.7.30.125
--> pppd: ▒e[07][08]
^CCaught signal 2:  Attempting to exit gracefully...
--> Terminating on signal 15
--> pppd: ▒e[07][08]
--> Connect time 5.4 minutes.
--> pppd: ▒e[07][08]
--> pppd: ▒e[07][08]
--> pppd: ▒e[07][08]
--> Disconnecting at Thu Jan 18 08:56:56 2018

 

Without stupid mode:

root@iot2000-ebs:/etc# wvdial MSSS
--> WvDial: Internet dialer version 1.61
--> Initializing modem.
--> Sending: ATZ
ATZ
OK
--> Sending: AT+CGDCONT=1,"IP","web.vodafone.de"
AT+CGDCONT=1,"IP","web.vodafone.de"
OK
--> Modem initialized.
--> Sending: ATDT*99***1#
--> Waiting for carrier.
ATDT*99***1#
CONNECT 2160
--> Carrier detected.  Waiting for prompt.
--> Don't know what to do!  Starting pppd and hoping for the best.
--> Starting pppd at Thu Jan 18 08:57:52 2018
--> Pid of pppd: 1021
--> pppd: �e[07][08]
--> Using interface ppp0
--> pppd: �e[07][08]
--> pppd: �e[07][08]
--> pppd: �e[07][08]
--> pppd: �e[07][08]
--> pppd: �e[07][08]
--> local  IP address 100.68.122.98
--> pppd: �e[07][08]
--> remote IP address 10.64.64.64
--> pppd: �e[07][08]
--> primary   DNS address 139.7.30.126
--> pppd: �e[07][08]
--> secondary DNS address 139.7.30.125
--> pppd: �e[07][08]


As you can see, when the netreg is just ignored and start
with pppd we get a connnection.

Just dumping the debug state. Mabye someone has some input on this.

Thanks,
Daniel
[16:18:12.800815] ofonod[3277]: oFono version 1.21
[16:18:12.800865] ofonod[3277]: src/plugin.c:__ofono_plugin_init() 
[16:18:12.800883] ofonod[3277]: src/gprs-provision.c:ofono_gprs_provision_driver_register() driver: 0x77dc40 name: GPRS context provisioning
[16:18:12.800896] ofonod[3277]: plugins/push-notification.c:push_notification_init() 
[16:18:12.800909] ofonod[3277]: plugins/smart-messaging.c:smart_messaging_init() 
[16:18:12.800919] ofonod[3277]: plugins/emulator_fuzz.c:emulator_fuzz_init() 
[16:18:12.800931] ofonod[3277]: src/modem.c:ofono_modem_driver_register() driver: 0x77de80, name: stktest
[16:18:12.8