aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomas Kukosa <tomas.kukosa@siemens.com>2007-12-28 10:42:44 +0000
committerTomas Kukosa <tomas.kukosa@siemens.com>2007-12-28 10:42:44 +0000
commit7529f334379c34ca3b5e906b31879a8f5944a8de (patch)
tree3bb0fa787a1066c5bc2b5a3afc519403a65b014a
parentcec1f884e98d111ed384cf1ec395e44620ad4964 (diff)
support for additionally SIZE constrained Typereference
the support is only semiautomated as this feature does not occur very often use this feature for the TBCD-STRING in the H.225 dissector svn path=/trunk/; revision=23958
-rw-r--r--asn1/h225/h225.cnf15
-rw-r--r--epan/asn1.c16
-rw-r--r--epan/asn1.h4
-rw-r--r--epan/dissectors/packet-h225.c132
-rw-r--r--epan/dissectors/packet-h225.h2
-rw-r--r--epan/dissectors/packet-per.c38
-rw-r--r--epan/dissectors/packet-per.h3
-rwxr-xr-xtools/asn2wrs.py24
8 files changed, 186 insertions, 48 deletions
diff --git a/asn1/h225/h225.cnf b/asn1/h225/h225.cnf
index 510bd74b23..21b309cec3 100644
--- a/asn1/h225/h225.cnf
+++ b/asn1/h225/h225.cnf
@@ -697,6 +697,21 @@ H221NonStandard/manufacturerCode VAL_PTR = &manufacturerCode
#=== end of GEF =========================================================================
+# TBCD-STRING is additionally constrained
+# parameter stack is used for passing this constraint
+
+#.FN_HDR TBCD-STRING
+ int min_len, max_len;
+ gboolean has_extension;
+
+ get_size_constraint_from_stack(actx, "TBCD_STRING", &min_len, &max_len, &has_extension);
+#.FN_PARS TBCD-STRING
+MIN_VAL = min_len
+MAX_VAL = max_len
+EXT = has_extension
+#.END
+
+
#.TYPE_ATTR
H221NonStandard/t35CountryCode TYPE = FT_UINT32 DISPLAY = BASE_DEC STRINGS = VALS(T35CountryCode_vals)
TransportAddress/ipAddress/ip TYPE = FT_IPv4 DISPLAY = BASE_NONE STRINGS = NULL
diff --git a/epan/asn1.c b/epan/asn1.c
index 19038ae7e8..801e00aa54 100644
--- a/epan/asn1.c
+++ b/epan/asn1.c
@@ -125,6 +125,14 @@ static asn1_par_t *push_new_par(asn1_ctx_t *actx) {
return par;
}
+void asn1_param_push_boolean(asn1_ctx_t *actx, gboolean value) {
+ asn1_par_t *par;
+
+ par = push_new_par(actx);
+ par->ptype = ASN1_PAR_BOOLEAN;
+ par->value.v_boolean = value;
+}
+
void asn1_param_push_integer(asn1_ctx_t *actx, gint32 value) {
asn1_par_t *par;
@@ -133,6 +141,14 @@ void asn1_param_push_integer(asn1_ctx_t *actx, gint32 value) {
par->value.v_integer = value;
}
+gboolean asn1_param_get_boolean(asn1_ctx_t *actx, const gchar *name) {
+ asn1_par_t *par = NULL;
+
+ par = get_par_by_name(actx, name);
+ DISSECTOR_ASSERT(par);
+ return par->value.v_boolean;
+}
+
gint32 asn1_param_get_integer(asn1_ctx_t *actx, const gchar *name) {
asn1_par_t *par = NULL;
diff --git a/epan/asn1.h b/epan/asn1.h
index 0f792bd482..5d0c9e306c 100644
--- a/epan/asn1.h
+++ b/epan/asn1.h
@@ -43,6 +43,7 @@ typedef enum {
typedef enum {
ASN1_PAR_IRR, /* irrelevant parameter */
/* value */
+ ASN1_PAR_BOOLEAN,
ASN1_PAR_INTEGER,
/* type */
ASN1_PAR_TYPE
@@ -57,6 +58,7 @@ typedef struct _asn1_par_t {
const gchar *name;
asn1_par_type ptype;
union {
+ gboolean v_boolean;
gint32 v_integer;
void *v_type;
} value;
@@ -179,7 +181,9 @@ extern void asn1_stack_frame_push(asn1_ctx_t *actx, const gchar *name);
extern void asn1_stack_frame_pop(asn1_ctx_t *actx, const gchar *name);
extern void asn1_stack_frame_check(asn1_ctx_t *actx, const gchar *name, const asn1_par_def_t *par_def);
+extern void asn1_param_push_boolean(asn1_ctx_t *actx, gboolean value);
extern void asn1_param_push_integer(asn1_ctx_t *actx, gint32 value);
+extern gboolean asn1_param_get_boolean(asn1_ctx_t *actx, const gchar *name);
extern gint32 asn1_param_get_integer(asn1_ctx_t *actx, const gchar *name);
extern void rose_ctx_init(rose_ctx_t *rctx);
diff --git a/epan/dissectors/packet-h225.c b/epan/dissectors/packet-h225.c
index 556cec691f..96b2087c89 100644
--- a/epan/dissectors/packet-h225.c
+++ b/epan/dissectors/packet-h225.c
@@ -1,7 +1,7 @@
/* Do not modify this file. */
/* It is created automatically by the ASN.1 to Wireshark dissector compiler */
/* packet-h225.c */
-/* ../../tools/asn2wrs.py -e -p h225 -c ./h225.cnf -s ./packet-h225-template -D . H323-MESSAGES.asn */
+/* ../../tools/asn2wrs.py -e -p h225 -c h225.cnf -s packet-h225-template H323-MESSAGES.asn */
/* Input file: packet-h225-template.c */
@@ -406,24 +406,24 @@ static int hf_h225_pISNSpecificNumber = -1; /* NULL */
static int hf_h225_localNumber = -1; /* NULL */
static int hf_h225_ansi_41_uim = -1; /* ANSI_41_UIM */
static int hf_h225_gsm_uim = -1; /* GSM_UIM */
-static int hf_h225_imsi = -1; /* TBCD_STRING */
-static int hf_h225_min = -1; /* TBCD_STRING */
-static int hf_h225_mdn = -1; /* TBCD_STRING */
-static int hf_h225_msisdn = -1; /* TBCD_STRING */
-static int hf_h225_esn = -1; /* TBCD_STRING */
-static int hf_h225_mscid = -1; /* TBCD_STRING */
+static int hf_h225_imsi = -1; /* TBCD_STRING_SIZE_3_16 */
+static int hf_h225_min = -1; /* TBCD_STRING_SIZE_3_16 */
+static int hf_h225_mdn = -1; /* TBCD_STRING_SIZE_3_16 */
+static int hf_h225_msisdn = -1; /* TBCD_STRING_SIZE_3_16 */
+static int hf_h225_esn = -1; /* TBCD_STRING_SIZE_16 */
+static int hf_h225_mscid = -1; /* TBCD_STRING_SIZE_3_16 */
static int hf_h225_system_id = -1; /* T_system_id */
-static int hf_h225_sid = -1; /* TBCD_STRING */
-static int hf_h225_mid = -1; /* TBCD_STRING */
+static int hf_h225_sid = -1; /* TBCD_STRING_SIZE_1_4 */
+static int hf_h225_mid = -1; /* TBCD_STRING_SIZE_1_4 */
static int hf_h225_systemMyTypeCode = -1; /* OCTET_STRING_SIZE_1 */
static int hf_h225_systemAccessType = -1; /* OCTET_STRING_SIZE_1 */
static int hf_h225_qualificationInformationCode = -1; /* OCTET_STRING_SIZE_1 */
-static int hf_h225_sesn = -1; /* TBCD_STRING */
-static int hf_h225_soc = -1; /* TBCD_STRING */
+static int hf_h225_sesn = -1; /* TBCD_STRING_SIZE_16 */
+static int hf_h225_soc = -1; /* TBCD_STRING_SIZE_3_16 */
static int hf_h225_tmsi = -1; /* OCTET_STRING_SIZE_1_4 */
-static int hf_h225_imei = -1; /* TBCD_STRING */
-static int hf_h225_hplmn = -1; /* TBCD_STRING */
-static int hf_h225_vplmn = -1; /* TBCD_STRING */
+static int hf_h225_imei = -1; /* TBCD_STRING_SIZE_15_16 */
+static int hf_h225_hplmn = -1; /* TBCD_STRING_SIZE_1_4 */
+static int hf_h225_vplmn = -1; /* TBCD_STRING_SIZE_1_4 */
static int hf_h225_isupE164Number = -1; /* IsupPublicPartyNumber */
static int hf_h225_isupDataPartyNumber = -1; /* IsupDigits */
static int hf_h225_isupTelexPartyNumber = -1; /* IsupDigits */
@@ -1895,14 +1895,50 @@ dissect_h225_PartyNumber(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_
static int
dissect_h225_TBCD_STRING(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
+#line 704 "h225.cnf"
+ int min_len, max_len;
+ gboolean has_extension;
+
+ get_size_constraint_from_stack(actx, "TBCD_STRING", &min_len, &max_len, &has_extension);
+
offset = dissect_per_restricted_character_string(tvb, offset, actx, tree, hf_index,
- NO_BOUND, NO_BOUND, "0123456789#*abc", 15,
+ min_len, max_len, "0123456789#*abc", 15,
NULL);
return offset;
}
+
+static int
+dissect_h225_TBCD_STRING_SIZE_3_16(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
+ offset = dissect_per_size_constrained_type(tvb, offset, actx, tree, hf_index, dissect_h225_TBCD_STRING,
+ "TBCD_STRING", 3, 16, FALSE);
+
+ return offset;
+}
+
+
+
+static int
+dissect_h225_TBCD_STRING_SIZE_16(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
+ offset = dissect_per_size_constrained_type(tvb, offset, actx, tree, hf_index, dissect_h225_TBCD_STRING,
+ "TBCD_STRING", 16, 16, FALSE);
+
+ return offset;
+}
+
+
+
+static int
+dissect_h225_TBCD_STRING_SIZE_1_4(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
+ offset = dissect_per_size_constrained_type(tvb, offset, actx, tree, hf_index, dissect_h225_TBCD_STRING,
+ "TBCD_STRING", 1, 4, FALSE);
+
+ return offset;
+}
+
+
static const value_string h225_T_system_id_vals[] = {
{ 0, "sid" },
{ 1, "mid" },
@@ -1910,8 +1946,8 @@ static const value_string h225_T_system_id_vals[] = {
};
static const per_choice_t T_system_id_choice[] = {
- { 0, &hf_h225_sid , ASN1_EXTENSION_ROOT , dissect_h225_TBCD_STRING },
- { 1, &hf_h225_mid , ASN1_EXTENSION_ROOT , dissect_h225_TBCD_STRING },
+ { 0, &hf_h225_sid , ASN1_EXTENSION_ROOT , dissect_h225_TBCD_STRING_SIZE_1_4 },
+ { 1, &hf_h225_mid , ASN1_EXTENSION_ROOT , dissect_h225_TBCD_STRING_SIZE_1_4 },
{ 0, NULL, 0, NULL }
};
@@ -1936,18 +1972,18 @@ dissect_h225_OCTET_STRING_SIZE_1(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *
static const per_sequence_t ANSI_41_UIM_sequence[] = {
- { &hf_h225_imsi , ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_h225_TBCD_STRING },
- { &hf_h225_min , ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_h225_TBCD_STRING },
- { &hf_h225_mdn , ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_h225_TBCD_STRING },
- { &hf_h225_msisdn , ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_h225_TBCD_STRING },
- { &hf_h225_esn , ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_h225_TBCD_STRING },
- { &hf_h225_mscid , ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_h225_TBCD_STRING },
+ { &hf_h225_imsi , ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_h225_TBCD_STRING_SIZE_3_16 },
+ { &hf_h225_min , ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_h225_TBCD_STRING_SIZE_3_16 },
+ { &hf_h225_mdn , ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_h225_TBCD_STRING_SIZE_3_16 },
+ { &hf_h225_msisdn , ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_h225_TBCD_STRING_SIZE_3_16 },
+ { &hf_h225_esn , ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_h225_TBCD_STRING_SIZE_16 },
+ { &hf_h225_mscid , ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_h225_TBCD_STRING_SIZE_3_16 },
{ &hf_h225_system_id , ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_h225_T_system_id },
{ &hf_h225_systemMyTypeCode, ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_h225_OCTET_STRING_SIZE_1 },
{ &hf_h225_systemAccessType, ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_h225_OCTET_STRING_SIZE_1 },
{ &hf_h225_qualificationInformationCode, ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_h225_OCTET_STRING_SIZE_1 },
- { &hf_h225_sesn , ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_h225_TBCD_STRING },
- { &hf_h225_soc , ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_h225_TBCD_STRING },
+ { &hf_h225_sesn , ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_h225_TBCD_STRING_SIZE_16 },
+ { &hf_h225_soc , ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_h225_TBCD_STRING_SIZE_3_16 },
{ NULL, 0, 0, NULL }
};
@@ -1970,13 +2006,23 @@ dissect_h225_OCTET_STRING_SIZE_1_4(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t
}
+
+static int
+dissect_h225_TBCD_STRING_SIZE_15_16(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
+ offset = dissect_per_size_constrained_type(tvb, offset, actx, tree, hf_index, dissect_h225_TBCD_STRING,
+ "TBCD_STRING", 15, 16, FALSE);
+
+ return offset;
+}
+
+
static const per_sequence_t GSM_UIM_sequence[] = {
- { &hf_h225_imsi , ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_h225_TBCD_STRING },
+ { &hf_h225_imsi , ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_h225_TBCD_STRING_SIZE_3_16 },
{ &hf_h225_tmsi , ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_h225_OCTET_STRING_SIZE_1_4 },
- { &hf_h225_msisdn , ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_h225_TBCD_STRING },
- { &hf_h225_imei , ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_h225_TBCD_STRING },
- { &hf_h225_hplmn , ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_h225_TBCD_STRING },
- { &hf_h225_vplmn , ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_h225_TBCD_STRING },
+ { &hf_h225_msisdn , ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_h225_TBCD_STRING_SIZE_3_16 },
+ { &hf_h225_imei , ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_h225_TBCD_STRING_SIZE_15_16 },
+ { &hf_h225_hplmn , ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_h225_TBCD_STRING_SIZE_1_4 },
+ { &hf_h225_vplmn , ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_h225_TBCD_STRING_SIZE_1_4 },
{ NULL, 0, 0, NULL }
};
@@ -8688,27 +8734,27 @@ void proto_register_h225(void) {
{ &hf_h225_imsi,
{ "imsi", "h225.imsi",
FT_STRING, BASE_NONE, NULL, 0,
- "h225.TBCD_STRING", HFILL }},
+ "h225.TBCD_STRING_SIZE_3_16", HFILL }},
{ &hf_h225_min,
{ "min", "h225.min",
FT_STRING, BASE_NONE, NULL, 0,
- "h225.TBCD_STRING", HFILL }},
+ "h225.TBCD_STRING_SIZE_3_16", HFILL }},
{ &hf_h225_mdn,
{ "mdn", "h225.mdn",
FT_STRING, BASE_NONE, NULL, 0,
- "h225.TBCD_STRING", HFILL }},
+ "h225.TBCD_STRING_SIZE_3_16", HFILL }},
{ &hf_h225_msisdn,
{ "msisdn", "h225.msisdn",
FT_STRING, BASE_NONE, NULL, 0,
- "h225.TBCD_STRING", HFILL }},
+ "h225.TBCD_STRING_SIZE_3_16", HFILL }},
{ &hf_h225_esn,
{ "esn", "h225.esn",
FT_STRING, BASE_NONE, NULL, 0,
- "h225.TBCD_STRING", HFILL }},
+ "h225.TBCD_STRING_SIZE_16", HFILL }},
{ &hf_h225_mscid,
{ "mscid", "h225.mscid",
FT_STRING, BASE_NONE, NULL, 0,
- "h225.TBCD_STRING", HFILL }},
+ "h225.TBCD_STRING_SIZE_3_16", HFILL }},
{ &hf_h225_system_id,
{ "system-id", "h225.system_id",
FT_UINT32, BASE_DEC, VALS(h225_T_system_id_vals), 0,
@@ -8716,11 +8762,11 @@ void proto_register_h225(void) {
{ &hf_h225_sid,
{ "sid", "h225.sid",
FT_STRING, BASE_NONE, NULL, 0,
- "h225.TBCD_STRING", HFILL }},
+ "h225.TBCD_STRING_SIZE_1_4", HFILL }},
{ &hf_h225_mid,
{ "mid", "h225.mid",
FT_STRING, BASE_NONE, NULL, 0,
- "h225.TBCD_STRING", HFILL }},
+ "h225.TBCD_STRING_SIZE_1_4", HFILL }},
{ &hf_h225_systemMyTypeCode,
{ "systemMyTypeCode", "h225.systemMyTypeCode",
FT_BYTES, BASE_HEX, NULL, 0,
@@ -8736,11 +8782,11 @@ void proto_register_h225(void) {
{ &hf_h225_sesn,
{ "sesn", "h225.sesn",
FT_STRING, BASE_NONE, NULL, 0,
- "h225.TBCD_STRING", HFILL }},
+ "h225.TBCD_STRING_SIZE_16", HFILL }},
{ &hf_h225_soc,
{ "soc", "h225.soc",
FT_STRING, BASE_NONE, NULL, 0,
- "h225.TBCD_STRING", HFILL }},
+ "h225.TBCD_STRING_SIZE_3_16", HFILL }},
{ &hf_h225_tmsi,
{ "tmsi", "h225.tmsi",
FT_BYTES, BASE_HEX, NULL, 0,
@@ -8748,15 +8794,15 @@ void proto_register_h225(void) {
{ &hf_h225_imei,
{ "imei", "h225.imei",
FT_STRING, BASE_NONE, NULL, 0,
- "h225.TBCD_STRING", HFILL }},
+ "h225.TBCD_STRING_SIZE_15_16", HFILL }},
{ &hf_h225_hplmn,
{ "hplmn", "h225.hplmn",
FT_STRING, BASE_NONE, NULL, 0,
- "h225.TBCD_STRING", HFILL }},
+ "h225.TBCD_STRING_SIZE_1_4", HFILL }},
{ &hf_h225_vplmn,
{ "vplmn", "h225.vplmn",
FT_STRING, BASE_NONE, NULL, 0,
- "h225.TBCD_STRING", HFILL }},
+ "h225.TBCD_STRING_SIZE_1_4", HFILL }},
{ &hf_h225_isupE164Number,
{ "e164Number", "h225.e164Number",
FT_NONE, BASE_NONE, NULL, 0,
diff --git a/epan/dissectors/packet-h225.h b/epan/dissectors/packet-h225.h
index b9145b3d0e..8521fab2aa 100644
--- a/epan/dissectors/packet-h225.h
+++ b/epan/dissectors/packet-h225.h
@@ -1,7 +1,7 @@
/* Do not modify this file. */
/* It is created automatically by the ASN.1 to Wireshark dissector compiler */
/* packet-h225.h */
-/* ../../tools/asn2wrs.py -e -p h225 -c ./h225.cnf -s ./packet-h225-template -D . H323-MESSAGES.asn */
+/* ../../tools/asn2wrs.py -e -p h225 -c h225.cnf -s packet-h225-template H323-MESSAGES.asn */
/* Input file: packet-h225-template.h */
diff --git a/epan/dissectors/packet-per.c b/epan/dissectors/packet-per.c
index 33998810f4..f2a9a36ba0 100644
--- a/epan/dissectors/packet-per.c
+++ b/epan/dissectors/packet-per.c
@@ -1880,6 +1880,44 @@ guint32 dissect_per_octet_string_containing_pdu_new(tvbuff_t *tvb, guint32 offse
return offset;
}
+guint32 dissect_per_size_constrained_type(tvbuff_t *tvb, guint32 offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index, per_type_fn type_cb, const gchar *name, int min_len, int max_len, gboolean has_extension)
+{
+ asn1_stack_frame_push(actx, name);
+ asn1_param_push_integer(actx, min_len);
+ asn1_param_push_integer(actx, max_len);
+ asn1_param_push_boolean(actx, has_extension);
+
+ offset = type_cb(tvb, offset, actx, tree, hf_index);
+
+ asn1_stack_frame_pop(actx, name);
+
+ return offset;
+}
+
+gboolean get_size_constraint_from_stack(asn1_ctx_t *actx, const gchar *name, int *pmin_len, int *pmax_len, gboolean *phas_extension)
+{
+ asn1_par_t *par;
+
+ if (pmin_len) *pmin_len = NO_BOUND;
+ if (pmax_len) *pmax_len = NO_BOUND;
+ if (phas_extension) *phas_extension = FALSE;
+
+ if (!actx->stack) return FALSE;
+ if (strcmp(actx->stack->name, name)) return FALSE;
+
+ par = actx->stack->par;
+ if (!par || (par->ptype != ASN1_PAR_INTEGER)) return FALSE;
+ if (pmin_len) *pmin_len = par->value.v_integer;
+ par = par->next;
+ if (!par || (par->ptype != ASN1_PAR_INTEGER)) return FALSE;
+ if (pmax_len) *pmax_len = par->value.v_integer;
+ par = par->next;
+ if (!par || (par->ptype != ASN1_PAR_BOOLEAN)) return FALSE;
+ if (phas_extension) *phas_extension = par->value.v_boolean;
+
+ return TRUE;
+}
+
/* 26 Encoding of a value of the external type */
diff --git a/epan/dissectors/packet-per.h b/epan/dissectors/packet-per.h
index 68416b9b10..1b89e9eeac 100644
--- a/epan/dissectors/packet-per.h
+++ b/epan/dissectors/packet-per.h
@@ -124,4 +124,7 @@ extern guint32 dissect_per_open_type_pdu_new(tvbuff_t *tvb, guint32 offset, asn1
extern guint32 dissect_per_external_type(tvbuff_t *tvb, guint32 offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index, per_type_fn type_cb);
+extern guint32 dissect_per_size_constrained_type(tvbuff_t *tvb, guint32 offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index, per_type_fn type_cb, const gchar *name, int min_len, int max_len, gboolean has_extension);
+extern gboolean get_size_constraint_from_stack(asn1_ctx_t *actx, const gchar *name, int *pmin_len, int *pmax_len, gboolean *phas_extension);
+
#endif /* __PACKET_PER_H__ */
diff --git a/tools/asn2wrs.py b/tools/asn2wrs.py
index aa8fb2a2ea..f3f9a1bb2d 100755
--- a/tools/asn2wrs.py
+++ b/tools/asn2wrs.py
@@ -3011,7 +3011,7 @@ class Type (Node):
if not ident and ectx.conform.omit_assignment('T', nm, ectx.Module()): return # Assignment to omit
if not ident: # Assignment
ectx.eth_reg_assign(nm, self)
- if self.type == 'Type_Ref':
+ if self.type == 'Type_Ref' and not self.tr_need_own_fn(ectx):
ectx.eth_reg_type(nm, self)
virtual_tr = Type_Ref(val=ectx.conform.use_item('SET_TYPE', nm))
if (self.type == 'Type_Ref') or ectx.conform.check_item('SET_TYPE', nm):
@@ -3023,6 +3023,9 @@ class Type (Node):
trnm = nm
elif ectx.conform.check_item('SET_TYPE', nm):
trnm = ectx.conform.use_item('SET_TYPE', nm)
+ elif (self.type == 'Type_Ref') and self.tr_need_own_fn(ectx):
+ ectx.eth_reg_type(nm, self) # need own function, e.g. for constraints
+ trnm = nm
else:
trnm = self.val
else:
@@ -3484,7 +3487,13 @@ class Type_Ref (Type):
ectx.eth_dep_add(ident, self.val)
def eth_tname(self):
- return asn2c(self.val)
+ if self.HasSizeConstraint():
+ return asn2c(self.val) + '_' + self.constr.eth_constrname()
+ else:
+ return asn2c(self.val)
+
+ def tr_need_own_fn(self, ectx):
+ return ectx.Per() and self.HasSizeConstraint()
def fld_obj_repr(self, ectx):
return self.val
@@ -3526,6 +3535,8 @@ class Type_Ref (Type):
pars['TYPE_REF_PROTO'] = ectx.eth_type[t]['proto']
pars['TYPE_REF_TNAME'] = t
pars['TYPE_REF_FN'] = 'dissect_%(TYPE_REF_PROTO)s_%(TYPE_REF_TNAME)s'
+ if self.HasSizeConstraint():
+ (pars['MIN_VAL'], pars['MAX_VAL'], pars['EXT']) = self.eth_get_size_constr(ectx)
return pars
def eth_type_default_body(self, ectx, tname):
@@ -3533,8 +3544,13 @@ class Type_Ref (Type):
body = ectx.eth_fn_call('%(TYPE_REF_FN)s', ret='offset',
par=(('%(IMPLICIT_TAG)s', '%(TVB)s', '%(OFFSET)s', '%(ACTX)s', '%(TREE)s', '%(HF_INDEX)s'),))
elif (ectx.Per()):
- body = ectx.eth_fn_call('%(TYPE_REF_FN)s', ret='offset',
- par=(('%(TVB)s', '%(OFFSET)s', '%(ACTX)s', '%(TREE)s', '%(HF_INDEX)s'),))
+ if self.HasSizeConstraint():
+ body = ectx.eth_fn_call('dissect_%(ER)s_size_constrained_type', ret='offset',
+ par=(('%(TVB)s', '%(OFFSET)s', '%(ACTX)s', '%(TREE)s', '%(HF_INDEX)s', '%(TYPE_REF_FN)s',),
+ ('"%(TYPE_REF_TNAME)s"', '%(MIN_VAL)s', '%(MAX_VAL)s', '%(EXT)s',),))
+ else:
+ body = ectx.eth_fn_call('%(TYPE_REF_FN)s', ret='offset',
+ par=(('%(TVB)s', '%(OFFSET)s', '%(ACTX)s', '%(TREE)s', '%(HF_INDEX)s'),))
else:
body = '#error Can not decode %s' % (tname)
return body