Add parser for items next action indicator objects
PATCH v2 1/10 Add parser for items next action indicator objects
--- src/stkutil.c | 36 ++++++++++++++++++++++++++++++++++++ src/stkutil.h | 9 +++++++++ 2 files changed, 45 insertions(+), 0 deletions(-)
src/stkutil.c +36 -0
@@ -67,6 +67,29 @@ static gboolean parse_dataobj_common_bool(struct comprehension_tlv_iter *iter,return TRUE; } +/* For data object that only has a byte array with variable length */ +static gboolean parse_dataobj_common_byte_array ( +struct comprehension_tlv_iter *iter, +enum stk_data_object_type type, +unsigned char *array,unsigned int *array_len) +{ +const unsigned char *data; +unsigned int len; + +if (comprehension_tlv_iter_get_tag (iter) != type) +return FALSE; + + len =comprehension_tlv_iter_get_length (iter); +if (len <1 ) +return FALSE; + + data =comprehension_tlv_iter_get_data (iter); + *array_len = len; +memcpy (array, data, len); + +return TRUE; +} +/* Defined in TS 102.223 Section 8.1 */ static gboolean parse_dataobj_address (struct comprehension_tlv_iter *iter,void *user)
@@ -643,6 +666,17 @@ static gboolean parse_dataobj_network_measurement_results(return TRUE; } +/* Defined in TS 102.223 Section 8.24 */ +static gboolean parse_dataobj_items_next_action_indicator ( +struct comprehension_tlv_iter *iter,void *user) +{ +struct stk_items_next_action_indicator *inai = user; + +return parse_dataobj_common_byte_array (iter, +STK_DATA_OBJECT_TYPE_ITEMS_NEXT_ACTION_INDICATOR , + inai->list, &inai->len); +} +/* Defined in TS 102.223 Section 8.31 */ static gboolean parse_dataobj_icon_id (struct comprehension_tlv_iter *iter,void *user)
@@ -760,6 +794,8 @@ static dataobj_handler handler_for_type(enum stk_data_object_type type)return parse_dataobj_help_request;case STK_DATA_OBJECT_TYPE_NETWORK_MEASUREMENT_RESULTS :return parse_dataobj_network_measurement_results; +case STK_DATA_OBJECT_TYPE_ITEMS_NEXT_ACTION_INDICATOR : +return parse_dataobj_items_next_action_indicator;case STK_DATA_OBJECT_TYPE_ICON_ID :return parse_dataobj_icon_id;case STK_DATA_OBJECT_TYPE_IMMEDIATE_RESPONSE :
src/stkutil.h +9 -0
@@ -370,6 +370,15 @@ struct stk_file { };/* +* According to 102.223 Section 8.24 the length of CTLV is 1 byte. This means +* that the maximum size is 127 according to the rules of CTLVs. +*/ +struct stk_items_next_action_indicator { +unsigned char list[127 ]; +unsigned int len; +}; + +/* * According to 102.223 Section 8.72 the length of text attribute CTLV is 1 * byte. This means that the maximum size is 127 according to the rules * of CTLVs. Empty attribute options will have len of 0.
Signature · 1 line
1.6.3.3
PATCH v2 2/10 Adjust the sequence of comprehension tlv structures
--- src/stkutil.h | 22 +++++++++++----------- 1 files changed, 11 insertions(+), 11 deletions(-)
src/stkutil.h +11 -11
@@ -347,17 +347,6 @@ struct stk_result {unsigned char *additional; }; -/* Defined in TS 102.223 Section 8.19 */ -struct stk_location_info { -char mnc[OFONO_MAX_MNC_LENGTH +1 ]; -char mcc[OFONO_MAX_MCC_LENGTH +1 ]; -unsigned short lac_tac; -ofono_bool_t has_ci; -unsigned short ci; -ofono_bool_t has_ext_ci; -unsigned short ext_ci; -}; -/* Define the struct of single file in TS102.223 Section 8.18. * According to TS 11.11 Section 6.2, each file id has two bytes, and the * maximum Dedicated File level is 2. So the maximum size of file is 8, which
@@ -369,6 +358,17 @@ struct stk_file {unsigned int len; }; +/* Defined in TS 102.223 Section 8.19 */ +struct stk_location_info { +char mnc[OFONO_MAX_MNC_LENGTH +1 ]; +char mcc[OFONO_MAX_MCC_LENGTH +1 ]; +unsigned short lac_tac; +ofono_bool_t has_ci; +unsigned short ci; +ofono_bool_t has_ext_ci; +unsigned short ext_ci; +}; +/* * According to 102.223 Section 8.24 the length of CTLV is 1 byte. This means * that the maximum size is 127 according to the rules of CTLVs.
Signature · 1 line
1.6.3.3
PATCH v2 3/10 Add parser for event list objects
--- src/stkutil.c | 12 ++++++++++++ src/stkutil.h | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 0 deletions(-)
src/stkutil.c +12 -0
@@ -677,6 +677,16 @@ static gboolean parse_dataobj_items_next_action_indicator( inai->list, &inai->len); } +/* Defined in TS 102.223 Section 8.25 */ +static gboolean parse_dataobj_event_list ( +struct comprehension_tlv_iter *iter,void *user) +{ +struct stk_event_list *el = user; + +return parse_dataobj_common_byte_array (iter, +STK_DATA_OBJECT_TYPE_EVENT_LIST , el->list, &el->len); +} +/* Defined in TS 102.223 Section 8.31 */ static gboolean parse_dataobj_icon_id (struct comprehension_tlv_iter *iter,void *user)
@@ -796,6 +806,8 @@ static dataobj_handler handler_for_type(enum stk_data_object_type type)return parse_dataobj_network_measurement_results;case STK_DATA_OBJECT_TYPE_ITEMS_NEXT_ACTION_INDICATOR :return parse_dataobj_items_next_action_indicator; +case STK_DATA_OBJECT_TYPE_EVENT_LIST : +return parse_dataobj_event_list;case STK_DATA_OBJECT_TYPE_ICON_ID :return parse_dataobj_icon_id;case STK_DATA_OBJECT_TYPE_IMMEDIATE_RESPONSE :
src/stkutil.h +33 -0
@@ -266,6 +266,30 @@ enum stk_tone_type {STK_TONE_TYPE_MELODY_8 =0x47 }; +enum stk_event_type { +STK_EVENT_TYPE_MT_CALL =0x00 , +STK_EVENT_TYPE_CALL_CONNECTED =0x01 , +STK_EVENT_TYPE_CALL_DISCONNECTED =0x02 , +STK_EVENT_TYPE_LOCATION_STATUS =0x03 , +STK_EVENT_TYPE_USER_ACTIVITY =0x04 , +STK_EVENT_TYPE_IDLE_SCREEN_AVAILABLE =0x05 , +STK_EVENT_TYPE_CARD_READER_STATUS =0x06 , +STK_EVENT_TYPE_LANGUAGE_SELECTION =0x07 , +STK_EVENT_TYPE_BROWSER_TERMINATION =0x08 , +STK_EVENT_TYPE_DATA_AVAILABLE =0x09 , +STK_EVENT_TYPE_CHANNEL_STATUS =0x0A , +STK_EVENT_TYPE_SINGLE_ACCESS_TECHNOLOGY_CHANGE =0x0B , +STK_EVENT_TYPE_DISPLAY_PARAMETERS_CHANGED =0x0C , +STK_EVENT_TYPE_LOCAL_CONNECTION =0x0D , +STK_EVENT_TYPE_NETWORK_SEARCH_MODE_CHANGE =0x0E , +STK_EVENT_TYPE_BROWSING_STATUS =0x0F , +STK_EVENT_TYPE_FRAMES_INFORMATION_CHANGE =0x10 , +STK_EVENT_TYPE_I_WLAN_ACCESS_STATUS =0x11 , +STK_EVENT_TYPE_NETWORK_REJECTION =0x12 , +STK_EVENT_TYPE_HCI_CONNECTIVITY_EVENT =0x13 , +STK_EVENT_TYPE_MULTIPLE_ACCESS_TECHNOLOGIES_CHANGE =0x14 +}; +/* Defined in TS 102.223 Section 8.1 */ struct stk_address {unsigned char ton_npi;
@@ -379,6 +403,15 @@ struct stk_items_next_action_indicator { };/* +* According to 102.223 Section 8.25, there are 21 kinds of event type and no +* one should appear more than once. +*/ +struct stk_event_list { +unsigned char list[21 ]; +unsigned int len; +}; + +/* * According to 102.223 Section 8.72 the length of text attribute CTLV is 1 * byte. This means that the maximum size is 127 according to the rules * of CTLVs. Empty attribute options will have len of 0.
Signature · 1 line
1.6.3.3
PATCH v2 4/10 Add parser for cause objects
--- src/stkutil.c | 30 ++++++++++++++++++++++++++++++ src/stkutil.h | 9 +++++++++ 2 files changed, 39 insertions(+), 0 deletions(-)
src/stkutil.c +30 -0
@@ -687,6 +687,34 @@ static gboolean parse_dataobj_event_list( STK_DATA_OBJECT_TYPE_EVENT_LIST, el->list, &el->len); } +/* Defined in TS 102.223 Section 8.26 */ +static gboolean parse_dataobj_cause ( +struct comprehension_tlv_iter *iter,void *user) +{ +struct stk_cause *cause = user; +const unsigned char *data; +unsigned int len; + +if (comprehension_tlv_iter_get_tag (iter) !=STK_DATA_OBJECT_TYPE_CAUSE ) +return FALSE; + + len =comprehension_tlv_iter_get_length (iter); +if ((len ==1 ) || (len >30 )) +return FALSE; + +if (len ==0 ) { + cause->has_cause = TRUE; +return TRUE; + } + + data =comprehension_tlv_iter_get_data (iter); + cause->len = len; +memcpy (cause->cause, data, len); + cause->has_cause = TRUE; + +return TRUE; +} +/* Defined in TS 102.223 Section 8.31 */ static gboolean parse_dataobj_icon_id (struct comprehension_tlv_iter *iter,void *user)
@@ -808,6 +836,8 @@ static dataobj_handler handler_for_type(enum stk_data_object_type type)return parse_dataobj_items_next_action_indicator;case STK_DATA_OBJECT_TYPE_EVENT_LIST :return parse_dataobj_event_list; +case STK_DATA_OBJECT_TYPE_CAUSE : +return parse_dataobj_cause;case STK_DATA_OBJECT_TYPE_ICON_ID :return parse_dataobj_icon_id;case STK_DATA_OBJECT_TYPE_IMMEDIATE_RESPONSE :
src/stkutil.h +9 -0
@@ -412,6 +412,15 @@ struct stk_event_list { };/* +* According to 102.223 Section 8.26, the maximum length of cause is 30. +*/ +struct stk_cause { +unsigned char cause[30 ]; +unsigned int len; +ofono_bool_t has_cause; +}; + +/* * According to 102.223 Section 8.72 the length of text attribute CTLV is 1 * byte. This means that the maximum size is 127 according to the rules * of CTLVs. Empty attribute options will have len of 0.
Signature · 1 line
1.6.3.3
PATCH v2 5/10 Add parser for location status objects
--- src/stkutil.c | 30 ++++++++++++++++++++++++++++++ src/stkutil.h | 6 ++++++ 2 files changed, 36 insertions(+), 0 deletions(-)
src/stkutil.c +30 -0
@@ -67,6 +67,26 @@ static gboolean parse_dataobj_common_bool(struct comprehension_tlv_iter *iter,return TRUE; } +/* For data object that only has one byte */ +static gboolean parse_dataobj_common_byte ( +struct comprehension_tlv_iter *iter,void *user, +enum stk_data_object_type type) +{ +char *byte = user; +const unsigned char *data; + +if (comprehension_tlv_iter_get_tag (iter) != type) +return FALSE; + +if (comprehension_tlv_iter_get_length (iter) !=1 ) +return FALSE; + + data =comprehension_tlv_iter_get_data (iter); + *byte = data[0 ]; + +return TRUE; +} +/* For data object that only has a byte array with variable length */ static gboolean parse_dataobj_common_byte_array( struct comprehension_tlv_iter *iter,
@@ -715,6 +735,14 @@ static gboolean parse_dataobj_cause(return TRUE; } +/* Defined in TS 102.223 Section 8.27 */ +static gboolean parse_dataobj_location_status ( +struct comprehension_tlv_iter *iter,void *user) +{ +return parse_dataobj_common_byte (iter, user, +STK_DATA_OBJECT_TYPE_LOCATION_STATUS ); +} +/* Defined in TS 102.223 Section 8.31 */ static gboolean parse_dataobj_icon_id (struct comprehension_tlv_iter *iter,void *user)
@@ -838,6 +866,8 @@ static dataobj_handler handler_for_type(enum stk_data_object_type type)return parse_dataobj_event_list;case STK_DATA_OBJECT_TYPE_CAUSE :return parse_dataobj_cause; +case STK_DATA_OBJECT_TYPE_LOCATION_STATUS : +return parse_dataobj_location_status;case STK_DATA_OBJECT_TYPE_ICON_ID :return parse_dataobj_icon_id;case STK_DATA_OBJECT_TYPE_IMMEDIATE_RESPONSE :
src/stkutil.h +6 -0
@@ -290,6 +290,12 @@ enum stk_event_type {STK_EVENT_TYPE_MULTIPLE_ACCESS_TECHNOLOGIES_CHANGE =0x14 }; +enum stk_service_state { +STK_NORMAL_SERVICE =0x00 , +STK_LIMITED_SERVICE =0x01 , +STK_NO_SERVICE =0x02 +}; +/* Defined in TS 102.223 Section 8.1 */ struct stk_address {unsigned char ton_npi;
Signature · 1 line
1.6.3.3
PATCH v2 6/10 Add parser for transaction identifier objects
--- src/stkutil.c | 12 ++++++++++++ src/stkutil.h | 9 +++++++++ 2 files changed, 21 insertions(+), 0 deletions(-)
src/stkutil.c +12 -0
@@ -743,6 +743,16 @@ static gboolean parse_dataobj_location_status( STK_DATA_OBJECT_TYPE_LOCATION_STATUS); } +/* Defined in TS 102.223 Section 8.28 */ +static gboolean parse_dataobj_transaction_id ( +struct comprehension_tlv_iter *iter,void *user) +{ +struct stk_transaction_id *ti = user; + +return parse_dataobj_common_byte_array (iter, +STK_DATA_OBJECT_TYPE_TRANSACTION_ID , ti->list, &ti->len); +} +/* Defined in TS 102.223 Section 8.31 */ static gboolean parse_dataobj_icon_id (struct comprehension_tlv_iter *iter,void *user)
@@ -868,6 +878,8 @@ static dataobj_handler handler_for_type(enum stk_data_object_type type)return parse_dataobj_cause;case STK_DATA_OBJECT_TYPE_LOCATION_STATUS :return parse_dataobj_location_status; +case STK_DATA_OBJECT_TYPE_TRANSACTION_ID : +return parse_dataobj_transaction_id;case STK_DATA_OBJECT_TYPE_ICON_ID :return parse_dataobj_icon_id;case STK_DATA_OBJECT_TYPE_IMMEDIATE_RESPONSE :
src/stkutil.h +9 -0
@@ -427,6 +427,15 @@ struct stk_cause { };/* +* According to 102.223 Section 8.28 the length of CTLV is 1 byte. This means +* that the maximum size is 127 according to the rules of CTLVs. +*/ +struct stk_transaction_id { +unsigned char list[127 ]; +unsigned int len; +}; + +/* * According to 102.223 Section 8.72 the length of text attribute CTLV is 1 * byte. This means that the maximum size is 127 according to the rules * of CTLVs. Empty attribute options will have len of 0.
Signature · 1 line
1.6.3.3
PATCH v2 7/10 Add parser for call control requested action objects
--- src/stkutil.c | 20 ++++++++++++++++++++ src/stkutil.h | 6 ++++++ 2 files changed, 26 insertions(+), 0 deletions(-)
src/stkutil.c +20 -0
@@ -753,6 +753,24 @@ static gboolean parse_dataobj_transaction_id( STK_DATA_OBJECT_TYPE_TRANSACTION_ID, ti->list, &ti->len); } +/* Defined in TS 102.223 Section 8.30 */ +static gboolean parse_dataobj_call_control_requested_action ( +struct comprehension_tlv_iter *iter,void *user) +{ +struct stk_call_control_requested_action *action = user; +unsigned int len; + + len =comprehension_tlv_iter_get_length (iter); + + action->action =g_try_malloc (len); +if (action->action ==NULL ) +return FALSE; + +return parse_dataobj_common_byte_array (iter, +STK_DATA_OBJECT_TYPE_CALL_CONTROL_REQUESTED_ACTION , + action->action, &action->len); +} +/* Defined in TS 102.223 Section 8.31 */ static gboolean parse_dataobj_icon_id (struct comprehension_tlv_iter *iter,void *user)
@@ -880,6 +898,8 @@ static dataobj_handler handler_for_type(enum stk_data_object_type type)return parse_dataobj_location_status;case STK_DATA_OBJECT_TYPE_TRANSACTION_ID :return parse_dataobj_transaction_id; +case STK_DATA_OBJECT_TYPE_CALL_CONTROL_REQUESTED_ACTION : +return parse_dataobj_call_control_requested_action;case STK_DATA_OBJECT_TYPE_ICON_ID :return parse_dataobj_icon_id;case STK_DATA_OBJECT_TYPE_IMMEDIATE_RESPONSE :
src/stkutil.h +6 -0
@@ -435,6 +435,12 @@ struct stk_transaction_id {unsigned int len; }; +/* Defined in TS 102.223 Section 8.30 */ +struct stk_call_control_requested_action { +unsigned char *action; +unsigned int len; +}; +/* * According to 102.223 Section 8.72 the length of text attribute CTLV is 1 * byte. This means that the maximum size is 127 according to the rules
Signature · 1 line
1.6.3.3
PATCH v2 8/10 Add enum for icon qualifier
--- src/stkutil.h | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
src/stkutil.h +5 -0
@@ -296,6 +296,11 @@ enum stk_service_state {STK_NO_SERVICE =0x02 }; +enum stk_icon_qualifier { +STK_ICON_QUALIFIER_TYPE_SELF_EXPLANATORY =0x00 , +STK_ICON_QUALIFIER_TYPE_NON_SELF_EXPLANATORY =0x01 +}; +/* Defined in TS 102.223 Section 8.1 */ struct stk_address {unsigned char ton_npi;
Signature · 1 line
1.6.3.3
PATCH v2 9/10 Adjust the sequence of icon identifier structure
--- src/stkutil.h | 19 ++++++++++--------- 1 files changed, 10 insertions(+), 9 deletions(-)
src/stkutil.h +10 -9
@@ -343,15 +343,6 @@ struct stk_ccp { };/* -* Icon ID denotes a file on the SIM filesystem. Since EF cannot have record -* ids of 0, we use icon_id with 0 to denote empty icon_identifier objects -*/ -struct stk_icon_identifier { -unsigned char qualifier; -unsigned char id; -}; - -/* * According to 102.223 Section 8.8 interval values of 0x00 are reserved. * We use this to denote empty duration objects. */
@@ -447,6 +438,16 @@ struct stk_call_control_requested_action { };/* +* Defined in TS 102.223 Section 8.31 +* Icon ID denotes a file on the SIM filesystem. Since EF cannot have record +* ids of 0, we use icon_id with 0 to denote empty icon_identifier objects +*/ +struct stk_icon_identifier { +unsigned char qualifier; +unsigned char id; +}; + +/* * According to 102.223 Section 8.72 the length of text attribute CTLV is 1 * byte. This means that the maximum size is 127 according to the rules * of CTLVs. Empty attribute options will have len of 0.
Signature · 1 line
1.6.3.3
PATCH v2 10/10 Add parser for item icon identifier list objects
--- src/stkutil.c | 26 ++++++++++++++++++++++++++ src/stkutil.h | 12 ++++++++++++ 2 files changed, 38 insertions(+), 0 deletions(-)
src/stkutil.c +26 -0
@@ -793,6 +793,30 @@ static gboolean parse_dataobj_icon_id(struct comprehension_tlv_iter *iter,return TRUE; } +/* Defined in TS 102.223 Section 8.32 */ +static gboolean parse_dataobj_item_icon_id_list ( +struct comprehension_tlv_iter *iter,void *user) +{ +struct stk_item_icon_id_list *iiil = user; +const unsigned char *data; +unsigned int len; + +if (comprehension_tlv_iter_get_tag (iter) != +STK_DATA_OBJECT_TYPE_ITEM_ICON_ID_LIST ) +return FALSE; + + len =comprehension_tlv_iter_get_length (iter); +if (len <2 ) +return FALSE; + + data =comprehension_tlv_iter_get_data (iter); + iiil->qualifier = data[0 ]; + iiil->len = len -1 ; +memcpy (iiil->list, data +1 , iiil->len); + +return TRUE; +} +/* Defined in 102.223 Section 8.43 */ static gboolean parse_dataobj_imm_resp (struct comprehension_tlv_iter *iter,void *user)
@@ -902,6 +926,8 @@ static dataobj_handler handler_for_type(enum stk_data_object_type type)return parse_dataobj_call_control_requested_action;case STK_DATA_OBJECT_TYPE_ICON_ID :return parse_dataobj_icon_id; +case STK_DATA_OBJECT_TYPE_ITEM_ICON_ID_LIST : +return parse_dataobj_item_icon_id_list;case STK_DATA_OBJECT_TYPE_IMMEDIATE_RESPONSE :return parse_dataobj_imm_resp;case STK_DATA_OBJECT_TYPE_TEXT_ATTRIBUTE :
src/stkutil.h +12 -0
@@ -447,6 +447,18 @@ struct stk_icon_identifier {unsigned char id; }; +/* +* According to 102.223 Section 8.32 the length of CTLV is 1 byte. This means +* that the maximum size is 127 according to the rules of CTLVs. This size also +* includes icon list qualifier for 1 byte, so the maxmimum size of icon +* identifier list is 126. +*/ +struct stk_item_icon_id_list { +unsigned char qualifier; +unsigned char list[126 ]; +unsigned int len; +}; +/* * According to 102.223 Section 8.72 the length of text attribute CTLV is 1 * byte. This means that the maximum size is 127 according to the rules
Signature · 1 line
1.6.3.3
Re: [PATCH v2 09/10] Adjust the sequence of icon identifier structure
In reply to Yang GuHi Yang,
Quoted 3 lines
--- src/stkutil.h | 19 ++++++++++--------- 1 files changed, 10 insertions(+), 9 deletions(-)
Please sanity check your patches, while applying I got this:
Applying: Add parser for items next action indicator objects
Applying: Adjust the sequence of comprehension tlv structures
Applying: Add parser for event list objects
Applying: Add parser for cause objects
Applying: Add parser for location status objects
Applying: Add parser for transaction identifier objects
Applying: Add parser for call control requested action objects
Applying: Add enum for icon qualifier
Applying: Adjust the sequence of icon identifier structure /home/denkenz/ofono-master/.git/rebase-apply/patch:38: trailing whitespace. /*
fatal: 1 line adds whitespace errors.
Patch failed at 0009 Adjust the sequence of icon identifier structure When you have resolved this problem run "git am --resolved".
If you would prefer to skip this patch, instead run "git am --skip". To restore the original branch and stop patching run "git am --abort".
Use
[apply]
whitespace = error
in your git config and apply locally to make sure they do so cleanly.
Regards,
-Denis
Hi Yang,
Quoted 13 lines
src/stkutil.c +13
-0+/* For data object that only has a byte array with variable length */ +static gboolean parse_dataobj_common_byte_array ( +struct comprehension_tlv_iter *iter, +enum stk_data_object_type type, +unsigned char *array,unsigned int *array_len) +{ +const unsigned char *data; +unsigned int len; + +if (comprehension_tlv_iter_get_tag (iter) != type) +return FALSE; + + len =comprehension_tlv_iter_get_length (iter);
src/stkutil.c static gboolean parse_dataobj_common_bool(struct comprehension_tlv_iter *iter, · line 92
Quoted 10 lines
src/stkutil.c +10
-0+if (len <1 ) +return FALSE; + + data =comprehension_tlv_iter_get_data (iter); + *array_len = len; +memcpy (array, data, len); + +return TRUE; +} +
So I can see the point of this function for a byte array that requires to be allocated. For fixed size arrays this function is not adequate; it does not do length (boundary) checking for instance.
Regards,
-Denis