Make stk_pdu_from_response use static buffers
PATCH 1/20 Make stk_pdu_from_response use static buffers
--- src/stkutil.c | 36 ++++++++++++++++++++---------------- src/stkutil.h | 5 ++--- unit/test-stkutil.c | 15 ++++++++++----- 3 files changed, 32 insertions(+), 24 deletions(-)
src/stkutil.c +20 -16
@@ -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; }
src/stkutil.h +2 -3
@@ -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);
unit/test-stkutil.c +10 -5
@@ -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[] = {
Signature · 1 line
1.7.1.86.g0e460.dirty
PATCH 2/20 stkutil: Add SMS-PP Data Download envelope builder
--- src/stkutil.c | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/stkutil.h | 17 +++++++++ 2 files changed, 127 insertions(+), 0 deletions(-)
src/stkutil.c +110 -0
@@ -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 *iterreturn 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; +}
src/stkutil.h +17 -0
@@ -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);
Signature · 1 line
1.7.1.86.g0e460.dirty
PATCH 3/20 test-stkutil: Tests for SMS-PP Data Download envelope builder
In reply to Andrzej Zaborowski--- unit/test-stkutil.c | 171 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 171 insertions(+), 0 deletions(-)
unit/test-stkutil.c +171 -0
@@ -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 (); }
Signature · 1 line
1.7.1.86.g0e460.dirty
PATCH 4/20 stkutil: Add CBS-PP Data Download envelope builder
In reply to Andrzej Zaborowski--- src/stkutil.c | 26 ++++++++++++++++++++++++++ src/stkutil.h | 5 +++++ 2 files changed, 31 insertions(+), 0 deletions(-)
src/stkutil.c +26 -0
@@ -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 ; };
src/stkutil.h +5 -0
@@ -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; }; };
Signature · 1 line
1.7.1.86.g0e460.dirty
PATCH 5/20 stk: Use envelope encoding utility from stkutil.c
In reply to Andrzej Zaborowski--- src/cbs.c | 2 +- src/ofono.h | 4 ++-- src/stk.c | 27 ++++++++++++++------------- 3 files changed, 17 insertions(+), 16 deletions(-)
src/cbs.c +1 -1
@@ -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 ; }
src/ofono.h +2 -2
@@ -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>
src/stk.c +14 -13
@@ -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,
Signature · 1 line
1.7.1.86.g0e460.dirty
PATCH 6/20 Fix: download CBS to SIM even when "Powered" is 0
In reply to Andrzej Zaborowski--- src/cbs.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)
src/cbs.c +5 -5
@@ -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 ;
Signature · 1 line
1.7.1.86.g0e460.dirty
PATCH 7/20 test-stkutil: Tests for CBS-PP Data Download envelope builder
In reply to Andrzej Zaborowski--- unit/test-stkutil.c | 112 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 112 insertions(+), 0 deletions(-)
unit/test-stkutil.c +112 -0
@@ -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 (); }
Signature · 1 line
1.7.1.86.g0e460.dirty
PATCH 8/20 stkutil: Add the Menu Selection envelope builder
In reply to Andrzej Zaborowski--- src/stkutil.c | 25 +++++++++++++++++++++++++ src/stkutil.h | 6 ++++++ 2 files changed, 31 insertions(+), 0 deletions(-)
src/stkutil.c +25 -0
@@ -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 ; };
src/stkutil.h +6 -0
@@ -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; }; };
Signature · 1 line
1.7.1.86.g0e460.dirty
PATCH 9/20 test-stkutil: Tests for the Menu Selection envelope builder
In reply to Andrzej Zaborowski--- unit/test-stkutil.c | 162 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 162 insertions(+), 0 deletions(-)
unit/test-stkutil.c +162 -0
@@ -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 (); }
Signature · 1 line
1.7.1.86.g0e460.dirty
PATCH 10/20 Add a "sim string" encoding utility.
In reply to Andrzej Zaborowski--- src/simutil.c | 25 ++++++++++--------------- src/util.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ src/util.h | 3 +++ 3 files changed, 59 insertions(+), 15 deletions(-)
src/simutil.c +10 -15
@@ -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; }
src/util.c +46 -0
49 lines not on this page · raw message
src/util.h +3 -0
@@ -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);
Signature · 1 line
1.7.1.86.g0e460.dirty
PATCH 11/20 simutil: Fix MMC MNC encoding for 2-digit MNCs.
In reply to Andrzej Zaborowski--- src/simutil.c | 19 ++++++++----------- 1 files changed, 8 insertions(+), 11 deletions(-)
src/simutil.c +8 -11
@@ -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)
Signature · 1 line
1.7.1.86.g0e460.dirty
PATCH 12/20 stkutil: Add the Call Control envelope builder
In reply to Andrzej Zaborowski--- src/stkutil.c | 178 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- src/stkutil.h | 31 ++++++++++ 2 files changed, 207 insertions(+), 2 deletions(-)
src/stkutil.c +176 -2
@@ -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 ; };
src/stkutil.h +31 -0
@@ -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; }; };
Signature · 1 line
1.7.1.86.g0e460.dirty
PATCH 13/20 test-stkutil: Tests for Call Control envelope builder
In reply to Andrzej Zaborowski--- unit/test-stkutil.c | 154 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 154 insertions(+), 0 deletions(-)
unit/test-stkutil.c +154 -0
@@ -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 (); }
Signature · 1 line
1.7.1.86.g0e460.dirty
PATCH 14/20 stkutil: Add the MO Short Message Control envelope builder
In reply to Andrzej Zaborowski--- src/stkutil.c | 16 ++++++++++++++++ src/stkutil.h | 7 +++++++ 2 files changed, 23 insertions(+), 0 deletions(-)
src/stkutil.c +16 -0
@@ -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 ; };
src/stkutil.h +7 -0
@@ -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; }; };
Signature · 1 line
1.7.1.86.g0e460.dirty
PATCH 15/20 test-stkutil: Tests for MO Short Message Control envelope builder
In reply to Andrzej Zaborowski--- unit/test-stkutil.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 79 insertions(+), 0 deletions(-)
unit/test-stkutil.c +79 -0
@@ -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 (); }
Signature · 1 line
1.7.1.86.g0e460.dirty
PATCH 16/20 For unitialised stk_location_info emit no data object
In reply to Andrzej ZaborowskiUse a separate function to write empty Location Information data objects.
--- src/stkutil.c | 33 +++++++++++++++++++++++---------- 1 files changed, 23 insertions(+), 10 deletions(-)
src/stkutil.c +23 -10
@@ -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;
Signature · 1 line
1.7.1.86.g0e460.dirty
PATCH 17/20 stkutil: Add the Event Download envelope builder
In reply to Andrzej Zaborowski--- src/stkutil.c | 556 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- src/stkutil.h | 196 ++++++++++++++++++++- 2 files changed, 746 insertions(+), 6 deletions(-)
src/stkutil.c +553 -3
@@ -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 ; };
src/stkutil.h +193 -3
269 lines not on this page · raw message
Signature · 1 line
1.7.1.86.g0e460.dirty
PATCH 18/20 test-stkutil: Tests for Event Download envelope builder
In reply to Andrzej Zaborowski--- unit/test-stkutil.c | 1204 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 1204 insertions(+), 0 deletions(-)
unit/test-stkutil.c +1204 -0
@@ -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 (); }
Signature · 1 line
1.7.1.86.g0e460.dirty
PATCH 19/20 stkutil: Add the Timer Expiration envelope builder
In reply to Andrzej Zaborowski--- src/stkutil.c | 13 +++++++++++++ src/stkutil.h | 6 ++++++ 2 files changed, 19 insertions(+), 0 deletions(-)
src/stkutil.c +13 -0
@@ -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 ; };
src/stkutil.h +6 -0
@@ -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; }; };
Signature · 1 line
1.7.1.86.g0e460.dirty
PATCH 20/20 test-stkutil: Tests for Timer Expiration envelope builder
In reply to Andrzej Zaborowski--- unit/test-stkutil.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 49 insertions(+), 0 deletions(-)
unit/test-stkutil.c +49 -0
@@ -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 (); }
Signature · 1 line
1.7.1.86.g0e460.dirty
Re: [PATCH 12/20] stkutil: Add the Call Control envelope builder
In reply to Andrzej ZaborowskiHi Andrew,
Quoted 3 lines
--- src/stkutil.c | 178++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
src/stkutil.h |
src/stkutil.c static gboolean parse_dataobj_subaddress(struct · line 323
Quoted 13 lines
31 ++++++++++
2 files changed, 207 insertions(+), 2 deletions(-)src/stkutil.c +0
-2@@ -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?
src/stkutil.c static gboolean parse_dataobj_subaddress(struct · line 324
Quoted 3 lines
src/stkutil.c +3
-0+/* 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?
src/stkutil.c static gboolean parse_dataobj_subaddress(struct
Quoted 5 lines
src/stkutil.c +5
-0+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.
src/stkutil.c
Quoted 2 lines
src/stkutil.c +2
-0+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
Quoted 6 lines
src/stkutil.c +6
-0+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;
src/stkutil.c
Quoted 10 lines
src/stkutil.c +10
-0+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
Re: [PATCH 17/20] stkutil: Add the Event Download envelope builder
In reply to Andrzej ZaborowskiHi Andrew,
src/stkutil.h struct stk_card_reader_id { · line 791
Quoted 3 lines
src/stkutil.h +1
-1/* Network Byte Order */ -unsigned int ipv4; +guint32 ipv4;
Why?
src/stkutil.h struct stk_frame_layout { · line 913
Quoted 7 lines
src/stkutil.h +2
-1@@ -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?
src/stkutil.h struct stk_frame_layout { · line 914
Quoted 1 line
src/stkutil.h +1
-0+ } list[66 ];
Do you mean 63 here?
src/stkutil.h struct stk_envelope_sms_mo_control { · line 1374
Quoted 5 lines
src/stkutil.h +2
-0unsigned 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
Re: [PATCH 17/20] stkutil: Add the Event Download envelope builder
Hi Denis,
Quoted 5 lines
src/stkutil.h struct stk_card_reader_id { · line 791
Quoted 3 lines
src/stkutil.h +1
-1/* 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
Re: [PATCH 17/20] stkutil: Add the Event Download envelope builder
Hi Marcel,
Quoted 10 lines
Hi Denis,
Quoted 5 lines
src/stkutil.h struct stk_card_reader_id { · line 791
Quoted 3 lines
src/stkutil.h +1
-1/* 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_tand 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
Re: [PATCH 12/20] stkutil: Add the Call Control envelope builder
In reply to Denis KenziorHi,
Quoted 14 lines · Denis Kenzior
Quoted 3 lines
---
src/stkutil.c | 178
++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
src/stkutil.h|Quoted 10 lines
31 ++++++++++
2 files changed, 207 insertions(+), 2 deletions(-)src/stkutil.c +0
-0@@ -319,8 +319,6 @@ static gboolean parse_dataobj_subaddress(struct comprehension_tlv_iter *iter, unsigned int len;
Quoted 5 lines
src/stkutil.c static gboolean parse_dataobj_subaddress(struct comprehension_tlv_iter *iter, · line 323
Quoted 3 lines
src/stkutil.c +0
-2len = 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).
Quoted 6 lines
src/stkutil.c static gboolean parse_dataobj_subaddress(struct · line 324
Quoted 4 lines
src/stkutil.c +3
-0+/* 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.
Quoted 13 lines
Quoted 6 lines
+ struct
stk_addressaddress;
+ structstk_addressss_string;
+ structstk_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.
Quoted 2 lines
+ int len;
+ }ussd_string;
Quoted 8 lines
The ussd string is limited to 160 bytes according to 23.038. So breaking this out into a proper stk datatype like:
structstk_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
Re: [PATCH 17/20] stkutil: Add the Event Download envelope builder
In reply to Denis KenziorHi,
Quoted 7 lines · Denis Kenzior
Hi Andrew,
Quoted 3 lines
/* 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).
Quoted 10 lines
src/stkutil.h struct stk_frame_layout { · line 913
Quoted 8 lines
src/stkutil.h +2
-1@@ -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).
Quoted 4 lines
src/stkutil.h struct stk_frame_layout { · line 914
Quoted 2 lines
src/stkutil.h +1
-0+ } list[66];Do you mean 63 here?
Yes :)
Quoted 8 lines
src/stkutil.h struct stk_envelope_sms_mo_control { · line 1374
Quoted 6 lines
src/stkutil.h +2
-0unsigned 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
Re: [PATCH 17/20] stkutil: Add the Event Download envelope builder
Hi Andrew,
Quoted 9 lines
Hi,
Quoted 6 lines · Denis Kenzior
Hi Andrew,
Quoted 3 lines
/* Network Byte Order */src/stkutil.h +1
-1-unsigned int ipv4; +guint32 ipv4;
Quoted 7 lines
Quoted 1 line
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
Re: [PATCH 12/20] stkutil: Add the Call Control envelope builder
In reply to Andrzej ZaborowskiHi Andrew,
Quoted 8 lines
Quoted 5 lines
src/stkutil.h struct stk_envelope_menu_selection { · line 1194
Quoted 3 lines
src/stkutil.h +3
-0+/* 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
Re: [PATCH 12/20] stkutil: Add the Call Control envelope builder
Quoted 9 lines · Denis Kenzior
Hi Andrew,
Quoted 6 lines
Quoted 5 lines
src/stkutil.h struct stk_envelope_menu_selection { · line 1194
Quoted 3 lines
src/stkutil.h +3
-0+/* 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?
Quoted 5 lines
Quoted 2 lines
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