* [PATCH 01/20] Make stk_pdu_from_response use static buffers
@ 2010-06-07 10:08 Andrzej Zaborowski
2010-06-07 10:08 ` [PATCH 02/20] stkutil: Add SMS-PP Data Download envelope builder Andrzej Zaborowski
` (18 more replies)
0 siblings, 19 replies; 29+ messages in thread
From: Andrzej Zaborowski @ 2010-06-07 10:08 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 4362 bytes --]
---
src/stkutil.c | 36 ++++++++++++++++++++----------------
src/stkutil.h | 5 ++---
unit/test-stkutil.c | 15 ++++++++++-----
3 files changed, 32 insertions(+), 24 deletions(-)
diff --git a/src/stkutil.c b/src/stkutil.c
index 82d4e84..14958a8 100644
--- a/src/stkutil.c
+++ b/src/stkutil.c
@@ -3980,14 +3980,15 @@ static gboolean build_local_info(struct stk_tlv_builder *builder,
return FALSE;
}
-unsigned int stk_pdu_from_response(const struct stk_response *response,
- unsigned char *pdu, unsigned int size)
+const unsigned char *stk_pdu_from_response(const struct stk_response *response,
+ unsigned int *out_length)
{
struct stk_tlv_builder builder;
gboolean ok = TRUE;
unsigned char tag;
+ static unsigned char pdu[512];
- stk_tlv_builder_init(&builder, pdu, size);
+ stk_tlv_builder_init(&builder, pdu, sizeof(pdu));
/*
* Encode command details, they come in order with
@@ -3996,19 +3997,19 @@ unsigned int stk_pdu_from_response(const struct stk_response *response,
*/
tag = STK_DATA_OBJECT_TYPE_COMMAND_DETAILS;
if (stk_tlv_builder_open_container(&builder, TRUE, tag, FALSE) == FALSE)
- return 0;
+ return NULL;
if (stk_tlv_builder_append_byte(&builder, response->number) == FALSE)
- return 0;
+ return NULL;
if (stk_tlv_builder_append_byte(&builder, response->type) == FALSE)
- return 0;
+ return NULL;
if (stk_tlv_builder_append_byte(&builder, response->qualifier) == FALSE)
- return 0;
+ return NULL;
if (stk_tlv_builder_close_container(&builder) == FALSE)
- return 0;
+ return NULL;
/* TS 102 223 section 6.8 states:
* "For all COMPREHENSION-TLV objects with Min = N, the terminal
@@ -4022,19 +4023,19 @@ unsigned int stk_pdu_from_response(const struct stk_response *response,
*/
tag = STK_DATA_OBJECT_TYPE_DEVICE_IDENTITIES;
if (stk_tlv_builder_open_container(&builder, TRUE, tag, FALSE) == FALSE)
- return 0;
+ return NULL;
if (stk_tlv_builder_append_byte(&builder, response->src) == FALSE)
- return 0;
+ return NULL;
if (stk_tlv_builder_append_byte(&builder, response->dst) == FALSE)
- return 0;
+ return NULL;
if (stk_tlv_builder_close_container(&builder) == FALSE)
- return 0;
+ return NULL;
if (build_dataobj_result(&builder, &response->result, TRUE) != TRUE)
- return 0;
+ return NULL;
switch (response->type) {
case STK_COMMAND_TYPE_DISPLAY_TEXT:
@@ -4105,11 +4106,14 @@ unsigned int stk_pdu_from_response(const struct stk_response *response,
case STK_COMMAND_TYPE_LAUNCH_BROWSER:
break;
default:
- return 0;
+ return NULL;
};
if (ok != TRUE)
- return 0;
+ return NULL;
+
+ if (out_length)
+ *out_length = stk_tlv_builder_get_length(&builder);
- return stk_tlv_builder_get_length(&builder);
+ return pdu;
}
diff --git a/src/stkutil.h b/src/stkutil.h
index cc5801c..7dd0d6c 100644
--- a/src/stkutil.h
+++ b/src/stkutil.h
@@ -1176,6 +1176,5 @@ struct stk_command *stk_command_new_from_pdu(const unsigned char *pdu,
unsigned int len);
void stk_command_free(struct stk_command *command);
-/* Returns # of bytes written or zero on error */
-unsigned int stk_pdu_from_response(const struct stk_response *response,
- unsigned char *pdu, unsigned int size);
+const unsigned char *stk_pdu_from_response(const struct stk_response *response,
+ unsigned int *out_length);
diff --git a/unit/test-stkutil.c b/unit/test-stkutil.c
index fb354bd..eb50d17 100644
--- a/unit/test-stkutil.c
+++ b/unit/test-stkutil.c
@@ -13949,13 +13949,18 @@ struct terminal_response_test {
static void test_terminal_response_encoding(gconstpointer data)
{
const struct terminal_response_test *test = data;
- unsigned char buf[512];
- unsigned int len;
+ const unsigned char *pdu;
+ unsigned int pdu_len;
- len = stk_pdu_from_response(&test->response, buf, sizeof(buf));
+ pdu = stk_pdu_from_response(&test->response, &pdu_len);
+
+ if (test->pdu)
+ g_assert(pdu);
+ else
+ g_assert(pdu == NULL);
- g_assert(len == test->pdu_len);
- g_assert(memcmp(buf, test->pdu, len) == 0);
+ g_assert(pdu_len == test->pdu_len);
+ g_assert(memcmp(pdu, test->pdu, pdu_len) == 0);
}
static const unsigned char display_text_response_111[] = {
--
1.7.1.86.g0e460.dirty
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 02/20] stkutil: Add SMS-PP Data Download envelope builder
2010-06-07 10:08 [PATCH 01/20] Make stk_pdu_from_response use static buffers Andrzej Zaborowski
@ 2010-06-07 10:08 ` Andrzej Zaborowski
2010-06-07 10:08 ` [PATCH 03/20] test-stkutil: Tests for " Andrzej Zaborowski
` (17 subsequent siblings)
18 siblings, 0 replies; 29+ messages in thread
From: Andrzej Zaborowski @ 2010-06-07 10:08 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 5560 bytes --]
---
src/stkutil.c | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/stkutil.h | 17 +++++++++
2 files changed, 127 insertions(+), 0 deletions(-)
diff --git a/src/stkutil.c b/src/stkutil.c
index 14958a8..661cfc6 100644
--- a/src/stkutil.c
+++ b/src/stkutil.c
@@ -3142,6 +3142,20 @@ static gboolean stk_tlv_builder_init(struct stk_tlv_builder *iter,
return comprehension_tlv_builder_init(&iter->ctlv, pdu, size);
}
+static gboolean stk_tlv_builder_recurse(struct stk_tlv_builder *iter,
+ struct ber_tlv_builder *btlv,
+ unsigned char tag)
+{
+ iter->value = NULL;
+ iter->len = 0;
+
+ if (ber_tlv_builder_next(btlv, tag >> 6, (tag >> 5) & 1,
+ tag & 0x1f) != TRUE)
+ return FALSE;
+
+ return ber_tlv_builder_recurse_comprehension(btlv, &iter->ctlv);
+}
+
static gboolean stk_tlv_builder_open_container(struct stk_tlv_builder *iter,
gboolean cr,
unsigned char shorttag,
@@ -3322,6 +3336,27 @@ static inline gboolean stk_tlv_builder_append_bytes(struct stk_tlv_builder *iter
return TRUE;
}
+/* Described in TS 102.223 Section 8.1 */
+static gboolean build_dataobj_address(struct stk_tlv_builder *tlv,
+ const void *data, gboolean cr)
+{
+ const struct stk_address *addr = data;
+ unsigned char tag = STK_DATA_OBJECT_TYPE_ADDRESS;
+ unsigned int len;
+ unsigned char number[128];
+
+ if (addr->number == NULL)
+ return TRUE;
+
+ len = (strlen(addr->number) + 1) / 2;
+ sim_encode_bcd_number(addr->number, number);
+
+ return stk_tlv_builder_open_container(tlv, cr, tag, FALSE) &&
+ stk_tlv_builder_append_byte(tlv, addr->ton_npi) &&
+ stk_tlv_builder_append_bytes(tlv, number, len) &&
+ stk_tlv_builder_close_container(tlv);
+}
+
/* Described in TS 102.223 Section 8.6 */
static gboolean build_dataobj_item_id(struct stk_tlv_builder *tlv,
const void *data, gboolean cr)
@@ -3374,6 +3409,28 @@ static gboolean build_dataobj_result(struct stk_tlv_builder *tlv,
return stk_tlv_builder_close_container(tlv);
}
+/* Described in TS 131.111 Section 8.13 */
+static gboolean build_dataobj_gsm_sms_tpdu(struct stk_tlv_builder *tlv,
+ const void *data, gboolean cr)
+{
+ const struct sms_deliver *msg = data;
+ struct sms sms;
+ unsigned char tag = STK_DATA_OBJECT_TYPE_GSM_SMS_TPDU;
+ unsigned char tpdu[165];
+ int tpdu_len;
+
+ sms.type = SMS_TYPE_DELIVER;
+ memset(&sms.sc_addr, 0, sizeof(sms.sc_addr));
+ memcpy(&sms.deliver, msg, sizeof(sms.deliver));
+
+ if (sms_encode(&sms, NULL, &tpdu_len, tpdu) == FALSE)
+ return FALSE;
+
+ return stk_tlv_builder_open_container(tlv, cr, tag, TRUE) &&
+ stk_tlv_builder_append_bytes(tlv, tpdu + 1, tpdu_len) &&
+ stk_tlv_builder_close_container(tlv);
+}
+
/* Defined in TS 102.223 Section 8.15 */
static gboolean build_dataobj_text(struct stk_tlv_builder *tlv,
const void *data, gboolean cr)
@@ -4117,3 +4174,56 @@ const unsigned char *stk_pdu_from_response(const struct stk_response *response,
return pdu;
}
+
+/* Described in TS 102.223 Section 8.7 */
+static gboolean build_envelope_dataobj_device_ids(struct stk_tlv_builder *tlv,
+ const void *data, gboolean cr)
+{
+ const struct stk_envelope *envelope = data;
+ unsigned char tag = STK_DATA_OBJECT_TYPE_DEVICE_IDENTITIES;
+
+ return stk_tlv_builder_open_container(tlv, cr, tag, FALSE) &&
+ stk_tlv_builder_append_byte(tlv, envelope->src) &&
+ stk_tlv_builder_append_byte(tlv, envelope->dst) &&
+ stk_tlv_builder_close_container(tlv);
+}
+
+const unsigned char *stk_pdu_from_envelope(const struct stk_envelope *envelope,
+ unsigned int *out_length)
+{
+ struct ber_tlv_builder btlv;
+ struct stk_tlv_builder builder;
+ gboolean ok = TRUE;
+ static unsigned char buffer[512];
+ unsigned char *pdu;
+
+ if (ber_tlv_builder_init(&btlv, buffer, sizeof(buffer)) != TRUE)
+ return NULL;
+
+ if (stk_tlv_builder_recurse(&builder, &btlv, envelope->type) != TRUE)
+ return NULL;
+
+ switch (envelope->type) {
+ case STK_ENVELOPE_TYPE_SMS_PP_DOWNLOAD:
+ ok = build_dataobj(&builder,
+ build_envelope_dataobj_device_ids,
+ DATAOBJ_FLAG_CR,
+ envelope,
+ build_dataobj_address, 0,
+ &envelope->sms_pp_download.address,
+ build_dataobj_gsm_sms_tpdu,
+ DATAOBJ_FLAG_CR,
+ &envelope->sms_pp_download.message,
+ NULL);
+ break;
+ default:
+ return NULL;
+ };
+
+ if (ok != TRUE)
+ return NULL;
+
+ ber_tlv_builder_optimize(&btlv, &pdu, out_length);
+
+ return pdu;
+}
diff --git a/src/stkutil.h b/src/stkutil.h
index 7dd0d6c..cc293ca 100644
--- a/src/stkutil.h
+++ b/src/stkutil.h
@@ -1172,9 +1172,26 @@ struct stk_response {
void (*destructor)(struct stk_response *response);
};
+/* ENVELOPEs defined in TS 102.223 Section 7 */
+struct stk_envelope_sms_pp_download {
+ struct stk_address address;
+ struct sms_deliver message;
+};
+
+struct stk_envelope {
+ enum stk_envelope_type type;
+ enum stk_device_identity_type src;
+ enum stk_device_identity_type dst;
+ union {
+ struct stk_envelope_sms_pp_download sms_pp_download;
+ };
+};
+
struct stk_command *stk_command_new_from_pdu(const unsigned char *pdu,
unsigned int len);
void stk_command_free(struct stk_command *command);
const unsigned char *stk_pdu_from_response(const struct stk_response *response,
unsigned int *out_length);
+const unsigned char *stk_pdu_from_envelope(const struct stk_envelope *envelope,
+ unsigned int *out_length);
--
1.7.1.86.g0e460.dirty
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 03/20] test-stkutil: Tests for SMS-PP Data Download envelope builder
2010-06-07 10:08 [PATCH 01/20] Make stk_pdu_from_response use static buffers Andrzej Zaborowski
2010-06-07 10:08 ` [PATCH 02/20] stkutil: Add SMS-PP Data Download envelope builder Andrzej Zaborowski
@ 2010-06-07 10:08 ` Andrzej Zaborowski
2010-06-07 10:08 ` [PATCH 04/20] stkutil: Add CBS-PP " Andrzej Zaborowski
` (16 subsequent siblings)
18 siblings, 0 replies; 29+ messages in thread
From: Andrzej Zaborowski @ 2010-06-07 10:08 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 5630 bytes --]
---
unit/test-stkutil.c | 171 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 171 insertions(+), 0 deletions(-)
diff --git a/unit/test-stkutil.c b/unit/test-stkutil.c
index eb50d17..d7b0c25 100644
--- a/unit/test-stkutil.c
+++ b/unit/test-stkutil.c
@@ -17890,6 +17890,167 @@ static const struct terminal_response_test launch_browser_response_data_411b = {
},
};
+struct envelope_test {
+ const unsigned char *pdu;
+ unsigned int pdu_len;
+ struct stk_envelope envelope;
+};
+
+static void test_envelope_encoding(gconstpointer data)
+{
+ const struct envelope_test *test = data;
+ const unsigned char *pdu;
+ unsigned int pdu_len;
+
+ pdu = stk_pdu_from_envelope(&test->envelope, &pdu_len);
+
+ if (test->pdu)
+ g_assert(pdu);
+ else
+ g_assert(pdu == NULL);
+
+ g_assert(pdu_len == test->pdu_len);
+ g_assert(memcmp(pdu, test->pdu, pdu_len) == 0);
+}
+
+static const unsigned char sms_pp_data_download_161[] = {
+ 0xd1, 0x2d, 0x82, 0x02, 0x83, 0x81, 0x06, 0x09,
+ 0x91, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
+ 0xf8, 0x8b, 0x1c, 0x04, 0x04, 0x91, 0x21, 0x43,
+ 0x7f, 0x16, 0x89, 0x10, 0x10, 0x00, 0x00, 0x00,
+ 0x00, 0x0d, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x20,
+ 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
+};
+
+static const struct envelope_test sms_pp_data_download_data_161 = {
+ .pdu = sms_pp_data_download_161,
+ .pdu_len = sizeof(sms_pp_data_download_161),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_SMS_PP_DOWNLOAD,
+ .src = STK_DEVICE_IDENTITY_TYPE_NETWORK,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .sms_pp_download = {
+ .address = {
+ .ton_npi = 0x91, /* Intl, ISDN */
+ .number = "112233445566778",
+ },
+ .message = {
+ .oaddr = {
+ .number_type =
+ SMS_NUMBER_TYPE_INTERNATIONAL,
+ .numbering_plan =
+ SMS_NUMBERING_PLAN_ISDN,
+ .address = "1234",
+ },
+ .pid = SMS_PID_TYPE_USIM_DOWNLOAD,
+ .dcs = 0x16, /* Uncompressed, Class 2, 8-bit */
+ .scts = {
+ .year = 98,
+ .month = 1,
+ .day = 1,
+ },
+ .udl = 13,
+ .ud = "Short Message",
+ },
+ }},
+ },
+};
+
+static const unsigned char sms_pp_data_download_162[] = {
+ 0xd1, 0x2d, 0x82, 0x02, 0x83, 0x81, 0x06, 0x09,
+ 0x91, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
+ 0xf8, 0x8b, 0x1c, 0x04, 0x04, 0x91, 0x21, 0x43,
+ 0x7f, 0xf6, 0x89, 0x10, 0x10, 0x00, 0x00, 0x00,
+ 0x00, 0x0d, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x20,
+ 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
+};
+
+static const struct envelope_test sms_pp_data_download_data_162 = {
+ .pdu = sms_pp_data_download_162,
+ .pdu_len = sizeof(sms_pp_data_download_162),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_SMS_PP_DOWNLOAD,
+ .src = STK_DEVICE_IDENTITY_TYPE_NETWORK,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .sms_pp_download = {
+ .address = {
+ .ton_npi = 0x91, /* Intl, ISDN */
+ .number = "112233445566778",
+ },
+ .message = {
+ .oaddr = {
+ .number_type =
+ SMS_NUMBER_TYPE_INTERNATIONAL,
+ .numbering_plan =
+ SMS_NUMBERING_PLAN_ISDN,
+ .address = "1234",
+ },
+ .pid = SMS_PID_TYPE_USIM_DOWNLOAD,
+ .dcs = 0xf6, /* Data, Class 2, 8-bit */
+ .scts = {
+ .year = 98,
+ .month = 1,
+ .day = 1,
+ },
+ .udl = 13,
+ .ud = "Short Message",
+ },
+ }},
+ },
+};
+
+static const unsigned char sms_pp_data_download_182[] = {
+ 0xd1, 0x3e, 0x82, 0x02, 0x83, 0x81, 0x06, 0x09,
+ 0x91, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
+ 0xf8, 0x8b, 0x2d, 0x44, 0x04, 0x91, 0x21, 0x43,
+ 0x7f, 0xf6, 0x89, 0x10, 0x10, 0x00, 0x00, 0x00,
+ 0x00, 0x1e, 0x02, 0x70, 0x00, 0x00, 0x19, 0x00,
+ 0x0d, 0x00, 0x00, 0x00, 0x00, 0xbf, 0xff, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0xdc, 0xdc,
+ 0xdc, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc,
+};
+
+static const struct envelope_test sms_pp_data_download_data_182 = {
+ .pdu = sms_pp_data_download_182,
+ .pdu_len = sizeof(sms_pp_data_download_182),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_SMS_PP_DOWNLOAD,
+ .src = STK_DEVICE_IDENTITY_TYPE_NETWORK,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .sms_pp_download = {
+ .address = {
+ .ton_npi = 0x91, /* Intl, ISDN */
+ .number = "112233445566778",
+ },
+ .message = {
+ .udhi = TRUE,
+ .oaddr = {
+ .number_type =
+ SMS_NUMBER_TYPE_INTERNATIONAL,
+ .numbering_plan =
+ SMS_NUMBERING_PLAN_ISDN,
+ .address = "1234",
+ },
+ .pid = SMS_PID_TYPE_USIM_DOWNLOAD,
+ .dcs = 0xf6, /* Data, Class 2, 8-bit */
+ .scts = {
+ .year = 98,
+ .month = 1,
+ .day = 1,
+ },
+ .udl = 30,
+ .ud = {
+ 0x02, 0x70, 0x00, 0x00, 0x19, 0x00,
+ 0x0d, 0x00, 0x00, 0x00, 0x00, 0xbf,
+ 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0xdc, 0xdc, 0xdc, 0xdc,
+ 0xdc, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc,
+ },
+ },
+ }},
+ },
+};
+
int main(int argc, char **argv)
{
g_test_init(&argc, &argv, NULL);
@@ -19560,5 +19721,15 @@ int main(int argc, char **argv)
&launch_browser_response_data_411b,
test_terminal_response_encoding);
+ g_test_add_data_func("/teststk/SMS-PP data download 1.6.1",
+ &sms_pp_data_download_data_161,
+ test_envelope_encoding);
+ g_test_add_data_func("/teststk/SMS-PP data download 1.6.2",
+ &sms_pp_data_download_data_162,
+ test_envelope_encoding);
+ g_test_add_data_func("/teststk/SMS-PP data download 1.8.2",
+ &sms_pp_data_download_data_182,
+ test_envelope_encoding);
+
return g_test_run();
}
--
1.7.1.86.g0e460.dirty
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 04/20] stkutil: Add CBS-PP Data Download envelope builder
2010-06-07 10:08 [PATCH 01/20] Make stk_pdu_from_response use static buffers Andrzej Zaborowski
2010-06-07 10:08 ` [PATCH 02/20] stkutil: Add SMS-PP Data Download envelope builder Andrzej Zaborowski
2010-06-07 10:08 ` [PATCH 03/20] test-stkutil: Tests for " Andrzej Zaborowski
@ 2010-06-07 10:08 ` Andrzej Zaborowski
2010-06-07 10:08 ` [PATCH 05/20] stk: Use envelope encoding utility from stkutil.c Andrzej Zaborowski
` (15 subsequent siblings)
18 siblings, 0 replies; 29+ messages in thread
From: Andrzej Zaborowski @ 2010-06-07 10:08 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2122 bytes --]
---
src/stkutil.c | 26 ++++++++++++++++++++++++++
src/stkutil.h | 5 +++++
2 files changed, 31 insertions(+), 0 deletions(-)
diff --git a/src/stkutil.c b/src/stkutil.c
index 661cfc6..acdf34f 100644
--- a/src/stkutil.c
+++ b/src/stkutil.c
@@ -3357,6 +3357,22 @@ static gboolean build_dataobj_address(struct stk_tlv_builder *tlv,
stk_tlv_builder_close_container(tlv);
}
+/* Described in TS 131.111 Section 8.5 */
+static gboolean build_dataobj_cbs_page(struct stk_tlv_builder *tlv,
+ const void *data, gboolean cr)
+{
+ const struct cbs *page = data;
+ unsigned char tag = STK_DATA_OBJECT_TYPE_CBS_PAGE;
+ unsigned char pdu[88];
+
+ if (cbs_encode(page, NULL, pdu) == FALSE)
+ return FALSE;
+
+ return stk_tlv_builder_open_container(tlv, cr, tag, TRUE) &&
+ stk_tlv_builder_append_bytes(tlv, pdu, 88) &&
+ stk_tlv_builder_close_container(tlv);
+}
+
/* Described in TS 102.223 Section 8.6 */
static gboolean build_dataobj_item_id(struct stk_tlv_builder *tlv,
const void *data, gboolean cr)
@@ -4216,6 +4232,16 @@ const unsigned char *stk_pdu_from_envelope(const struct stk_envelope *envelope,
&envelope->sms_pp_download.message,
NULL);
break;
+ case STK_ENVELOPE_TYPE_CBS_PP_DOWNLOAD:
+ ok = build_dataobj(&builder,
+ build_envelope_dataobj_device_ids,
+ DATAOBJ_FLAG_CR,
+ envelope,
+ build_dataobj_cbs_page,
+ DATAOBJ_FLAG_CR,
+ &envelope->cbs_pp_download.page,
+ NULL);
+ break;
default:
return NULL;
};
diff --git a/src/stkutil.h b/src/stkutil.h
index cc293ca..65ccfd3 100644
--- a/src/stkutil.h
+++ b/src/stkutil.h
@@ -1178,12 +1178,17 @@ struct stk_envelope_sms_pp_download {
struct sms_deliver message;
};
+struct stk_envelope_cbs_pp_download {
+ struct cbs page;
+};
+
struct stk_envelope {
enum stk_envelope_type type;
enum stk_device_identity_type src;
enum stk_device_identity_type dst;
union {
struct stk_envelope_sms_pp_download sms_pp_download;
+ struct stk_envelope_cbs_pp_download cbs_pp_download;
};
};
--
1.7.1.86.g0e460.dirty
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 05/20] stk: Use envelope encoding utility from stkutil.c
2010-06-07 10:08 [PATCH 01/20] Make stk_pdu_from_response use static buffers Andrzej Zaborowski
` (2 preceding siblings ...)
2010-06-07 10:08 ` [PATCH 04/20] stkutil: Add CBS-PP " Andrzej Zaborowski
@ 2010-06-07 10:08 ` Andrzej Zaborowski
2010-06-07 10:08 ` [PATCH 06/20] Fix: download CBS to SIM even when "Powered" is 0 Andrzej Zaborowski
` (14 subsequent siblings)
18 siblings, 0 replies; 29+ messages in thread
From: Andrzej Zaborowski @ 2010-06-07 10:08 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2700 bytes --]
---
src/cbs.c | 2 +-
src/ofono.h | 4 ++--
src/stk.c | 27 ++++++++++++++-------------
3 files changed, 17 insertions(+), 16 deletions(-)
diff --git a/src/cbs.c b/src/cbs.c
index 56607a8..27185ba 100644
--- a/src/cbs.c
+++ b/src/cbs.c
@@ -197,7 +197,7 @@ void ofono_cbs_notify(struct ofono_cbs *cbs, const unsigned char *pdu,
if (cbs_topic_in_range(c.message_identifier, cbs->efcbmid_contents)) {
if (cbs->stk)
- __ofono_cbs_sim_download(cbs->stk, pdu, pdu_len);
+ __ofono_cbs_sim_download(cbs->stk, &c);
return;
}
diff --git a/src/ofono.h b/src/ofono.h
index a1e4911..e2271e6 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -177,8 +177,8 @@ void __ofono_atom_free(struct ofono_atom *atom);
#include <ofono/sim.h>
#include <ofono/stk.h>
-void __ofono_cbs_sim_download(struct ofono_stk *stk,
- const guint8 *pdu, int pdu_len);
+struct cbs;
+void __ofono_cbs_sim_download(struct ofono_stk *stk, const struct cbs *msg);
#include <ofono/ssn.h>
diff --git a/src/stk.c b/src/stk.c
index 8573d2c..14d1a0c 100644
--- a/src/stk.c
+++ b/src/stk.c
@@ -49,32 +49,33 @@ static void stk_cbs_download_cb(const struct ofono_error *error,
{
if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
ofono_error("CellBroadcast download to UICC failed");
+ /* "The ME may retry to deliver the same Cell Broadcast
+ * page." */
return;
}
DBG("CellBroadcast download to UICC reported no error");
}
-void __ofono_cbs_sim_download(struct ofono_stk *stk,
- const guint8 *pdu, int pdu_len)
+void __ofono_cbs_sim_download(struct ofono_stk *stk, const struct cbs *msg)
{
- guint8 tlv[pdu_len + 8];
+ const guint8 *tlv;
+ unsigned int tlv_len;
+ struct stk_envelope e;
if (stk->driver->envelope == NULL)
return;
- tlv[0] = STK_ENVELOPE_TYPE_CBS_PP_DOWNLOAD;
- tlv[1] = 6 + pdu_len;
- tlv[2] = 0x80 | STK_DATA_OBJECT_TYPE_DEVICE_IDENTITIES;
- tlv[3] = 0x02; /* Device Identities length */
- tlv[4] = STK_DEVICE_IDENTITY_TYPE_NETWORK;
- tlv[5] = STK_DEVICE_IDENTITY_TYPE_UICC;
- tlv[6] = 0x80 | STK_DATA_OBJECT_TYPE_CBS_PAGE;
- tlv[7] = pdu_len;
+ e.type = STK_ENVELOPE_TYPE_CBS_PP_DOWNLOAD;
+ e.src = STK_DEVICE_IDENTITY_TYPE_NETWORK;
+ e.dst = STK_DEVICE_IDENTITY_TYPE_UICC;
+ memcpy(&e.cbs_pp_download.page, msg, sizeof(msg));
- memcpy(tlv + 8, pdu, pdu_len);
+ tlv = stk_pdu_from_envelope(&e, &tlv_len);
+ if (!tlv)
+ return;
- stk->driver->envelope(stk, pdu_len + 8, tlv, stk_cbs_download_cb, stk);
+ stk->driver->envelope(stk, tlv_len, tlv, stk_cbs_download_cb, stk);
}
void ofono_stk_proactive_command_notify(struct ofono_stk *stk,
--
1.7.1.86.g0e460.dirty
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 06/20] Fix: download CBS to SIM even when "Powered" is 0
2010-06-07 10:08 [PATCH 01/20] Make stk_pdu_from_response use static buffers Andrzej Zaborowski
` (3 preceding siblings ...)
2010-06-07 10:08 ` [PATCH 05/20] stk: Use envelope encoding utility from stkutil.c Andrzej Zaborowski
@ 2010-06-07 10:08 ` Andrzej Zaborowski
2010-06-07 10:08 ` [PATCH 07/20] test-stkutil: Tests for CBS-PP Data Download envelope builder Andrzej Zaborowski
` (13 subsequent siblings)
18 siblings, 0 replies; 29+ messages in thread
From: Andrzej Zaborowski @ 2010-06-07 10:08 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 908 bytes --]
---
src/cbs.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/cbs.c b/src/cbs.c
index 27185ba..316573b 100644
--- a/src/cbs.c
+++ b/src/cbs.c
@@ -185,11 +185,6 @@ void ofono_cbs_notify(struct ofono_cbs *cbs, const unsigned char *pdu,
if (cbs->assembly == NULL)
return;
- if (!cbs->powered) {
- ofono_error("Ignoring CBS because powered is off");
- return;
- }
-
if (!cbs_decode(pdu, pdu_len, &c)) {
ofono_error("Unable to decode CBS PDU");
return;
@@ -201,6 +196,11 @@ void ofono_cbs_notify(struct ofono_cbs *cbs, const unsigned char *pdu,
return;
}
+ if (!cbs->powered) {
+ ofono_error("Ignoring CBS because powered is off");
+ return;
+ }
+
if (!cbs_dcs_decode(c.dcs, &udhi, &cls, &charset, &comp, NULL, NULL)) {
ofono_error("Unknown / Reserved DCS. Ignoring");
return;
--
1.7.1.86.g0e460.dirty
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 07/20] test-stkutil: Tests for CBS-PP Data Download envelope builder
2010-06-07 10:08 [PATCH 01/20] Make stk_pdu_from_response use static buffers Andrzej Zaborowski
` (4 preceding siblings ...)
2010-06-07 10:08 ` [PATCH 06/20] Fix: download CBS to SIM even when "Powered" is 0 Andrzej Zaborowski
@ 2010-06-07 10:08 ` Andrzej Zaborowski
2010-06-07 10:08 ` [PATCH 08/20] stkutil: Add the Menu Selection " Andrzej Zaborowski
` (12 subsequent siblings)
18 siblings, 0 replies; 29+ messages in thread
From: Andrzej Zaborowski @ 2010-06-07 10:08 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 4779 bytes --]
---
unit/test-stkutil.c | 112 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 112 insertions(+), 0 deletions(-)
diff --git a/unit/test-stkutil.c b/unit/test-stkutil.c
index d7b0c25..ac6db51 100644
--- a/unit/test-stkutil.c
+++ b/unit/test-stkutil.c
@@ -18051,6 +18051,113 @@ static const struct envelope_test sms_pp_data_download_data_182 = {
},
};
+static const unsigned char cbs_pp_data_download_11[] = {
+ 0xd2, 0x5e, 0x82, 0x02, 0x83, 0x81, 0x8c, 0x58,
+ 0xc0, 0x11, 0x10, 0x01, 0x01, 0x11, 0xc3, 0x32,
+ 0x9b, 0x0d, 0x12, 0xca, 0xdf, 0x61, 0xf2, 0x38,
+ 0x3c, 0xa7, 0x83, 0x40, 0x20, 0x10, 0x08, 0x04,
+ 0x02, 0x81, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02,
+ 0x81, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x81,
+ 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x81, 0x40,
+ 0x20, 0x10, 0x08, 0x04, 0x02, 0x81, 0x40, 0x20,
+ 0x10, 0x08, 0x04, 0x02, 0x81, 0x40, 0x20, 0x10,
+ 0x08, 0x04, 0x02, 0x81, 0x40, 0x20, 0x10, 0x08,
+ 0x04, 0x02, 0x81, 0x40, 0x20, 0x10, 0x08, 0x04,
+ 0x02, 0x81, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02,
+};
+
+static const struct envelope_test cbs_pp_data_download_data_11 = {
+ .pdu = cbs_pp_data_download_11,
+ .pdu_len = sizeof(cbs_pp_data_download_11),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_CBS_PP_DOWNLOAD,
+ .src = STK_DEVICE_IDENTITY_TYPE_NETWORK,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .cbs_pp_download = {
+ .page = {
+ .gs = CBS_GEO_SCOPE_CELL_NORMAL,
+ .message_code = 1,
+ .update_number = 1,
+ .message_identifier = 0x1001,
+ .dcs = CBS_LANGUAGE_ENGLISH, /* GSM 7-bit */
+ .max_pages = 1,
+ .page = 1,
+ .ud = {
+ /* 7-bit "Cell Broadcast " repeated */
+ 0xc3, 0x32, 0x9b, 0x0d, 0x12, 0xca,
+ 0xdf, 0x61, 0xf2, 0x38, 0x3c, 0xa7,
+ 0x83, 0x40, 0x20, 0x10, 0x08, 0x04,
+ 0x02, 0x81, 0x40, 0x20, 0x10, 0x08,
+ 0x04, 0x02, 0x81, 0x40, 0x20, 0x10,
+ 0x08, 0x04, 0x02, 0x81, 0x40, 0x20,
+ 0x10, 0x08, 0x04, 0x02, 0x81, 0x40,
+ 0x20, 0x10, 0x08, 0x04, 0x02, 0x81,
+ 0x40, 0x20, 0x10, 0x08, 0x04, 0x02,
+ 0x81, 0x40, 0x20, 0x10, 0x08, 0x04,
+ 0x02, 0x81, 0x40, 0x20, 0x10, 0x08,
+ 0x04, 0x02, 0x81, 0x40, 0x20, 0x10,
+ 0x08, 0x04, 0x02, 0x81, 0x40, 0x20,
+ 0x10, 0x08, 0x04, 0x02,
+ },
+ },
+ }},
+ },
+};
+
+static const unsigned char cbs_pp_data_download_17[] = {
+ 0xd2, 0x5e, 0x82, 0x02, 0x83, 0x81, 0x8c, 0x58,
+ 0xc0, 0x11, 0x10, 0x01, 0x96, 0x11, 0x02, 0x70,
+ 0x00, 0x00, 0x4d, 0x00, 0x0d, 0x00, 0x00, 0x00,
+ 0x00, 0xbf, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc,
+ 0xdc, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc,
+ 0xdc, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc,
+ 0xdc, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc,
+ 0xdc, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc,
+ 0xdc, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc,
+ 0xdc, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc,
+ 0xdc, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc,
+};
+
+static const struct envelope_test cbs_pp_data_download_data_17 = {
+ .pdu = cbs_pp_data_download_17,
+ .pdu_len = sizeof(cbs_pp_data_download_17),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_CBS_PP_DOWNLOAD,
+ .src = STK_DEVICE_IDENTITY_TYPE_NETWORK,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .cbs_pp_download = {
+ .page = {
+ .gs = CBS_GEO_SCOPE_CELL_NORMAL,
+ .message_code = 1,
+ .update_number = 1,
+ .message_identifier = 0x1001,
+ .dcs = SMS_CLASS_2 | (SMS_CHARSET_8BIT << 2) |
+ (9 << 4), /* UDHI present */
+ .max_pages = 1,
+ .page = 1,
+ .ud = {
+ /* Secured User Header */
+ 0x02, 0x70, 0x00, 0x00, 0x4d, 0x00,
+ 0x0d, 0x00, 0x00, 0x00, 0x00, 0xbf,
+ 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0xdc, 0xdc, 0xdc, 0xdc,
+ 0xdc, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc,
+ 0xdc, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc,
+ 0xdc, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc,
+ 0xdc, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc,
+ 0xdc, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc,
+ 0xdc, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc,
+ 0xdc, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc,
+ 0xdc, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc,
+ 0xdc, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc,
+ 0xdc, 0xdc, 0xdc, 0xdc,
+ },
+ },
+ }},
+ },
+};
+
int main(int argc, char **argv)
{
g_test_init(&argc, &argv, NULL);
@@ -19731,5 +19838,10 @@ int main(int argc, char **argv)
&sms_pp_data_download_data_182,
test_envelope_encoding);
+ g_test_add_data_func("/teststk/CBS-PP data download 1.1",
+ &cbs_pp_data_download_data_11, test_envelope_encoding);
+ g_test_add_data_func("/teststk/CBS-PP data download 1.7",
+ &cbs_pp_data_download_data_17, test_envelope_encoding);
+
return g_test_run();
}
--
1.7.1.86.g0e460.dirty
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 08/20] stkutil: Add the Menu Selection envelope builder
2010-06-07 10:08 [PATCH 01/20] Make stk_pdu_from_response use static buffers Andrzej Zaborowski
` (5 preceding siblings ...)
2010-06-07 10:08 ` [PATCH 07/20] test-stkutil: Tests for CBS-PP Data Download envelope builder Andrzej Zaborowski
@ 2010-06-07 10:08 ` Andrzej Zaborowski
2010-06-07 10:08 ` [PATCH 09/20] test-stkutil: Tests for " Andrzej Zaborowski
` (11 subsequent siblings)
18 siblings, 0 replies; 29+ messages in thread
From: Andrzej Zaborowski @ 2010-06-07 10:08 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2184 bytes --]
---
src/stkutil.c | 25 +++++++++++++++++++++++++
src/stkutil.h | 6 ++++++
2 files changed, 31 insertions(+), 0 deletions(-)
diff --git a/src/stkutil.c b/src/stkutil.c
index acdf34f..83ff5c7 100644
--- a/src/stkutil.c
+++ b/src/stkutil.c
@@ -3561,6 +3561,20 @@ static gboolean build_dataobj_imei(struct stk_tlv_builder *tlv,
stk_tlv_builder_close_container(tlv);
}
+/* Described in TS 102.223 Section 8.21 */
+static gboolean build_dataobj_help_request(struct stk_tlv_builder *tlv,
+ const void *data, gboolean cr)
+{
+ const ofono_bool_t *help = data;
+ unsigned char tag = STK_DATA_OBJECT_TYPE_HELP_REQUEST;
+
+ if (*help != TRUE)
+ return TRUE;
+
+ return stk_tlv_builder_open_container(tlv, cr, tag, FALSE) &&
+ stk_tlv_builder_close_container(tlv);
+}
+
/* Described in TS 102.223 Section 8.22 */
static gboolean build_dataobj_network_measurement_results(
struct stk_tlv_builder *tlv,
@@ -4242,6 +4256,17 @@ const unsigned char *stk_pdu_from_envelope(const struct stk_envelope *envelope,
&envelope->cbs_pp_download.page,
NULL);
break;
+ case STK_ENVELOPE_TYPE_MENU_SELECTION:
+ ok = build_dataobj(&builder,
+ build_envelope_dataobj_device_ids,
+ DATAOBJ_FLAG_CR,
+ envelope,
+ build_dataobj_item_id, DATAOBJ_FLAG_CR,
+ &envelope->menu_selection.item_id,
+ build_dataobj_help_request, 0,
+ &envelope->menu_selection.help_request,
+ NULL);
+ break;
default:
return NULL;
};
diff --git a/src/stkutil.h b/src/stkutil.h
index 65ccfd3..d4b5b23 100644
--- a/src/stkutil.h
+++ b/src/stkutil.h
@@ -1182,6 +1182,11 @@ struct stk_envelope_cbs_pp_download {
struct cbs page;
};
+struct stk_envelope_menu_selection {
+ unsigned char item_id;
+ ofono_bool_t help_request;
+};
+
struct stk_envelope {
enum stk_envelope_type type;
enum stk_device_identity_type src;
@@ -1189,6 +1194,7 @@ struct stk_envelope {
union {
struct stk_envelope_sms_pp_download sms_pp_download;
struct stk_envelope_cbs_pp_download cbs_pp_download;
+ struct stk_envelope_menu_selection menu_selection;
};
};
--
1.7.1.86.g0e460.dirty
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 09/20] test-stkutil: Tests for the Menu Selection envelope builder
2010-06-07 10:08 [PATCH 01/20] Make stk_pdu_from_response use static buffers Andrzej Zaborowski
` (6 preceding siblings ...)
2010-06-07 10:08 ` [PATCH 08/20] stkutil: Add the Menu Selection " Andrzej Zaborowski
@ 2010-06-07 10:08 ` Andrzej Zaborowski
2010-06-07 10:08 ` [PATCH 10/20] Add a "sim string" encoding utility Andrzej Zaborowski
` (10 subsequent siblings)
18 siblings, 0 replies; 29+ messages in thread
From: Andrzej Zaborowski @ 2010-06-07 10:08 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 5462 bytes --]
---
unit/test-stkutil.c | 162 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 162 insertions(+), 0 deletions(-)
diff --git a/unit/test-stkutil.c b/unit/test-stkutil.c
index ac6db51..2a33c30 100644
--- a/unit/test-stkutil.c
+++ b/unit/test-stkutil.c
@@ -18158,6 +18158,151 @@ static const struct envelope_test cbs_pp_data_download_data_17 = {
},
};
+static const unsigned char menu_selection_111[] = {
+ 0xd3, 0x07, 0x82, 0x02, 0x01, 0x81, 0x90, 0x01,
+ 0x02,
+};
+
+static const struct envelope_test menu_selection_data_111 = {
+ .pdu = menu_selection_111,
+ .pdu_len = sizeof(menu_selection_111),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_MENU_SELECTION,
+ .src = STK_DEVICE_IDENTITY_TYPE_KEYPAD,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .menu_selection = {
+ .item_id = 0x2,
+ }},
+ },
+};
+
+static const unsigned char menu_selection_112[] = {
+ 0xd3, 0x07, 0x82, 0x02, 0x01, 0x81, 0x90, 0x01,
+ 0x12,
+};
+
+static const struct envelope_test menu_selection_data_112 = {
+ .pdu = menu_selection_112,
+ .pdu_len = sizeof(menu_selection_112),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_MENU_SELECTION,
+ .src = STK_DEVICE_IDENTITY_TYPE_KEYPAD,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .menu_selection = {
+ .item_id = 0x12,
+ }},
+ },
+};
+
+static const unsigned char menu_selection_121[] = {
+ 0xd3, 0x07, 0x82, 0x02, 0x01, 0x81, 0x90, 0x01,
+ 0x3d,
+};
+
+static const struct envelope_test menu_selection_data_121 = {
+ .pdu = menu_selection_121,
+ .pdu_len = sizeof(menu_selection_121),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_MENU_SELECTION,
+ .src = STK_DEVICE_IDENTITY_TYPE_KEYPAD,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .menu_selection = {
+ .item_id = 0x3d,
+ }},
+ },
+};
+
+static const unsigned char menu_selection_122[] = {
+ 0xd3, 0x07, 0x82, 0x02, 0x01, 0x81, 0x90, 0x01,
+ 0xfb,
+};
+
+static const struct envelope_test menu_selection_data_122 = {
+ .pdu = menu_selection_122,
+ .pdu_len = sizeof(menu_selection_122),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_MENU_SELECTION,
+ .src = STK_DEVICE_IDENTITY_TYPE_KEYPAD,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .menu_selection = {
+ .item_id = 0xfb,
+ }},
+ },
+};
+
+static const unsigned char menu_selection_123[] = {
+ 0xd3, 0x07, 0x82, 0x02, 0x01, 0x81, 0x90, 0x01,
+ 0x01,
+};
+
+static const struct envelope_test menu_selection_data_123 = {
+ .pdu = menu_selection_123,
+ .pdu_len = sizeof(menu_selection_123),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_MENU_SELECTION,
+ .src = STK_DEVICE_IDENTITY_TYPE_KEYPAD,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .menu_selection = {
+ .item_id = 0x1,
+ }},
+ },
+};
+
+static const unsigned char menu_selection_211[] = {
+ 0xd3, 0x09, 0x82, 0x02, 0x01, 0x81, 0x90, 0x01,
+ 0x02, 0x15, 0x00,
+};
+
+static const struct envelope_test menu_selection_data_211 = {
+ .pdu = menu_selection_211,
+ .pdu_len = sizeof(menu_selection_211),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_MENU_SELECTION,
+ .src = STK_DEVICE_IDENTITY_TYPE_KEYPAD,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .menu_selection = {
+ .item_id = 0x2,
+ .help_request = TRUE,
+ }},
+ },
+};
+
+static const unsigned char menu_selection_612[] = {
+ 0xd3, 0x07, 0x82, 0x02, 0x01, 0x81, 0x90, 0x01,
+ 0x05,
+};
+
+static const struct envelope_test menu_selection_data_612 = {
+ .pdu = menu_selection_612,
+ .pdu_len = sizeof(menu_selection_612),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_MENU_SELECTION,
+ .src = STK_DEVICE_IDENTITY_TYPE_KEYPAD,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .menu_selection = {
+ .item_id = 0x5,
+ }},
+ },
+};
+
+static const unsigned char menu_selection_641[] = {
+ 0xd3, 0x07, 0x82, 0x02, 0x01, 0x81, 0x90, 0x01,
+ 0x08,
+};
+
+static const struct envelope_test menu_selection_data_641 = {
+ .pdu = menu_selection_641,
+ .pdu_len = sizeof(menu_selection_641),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_MENU_SELECTION,
+ .src = STK_DEVICE_IDENTITY_TYPE_KEYPAD,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .menu_selection = {
+ .item_id = 0x8,
+ }},
+ },
+};
+
int main(int argc, char **argv)
{
g_test_init(&argc, &argv, NULL);
@@ -19843,5 +19988,22 @@ int main(int argc, char **argv)
g_test_add_data_func("/teststk/CBS-PP data download 1.7",
&cbs_pp_data_download_data_17, test_envelope_encoding);
+ g_test_add_data_func("/teststk/Menu Selection 1.1.1",
+ &menu_selection_data_111, test_envelope_encoding);
+ g_test_add_data_func("/teststk/Menu Selection 1.1.2",
+ &menu_selection_data_112, test_envelope_encoding);
+ g_test_add_data_func("/teststk/Menu Selection 1.2.1",
+ &menu_selection_data_121, test_envelope_encoding);
+ g_test_add_data_func("/teststk/Menu Selection 1.2.2",
+ &menu_selection_data_122, test_envelope_encoding);
+ g_test_add_data_func("/teststk/Menu Selection 1.2.3",
+ &menu_selection_data_123, test_envelope_encoding);
+ g_test_add_data_func("/teststk/Menu Selection 2.1.1",
+ &menu_selection_data_211, test_envelope_encoding);
+ g_test_add_data_func("/teststk/Menu Selection 6.1.2",
+ &menu_selection_data_612, test_envelope_encoding);
+ g_test_add_data_func("/teststk/Menu Selection 6.4.1",
+ &menu_selection_data_641, test_envelope_encoding);
+
return g_test_run();
}
--
1.7.1.86.g0e460.dirty
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 10/20] Add a "sim string" encoding utility.
2010-06-07 10:08 [PATCH 01/20] Make stk_pdu_from_response use static buffers Andrzej Zaborowski
` (7 preceding siblings ...)
2010-06-07 10:08 ` [PATCH 09/20] test-stkutil: Tests for " Andrzej Zaborowski
@ 2010-06-07 10:08 ` Andrzej Zaborowski
2010-06-07 10:08 ` [PATCH 11/20] simutil: Fix MMC MNC encoding for 2-digit MNCs Andrzej Zaborowski
` (9 subsequent siblings)
18 siblings, 0 replies; 29+ messages in thread
From: Andrzej Zaborowski @ 2010-06-07 10:08 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 3081 bytes --]
---
src/simutil.c | 25 ++++++++++---------------
src/util.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
src/util.h | 3 +++
3 files changed, 59 insertions(+), 15 deletions(-)
diff --git a/src/simutil.c b/src/simutil.c
index f980bf6..7291729 100644
--- a/src/simutil.c
+++ b/src/simutil.c
@@ -1232,29 +1232,24 @@ void sim_adn_build(unsigned char *data, int length,
const char *identifier)
{
int number_len = strlen(ph->number);
- unsigned char *gsm_identifier = NULL;
- long gsm_bytes;
- long alpha_length;
+ unsigned char *alpha = NULL;
+ int alpha_written = 0;
+ int alpha_length;
alpha_length = length - 14;
/* Alpha-Identifier field */
if (alpha_length > 0) {
- memset(data, 0xff, alpha_length);
-
if (identifier)
- gsm_identifier = convert_utf8_to_gsm(identifier,
- -1, NULL, &gsm_bytes, 0);
-
- if (gsm_identifier) {
- memcpy(data, gsm_identifier,
- MIN(gsm_bytes, alpha_length));
- g_free(gsm_identifier);
+ alpha = utf8_to_sim_string(identifier, alpha_length,
+ &alpha_written);
+ if (alpha) {
+ memcpy(data, alpha, alpha_written);
+ g_free(alpha);
}
- /* TODO: figure out when the identifier needs to
- * be encoded in UCS2 and do this.
- */
+ memset(data + alpha_written, 0xff,
+ alpha_length - alpha_written);
data += alpha_length;
}
diff --git a/src/util.c b/src/util.c
index e5ce7b3..fd8b305 100644
--- a/src/util.c
+++ b/src/util.c
@@ -1215,3 +1215,49 @@ char *sim_string_to_utf8(const unsigned char *buffer, int length)
return utf8;
}
+
+unsigned char *utf8_to_sim_string(const char *utf,
+ int max_length, int *out_length)
+{
+ unsigned char *result;
+ unsigned char *ucs2;
+ long gsm_bytes;
+ gsize converted;
+
+ result = convert_utf8_to_gsm(utf, -1, NULL, &gsm_bytes, 0);
+ if (result) {
+ if (gsm_bytes > max_length) {
+ gsm_bytes = max_length;
+ while (gsm_bytes && result[gsm_bytes - 1] == 0x1b)
+ gsm_bytes -= 1;
+ }
+
+ *out_length = gsm_bytes;
+ return result;
+ }
+
+ /* NOTE: UCS2 formats with an offset are never used */
+
+ ucs2 = (guint8 *) g_convert(utf, -1, "UCS-2BE//TRANSLIT", "UTF-8",
+ NULL, &converted, NULL);
+
+ if (!ucs2)
+ return NULL;
+
+ if (max_length != -1 && (int) converted + 1 > max_length)
+ converted = (max_length - 1) & ~1;
+
+ result = g_try_malloc(converted + 1);
+ if (!result) {
+ g_free(ucs2);
+ return NULL;
+ }
+
+ *out_length = converted + 1;
+
+ result[0] = 0x80;
+ memcpy(&result[1], ucs2, converted);
+ g_free(ucs2);
+
+ return result;
+}
diff --git a/src/util.h b/src/util.h
index 2835b76..9da81aa 100644
--- a/src/util.h
+++ b/src/util.h
@@ -77,3 +77,6 @@ unsigned char *pack_7bit(const unsigned char *in, long len, int byte_offset,
long *items_written, unsigned char terminator);
char *sim_string_to_utf8(const unsigned char *buffer, int length);
+
+unsigned char *utf8_to_sim_string(const char *utf,
+ int max_length, int *out_length);
--
1.7.1.86.g0e460.dirty
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 11/20] simutil: Fix MMC MNC encoding for 2-digit MNCs.
2010-06-07 10:08 [PATCH 01/20] Make stk_pdu_from_response use static buffers Andrzej Zaborowski
` (8 preceding siblings ...)
2010-06-07 10:08 ` [PATCH 10/20] Add a "sim string" encoding utility Andrzej Zaborowski
@ 2010-06-07 10:08 ` Andrzej Zaborowski
2010-06-07 10:08 ` [PATCH 12/20] stkutil: Add the Call Control envelope builder Andrzej Zaborowski
` (8 subsequent siblings)
18 siblings, 0 replies; 29+ messages in thread
From: Andrzej Zaborowski @ 2010-06-07 10:08 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1229 bytes --]
---
src/simutil.c | 19 ++++++++-----------
1 files changed, 8 insertions(+), 11 deletions(-)
diff --git a/src/simutil.c b/src/simutil.c
index 7291729..3315299 100644
--- a/src/simutil.c
+++ b/src/simutil.c
@@ -117,6 +117,8 @@ static struct sim_ef_info ef_db[] = {
{ 0x6FE3, 0x0000, BINARY, 18, PIN, PIN },
};
+static inline int to_semi_oct(char in);
+
void simple_tlv_iter_init(struct simple_tlv_iter *iter,
const unsigned char *pdu, unsigned int len)
{
@@ -844,19 +846,14 @@ void sim_parse_mcc_mnc(const guint8 *bcd, char *mcc, char *mnc)
void sim_encode_mcc_mnc(guint8 *out, const char *mcc, const char *mnc)
{
- char str[7] = "ffffff";
-
- str[0] = mcc[0];
- str[1] = mcc[1];
- if (mcc[2])
- str[2] = mcc[2];
+ out[0] = to_semi_oct(mcc[0]);
+ out[0] |= to_semi_oct(mcc[1]) << 4;
- str[4] = mnc[0];
- str[5] = mnc[1];
- if (mnc[2])
- str[3] = mnc[2];
+ out[1] = mcc[2] ? to_semi_oct(mcc[2]) : 0xf;
+ out[1] |= (mnc[2] ? to_semi_oct(mnc[2]) : 0xf) << 4;
- encode_bcd_number(str, out);
+ out[2] = to_semi_oct(mnc[0]);
+ out[2] |= to_semi_oct(mnc[1]) << 4;
}
static gint spdi_operator_compare(gconstpointer a, gconstpointer b)
--
1.7.1.86.g0e460.dirty
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 12/20] stkutil: Add the Call Control envelope builder
2010-06-07 10:08 [PATCH 01/20] Make stk_pdu_from_response use static buffers Andrzej Zaborowski
` (9 preceding siblings ...)
2010-06-07 10:08 ` [PATCH 11/20] simutil: Fix MMC MNC encoding for 2-digit MNCs Andrzej Zaborowski
@ 2010-06-07 10:08 ` Andrzej Zaborowski
2010-06-09 22:57 ` Denis Kenzior
2010-06-07 10:08 ` [PATCH 13/20] test-stkutil: Tests for " Andrzej Zaborowski
` (7 subsequent siblings)
18 siblings, 1 reply; 29+ messages in thread
From: Andrzej Zaborowski @ 2010-06-07 10:08 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 10445 bytes --]
---
src/stkutil.c | 178 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
src/stkutil.h | 31 ++++++++++
2 files changed, 207 insertions(+), 2 deletions(-)
diff --git a/src/stkutil.c b/src/stkutil.c
index 83ff5c7..b9a152a 100644
--- a/src/stkutil.c
+++ b/src/stkutil.c
@@ -319,8 +319,6 @@ static gboolean parse_dataobj_subaddress(struct comprehension_tlv_iter *iter,
unsigned int len;
len = comprehension_tlv_iter_get_length(iter);
- if (len < 1)
- return FALSE;
if (len > sizeof(subaddr->subaddr))
return FALSE;
@@ -329,6 +327,8 @@ static gboolean parse_dataobj_subaddress(struct comprehension_tlv_iter *iter,
subaddr->len = len;
memcpy(subaddr->subaddr, data, len);
+ subaddr->has_subaddr = TRUE;
+
return TRUE;
}
@@ -3357,6 +3357,61 @@ static gboolean build_dataobj_address(struct stk_tlv_builder *tlv,
stk_tlv_builder_close_container(tlv);
}
+/* Described in TS 102.223 Section 8.2 */
+static gboolean build_dataobj_alpha_id(struct stk_tlv_builder *tlv,
+ const void *data, gboolean cr)
+{
+ unsigned char tag = STK_DATA_OBJECT_TYPE_ALPHA_ID;
+ int len;
+ unsigned char *string;
+
+ if (data == NULL)
+ return TRUE;
+
+ if (strlen(data) == 0)
+ return stk_tlv_builder_open_container(tlv, cr, tag, FALSE) &&
+ stk_tlv_builder_close_container(tlv);
+
+ string = utf8_to_sim_string(data, -1, &len);
+ if (string == NULL)
+ return FALSE;
+
+ return stk_tlv_builder_open_container(tlv, cr, tag, TRUE) &&
+ stk_tlv_builder_append_bytes(tlv, string, len) &&
+ stk_tlv_builder_close_container(tlv);
+}
+
+/* Described in TS 102.223 Section 8.3 */
+static gboolean build_dataobj_subaddress(struct stk_tlv_builder *tlv,
+ const void *data, gboolean cr)
+{
+ const struct stk_subaddress *sa = data;
+ unsigned char tag = STK_DATA_OBJECT_TYPE_SUBADDRESS;
+
+ if (sa->has_subaddr == FALSE)
+ return TRUE;
+
+ return stk_tlv_builder_open_container(tlv, cr, tag, FALSE) &&
+ stk_tlv_builder_append_bytes(tlv, sa->subaddr, sa->len) &&
+ stk_tlv_builder_close_container(tlv);
+}
+
+/* Described in TS 131.111 Section 8.4 */
+static gboolean build_dataobj_ccp(struct stk_tlv_builder *tlv,
+ const void *data, gboolean cr)
+{
+ const struct stk_ccp *ccp = data;
+ unsigned char tag = STK_DATA_OBJECT_TYPE_CCP;
+
+ if (ccp->len == 0)
+ return TRUE;
+
+ return stk_tlv_builder_open_container(tlv, cr, tag, FALSE) &&
+ stk_tlv_builder_append_byte(tlv, ccp->len) &&
+ stk_tlv_builder_append_bytes(tlv, ccp->ccp, ccp->len) &&
+ stk_tlv_builder_close_container(tlv);
+}
+
/* Described in TS 131.111 Section 8.5 */
static gboolean build_dataobj_cbs_page(struct stk_tlv_builder *tlv,
const void *data, gboolean cr)
@@ -3447,6 +3502,27 @@ static gboolean build_dataobj_gsm_sms_tpdu(struct stk_tlv_builder *tlv,
stk_tlv_builder_close_container(tlv);
}
+/* Described in TS 131.111 Section 8.14 */
+static gboolean build_dataobj_ss_string(struct stk_tlv_builder *tlv,
+ const void *data, gboolean cr)
+{
+ const struct stk_address *addr = data;
+ unsigned char tag = STK_DATA_OBJECT_TYPE_SS_STRING;
+ unsigned int len;
+ unsigned char number[128];
+
+ if (addr->number == NULL)
+ return TRUE;
+
+ len = (strlen(addr->number) + 1) / 2;
+ sim_encode_bcd_number(addr->number, number);
+
+ return stk_tlv_builder_open_container(tlv, cr, tag, FALSE) &&
+ stk_tlv_builder_append_byte(tlv, addr->ton_npi) &&
+ stk_tlv_builder_append_bytes(tlv, number, len) &&
+ stk_tlv_builder_close_container(tlv);
+}
+
/* Defined in TS 102.223 Section 8.15 */
static gboolean build_dataobj_text(struct stk_tlv_builder *tlv,
const void *data, gboolean cr)
@@ -3484,6 +3560,22 @@ static gboolean build_dataobj_text(struct stk_tlv_builder *tlv,
return stk_tlv_builder_close_container(tlv);
}
+/* Described in TS 131.111 Section 8.17 */
+static gboolean build_dataobj_ussd_string(struct stk_tlv_builder *tlv,
+ const void *data, gboolean cr)
+{
+ const struct stk_ussd_string *ussd = data;
+ unsigned char tag = STK_DATA_OBJECT_TYPE_USSD_STRING;
+
+ if (ussd->string == NULL)
+ return TRUE;
+
+ return stk_tlv_builder_open_container(tlv, cr, tag, FALSE) &&
+ stk_tlv_builder_append_byte(tlv, ussd->dcs) &&
+ stk_tlv_builder_append_bytes(tlv, ussd->string, ussd->len) &&
+ stk_tlv_builder_close_container(tlv);
+}
+
/* Described in TS 102.223 Section 8.19 */
static gboolean build_dataobj_location_info(struct stk_tlv_builder *tlv,
const void *data, gboolean cr)
@@ -3731,6 +3823,21 @@ static gboolean build_dataobj_at_response(struct stk_tlv_builder *tlv,
stk_tlv_builder_close_container(tlv);
}
+/* Described in TS 131.111 Section 8.42 */
+static gboolean build_dataobj_bc_repeat(struct stk_tlv_builder *tlv,
+ const void *data, gboolean cr)
+{
+ unsigned char tag = STK_DATA_OBJECT_TYPE_BC_REPEAT_INDICATOR;
+ const struct stk_bc_repeat *bcr = data;
+
+ if (bcr->has_bc_repeat == FALSE)
+ return TRUE;
+
+ return stk_tlv_builder_open_container(tlv, cr, tag, TRUE) &&
+ stk_tlv_builder_append_byte(tlv, bcr->value) &&
+ stk_tlv_builder_close_container(tlv);
+}
+
/* Described in TS 102.223 Section 8.45 */
static gboolean build_dataobj_language(struct stk_tlv_builder *tlv,
const void *data, gboolean cr)
@@ -3806,6 +3913,23 @@ static gboolean build_dataobj_esn(struct stk_tlv_builder *tlv,
stk_tlv_builder_close_container(tlv);
}
+/* Described in TS 131.111 Section 8.72, 3GPP 24.008 Section 9.5.7 */
+static gboolean build_dataobj_pdp_context_params(struct stk_tlv_builder *tlv,
+ const void *data, gboolean cr)
+{
+ const struct stk_common_byte_array *params = data;
+ unsigned char tag = STK_DATA_OBJECT_TYPE_PDP_ACTIVATION_PARAMETER;
+
+ if (params->len < 1)
+ return TRUE;
+ if (params->len > 0x7f)
+ return FALSE;
+
+ return stk_tlv_builder_open_container(tlv, cr, tag, FALSE) &&
+ stk_tlv_builder_append_bytes(tlv, params->array, params->len) &&
+ stk_tlv_builder_close_container(tlv);
+}
+
/* Described in TS 102.223 Section 8.74
*
* See format note in parse_dataobj_imeisv.
@@ -3894,6 +4018,23 @@ static gboolean build_dataobj_broadcast_network_information(
stk_tlv_builder_close_container(tlv);
}
+/* Described in TS 131.111 Section 8.98, 3GPP 24.301 Section 6.5.1 */
+static gboolean build_dataobj_eps_pdn_conn_params(struct stk_tlv_builder *tlv,
+ const void *data, gboolean cr)
+{
+ const struct stk_common_byte_array *params = data;
+ unsigned char tag = STK_DATA_OBJECT_TYPE_EPS_PDN_CONN_ACTIVATION_REQ;
+
+ if (params->len < 1)
+ return TRUE;
+ if (params->len > 0x7f)
+ return FALSE;
+
+ return stk_tlv_builder_open_container(tlv, cr, tag, FALSE) &&
+ stk_tlv_builder_append_bytes(tlv, params->array, params->len) &&
+ stk_tlv_builder_close_container(tlv);
+}
+
static gboolean build_dataobj(struct stk_tlv_builder *tlv,
dataobj_writer builder_func, ...)
{
@@ -4267,6 +4408,39 @@ const unsigned char *stk_pdu_from_envelope(const struct stk_envelope *envelope,
&envelope->menu_selection.help_request,
NULL);
break;
+ case STK_ENVELOPE_TYPE_CALL_CONTROL:
+ ok = build_dataobj(&builder,
+ build_envelope_dataobj_device_ids,
+ DATAOBJ_FLAG_CR,
+ envelope,
+ build_dataobj_address, DATAOBJ_FLAG_CR,
+ &envelope->call_control.address,
+ build_dataobj_ss_string,
+ DATAOBJ_FLAG_CR,
+ &envelope->call_control.ss_string,
+ build_dataobj_ussd_string,
+ DATAOBJ_FLAG_CR,
+ &envelope->call_control.ussd_string,
+ build_dataobj_pdp_context_params,
+ DATAOBJ_FLAG_CR,
+ &envelope->call_control.pdp_ctx_params,
+ build_dataobj_eps_pdn_conn_params,
+ DATAOBJ_FLAG_CR,
+ &envelope->call_control.eps_pdn_params,
+ build_dataobj_ccp, 0,
+ &envelope->call_control.ccp1,
+ build_dataobj_subaddress, 0,
+ &envelope->call_control.subaddress,
+ build_dataobj_location_info, 0,
+ &envelope->call_control.location,
+ build_dataobj_ccp, 0,
+ &envelope->call_control.ccp2,
+ build_dataobj_alpha_id, 0,
+ envelope->call_control.alpha_id,
+ build_dataobj_bc_repeat, 0,
+ &envelope->call_control.bc_repeat,
+ NULL);
+ break;
default:
return NULL;
};
diff --git a/src/stkutil.h b/src/stkutil.h
index d4b5b23..33a0f91 100644
--- a/src/stkutil.h
+++ b/src/stkutil.h
@@ -178,6 +178,7 @@ enum stk_data_object_type {
STK_DATA_OBJECT_TYPE_PLMN_LIST = 0x79,
STK_DATA_OBJECT_TYPE_BROADCAST_NETWORK_INFO = 0x7A,
STK_DATA_OBJECT_TYPE_ACTIVATE_DESCRIPTOR = 0x7B,
+ STK_DATA_OBJECT_TYPE_EPS_PDN_CONN_ACTIVATION_REQ = 0x7C,
};
enum stk_device_identity_type {
@@ -474,6 +475,7 @@ struct stk_address {
* bytes."
*/
struct stk_subaddress {
+ ofono_bool_t has_subaddr;
unsigned char len;
unsigned char subaddr[23];
};
@@ -1187,6 +1189,34 @@ struct stk_envelope_menu_selection {
ofono_bool_t help_request;
};
+/* Used both in the ENVELOPE message to UICC and response from UICC */
+struct stk_envelope_call_control {
+ /* Exactly one of the following 5 fields must be present */
+ struct stk_address address;
+ struct stk_address ss_string;
+ struct stk_ussd_string {
+ unsigned char dcs;
+ const unsigned char *string;
+ int len;
+ } ussd_string;
+ struct stk_common_byte_array pdp_ctx_params;
+ struct stk_common_byte_array eps_pdn_params;
+ /* At least one of the following two fields must be present in a
+ * response indicating modification of the call.
+ * In an EVELOPE message, only allowed for a call setup. */
+ struct stk_ccp ccp1;
+ struct stk_subaddress subaddress;
+ struct stk_location_info location;
+ /* Only allowed when ccp1 is present */
+ struct stk_ccp ccp2;
+ char *alpha_id;
+ /* Only allowed when both ccp1 and ccp2 are present */
+ struct stk_bc_repeat {
+ ofono_bool_t has_bc_repeat;
+ unsigned char value;
+ } bc_repeat;
+};
+
struct stk_envelope {
enum stk_envelope_type type;
enum stk_device_identity_type src;
@@ -1195,6 +1225,7 @@ struct stk_envelope {
struct stk_envelope_sms_pp_download sms_pp_download;
struct stk_envelope_cbs_pp_download cbs_pp_download;
struct stk_envelope_menu_selection menu_selection;
+ struct stk_envelope_call_control call_control;
};
};
--
1.7.1.86.g0e460.dirty
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 13/20] test-stkutil: Tests for Call Control envelope builder
2010-06-07 10:08 [PATCH 01/20] Make stk_pdu_from_response use static buffers Andrzej Zaborowski
` (10 preceding siblings ...)
2010-06-07 10:08 ` [PATCH 12/20] stkutil: Add the Call Control envelope builder Andrzej Zaborowski
@ 2010-06-07 10:08 ` Andrzej Zaborowski
2010-06-07 10:08 ` [PATCH 14/20] stkutil: Add the MO Short Message " Andrzej Zaborowski
` (6 subsequent siblings)
18 siblings, 0 replies; 29+ messages in thread
From: Andrzej Zaborowski @ 2010-06-07 10:08 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 5047 bytes --]
---
unit/test-stkutil.c | 154 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 154 insertions(+), 0 deletions(-)
diff --git a/unit/test-stkutil.c b/unit/test-stkutil.c
index 2a33c30..d8f6cf2 100644
--- a/unit/test-stkutil.c
+++ b/unit/test-stkutil.c
@@ -18303,6 +18303,151 @@ static const struct envelope_test menu_selection_data_641 = {
},
};
+static const unsigned char call_control_111a[] = {
+ 0xd4, 0x25, 0x82, 0x02, 0x82, 0x81, 0x86, 0x0b,
+ 0x91, 0x10, 0x32, 0x54, 0x76, 0x98, 0x10, 0x32,
+ 0x54, 0x76, 0x98, 0x07, 0x07, 0x06, 0x60, 0x04,
+ 0x02, 0x00, 0x05, 0x81, 0x13, 0x09, 0x00, 0xf1,
+ 0x10, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01,
+};
+
+static const struct envelope_test call_control_data_111a = {
+ .pdu = call_control_111a,
+ .pdu_len = sizeof(call_control_111a),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_CALL_CONTROL,
+ .src = STK_DEVICE_IDENTITY_TYPE_TERMINAL,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .call_control = {
+ .address = {
+ .ton_npi = 0x91, /* Intl, ISDN */
+ .number = "01234567890123456789",
+ },
+ .ccp1 = {
+ .ccp = {
+ 0x60, 0x04, 0x02, 0x00, 0x05, 0x81,
+ },
+ .len = 6,
+ },
+ .location = {
+ .mcc = "001",
+ .mnc = "01",
+ .lac_tac = 0x0001,
+ .has_ci = TRUE,
+ .ci = 0x0001,
+ .has_ext_ci = TRUE,
+ .ext_ci = 0x0001,
+ },
+ }},
+ },
+};
+
+static const unsigned char call_control_111b[] = {
+ 0xd4, 0x23, 0x82, 0x02, 0x82, 0x81, 0x86, 0x0b,
+ 0x91, 0x10, 0x32, 0x54, 0x76, 0x98, 0x10, 0x32,
+ 0x54, 0x76, 0x98, 0x07, 0x07, 0x06, 0x60, 0x04,
+ 0x02, 0x00, 0x05, 0x81, 0x13, 0x07, 0x00, 0x11,
+ 0x10, 0x00, 0x01, 0x00, 0x01,
+};
+
+static const struct envelope_test call_control_data_111b = {
+ .pdu = call_control_111b,
+ .pdu_len = sizeof(call_control_111b),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_CALL_CONTROL,
+ .src = STK_DEVICE_IDENTITY_TYPE_TERMINAL,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .call_control = {
+ .address = {
+ .ton_npi = 0x91, /* Intl, ISDN */
+ .number = "01234567890123456789",
+ },
+ .ccp1 = {
+ .ccp = {
+ 0x60, 0x04, 0x02, 0x00, 0x05, 0x81,
+ },
+ .len = 6,
+ },
+ .location = {
+ .mcc = "001",
+ .mnc = "011",
+ .lac_tac = 0x0001,
+ .has_ci = TRUE,
+ .ci = 0x0001,
+ },
+ }},
+ },
+};
+
+static const unsigned char call_control_131a[] = {
+ 0xd4, 0x18, 0x82, 0x02, 0x82, 0x81, 0x86, 0x07,
+ 0x91, 0x10, 0x32, 0x04, 0x21, 0x43, 0x65, 0x13,
+ 0x09, 0x00, 0xf1, 0x10, 0x00, 0x01, 0x00, 0x01,
+ 0x00, 0x01,
+ /*
+ * Byte 3 changed to 0x82 and byte 7 changed to 0x86 (Comprehension
+ * Required should be set according to TS 102 223 7.3.1.6)
+ */
+};
+
+static const struct envelope_test call_control_data_131a = {
+ .pdu = call_control_131a,
+ .pdu_len = sizeof(call_control_131a),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_CALL_CONTROL,
+ .src = STK_DEVICE_IDENTITY_TYPE_TERMINAL,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .call_control = {
+ .address = {
+ .ton_npi = 0x91, /* Intl, ISDN */
+ .number = "012340123456",
+ },
+ .location = {
+ .mcc = "001",
+ .mnc = "01",
+ .lac_tac = 0x0001,
+ .has_ci = TRUE,
+ .ci = 0x0001,
+ .has_ext_ci = TRUE,
+ .ext_ci = 0x0001,
+ },
+ }},
+ },
+};
+
+static const unsigned char call_control_131b[] = {
+ 0xd4, 0x16, 0x82, 0x02, 0x82, 0x81, 0x86, 0x07,
+ 0x91, 0x10, 0x32, 0x04, 0x21, 0x43, 0x65, 0x13,
+ 0x07, 0x00, 0x11, 0x10, 0x00, 0x01, 0x00, 0x01,
+ /*
+ * Byte 3 changed to 0x82 and byte 7 changed to 0x86 (Comprehension
+ * Required should be set according to TS 102 223 7.3.1.6)
+ */
+};
+
+static const struct envelope_test call_control_data_131b = {
+ .pdu = call_control_131b,
+ .pdu_len = sizeof(call_control_131b),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_CALL_CONTROL,
+ .src = STK_DEVICE_IDENTITY_TYPE_TERMINAL,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .call_control = {
+ .address = {
+ .ton_npi = 0x91, /* Intl, ISDN */
+ .number = "012340123456",
+ },
+ .location = {
+ .mcc = "001",
+ .mnc = "011",
+ .lac_tac = 0x0001,
+ .has_ci = TRUE,
+ .ci = 0x0001,
+ },
+ }},
+ },
+};
+
int main(int argc, char **argv)
{
g_test_init(&argc, &argv, NULL);
@@ -20005,5 +20150,14 @@ int main(int argc, char **argv)
g_test_add_data_func("/teststk/Menu Selection 6.4.1",
&menu_selection_data_641, test_envelope_encoding);
+ g_test_add_data_func("/teststk/Call Control 1.1.1A",
+ &call_control_data_111a, test_envelope_encoding);
+ g_test_add_data_func("/teststk/Call Control 1.1.1B",
+ &call_control_data_111b, test_envelope_encoding);
+ g_test_add_data_func("/teststk/Call Control 1.3.1A",
+ &call_control_data_131a, test_envelope_encoding);
+ g_test_add_data_func("/teststk/Call Control 1.3.1B",
+ &call_control_data_131b, test_envelope_encoding);
+
return g_test_run();
}
--
1.7.1.86.g0e460.dirty
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 14/20] stkutil: Add the MO Short Message Control envelope builder
2010-06-07 10:08 [PATCH 01/20] Make stk_pdu_from_response use static buffers Andrzej Zaborowski
` (11 preceding siblings ...)
2010-06-07 10:08 ` [PATCH 13/20] test-stkutil: Tests for " Andrzej Zaborowski
@ 2010-06-07 10:08 ` Andrzej Zaborowski
2010-06-07 10:08 ` [PATCH 15/20] test-stkutil: Tests for " Andrzej Zaborowski
` (5 subsequent siblings)
18 siblings, 0 replies; 29+ messages in thread
From: Andrzej Zaborowski @ 2010-06-07 10:08 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1739 bytes --]
---
src/stkutil.c | 16 ++++++++++++++++
src/stkutil.h | 7 +++++++
2 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/src/stkutil.c b/src/stkutil.c
index b9a152a..9930d0b 100644
--- a/src/stkutil.c
+++ b/src/stkutil.c
@@ -4441,6 +4441,22 @@ const unsigned char *stk_pdu_from_envelope(const struct stk_envelope *envelope,
&envelope->call_control.bc_repeat,
NULL);
break;
+ case STK_ENVELOPE_TYPE_MO_SMS_CONTROL:
+ /*
+ * Comprehension Required according to the specs but not
+ * enabled in conformance tests in 3GPP 31.124.
+ */
+ ok = build_dataobj(&builder,
+ build_envelope_dataobj_device_ids, 0,
+ envelope,
+ build_dataobj_address, 0,
+ &envelope->sms_mo_control.sc_address,
+ build_dataobj_address, 0,
+ &envelope->sms_mo_control.dest_address,
+ build_dataobj_location_info, 0,
+ &envelope->sms_mo_control.location,
+ NULL);
+ break;
default:
return NULL;
};
diff --git a/src/stkutil.h b/src/stkutil.h
index 33a0f91..a57af48 100644
--- a/src/stkutil.h
+++ b/src/stkutil.h
@@ -1217,6 +1217,12 @@ struct stk_envelope_call_control {
} bc_repeat;
};
+struct stk_envelope_sms_mo_control {
+ struct stk_address sc_address;
+ struct stk_address dest_address;
+ struct stk_location_info location;
+};
+
struct stk_envelope {
enum stk_envelope_type type;
enum stk_device_identity_type src;
@@ -1226,6 +1232,7 @@ struct stk_envelope {
struct stk_envelope_cbs_pp_download cbs_pp_download;
struct stk_envelope_menu_selection menu_selection;
struct stk_envelope_call_control call_control;
+ struct stk_envelope_sms_mo_control sms_mo_control;
};
};
--
1.7.1.86.g0e460.dirty
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 15/20] test-stkutil: Tests for MO Short Message Control envelope builder
2010-06-07 10:08 [PATCH 01/20] Make stk_pdu_from_response use static buffers Andrzej Zaborowski
` (12 preceding siblings ...)
2010-06-07 10:08 ` [PATCH 14/20] stkutil: Add the MO Short Message " Andrzej Zaborowski
@ 2010-06-07 10:08 ` Andrzej Zaborowski
2010-06-07 10:08 ` [PATCH 16/20] For unitialised stk_location_info emit no data object Andrzej Zaborowski
` (4 subsequent siblings)
18 siblings, 0 replies; 29+ messages in thread
From: Andrzej Zaborowski @ 2010-06-07 10:08 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 3026 bytes --]
---
unit/test-stkutil.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 79 insertions(+), 0 deletions(-)
diff --git a/unit/test-stkutil.c b/unit/test-stkutil.c
index d8f6cf2..8769bfe 100644
--- a/unit/test-stkutil.c
+++ b/unit/test-stkutil.c
@@ -18448,6 +18448,78 @@ static const struct envelope_test call_control_data_131b = {
},
};
+static const unsigned char mo_short_message_control_111a[] = {
+ 0xd5, 0x22, 0x02, 0x02, 0x82, 0x81, 0x06, 0x09,
+ 0x91, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
+ 0xf8, 0x06, 0x06, 0x91, 0x10, 0x32, 0x54, 0x76,
+ 0xf8, 0x13, 0x09, 0x00, 0xf1, 0x10, 0x00, 0x01,
+ 0x00, 0x01, 0x00, 0x01,
+};
+
+static const struct envelope_test mo_short_message_control_data_111a = {
+ .pdu = mo_short_message_control_111a,
+ .pdu_len = sizeof(mo_short_message_control_111a),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_MO_SMS_CONTROL,
+ .src = STK_DEVICE_IDENTITY_TYPE_TERMINAL,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .sms_mo_control = {
+ .sc_address = {
+ .ton_npi = 0x91, /* Intl, ISDN */
+ .number = "112233445566778",
+ },
+ .dest_address = {
+ .ton_npi = 0x91, /* Intl, ISDN */
+ .number = "012345678",
+ },
+ .location = {
+ .mcc = "001",
+ .mnc = "01",
+ .lac_tac = 0x0001,
+ .has_ci = TRUE,
+ .ci = 0x0001,
+ .has_ext_ci = TRUE,
+ .ext_ci = 0x0001,
+ },
+ }},
+ },
+};
+
+static const unsigned char mo_short_message_control_111b[] = {
+ 0xd5, 0x20, 0x02, 0x02, 0x82, 0x81, 0x06, 0x09,
+ 0x91, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
+ 0xf8, 0x06, 0x06, 0x91, 0x10, 0x32, 0x54, 0x76,
+ 0xf8, 0x13, 0x07, 0x00, 0x11, 0x10, 0x00, 0x01,
+ 0x00, 0x01,
+};
+
+static const struct envelope_test mo_short_message_control_data_111b = {
+ .pdu = mo_short_message_control_111b,
+ .pdu_len = sizeof(mo_short_message_control_111b),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_MO_SMS_CONTROL,
+ .src = STK_DEVICE_IDENTITY_TYPE_TERMINAL,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .sms_mo_control = {
+ .sc_address = {
+ .ton_npi = 0x91, /* Intl, ISDN */
+ .number = "112233445566778",
+ },
+ .dest_address = {
+ .ton_npi = 0x91, /* Intl, ISDN */
+ .number = "012345678",
+ },
+ .location = {
+ .mcc = "001",
+ .mnc = "011",
+ .lac_tac = 0x0001,
+ .has_ci = TRUE,
+ .ci = 0x0001,
+ },
+ }},
+ },
+};
+
int main(int argc, char **argv)
{
g_test_init(&argc, &argv, NULL);
@@ -20159,5 +20231,12 @@ int main(int argc, char **argv)
g_test_add_data_func("/teststk/Call Control 1.3.1B",
&call_control_data_131b, test_envelope_encoding);
+ g_test_add_data_func("/teststk/MO Short Message Control 1.1.1A",
+ &mo_short_message_control_data_111a,
+ test_envelope_encoding);
+ g_test_add_data_func("/teststk/MO Short Message Control 1.1.1B",
+ &mo_short_message_control_data_111b,
+ test_envelope_encoding);
+
return g_test_run();
}
--
1.7.1.86.g0e460.dirty
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 16/20] For unitialised stk_location_info emit no data object
2010-06-07 10:08 [PATCH 01/20] Make stk_pdu_from_response use static buffers Andrzej Zaborowski
` (13 preceding siblings ...)
2010-06-07 10:08 ` [PATCH 15/20] test-stkutil: Tests for " Andrzej Zaborowski
@ 2010-06-07 10:08 ` Andrzej Zaborowski
2010-06-07 10:08 ` [PATCH 17/20] stkutil: Add the Event Download envelope builder Andrzej Zaborowski
` (3 subsequent siblings)
18 siblings, 0 replies; 29+ messages in thread
From: Andrzej Zaborowski @ 2010-06-07 10:08 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2256 bytes --]
Use a separate function to write empty Location Information data objects.
---
src/stkutil.c | 33 +++++++++++++++++++++++----------
1 files changed, 23 insertions(+), 10 deletions(-)
diff --git a/src/stkutil.c b/src/stkutil.c
index 9930d0b..f8e7568 100644
--- a/src/stkutil.c
+++ b/src/stkutil.c
@@ -3584,14 +3584,8 @@ static gboolean build_dataobj_location_info(struct stk_tlv_builder *tlv,
unsigned char tag = STK_DATA_OBJECT_TYPE_LOCATION_INFO;
guint8 mccmnc[3];
- if (li->mcc[0] == 0)
- /*
- * "If no location information is available for an access
- * technology, the respective data object shall have
- * length zero."
- */
- return stk_tlv_builder_open_container(tlv, cr, tag, FALSE) &&
- stk_tlv_builder_close_container(tlv);
+ if (li->mcc[0] == '\0')
+ return TRUE;
sim_encode_mcc_mnc(mccmnc, li->mcc, li->mnc);
@@ -3624,6 +3618,15 @@ static gboolean build_dataobj_location_info(struct stk_tlv_builder *tlv,
return stk_tlv_builder_close_container(tlv);
}
+static gboolean build_empty_dataobj_location_info(struct stk_tlv_builder *tlv,
+ const void *data, gboolean cr)
+{
+ unsigned char tag = STK_DATA_OBJECT_TYPE_LOCATION_INFO;
+
+ return stk_tlv_builder_open_container(tlv, cr, tag, FALSE) &&
+ stk_tlv_builder_close_container(tlv);
+}
+
/* Described in TS 102.223 Section 8.20
*
* See format note in parse_dataobj_imei.
@@ -4177,12 +4180,22 @@ static gboolean build_local_info(struct stk_tlv_builder *builder,
NULL) != TRUE)
return FALSE;
- for (i = 0; i < info->location_infos.access_techs.length; i++)
+ for (i = 0; i < info->location_infos.access_techs.length; i++) {
+ dataobj_writer location = build_dataobj_location_info;
+ /*
+ * "If no location information is available for an
+ * access technology, the respective data object
+ * shall have length zero."
+ */
+ if (info->location_infos.locations[i].mcc[0] == '\0')
+ location = build_empty_dataobj_location_info;
+
if (build_dataobj(builder,
- build_dataobj_location_info,
+ location,
0, &info->location_infos.locations[i],
NULL) != TRUE)
return FALSE;
+ }
return TRUE;
--
1.7.1.86.g0e460.dirty
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 17/20] stkutil: Add the Event Download envelope builder
2010-06-07 10:08 [PATCH 01/20] Make stk_pdu_from_response use static buffers Andrzej Zaborowski
` (14 preceding siblings ...)
2010-06-07 10:08 ` [PATCH 16/20] For unitialised stk_location_info emit no data object Andrzej Zaborowski
@ 2010-06-07 10:08 ` Andrzej Zaborowski
2010-06-10 1:06 ` Denis Kenzior
2010-06-07 10:08 ` [PATCH 18/20] test-stkutil: Tests for " Andrzej Zaborowski
` (2 subsequent siblings)
18 siblings, 1 reply; 29+ messages in thread
From: Andrzej Zaborowski @ 2010-06-07 10:08 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 32428 bytes --]
---
src/stkutil.c | 556 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
src/stkutil.h | 196 ++++++++++++++++++++-
2 files changed, 746 insertions(+), 6 deletions(-)
diff --git a/src/stkutil.c b/src/stkutil.c
index f8e7568..26af066 100644
--- a/src/stkutil.c
+++ b/src/stkutil.c
@@ -1208,8 +1208,10 @@ static gboolean parse_dataobj_other_address(
const unsigned char *data;
unsigned char len = comprehension_tlv_iter_get_length(iter);
- if (len == 0)
+ if (len == 0) {
+ oa->type = STK_ADDRESS_AUTO;
return TRUE;
+ }
if ((len != 5) && (len != 17))
return FALSE;
@@ -1434,6 +1436,7 @@ static gboolean parse_dataobj_remote_entity_address(
return FALSE;
}
+ rea->has_address = TRUE;
rea->coding_type = data[0];
memcpy(&rea->addr, data + 1, len - 1);
@@ -1623,6 +1626,7 @@ static gboolean parse_dataobj_frames_info(struct comprehension_tlv_iter *iter,
struct stk_frames_info *fi = user;
const unsigned char *data;
unsigned char len = comprehension_tlv_iter_get_length(iter);
+ unsigned int i;
if (len < 1)
return FALSE;
@@ -1635,12 +1639,18 @@ static gboolean parse_dataobj_frames_info(struct comprehension_tlv_iter *iter,
if ((len == 1 && data[0] != 0) || (len > 1 && data[0] == 0))
return FALSE;
+ if (len % 2 == 0)
+ return FALSE;
+
if (len == 1)
return TRUE;
fi->id = data[0];
- fi->len = len - 1;
- memcpy(fi->list, data + 1, fi->len);
+ fi->len = (len - 1) / 2;
+ for (i = 0; i < len; i++) {
+ fi->list[i].height = data[i * 2 + 1] & 0x1f;
+ fi->list[i].width = data[i * 2 + 2] & 0x7f;
+ }
return TRUE;
}
@@ -3688,6 +3698,81 @@ static gboolean build_dataobj_network_measurement_results(
return stk_tlv_builder_close_container(tlv);
}
+/* Described in TS 102.223 Section 8.25 */
+static gboolean build_dataobj_event_list(struct stk_tlv_builder *tlv,
+ const void *data, gboolean cr)
+{
+ const struct stk_event_list *list = data;
+ unsigned char tag = STK_DATA_OBJECT_TYPE_EVENT_LIST;
+
+ return stk_tlv_builder_open_container(tlv, cr, tag, FALSE) &&
+ stk_tlv_builder_append_bytes(tlv, list->list, list->len) &&
+ stk_tlv_builder_close_container(tlv);
+}
+
+/* Shortcut for a single Event type */
+static gboolean build_dataobj_event_type(struct stk_tlv_builder *tlv,
+ const void *data, gboolean cr)
+{
+ const struct stk_event_list list = {
+ .list = { *(unsigned char *) data },
+ .len = 1,
+ };
+
+ return build_dataobj_event_list(tlv, &list, cr);
+}
+
+/* Described in TS 102.223 Section 8.26 */
+static gboolean build_dataobj_cause(struct stk_tlv_builder *tlv,
+ const void *data, gboolean cr)
+{
+ const struct stk_cause *cause = data;
+ unsigned char tag = STK_DATA_OBJECT_TYPE_CAUSE;
+
+ if (cause->has_cause == FALSE)
+ return TRUE;
+
+ return stk_tlv_builder_open_container(tlv, cr, tag, FALSE) &&
+ stk_tlv_builder_append_bytes(tlv, cause->cause, cause->len) &&
+ stk_tlv_builder_close_container(tlv);
+}
+
+/* Described in TS 102.223 Section 8.27 */
+static gboolean build_dataobj_location_status(struct stk_tlv_builder *tlv,
+ const void *data, gboolean cr)
+{
+ const enum stk_service_state *state = data;
+ unsigned char tag = STK_DATA_OBJECT_TYPE_LOCATION_STATUS;
+
+ return stk_tlv_builder_open_container(tlv, cr, tag, FALSE) &&
+ stk_tlv_builder_append_byte(tlv, *state) &&
+ stk_tlv_builder_close_container(tlv);
+}
+
+/* Described in TS 131.111 Section 8.28 */
+static gboolean build_dataobj_transaction_ids(struct stk_tlv_builder *tlv,
+ const void *data, gboolean cr)
+{
+ const struct stk_transaction_id *id = data;
+ unsigned char tag = STK_DATA_OBJECT_TYPE_TRANSACTION_ID;
+
+ return stk_tlv_builder_open_container(tlv, cr, tag, FALSE) &&
+ stk_tlv_builder_append_bytes(tlv, id->list, id->len) &&
+ stk_tlv_builder_close_container(tlv);
+}
+
+/* Shortcut for a single Transaction ID */
+static gboolean build_dataobj_transaction_id(struct stk_tlv_builder *tlv,
+ const void *data, gboolean cr)
+{
+ const struct stk_transaction_id ids = {
+ .list = { *(unsigned char *) data },
+ .len = 1,
+ };
+
+ return build_dataobj_transaction_ids(tlv, &ids, cr);
+}
+
/* Described in 3GPP 31.111 Section 8.29 */
static gboolean build_dataobj_bcch_channel_list(struct stk_tlv_builder *tlv,
const void *data, gboolean cr)
@@ -3739,6 +3824,26 @@ static gboolean build_dataobj_cc_requested_action(struct stk_tlv_builder *tlv,
stk_tlv_builder_close_container(tlv);
}
+/* Described in TS 102.223 Section 8.33 */
+static gboolean build_dataobj_card_reader_status(struct stk_tlv_builder *tlv,
+ const void *data, gboolean cr)
+{
+ const struct stk_reader_status *status = data;
+ unsigned char tag = STK_DATA_OBJECT_TYPE_CARD_READER_STATUS;
+ unsigned char byte;
+
+ byte = status->id |
+ (status->removable << 3) |
+ (status->present << 4) |
+ (status->id1_size << 5) |
+ (status->card_present << 6) |
+ (status->card_powered << 7);
+
+ return stk_tlv_builder_open_container(tlv, cr, tag, FALSE) &&
+ stk_tlv_builder_append_byte(tlv, byte) &&
+ stk_tlv_builder_close_container(tlv);
+}
+
/* Described in TS 102.223 Section 8.37 */
static gboolean build_dataobj_timer_id(struct stk_tlv_builder *tlv,
const void *data, gboolean cr)
@@ -3873,6 +3978,112 @@ static gboolean build_dataobj_timing_advance(struct stk_tlv_builder *tlv,
stk_tlv_builder_close_container(tlv);
}
+/* Described in TS 102.223 Section 8.51 */
+static gboolean build_dataobj_browser_termination_cause(
+ struct stk_tlv_builder *tlv,
+ const void *data, gboolean cr)
+{
+ const enum stk_browser_termination_cause *cause = data;
+ unsigned char tag = STK_DATA_OBJECT_TYPE_BROWSER_TERMINATION_CAUSE;
+
+ return stk_tlv_builder_open_container(tlv, cr, tag, FALSE) &&
+ stk_tlv_builder_append_byte(tlv, *cause) &&
+ stk_tlv_builder_close_container(tlv);
+}
+
+/* Described in TS 102.223 Section 8.52 */
+static gboolean build_dataobj_bearer_description(struct stk_tlv_builder *tlv,
+ const void *data, gboolean cr)
+{
+ const struct stk_bearer_description *bd = data;
+ unsigned char tag = STK_DATA_OBJECT_TYPE_BEARER_DESCRIPTION;
+
+ if (bd->type == 0x00)
+ return TRUE;
+
+ return stk_tlv_builder_open_container(tlv, cr, tag, FALSE) &&
+ stk_tlv_builder_append_byte(tlv, bd->type) &&
+ stk_tlv_builder_append_bytes(tlv, bd->pars, bd->len) &&
+ stk_tlv_builder_close_container(tlv);
+}
+
+/* Described in TS 102.223 Section 8.54 */
+static gboolean build_dataobj_channel_data_length(
+ struct stk_tlv_builder *tlv,
+ const void *data, gboolean cr)
+{
+ const unsigned int *length = data;
+ unsigned char tag = STK_DATA_OBJECT_TYPE_CHANNEL_DATA_LENGTH;
+
+ return stk_tlv_builder_open_container(tlv, cr, tag, FALSE) &&
+ stk_tlv_builder_append_byte(tlv, MIN(*length, 255)) &&
+ stk_tlv_builder_close_container(tlv);
+}
+
+/* Described in TS 102.223 Section 8.56 */
+static gboolean build_dataobj_channel_status(struct stk_tlv_builder *tlv,
+ const void *data, gboolean cr)
+{
+ unsigned char tag = STK_DATA_OBJECT_TYPE_CHANNEL_STATUS;
+
+ return stk_tlv_builder_open_container(tlv, cr, tag, FALSE) &&
+ stk_tlv_builder_append_bytes(tlv, data, 2) &&
+ stk_tlv_builder_close_container(tlv);
+}
+
+/* Described in TS 102.223 Section 8.58 */
+static gboolean build_dataobj_other_address(struct stk_tlv_builder *tlv,
+ const void *data, gboolean cr)
+{
+ const struct stk_other_address *addr = data;
+ unsigned char tag = STK_DATA_OBJECT_TYPE_OTHER_ADDRESS;
+ gboolean ok = FALSE;
+
+ if (!addr->type)
+ return TRUE;
+
+ if (stk_tlv_builder_open_container(tlv, cr, tag, FALSE) == FALSE)
+ return FALSE;
+
+ switch (addr->type) {
+ case STK_ADDRESS_AUTO:
+ ok = TRUE;
+ break;
+ case STK_ADDRESS_IPV4:
+ ok =
+ stk_tlv_builder_append_byte(tlv, addr->type) &&
+ stk_tlv_builder_append_bytes(tlv,
+ (const guint8 *) &addr->addr.ipv4, 4);
+ break;
+ case STK_ADDRESS_IPV6:
+ ok =
+ stk_tlv_builder_append_byte(tlv, addr->type) &&
+ stk_tlv_builder_append_bytes(tlv, addr->addr.ipv6, 16);
+ break;
+ }
+
+ if (!ok)
+ return FALSE;
+
+ return stk_tlv_builder_close_container(tlv);
+}
+
+/* Described in TS 102.223 Section 8.59 */
+static gboolean build_dataobj_uicc_te_interface(struct stk_tlv_builder *tlv,
+ const void *data, gboolean cr)
+{
+ const struct stk_uicc_te_interface *iface = data;
+ unsigned char tag = STK_DATA_OBJECT_TYPE_UICC_TE_INTERFACE;
+
+ if (iface->protocol == 0 && iface->port == 0)
+ return TRUE;
+
+ return stk_tlv_builder_open_container(tlv, cr, tag, FALSE) &&
+ stk_tlv_builder_append_byte(tlv, iface->protocol) &&
+ stk_tlv_builder_append_short(tlv, iface->port) &&
+ stk_tlv_builder_close_container(tlv);
+}
+
/* Described in TS 102.223 Section 8.61 */
static gboolean build_dataobj_access_technologies(struct stk_tlv_builder *tlv,
const void *data, gboolean cr)
@@ -3903,6 +4114,66 @@ static gboolean build_dataobj_access_technology(struct stk_tlv_builder *tlv,
return build_dataobj_access_technologies(tlv, &techs, cr);
}
+/* Described in TS 102.223 Section 8.62 */
+static gboolean build_dataobj_display_parameters(struct stk_tlv_builder *tlv,
+ const void *data, gboolean cr)
+{
+ const struct stk_display_parameters *params = data;
+ unsigned char tag = STK_DATA_OBJECT_TYPE_DISPLAY_PARAMETERS;
+
+ return stk_tlv_builder_open_container(tlv, cr, tag, FALSE) &&
+ stk_tlv_builder_append_byte(tlv, params->height) &&
+ stk_tlv_builder_append_byte(tlv, params->width) &&
+ stk_tlv_builder_append_byte(tlv, params->effects) &&
+ stk_tlv_builder_close_container(tlv);
+}
+
+/* Described in TS 102.223 Section 8.63 */
+static gboolean build_dataobj_service_record(struct stk_tlv_builder *tlv,
+ const void *data, gboolean cr)
+{
+ const struct stk_service_record *rec = data;
+ unsigned char tag = STK_DATA_OBJECT_TYPE_SERVICE_RECORD;
+
+ return stk_tlv_builder_open_container(tlv, cr, tag, TRUE) &&
+ stk_tlv_builder_append_byte(tlv, rec->tech_id) &&
+ stk_tlv_builder_append_byte(tlv, rec->serv_id) &&
+ stk_tlv_builder_append_bytes(tlv, rec->serv_rec, rec->len) &&
+ stk_tlv_builder_close_container(tlv);
+}
+
+/* Described in TS 102.223 Section 8.68 */
+static gboolean build_dataobj_remote_entity_address(struct stk_tlv_builder *tlv,
+ const void *data, gboolean cr)
+{
+ const struct stk_remote_entity_address *addr = data;
+ unsigned char tag = STK_DATA_OBJECT_TYPE_REMOTE_ENTITY_ADDRESS;
+ gboolean ok = FALSE;
+
+ if (addr->has_address != TRUE)
+ return TRUE;
+
+ if (stk_tlv_builder_open_container(tlv, cr, tag, TRUE) != TRUE)
+ return FALSE;
+
+ if (stk_tlv_builder_append_byte(tlv, addr->coding_type) != TRUE)
+ return FALSE;
+
+ switch (addr->coding_type) {
+ case 0x00:
+ ok = stk_tlv_builder_append_bytes(tlv, addr->addr.ieee802, 6);
+ break;
+ case 0x01:
+ ok = stk_tlv_builder_append_bytes(tlv, addr->addr.irda, 4);
+ break;
+ }
+
+ if (!ok)
+ return FALSE;
+
+ return stk_tlv_builder_close_container(tlv);
+}
+
/* Described in TS 102.223 Section 8.69 */
static gboolean build_dataobj_esn(struct stk_tlv_builder *tlv,
const void *data, gboolean cr)
@@ -3986,6 +4257,44 @@ static gboolean build_dataobj_battery_state(struct stk_tlv_builder *tlv,
stk_tlv_builder_close_container(tlv);
}
+/* Described in TS 102.223 Section 8.77 */
+static gboolean build_dataobj_browsing_status(struct stk_tlv_builder *tlv,
+ const void *data, gboolean cr)
+{
+ const struct stk_common_byte_array *bs = data;
+ unsigned char tag = STK_DATA_OBJECT_TYPE_BROWSING_STATUS;
+
+ return stk_tlv_builder_open_container(tlv, cr, tag, TRUE) &&
+ stk_tlv_builder_append_bytes(tlv, bs->array, bs->len) &&
+ stk_tlv_builder_close_container(tlv);
+}
+
+/* Described in TS 102.223 Section 8.79 */
+static gboolean build_dataobj_frames_information(struct stk_tlv_builder *tlv,
+ const void *data, gboolean cr)
+{
+ const struct stk_frames_info *info = data;
+ unsigned char tag = STK_DATA_OBJECT_TYPE_FRAMES_INFO;
+ unsigned int i;
+
+ if (stk_tlv_builder_open_container(tlv, cr, tag, FALSE) != TRUE)
+ return FALSE;
+
+ if (stk_tlv_builder_append_byte(tlv, info->id) != TRUE)
+ return FALSE;
+
+ for (i = 0; i < info->len; i++) {
+ if (stk_tlv_builder_append_byte(tlv,
+ info->list[i].height) != TRUE)
+ return FALSE;
+ if (stk_tlv_builder_append_byte(tlv,
+ info->list[i].width) != TRUE)
+ return FALSE;
+ }
+
+ return stk_tlv_builder_close_container(tlv);
+}
+
/* Described in TS 102.223 Section 8.81 */
static gboolean build_dataobj_meid(struct stk_tlv_builder *tlv,
const void *data, gboolean cr)
@@ -4007,6 +4316,18 @@ static gboolean build_dataobj_meid(struct stk_tlv_builder *tlv,
stk_tlv_builder_close_container(tlv);
}
+/* Described in TS 131.111 Section 8.84 */
+static gboolean build_dataobj_i_wlan_access_status(struct stk_tlv_builder *tlv,
+ const void *data, gboolean cr)
+{
+ const enum stk_i_wlan_access_status *status = data;
+ unsigned char tag = STK_DATA_OBJECT_TYPE_I_WLAN_ACCESS_STATUS;
+
+ return stk_tlv_builder_open_container(tlv, cr, tag, FALSE) &&
+ stk_tlv_builder_append_byte(tlv, *status) &&
+ stk_tlv_builder_close_container(tlv);
+}
+
/* Described in TS 102.223 Section 8.90 */
static gboolean build_dataobj_broadcast_network_information(
struct stk_tlv_builder *tlv,
@@ -4021,6 +4342,50 @@ static gboolean build_dataobj_broadcast_network_information(
stk_tlv_builder_close_container(tlv);
}
+/* Described in TS 131.111 Section 8.91 / 3GPP 24.008 Section 10.5.5.15 */
+static gboolean build_dataobj_routing_area_id(struct stk_tlv_builder *tlv,
+ const void *data, gboolean cr)
+{
+ const struct stk_routing_area_info *rai = data;
+ unsigned char tag = STK_DATA_OBJECT_TYPE_ROUTING_AREA_INFO;
+ guint8 mccmnc[3];
+
+ if (rai->mcc[0] == 0)
+ return TRUE;
+
+ sim_encode_mcc_mnc(mccmnc, rai->mcc, rai->mnc);
+
+ return stk_tlv_builder_open_container(tlv, cr, tag, FALSE) &&
+ stk_tlv_builder_append_bytes(tlv, mccmnc, 3) &&
+ stk_tlv_builder_append_short(tlv, rai->lac) &&
+ stk_tlv_builder_append_byte(tlv, rai->rac) &&
+ stk_tlv_builder_close_container(tlv);
+}
+
+/* Described in TS 131.111 Section 8.92 */
+static gboolean build_dataobj_update_attach_type(struct stk_tlv_builder *tlv,
+ const void *data, gboolean cr)
+{
+ const enum stk_update_attach_type *type = data;
+ unsigned char tag = STK_DATA_OBJECT_TYPE_UPDATE_ATTACH_TYPE;
+
+ return stk_tlv_builder_open_container(tlv, cr, tag, FALSE) &&
+ stk_tlv_builder_append_byte(tlv, *type) &&
+ stk_tlv_builder_close_container(tlv);
+}
+
+/* Described in TS 131.111 Section 8.93 */
+static gboolean build_dataobj_rejection_cause_code(struct stk_tlv_builder *tlv,
+ const void *data, gboolean cr)
+{
+ const enum stk_rejection_cause_code *cause = data;
+ unsigned char tag = STK_DATA_OBJECT_TYPE_REJECTION_CAUSE_CODE;
+
+ return stk_tlv_builder_open_container(tlv, cr, tag, FALSE) &&
+ stk_tlv_builder_append_byte(tlv, *cause) &&
+ stk_tlv_builder_close_container(tlv);
+}
+
/* Described in TS 131.111 Section 8.98, 3GPP 24.301 Section 6.5.1 */
static gboolean build_dataobj_eps_pdn_conn_params(struct stk_tlv_builder *tlv,
const void *data, gboolean cr)
@@ -4038,6 +4403,25 @@ static gboolean build_dataobj_eps_pdn_conn_params(struct stk_tlv_builder *tlv,
stk_tlv_builder_close_container(tlv);
}
+/* Described in TS 131.111 Section 8.99 / 3GPP 24.301 Section 9.9.3.32 */
+static gboolean build_dataobj_tracking_area_id(struct stk_tlv_builder *tlv,
+ const void *data, gboolean cr)
+{
+ const struct stk_tracking_area_id *tai = data;
+ unsigned char tag = STK_DATA_OBJECT_TYPE_TRACKING_AREA_ID;
+ guint8 mccmnc[3];
+
+ if (tai->mcc[0] == 0)
+ return TRUE;
+
+ sim_encode_mcc_mnc(mccmnc, tai->mcc, tai->mnc);
+
+ return stk_tlv_builder_open_container(tlv, cr, tag, FALSE) &&
+ stk_tlv_builder_append_bytes(tlv, mccmnc, 3) &&
+ stk_tlv_builder_append_short(tlv, tai->tac) &&
+ stk_tlv_builder_close_container(tlv);
+}
+
static gboolean build_dataobj(struct stk_tlv_builder *tlv,
dataobj_writer builder_func, ...)
{
@@ -4372,6 +4756,169 @@ static gboolean build_envelope_dataobj_device_ids(struct stk_tlv_builder *tlv,
stk_tlv_builder_close_container(tlv);
}
+static gboolean build_envelope_event_download(struct stk_tlv_builder *builder,
+ const struct stk_envelope *envelope)
+{
+ const struct stk_envelope_event_download *evt =
+ &envelope->event_download;
+
+ if (build_dataobj(builder,
+ build_dataobj_event_type, DATAOBJ_FLAG_CR,
+ &evt->type,
+ build_envelope_dataobj_device_ids,
+ DATAOBJ_FLAG_CR,
+ envelope,
+ NULL) == FALSE)
+ return FALSE;
+
+ switch (evt->type) {
+ case STK_EVENT_TYPE_MT_CALL:
+ return build_dataobj(builder,
+ build_dataobj_transaction_id,
+ DATAOBJ_FLAG_CR,
+ &evt->mt_call.transaction_id,
+ build_dataobj_address, 0,
+ &evt->mt_call.caller_address,
+ build_dataobj_subaddress, 0,
+ &evt->mt_call.caller_subaddress,
+ NULL);
+ case STK_EVENT_TYPE_CALL_CONNECTED:
+ return build_dataobj(builder,
+ build_dataobj_transaction_id,
+ DATAOBJ_FLAG_CR,
+ &evt->call_connected.transaction_id,
+ NULL);
+ case STK_EVENT_TYPE_CALL_DISCONNECTED:
+ return build_dataobj(builder,
+ build_dataobj_transaction_ids,
+ DATAOBJ_FLAG_CR,
+ &evt->call_disconnected.transaction_ids,
+ build_dataobj_cause, 0,
+ &evt->call_disconnected.cause,
+ NULL);
+ case STK_EVENT_TYPE_LOCATION_STATUS:
+ return build_dataobj(builder,
+ build_dataobj_location_status,
+ DATAOBJ_FLAG_CR,
+ &evt->location_status.state,
+ build_dataobj_location_info, 0,
+ &evt->location_status.info,
+ NULL);
+ case STK_EVENT_TYPE_USER_ACTIVITY:
+ case STK_EVENT_TYPE_IDLE_SCREEN_AVAILABLE:
+ return TRUE;
+ case STK_EVENT_TYPE_CARD_READER_STATUS:
+ return build_dataobj(builder,
+ build_dataobj_card_reader_status,
+ DATAOBJ_FLAG_CR,
+ &evt->card_reader_status,
+ NULL);
+ case STK_EVENT_TYPE_LANGUAGE_SELECTION:
+ return build_dataobj(builder,
+ build_dataobj_language, DATAOBJ_FLAG_CR,
+ evt->language_selection,
+ NULL);
+ case STK_EVENT_TYPE_BROWSER_TERMINATION:
+ return build_dataobj(builder,
+ build_dataobj_browser_termination_cause,
+ DATAOBJ_FLAG_CR,
+ &evt->browser_termination.cause,
+ NULL);
+ case STK_EVENT_TYPE_DATA_AVAILABLE:
+ return build_dataobj(builder,
+ build_dataobj_channel_status,
+ DATAOBJ_FLAG_CR,
+ &evt->data_available.channel_status,
+ build_dataobj_channel_data_length,
+ DATAOBJ_FLAG_CR,
+ &evt->data_available.channel_data_len,
+ NULL);
+ case STK_EVENT_TYPE_CHANNEL_STATUS:
+ return build_dataobj(builder,
+ build_dataobj_channel_status,
+ DATAOBJ_FLAG_CR,
+ &evt->channel_status.status,
+ build_dataobj_bearer_description,
+ DATAOBJ_FLAG_CR,
+ &evt->channel_status.bearer_desc,
+ build_dataobj_other_address,
+ DATAOBJ_FLAG_CR,
+ &evt->channel_status.address,
+ NULL);
+ case STK_EVENT_TYPE_SINGLE_ACCESS_TECHNOLOGY_CHANGE:
+ return build_dataobj(builder,
+ build_dataobj_access_technology,
+ DATAOBJ_FLAG_CR,
+ &evt->access_technology_change,
+ NULL);
+ case STK_EVENT_TYPE_DISPLAY_PARAMETERS_CHANGED:
+ return build_dataobj(builder,
+ build_dataobj_display_parameters,
+ DATAOBJ_FLAG_CR,
+ &evt->display_params_changed,
+ NULL);
+ case STK_EVENT_TYPE_LOCAL_CONNECTION:
+ return build_dataobj(builder,
+ build_dataobj_service_record,
+ DATAOBJ_FLAG_CR,
+ &evt->local_connection.service_record,
+ build_dataobj_remote_entity_address, 0,
+ &evt->local_connection.remote_addr,
+ build_dataobj_uicc_te_interface, 0,
+ &evt->local_connection.transport_level,
+ build_dataobj_other_address,
+ 0,
+ &evt->local_connection.transport_addr,
+ NULL);
+ case STK_EVENT_TYPE_NETWORK_SEARCH_MODE_CHANGE:
+ return build_dataobj(builder,
+ build_dataobj_network_search_mode,
+ DATAOBJ_FLAG_CR,
+ &evt->network_search_mode_change,
+ NULL);
+ case STK_EVENT_TYPE_BROWSING_STATUS:
+ return build_dataobj(builder,
+ build_dataobj_browsing_status,
+ DATAOBJ_FLAG_CR,
+ &evt->browsing_status,
+ NULL);
+ case STK_EVENT_TYPE_FRAMES_INFORMATION_CHANGE:
+ return build_dataobj(builder,
+ build_dataobj_frames_information,
+ DATAOBJ_FLAG_CR,
+ &evt->frames_information_change,
+ NULL);
+ case STK_EVENT_TYPE_I_WLAN_ACCESS_STATUS:
+ return build_dataobj(builder,
+ build_dataobj_i_wlan_access_status,
+ DATAOBJ_FLAG_CR,
+ &evt->i_wlan_access_status,
+ NULL);
+ case STK_EVENT_TYPE_NETWORK_REJECTION:
+ return build_dataobj(builder,
+ build_dataobj_location_info, 0,
+ &evt->network_rejection.location,
+ build_dataobj_routing_area_id, 0,
+ &evt->network_rejection.rai,
+ build_dataobj_tracking_area_id, 0,
+ &evt->network_rejection.tai,
+ build_dataobj_access_technology,
+ DATAOBJ_FLAG_CR,
+ &evt->network_rejection.access_tech,
+ build_dataobj_update_attach_type,
+ DATAOBJ_FLAG_CR,
+ &evt->network_rejection.update_attach,
+ build_dataobj_rejection_cause_code,
+ DATAOBJ_FLAG_CR,
+ &evt->network_rejection.cause,
+ NULL);
+ case STK_EVENT_TYPE_HCI_CONNECTIVITY_EVENT:
+ return TRUE;
+ default:
+ return FALSE;
+ }
+}
+
const unsigned char *stk_pdu_from_envelope(const struct stk_envelope *envelope,
unsigned int *out_length)
{
@@ -4470,6 +5017,9 @@ const unsigned char *stk_pdu_from_envelope(const struct stk_envelope *envelope,
&envelope->sms_mo_control.location,
NULL);
break;
+ case STK_ENVELOPE_TYPE_EVENT_DOWNLOAD:
+ ok = build_envelope_event_download(&builder, envelope);
+ break;
default:
return NULL;
};
diff --git a/src/stkutil.h b/src/stkutil.h
index a57af48..a24ace7 100644
--- a/src/stkutil.h
+++ b/src/stkutil.h
@@ -154,6 +154,8 @@ enum stk_data_object_type {
STK_DATA_OBJECT_TYPE_NETWORK_ACCESS_NAME = 0x47,
STK_DATA_OBJECT_TYPE_CDMA_SMS_TPDU = 0x48,
STK_DATA_OBJECT_TYPE_REMOTE_ENTITY_ADDRESS = 0x49,
+ STK_DATA_OBJECT_TYPE_I_WLAN_ID_TAG = 0x4A,
+ STK_DATA_OBJECT_TYPE_I_WLAN_ACCESS_STATUS = 0x4B,
STK_DATA_OBJECT_TYPE_TEXT_ATTRIBUTE = 0x50,
STK_DATA_OBJECT_TYPE_ITEM_TEXT_ATTRIBUTE_LIST = 0x51,
STK_DATA_OBJECT_TYPE_PDP_ACTIVATION_PARAMETER = 0x52,
@@ -174,11 +176,13 @@ enum stk_data_object_type {
STK_DATA_OBJECT_TYPE_REGISTRY_APPLICATION_DATA = 0x71,
STK_DATA_OBJECT_TYPE_ROUTING_AREA_INFO = 0x73,
STK_DATA_OBJECT_TYPE_UPDATE_ATTACH_TYPE = 0x74,
+ STK_DATA_OBJECT_TYPE_REJECTION_CAUSE_CODE = 0x75,
STK_DATA_OBJECT_TYPE_NMEA_SENTENCE = 0x78,
STK_DATA_OBJECT_TYPE_PLMN_LIST = 0x79,
STK_DATA_OBJECT_TYPE_BROADCAST_NETWORK_INFO = 0x7A,
STK_DATA_OBJECT_TYPE_ACTIVATE_DESCRIPTOR = 0x7B,
STK_DATA_OBJECT_TYPE_EPS_PDN_CONN_ACTIVATION_REQ = 0x7C,
+ STK_DATA_OBJECT_TYPE_TRACKING_AREA_ID = 0x7D,
};
enum stk_device_identity_type {
@@ -404,6 +408,7 @@ enum stk_bearer_type {
};
enum stk_address_type {
+ STK_ADDRESS_AUTO = -1,
STK_ADDRESS_IPV4 = 0x21,
STK_ADDRESS_IPV6 = 0x57
};
@@ -448,6 +453,100 @@ enum stk_broadcast_network_technology {
STK_BROADCAST_NETWORK_T_DMB = 0x03
};
+enum stk_i_wlan_access_status {
+ STK_I_WLAN_STATUS_NO_COVERAGE = 0x00,
+ STK_I_WLAN_STATUS_NOT_CONNECTED = 0x01,
+ STK_I_WLAN_STATUS_CONNECTED = 0x02,
+};
+
+enum stk_update_attach_type {
+ STK_UPDATE_ATTACH_NORMAL_LOCATION_UPDATING = 0x00,
+ STK_UPDATE_ATTACH_PERIODIC_UPDATING = 0x01,
+ STK_UPDATE_ATTACH_IMSI_ATTACH = 0x02,
+ STK_UPDATE_ATTACH_GPRS_ATTACH = 0x03,
+ STK_UPDATE_ATTACH_GPRS_IMSI_ATTACH = 0x04,
+ STK_UPDATE_ATTACH_RA_UPDATING = 0x05,
+ STK_UPDATE_ATTACH_RA_LA_UPDATING = 0x06,
+ STK_UPDATE_ATTACH_RA_LA_UPDATING_IMSI_ATTACH = 0x07,
+ STK_UPDATE_ATTACH_PERIODIC_RA_UPDATING = 0x08,
+ STK_UPDATE_ATTACH_EPS_ATTACH = 0x09,
+ STK_UPDATE_ATTACH_EPS_IMSI_ATTACH = 0x0a,
+ STK_UPDATE_ATTACH_TA_UPDATING = 0x0b,
+ STK_UPDATE_ATTACH_TA_LA_UPDATING = 0x0c,
+ STK_UPDATE_ATTACH_TA_LA_UPDATING_IMSI_ATTACH = 0x0d,
+ STK_UPDATE_ATTACH_PERIDIC_TA_UPDATING = 0x0e,
+};
+
+enum stk_rejection_cause_code {
+ /* MM and GMM codes (GERAN/UTRAN) */
+ STK_CAUSE_GMM_IMSI_UNKNOWN_IN_HLR = 0x02,
+ STK_CAUSE_GMM_ILLEGAL_MS = 0x03,
+ STK_CAUSE_GMM_IMSI_UNKNOWN_IN_VLR = 0x04,
+ STK_CAUSE_GMM_IMEI_NOT_ACCEPTED = 0x05,
+ STK_CAUSE_GMM_ILLEGAL_ME = 0x06,
+ STK_CAUSE_GMM_GPRS_NOT_ALLOWED = 0x07,
+ STK_CAUSE_GMM_GPRS_AND_NON_GPRS_NOT_ALLOWED = 0x08,
+ STK_CAUSE_GMM_IMEI_NOT_DERIVED_BY_NETWORK = 0x09,
+ STK_CAUSE_GMM_IMPLICITLY_DETACHED = 0x0a,
+ STK_CAUSE_GMM_PLMN_NOT_ALLOWED = 0x0b,
+ STK_CAUSE_GMM_LAC_NOT_ALLOWED = 0x0c,
+ STK_CAUSE_GMM_ROAMING_NOT_ALLOWED = 0x0d,
+ STK_CAUSE_GMM_GPRS_NOT_ALLOWED_IN_PLMN = 0x0e,
+ STK_CAUSE_GMM_NO_SUITABLE_CELLS = 0x0f,
+ STK_CAUSE_GMM_MSC_TEMPORARILY_UNREACHABLE = 0x10,
+ STK_CAUSE_GMM_NETWORK_FAILURE = 0x11,
+ STK_CAUSE_GMM_MAC_FAILURE = 0x14,
+ STK_CAUSE_GMM_SYNCH_FAILURE = 0x15,
+ STK_CAUSE_GMM_CONGESTION = 0x16,
+ STK_CAUSE_GMM_GSM_AUTHENTICATION_UNACCEPTABLE = 0x17,
+ STK_CAUSE_GMM_NOT_AUTHORISED_FOR_CSG = 0x19,
+ STK_CAUSE_GMM_SERVICE_OPTION_NOT_SUPPORTED = 0x20,
+ STK_CAUSE_GMM_SERVICE_OPTION_NOT_SUBSCRIBED = 0x21,
+ STK_CAUSE_GMM_SERVICE_OPTION_TEMPORARY_DEFUNC = 0x22,
+ STK_CAUSE_GMM_CALL_NOT_IDENTIFIED = 0x26,
+ STK_CAUSE_GMM_NO_PDP_CONTEXT_ACTIVATED = 0x28,
+ STK_CAUSE_GMM_RETRY_ON_NEW_CELL = 0x30, /* to 0x3f */
+ STK_CAUSE_GMM_SEMANTICALLY_INCORRECT_MESSAGE = 0x5f,
+ STK_CAUSE_GMM_INVALID_MANDATORY_INFO = 0x60,
+ STK_CAUSE_GMM_MESSAGE_TYPE_UNKNOWN = 0x61,
+ STK_CAUSE_GMM_MESSAGE_TYPE_INCOMPATIBLE_STATE = 0x62,
+ STK_CAUSE_GMM_IE_UNKNOWN = 0x63,
+ STK_CAUSE_GMM_CONDITIONAL_IE_ERROR = 0x64,
+ STK_CAUSE_GMM_MESSAGE_INCOMPATIBLE_WITH_STATE = 0x65,
+ STK_CAUSE_GMM_PROTOCOL_ERROR = 0x6f,
+ /* EMM codes (E-UTRAN) */
+ STK_CAUSE_EMM_IMSI_UNKNOWN_IN_HSS = 0x02,
+ STK_CAUSE_EMM_ILLEGAL_UE = 0x03,
+ STK_CAUSE_EMM_ILLEGAL_ME = 0x06,
+ STK_CAUSE_EMM_EPS_NOT_ALLOWED = 0x07,
+ STK_CAUSE_EMM_EPS_AND_NON_EPS_NOT_ALLOWED = 0x08,
+ STK_CAUSE_EMM_IMEI_NOT_DERIVED_BY_NETWORK = 0x09,
+ STK_CAUSE_EMM_IMPLICITLY_DETACHED = 0x0a,
+ STK_CAUSE_EMM_PLMN_NOT_ALLOWED = 0x0b,
+ STK_CAUSE_EMM_TAC_NOT_ALLOWED = 0x0c,
+ STK_CAUSE_EMM_ROAMING_NOT_ALLOWED = 0x0d,
+ STK_CAUSE_EMM_EPS_NOT_ALLOWED_IN_PLMN = 0x0e,
+ STK_CAUSE_EMM_NO_SUITABLE_CELLS = 0x0f,
+ STK_CAUSE_EMM_MSC_TEMPORARILY_UNREACHABLE = 0x10,
+ STK_CAUSE_EMM_NETWORK_FAILURE = 0x11,
+ STK_CAUSE_EMM_MAC_FAILURE = 0x14,
+ STK_CAUSE_EMM_SYNCH_FAILURE = 0x15,
+ STK_CAUSE_EMM_CONGESTION = 0x16,
+ STK_CAUSE_EMM_SECURITY_MODE_REJECTED = 0x18,
+ STK_CAUSE_EMM_NOT_AUTHORISED_FOR_CSG = 0x19,
+ STK_CAUSE_EMM_CS_FALLBACK_NOT_ALLOWED = 0x26,
+ STK_CAUSE_EMM_CS_DOMAIN_TEMPORARY_UNAVAILABLE = 0x27,
+ STK_CAUSE_EMM_NO_EPS_BEARER_CONTEXT_ACTIVATED = 0x28,
+ STK_CAUSE_EMM_SEMANTICALLY_INCORRECT_MESSAGE = 0x5f,
+ STK_CAUSE_EMM_INVALID_MANDATORY_INFO = 0x60,
+ STK_CAUSE_EMM_MESSAGE_TYPE_UNKNOWN = 0x61,
+ STK_CAUSE_EMM_MESSAGE_TYPE_INCOMPATIBLE_STATE = 0x62,
+ STK_CAUSE_EMM_IE_UNKNOWN = 0x63,
+ STK_CAUSE_EMM_CONDITIONAL_IE_ERROR = 0x64,
+ STK_CAUSE_EMM_MESSAGE_INCOMPATIBLE_WITH_STATE = 0x65,
+ STK_CAUSE_EMM_PROTOCOL_ERROR = 0x6f,
+};
+
/* For data object that only has a byte array with undetermined length */
struct stk_common_byte_array {
unsigned char *array;
@@ -609,6 +708,16 @@ struct stk_item_icon_id_list {
unsigned int len;
};
+/* Defined in TS 102.223 Section 8.33 */
+struct stk_reader_status {
+ int id;
+ ofono_bool_t removable;
+ ofono_bool_t present;
+ ofono_bool_t id1_size;
+ ofono_bool_t card_present;
+ ofono_bool_t card_powered;
+};
+
/*
* According to 102.223 Section 8.34 the length of CTLV is 1 byte. This means
* that the maximum size is 127 according to the rules of CTLVs.
@@ -679,10 +788,10 @@ struct stk_card_reader_id {
struct stk_other_address {
union {
/* Network Byte Order */
- unsigned int ipv4;
+ guint32 ipv4;
unsigned char ipv6[16];
} addr;
- unsigned char type;
+ enum stk_address_type type;
};
/* Defined in TS 102.223 Section 8.59 */
@@ -744,6 +853,7 @@ struct stk_attribute_info {
*/
struct stk_remote_entity_address {
unsigned char coding_type;
+ ofono_bool_t has_address;
union {
unsigned char ieee802[6];
unsigned char irda[4];
@@ -799,7 +909,9 @@ struct stk_frame_layout {
*/
struct stk_frames_info {
unsigned char id;
- unsigned char list[126];
+ struct {
+ unsigned int width, height;
+ } list[66];
unsigned int len;
};
@@ -864,6 +976,21 @@ struct stk_broadcast_network_information {
unsigned int len;
};
+/* Defined in TS 131.111 Section 8.91 */
+struct stk_routing_area_info {
+ char mnc[OFONO_MAX_MNC_LENGTH + 1];
+ char mcc[OFONO_MAX_MCC_LENGTH + 1];
+ unsigned short lac;
+ unsigned char rac;
+};
+
+/* Defined in TS 131.111 Section 8.99 */
+struct stk_tracking_area_id {
+ char mnc[OFONO_MAX_MNC_LENGTH + 1];
+ char mcc[OFONO_MAX_MCC_LENGTH + 1];
+ unsigned short tac;
+};
+
struct stk_command_display_text {
char *text;
struct stk_icon_id icon_id;
@@ -1223,6 +1350,68 @@ struct stk_envelope_sms_mo_control {
struct stk_location_info location;
};
+struct stk_envelope_event_download {
+ enum stk_event_type type;
+ union {
+ struct {
+ unsigned char transaction_id;
+ struct stk_address caller_address;
+ struct stk_subaddress caller_subaddress;
+ } mt_call;
+ struct {
+ unsigned char transaction_id;
+ } call_connected;
+ struct {
+ struct stk_transaction_id transaction_ids;
+ struct stk_cause cause;
+ } call_disconnected;
+ struct {
+ enum stk_service_state state;
+ /* Present when state indicated Normal Service */
+ struct stk_location_info info;
+ } location_status;
+ struct stk_reader_status card_reader_status;
+ const char *language_selection;
+ struct {
+ enum stk_browser_termination_cause cause;
+ } browser_termination;
+ struct {
+ unsigned char channel_status[2];
+ unsigned int channel_data_len;
+ } data_available;
+ struct {
+ unsigned char status[2];
+ struct stk_bearer_description bearer_desc;
+ struct stk_other_address address;
+ } channel_status;
+ struct stk_access_technologies access_technology_change;
+ struct stk_display_parameters display_params_changed;
+ struct {
+ /*
+ * Note the service record subfield is not required,
+ * only the Technology id and Service id.
+ */
+ struct stk_service_record service_record;
+ struct stk_remote_entity_address remote_addr;
+ struct stk_uicc_te_interface transport_level;
+ /* Only present if transport_level present */
+ struct stk_other_address transport_addr;
+ } local_connection;
+ enum stk_network_search_mode network_search_mode_change;
+ struct stk_common_byte_array browsing_status;
+ struct stk_frames_info frames_information_change;
+ enum stk_i_wlan_access_status i_wlan_access_status;
+ struct {
+ struct stk_location_info location;
+ struct stk_routing_area_info rai;
+ struct stk_tracking_area_id tai;
+ enum stk_access_technology_type access_tech;
+ enum stk_update_attach_type update_attach;
+ enum stk_rejection_cause_code cause;
+ } network_rejection;
+ };
+};
+
struct stk_envelope {
enum stk_envelope_type type;
enum stk_device_identity_type src;
@@ -1233,6 +1422,7 @@ struct stk_envelope {
struct stk_envelope_menu_selection menu_selection;
struct stk_envelope_call_control call_control;
struct stk_envelope_sms_mo_control sms_mo_control;
+ struct stk_envelope_event_download event_download;
};
};
--
1.7.1.86.g0e460.dirty
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 18/20] test-stkutil: Tests for Event Download envelope builder
2010-06-07 10:08 [PATCH 01/20] Make stk_pdu_from_response use static buffers Andrzej Zaborowski
` (15 preceding siblings ...)
2010-06-07 10:08 ` [PATCH 17/20] stkutil: Add the Event Download envelope builder Andrzej Zaborowski
@ 2010-06-07 10:08 ` Andrzej Zaborowski
2010-06-07 10:08 ` [PATCH 19/20] stkutil: Add the Timer Expiration " Andrzej Zaborowski
2010-06-07 10:08 ` [PATCH 20/20] test-stkutil: Tests for " Andrzej Zaborowski
18 siblings, 0 replies; 29+ messages in thread
From: Andrzej Zaborowski @ 2010-06-07 10:08 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 38871 bytes --]
---
unit/test-stkutil.c | 1204 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 1204 insertions(+), 0 deletions(-)
diff --git a/unit/test-stkutil.c b/unit/test-stkutil.c
index 8769bfe..ad66208 100644
--- a/unit/test-stkutil.c
+++ b/unit/test-stkutil.c
@@ -18520,6 +18520,1084 @@ static const struct envelope_test mo_short_message_control_data_111b = {
},
};
+static const unsigned char event_download_mt_call_111[] = {
+ 0xd6, 0x0a, 0x99, 0x01, 0x00, 0x82, 0x02, 0x83,
+ 0x81, 0x9c, 0x01, 0x00,
+ /*
+ * Byte 3 changed to 0x99 and byte 10 to 0x9c (Comprehension
+ * Required should be set according to TS 102 223 7.5.1.2)
+ */
+};
+
+static const struct envelope_test event_download_mt_call_data_111 = {
+ .pdu = event_download_mt_call_111,
+ .pdu_len = sizeof(event_download_mt_call_111),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_EVENT_DOWNLOAD,
+ .src = STK_DEVICE_IDENTITY_TYPE_NETWORK,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .event_download = {
+ .type = STK_EVENT_TYPE_MT_CALL,
+ { .mt_call = {
+ .transaction_id = 0,
+ }},
+ }},
+ },
+};
+
+static const unsigned char event_download_mt_call_112[] = {
+ 0xd6, 0x0f, 0x99, 0x01, 0x00, 0x82, 0x02, 0x83,
+ 0x81, 0x9c, 0x01, 0x00, 0x06, 0x03, 0x81, 0x89,
+ 0x67,
+ /*
+ * Byte 3 changed to 0x99 and byte 10 to 0x9c and byte 13 to
+ * 0x06 (Comprehension Required should be set according to
+ * TS 102 223 7.5.1.2)
+ */
+};
+
+static const struct envelope_test event_download_mt_call_data_112 = {
+ .pdu = event_download_mt_call_112,
+ .pdu_len = sizeof(event_download_mt_call_112),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_EVENT_DOWNLOAD,
+ .src = STK_DEVICE_IDENTITY_TYPE_NETWORK,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .event_download = {
+ .type = STK_EVENT_TYPE_MT_CALL,
+ { .mt_call = {
+ .transaction_id = 0,
+ .caller_address = {
+ .ton_npi = 0x81, /* Unknown, ISDN */
+ .number = "9876",
+ },
+ }},
+ }},
+ },
+};
+
+static const unsigned char event_download_call_connected_111[] = {
+ 0xd6, 0x0a, 0x99, 0x01, 0x01, 0x82, 0x02, 0x82,
+ 0x81, 0x9c, 0x01, 0x80,
+ /*
+ * Byte 3 changed to 0x99 and byte 10 to 0x9c (Comprehension
+ * Required should be set according to TS 102 223 7.5.2.2)
+ */
+};
+
+static const struct envelope_test event_download_call_connected_data_111 = {
+ .pdu = event_download_call_connected_111,
+ .pdu_len = sizeof(event_download_call_connected_111),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_EVENT_DOWNLOAD,
+ .src = STK_DEVICE_IDENTITY_TYPE_TERMINAL,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .event_download = {
+ .type = STK_EVENT_TYPE_CALL_CONNECTED,
+ { .call_connected = {
+ .transaction_id = 0x80,
+ }},
+ }},
+ },
+};
+
+static const unsigned char event_download_call_connected_112[] = {
+ 0xd6, 0x0a, 0x99, 0x01, 0x01, 0x82, 0x02, 0x83,
+ 0x81, 0x9c, 0x01, 0x80,
+ /*
+ * Byte 3 changed to 0x99 and byte 10 to 0x9c (Comprehension
+ * Required should be set according to TS 102 223 7.5.2.2)
+ */
+};
+
+static const struct envelope_test event_download_call_connected_data_112 = {
+ .pdu = event_download_call_connected_112,
+ .pdu_len = sizeof(event_download_call_connected_112),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_EVENT_DOWNLOAD,
+ .src = STK_DEVICE_IDENTITY_TYPE_NETWORK,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .event_download = {
+ .type = STK_EVENT_TYPE_CALL_CONNECTED,
+ { .call_connected = {
+ .transaction_id = 0x80,
+ }},
+ }},
+ },
+};
+
+static const unsigned char event_download_call_disconnected_111[] = {
+ 0xd6, 0x0a, 0x99, 0x01, 0x02, 0x82, 0x02, 0x83,
+ 0x81, 0x9c, 0x01, 0x80,
+ /*
+ * Byte 3 changed to 0x99 and byte 10 to 0x9c (Comprehension
+ * Required should be set according to TS 102 223 7.5.3.2)
+ */
+};
+
+static const struct envelope_test event_download_call_disconnected_data_111 = {
+ .pdu = event_download_call_disconnected_111,
+ .pdu_len = sizeof(event_download_call_disconnected_111),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_EVENT_DOWNLOAD,
+ .src = STK_DEVICE_IDENTITY_TYPE_NETWORK,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .event_download = {
+ .type = STK_EVENT_TYPE_CALL_DISCONNECTED,
+ { .call_disconnected = {
+ .transaction_ids = {
+ .len = 1,
+ .list = { 0x80 },
+ },
+ }},
+ }},
+ },
+};
+
+static const unsigned char event_download_call_disconnected_112a[] = {
+ 0xd6, 0x0a, 0x99, 0x01, 0x02, 0x82, 0x02, 0x82,
+ 0x81, 0x9c, 0x01, 0x80,
+ /*
+ * Byte 3 changed to 0x99 and byte 10 to 0x9c (Comprehension
+ * Required should be set according to TS 102 223 7.5.3.2)
+ */
+};
+
+static const struct envelope_test
+ event_download_call_disconnected_data_112a = {
+ .pdu = event_download_call_disconnected_112a,
+ .pdu_len = sizeof(event_download_call_disconnected_112a),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_EVENT_DOWNLOAD,
+ .src = STK_DEVICE_IDENTITY_TYPE_TERMINAL,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .event_download = {
+ .type = STK_EVENT_TYPE_CALL_DISCONNECTED,
+ { .call_disconnected = {
+ .transaction_ids = {
+ .len = 1,
+ .list = { 0x80 },
+ },
+ }},
+ }},
+ },
+};
+
+static const unsigned char event_download_call_disconnected_112b[] = {
+ 0xd6, 0x0e, 0x99, 0x01, 0x02, 0x82, 0x02, 0x82,
+ 0x81, 0x9c, 0x01, 0x80, 0x1a, 0x02, 0x60, 0x90,
+ /*
+ * Byte 3 changed to 0x99 and byte 10 to 0x9c and byte 13 to
+ * 1a (Comprehension Required should be set according to TS
+ * 102 223 7.5.3.2)
+ */
+};
+
+static const struct envelope_test
+ event_download_call_disconnected_data_112b = {
+ .pdu = event_download_call_disconnected_112b,
+ .pdu_len = sizeof(event_download_call_disconnected_112b),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_EVENT_DOWNLOAD,
+ .src = STK_DEVICE_IDENTITY_TYPE_TERMINAL,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .event_download = {
+ .type = STK_EVENT_TYPE_CALL_DISCONNECTED,
+ { .call_disconnected = {
+ .transaction_ids = {
+ .len = 1,
+ .list = { 0x80 },
+ },
+ .cause = {
+ .has_cause = TRUE,
+ .len = 2,
+ /* Normal call clearing */
+ .cause = { 0x60, 0x90 },
+ },
+ }},
+ }},
+ },
+};
+
+static const unsigned char event_download_call_disconnected_112c[] = {
+ 0xd6, 0x0e, 0x99, 0x01, 0x02, 0x82, 0x02, 0x82,
+ 0x81, 0x9c, 0x01, 0x80, 0x1a, 0x02, 0xe0, 0x90,
+ /*
+ * Byte 3 changed to 0x99 and byte 10 to 0x9c and byte 13 to
+ * 1a (Comprehension Required should be set according to TS
+ * 102 223 7.5.3.2)
+ */
+};
+
+static const struct envelope_test
+ event_download_call_disconnected_data_112c = {
+ .pdu = event_download_call_disconnected_112c,
+ .pdu_len = sizeof(event_download_call_disconnected_112c),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_EVENT_DOWNLOAD,
+ .src = STK_DEVICE_IDENTITY_TYPE_TERMINAL,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .event_download = {
+ .type = STK_EVENT_TYPE_CALL_DISCONNECTED,
+ { .call_disconnected = {
+ .transaction_ids = {
+ .len = 1,
+ .list = { 0x80 },
+ },
+ .cause = {
+ .has_cause = TRUE,
+ .len = 2,
+ /* Normal call clearing */
+ .cause = { 0xe0, 0x90 },
+ },
+ }},
+ }},
+ },
+};
+
+static const unsigned char event_download_call_disconnected_113a[] = {
+ 0xd6, 0x0e, 0x99, 0x01, 0x02, 0x82, 0x02, 0x83,
+ 0x81, 0x9c, 0x01, 0x00, 0x1a, 0x02, 0x60, 0x90,
+ /*
+ * Byte 3 changed to 0x99 and byte 10 to 0x9c and byte 13 to
+ * 1a (Comprehension Required should be set according to TS
+ * 102 223 7.5.3.2)
+ */
+};
+
+static const struct envelope_test
+ event_download_call_disconnected_data_113a = {
+ .pdu = event_download_call_disconnected_113a,
+ .pdu_len = sizeof(event_download_call_disconnected_113a),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_EVENT_DOWNLOAD,
+ .src = STK_DEVICE_IDENTITY_TYPE_NETWORK,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .event_download = {
+ .type = STK_EVENT_TYPE_CALL_DISCONNECTED,
+ { .call_disconnected = {
+ .transaction_ids = {
+ .len = 1,
+ .list = { 0 },
+ },
+ .cause = {
+ .has_cause = TRUE,
+ .len = 2,
+ /* Normal call clearing */
+ .cause = { 0x60, 0x90 },
+ },
+ }},
+ }},
+ },
+};
+
+static const unsigned char event_download_call_disconnected_113b[] = {
+ 0xd6, 0x0e, 0x99, 0x01, 0x02, 0x82, 0x02, 0x83,
+ 0x81, 0x9c, 0x01, 0x00, 0x1a, 0x02, 0xe0, 0x90,
+ /*
+ * Byte 3 changed to 0x99 and byte 10 to 0x9c and byte 13 to
+ * 1a (Comprehension Required should be set according to TS
+ * 102 223 7.5.3.2)
+ */
+};
+
+static const struct envelope_test
+ event_download_call_disconnected_data_113b = {
+ .pdu = event_download_call_disconnected_113b,
+ .pdu_len = sizeof(event_download_call_disconnected_113b),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_EVENT_DOWNLOAD,
+ .src = STK_DEVICE_IDENTITY_TYPE_NETWORK,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .event_download = {
+ .type = STK_EVENT_TYPE_CALL_DISCONNECTED,
+ { .call_disconnected = {
+ .transaction_ids = {
+ .len = 1,
+ .list = { 0 },
+ },
+ .cause = {
+ .has_cause = TRUE,
+ .len = 2,
+ /* Normal call clearing */
+ .cause = { 0xe0, 0x90 },
+ },
+ }},
+ }},
+ },
+};
+
+static const unsigned char event_download_call_disconnected_114a[] = {
+ 0xd6, 0x0c, 0x99, 0x01, 0x02, 0x82, 0x02, 0x82,
+ 0x81, 0x9c, 0x01, 0x80, 0x1a, 0x00,
+ /*
+ * Byte 3 changed to 0x99 and byte 10 to 0x9c and byte 13 to
+ * 1a (Comprehension Required should be set according to TS
+ * 102 223 7.5.3.2)
+ */
+};
+
+static const struct envelope_test
+ event_download_call_disconnected_data_114a = {
+ .pdu = event_download_call_disconnected_114a,
+ .pdu_len = sizeof(event_download_call_disconnected_114a),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_EVENT_DOWNLOAD,
+ .src = STK_DEVICE_IDENTITY_TYPE_TERMINAL,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .event_download = {
+ .type = STK_EVENT_TYPE_CALL_DISCONNECTED,
+ { .call_disconnected = {
+ .transaction_ids = {
+ .len = 1,
+ .list = { 0x80 },
+ },
+ .cause = {
+ .has_cause = TRUE,
+ /* Radio link failure */
+ },
+ }},
+ }},
+ },
+};
+
+static const unsigned char event_download_call_disconnected_114b[] = {
+ 0xd6, 0x0c, 0x99, 0x01, 0x02, 0x82, 0x02, 0x82,
+ 0x81, 0x9c, 0x01, 0x00, 0x1a, 0x00,
+ /*
+ * Byte 3 changed to 0x99 and byte 10 to 0x9c and byte 13 to
+ * 1a (Comprehension Required should be set according to TS
+ * 102 223 7.5.3.2)
+ */
+};
+
+static const struct envelope_test
+ event_download_call_disconnected_data_114b = {
+ .pdu = event_download_call_disconnected_114b,
+ .pdu_len = sizeof(event_download_call_disconnected_114b),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_EVENT_DOWNLOAD,
+ .src = STK_DEVICE_IDENTITY_TYPE_TERMINAL,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .event_download = {
+ .type = STK_EVENT_TYPE_CALL_DISCONNECTED,
+ { .call_disconnected = {
+ .transaction_ids = {
+ .len = 1,
+ .list = { 0 },
+ },
+ .cause = {
+ .has_cause = TRUE,
+ /* Radio link failure */
+ },
+ }},
+ }},
+ },
+};
+
+static const unsigned char event_download_location_status_111[] = {
+ 0xd6, 0x0a, 0x99, 0x01, 0x03, 0x82, 0x02, 0x82,
+ 0x81, 0x9b, 0x01, 0x02,
+ /*
+ * Byte 3 changed to 0x99 and byte 10 to 0x9b (Comprehension
+ * Required should be set according to TS 102 223 7.5.4.2)
+ */
+};
+
+static const struct envelope_test
+ event_download_location_status_data_111 = {
+ .pdu = event_download_location_status_111,
+ .pdu_len = sizeof(event_download_location_status_111),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_EVENT_DOWNLOAD,
+ .src = STK_DEVICE_IDENTITY_TYPE_TERMINAL,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .event_download = {
+ .type = STK_EVENT_TYPE_LOCATION_STATUS,
+ { .location_status = {
+ .state = STK_NO_SERVICE,
+ }},
+ }},
+ },
+};
+
+static const unsigned char event_download_location_status_112a[] = {
+ 0xd6, 0x15, 0x99, 0x01, 0x03, 0x82, 0x02, 0x82,
+ 0x81, 0x9b, 0x01, 0x00, 0x13, 0x09, 0x00, 0xf1,
+ 0x10, 0x00, 0x02, 0x00, 0x02, 0x00, 0x01,
+ /*
+ * Byte 3 changed to 0x99 and byte 10 to 0x9b (Comprehension
+ * Required should be set according to TS 102 223 7.5.4.2)
+ */
+};
+
+static const struct envelope_test
+ event_download_location_status_data_112a = {
+ .pdu = event_download_location_status_112a,
+ .pdu_len = sizeof(event_download_location_status_112a),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_EVENT_DOWNLOAD,
+ .src = STK_DEVICE_IDENTITY_TYPE_TERMINAL,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .event_download = {
+ .type = STK_EVENT_TYPE_LOCATION_STATUS,
+ { .location_status = {
+ .state = STK_NORMAL_SERVICE,
+ .info = {
+ .mcc = "001",
+ .mnc = "01",
+ .lac_tac = 0x0002,
+ .has_ci = TRUE,
+ .ci = 0x0002,
+ .has_ext_ci = TRUE,
+ .ext_ci = 0x0001,
+ },
+ }},
+ }},
+ },
+};
+
+static const unsigned char event_download_location_status_112b[] = {
+ 0xd6, 0x13, 0x99, 0x01, 0x03, 0x82, 0x02, 0x82,
+ 0x81, 0x9b, 0x01, 0x00, 0x13, 0x07, 0x00, 0x11,
+ 0x10, 0x00, 0x02, 0x00, 0x02,
+ /*
+ * Byte 3 changed to 0x99 and byte 10 to 0x9b (Comprehension
+ * Required should be set according to TS 102 223 7.5.4.2)
+ */
+};
+
+static const struct envelope_test
+ event_download_location_status_data_112b = {
+ .pdu = event_download_location_status_112b,
+ .pdu_len = sizeof(event_download_location_status_112b),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_EVENT_DOWNLOAD,
+ .src = STK_DEVICE_IDENTITY_TYPE_TERMINAL,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .event_download = {
+ .type = STK_EVENT_TYPE_LOCATION_STATUS,
+ { .location_status = {
+ .state = STK_NORMAL_SERVICE,
+ .info = {
+ .mcc = "001",
+ .mnc = "011",
+ .lac_tac = 0x0002,
+ .has_ci = TRUE,
+ .ci = 0x0002,
+ },
+ }},
+ }},
+ },
+};
+
+static const unsigned char event_download_location_status_122[] = {
+ 0xd6, 0x15, 0x99, 0x01, 0x03, 0x82, 0x02, 0x82,
+ 0x81, 0x9b, 0x01, 0x00, 0x13, 0x09, 0x00, 0xf1,
+ 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x2f,
+ /*
+ * Byte 3 changed to 0x99 and byte 10 to 0x9b (Comprehension
+ * Required should be set according to TS 102 223 7.5.4.2)
+ */
+};
+
+static const struct envelope_test
+ event_download_location_status_data_122 = {
+ .pdu = event_download_location_status_122,
+ .pdu_len = sizeof(event_download_location_status_122),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_EVENT_DOWNLOAD,
+ .src = STK_DEVICE_IDENTITY_TYPE_TERMINAL,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .event_download = {
+ .type = STK_EVENT_TYPE_LOCATION_STATUS,
+ { .location_status = {
+ .state = STK_NORMAL_SERVICE,
+ .info = {
+ .mcc = "001",
+ .mnc = "01",
+ .lac_tac = 0x0002,
+ .has_eutran_ci = TRUE,
+ .eutran_ci = 0x0000002,
+ },
+ }},
+ }},
+ },
+};
+
+/*
+ * This is from 27.22.7.5. The ENVELOPE given in 27.22.4.16.1.1 seems to
+ * have invalid length value (2nd byte), but in turn the Comprehension
+ * Required bit is set correctly..
+ */
+static const unsigned char event_download_user_activity_111[] = {
+ 0xd6, 0x07, 0x99, 0x01, 0x04, 0x82, 0x02, 0x82,
+ 0x81,
+ /*
+ * Byte 3 changed to 0x99 (Comprehension Required should be
+ * set according to TS 102 223 7.5.5.2)
+ */
+};
+
+static const struct envelope_test event_download_user_activity_data_111 = {
+ .pdu = event_download_user_activity_111,
+ .pdu_len = sizeof(event_download_user_activity_111),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_EVENT_DOWNLOAD,
+ .src = STK_DEVICE_IDENTITY_TYPE_TERMINAL,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .event_download = {
+ .type = STK_EVENT_TYPE_USER_ACTIVITY,
+ }},
+ },
+};
+
+static const unsigned char event_download_idle_screen_available_111[] = {
+ 0xd6, 0x07, 0x99, 0x01, 0x05, 0x82, 0x02, 0x02,
+ 0x81,
+ /*
+ * Byte 3 changed to 0x99 (Comprehension Required should be
+ * set according to TS 102 223 7.5.6.2)
+ */
+};
+
+static const struct envelope_test
+ event_download_idle_screen_available_data_111 = {
+ .pdu = event_download_idle_screen_available_111,
+ .pdu_len = sizeof(event_download_idle_screen_available_111),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_EVENT_DOWNLOAD,
+ .src = STK_DEVICE_IDENTITY_TYPE_DISPLAY,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .event_download = {
+ .type = STK_EVENT_TYPE_IDLE_SCREEN_AVAILABLE,
+ }},
+ },
+};
+
+static const unsigned char event_download_card_reader_status_111a[] = {
+ 0xd6, 0x0a, 0x99, 0x01, 0x06, 0x82, 0x02, 0x82,
+ 0x81, 0xa0, 0x01, 0x79,
+};
+
+static const struct envelope_test
+ event_download_card_reader_status_data_111a = {
+ .pdu = event_download_card_reader_status_111a,
+ .pdu_len = sizeof(event_download_card_reader_status_111a),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_EVENT_DOWNLOAD,
+ .src = STK_DEVICE_IDENTITY_TYPE_TERMINAL,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .event_download = {
+ .type = STK_EVENT_TYPE_CARD_READER_STATUS,
+ { .card_reader_status = {
+ .id = 1,
+ .removable = TRUE,
+ .present = TRUE,
+ .id1_size = TRUE,
+ .card_present = TRUE,
+ .card_powered = FALSE,
+ }},
+ }},
+ },
+};
+
+static const unsigned char event_download_card_reader_status_111b[] = {
+ 0xd6, 0x0a, 0x99, 0x01, 0x06, 0x82, 0x02, 0x82,
+ 0x81, 0xa0, 0x01, 0x59,
+};
+
+static const struct envelope_test
+ event_download_card_reader_status_data_111b = {
+ .pdu = event_download_card_reader_status_111b,
+ .pdu_len = sizeof(event_download_card_reader_status_111b),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_EVENT_DOWNLOAD,
+ .src = STK_DEVICE_IDENTITY_TYPE_TERMINAL,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .event_download = {
+ .type = STK_EVENT_TYPE_CARD_READER_STATUS,
+ { .card_reader_status = {
+ .id = 1,
+ .removable = TRUE,
+ .present = TRUE,
+ .id1_size = FALSE,
+ .card_present = TRUE,
+ .card_powered = FALSE,
+ }},
+ }},
+ },
+};
+
+static const unsigned char event_download_card_reader_status_111c[] = {
+ 0xd6, 0x0a, 0x99, 0x01, 0x06, 0x82, 0x02, 0x82,
+ 0x81, 0xa0, 0x01, 0x71,
+};
+
+static const struct envelope_test
+ event_download_card_reader_status_data_111c = {
+ .pdu = event_download_card_reader_status_111c,
+ .pdu_len = sizeof(event_download_card_reader_status_111c),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_EVENT_DOWNLOAD,
+ .src = STK_DEVICE_IDENTITY_TYPE_TERMINAL,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .event_download = {
+ .type = STK_EVENT_TYPE_CARD_READER_STATUS,
+ { .card_reader_status = {
+ .id = 1,
+ .removable = FALSE,
+ .present = TRUE,
+ .id1_size = TRUE,
+ .card_present = TRUE,
+ .card_powered = FALSE,
+ }},
+ }},
+ },
+};
+
+static const unsigned char event_download_card_reader_status_111d[] = {
+ 0xd6, 0x0a, 0x99, 0x01, 0x06, 0x82, 0x02, 0x82,
+ 0x81, 0xa0, 0x01, 0x51,
+};
+
+static const struct envelope_test
+ event_download_card_reader_status_data_111d = {
+ .pdu = event_download_card_reader_status_111d,
+ .pdu_len = sizeof(event_download_card_reader_status_111d),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_EVENT_DOWNLOAD,
+ .src = STK_DEVICE_IDENTITY_TYPE_TERMINAL,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .event_download = {
+ .type = STK_EVENT_TYPE_CARD_READER_STATUS,
+ { .card_reader_status = {
+ .id = 1,
+ .removable = FALSE,
+ .present = TRUE,
+ .id1_size = FALSE,
+ .card_present = TRUE,
+ .card_powered = FALSE,
+ }},
+ }},
+ },
+};
+
+static const unsigned char event_download_card_reader_status_112a[] = {
+ 0xd6, 0x0a, 0x99, 0x01, 0x06, 0x82, 0x02, 0x82,
+ 0x81, 0xa0, 0x01, 0x39,
+};
+
+static const struct envelope_test
+ event_download_card_reader_status_data_112a = {
+ .pdu = event_download_card_reader_status_112a,
+ .pdu_len = sizeof(event_download_card_reader_status_112a),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_EVENT_DOWNLOAD,
+ .src = STK_DEVICE_IDENTITY_TYPE_TERMINAL,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .event_download = {
+ .type = STK_EVENT_TYPE_CARD_READER_STATUS,
+ { .card_reader_status = {
+ .id = 1,
+ .removable = TRUE,
+ .present = TRUE,
+ .id1_size = TRUE,
+ .card_present = FALSE,
+ }},
+ }},
+ },
+};
+
+static const unsigned char event_download_card_reader_status_112b[] = {
+ 0xd6, 0x0a, 0x99, 0x01, 0x06, 0x82, 0x02, 0x82,
+ 0x81, 0xa0, 0x01, 0x19,
+};
+
+static const struct envelope_test
+ event_download_card_reader_status_data_112b = {
+ .pdu = event_download_card_reader_status_112b,
+ .pdu_len = sizeof(event_download_card_reader_status_112b),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_EVENT_DOWNLOAD,
+ .src = STK_DEVICE_IDENTITY_TYPE_TERMINAL,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .event_download = {
+ .type = STK_EVENT_TYPE_CARD_READER_STATUS,
+ { .card_reader_status = {
+ .id = 1,
+ .removable = TRUE,
+ .present = TRUE,
+ .id1_size = FALSE,
+ .card_present = FALSE,
+ }},
+ }},
+ },
+};
+
+static const unsigned char event_download_card_reader_status_112c[] = {
+ 0xd6, 0x0a, 0x99, 0x01, 0x06, 0x82, 0x02, 0x82,
+ 0x81, 0xa0, 0x01, 0x31,
+};
+
+static const struct envelope_test
+ event_download_card_reader_status_data_112c = {
+ .pdu = event_download_card_reader_status_112c,
+ .pdu_len = sizeof(event_download_card_reader_status_112c),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_EVENT_DOWNLOAD,
+ .src = STK_DEVICE_IDENTITY_TYPE_TERMINAL,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .event_download = {
+ .type = STK_EVENT_TYPE_CARD_READER_STATUS,
+ { .card_reader_status = {
+ .id = 1,
+ .removable = FALSE,
+ .present = TRUE,
+ .id1_size = TRUE,
+ .card_present = FALSE,
+ }},
+ }},
+ },
+};
+
+static const unsigned char event_download_card_reader_status_112d[] = {
+ 0xd6, 0x0a, 0x99, 0x01, 0x06, 0x82, 0x02, 0x82,
+ 0x81, 0xa0, 0x01, 0x11,
+};
+
+static const struct envelope_test
+ event_download_card_reader_status_data_112d = {
+ .pdu = event_download_card_reader_status_112d,
+ .pdu_len = sizeof(event_download_card_reader_status_112d),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_EVENT_DOWNLOAD,
+ .src = STK_DEVICE_IDENTITY_TYPE_TERMINAL,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .event_download = {
+ .type = STK_EVENT_TYPE_CARD_READER_STATUS,
+ { .card_reader_status = {
+ .id = 1,
+ .removable = FALSE,
+ .present = TRUE,
+ .id1_size = FALSE,
+ .card_present = FALSE,
+ }},
+ }},
+ },
+};
+
+static const unsigned char event_download_card_reader_status_212a[] = {
+ 0xd6, 0x0a, 0x99, 0x01, 0x06, 0x82, 0x02, 0x82,
+ 0x81, 0xa0, 0x01, 0x29,
+};
+
+static const struct envelope_test
+ event_download_card_reader_status_data_212a = {
+ .pdu = event_download_card_reader_status_212a,
+ .pdu_len = sizeof(event_download_card_reader_status_212a),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_EVENT_DOWNLOAD,
+ .src = STK_DEVICE_IDENTITY_TYPE_TERMINAL,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .event_download = {
+ .type = STK_EVENT_TYPE_CARD_READER_STATUS,
+ { .card_reader_status = {
+ .id = 1,
+ .removable = TRUE,
+ .present = FALSE,
+ .id1_size = TRUE,
+ .card_present = FALSE,
+ }},
+ }},
+ },
+};
+
+static const unsigned char event_download_card_reader_status_212b[] = {
+ 0xd6, 0x0a, 0x99, 0x01, 0x06, 0x82, 0x02, 0x82,
+ 0x81, 0xa0, 0x01, 0x09,
+};
+
+static const struct envelope_test
+ event_download_card_reader_status_data_212b = {
+ .pdu = event_download_card_reader_status_212b,
+ .pdu_len = sizeof(event_download_card_reader_status_212b),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_EVENT_DOWNLOAD,
+ .src = STK_DEVICE_IDENTITY_TYPE_TERMINAL,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .event_download = {
+ .type = STK_EVENT_TYPE_CARD_READER_STATUS,
+ { .card_reader_status = {
+ .id = 1,
+ .removable = TRUE,
+ .present = FALSE,
+ .id1_size = FALSE,
+ .card_present = FALSE,
+ }},
+ }},
+ },
+};
+
+static const unsigned char event_download_language_selection_111[] = {
+ 0xd6, 0x0b, 0x99, 0x01, 0x07, 0x82, 0x02, 0x82,
+ 0x81, 0xad, 0x02, 0x64, 0x65,
+ /*
+ * Byte 3 changed to 0x99 and byte 10 to 0xad (Comprehension
+ * Required should be set according to TS 102 223 7.5.8.2)
+ */
+};
+
+static const struct envelope_test
+ event_download_language_selection_data_111 = {
+ .pdu = event_download_language_selection_111,
+ .pdu_len = sizeof(event_download_language_selection_111),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_EVENT_DOWNLOAD,
+ .src = STK_DEVICE_IDENTITY_TYPE_TERMINAL,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .event_download = {
+ .type = STK_EVENT_TYPE_LANGUAGE_SELECTION,
+ { .language_selection = "de" },
+ }},
+ },
+};
+
+static const unsigned char event_download_language_selection_122[] = {
+ 0xd6, 0x0b, 0x99, 0x01, 0x07, 0x82, 0x02, 0x82,
+ 0x81, 0xad, 0x02, 0x73, 0x65,
+ /* Byte 5 changed to 0x07 (Event: Language Selection) */
+ /* Byte 8 changed to 0x82 (Source device: Terminal) */
+ /* Removed the (unexpected?) Transaction ID data object (0x2d) */
+};
+
+static const struct envelope_test
+ event_download_language_selection_data_122 = {
+ .pdu = event_download_language_selection_122,
+ .pdu_len = sizeof(event_download_language_selection_122),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_EVENT_DOWNLOAD,
+ .src = STK_DEVICE_IDENTITY_TYPE_TERMINAL,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .event_download = {
+ .type = STK_EVENT_TYPE_LANGUAGE_SELECTION,
+ { .language_selection = "se" },
+ }},
+ },
+};
+
+static const unsigned char event_download_browser_termination_111[] = {
+ 0xd6, 0x0a, 0x99, 0x01, 0x08, 0x82, 0x02, 0x82,
+ 0x81, 0xb4, 0x01, 0x00,
+};
+
+static const struct envelope_test
+ event_download_browser_termination_data_111 = {
+ .pdu = event_download_browser_termination_111,
+ .pdu_len = sizeof(event_download_browser_termination_111),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_EVENT_DOWNLOAD,
+ .src = STK_DEVICE_IDENTITY_TYPE_TERMINAL,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .event_download = {
+ .type = STK_EVENT_TYPE_BROWSER_TERMINATION,
+ { .browser_termination = {
+ .cause = STK_BROWSER_USER_TERMINATION,
+ }},
+ }},
+ },
+};
+
+static const unsigned char event_download_data_available_111[] = {
+ 0xd6, 0x0e, 0x99, 0x01, 0x09, 0x82, 0x02, 0x82,
+ 0x81, 0xb8, 0x02, 0x81, 0x00, 0xb7, 0x01, 0xff,
+};
+
+static const struct envelope_test event_download_data_available_data_111 = {
+ .pdu = event_download_data_available_111,
+ .pdu_len = sizeof(event_download_data_available_111),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_EVENT_DOWNLOAD,
+ .src = STK_DEVICE_IDENTITY_TYPE_TERMINAL,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .event_download = {
+ .type = STK_EVENT_TYPE_DATA_AVAILABLE,
+ { .data_available = {
+ /* Channel 1 open, Link established */
+ .channel_status = { 0x81, 0x00 },
+ .channel_data_len = 255,
+ }},
+ }},
+ },
+};
+
+static const unsigned char event_download_data_available_211[] = {
+ 0xd6, 0x0e, 0x99, 0x01, 0x09, 0x82, 0x02, 0x82,
+ 0x81, 0xb8, 0x02, 0x81, 0x01, 0xb7, 0x01, 0xff,
+};
+
+static const struct envelope_test event_download_data_available_data_211 = {
+ .pdu = event_download_data_available_211,
+ .pdu_len = sizeof(event_download_data_available_211),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_EVENT_DOWNLOAD,
+ .src = STK_DEVICE_IDENTITY_TYPE_TERMINAL,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .event_download = {
+ .type = STK_EVENT_TYPE_DATA_AVAILABLE,
+ { .data_available = {
+ /* Channel 1 open, Link established */
+ .channel_status = { 0x81, 0x01 },
+ .channel_data_len = 255,
+ }},
+ }},
+ },
+};
+
+static const unsigned char event_download_channel_status_131[] = {
+ 0xd6, 0x0b, 0x99, 0x01, 0x0a, 0x82, 0x02, 0x82,
+ 0x81, 0xb8, 0x02, 0x01, 0x05,
+};
+
+static const struct envelope_test event_download_channel_status_data_131 = {
+ .pdu = event_download_channel_status_131,
+ .pdu_len = sizeof(event_download_channel_status_131),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_EVENT_DOWNLOAD,
+ .src = STK_DEVICE_IDENTITY_TYPE_TERMINAL,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .event_download = {
+ .type = STK_EVENT_TYPE_CHANNEL_STATUS,
+ { .channel_status = {
+ /* Channel 1, Link dropped */
+ .status = { 0x01, 0x05 },
+ }},
+ }},
+ },
+};
+
+static const unsigned char event_download_channel_status_211[] = {
+ 0xd6, 0x0b, 0x99, 0x01, 0x0a, 0x82, 0x02, 0x82,
+ 0x81, 0xb8, 0x02, 0x41, 0x00,
+ /*
+ * Byte 10 changed to 0xb8 (Comprehension Required should be
+ * set according to TS 102 223 7.5.11.2)
+ */
+};
+
+static const struct envelope_test event_download_channel_status_data_211 = {
+ .pdu = event_download_channel_status_211,
+ .pdu_len = sizeof(event_download_channel_status_211),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_EVENT_DOWNLOAD,
+ .src = STK_DEVICE_IDENTITY_TYPE_TERMINAL,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .event_download = {
+ .type = STK_EVENT_TYPE_CHANNEL_STATUS,
+ { .channel_status = {
+ /* Channel 1, TCP in LISTEN state */
+ .status = { 0x41, 0x00 },
+ }},
+ }},
+ },
+};
+
+static const unsigned char event_download_channel_status_221[] = {
+ 0xd6, 0x0b, 0x99, 0x01, 0x0a, 0x82, 0x02, 0x82,
+ 0x81, 0xb8, 0x02, 0x81, 0x01,
+ /*
+ * Byte 10 changed to 0xb8 (Comprehension Required should be
+ * set according to TS 102 223 7.5.11.2)
+ */
+};
+
+static const struct envelope_test event_download_channel_status_data_221 = {
+ .pdu = event_download_channel_status_221,
+ .pdu_len = sizeof(event_download_channel_status_221),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_EVENT_DOWNLOAD,
+ .src = STK_DEVICE_IDENTITY_TYPE_TERMINAL,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .event_download = {
+ .type = STK_EVENT_TYPE_CHANNEL_STATUS,
+ { .channel_status = {
+ /* Channel 1 open, TCP Link established */
+ .status = { 0x81, 0x01 },
+ }},
+ }},
+ },
+};
+
+static const unsigned char event_download_network_rejection_111[] = {
+ 0xd6, 0x17, 0x99, 0x01, 0x12, 0x82, 0x02, 0x83,
+ 0x81, 0x7d, 0x05, 0x00, 0xf1, 0x10, 0x00, 0x01,
+ 0xbf, 0x01, 0x08, 0xf4, 0x01, 0x09, 0xf5, 0x01,
+ 0x0b,
+ /*
+ * Byte 3 changed to 99, byte 17 changed to bf, byte 19 to f4 and
+ * byte 22 to f5 (Comprehension Required should be set according
+ * to TS 131 111 7.5.2.2)
+ */
+};
+
+static const struct envelope_test event_download_network_rejection_data_111 = {
+ .pdu = event_download_network_rejection_111,
+ .pdu_len = sizeof(event_download_network_rejection_111),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_EVENT_DOWNLOAD,
+ .src = STK_DEVICE_IDENTITY_TYPE_NETWORK,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .event_download = {
+ .type = STK_EVENT_TYPE_NETWORK_REJECTION,
+ { .network_rejection = {
+ .tai = {
+ .mcc = "001",
+ .mnc = "01",
+ .tac = 0x0001,
+ },
+ .access_tech = STK_ACCESS_TECHNOLOGY_EUTRAN,
+ .update_attach = STK_UPDATE_ATTACH_EPS_ATTACH,
+ .cause = STK_CAUSE_EMM_PLMN_NOT_ALLOWED,
+ }},
+ }},
+ },
+};
+
+static const unsigned char event_download_network_rejection_121[] = {
+ 0xd6, 0x17, 0x99, 0x01, 0x12, 0x82, 0x02, 0x83,
+ 0x81, 0x7d, 0x05, 0x00, 0xf1, 0x10, 0x00, 0x01,
+ 0xbf, 0x01, 0x08, 0xf4, 0x01, 0x0b, 0xf5, 0x01,
+ 0x0c,
+ /*
+ * Byte 3 changed to 99, byte 17 changed to bf, byte 19 to f4 and
+ * byte 22 to f5 (Comprehension Required should be set according
+ * to TS 131 111 7.5.2.2)
+ */
+};
+
+static const struct envelope_test event_download_network_rejection_data_121 = {
+ .pdu = event_download_network_rejection_121,
+ .pdu_len = sizeof(event_download_network_rejection_121),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_EVENT_DOWNLOAD,
+ .src = STK_DEVICE_IDENTITY_TYPE_NETWORK,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .event_download = {
+ .type = STK_EVENT_TYPE_NETWORK_REJECTION,
+ { .network_rejection = {
+ .tai = {
+ .mcc = "001",
+ .mnc = "01",
+ .tac = 0x0001,
+ },
+ .access_tech = STK_ACCESS_TECHNOLOGY_EUTRAN,
+ .update_attach = STK_UPDATE_ATTACH_TA_UPDATING,
+ .cause = STK_CAUSE_EMM_TAC_NOT_ALLOWED,
+ }},
+ }},
+ },
+};
+
int main(int argc, char **argv)
{
g_test_init(&argc, &argv, NULL);
@@ -20238,5 +21316,131 @@ int main(int argc, char **argv)
&mo_short_message_control_data_111b,
test_envelope_encoding);
+ g_test_add_data_func("/teststk/Event: MT Call 1.1.1",
+ &event_download_mt_call_data_111,
+ test_envelope_encoding);
+ g_test_add_data_func("/teststk/Event: MT Call 1.1.2",
+ &event_download_mt_call_data_112,
+ test_envelope_encoding);
+
+ g_test_add_data_func("/teststk/Event: Call Connected 1.1.1",
+ &event_download_call_connected_data_111,
+ test_envelope_encoding);
+ g_test_add_data_func("/teststk/Event: Call Connected 1.1.2",
+ &event_download_call_connected_data_112,
+ test_envelope_encoding);
+
+ g_test_add_data_func("/teststk/Event: Call Disconnected 1.1.1",
+ &event_download_call_disconnected_data_111,
+ test_envelope_encoding);
+ g_test_add_data_func("/teststk/Event: Call Disconnected 1.1.2A",
+ &event_download_call_disconnected_data_112a,
+ test_envelope_encoding);
+ g_test_add_data_func("/teststk/Event: Call Disconnected 1.1.2B",
+ &event_download_call_disconnected_data_112b,
+ test_envelope_encoding);
+ g_test_add_data_func("/teststk/Event: Call Disconnected 1.1.2C",
+ &event_download_call_disconnected_data_112c,
+ test_envelope_encoding);
+ g_test_add_data_func("/teststk/Event: Call Disconnected 1.1.3A",
+ &event_download_call_disconnected_data_113a,
+ test_envelope_encoding);
+ g_test_add_data_func("/teststk/Event: Call Disconnected 1.1.3B",
+ &event_download_call_disconnected_data_113b,
+ test_envelope_encoding);
+ g_test_add_data_func("/teststk/Event: Call Disconnected 1.1.4A",
+ &event_download_call_disconnected_data_114a,
+ test_envelope_encoding);
+ g_test_add_data_func("/teststk/Event: Call Disconnected 1.1.4B",
+ &event_download_call_disconnected_data_114b,
+ test_envelope_encoding);
+
+ g_test_add_data_func("/teststk/Event: Location Status 1.1.1",
+ &event_download_location_status_data_111,
+ test_envelope_encoding);
+ g_test_add_data_func("/teststk/Event: Location Status 1.1.2A",
+ &event_download_location_status_data_112a,
+ test_envelope_encoding);
+ g_test_add_data_func("/teststk/Event: Location Status 1.1.2B",
+ &event_download_location_status_data_112b,
+ test_envelope_encoding);
+ g_test_add_data_func("/teststk/Event: Location Status 1.2.2",
+ &event_download_location_status_data_122,
+ test_envelope_encoding);
+
+ g_test_add_data_func("/teststk/Event: User Activity 1.1.1",
+ &event_download_user_activity_data_111,
+ test_envelope_encoding);
+
+ g_test_add_data_func("/teststk/Event: Idle Screen Available 1.1.1",
+ &event_download_idle_screen_available_data_111,
+ test_envelope_encoding);
+
+ g_test_add_data_func("/teststk/Event: Card Reader Status 1.1.1A",
+ &event_download_card_reader_status_data_111a,
+ test_envelope_encoding);
+ g_test_add_data_func("/teststk/Event: Card Reader Status 1.1.1B",
+ &event_download_card_reader_status_data_111b,
+ test_envelope_encoding);
+ g_test_add_data_func("/teststk/Event: Card Reader Status 1.1.1C",
+ &event_download_card_reader_status_data_111c,
+ test_envelope_encoding);
+ g_test_add_data_func("/teststk/Event: Card Reader Status 1.1.1D",
+ &event_download_card_reader_status_data_111d,
+ test_envelope_encoding);
+ g_test_add_data_func("/teststk/Event: Card Reader Status 1.1.2A",
+ &event_download_card_reader_status_data_112a,
+ test_envelope_encoding);
+ g_test_add_data_func("/teststk/Event: Card Reader Status 1.1.2B",
+ &event_download_card_reader_status_data_112b,
+ test_envelope_encoding);
+ g_test_add_data_func("/teststk/Event: Card Reader Status 1.1.2C",
+ &event_download_card_reader_status_data_112c,
+ test_envelope_encoding);
+ g_test_add_data_func("/teststk/Event: Card Reader Status 1.1.2D",
+ &event_download_card_reader_status_data_112d,
+ test_envelope_encoding);
+ g_test_add_data_func("/teststk/Event: Card Reader Status 2.1.2A",
+ &event_download_card_reader_status_data_212a,
+ test_envelope_encoding);
+ g_test_add_data_func("/teststk/Event: Card Reader Status 2.1.2B",
+ &event_download_card_reader_status_data_212b,
+ test_envelope_encoding);
+
+ g_test_add_data_func("/teststk/Event: Language Selection 1.1.1",
+ &event_download_language_selection_data_111,
+ test_envelope_encoding);
+ g_test_add_data_func("/teststk/Event: Language Selection 1.2.2",
+ &event_download_language_selection_data_122,
+ test_envelope_encoding);
+
+ g_test_add_data_func("/teststk/Event: Browser Termination 1.1.1",
+ &event_download_browser_termination_data_111,
+ test_envelope_encoding);
+
+ g_test_add_data_func("/teststk/Event: Data Available 1.1.1",
+ &event_download_data_available_data_111,
+ test_envelope_encoding);
+ g_test_add_data_func("/teststk/Event: Data Available 2.1.1",
+ &event_download_data_available_data_211,
+ test_envelope_encoding);
+
+ g_test_add_data_func("/teststk/Event: Channel Status 1.3.1",
+ &event_download_channel_status_data_131,
+ test_envelope_encoding);
+ g_test_add_data_func("/teststk/Event: Channel Status 2.1.1",
+ &event_download_channel_status_data_211,
+ test_envelope_encoding);
+ g_test_add_data_func("/teststk/Event: Channel Status 2.2.1",
+ &event_download_channel_status_data_221,
+ test_envelope_encoding);
+
+ g_test_add_data_func("/teststk/Event: Network Rejection 1.1.1",
+ &event_download_network_rejection_data_111,
+ test_envelope_encoding);
+ g_test_add_data_func("/teststk/Event: Network Rejection 1.2.1",
+ &event_download_network_rejection_data_121,
+ test_envelope_encoding);
+
return g_test_run();
}
--
1.7.1.86.g0e460.dirty
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 19/20] stkutil: Add the Timer Expiration envelope builder
2010-06-07 10:08 [PATCH 01/20] Make stk_pdu_from_response use static buffers Andrzej Zaborowski
` (16 preceding siblings ...)
2010-06-07 10:08 ` [PATCH 18/20] test-stkutil: Tests for " Andrzej Zaborowski
@ 2010-06-07 10:08 ` Andrzej Zaborowski
2010-06-07 10:08 ` [PATCH 20/20] test-stkutil: Tests for " Andrzej Zaborowski
18 siblings, 0 replies; 29+ messages in thread
From: Andrzej Zaborowski @ 2010-06-07 10:08 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1589 bytes --]
---
src/stkutil.c | 13 +++++++++++++
src/stkutil.h | 6 ++++++
2 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/src/stkutil.c b/src/stkutil.c
index 26af066..858595b 100644
--- a/src/stkutil.c
+++ b/src/stkutil.c
@@ -5020,6 +5020,19 @@ const unsigned char *stk_pdu_from_envelope(const struct stk_envelope *envelope,
case STK_ENVELOPE_TYPE_EVENT_DOWNLOAD:
ok = build_envelope_event_download(&builder, envelope);
break;
+ case STK_ENVELOPE_TYPE_TIMER_EXPIRATION:
+ ok = build_dataobj(&builder,
+ build_envelope_dataobj_device_ids,
+ DATAOBJ_FLAG_CR,
+ envelope,
+ build_dataobj_timer_id,
+ DATAOBJ_FLAG_CR,
+ &envelope->timer_expiration.id,
+ build_dataobj_timer_value,
+ DATAOBJ_FLAG_CR,
+ &envelope->timer_expiration.value,
+ NULL);
+ break;
default:
return NULL;
};
diff --git a/src/stkutil.h b/src/stkutil.h
index a24ace7..2771dfd 100644
--- a/src/stkutil.h
+++ b/src/stkutil.h
@@ -1412,6 +1412,11 @@ struct stk_envelope_event_download {
};
};
+struct stk_envelope_timer_expiration {
+ unsigned char id;
+ struct stk_timer_value value;
+} timer_expiration;
+
struct stk_envelope {
enum stk_envelope_type type;
enum stk_device_identity_type src;
@@ -1423,6 +1428,7 @@ struct stk_envelope {
struct stk_envelope_call_control call_control;
struct stk_envelope_sms_mo_control sms_mo_control;
struct stk_envelope_event_download event_download;
+ struct stk_envelope_timer_expiration timer_expiration;
};
};
--
1.7.1.86.g0e460.dirty
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 20/20] test-stkutil: Tests for Timer Expiration envelope builder
2010-06-07 10:08 [PATCH 01/20] Make stk_pdu_from_response use static buffers Andrzej Zaborowski
` (17 preceding siblings ...)
2010-06-07 10:08 ` [PATCH 19/20] stkutil: Add the Timer Expiration " Andrzej Zaborowski
@ 2010-06-07 10:08 ` Andrzej Zaborowski
18 siblings, 0 replies; 29+ messages in thread
From: Andrzej Zaborowski @ 2010-06-07 10:08 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2078 bytes --]
---
unit/test-stkutil.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 49 insertions(+), 0 deletions(-)
diff --git a/unit/test-stkutil.c b/unit/test-stkutil.c
index ad66208..80f852a 100644
--- a/unit/test-stkutil.c
+++ b/unit/test-stkutil.c
@@ -19598,6 +19598,50 @@ static const struct envelope_test event_download_network_rejection_data_121 = {
},
};
+static const unsigned char timer_expiration_211[] = {
+ 0xd7, 0x0c, 0x82, 0x02, 0x82, 0x81, 0xa4, 0x01,
+ 0x01, 0xa5, 0x03, 0x00, 0x00, 0x01,
+};
+
+static const struct envelope_test timer_expiration_data_211 = {
+ .pdu = timer_expiration_211,
+ .pdu_len = sizeof(timer_expiration_211),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_TIMER_EXPIRATION,
+ .src = STK_DEVICE_IDENTITY_TYPE_TERMINAL,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .timer_expiration = {
+ .id = 1,
+ .value = {
+ .second = 10,
+ .has_value = TRUE,
+ },
+ }},
+ },
+};
+
+static const unsigned char timer_expiration_221a[] = {
+ 0xd7, 0x0c, 0x82, 0x02, 0x82, 0x81, 0xa4, 0x01,
+ 0x01, 0xa5, 0x03, 0x00, 0x00, 0x03,
+};
+
+static const struct envelope_test timer_expiration_data_221a = {
+ .pdu = timer_expiration_221a,
+ .pdu_len = sizeof(timer_expiration_221a),
+ .envelope = {
+ .type = STK_ENVELOPE_TYPE_TIMER_EXPIRATION,
+ .src = STK_DEVICE_IDENTITY_TYPE_TERMINAL,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ { .timer_expiration = {
+ .id = 1,
+ .value = {
+ .second = 30,
+ .has_value = TRUE,
+ },
+ }},
+ },
+};
+
int main(int argc, char **argv)
{
g_test_init(&argc, &argv, NULL);
@@ -21442,5 +21486,10 @@ int main(int argc, char **argv)
&event_download_network_rejection_data_121,
test_envelope_encoding);
+ g_test_add_data_func("/teststk/Timer Expiration 2.1.1",
+ &timer_expiration_data_211, test_envelope_encoding);
+ g_test_add_data_func("/teststk/Timer Expiration 2.2.1A",
+ &timer_expiration_data_221a, test_envelope_encoding);
+
return g_test_run();
}
--
1.7.1.86.g0e460.dirty
^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: [PATCH 12/20] stkutil: Add the Call Control envelope builder
2010-06-07 10:08 ` [PATCH 12/20] stkutil: Add the Call Control envelope builder Andrzej Zaborowski
@ 2010-06-09 22:57 ` Denis Kenzior
2010-06-11 19:18 ` Andrzej Zaborowski
0 siblings, 1 reply; 29+ messages in thread
From: Denis Kenzior @ 2010-06-09 22:57 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2156 bytes --]
Hi Andrew,
> ---
> src/stkutil.c | 178
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
src/stkutil.h |
> 31 ++++++++++
> 2 files changed, 207 insertions(+), 2 deletions(-)
>
> diff --git a/src/stkutil.c b/src/stkutil.c
> index 83ff5c7..b9a152a 100644
> --- a/src/stkutil.c
> +++ b/src/stkutil.c
> @@ -319,8 +319,6 @@ static gboolean parse_dataobj_subaddress(struct
> comprehension_tlv_iter *iter, unsigned int len;
>
> len = comprehension_tlv_iter_get_length(iter);
> - if (len < 1)
> - return FALSE;
This seems wrong. Can you point me to the test that uses empty subaddresses?
> +/* Used both in the ENVELOPE message to UICC and response from UICC */
> +struct stk_envelope_call_control {
> + /* Exactly one of the following 5 fields must be present */
Why are we not using a union then?
> + struct stk_address address;
> + struct stk_address ss_string;
> + struct stk_ussd_string {
> + unsigned char dcs;
> + const unsigned char *string;
Please don't do that. These objects will be passed around like candy and I
don't want to deal with dangling pointers.
> + int len;
> + } ussd_string;
The ussd string is limited to 160 bytes according to 23.038. So breaking this
out into a proper stk datatype like:
struct stk_ussd_string {
unsigned char dcs;
unsigned char ussd[160];
int len;
};
would be better
> + struct stk_common_byte_array pdp_ctx_params;
> + struct stk_common_byte_array eps_pdn_params;
> + /* At least one of the following two fields must be present in a
> + * response indicating modification of the call.
> + * In an EVELOPE message, only allowed for a call setup. */
> + struct stk_ccp ccp1;
> + struct stk_subaddress subaddress;
> + struct stk_location_info location;
> + /* Only allowed when ccp1 is present */
> + struct stk_ccp ccp2;
> + char *alpha_id;
> + /* Only allowed when both ccp1 and ccp2 are present */
> + struct stk_bc_repeat {
> + ofono_bool_t has_bc_repeat;
> + unsigned char value;
> + } bc_repeat;
Can we break this out into a proper datatype as well, not nested in this
struct.
Regards,
-Denis
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 17/20] stkutil: Add the Event Download envelope builder
2010-06-07 10:08 ` [PATCH 17/20] stkutil: Add the Event Download envelope builder Andrzej Zaborowski
@ 2010-06-10 1:06 ` Denis Kenzior
2010-06-10 1:19 ` Marcel Holtmann
2010-06-11 19:27 ` Andrzej Zaborowski
0 siblings, 2 replies; 29+ messages in thread
From: Denis Kenzior @ 2010-06-10 1:06 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 659 bytes --]
Hi Andrew,
> /* Network Byte Order */
> - unsigned int ipv4;
> + guint32 ipv4;
Why?
> @@ -799,7 +909,9 @@ struct stk_frame_layout {
> */
> struct stk_frames_info {
> unsigned char id;
> - unsigned char list[126];
> + struct {
> + unsigned int width, height;
do you mean unsigned char here?
> + } list[66];
Do you mean 63 here?
> unsigned int len;
> };
>
> + struct stk_reader_status card_reader_status;
> + const char *language_selection;
Per IRC conversation, lets not use const pointers in these structures.
Can you resubmit patches 12, 13 and 17-20. All others have been pushed.
Thanks,
-Denis
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 17/20] stkutil: Add the Event Download envelope builder
2010-06-10 1:06 ` Denis Kenzior
@ 2010-06-10 1:19 ` Marcel Holtmann
2010-06-10 1:37 ` Denis Kenzior
2010-06-11 19:27 ` Andrzej Zaborowski
1 sibling, 1 reply; 29+ messages in thread
From: Marcel Holtmann @ 2010-06-10 1:19 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 265 bytes --]
Hi Denis,
> > /* Network Byte Order */
> > - unsigned int ipv4;
> > + guint32 ipv4;
>
> Why?
actually unsigned int on 64-bit has a different size than on 32-bit.
However I prefer we use uint32_t and not the guint32 types.
Regards
Marcel
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 17/20] stkutil: Add the Event Download envelope builder
2010-06-10 1:19 ` Marcel Holtmann
@ 2010-06-10 1:37 ` Denis Kenzior
0 siblings, 0 replies; 29+ messages in thread
From: Denis Kenzior @ 2010-06-10 1:37 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 496 bytes --]
Hi Marcel,
> Hi Denis,
>
> > > /* Network Byte Order */
> > > - unsigned int ipv4;
> > > + guint32 ipv4;
> >
> > Why?
>
> actually unsigned int on 64-bit has a different size than on 32-bit.
> However I prefer we use uint32_t and not the guint32 types.
Err, no it doesn't. You must be thinking of long ints.
While theoretically 8-byte ints are allowed by the standard, no such platform
exists that I know of. Using uint32_t is preferable though.
Regards,
-Denis
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 12/20] stkutil: Add the Call Control envelope builder
2010-06-09 22:57 ` Denis Kenzior
@ 2010-06-11 19:18 ` Andrzej Zaborowski
2010-06-11 19:34 ` Denis Kenzior
0 siblings, 1 reply; 29+ messages in thread
From: Andrzej Zaborowski @ 2010-06-11 19:18 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2062 bytes --]
Hi,
On 10 June 2010 00:57, Denis Kenzior <denkenz@gmail.com> wrote:
>> ---
>> src/stkutil.c | 178
>> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
> src/stkutil.h |
>> 31 ++++++++++
>> 2 files changed, 207 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/stkutil.c b/src/stkutil.c
>> index 83ff5c7..b9a152a 100644
>> --- a/src/stkutil.c
>> +++ b/src/stkutil.c
>> @@ -319,8 +319,6 @@ static gboolean parse_dataobj_subaddress(struct
>> comprehension_tlv_iter *iter, unsigned int len;
>>
>> len = comprehension_tlv_iter_get_length(iter);
>> - if (len < 1)
>> - return FALSE;
>
> This seems wrong. Can you point me to the test that uses empty subaddresses?
I removed this from the new version of the patch. Empty subaddress
("null object") is only used in the response to the Call Control
ENVELOPE (second half of section 7.3.1.6).
>
>> +/* Used both in the ENVELOPE message to UICC and response from UICC */
>> +struct stk_envelope_call_control {
>> + /* Exactly one of the following 5 fields must be present */
>
> Why are we not using a union then?
We don't know which one of 5 is valid if it's a union. We could add a
field to indicate that but I guess it's simpler the way it is.
>
>> + struct stk_address address;
>> + struct stk_address ss_string;
>> + struct stk_ussd_string {
>> + unsigned char dcs;
>> + const unsigned char *string;
>
> Please don't do that. These objects will be passed around like candy and I
> don't want to deal with dangling pointers.
>
>> + int len;
>> + } ussd_string;
>
> The ussd string is limited to 160 bytes according to 23.038. So breaking this
> out into a proper stk datatype like:
> struct stk_ussd_string {
> unsigned char dcs;
> unsigned char ussd[160];
> int len;
> };
> would be better
Ok. I'll resend these four patches and add the remaining ENVELOPEs.
Regards
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 17/20] stkutil: Add the Event Download envelope builder
2010-06-10 1:06 ` Denis Kenzior
2010-06-10 1:19 ` Marcel Holtmann
@ 2010-06-11 19:27 ` Andrzej Zaborowski
2010-06-11 19:31 ` Denis Kenzior
1 sibling, 1 reply; 29+ messages in thread
From: Andrzej Zaborowski @ 2010-06-11 19:27 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1291 bytes --]
Hi,
On 10 June 2010 03:06, Denis Kenzior <denkenz@gmail.com> wrote:
> Hi Andrew,
>
>> /* Network Byte Order */
>> - unsigned int ipv4;
>> + guint32 ipv4;
>
> Why?
int has no guranteed size except at the ABI level. So the SysV r4
ABIs for x86, ARM and amd64 make it 32-bit but you don't know what
happens elsewhere. I'll remove this change as it's unlikely int will
be < 32-bit and if it's wider we don't care. (I, too, prefer stdint
types like uint32_t).
>
>> @@ -799,7 +909,9 @@ struct stk_frame_layout {
>> */
>> struct stk_frames_info {
>> unsigned char id;
>> - unsigned char list[126];
>> + struct {
>> + unsigned int width, height;
>
> do you mean unsigned char here?
I'll change it to char, a;though int isn't bad as these are integers
(something you can perform arithmetics on, not like an 8-bit
identifier).
>
>> + } list[66];
>
> Do you mean 63 here?
Yes :)
>
>> unsigned int len;
>> };
>>
>> + struct stk_reader_status card_reader_status;
>> + const char *language_selection;
>
> Per IRC conversation, lets not use const pointers in these structures.
Ok.
Regards
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 17/20] stkutil: Add the Event Download envelope builder
2010-06-11 19:27 ` Andrzej Zaborowski
@ 2010-06-11 19:31 ` Denis Kenzior
0 siblings, 0 replies; 29+ messages in thread
From: Denis Kenzior @ 2010-06-11 19:31 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 654 bytes --]
Hi Andrew,
> Hi,
>
> On 10 June 2010 03:06, Denis Kenzior <denkenz@gmail.com> wrote:
> > Hi Andrew,
> >
> >> /* Network Byte Order */
> >> - unsigned int ipv4;
> >> + guint32 ipv4;
> >
> > Why?
>
> int has no guranteed size except at the ABI level. So the SysV r4
> ABIs for x86, ARM and amd64 make it 32-bit but you don't know what
> happens elsewhere. I'll remove this change as it's unlikely int will
> be < 32-bit and if it's wider we don't care. (I, too, prefer stdint
> types like uint32_t).
Lets go with uint32_t, I think everyone agrees it the better approach.
Regards,
-Denis
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 12/20] stkutil: Add the Call Control envelope builder
2010-06-11 19:18 ` Andrzej Zaborowski
@ 2010-06-11 19:34 ` Denis Kenzior
2010-06-11 20:04 ` Andrzej Zaborowski
0 siblings, 1 reply; 29+ messages in thread
From: Denis Kenzior @ 2010-06-11 19:34 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 632 bytes --]
Hi Andrew,
> >> +/* Used both in the ENVELOPE message to UICC and response from UICC */
> >> +struct stk_envelope_call_control {
> >> + /* Exactly one of the following 5 fields must be present */
> >
> > Why are we not using a union then?
>
> We don't know which one of 5 is valid if it's a union. We could add a
> field to indicate that but I guess it's simpler the way it is.
It seems like a type + union might be better for the consumers of this
structure though. Otherwise they have to check up to 5 structs for emptiness
before figuring out what the type actually is. Your call.
Regards,
-Denis
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 12/20] stkutil: Add the Call Control envelope builder
2010-06-11 19:34 ` Denis Kenzior
@ 2010-06-11 20:04 ` Andrzej Zaborowski
0 siblings, 0 replies; 29+ messages in thread
From: Andrzej Zaborowski @ 2010-06-11 20:04 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 685 bytes --]
On 11 June 2010 21:34, Denis Kenzior <denkenz@gmail.com> wrote:
> Hi Andrew,
>
>
>> >> +/* Used both in the ENVELOPE message to UICC and response from UICC */
>> >> +struct stk_envelope_call_control {
>> >> + /* Exactly one of the following 5 fields must be present */
>> >
>> > Why are we not using a union then?
>>
>> We don't know which one of 5 is valid if it's a union. We could add a
>> field to indicate that but I guess it's simpler the way it is.
>
> It seems like a type + union might be better for the consumers of this
> structure though.
Okay, currenlty the UICC will be the only consumer but we may need to
be a consumer too, later.
Regards
^ permalink raw reply [flat|nested] 29+ messages in thread
end of thread, other threads:[~2010-06-11 20:04 UTC | newest]
Thread overview: 29+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-07 10:08 [PATCH 01/20] Make stk_pdu_from_response use static buffers Andrzej Zaborowski
2010-06-07 10:08 ` [PATCH 02/20] stkutil: Add SMS-PP Data Download envelope builder Andrzej Zaborowski
2010-06-07 10:08 ` [PATCH 03/20] test-stkutil: Tests for " Andrzej Zaborowski
2010-06-07 10:08 ` [PATCH 04/20] stkutil: Add CBS-PP " Andrzej Zaborowski
2010-06-07 10:08 ` [PATCH 05/20] stk: Use envelope encoding utility from stkutil.c Andrzej Zaborowski
2010-06-07 10:08 ` [PATCH 06/20] Fix: download CBS to SIM even when "Powered" is 0 Andrzej Zaborowski
2010-06-07 10:08 ` [PATCH 07/20] test-stkutil: Tests for CBS-PP Data Download envelope builder Andrzej Zaborowski
2010-06-07 10:08 ` [PATCH 08/20] stkutil: Add the Menu Selection " Andrzej Zaborowski
2010-06-07 10:08 ` [PATCH 09/20] test-stkutil: Tests for " Andrzej Zaborowski
2010-06-07 10:08 ` [PATCH 10/20] Add a "sim string" encoding utility Andrzej Zaborowski
2010-06-07 10:08 ` [PATCH 11/20] simutil: Fix MMC MNC encoding for 2-digit MNCs Andrzej Zaborowski
2010-06-07 10:08 ` [PATCH 12/20] stkutil: Add the Call Control envelope builder Andrzej Zaborowski
2010-06-09 22:57 ` Denis Kenzior
2010-06-11 19:18 ` Andrzej Zaborowski
2010-06-11 19:34 ` Denis Kenzior
2010-06-11 20:04 ` Andrzej Zaborowski
2010-06-07 10:08 ` [PATCH 13/20] test-stkutil: Tests for " Andrzej Zaborowski
2010-06-07 10:08 ` [PATCH 14/20] stkutil: Add the MO Short Message " Andrzej Zaborowski
2010-06-07 10:08 ` [PATCH 15/20] test-stkutil: Tests for " Andrzej Zaborowski
2010-06-07 10:08 ` [PATCH 16/20] For unitialised stk_location_info emit no data object Andrzej Zaborowski
2010-06-07 10:08 ` [PATCH 17/20] stkutil: Add the Event Download envelope builder Andrzej Zaborowski
2010-06-10 1:06 ` Denis Kenzior
2010-06-10 1:19 ` Marcel Holtmann
2010-06-10 1:37 ` Denis Kenzior
2010-06-11 19:27 ` Andrzej Zaborowski
2010-06-11 19:31 ` Denis Kenzior
2010-06-07 10:08 ` [PATCH 18/20] test-stkutil: Tests for " Andrzej Zaborowski
2010-06-07 10:08 ` [PATCH 19/20] stkutil: Add the Timer Expiration " Andrzej Zaborowski
2010-06-07 10:08 ` [PATCH 20/20] test-stkutil: Tests for " Andrzej Zaborowski
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.