diff --git a/asn1/gsm_map/gsm_map.cnf b/asn1/gsm_map/gsm_map.cnf index 6f555563d5..7b9ac29f38 100644 --- a/asn1/gsm_map/gsm_map.cnf +++ b/asn1/gsm_map/gsm_map.cnf @@ -566,7 +566,7 @@ actx->pinfo->p2p_dir = P2P_DIR_RECV; if (!parameter_tvb) return offset; subtree = proto_item_add_subtree(actx->created_item, ett_gsm_map_LAIFixedLength); - dissect_e212_mcc_mnc(parameter_tvb, actx->pinfo, subtree, 0); + dissect_e212_mcc_mnc(parameter_tvb, actx->pinfo, subtree, 0, TRUE); #.FN_BODY RadioResourceInformation VAL_PTR = ¶meter_tvb tvbuff_t *parameter_tvb; diff --git a/asn1/ranap/ranap.cnf b/asn1/ranap/ranap.cnf index 98736bc7d6..7cfe1f8000 100644 --- a/asn1/ranap/ranap.cnf +++ b/asn1/ranap/ranap.cnf @@ -243,7 +243,7 @@ MAX_VAL = asn1_param_get_integer(%(ACTX)s,"upperBound") if (!parameter_tvb) return offset; - dissect_e212_mcc_mnc(parameter_tvb, actx->pinfo, tree, 0); + dissect_e212_mcc_mnc(parameter_tvb, actx->pinfo, tree, 0, FALSE); #.END # FN_BODY MBMSSessionDuration VAL_PTR = ¶meter_tvb diff --git a/asn1/s1ap/s1ap.cnf b/asn1/s1ap/s1ap.cnf index 7d3e9ba1ea..2788a7d1aa 100644 --- a/asn1/s1ap/s1ap.cnf +++ b/asn1/s1ap/s1ap.cnf @@ -173,7 +173,7 @@ MAX_VAL = asn1_param_get_integer(%(ACTX)s,"upperBound") if (!parameter_tvb) return offset; - dissect_e212_mcc_mnc(parameter_tvb, actx->pinfo, tree, 0); + dissect_e212_mcc_mnc(parameter_tvb, actx->pinfo, tree, 0, FALSE); #.END #.FN_BODY NAS-PDU VAL_PTR = ¶meter_tvb diff --git a/asn1/sabp/sabp.cnf b/asn1/sabp/sabp.cnf index 381f4ee4f3..e0d8a8cbce 100644 --- a/asn1/sabp/sabp.cnf +++ b/asn1/sabp/sabp.cnf @@ -163,7 +163,7 @@ Error-Indication N sabp.proc.imsg id-Error-Indication if (!parameter_tvb) return offset; subtree = proto_item_add_subtree(actx->created_item, ett_sabp_e212); - dissect_e212_mcc_mnc(parameter_tvb, actx->pinfo, subtree, 0); + dissect_e212_mcc_mnc(parameter_tvb, actx->pinfo, subtree, 0, FALSE); #.FN_BODY Data-Coding-Scheme VAL_PTR = ¶meter_tvb tvbuff_t *parameter_tvb=NULL; diff --git a/asn1/x2ap/x2ap.cnf b/asn1/x2ap/x2ap.cnf index 7f9075161c..e904b23398 100644 --- a/asn1/x2ap/x2ap.cnf +++ b/asn1/x2ap/x2ap.cnf @@ -84,7 +84,7 @@ ProtocolIE-ContainerPairList if (!parameter_tvb) return offset; - dissect_e212_mcc_mnc(parameter_tvb, actx->pinfo, tree, 0); + dissect_e212_mcc_mnc(parameter_tvb, actx->pinfo, tree, 0, FALSE); #.END #.FN_BODY TargeteNBtoSource-eNBTransparentContainer VAL_PTR = ¶meter_tvb diff --git a/epan/dissectors/packet-bssap.c b/epan/dissectors/packet-bssap.c index a0e84542b0..fd03042e55 100644 --- a/epan/dissectors/packet-bssap.c +++ b/epan/dissectors/packet-bssap.c @@ -1631,7 +1631,7 @@ dissect_bssap_global_cn_id(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, */ plmn_item = proto_tree_add_item(global_cn_id_tree, hf_bssap_plmn_id, tvb, offset, 3, FALSE); plmn_tree = proto_item_add_subtree(plmn_item, ett_bssap_plmn); - dissect_e212_mcc_mnc(tvb, pinfo, plmn_tree, offset); + dissect_e212_mcc_mnc(tvb, pinfo, plmn_tree, offset, TRUE); offset = offset + 3; /* Octet 6 - 7 CN-Id (INTEGER 0..4095) */ diff --git a/epan/dissectors/packet-diameter_3gpp.c b/epan/dissectors/packet-diameter_3gpp.c index 38f41c70e6..be1f5838c3 100644 --- a/epan/dissectors/packet-diameter_3gpp.c +++ b/epan/dissectors/packet-diameter_3gpp.c @@ -120,7 +120,7 @@ dissect_diameter_3gpp_tmgi(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree proto_tree_add_item(sub_tree, hf_diameter_mbms_service_id, tvb, offset, 3, FALSE); offset = offset+3; - offset = dissect_e212_mcc_mnc(tvb, pinfo, sub_tree, offset); + offset = dissect_e212_mcc_mnc(tvb, pinfo, sub_tree, offset, TRUE); return offset; diff --git a/epan/dissectors/packet-e212.c b/epan/dissectors/packet-e212.c index e659b1b079..eb8c285f7c 100644 --- a/epan/dissectors/packet-e212.c +++ b/epan/dissectors/packet-e212.c @@ -1596,6 +1596,21 @@ static int hf_E212_mnc = -1; static int hf_E212_msin = -1; /* + * MCC/MNC dissection - little endian MNC encoding + * + * MNC of length 2: + * + * 8 7 6 5 4 3 2 1 + * +---+---+---+---+---+---+---+---+ + * | MCC digit 2 | MCC digit 1 | octet x + * +---------------+---------------+ + * | Filler | MCC digit 3 | octet x+1 + * +---------------+---------------+ + * | MNC digit 2 | MNC digit 1 | octet x+2 + * +---------------+---------------+ + * + * MNC of length 3: + * * 8 7 6 5 4 3 2 1 * +---+---+---+---+---+---+---+---+ * | MCC digit 2 | MCC digit 1 | octet x @@ -1604,9 +1619,34 @@ static int hf_E212_msin = -1; * +---------------+---------------+ * | MNC digit 2 | MNC digit 1 | octet x+2 * +---------------+---------------+ + * + * + * MCC/MNC dissection - big endian MNC encoding + * + * MNC of length 2: + * + * 8 7 6 5 4 3 2 1 + * +---+---+---+---+---+---+---+---+ + * | MCC digit 2 | MCC digit 1 | octet x + * +---------------+---------------+ + * | Filler | MCC digit 3 | octet x+1 + * +---------------+---------------+ + * | MNC digit 2 | MNC digit 1 | octet x+2 + * +---------------+---------------+ + * + * MNC of length 3: + * + * 8 7 6 5 4 3 2 1 + * +---+---+---+---+---+---+---+---+ + * | MCC digit 2 | MCC digit 1 | octet x + * +---------------+---------------+ + * | MNC digit 1 | MCC digit 3 | octet x+1 + * +---------------+---------------+ + * | MNC digit 3 | MNC digit 2 | octet x+2 + * +---------------+---------------+ */ int -dissect_e212_mcc_mnc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset){ +dissect_e212_mcc_mnc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, gboolean little_endian){ int start_offset; guint8 octet; @@ -1632,7 +1672,10 @@ dissect_e212_mcc_mnc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int of mcc = 100 * mcc1 + 10 * mcc2 + mcc3; mnc = 10 * mnc1 + mnc2; if (mnc3 != 0xf) { - mnc = 10 * mnc + mnc3; + if(little_endian) + mnc = 10 * mnc + mnc3; + else + mnc = 100 * mnc3 + mnc; } item = proto_tree_add_uint(tree, hf_E212_mcc , tvb, start_offset, 2, mcc ); if ((mcc1 > 9) || (mcc2 > 9) || (mcc3 > 9)) diff --git a/epan/dissectors/packet-e212.h b/epan/dissectors/packet-e212.h index ec92f3f7a4..71975eccef 100644 --- a/epan/dissectors/packet-e212.h +++ b/epan/dissectors/packet-e212.h @@ -30,7 +30,7 @@ extern const value_string E212_codes[]; -int dissect_e212_mcc_mnc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset); +int dissect_e212_mcc_mnc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, gboolean little_endian); int dissect_e212_mcc_mnc_in_address(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset); #endif /* __PACKET_E212_H__ */ diff --git a/epan/dissectors/packet-gsm_a_bssmap.c b/epan/dissectors/packet-gsm_a_bssmap.c index 5b16056a1c..373c315460 100644 --- a/epan/dissectors/packet-gsm_a_bssmap.c +++ b/epan/dissectors/packet-gsm_a_bssmap.c @@ -1520,7 +1520,10 @@ be_cell_id_aux(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar */ /* FALLTHRU */ case 0x0c: /* For identification of a UTRAN cell for cell load information: */ - curr_offset = dissect_e212_mcc_mnc(tvb, g_pinfo, tree, curr_offset); + if (disc != 0x0b) + curr_offset = dissect_e212_mcc_mnc(tvb, g_pinfo, tree, curr_offset, TRUE); + else + curr_offset = dissect_e212_mcc_mnc(tvb, g_pinfo, tree, curr_offset, FALSE); /* FALLTHRU */ case 0x01: diff --git a/epan/dissectors/packet-gsm_a_common.c b/epan/dissectors/packet-gsm_a_common.c index aa62fd4bc8..046adb6480 100644 --- a/epan/dissectors/packet-gsm_a_common.c +++ b/epan/dissectors/packet-gsm_a_common.c @@ -1705,7 +1705,7 @@ de_lai(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *ad mcc_mnc_aux(octs, mcc, mnc); - curr_offset = dissect_e212_mcc_mnc(tvb, gsm_a_dtap_pinfo, subtree, curr_offset); + curr_offset = dissect_e212_mcc_mnc(tvb, gsm_a_dtap_pinfo, subtree, curr_offset, TRUE); value = tvb_get_ntohs(tvb, curr_offset); @@ -1904,7 +1904,7 @@ de_mid(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_st /* MCC/MNC*/ /* MCC, Mobile country code (octet 6a, octet 6b bits 1 to 4)*/ /* MNC, Mobile network code (octet 6b bits 5 to 8, octet 6c) */ - curr_offset = dissect_e212_mcc_mnc(tvb, gsm_a_dtap_pinfo, tree, curr_offset); + curr_offset = dissect_e212_mcc_mnc(tvb, gsm_a_dtap_pinfo, tree, curr_offset,TRUE); } if((oct&0x20)==0x20){ /* MBMS Session Identity (octet 7) diff --git a/epan/dissectors/packet-gsm_a_gm.c b/epan/dissectors/packet-gsm_a_gm.c index ee16816f56..a18fd0e805 100644 --- a/epan/dissectors/packet-gsm_a_gm.c +++ b/epan/dissectors/packet-gsm_a_gm.c @@ -2541,7 +2541,7 @@ de_gmm_rai(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar mcc,mnc,lac,rac); subtree = proto_item_add_subtree(item, ett_gmm_rai); - dissect_e212_mcc_mnc(tvb, gsm_a_dtap_pinfo, subtree, offset); + dissect_e212_mcc_mnc(tvb, gsm_a_dtap_pinfo, subtree, offset, TRUE); proto_tree_add_item(subtree, hf_gsm_a_lac, tvb, curr_offset+3, 2, FALSE); proto_tree_add_item(subtree, hf_gsm_a_gm_rac, tvb, curr_offset+5, 1, FALSE); @@ -4291,7 +4291,7 @@ de_sm_tmgi(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *ad curr_offset += 3; NO_MORE_DATA_CHECK(len); - curr_offset = dissect_e212_mcc_mnc(tvb, gsm_a_dtap_pinfo, tree, curr_offset); + curr_offset = dissect_e212_mcc_mnc(tvb, gsm_a_dtap_pinfo, tree, curr_offset, TRUE); EXTRANEOUS_DATA_CHECK(len, curr_offset - offset); diff --git a/epan/dissectors/packet-gsm_map.c b/epan/dissectors/packet-gsm_map.c index 1d761d1e92..7447105758 100644 --- a/epan/dissectors/packet-gsm_map.c +++ b/epan/dissectors/packet-gsm_map.c @@ -3653,7 +3653,7 @@ dissect_gsm_map_LAIFixedLength(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int if (!parameter_tvb) return offset; subtree = proto_item_add_subtree(actx->created_item, ett_gsm_map_LAIFixedLength); - dissect_e212_mcc_mnc(parameter_tvb, actx->pinfo, subtree, 0); + dissect_e212_mcc_mnc(parameter_tvb, actx->pinfo, subtree, 0, TRUE); diff --git a/epan/dissectors/packet-gtpv2.c b/epan/dissectors/packet-gtpv2.c index 1a93d55c8c..05987fca43 100644 --- a/epan/dissectors/packet-gtpv2.c +++ b/epan/dissectors/packet-gtpv2.c @@ -788,7 +788,7 @@ dissect_gtpv2_rat_type(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, static void dissect_gtpv2_serv_net(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 instance _U_) { - dissect_e212_mcc_mnc(tvb, pinfo, tree, 0); + dissect_e212_mcc_mnc(tvb, pinfo, tree, 0, TRUE); } /* @@ -1150,7 +1150,7 @@ dissect_gtpv2_uli(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto /* 8.22.1 CGI field */ if (flags&0x01) { - dissect_e212_mcc_mnc(tvb, pinfo, tree, offset); + dissect_e212_mcc_mnc(tvb, pinfo, tree, offset, TRUE); offset+=3; proto_tree_add_item(tree, hf_gtpv2_uli_cgi_lac, tvb, offset, 2, FALSE); proto_tree_add_item(tree, hf_gtpv2_uli_cgi_ci, tvb, offset, 2, FALSE); @@ -1162,7 +1162,7 @@ dissect_gtpv2_uli(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto /* 8.22.2 SAI field */ if (flags&0x02) { - dissect_e212_mcc_mnc(tvb, pinfo, tree, offset); + dissect_e212_mcc_mnc(tvb, pinfo, tree, offset, TRUE); offset+=3; proto_tree_add_item(tree, hf_gtpv2_uli_sai_lac, tvb, offset, 2, FALSE); proto_tree_add_item(tree, hf_gtpv2_uli_sai_sac, tvb, offset, 2, FALSE); @@ -1173,7 +1173,7 @@ dissect_gtpv2_uli(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto /* 8.22.3 RAI field */ if (flags&0x04) { - dissect_e212_mcc_mnc(tvb, pinfo, tree, offset); + dissect_e212_mcc_mnc(tvb, pinfo, tree, offset, TRUE); offset+=3; proto_tree_add_item(tree, hf_gtpv2_uli_rai_lac, tvb, offset, 2, FALSE); proto_tree_add_item(tree, hf_gtpv2_uli_rai_rac, tvb, offset, 2, FALSE); @@ -1184,7 +1184,7 @@ dissect_gtpv2_uli(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto /* 8.22.4 TAI field */ if (flags&0x08) { - dissect_e212_mcc_mnc(tvb, pinfo, tree, offset); + dissect_e212_mcc_mnc(tvb, pinfo, tree, offset, TRUE); offset+=3; proto_tree_add_item(tree, hf_gtpv2_uli_tai_tac, tvb, offset, 2, FALSE); offset+=2; @@ -1194,7 +1194,7 @@ dissect_gtpv2_uli(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto /* 8.22.5 ECGI field */ if (flags&0x10) { - dissect_e212_mcc_mnc(tvb, pinfo, tree, offset); + dissect_e212_mcc_mnc(tvb, pinfo, tree, offset, TRUE); offset+=3; /* The bits 8 through 5, of octet e+3 (Fig 8.21.5-1 in TS 29.274 V8.2.0) are spare and hence they would not make any difference to the hex string following it, thus we directly read 4 bytes from tvb */ diff --git a/epan/dissectors/packet-nas_eps.c b/epan/dissectors/packet-nas_eps.c index 1b8d77fec2..c320635107 100644 --- a/epan/dissectors/packet-nas_eps.c +++ b/epan/dissectors/packet-nas_eps.c @@ -886,7 +886,7 @@ de_emm_eps_mid(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, g case 6: /* GUTI */ curr_offset++; - curr_offset = dissect_e212_mcc_mnc(tvb, gpinfo, tree, curr_offset); + curr_offset = dissect_e212_mcc_mnc(tvb, gpinfo, tree, curr_offset, TRUE); /* MME Group ID octet 7 - 8 */ proto_tree_add_item(tree, hf_nas_eps_emm_mme_grp_id, tvb, curr_offset, 2, FALSE); curr_offset+=2; @@ -1277,7 +1277,7 @@ de_emm_trac_area_id(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _ curr_offset = offset; - curr_offset = dissect_e212_mcc_mnc(tvb, gpinfo, tree, curr_offset); + curr_offset = dissect_e212_mcc_mnc(tvb, gpinfo, tree, curr_offset, TRUE); proto_tree_add_item(tree, hf_nas_eps_emm_tai_tac, tvb, curr_offset, 2, FALSE); curr_offset+=2; @@ -1329,7 +1329,7 @@ de_emm_trac_area_id_lst(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint l * MNC digit 3 MCC digit 3 octet 3 * MNC digit 2 MNC digit 1 octet 4 */ - curr_offset = dissect_e212_mcc_mnc(tvb, gpinfo, tree, curr_offset); + curr_offset = dissect_e212_mcc_mnc(tvb, gpinfo, tree, curr_offset, TRUE); /* type of list = "000" */ /* TAC 1 octet 5 * TAC 1 (continued) octet 6 @@ -1352,7 +1352,7 @@ de_emm_trac_area_id_lst(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint l * MNC digit 3 MCC digit 3 octet 3 * MNC digit 2 MNC digit 1 octet 4 */ - curr_offset = dissect_e212_mcc_mnc(tvb, gpinfo, tree, curr_offset); + curr_offset = dissect_e212_mcc_mnc(tvb, gpinfo, tree, curr_offset, TRUE); proto_tree_add_item(tree, hf_nas_eps_emm_tai_tac, tvb, curr_offset, 2, FALSE); curr_offset+=2; break; @@ -1368,7 +1368,7 @@ de_emm_trac_area_id_lst(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint l * MNC digit 3 MCC digit 3 octet 3 * MNC digit 2 MNC digit 1 octet 4 */ - curr_offset = dissect_e212_mcc_mnc(tvb, gpinfo, tree, curr_offset); + curr_offset = dissect_e212_mcc_mnc(tvb, gpinfo, tree, curr_offset, TRUE); proto_tree_add_item(tree, hf_nas_eps_emm_tai_tac, tvb, curr_offset, 2, FALSE); curr_offset+=2; } diff --git a/epan/dissectors/packet-ranap.c b/epan/dissectors/packet-ranap.c index 277d6566c7..8ac761f4fc 100644 --- a/epan/dissectors/packet-ranap.c +++ b/epan/dissectors/packet-ranap.c @@ -2495,7 +2495,7 @@ dissect_ranap_PLMNidentity(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _ if (!parameter_tvb) return offset; - dissect_e212_mcc_mnc(parameter_tvb, actx->pinfo, tree, 0); + dissect_e212_mcc_mnc(parameter_tvb, actx->pinfo, tree, 0, FALSE); return offset; diff --git a/epan/dissectors/packet-s1ap.c b/epan/dissectors/packet-s1ap.c index 49cca2f0f7..56db342d3e 100644 --- a/epan/dissectors/packet-s1ap.c +++ b/epan/dissectors/packet-s1ap.c @@ -1587,7 +1587,7 @@ dissect_s1ap_PLMNidentity(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U if (!parameter_tvb) return offset; - dissect_e212_mcc_mnc(parameter_tvb, actx->pinfo, tree, 0); + dissect_e212_mcc_mnc(parameter_tvb, actx->pinfo, tree, 0, FALSE); return offset; diff --git a/epan/dissectors/packet-sabp.c b/epan/dissectors/packet-sabp.c index 2438654027..9d023ac13d 100644 --- a/epan/dissectors/packet-sabp.c +++ b/epan/dissectors/packet-sabp.c @@ -688,7 +688,7 @@ dissect_sabp_T_pLMNidentity(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx if (!parameter_tvb) return offset; subtree = proto_item_add_subtree(actx->created_item, ett_sabp_e212); - dissect_e212_mcc_mnc(parameter_tvb, actx->pinfo, subtree, 0); + dissect_e212_mcc_mnc(parameter_tvb, actx->pinfo, subtree, 0, FALSE); diff --git a/epan/dissectors/packet-uma.c b/epan/dissectors/packet-uma.c index a4f6e7be93..4c9e306e26 100644 --- a/epan/dissectors/packet-uma.c +++ b/epan/dissectors/packet-uma.c @@ -1358,7 +1358,7 @@ dissect_uma_IE(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset) octet = tvb_get_guint8(tvb,ie_offset); ie_offset++; if ( octet == 0 ){ - ie_offset = dissect_e212_mcc_mnc(tvb, pinfo, urr_ie_tree, ie_offset); + ie_offset = dissect_e212_mcc_mnc(tvb, pinfo, urr_ie_tree, ie_offset, TRUE); proto_tree_add_item(urr_ie_tree, hf_uma_urr_lac, tvb, ie_offset, 2, FALSE); ie_offset = ie_offset + 2; /* The octets 9-12 are coded as shown in 3GPP TS 25.331, Table 'Cell identity'. diff --git a/epan/dissectors/packet-x2ap.c b/epan/dissectors/packet-x2ap.c index 9a42b50dbd..bb856a5299 100644 --- a/epan/dissectors/packet-x2ap.c +++ b/epan/dissectors/packet-x2ap.c @@ -1007,7 +1007,7 @@ dissect_x2ap_PLMN_Identity(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _ if (!parameter_tvb) return offset; - dissect_e212_mcc_mnc(parameter_tvb, actx->pinfo, tree, 0); + dissect_e212_mcc_mnc(parameter_tvb, actx->pinfo, tree, 0, FALSE); return offset;