Re: [PATCH v2 2/3] sim: Create new dbus method to clear the forbidden network operator list
Denis Kenzior <[email protected]> Thu, 3 Jul 2025 12:51:00 -0500
| Newsgroups | dev.linux.lists.ofono |
|---|---|
| Message-ID | <[email protected]> |
Hi Sean,
On 7/3/25 6:48 AM, Sean Nyekjaer wrote:
> To clear the list:
> busctl call org.ofono /sim76xx_0 org.ofono.SimManager
> ClearForbiddenNetworkOperators
> ---
> src/sim.c | 43 +++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 43 insertions(+)
>
> diff --git a/src/sim.c b/src/sim.c
> index 7d9a180abd0c5b7adedebfe7026125dbada9752e..4f72bd9ac1abf484fed77008c03cae9186b63c9e 100644
> --- a/src/sim.c
> +++ b/src/sim.c
> @@ -143,6 +143,11 @@ struct msisdn_set_request {
> DBusMessage *msg;
> };
>
> +struct fplmn_set_request {
> + struct ofono_sim *sim;
> + DBusMessage *msg;
> +};
> +
I don't think this is used?
> struct service_number {
> char *id;
> struct ofono_phone_number ph;
> @@ -649,6 +654,41 @@ static gboolean set_own_numbers(struct ofono_sim *sim,
> return TRUE;
> }
>
> +static void sim_efplmn_cb(const struct ofono_error *error, void *data)
> +{
> + struct ofono_sim *sim = data;
> + DBusMessage *reply;
> +
> + if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
> + ofono_error("Unable to clear Forbidden PLMN");
> + reply = __ofono_error_failed(sim->pending);
> + } else {
> + reply = dbus_message_new_method_return(sim->pending);
> + }
> +
> + __ofono_dbus_pending_reply(&sim->pending, reply);
> +}
> +
> +static DBusMessage *sim_clear_forbidden_plmn(DBusConnection *conn, DBusMessage *msg,
> + void *data)
> +{
> + struct ofono_sim *sim = data;
> + DBusMessageIter iter;
> + DBusMessageIter var;
> + static uint8_t plmn_list[12] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
What if FPLMN isn't 12 bytes long? Have you tried with a few different SIMs?
A safer approach would be to use something like sim_fs_read_info to obtain the
FPLMN length, then write the entire file's contents as FFs.
> +
> + if (sim->pending)
> + return __ofono_error_busy(msg);
> +
> + sim->pending = dbus_message_ref(msg);
> +
> + sim->driver->write_file_transparent(sim, SIM_EF_PLMN_FILEID, 0, 12,
> + plmn_list, NULL, 0, sim_efplmn_cb, sim);
Careful, there might not be an actual implementation of 'write_file_transparent'
provided.
> +
> + return NULL;
> +}
> +
> static void sim_set_slot_callback(const struct ofono_error *error, void *data)
> {
> struct ofono_sim *sim = data;
> @@ -687,6 +727,7 @@ static DBusMessage *sim_set_property(DBusConnection *conn, DBusMessage *msg,
> DBusMessageIter var;
> DBusMessageIter var_elem;
> const char *name, *value;
> + ofono_bool_t clear_fplmn;
What's this for?
>
> if (!dbus_message_iter_init(msg, &iter))
> return __ofono_error_invalid_args(msg);
> @@ -1297,6 +1338,8 @@ static const GDBusMethodTable sim_methods[] = {
> { GDBUS_ASYNC_METHOD("SetProperty",
> GDBUS_ARGS({ "property", "s" }, { "value", "v" }),
> NULL, sim_set_property) },
> + { GDBUS_ASYNC_METHOD("ClearForbiddenNetworkOperators",
> + NULL, NULL, sim_clear_forbidden_plmn) },
> { GDBUS_ASYNC_METHOD("ChangePin",
> GDBUS_ARGS({ "type", "s" }, { "oldpin", "s" },
> { "newpin", "s" }), NULL,
>
Regards,
-Denis