All of lore.kernel.org
 help / color / mirror / Atom feed
From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH 3/4] Add parser for file list objects
Date: Tue, 16 Mar 2010 14:01:12 -0600	[thread overview]
Message-ID: <201003161501.13210.denkenz@gmail.com> (raw)
In-Reply-To: <1268733700-30154-3-git-send-email-yang.gu@intel.com>

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

Hi Yang,

> ---
>  src/stkutil.c |   42 ++++++++++++++++++++++++++++++++++++++++++
>  src/stkutil.h |    6 ++++++
>  2 files changed, 48 insertions(+), 0 deletions(-)
> 
> diff --git a/src/stkutil.c b/src/stkutil.c
> index ceba2d5..9f3bc0b 100644
> --- a/src/stkutil.c
> +++ b/src/stkutil.c
> @@ -406,6 +406,46 @@ static gboolean parse_dataobj_tone(struct
>  comprehension_tlv_iter *iter, return TRUE;
>  }
> 
> +/* Defined in TS 102.223 Section 8.18 */
> +static gboolean parse_dataobj_file_list(struct comprehension_tlv_iter
>  *iter, +						void *user)
> +{
> +	GSList **fl = user;
> +	const unsigned char *data;
> +	unsigned int len;
> +	unsigned int i;
> +	unsigned int start = 1;
> +	struct stk_file *sf;
> +
> +	if (comprehension_tlv_iter_get_tag(iter) !=
> +			STK_DATA_OBJECT_TYPE_FILE_LIST)
> +		return FALSE;
> +
> +	len = comprehension_tlv_iter_get_length(iter);
> +	if (len < 5)
> +		return FALSE;
> +
> +	data = comprehension_tlv_iter_get_data(iter);
> +
> +	if (data[start] != 0x3f)
> +		return FALSE;
> +
> +	for (i = start + 4; i <= len; i += 2) {
> +		if ((data[i] == 0x3f) || (i == len)) {
> +			sf = g_new0(struct stk_file, 1);
> +			sf->file = g_malloc(i-start);
> +			memcpy(sf->file, data+start, i-start);
> +			sf->len = i - start;
> +			*fl = g_slist_prepend(*fl, sf);
> +			start = i;
> +		}
> +	}
> +

Ok, so the logic here actually makes no sense.  Please review TS 31.124 for an 
example on how this actually works.  Basically these guys are relying on 
0x3FXX as the marker for identifying the Master File and then relying on the 
type of MF/DF/EF to figure out where the file identifier ends.  Completely 
insane.

For reference from TS 11.11:

The first byte identifies the type of file, and for GSM is:
‑	'3F': Master File;
‑	'7F': 1st level Dedicated File;
-	'5F': 2nd level Dedicated File;
‑	'2F': Elementary File under the Master File;
‑	'6F': Elementary File under a 1st level Dedicated File;
-	'4F': Elementary File under 2nd level Dedicated File.

You will have to walk each first byte to determine when the file actually ends.  
I suggest allocating a maximum of 8 bytes to the file structure (2 bytes for 
MF, 2 bytes for 1st level DF, 2 bytes for 2nd level DF and 2 bytes for EF)

Regards,
-Denis

> +	*fl = g_slist_reverse(*fl);
> +
> +	return TRUE;
> +}
> +
>  /* Defined in TS 102.223 Section 8.31 */
>  static gboolean parse_dataobj_icon_id(struct comprehension_tlv_iter *iter,
>  					void *user)
> @@ -523,6 +563,8 @@ static dataobj_handler handler_for_type(enum
>  stk_data_object_type type) return parse_dataobj_text;
>  	case STK_DATA_OBJECT_TYPE_TONE:
>  		return parse_dataobj_tone;
> +	case STK_DATA_OBJECT_TYPE_FILE_LIST:
> +		return parse_dataobj_file_list;
>  	case STK_DATA_OBJECT_TYPE_ICON_ID:
>  		return parse_dataobj_icon_id;
>  	case STK_DATA_OBJECT_TYPE_IMMEDIATE_RESPONSE:
> diff --git a/src/stkutil.h b/src/stkutil.h
> index b408f38..5b1a44b 100644
> --- a/src/stkutil.h
> +++ b/src/stkutil.h
> @@ -345,6 +345,12 @@ struct stk_result {
>  	unsigned char *additional;
>  };
> 
> +/* Define the struct of single file in TS102.223 Section 8.18 */
> +struct stk_file {
> +	unsigned char *file;
> +	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
> 

  parent reply	other threads:[~2010-03-16 20:01 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-16 10:01 [PATCH 1/4] Fix the structure of stk_subaddress Yang Gu
2010-03-16 10:01 ` [PATCH 2/4] Handle the conversion failure when parsing item Yang Gu
2010-03-16 10:01   ` [PATCH 3/4] Add parser for file list objects Yang Gu
2010-03-16 10:01     ` [PATCH 4/4] Add parser for location information objects Yang Gu
2010-03-16 18:46       ` Marcel Holtmann
2010-03-16 18:44     ` [PATCH 3/4] Add parser for file list objects Marcel Holtmann
2010-03-16 20:01     ` Denis Kenzior [this message]
2010-03-16 18:36   ` [PATCH 2/4] Handle the conversion failure when parsing item Marcel Holtmann
2010-03-16 20:27     ` Denis Kenzior
2010-03-17  4:40       ` Marcel Holtmann
2010-03-16 20:29   ` Denis Kenzior
2010-03-17  3:33     ` Gu, Yang
2010-03-17  4:44       ` Marcel Holtmann
2010-03-16 20:28 ` [PATCH 1/4] Fix the structure of stk_subaddress Denis Kenzior

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=201003161501.13210.denkenz@gmail.com \
    --to=denkenz@gmail.com \
    --cc=ofono@ofono.org \
    /path/to/YOUR_REPLY

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

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