From d6879b6c24cce79b2aed1b7b28e2c9ee2e90bff1 Mon Sep 17 00:00:00 2001 From: Martin Mathieson Date: Mon, 4 Feb 2019 14:04:14 +0000 Subject: For ASN.1-based protocols, make sure protocol filter will match. This is optional, and enabled by setting PROTO_ROOT_NAME to the name of the item in the OPT section of the .cnf file. For now, setting only in nr-rrc. Change-Id: Ibe96c7de982af0346af90bc0e095f20d1a7ac506 Reviewed-on: https://code.wireshark.org/review/31876 Petri-Dish: Martin Mathieson Tested-by: Petri Dish Buildbot Reviewed-by: Martin Mathieson --- epan/dissectors/asn1/nr-rrc/nr-rrc.cnf | 1 + epan/dissectors/packet-nr-rrc.c | 50 ++++++++++++++++++++++++++++++++++ tools/asn2wrs.py | 12 +++++++- 3 files changed, 62 insertions(+), 1 deletion(-) diff --git a/epan/dissectors/asn1/nr-rrc/nr-rrc.cnf b/epan/dissectors/asn1/nr-rrc/nr-rrc.cnf index e4fc230cb7..261b7155c2 100644 --- a/epan/dissectors/asn1/nr-rrc/nr-rrc.cnf +++ b/epan/dissectors/asn1/nr-rrc/nr-rrc.cnf @@ -5,6 +5,7 @@ #.OPT PER UNALIGNED +PROTO_ROOT_NAME proto_nr_rrc #.END #.USE_VALS_EXT diff --git a/epan/dissectors/packet-nr-rrc.c b/epan/dissectors/packet-nr-rrc.c index f56520730d..275bd380c4 100644 --- a/epan/dissectors/packet-nr-rrc.c +++ b/epan/dissectors/packet-nr-rrc.c @@ -4652,6 +4652,8 @@ static const per_sequence_t HandoverCommand_sequence[] = { static int dissect_nr_rrc_HandoverCommand(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { + proto_item *prot_ti = proto_tree_add_item(tree, proto_nr_rrc, tvb, 0, -1, ENC_NA); + PROTO_ITEM_SET_HIDDEN(prot_ti); offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, ett_nr_rrc_HandoverCommand, HandoverCommand_sequence); @@ -5587,6 +5589,8 @@ static const per_sequence_t ConfigRestrictInfoSCG_sequence[] = { static int dissect_nr_rrc_ConfigRestrictInfoSCG(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { + proto_item *prot_ti = proto_tree_add_item(tree, proto_nr_rrc, tvb, 0, -1, ENC_NA); + PROTO_ITEM_SET_HIDDEN(prot_ti); offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, ett_nr_rrc_ConfigRestrictInfoSCG, ConfigRestrictInfoSCG_sequence); @@ -5859,6 +5863,8 @@ static const per_sequence_t HandoverPreparationInformation_sequence[] = { static int dissect_nr_rrc_HandoverPreparationInformation(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { + proto_item *prot_ti = proto_tree_add_item(tree, proto_nr_rrc, tvb, 0, -1, ENC_NA); + PROTO_ITEM_SET_HIDDEN(prot_ti); offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, ett_nr_rrc_HandoverPreparationInformation, HandoverPreparationInformation_sequence); @@ -5894,6 +5900,8 @@ static const per_sequence_t BandCombinationInfoSN_sequence[] = { static int dissect_nr_rrc_BandCombinationInfoSN(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { + proto_item *prot_ti = proto_tree_add_item(tree, proto_nr_rrc, tvb, 0, -1, ENC_NA); + PROTO_ITEM_SET_HIDDEN(prot_ti); offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, ett_nr_rrc_BandCombinationInfoSN, BandCombinationInfoSN_sequence); @@ -7643,6 +7651,8 @@ static const per_sequence_t MeasurementTimingConfiguration_sequence[] = { static int dissect_nr_rrc_MeasurementTimingConfiguration(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { + proto_item *prot_ti = proto_tree_add_item(tree, proto_nr_rrc, tvb, 0, -1, ENC_NA); + PROTO_ITEM_SET_HIDDEN(prot_ti); offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, ett_nr_rrc_MeasurementTimingConfiguration, MeasurementTimingConfiguration_sequence); @@ -7768,6 +7778,8 @@ static const per_sequence_t UERadioPagingInformation_sequence[] = { static int dissect_nr_rrc_UERadioPagingInformation(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { + proto_item *prot_ti = proto_tree_add_item(tree, proto_nr_rrc, tvb, 0, -1, ENC_NA); + PROTO_ITEM_SET_HIDDEN(prot_ti); offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, ett_nr_rrc_UERadioPagingInformation, UERadioPagingInformation_sequence); @@ -7889,6 +7901,8 @@ static const per_sequence_t UERadioAccessCapabilityInformation_sequence[] = { static int dissect_nr_rrc_UERadioAccessCapabilityInformation(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { + proto_item *prot_ti = proto_tree_add_item(tree, proto_nr_rrc, tvb, 0, -1, ENC_NA); + PROTO_ITEM_SET_HIDDEN(prot_ti); offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, ett_nr_rrc_UERadioAccessCapabilityInformation, UERadioAccessCapabilityInformation_sequence); @@ -7994,6 +8008,8 @@ static const per_sequence_t MIB_sequence[] = { static int dissect_nr_rrc_MIB(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { + proto_item *prot_ti = proto_tree_add_item(tree, proto_nr_rrc, tvb, 0, -1, ENC_NA); + PROTO_ITEM_SET_HIDDEN(prot_ti); col_append_sep_str(actx->pinfo->cinfo, COL_INFO, NULL, "MIB"); offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, @@ -8591,6 +8607,8 @@ static const per_sequence_t SIB2_sequence[] = { static int dissect_nr_rrc_SIB2(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { + proto_item *prot_ti = proto_tree_add_item(tree, proto_nr_rrc, tvb, 0, -1, ENC_NA); + PROTO_ITEM_SET_HIDDEN(prot_ti); col_append_str(actx->pinfo->cinfo, COL_INFO, " SIB2"); offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, @@ -8720,6 +8738,8 @@ static const per_sequence_t SIB3_sequence[] = { static int dissect_nr_rrc_SIB3(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { + proto_item *prot_ti = proto_tree_add_item(tree, proto_nr_rrc, tvb, 0, -1, ENC_NA); + PROTO_ITEM_SET_HIDDEN(prot_ti); col_append_str(actx->pinfo->cinfo, COL_INFO, " SIB3"); offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, @@ -8849,6 +8869,8 @@ static const per_sequence_t SIB4_sequence[] = { static int dissect_nr_rrc_SIB4(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { + proto_item *prot_ti = proto_tree_add_item(tree, proto_nr_rrc, tvb, 0, -1, ENC_NA); + PROTO_ITEM_SET_HIDDEN(prot_ti); col_append_str(actx->pinfo->cinfo, COL_INFO, " SIB4"); offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, @@ -9208,6 +9230,8 @@ static const per_sequence_t SIB5_sequence[] = { static int dissect_nr_rrc_SIB5(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { + proto_item *prot_ti = proto_tree_add_item(tree, proto_nr_rrc, tvb, 0, -1, ENC_NA); + PROTO_ITEM_SET_HIDDEN(prot_ti); col_append_str(actx->pinfo->cinfo, COL_INFO, " SIB5"); offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, @@ -9286,6 +9310,8 @@ static const per_sequence_t SIB6_sequence[] = { static int dissect_nr_rrc_SIB6(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { + proto_item *prot_ti = proto_tree_add_item(tree, proto_nr_rrc, tvb, 0, -1, ENC_NA); + PROTO_ITEM_SET_HIDDEN(prot_ti); col_append_str(actx->pinfo->cinfo, COL_INFO, " SIB6"); offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, @@ -9441,6 +9467,8 @@ static const per_sequence_t SIB7_sequence[] = { static int dissect_nr_rrc_SIB7(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { + proto_item *prot_ti = proto_tree_add_item(tree, proto_nr_rrc, tvb, 0, -1, ENC_NA); + PROTO_ITEM_SET_HIDDEN(prot_ti); col_append_str(actx->pinfo->cinfo, COL_INFO, " SIB7"); offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, @@ -9597,6 +9625,8 @@ static const per_sequence_t SIB8_sequence[] = { static int dissect_nr_rrc_SIB8(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { + proto_item *prot_ti = proto_tree_add_item(tree, proto_nr_rrc, tvb, 0, -1, ENC_NA); + PROTO_ITEM_SET_HIDDEN(prot_ti); col_append_str(actx->pinfo->cinfo, COL_INFO, " SIB8"); offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, @@ -9691,6 +9721,8 @@ static const per_sequence_t SIB9_sequence[] = { static int dissect_nr_rrc_SIB9(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { + proto_item *prot_ti = proto_tree_add_item(tree, proto_nr_rrc, tvb, 0, -1, ENC_NA); + PROTO_ITEM_SET_HIDDEN(prot_ti); col_append_str(actx->pinfo->cinfo, COL_INFO, " SIB9"); offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, @@ -13279,6 +13311,8 @@ static const per_sequence_t SIB1_sequence[] = { static int dissect_nr_rrc_SIB1(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { + proto_item *prot_ti = proto_tree_add_item(tree, proto_nr_rrc, tvb, 0, -1, ENC_NA); + PROTO_ITEM_SET_HIDDEN(prot_ti); col_append_sep_str(actx->pinfo->cinfo, COL_INFO, NULL, "SIB1"); offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, @@ -14330,6 +14364,8 @@ static const per_sequence_t RadioBearerConfig_sequence[] = { static int dissect_nr_rrc_RadioBearerConfig(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { + proto_item *prot_ti = proto_tree_add_item(tree, proto_nr_rrc, tvb, 0, -1, ENC_NA); + PROTO_ITEM_SET_HIDDEN(prot_ti); offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, ett_nr_rrc_RadioBearerConfig, RadioBearerConfig_sequence); @@ -16341,6 +16377,8 @@ static const per_sequence_t MeasGapConfig_sequence[] = { static int dissect_nr_rrc_MeasGapConfig(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { + proto_item *prot_ti = proto_tree_add_item(tree, proto_nr_rrc, tvb, 0, -1, ENC_NA); + PROTO_ITEM_SET_HIDDEN(prot_ti); offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, ett_nr_rrc_MeasGapConfig, MeasGapConfig_sequence); @@ -16477,6 +16515,8 @@ static const per_sequence_t MeasConfig_sequence[] = { static int dissect_nr_rrc_MeasConfig(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { + proto_item *prot_ti = proto_tree_add_item(tree, proto_nr_rrc, tvb, 0, -1, ENC_NA); + PROTO_ITEM_SET_HIDDEN(prot_ti); offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, ett_nr_rrc_MeasConfig, MeasConfig_sequence); @@ -16867,6 +16907,8 @@ static const per_sequence_t RRCReconfiguration_sequence[] = { static int dissect_nr_rrc_RRCReconfiguration(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { + proto_item *prot_ti = proto_tree_add_item(tree, proto_nr_rrc, tvb, 0, -1, ENC_NA); + PROTO_ITEM_SET_HIDDEN(prot_ti); col_append_sep_str(actx->pinfo->cinfo, COL_INFO, NULL, "RRC Reconfiguration"); offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, @@ -19301,6 +19343,8 @@ static const per_sequence_t UplinkTxDirectCurrentList_sequence_of[1] = { static int dissect_nr_rrc_UplinkTxDirectCurrentList(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { + proto_item *prot_ti = proto_tree_add_item(tree, proto_nr_rrc, tvb, 0, -1, ENC_NA); + PROTO_ITEM_SET_HIDDEN(prot_ti); offset = dissect_per_constrained_sequence_of(tvb, offset, actx, tree, hf_index, ett_nr_rrc_UplinkTxDirectCurrentList, UplinkTxDirectCurrentList_sequence_of, 1, maxNrofServingCells, FALSE); @@ -19395,6 +19439,8 @@ static const per_sequence_t RRCReconfigurationComplete_sequence[] = { static int dissect_nr_rrc_RRCReconfigurationComplete(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { + proto_item *prot_ti = proto_tree_add_item(tree, proto_nr_rrc, tvb, 0, -1, ENC_NA); + PROTO_ITEM_SET_HIDDEN(prot_ti); col_append_sep_str(actx->pinfo->cinfo, COL_INFO, NULL, "RRC Reconfiguration Complete"); offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, @@ -32310,6 +32356,8 @@ static const per_sequence_t CellGroupConfig_sequence[] = { static int dissect_nr_rrc_CellGroupConfig(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { + proto_item *prot_ti = proto_tree_add_item(tree, proto_nr_rrc, tvb, 0, -1, ENC_NA); + PROTO_ITEM_SET_HIDDEN(prot_ti); offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, ett_nr_rrc_CellGroupConfig, CellGroupConfig_sequence); @@ -35786,6 +35834,8 @@ static const per_sequence_t FreqBandList_sequence_of[1] = { static int dissect_nr_rrc_FreqBandList(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { + proto_item *prot_ti = proto_tree_add_item(tree, proto_nr_rrc, tvb, 0, -1, ENC_NA); + PROTO_ITEM_SET_HIDDEN(prot_ti); offset = dissect_per_constrained_sequence_of(tvb, offset, actx, tree, hf_index, ett_nr_rrc_FreqBandList, FreqBandList_sequence_of, 1, maxBandsMRDC, FALSE); diff --git a/tools/asn2wrs.py b/tools/asn2wrs.py index b7f529e627..477ded4ae4 100755 --- a/tools/asn2wrs.py +++ b/tools/asn2wrs.py @@ -1510,6 +1510,11 @@ class EthCtx: #if self.conform.get_fn_presence(tname): # out += self.conform.get_fn_text(tname, 'FN_HDR') #el + if self.conform.check_item('PDU', tname) and self.conform.proto_root_name: + out += ' proto_item *prot_ti = proto_tree_add_item(tree, ' + self.conform.proto_root_name + ', tvb, 0, -1, ENC_NA);\n' + out += ' PROTO_ITEM_SET_HIDDEN(prot_ti);\n' + + if self.conform.get_fn_presence(self.eth_type[tname]['ref'][0]): out += self.conform.get_fn_text(self.eth_type[tname]['ref'][0], 'FN_HDR') return out @@ -2161,6 +2166,7 @@ class EthCnf: self.report = {} self.suppress_line = False self.include_path = [] + self.proto_root_name = None # Value name Default value Duplicity check Usage check self.tblcfg['EXPORTS'] = { 'val_nm' : 'flag', 'val_dflt' : 0, 'chk_dup' : True, 'chk_use' : True } self.tblcfg['MAKE_ENUM'] = { 'val_nm' : 'flag', 'val_dflt' : 0, 'chk_dup' : True, 'chk_use' : True } @@ -2744,7 +2750,7 @@ class EthCnf: self.report[name][-1]['text'] += line def set_opt(self, opt, par, fn, lineno): - #print "set_opt: %s, %s" % (opt, par) + #print("set_opt: %s, %s" % (opt, par)) if opt in ("-I",): par = self.check_par(par, 1, 1, fn, lineno) if not par: return @@ -2769,6 +2775,10 @@ class EthCnf: elif opt in ("-u", "UNALIGNED"): par = self.check_par(par, 0, 0, fn, lineno) self.ectx.aligned = False + elif opt in ("PROTO_ROOT_NAME"): + par = self.check_par(par, 1, 1, fn, lineno) + if not par: return + self.proto_root_name = par[0] elif opt in ("-d",): par = self.check_par(par, 1, 1, fn, lineno) if not par: return -- cgit v1.2.3