summaryrefslogtreecommitdiffstats
path: root/src/simutil.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/simutil.c')
-rw-r--r--src/simutil.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/simutil.c b/src/simutil.c
index 1430ec32..51b1f5cc 100644
--- a/src/simutil.c
+++ b/src/simutil.c
@@ -398,3 +398,31 @@ const struct sim_eons_operator_info *sim_eons_lookup_with_lac(
{
return sim_eons_lookup_common(eons, mcc, mnc, TRUE, lac);
}
+
+gboolean sim_adn_parse(const unsigned char *data, int length,
+ struct ofono_phone_number *ph)
+{
+ int number_len;
+ int ton_npi;
+
+ if (length < 14)
+ return FALSE;
+
+ /* Skip Alpha-Identifier field */
+ data += length - 14;
+
+ number_len = *data++;
+ ton_npi = *data++;
+
+ if (number_len > 11 || ton_npi == 0xff)
+ return FALSE;
+
+ ph->type = bit_field(ton_npi, 4, 3);
+
+ /* BCD coded, however the TON/NPI is given by the first byte */
+ number_len = (number_len - 1) * 2;
+
+ extract_bcd_number(data, number_len, ph->number);
+
+ return TRUE;
+}