Skip to content

Commit

Permalink
Simplify logic a bit now that we do not use anymore GUINT_TO_POINTER …
Browse files Browse the repository at this point in the history
…macro

svn path=/trunk/; revision=51490
  • Loading branch information
pquantin committed Aug 23, 2013
1 parent 483ee31 commit ae4f556
Show file tree
Hide file tree
Showing 3 changed files with 250 additions and 242 deletions.
201 changes: 96 additions & 105 deletions asn1/lte-rrc/lte-rrc.cnf
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ SI-OrPSI-GERAN TYPE_PREFIX
}

#.FN_BODY UE-CapabilityRAT-Container
/* Since storing value+1, this effectively unsets this field */
private_data_set_rat_type(actx, 0);
/* Initialise to invalid value */
private_data_set_rat_type(actx, 0xFF);
%(DEFAULT_BODY)s

#.FN_BODY RAT-Type VAL_PTR = &rat_type
guint32 rat_type;
%(DEFAULT_BODY)s
private_data_set_rat_type(actx, rat_type+1);
private_data_set_rat_type(actx, (guint8)rat_type);

#RAT-Type ::= ENUMERATED {
# eutra, utra, geran-cs, geran-ps, cdma2000-1XRTT,
Expand Down Expand Up @@ -127,55 +127,51 @@ if(ue_cap_tvb){
proto_tree *subtree, *subtree2;
guint8 byte;
subtree = proto_item_add_subtree(actx->created_item, ett_lte_rrc_UE_CapabilityRAT_Container);
if (private_data_get_rat_type(actx)) {
switch(private_data_get_rat_type(actx)-1){
case RAT_Type_eutra:
/* eutra */
dissect_lte_rrc_UE_EUTRA_Capability_PDU(ue_cap_tvb, actx->pinfo, subtree, NULL);
break;
case RAT_Type_utra:
/* utra */
dissect_rrc_InterRATHandoverInfo_PDU(ue_cap_tvb, actx->pinfo, subtree, NULL);
break;
case RAT_Type_geran_cs:
/* geran-cs */
/* Mobile Station Classmark 2 is formatted as TLV with the two first bytes set to 0x33 0x03 */
item = proto_tree_add_text(subtree, ue_cap_tvb, 0, 5, "Mobile Station Classmark 2");
subtree2 = proto_item_add_subtree(item, ett_lte_rrc_UE_CapabilityRAT_Container);
byte = tvb_get_guint8(ue_cap_tvb, 0);
if (byte != 0x33) {
expert_add_info_format_text(actx->pinfo, item, &ei_lte_rrc_unexpected_type_value,
"Unexpected type value (found 0x%02X)", byte);
}
byte = tvb_get_guint8(ue_cap_tvb, 1);
if (byte != 0x03) {
expert_add_info_format_text(actx->pinfo, item, &ei_lte_rrc_unexpected_length_value,
"Unexpected length value (found %d)", byte);
}
de_ms_cm_2(ue_cap_tvb, subtree2, actx->pinfo, 2, 3, NULL, 0);
/* Mobile Station Classmark 3 is formatted as V */
length = tvb_ensure_length_remaining(ue_cap_tvb, 5);
item = proto_tree_add_text(subtree, ue_cap_tvb, 5, length, "Mobile Station Classmark 3");
subtree2 = proto_item_add_subtree(item, ett_lte_rrc_UE_CapabilityRAT_Container);
de_ms_cm_3(ue_cap_tvb, subtree2, actx->pinfo, 5, length, NULL, 0);
break;
case RAT_Type_geran_ps:
/* geran-ps */
/* MS Radio Access Capability is formatted as V */
length = tvb_length(ue_cap_tvb);
item = proto_tree_add_text(subtree, ue_cap_tvb, 0, length, "MS Radio Access Capability");
subtree2 = proto_item_add_subtree(item, ett_lte_rrc_UE_CapabilityRAT_Container);
de_gmm_ms_radio_acc_cap(ue_cap_tvb, subtree2, actx->pinfo, 0, length, NULL, 0);
break;
case RAT_Type_cdma2000_1XRTT:
/* cdma2000-1XRTT */
/* dissection of "A21 Mobile Subscription Information" could be added to packet-ansi_a.c */
break;
default:
break;
switch(private_data_get_rat_type(actx)){
case RAT_Type_eutra:
/* eutra */
dissect_lte_rrc_UE_EUTRA_Capability_PDU(ue_cap_tvb, actx->pinfo, subtree, NULL);
break;
case RAT_Type_utra:
/* utra */
dissect_rrc_InterRATHandoverInfo_PDU(ue_cap_tvb, actx->pinfo, subtree, NULL);
break;
case RAT_Type_geran_cs:
/* geran-cs */
/* Mobile Station Classmark 2 is formatted as TLV with the two first bytes set to 0x33 0x03 */
item = proto_tree_add_text(subtree, ue_cap_tvb, 0, 5, "Mobile Station Classmark 2");
subtree2 = proto_item_add_subtree(item, ett_lte_rrc_UE_CapabilityRAT_Container);
byte = tvb_get_guint8(ue_cap_tvb, 0);
if (byte != 0x33) {
expert_add_info_format_text(actx->pinfo, item, &ei_lte_rrc_unexpected_type_value,
"Unexpected type value (found 0x%02X)", byte);
}
/* Unset again */
private_data_set_rat_type(actx, 0);
byte = tvb_get_guint8(ue_cap_tvb, 1);
if (byte != 0x03) {
expert_add_info_format_text(actx->pinfo, item, &ei_lte_rrc_unexpected_length_value,
"Unexpected length value (found %d)", byte);
}
de_ms_cm_2(ue_cap_tvb, subtree2, actx->pinfo, 2, 3, NULL, 0);
/* Mobile Station Classmark 3 is formatted as V */
length = tvb_ensure_length_remaining(ue_cap_tvb, 5);
item = proto_tree_add_text(subtree, ue_cap_tvb, 5, length, "Mobile Station Classmark 3");
subtree2 = proto_item_add_subtree(item, ett_lte_rrc_UE_CapabilityRAT_Container);
de_ms_cm_3(ue_cap_tvb, subtree2, actx->pinfo, 5, length, NULL, 0);
break;
case RAT_Type_geran_ps:
/* geran-ps */
/* MS Radio Access Capability is formatted as V */
length = tvb_length(ue_cap_tvb);
item = proto_tree_add_text(subtree, ue_cap_tvb, 0, length, "MS Radio Access Capability");
subtree2 = proto_item_add_subtree(item, ett_lte_rrc_UE_CapabilityRAT_Container);
de_gmm_ms_radio_acc_cap(ue_cap_tvb, subtree2, actx->pinfo, 0, length, NULL, 0);
break;
case RAT_Type_cdma2000_1XRTT:
/* cdma2000-1XRTT */
/* dissection of "A21 Mobile Subscription Information" could be added to packet-ansi_a.c */
break;
default:
break;
}
}

Expand Down Expand Up @@ -229,13 +225,13 @@ if(ue_cap_tvb){

#.FN_BODY Handover
/* Initialise to invalid value */
private_data_set_rat_type(actx, 0);
private_data_set_rat_target_type(actx, 0xFF);
%(DEFAULT_BODY)s

#.FN_BODY Handover/targetRAT-Type VAL_PTR = &target_rat_type
guint32 target_rat_type;
%(DEFAULT_BODY)s
private_data_set_rat_target_type(actx, target_rat_type+1);
private_data_set_rat_target_type(actx, (guint8)target_rat_type);

#.FN_BODY Handover/targetRAT-MessageContainer VAL_PTR = &target_rat_msg_cont_tvb
tvbuff_t *target_rat_msg_cont_tvb = NULL;
Expand All @@ -244,37 +240,33 @@ if(ue_cap_tvb){
guint8 byte;
proto_tree *subtree;
subtree = proto_item_add_subtree(actx->created_item, ett_lte_rrc_targetRAT_MessageContainer);
if (private_data_get_rat_target_type(actx)) {
switch (private_data_get_rat_target_type(actx)-1){
case T_targetRAT_Type_utra:
/* utra */
if (rrc_irat_ho_to_utran_cmd_handle)
call_dissector(rrc_irat_ho_to_utran_cmd_handle, target_rat_msg_cont_tvb, actx->pinfo, subtree);
break;
case T_targetRAT_Type_geran:
/* geran */
byte = tvb_get_guint8(target_rat_msg_cont_tvb, 0);
if (byte == 0x06) {
if (gsm_a_dtap_handle) {
call_dissector(gsm_a_dtap_handle, target_rat_msg_cont_tvb, actx->pinfo, subtree);
}
} else {
if (gsm_rlcmac_dl_handle) {
call_dissector(gsm_rlcmac_dl_handle, target_rat_msg_cont_tvb, actx->pinfo, subtree);
}
switch (private_data_get_rat_target_type(actx)){
case T_targetRAT_Type_utra:
/* utra */
if (rrc_irat_ho_to_utran_cmd_handle)
call_dissector(rrc_irat_ho_to_utran_cmd_handle, target_rat_msg_cont_tvb, actx->pinfo, subtree);
break;
case T_targetRAT_Type_geran:
/* geran */
byte = tvb_get_guint8(target_rat_msg_cont_tvb, 0);
if (byte == 0x06) {
if (gsm_a_dtap_handle) {
call_dissector(gsm_a_dtap_handle, target_rat_msg_cont_tvb, actx->pinfo, subtree);
}
} else {
if (gsm_rlcmac_dl_handle) {
call_dissector(gsm_rlcmac_dl_handle, target_rat_msg_cont_tvb, actx->pinfo, subtree);
}
break;
case T_targetRAT_Type_cdma2000_1XRTT:
/* cdma2000-1XRTT */
break;
case T_targetRAT_Type_cdma2000_HRPD:
/* cdma2000-HRPD */
break;
default:
break;
}
/* Unset again */
private_data_set_rat_target_type(actx, 0);
break;
case T_targetRAT_Type_cdma2000_1XRTT:
/* cdma2000-1XRTT */
break;
case T_targetRAT_Type_cdma2000_HRPD:
/* cdma2000-HRPD */
break;
default:
break;
}
}

Expand Down Expand Up @@ -302,13 +294,16 @@ if(ue_cap_tvb){
de_emm_sec_par_to_eutra(nas_sec_param_to_eutra_tvb, subtree, actx->pinfo, 0, length, NULL, 0);
}

#.FN_BODY SI-OrPSI-GERAN VAL_PTR = &si_or_psi_geran
guint32 si_or_psi_geran;
#.FN_BODY SI-OrPSI-GERAN/si
private_data_set_si_or_psi_geran(actx, (guint8)SI_OrPSI_GERAN_si); /* SI message */
%(DEFAULT_BODY)s

#.FN_BODY SI-OrPSI-GERAN/psi
private_data_set_si_or_psi_geran(actx, (guint8)SI_OrPSI_GERAN_psi); /* PSI message */
%(DEFAULT_BODY)s
private_data_set_si_or_psi_geran(actx, si_or_psi_geran+1);

#.FN_BODY CellInfoGERAN-r9
private_data_set_si_or_psi_geran(actx, SI_OrPSI_GERAN_si+1); /* SI message */
#.FN_BODY CellInfoGERAN-r9/systemInformation-r9
private_data_set_si_or_psi_geran(actx, (guint8)SI_OrPSI_GERAN_si); /* SI message */
%(DEFAULT_BODY)s

#.FN_BODY SystemInfoListGERAN/_item VAL_PTR = &sys_info_list_tvb
Expand All @@ -317,25 +312,21 @@ if(ue_cap_tvb){
%(DEFAULT_BODY)s
if (sys_info_list_tvb) {
subtree = proto_item_add_subtree(actx->created_item, ett_lte_rrc_siPsiSibContainer);
if (private_data_get_si_or_psi_geran(actx)) {
switch (private_data_get_si_or_psi_geran(actx)-1) {
case SI_OrPSI_GERAN_si:
/* SI message */
if (gsm_a_dtap_handle) {
call_dissector(gsm_a_dtap_handle, sys_info_list_tvb, actx->pinfo, subtree);
}
break;
case SI_OrPSI_GERAN_psi:
/* PSI message */
if (gsm_rlcmac_dl_handle) {
call_dissector(gsm_rlcmac_dl_handle, sys_info_list_tvb, actx->pinfo, subtree);
}
break;
default:
break;
switch (private_data_get_si_or_psi_geran(actx)) {
case SI_OrPSI_GERAN_si:
/* SI message */
if (gsm_a_dtap_handle) {
call_dissector(gsm_a_dtap_handle, sys_info_list_tvb, actx->pinfo, subtree);
}
break;
case SI_OrPSI_GERAN_psi:
/* PSI message */
if (gsm_rlcmac_dl_handle) {
call_dissector(gsm_rlcmac_dl_handle, sys_info_list_tvb, actx->pinfo, subtree);
}
/* Unset value */
private_data_set_si_or_psi_geran(actx, 0);
break;
default:
break;
}
}

Expand Down
20 changes: 10 additions & 10 deletions asn1/lte-rrc/packet-lte-rrc-template.c
Original file line number Diff line number Diff line change
Expand Up @@ -1813,11 +1813,11 @@ typedef struct drx_config_t {
/* Struct to store all current uses of packet private data */
typedef struct lte_rrc_private_data_t
{
guint32 rat_type; /* Store as +1 real value, so 0 means 'not set' */
guint32 target_rat_type; /* Store as +1 real value, so 0 means 'not set' */
guint32 si_or_psi_geran; /* Store as +1 real value, so 0 means 'not set' */
guint16 message_identifier;
guint8 rat_type;
guint8 target_rat_type;
guint8 si_or_psi_geran;
guint8 ra_preambles;
guint16 message_identifier;
drb_mapping_t drb_mapping;
drx_config_t drx_config;
} lte_rrc_private_data_t;
Expand Down Expand Up @@ -1853,41 +1853,41 @@ static drb_mapping_t* private_data_get_drb_mapping(asn1_ctx_t *actx)


/* RAT type */
static guint32 private_data_get_rat_type(asn1_ctx_t *actx)
static guint8 private_data_get_rat_type(asn1_ctx_t *actx)
{
lte_rrc_private_data_t *private_data = (lte_rrc_private_data_t*)lte_rrc_get_private_data(actx);
return private_data->rat_type;
}

static void private_data_set_rat_type(asn1_ctx_t *actx, guint32 rat_type)
static void private_data_set_rat_type(asn1_ctx_t *actx, guint8 rat_type)
{
lte_rrc_private_data_t *private_data = (lte_rrc_private_data_t*)lte_rrc_get_private_data(actx);
private_data->rat_type = rat_type;
}


/* Target RAT type */
static guint32 private_data_get_rat_target_type(asn1_ctx_t *actx)
static guint8 private_data_get_rat_target_type(asn1_ctx_t *actx)
{
lte_rrc_private_data_t *private_data = (lte_rrc_private_data_t*)lte_rrc_get_private_data(actx);
return private_data->target_rat_type;
}

static void private_data_set_rat_target_type(asn1_ctx_t *actx, guint32 target_rat_type)
static void private_data_set_rat_target_type(asn1_ctx_t *actx, guint8 target_rat_type)
{
lte_rrc_private_data_t *private_data = (lte_rrc_private_data_t*)lte_rrc_get_private_data(actx);
private_data->target_rat_type = target_rat_type;
}


/* si_or_psi_geran */
static guint32 private_data_get_si_or_psi_geran(asn1_ctx_t *actx)
static guint8 private_data_get_si_or_psi_geran(asn1_ctx_t *actx)
{
lte_rrc_private_data_t *private_data = (lte_rrc_private_data_t*)lte_rrc_get_private_data(actx);
return private_data->si_or_psi_geran;
}

static void private_data_set_si_or_psi_geran(asn1_ctx_t *actx, guint32 si_or_psi_geran)
static void private_data_set_si_or_psi_geran(asn1_ctx_t *actx, guint8 si_or_psi_geran)
{
lte_rrc_private_data_t *private_data = (lte_rrc_private_data_t*)lte_rrc_get_private_data(actx);
private_data->si_or_psi_geran = si_or_psi_geran;
Expand Down
Loading

0 comments on commit ae4f556

Please sign in to comment.