[PATCH 1/1] sim: fix segfault in sim atom

2019-03-06 Thread Anirudh Gargi
While adding the sim pin cache feature, pin_name could cause issue in
cases when sim pin is not there.

log:
ofonod[27810]: drivers/atmodem/sim.c:at_cpin_cb() crsm_pin_cb: READY
ofonod[27810]: src/sim.c:sim_pin_query_cb() sim->pin_type: 0, pin_type: 0
ofonod[27810]: Aborting (signal 11) [./src/ofonod]
ofonod[27810]:  backtrace 
ofonod[27810]: #0  0x7fb7a7586cb0 in /lib/x86_64-linux-gnu/libc.so.6
ofonod[27810]: #1  0x7fb7a7693cd8 in /lib/x86_64-linux-gnu/libc.so.6
ofonod[27810]: #2  0x4d899b in sim_pin_query_cb() at src/sim.c:3174
ofonod[27810]: #3  0x4649e7 in at_cpin_cb() at drivers/atmodem/sim.c:1304
ofonod[27810]: #4  0x4a5d70 in at_chat_finish_command() at gatchat/gatchat.c:462
---
 src/sim.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/sim.c b/src/sim.c
index 104ddd1..c6ea4b0 100644
--- a/src/sim.c
+++ b/src/sim.c
@@ -3127,7 +3127,7 @@ static void sim_pin_query_cb(const struct ofono_error 
*error,
DBusConnection *conn = ofono_dbus_get_connection();
const char *path = __ofono_atom_get_path(sim->atom);
struct cached_pin *cpins = pin_cache_lookup(sim->iccid);
-   const char *pin_name;
+   const char *pin_name = sim_passwd_name(pin_type);
char **locked_pins;
gboolean lock_changed;
 
@@ -3140,7 +3140,6 @@ static void sim_pin_query_cb(const struct ofono_error 
*error,
 
if (sim->pin_type != pin_type) {
sim->pin_type = pin_type;
-   pin_name = sim_passwd_name(pin_type);
 
if (pin_type != OFONO_SIM_PASSWORD_NONE &&
password_is_pin(pin_type) == FALSE)
-- 
2.7.4

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


[PATCH] xmm7xxx: enable sms and phonebook support

2018-10-03 Thread Anirudh Gargi
Enable SMS and Phonebook atom for the xmm7xxx series modem.
SMS send and CREG eutran states fixed in atmodem driver to support
sms and phonebook feature for xmm7xxx based modems.
---
 plugins/xmm7xxx.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/plugins/xmm7xxx.c b/plugins/xmm7xxx.c
index 9db87ad..a6dd097 100644
--- a/plugins/xmm7xxx.c
+++ b/plugins/xmm7xxx.c
@@ -50,6 +50,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include 
 #include 
@@ -128,13 +130,19 @@ static void switch_sim_state_status(struct ofono_modem 
*modem, int status)
break;
case 2: /* SIM inserted, PIN verification not needed - READY */
case 3: /* SIM inserted, PIN verified - READY */
-   case 7:
+   case 7: /* SIM inserted, SMS and phonebook - READY */
if (data->have_sim == FALSE) {
ofono_sim_inserted_notify(data->sim, TRUE);
data->have_sim = TRUE;
}
 
ofono_sim_initialized_notify(data->sim);
+   if (data->sms_phonebook_added == FALSE) {
+   ofono_phonebook_create(modem, 0, "atmodem", data->chat);
+   ofono_sms_create(modem, 0, "atmodem", data->chat);
+   data->sms_phonebook_added = TRUE;
+   }
+
break;
default:
ofono_warn("Unknown SIM state %d received", status);
-- 
2.7.4

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


[PATCH] gprs: fix seg fault in case of NULL callback

2018-10-01 Thread Anirudh Gargi
In case of AT callback if callback handler is NULL, check for null
before calling the success macro.

Logs:
ofonod[32496]: src/network.c:current_operator_callback() 0x157ad60, (nil)
ofonod[32496]: src/gprs.c:netreg_status_changed() 0
ofonod[32496]: src/gprs.c:gprs_netreg_update() attach: 0, driver_attached: 1
ofonod[32496]: src/gprs.c:ofono_gprs_detached_notify() /xmm7xxx_0
ofonod[32496]: drivers/ifxmodem/gprs-context.c:ifx_gprs_detach_shutdown()
ofonod[32496]: drivers/ifxmodem/gprs-context.c:ifx_gprs_deactivate_primary() 
cid 0
ofonod[32496]: src/gprs.c:ofono_gprs_detached_notify() /xmm7xxx_0
ofonod[32496]: src/gprs.c:gprs_attach_callback() /xmm7xxx_0 error = 0
ofonod[32496]: drivers/ifxmodem/gprs-context.c:deactivate_cb() ok 0
ofonod[32496]: Aborting (signal 11) [./../src/ofonod]
ofonod[32496]:  backtrace 
ofonod[32496]: +++
---
 drivers/ifxmodem/gprs-context.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/ifxmodem/gprs-context.c b/drivers/ifxmodem/gprs-context.c
index 43e81c5..885e41b 100644
--- a/drivers/ifxmodem/gprs-context.c
+++ b/drivers/ifxmodem/gprs-context.c
@@ -514,6 +514,9 @@ static void deactivate_cb(gboolean ok, GAtResult *result, 
gpointer user_data)
if (gcd->vendor != OFONO_VENDOR_XMM)
g_at_chat_resume(gcd->chat);
 
+   if (!gcd->cb)
+   return;
+
CALLBACK_WITH_SUCCESS(gcd->cb, gcd->cb_data);
 }
 
-- 
2.7.4

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


[PATCH] sms: allow sms send for EUTRAN sms only state

2018-09-27 Thread Anirudh Gargi
Patch to be considered, if support for EUTRAN SMS states accepted.

SMS registered flag while sending sms to consider the new EUTRAN
registered status also.
---
 src/sms.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/sms.c b/src/sms.c
index b86158e..c604e05 100644
--- a/src/sms.c
+++ b/src/sms.c
@@ -782,6 +782,8 @@ static void netreg_status_watch(int status, int lac, int 
ci, int tech,
switch (status) {
case NETWORK_REGISTRATION_STATUS_REGISTERED:
case NETWORK_REGISTRATION_STATUS_ROAMING:
+   case NETWORK_REGISTRATION_STATUS_REGISTERED_SMS_EUTRAN:
+   case NETWORK_REGISTRATION_STATUS_ROAMING_SMS_EUTRAN:
sms->registered = TRUE;
break;
default:
-- 
2.7.4

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


[PATCH] network: add support eutran sms only states

2018-09-27 Thread Anirudh Gargi
EUTRAN SMS states mapped to registered and roaming respectively.
For the new CREG status (9/10) of CREG, it can be map to a new Dbus
CSFB property.

Added clarity in API doc for voice calling in case of lte.
---
 doc/network-api.txt |  4 +++-
 src/common.c|  4 
 src/common.h| 19 +--
 3 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/doc/network-api.txt b/doc/network-api.txt
index 83a2bc0..9c367c7 100644
--- a/doc/network-api.txt
+++ b/doc/network-api.txt
@@ -77,7 +77,9 @@ Propertiesstring Mode [readonly]
 
string Status [readonly]
 
-   The current registration status of a modem.
+   The current registration status of a modem. In case
+   technology is 'lte', 'registered' and 'roaming' may
+   not necessarily mean voice calling available.
 
The possible values are:
"unregistered"  Not registered to any network
diff --git a/src/common.c b/src/common.c
index 3ccaf7c..0db412a 100644
--- a/src/common.c
+++ b/src/common.c
@@ -669,6 +669,10 @@ const char *registration_status_to_string(int status)
return "unknown";
case NETWORK_REGISTRATION_STATUS_ROAMING:
return "roaming";
+   case NETWORK_REGISTRATION_STATUS_REGISTERED_SMS_EUTRAN:
+   return "registered";
+   case NETWORK_REGISTRATION_STATUS_ROAMING_SMS_EUTRAN:
+   return "roaming";
}
 
return "";
diff --git a/src/common.h b/src/common.h
index 1b6b01d..f7bd3cb 100644
--- a/src/common.h
+++ b/src/common.h
@@ -37,12 +37,19 @@ enum access_technology {
 
 /* 27.007 Section 7.2  */
 enum network_registration_status {
-   NETWORK_REGISTRATION_STATUS_NOT_REGISTERED =0,
-   NETWORK_REGISTRATION_STATUS_REGISTERED =1,
-   NETWORK_REGISTRATION_STATUS_SEARCHING = 2,
-   NETWORK_REGISTRATION_STATUS_DENIED =3,
-   NETWORK_REGISTRATION_STATUS_UNKNOWN =   4,
-   NETWORK_REGISTRATION_STATUS_ROAMING =   5,
+   NETWORK_REGISTRATION_STATUS_NOT_REGISTERED =0,
+   NETWORK_REGISTRATION_STATUS_REGISTERED =1,
+   NETWORK_REGISTRATION_STATUS_SEARCHING = 2,
+   NETWORK_REGISTRATION_STATUS_DENIED =3,
+   NETWORK_REGISTRATION_STATUS_UNKNOWN =   4,
+   NETWORK_REGISTRATION_STATUS_ROAMING =   5,
+   NETWORK_REGISTRATION_STATUS_REGISTERED_SMS_EUTRAN = 6,
+   NETWORK_REGISTRATION_STATUS_ROAMING_SMS_EUTRAN =7,
+   /*
+* Add along with new CSFB Dbus property.
+   NETWORK_REGISTRATION_STATUS_REGISTERED_NO_CSFB_EUTRAN = 9,
+   NETWORK_REGISTRATION_STATUS_ROAMING_NO_CSFB_EUTRAN =10,
+   */
 };
 
 /* 27.007 Section 7.3  */
-- 
2.7.4

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


[PATCH] atmodem: add EUTRAN tech for creg read status

2018-09-27 Thread Anirudh Gargi
Add handling for CREG's status to get the technology type. CREG
notify URC does not need additional handling as 'AcT' is mapped
one-on-one to tech.
---
 drivers/atmodem/network-registration.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/atmodem/network-registration.c 
b/drivers/atmodem/network-registration.c
index 0854cd1..789397e 100644
--- a/drivers/atmodem/network-registration.c
+++ b/drivers/atmodem/network-registration.c
@@ -228,6 +228,10 @@ static void at_creg_cb(gboolean ok, GAtResult *result, 
gpointer user_data)
if ((status == 1 || status == 5) && (tech == -1))
tech = nd->tech;
 
+   /* 6-10 is EUTRAN, with 8 being emergency bearer case */
+   if((status > 5) && (tech == -1))
+   tech = ACCESS_TECHNOLOGY_EUTRAN;
+
cb(, status, lac, ci, tech, cbd->data);
 }
 
-- 
2.7.4

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


[PATCH] atmodem: add AT+CREG handling for lte status

2018-09-11 Thread Anirudh Gargi
added CREG 'status' 6 and 7 for sms only registered state on E-UTRAN
for  CREG cmd reply callback and URC notfiy.
---
 drivers/atmodem/network-registration.c | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/atmodem/network-registration.c 
b/drivers/atmodem/network-registration.c
index 0854cd1..c0ec8c7 100644
--- a/drivers/atmodem/network-registration.c
+++ b/drivers/atmodem/network-registration.c
@@ -228,6 +228,10 @@ static void at_creg_cb(gboolean ok, GAtResult *result, 
gpointer user_data)
if ((status == 1 || status == 5) && (tech == -1))
tech = nd->tech;
 
+   /* Handle EUTRAN cases */
+   if ((status == 6 || status == 7) && (tech == -1))
+   tech = ACCESS_TECHNOLOGY_EUTRAN;
+
cb(, status, lac, ci, tech, cbd->data);
 }
 
@@ -1522,8 +1526,11 @@ static void creg_notify(GAtResult *result, gpointer 
user_data)
, , , nd->vendor) == FALSE)
return;
 
-   if (status != 1 && status != 5)
-   goto notify;
+   /* Not camped case */
+   if (status != 1 && status != 5) {
+   if (status != 6 && status != 7)
+   goto notify;
+   }
 
tq = g_try_new0(struct tech_query, 1);
if (tq == NULL)
@@ -1569,6 +1576,9 @@ static void creg_notify(GAtResult *result, gpointer 
user_data)
if ((status == 1 || status == 5) && tech == -1)
tech = nd->tech;
 
+   if ((status == 6 || status == 7) && tech == -1)
+   tech = ACCESS_TECHNOLOGY_EUTRAN;
+
 notify:
ofono_netreg_status_notify(netreg, status, lac, ci, tech);
 }
-- 
2.7.4

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


[PATCH] sms: fix send sms in case of lte registration

2018-09-10 Thread Anirudh Gargi
CREG status 6 and 7 added in network registration status, sms atom
to consider new states also.
---
 src/common.h | 14 --
 src/sms.c|  2 ++
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/common.h b/src/common.h
index 1b6b01d..b826228 100644
--- a/src/common.h
+++ b/src/common.h
@@ -37,12 +37,14 @@ enum access_technology {
 
 /* 27.007 Section 7.2  */
 enum network_registration_status {
-   NETWORK_REGISTRATION_STATUS_NOT_REGISTERED =0,
-   NETWORK_REGISTRATION_STATUS_REGISTERED =1,
-   NETWORK_REGISTRATION_STATUS_SEARCHING = 2,
-   NETWORK_REGISTRATION_STATUS_DENIED =3,
-   NETWORK_REGISTRATION_STATUS_UNKNOWN =   4,
-   NETWORK_REGISTRATION_STATUS_ROAMING =   5,
+   NETWORK_REGISTRATION_STATUS_NOT_REGISTERED =0,
+   NETWORK_REGISTRATION_STATUS_REGISTERED =1,
+   NETWORK_REGISTRATION_STATUS_SEARCHING = 2,
+   NETWORK_REGISTRATION_STATUS_DENIED =3,
+   NETWORK_REGISTRATION_STATUS_UNKNOWN =   4,
+   NETWORK_REGISTRATION_STATUS_ROAMING =   5,
+   NETWORK_REGISTRATION_STATUS_REGISTERED_SMS_EUTRAN = 6,
+   NETWORK_REGISTRATION_STATUS_ROAMING_SMS_EUTRAN =7,
 };
 
 /* 27.007 Section 7.3  */
diff --git a/src/sms.c b/src/sms.c
index b86158e..c604e05 100644
--- a/src/sms.c
+++ b/src/sms.c
@@ -782,6 +782,8 @@ static void netreg_status_watch(int status, int lac, int 
ci, int tech,
switch (status) {
case NETWORK_REGISTRATION_STATUS_REGISTERED:
case NETWORK_REGISTRATION_STATUS_ROAMING:
+   case NETWORK_REGISTRATION_STATUS_REGISTERED_SMS_EUTRAN:
+   case NETWORK_REGISTRATION_STATUS_ROAMING_SMS_EUTRAN:
sms->registered = TRUE;
break;
default:
-- 
2.7.4

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