static void inf_pin_retries_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; ofono_sim_pin_retries_cb_t cb = cbd->cb; struct sim_data *sd = cbd->user; struct parcel rilp; int32_t *data; int len; char *hex_dump; int expected; DBG(""); if (message->error != RIL_E_SUCCESS) { ofono_error("Reply failure: %s", ril_error_to_string(message->error)); goto error; } g_ril_init_parcel(message, &rilp); data = parcel_r_raw(&rilp, &len); if (data == NULL) { ofono_error("%s: malformed parcel", __func__); goto error; } hex_dump = encode_hex((unsigned char *) data, len, '\0'); g_ril_append_print_buf(sd->ril, "{%d,%s}", len, hex_dump); g_ril_print_response(sd->ril, message); g_free(hex_dump); expected = sizeof(int32_t) * 5; if (len < expected) { ofono_error("%s: reply too small", __func__); g_free(data); goto error; } /* First integer is INF_RIL_REQUEST_OEM_GET_REMAIN_SIM_PIN_ATTEMPTS */ sd->retries[OFONO_SIM_PASSWORD_SIM_PIN] = data[1]; sd->retries[OFONO_SIM_PASSWORD_SIM_PIN2] = data[2]; sd->retries[OFONO_SIM_PASSWORD_SIM_PUK] = data[3]; sd->retries[OFONO_SIM_PASSWORD_SIM_PUK2] = data[4]; g_free(data); CALLBACK_WITH_SUCCESS(cb, sd->retries, cbd->data); return; error: CALLBACK_WITH_FAILURE(cb, NULL, cbd->data); }
struct reply_oem_hook *g_ril_reply_oem_hook_raw(GRil *gril, const struct ril_msg *message) { struct reply_oem_hook *reply = NULL; struct parcel rilp; reply = g_try_malloc0(sizeof(*reply)); if (reply == NULL) { ofono_error("%s: out of memory", __func__); goto end; } g_ril_init_parcel(message, &rilp); reply->data = parcel_r_raw(&rilp, &(reply->length)); if (rilp.malformed) { ofono_error("%s: malformed parcel", __func__); g_ril_reply_free_oem_hook(reply); reply = NULL; goto end; } g_ril_append_print_buf(gril, "{%d", reply->length); if (reply->data != NULL) { char *hex_dump; hex_dump = encode_hex(reply->data, reply->length, '\0'); g_ril_append_print_buf(gril, "%s,%s", print_buf, hex_dump); g_free(hex_dump); } g_ril_append_print_buf(gril, "%s}", print_buf); g_ril_print_response(gril, message); end: return reply; }