mirror of git://git.sysmocom.de/ofono
stkutil: Refactor stk_location_info
In some cases an empty stk_location_info means that no object should be emitted (e.g. it is optional) and in other cases an empty object should be emitted. This is context specific to the terminal response / envelope and thus we break this up into two separate functions.
This commit is contained in:
parent
08c689ca7c
commit
b95ef22f61
|
@ -3492,14 +3492,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);
|
||||
|
||||
|
@ -3532,6 +3526,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.
|
||||
|
@ -4036,12 +4039,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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue