summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2015-11-13 14:27:47 -0600
committerDenis Kenzior <denkenz@gmail.com>2015-11-13 14:27:47 -0600
commit659851b1b1934a62929cd02c3c4041bc7301e51d (patch)
treea3f9bc908bf0d2869153df14f2a7aec7a5fe3d2f
parent2a6e6df52cb30161cbe8239ec5f365685980f3fe (diff)
downloadofono-659851b1b1934a62929cd02c3c4041bc7301e51d.tar.bz2
rilmodem: Implement ril_cops_cb inline
-rw-r--r--drivers/rilmodem/network-registration.c62
1 files changed, 50 insertions, 12 deletions
diff --git a/drivers/rilmodem/network-registration.c b/drivers/rilmodem/network-registration.c
index fb3600fe..1a033e23 100644
--- a/drivers/rilmodem/network-registration.c
+++ b/drivers/rilmodem/network-registration.c
@@ -337,31 +337,69 @@ static void ril_cops_cb(struct ril_msg *message, gpointer user_data)
struct cb_data *cbd = user_data;
ofono_netreg_operator_cb_t cb = cbd->cb;
struct netreg_data *nd = cbd->user;
- struct reply_operator *reply;
struct ofono_network_operator op;
+ struct parcel rilp;
+ int num_params;
+ char *lalpha;
+ char *salpha;
+ char *numeric;
- if (message->error != RIL_E_SUCCESS) {
- ofono_error("%s: failed to retrive the current operator",
- __func__);
+ DBG("");
+
+ if (message->error != RIL_E_SUCCESS)
+ goto error;
+
+ /*
+ * Minimum message length is 16:
+ * - array size
+ * - 3 NULL strings
+ */
+ if (message->buf_len < 16) {
+ ofono_error("%s: invalid OPERATOR reply: "
+ "size too small (< 16): %d ",
+ __func__,
+ (int) message->buf_len);
goto error;
}
- reply = g_ril_reply_parse_operator(nd->ril, message);
- if (reply == NULL)
+ g_ril_init_parcel(message, &rilp);
+
+ num_params = parcel_r_int32(&rilp);
+ if (num_params != 3) {
+ ofono_error("%s: invalid OPERATOR reply: "
+ "number of params is %d; should be 3.",
+ __func__,
+ num_params);
goto error;
+ }
+
+ lalpha = parcel_r_string(&rilp);
+ salpha = parcel_r_string(&rilp);
+ numeric = parcel_r_string(&rilp);
- set_oper_name(reply->lalpha, reply->salpha, &op);
+ g_ril_append_print_buf(nd->ril,
+ "(lalpha=%s, salpha=%s, numeric=%s)",
+ lalpha, salpha, numeric);
- extract_mcc_mnc(reply->numeric, op.mcc, op.mnc);
+ g_ril_print_response(nd->ril, message);
+
+ if ((lalpha == NULL && salpha == NULL) || numeric == NULL) {
+ g_free(lalpha);
+ g_free(salpha);
+ g_free(numeric);
+ goto error;
+ }
- /* Set to current */
+ set_oper_name(lalpha, salpha, &op);
+ extract_mcc_mnc(numeric, op.mcc, op.mnc);
op.status = OPERATOR_STATUS_CURRENT;
op.tech = ril_tech_to_access_tech(nd->tech);
- CALLBACK_WITH_SUCCESS(cb, &op, cbd->data);
-
- g_ril_reply_free_operator(reply);
+ g_free(lalpha);
+ g_free(salpha);
+ g_free(numeric);
+ CALLBACK_WITH_SUCCESS(cb, &op, cbd->data);
return;
error: