All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Prestwood <james.prestwood@linux.intel.com>
To: ofono@ofono.org
Subject: [PATCH 8/8] sim: added NetworkAccessIdentifier to SimManager
Date: Wed, 01 Nov 2017 10:33:48 -0700	[thread overview]
Message-ID: <1509557628-15121-8-git-send-email-james.prestwood@linux.intel.com> (raw)
In-Reply-To: <1509557628-15121-1-git-send-email-james.prestwood@linux.intel.com>

[-- Attachment #1: Type: text/plain, Size: 2712 bytes --]

EAP-SIM/AKA/AKA' requires the SIM's NAI to authenticate.
If available, this can be obtained from the ISIM AID.

If the ISIM AID is found a new AID based context will be
created and the EFIMPI file will be read from the SIM
which contains the NAI.
---
 src/sim.c | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/src/sim.c b/src/sim.c
index 8b466c9..f09c550 100644
--- a/src/sim.c
+++ b/src/sim.c
@@ -125,6 +125,7 @@ struct ofono_sim {
 	struct sim_fs *simfs_isim;
 	struct ofono_sim_context *context;
 	struct ofono_sim_context *early_context;
+	struct ofono_sim_context *isim_context;
 
 	unsigned char *iidf_image;
 	unsigned int *iidf_watch_ids;
@@ -136,6 +137,7 @@ struct ofono_sim {
 	unsigned int hfp_watch;
 
 	GSList *aid_sessions;
+	char *nai;
 };
 
 struct msisdn_set_request {
@@ -407,6 +409,10 @@ static DBusMessage *sim_get_properties(DBusConnection *conn,
 		ofono_dbus_dict_append(&dict, "ServiceProviderName",
 					DBUS_TYPE_STRING, &sim->spn);
 
+	if (sim->nai)
+		ofono_dbus_dict_append(&dict, "NetworkAccessIdentifier",
+					DBUS_TYPE_STRING, &sim->nai);
+
 	fdn = sim->fixed_dialing;
 	ofono_dbus_dict_append(&dict, "FixedDialing", DBUS_TYPE_BOOLEAN, &fdn);
 
@@ -1456,6 +1462,25 @@ static void sim_set_ready(struct ofono_sim *sim)
 	call_state_watches(sim);
 }
 
+static void impi_read_cb(int ok, int total_length, int record,
+		const unsigned char *data,
+		int record_length, void *userdata)
+{
+	struct ofono_sim *sim = userdata;
+
+	if (!ok) {
+		DBG("error reading IMPI");
+		return;
+	}
+
+	if (data[0] != 0x80) {
+		DBG("invalid TLV tag 0x%02x", data[0]);
+		return;
+	}
+
+	sim->nai = g_strndup((const char *)data + 2, data[1]);
+}
+
 static void discover_apps_cb(const struct ofono_error *error,
 		const unsigned char *dataobj,
 		int len, void *data)
@@ -1484,6 +1509,12 @@ static void discover_apps_cb(const struct ofono_error *error,
 			 * the FS structure so the ISIM EF's can be accessed.
 			 */
 			sim->simfs_isim = sim_fs_new(sim, sim->driver);
+			sim->isim_context = ofono_sim_context_create_isim(
+					sim);
+			/* attempt to get the NAI from EFimpi */
+			ofono_sim_read_bytes(sim->isim_context,
+					SIM_ISIM_EFIMPI_FILEID, 0, 255, NULL,
+					0, impi_read_cb, sim);
 		}
 
 		g_free(app);
@@ -2547,6 +2578,14 @@ static void sim_free_main_state(struct ofono_sim *sim)
 		sim->context = NULL;
 	}
 
+	if (sim->isim_context) {
+		ofono_sim_context_free(sim->isim_context);
+		sim->isim_context = NULL;
+	}
+
+	if (sim->nai)
+		g_free(sim->nai);
+
 	if (sim->aid_sessions)
 		g_slist_free(sim->aid_sessions);
 }
-- 
2.7.4


  parent reply	other threads:[~2017-11-01 17:33 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-01 17:33 [PATCH 1/8] simutil: Added ISIM elementary file ID's James Prestwood
2017-11-01 17:33 ` [PATCH 2/8] sim: header definitions for AID session APIs James Prestwood
2017-11-02 16:55   ` Denis Kenzior
2017-11-01 17:33 ` [PATCH 3/8] sim: AID session management James Prestwood
2017-11-02 17:10   ` Denis Kenzior
2017-11-01 17:33 ` [PATCH 4/8] atmodem: implement new driver APIs for AID sessions James Prestwood
2017-11-01 17:33 ` [PATCH 5/8] simfs: read files from specific AID's James Prestwood
2017-11-01 17:33 ` [PATCH 6/8] sim: header definitions for AID sim context API James Prestwood
2017-11-01 17:33 ` [PATCH 7/8] sim: implement create context with AID James Prestwood
2017-11-01 17:33 ` James Prestwood [this message]
2017-11-02 16:40 ` [PATCH 1/8] simutil: Added ISIM elementary file ID's Denis Kenzior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1509557628-15121-8-git-send-email-james.prestwood@linux.intel.com \
    --to=james.prestwood@linux.intel.com \
    --cc=ofono@ofono.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.