aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--asn1/h225/h225.asn2
-rw-r--r--asn1/h225/h225.cnf21
-rw-r--r--asn1/h245/h245.asn3
-rw-r--r--epan/dissectors/packet-h225.c69
-rw-r--r--epan/dissectors/packet-h235.c18
-rw-r--r--epan/dissectors/packet-h245.c37
-rw-r--r--epan/dissectors/packet-per.c35
-rw-r--r--epan/dissectors/packet-per.h2
-rwxr-xr-xtools/asn2eth.py203
9 files changed, 232 insertions, 158 deletions
diff --git a/asn1/h225/h225.asn b/asn1/h225/h225.asn
index 0b2145bf4d..bd94d76805 100644
--- a/asn1/h225/h225.asn
+++ b/asn1/h225/h225.asn
@@ -656,7 +656,7 @@ AliasAddress ::= CHOICE {
partyNumber PartyNumber,
mobileUIM MobileUIM
}
-DialedDigits ::= IA5String(SIZE (1..128)) -- (FROM ("0123456789#*,"))
+DialedDigits ::= IA5String(SIZE (1..128))(FROM ("0123456789#*,"))
AddressPattern ::= CHOICE {
wildcard AliasAddress,
range SEQUENCE {startOfRange PartyNumber,
diff --git a/asn1/h225/h225.cnf b/asn1/h225/h225.cnf
index 52caf33aba..091cb55417 100644
--- a/asn1/h225/h225.cnf
+++ b/asn1/h225/h225.cnf
@@ -206,20 +206,21 @@ CallIdentifier/guid guid
h225_pi->is_destinationInfo = TRUE;
#.END
#----------------------------------------------------------------------------------------
-# TODO asn2eth can't handle restriced string ?
+#.FN_PARS DialedDigits
+ VAL_PTR = &value_tvb
#.FN_BODY DialedDigits
+ tvbuff_t *value_tvb = NULL;
+ guint len = 0;
+
+%(DEFAULT_BODY)s
if (h225_pi->is_destinationInfo == TRUE) {
- offset = dissect_per_restricted_character_string(tvb, offset, pinfo, tree, hf_index, 1, 128, "#,*0123456789", 13, (char *)&h225_pi->dialedDigits , 64);
+ if (value_tvb) {
+ len = tvb_length(value_tvb);
+ tvb_memcpy(value_tvb, h225_pi->dialedDigits, 0, len);
+ }
+ h225_pi->dialedDigits[len] = '\0';
h225_pi->is_destinationInfo = FALSE;
}
- else
- offset = dissect_per_restricted_character_string(tvb, offset, pinfo, tree, hf_index, 1, 128, "#,*0123456789", 13, NULL, 0);
-#.END
-#----------------------------------------------------------------------------------------
-# TODO asn2eth can't handle restriced string ?
-#.FN_BODY NumberDigits
-
- offset=dissect_per_restricted_character_string(tvb, offset, pinfo, tree, hf_index, 1, 128, "#,*0123456789", 13, NULL, 0);
#.END
#----------------------------------------------------------------------------------------
#.FN_PARS H245TransportAddress/h245ipAddress/h245ipv4
diff --git a/asn1/h245/h245.asn b/asn1/h245/h245.asn
index 9c05f2dcca..dc3e9f7d0a 100644
--- a/asn1/h245/h245.asn
+++ b/asn1/h245/h245.asn
@@ -3032,11 +3032,10 @@ UserInputIndication ::= CHOICE {
encryptedIA5String NULL,
-- indicates encrypted general string
encryptedGeneralString NULL},
--- IA5String(SIZE (1) ^ FROM ("0123456789#*ABCD!")),
signal
SEQUENCE {signalType
- IA5String(SIZE (1) ),
+ IA5String(SIZE (1))(FROM ("0123456789#*ABCD!")),
-- holds dummy "!" if encryptedSignalType is being used
duration INTEGER(1..65535) OPTIONAL, -- milliseconds--
rtp Rtp OPTIONAL,
diff --git a/epan/dissectors/packet-h225.c b/epan/dissectors/packet-h225.c
index 734db25cb5..804028d459 100644
--- a/epan/dissectors/packet-h225.c
+++ b/epan/dissectors/packet-h225.c
@@ -2231,14 +2231,24 @@ static int dissect_h245Address(tvbuff_t *tvb, int offset, packet_info *pinfo, pr
}
+
static int
dissect_h225_DialedDigits(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
+ tvbuff_t *value_tvb = NULL;
+ guint len = 0;
+
+ offset = dissect_per_restricted_character_string(tvb, offset, pinfo, tree, hf_index,
+ 1, 128, "0123456789#*,", strlen("0123456789#*,"),
+ &value_tvb);
+
if (h225_pi->is_destinationInfo == TRUE) {
- offset = dissect_per_restricted_character_string(tvb, offset, pinfo, tree, hf_index, 1, 128, "#,*0123456789", 13, (char *)&h225_pi->dialedDigits , 64);
+ if (value_tvb) {
+ len = tvb_length(value_tvb);
+ tvb_memcpy(value_tvb, h225_pi->dialedDigits, 0, len);
+ }
+ h225_pi->dialedDigits[len] = '\0';
h225_pi->is_destinationInfo = FALSE;
}
- else
- offset = dissect_per_restricted_character_string(tvb, offset, pinfo, tree, hf_index, 1, 128, "#,*0123456789", 13, NULL, 0);
return offset;
}
@@ -2247,10 +2257,11 @@ static int dissect_dialedDigits(tvbuff_t *tvb, int offset, packet_info *pinfo, p
}
+
static int
dissect_h225_BMPString_SIZE_1_256(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
offset = dissect_per_BMPString(tvb, offset, pinfo, tree, hf_index,
- 1, 256);
+ 1, 256);
return offset;
}
@@ -2259,10 +2270,11 @@ static int dissect_h323_ID(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_
}
+
static int
dissect_h225_IA5String_SIZE_1_512(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
offset = dissect_per_IA5String(tvb, offset, pinfo, tree, hf_index,
- 1, 512);
+ 1, 512);
return offset;
}
@@ -2525,10 +2537,12 @@ static int dissect_publicTypeOfNumber(tvbuff_t *tvb, int offset, packet_info *pi
}
+
static int
dissect_h225_NumberDigits(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
-
- offset=dissect_per_restricted_character_string(tvb, offset, pinfo, tree, hf_index, 1, 128, "#,*0123456789", 13, NULL, 0);
+ offset = dissect_per_restricted_character_string(tvb, offset, pinfo, tree, hf_index,
+ 1, 128, "0123456789#*,", strlen("0123456789#*,"),
+ NULL);
return offset;
}
@@ -2661,11 +2675,12 @@ static int dissect_routeCalltoSCN_item(tvbuff_t *tvb, int offset, packet_info *p
}
+
static int
dissect_h225_TBCD_STRING(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
offset = dissect_per_restricted_character_string(tvb, offset, pinfo, tree, hf_index,
- -1, -1, "0123456789#*abc", strlen("0123456789#*abc"),
- NULL, 0);
+ -1, -1, "0123456789#*abc", strlen("0123456789#*abc"),
+ NULL);
return offset;
}
@@ -3719,10 +3734,11 @@ static int dissect_almostOutOfResources(tvbuff_t *tvb, int offset, packet_info *
}
+
static int
dissect_h225_BIT_STRING_SIZE_32(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
offset = dissect_per_bit_string(tvb, offset, pinfo, tree, hf_index,
- 32, 32);
+ 32, 32);
return offset;
}
@@ -3744,10 +3760,11 @@ static int dissect_tunnelledProtocolObjectID(tvbuff_t *tvb, int offset, packet_i
}
+
static int
dissect_h225_IA5String_SIZE_1_64(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
offset = dissect_per_IA5String(tvb, offset, pinfo, tree, hf_index,
- 1, 64);
+ 1, 64);
return offset;
}
@@ -4227,10 +4244,11 @@ static int dissect_cryptoEPPwdHash(tvbuff_t *tvb, int offset, packet_info *pinfo
}
+
static int
dissect_h225_GatekeeperIdentifier(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
offset = dissect_per_BMPString(tvb, offset, pinfo, tree, hf_index,
- 1, 128);
+ 1, 128);
return offset;
}
@@ -4359,10 +4377,11 @@ static int dissect_fastStart(tvbuff_t *tvb, int offset, packet_info *pinfo, prot
}
+
static int
dissect_h225_EndpointIdentifier(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
offset = dissect_per_BMPString(tvb, offset, pinfo, tree, hf_index,
- 1, 128);
+ 1, 128);
return offset;
}
@@ -4458,10 +4477,11 @@ static int dissect_connectionParameters(tvbuff_t *tvb, int offset, packet_info *
}
+
static int
dissect_h225_IA5String_SIZE_1_32(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
offset = dissect_per_IA5String(tvb, offset, pinfo, tree, hf_index,
- 1, 32);
+ 1, 32);
return offset;
}
@@ -4553,10 +4573,11 @@ static int dissect_number8(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_
}
+
static int
dissect_h225_IA5String_SIZE_0_512(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
offset = dissect_per_IA5String(tvb, offset, pinfo, tree, hf_index,
- 0, 512);
+ 0, 512);
return offset;
}
@@ -4578,10 +4599,11 @@ static int dissect_signal(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_t
}
+
static int
dissect_h225_BMPString_SIZE_1_512(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
offset = dissect_per_BMPString(tvb, offset, pinfo, tree, hf_index,
- 1, 512);
+ 1, 512);
return offset;
}
@@ -4784,10 +4806,11 @@ static int dissect_number32(tvbuff_t *tvb, int offset, packet_info *pinfo, proto
}
+
static int
dissect_h225_IA5String_SIZE_1_128(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
offset = dissect_per_IA5String(tvb, offset, pinfo, tree, hf_index,
- 1, 128);
+ 1, 128);
return offset;
}
@@ -5155,10 +5178,11 @@ static int dissect_messageNotUnderstood(tvbuff_t *tvb, int offset, packet_info *
}
+
static int
dissect_h225_IA5String(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
offset = dissect_per_IA5String(tvb, offset, pinfo, tree, hf_index,
- -1, -1);
+ -1, -1);
return offset;
}
@@ -5167,10 +5191,11 @@ static int dissect_text(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tre
}
+
static int
dissect_h225_BMPString(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
offset = dissect_per_BMPString(tvb, offset, pinfo, tree, hf_index,
- -1, -1);
+ -1, -1);
return offset;
}
@@ -6808,10 +6833,11 @@ static int dissect_integrity_item(tvbuff_t *tvb, int offset, packet_info *pinfo,
}
+
static int
dissect_h225_BIT_STRING(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
offset = dissect_per_bit_string(tvb, offset, pinfo, tree, hf_index,
- -1, -1);
+ -1, -1);
return offset;
}
@@ -7110,10 +7136,11 @@ static int dissect_callCreditCapability(tvbuff_t *tvb, int offset, packet_info *
}
+
static int
dissect_h225_PrintableString(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
offset = dissect_per_PrintableString(tvb, offset, pinfo, tree, hf_index,
- -1, -1);
+ -1, -1);
return offset;
}
diff --git a/epan/dissectors/packet-h235.c b/epan/dissectors/packet-h235.c
index 8b1e961484..e55e0e1e3d 100644
--- a/epan/dissectors/packet-h235.c
+++ b/epan/dissectors/packet-h235.c
@@ -206,10 +206,11 @@ static int dissect_random(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_t
}
+
static int
dissect_h235_Password(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
offset = dissect_per_BMPString(tvb, offset, pinfo, tree, hf_index,
- 1, 128);
+ 1, 128);
return offset;
}
@@ -218,10 +219,11 @@ static int dissect_password(tvbuff_t *tvb, int offset, packet_info *pinfo, proto
}
+
static int
dissect_h235_Identifier(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
offset = dissect_per_BMPString(tvb, offset, pinfo, tree, hf_index,
- 1, 128);
+ 1, 128);
return offset;
}
@@ -233,10 +235,11 @@ static int dissect_sendersID(tvbuff_t *tvb, int offset, packet_info *pinfo, prot
}
+
static int
dissect_h235_KeyMaterial(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
offset = dissect_per_bit_string(tvb, offset, pinfo, tree, hf_index,
- 1, 2048);
+ 1, 2048);
return offset;
}
@@ -322,10 +325,11 @@ static int dissect_nonStandard(tvbuff_t *tvb, int offset, packet_info *pinfo, pr
}
+
static int
dissect_h235_BIT_STRING_SIZE_0_2048(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
offset = dissect_per_bit_string(tvb, offset, pinfo, tree, hf_index,
- 0, 2048);
+ 0, 2048);
return offset;
}
@@ -359,10 +363,11 @@ static int dissect_dhkey(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tr
}
+
static int
dissect_h235_BIT_STRING_SIZE_0_511(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
offset = dissect_per_bit_string(tvb, offset, pinfo, tree, hf_index,
- 0, 511);
+ 0, 511);
return offset;
}
@@ -673,10 +678,11 @@ static int dissect_sharedSecret(tvbuff_t *tvb, int offset, packet_info *pinfo, p
}
+
static int
dissect_h235_BIT_STRING(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
offset = dissect_per_bit_string(tvb, offset, pinfo, tree, hf_index,
- -1, -1);
+ -1, -1);
return offset;
}
diff --git a/epan/dissectors/packet-h245.c b/epan/dissectors/packet-h245.c
index b541f4d431..411da62976 100644
--- a/epan/dissectors/packet-h245.c
+++ b/epan/dissectors/packet-h245.c
@@ -1555,7 +1555,7 @@ static int hf_h245_iv = -1; /* OCTET_STRING */
static int hf_h245_alphanumeric = -1; /* GeneralString */
static int hf_h245_userInputSupportIndication = -1; /* T_userInputSupportIndication */
static int hf_h245_signal = -1; /* T_signal */
-static int hf_h245_signalType = -1; /* IA5String_SIZE_1 */
+static int hf_h245_signalType = -1; /* T_signalType */
static int hf_h245_duration = -1; /* INTEGER_1_65535 */
static int hf_h245_rtp = -1; /* Rtp */
static int hf_h245_rtpPayloadIndication = -1; /* NULL */
@@ -3407,10 +3407,11 @@ static int dissect_availableBitRates(tvbuff_t *tvb, int offset, packet_info *pin
}
+
static int
dissect_h245_NumericString_SIZE_1_16(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
offset = dissect_per_NumericString(tvb, offset, pinfo, tree, hf_index,
- 1, 16);
+ 1, 16);
return offset;
}
@@ -5256,10 +5257,11 @@ static int dissect_conferenceIdentifier(tvbuff_t *tvb, int offset, packet_info *
}
+
static int
dissect_h245_IA5String_SIZE_1_64(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
offset = dissect_per_IA5String(tvb, offset, pinfo, tree, hf_index,
- 1, 64);
+ 1, 64);
return offset;
}
@@ -7739,6 +7741,7 @@ static int dissect_vbd(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree
}
+
static int
dissect_h245_GeneralString(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
offset = dissect_per_GeneralString(tvb, offset, pinfo, tree, hf_index);
@@ -10239,10 +10242,12 @@ static int dissect_distribution(tvbuff_t *tvb, int offset, packet_info *pinfo, p
}
+
static int
dissect_h245_T_e164Address(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
- offset = dissect_per_IA5String(tvb, offset, pinfo, tree, hf_index,
- -1, -1);
+ offset = dissect_per_restricted_character_string(tvb, offset, pinfo, tree, hf_index,
+ 1, 128, "0123456789#*,", strlen("0123456789#*,"),
+ NULL);
return offset;
}
@@ -10358,10 +10363,11 @@ static int dissect_certificateResponse(tvbuff_t *tvb, int offset, packet_info *p
}
+
static int
dissect_h245_BIT_STRING_SIZE_1_65535(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
offset = dissect_per_bit_string(tvb, offset, pinfo, tree, hf_index,
- 1, 65535);
+ 1, 65535);
return offset;
}
@@ -12207,10 +12213,11 @@ static int dissect_callInformationReq(tvbuff_t *tvb, int offset, packet_info *pi
}
+
static int
dissect_h245_NumericString_SIZE_0_40(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
offset = dissect_per_NumericString(tvb, offset, pinfo, tree, hf_index,
- 0, 40);
+ 0, 40);
return offset;
}
@@ -12219,10 +12226,11 @@ static int dissect_networkAddressNum(tvbuff_t *tvb, int offset, packet_info *pin
}
+
static int
dissect_h245_IA5String_SIZE_1_40(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
offset = dissect_per_IA5String(tvb, offset, pinfo, tree, hf_index,
- 1, 40);
+ 1, 40);
return offset;
}
@@ -13547,10 +13555,11 @@ static int dissect_maintenanceLoopReject(tvbuff_t *tvb, int offset, packet_info
}
+
static int
dissect_h245_BMPString_SIZE_1_128(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
offset = dissect_per_BMPString(tvb, offset, pinfo, tree, hf_index,
- 1, 128);
+ 1, 128);
return offset;
}
@@ -16174,15 +16183,17 @@ static int dissect_userInputSupportIndication(tvbuff_t *tvb, int offset, packet_
}
+
static int
-dissect_h245_IA5String_SIZE_1(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
- offset = dissect_per_IA5String(tvb, offset, pinfo, tree, hf_index,
- 1, 1);
+dissect_h245_T_signalType(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
+ offset = dissect_per_restricted_character_string(tvb, offset, pinfo, tree, hf_index,
+ 1, 1, "0123456789#*ABCD!", strlen("0123456789#*ABCD!"),
+ NULL);
return offset;
}
static int dissect_signalType(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree) {
- return dissect_h245_IA5String_SIZE_1(tvb, offset, pinfo, tree, hf_h245_signalType);
+ return dissect_h245_T_signalType(tvb, offset, pinfo, tree, hf_h245_signalType);
}
diff --git a/epan/dissectors/packet-per.c b/epan/dissectors/packet-per.c
index f5007ddc9a..7b2b4d4228 100644
--- a/epan/dissectors/packet-per.c
+++ b/epan/dissectors/packet-per.c
@@ -288,11 +288,11 @@ dissect_per_IA5String(tvbuff_t *tvb, guint32 offset, packet_info *pinfo, proto_t
/* XXX we dont do >64k length strings yet */
guint32
-dissect_per_restricted_character_string(tvbuff_t *tvb, guint32 offset, packet_info *pinfo, proto_tree *tree, int hf_index, int min_len, int max_len, const char *alphabet, int alphabet_length, char *info_str, guint32 info_str_len)
+dissect_per_restricted_character_string(tvbuff_t *tvb, guint32 offset, packet_info *pinfo, proto_tree *tree, int hf_index, int min_len, int max_len, const char *alphabet, int alphabet_length, tvbuff_t **value_tvb)
{
guint32 length;
gboolean byte_aligned;
- static char str[1024];
+ guchar *buf;
guint char_pos;
int bits_per_char;
guint32 old_offset;
@@ -301,8 +301,9 @@ DEBUG_ENTRY("dissect_per_restricted_character_string");
/* xx.x if the length is 0 bytes there will be no encoding */
if(max_len==0){
- if (info_str != NULL) {
- info_str[0] = '\0';
+ if (value_tvb) {
+ *value_tvb = tvb_new_real_data(NULL, 0, 0);
+ tvb_set_child_real_data_tvbuff(tvb, value_tvb);
}
return offset;
}
@@ -393,6 +394,7 @@ DEBUG_ENTRY("dissect_per_restricted_character_string");
}
+ buf = g_malloc(length+1);
old_offset=offset;
for(char_pos=0;char_pos<length;char_pos++){
guchar val;
@@ -408,41 +410,44 @@ DEBUG_ENTRY("dissect_per_restricted_character_string");
bitsperchar is 8
*/
if(bits_per_char==8){
- str[char_pos]=val;
+ buf[char_pos]=val;
} else {
if (val < alphabet_length){
- str[char_pos]=alphabet[val];
+ buf[char_pos]=alphabet[val];
} else {
- str[char_pos] = '?'; /* XXX - how to mark this? */
+ buf[char_pos] = '?'; /* XXX - how to mark this? */
}
}
}
- str[char_pos]=0;
- proto_tree_add_string(tree, hf_index, tvb, (old_offset>>3), (offset>>3)-(old_offset>>3), str);
- if (info_str != NULL && info_str_len > 0) {
- if (info_str_len<length) str[info_str_len-1] = '\0';
- strcpy(info_str, str);
+ buf[char_pos]=0;
+ proto_tree_add_string(tree, hf_index, tvb, (old_offset>>3), (offset>>3)-(old_offset>>3), buf);
+ if (value_tvb) {
+ *value_tvb = tvb_new_real_data(buf, length, length);
+ tvb_set_free_cb(value_tvb, g_free);
+ tvb_set_child_real_data_tvbuff(tvb, value_tvb);
+ } else {
+ g_free(buf);
}
return offset;
}
guint32
dissect_per_NumericString(tvbuff_t *tvb, guint32 offset, packet_info *pinfo, proto_tree *tree, int hf_index, int min_len, int max_len)
{
- offset=dissect_per_restricted_character_string(tvb, offset, pinfo, tree, hf_index, min_len, max_len, " 0123456789", 11, NULL, 0);
+ offset=dissect_per_restricted_character_string(tvb, offset, pinfo, tree, hf_index, min_len, max_len, " 0123456789", 11, NULL);
return offset;
}
guint32
dissect_per_PrintableString(tvbuff_t *tvb, guint32 offset, packet_info *pinfo, proto_tree *tree, int hf_index, int min_len, int max_len)
{
- offset=dissect_per_restricted_character_string(tvb, offset, pinfo, tree, hf_index, min_len, max_len, " '()+,-.*0123456789:=?ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 74, NULL, 0);
+ offset=dissect_per_restricted_character_string(tvb, offset, pinfo, tree, hf_index, min_len, max_len, " '()+,-.*0123456789:=?ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 74, NULL);
return offset;
}
guint32
dissect_per_VisibleString(tvbuff_t *tvb, guint32 offset, packet_info *pinfo, proto_tree *tree, int hf_index, int min_len, int max_len)
{
offset=dissect_per_restricted_character_string(tvb, offset, pinfo, tree, hf_index, min_len, max_len,
- " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~", 95, NULL, 0);
+ " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~", 95, NULL);
return offset;
}
guint32
diff --git a/epan/dissectors/packet-per.h b/epan/dissectors/packet-per.h
index 4993982489..30f54114fc 100644
--- a/epan/dissectors/packet-per.h
+++ b/epan/dissectors/packet-per.h
@@ -104,6 +104,6 @@ extern guint32 dissect_per_octet_string(tvbuff_t *tvb, guint32 offset, packet_in
extern guint32 dissect_per_bit_string(tvbuff_t *tvb, guint32 offset, packet_info *pinfo, proto_tree *tree, int hf_index, int min_len, int max_len);
-extern guint32 dissect_per_restricted_character_string(tvbuff_t *tvb, guint32 offset, packet_info *pinfo, proto_tree *tree, int hf_index, int min_len, int max_len, const char *alphabet, int alphabet_length, char *info_str, guint32 info_str_len);
+extern guint32 dissect_per_restricted_character_string(tvbuff_t *tvb, guint32 offset, packet_info *pinfo, proto_tree *tree, int hf_index, int min_len, int max_len, const char *alphabet, int alphabet_length, tvbuff_t **value_tvb);
#endif /* __PACKET_PER_H__ */
diff --git a/tools/asn2eth.py b/tools/asn2eth.py
index f3d77b5027..b204adc1a1 100755
--- a/tools/asn2eth.py
+++ b/tools/asn2eth.py
@@ -765,7 +765,7 @@ class EthCtx:
def eth_bits(self, tname, bits):
out = ""
out += "static const "
- out += "asn_namedbit %s_bits[] = {\n" % (tname)
+ out += "asn_namedbit %(TABLE)s[] = {\n"
for (val, id) in bits:
out += ' { %2d, &hf_%s_%s_%s, -1, -1, "%s", NULL },\n' % (val, self.eproto, tname, asn2c(id), id)
out += " { 0, NULL, 0, 0, NULL, NULL }\n};\n"
@@ -1746,24 +1746,16 @@ class Type (Node):
self.eth_reg_sub(nm, ectx)
def eth_get_size_constr(self):
- minv = '-1'
- maxv = '-1'
- ext = 'FALSE'
+ (minv, maxv, ext) = ('-1', '-1', 'FALSE')
if not self.HasConstraint():
- minv = '-1'
- maxv = '-1'
- ext = 'FALSE'
+ (minv, maxv, ext) = ('-1', '-1', 'FALSE')
elif self.constr.IsSize():
- if self.constr.subtype.type == 'SingleValue':
- minv = self.constr.subtype.subtype
- maxv = self.constr.subtype.subtype
- else:
- minv = self.constr.subtype.subtype[0]
- maxv = self.constr.subtype.subtype[1]
- if hasattr(self.constr.subtype, 'ext') and self.constr.subtype.ext:
- ext = 'TRUE'
- else:
- ext = 'FALSE'
+ (minv, maxv, ext) = self.constr.GetSize()
+ elif (self.constr.type == 'Intersection'):
+ if self.constr.subtype[0].IsSize():
+ (minv, maxv, ext) = self.constr.subtype[0].GetSize()
+ elif self.constr.subtype[1].IsSize():
+ (minv, maxv, ext) = self.constr.subtype[1].GetSize()
return (minv, maxv, ext)
def eth_type_vals(self, tname, ectx):
@@ -1840,6 +1832,23 @@ class Constraint (Node):
def IsSize(self):
return self.type == 'Size' and (self.subtype.type == 'SingleValue' or self.subtype.type == 'ValueRange')
+ def GetSize(self):
+ minv = '-1'
+ maxv = '-1'
+ ext = 'FALSE'
+ if self.IsSize():
+ if self.subtype.type == 'SingleValue':
+ minv = self.subtype.subtype
+ maxv = self.subtype.subtype
+ else:
+ minv = self.subtype.subtype[0]
+ maxv = self.subtype.subtype[1]
+ if hasattr(self.subtype, 'ext') and self.subtype.ext:
+ ext = 'TRUE'
+ else:
+ ext = 'FALSE'
+ return (minv, maxv, ext)
+
def IsPermAlph(self):
return self.type == 'From' and self.subtype.type == 'SingleValue'
@@ -2410,14 +2419,14 @@ class ChoiceType (Type):
def GetTTag(self, ectx):
lst = self.elt_list
- cls = '-1/*choice*/'
- if hasattr(self, 'ext_list'):
- lst.extend(self.ext_list)
- if (len(lst) > 0):
- cls = lst[0].GetTag(ectx)[0]
- for e in (lst):
- if (e.GetTag(ectx)[0] != cls):
- cls = '-1/*choice*/'
+ cls = 'BER_CLASS_ANY/*choice*/'
+ #if hasattr(self, 'ext_list'):
+ # lst.extend(self.ext_list)
+ #if (len(lst) > 0):
+ # cls = lst[0].GetTag(ectx)[0]
+ #for e in (lst):
+ # if (e.GetTag(ectx)[0] != cls):
+ # cls = '-1/*choice*/'
return (cls, '-1/*choice*/')
def IndetermTag(self, ectx):
@@ -2784,47 +2793,62 @@ class RestrictedCharacterStringType (CharacterStringType):
def GetTTag(self, ectx):
return ('BER_CLASS_UNI', 'BER_UNI_TAG_' + self.eth_tsname())
- def eth_type_fn(self, proto, tname, ectx):
- out = ectx.eth_type_fn_hdr(tname)
- (minv, maxv, ext) = self.eth_get_size_constr()
+ def HasPermAlph(self):
+ return (self.HasConstraint() and
+ (self.constr.IsPermAlph() or
+ (self.constr.type == 'Intersection' and (self.constr.subtype[0].IsPermAlph() or self.constr.subtype[1].IsPermAlph()))
+ )
+ )
+
+ def eth_type_default_pars(self, ectx, tname):
+ pars = Type.eth_type_default_pars(self, ectx, tname)
+ (pars['MIN_VAL'], pars['MAX_VAL'], pars['EXT']) = self.eth_get_size_constr()
+ (pars['STRING_TYPE'], pars['STRING_TAG']) = (self.eth_tsname(), self.GetTTag(ectx)[1])
+ (pars['ALPHABET'], pars['ALPHABET_LEN']) = ('NULL', '0')
+ if self.HasPermAlph():
+ if self.constr.IsPermAlph():
+ pars['ALPHABET'] = self.constr.subtype.subtype
+ elif self.constr.subtype[0].IsPermAlph():
+ pars['ALPHABET'] = self.constr.subtype[0].subtype.subtype
+ elif self.constr.subtype[1].IsPermAlph():
+ pars['ALPHABET'] = self.constr.subtype[1].subtype.subtype
+ pars['ALPHABET_LEN'] = 'strlen(%(ALPHABET)s)'
+ return pars
+
+ def eth_type_default_body(self, ectx, tname):
if (ectx.Ber()):
- body = ectx.eth_fn_call('dissect_ber_restricted_string', ret='offset',
- par=(('implicit_tag', self.GetTTag(ectx)[1]),
- ('pinfo', 'tree', 'tvb', 'offset', 'hf_index'),
- ('NULL',)))
- elif (ectx.Per() and self.HasConstraint() and self.constr.IsPermAlph()):
- alphabet = self.constr.subtype.subtype
- alphabet_length = 'strlen(%s)' % (alphabet)
+ body = ectx.eth_fn_call('dissect_%(ER)s_restricted_string', ret='offset',
+ par=(('%(IMPLICIT_TAG)s', '%(STRING_TAG)s'),
+ ('%(PINFO)s', '%(TREE)s', '%(TVB)s', '%(OFFSET)s', '%(HF_INDEX)s'),
+ ('%(VAL_PTR)s',),))
+ elif (ectx.Per() and self.HasPermAlph()):
if (ectx.OPer()):
- body = ectx.eth_fn_call('dissect_per_restricted_character_string', ret='offset',
- par=(('tvb', 'offset', 'pinfo', 'tree', 'hf_index'),
- (minv, maxv, alphabet, alphabet_length),
- ('NULL','0')))
+ body = ectx.eth_fn_call('dissect_%(ER)s_restricted_character_string', ret='offset',
+ par=(('%(TVB)s', '%(OFFSET)s', '%(PINFO)s', '%(TREE)s', '%(HF_INDEX)s'),
+ ('%(MIN_VAL)s', '%(MAX_VAL)s', '%(ALPHABET)s', '%(ALPHABET_LEN)s'),
+ ('%(VAL_PTR)s',),))
else:
body = '#error Can not decode %s' % (tname)
elif (ectx.NPer()):
- body = ectx.eth_fn_call('dissect_pern_' + self.eth_tsname(), ret='offset',
- par=(('tvb', 'offset', 'pinfo', 'tree'),
- ('hf_index', 'item', 'private_data'),
- (minv, maxv, ext),
- ('NULL', 'NULL')))
+ body = ectx.eth_fn_call('dissect_%(ER)s_%(STRING_TYPE)s', ret='offset',
+ par=(('%(TVB)s', '%(OFFSET)s', '%(PINFO)s', '%(TREE)s', '%(HF_INDEX)s', 'item', 'private_data'),
+ ('%(MIN_VAL)s', '%(MAX_VAL)s', '%(EXT)s',),
+ ('%(VAL_PTR)s',),))
elif (ectx.OPer()):
if (self.eth_tsname() == 'GeneralString'):
- body = ectx.eth_fn_call('dissect_per_' + self.eth_tsname(), ret='offset',
- par=(('tvb', 'offset', 'pinfo', 'tree', 'hf_index'),))
+ body = ectx.eth_fn_call('dissect_%(ER)s_%(STRING_TYPE)s', ret='offset',
+ par=(('%(TVB)s', '%(OFFSET)s', '%(PINFO)s', '%(TREE)s', '%(HF_INDEX)s'),))
elif (self.eth_tsname() == 'GeneralizedTime'):
- body = ectx.eth_fn_call('dissect_per_' + 'VisibleString', ret='offset',
- par=(('tvb', 'offset', 'pinfo', 'tree', 'hf_index'),
- (minv, maxv)))
+ body = ectx.eth_fn_call('dissect_%(ER)s_VisibleString', ret='offset',
+ par=(('%(TVB)s', '%(OFFSET)s', '%(PINFO)s', '%(TREE)s', '%(HF_INDEX)s'),
+ ('%(MIN_VAL)s', '%(MAX_VAL)s',),))
else:
- body = ectx.eth_fn_call('dissect_per_' + self.eth_tsname(), ret='offset',
- par=(('tvb', 'offset', 'pinfo', 'tree', 'hf_index'),
- (minv, maxv)))
+ body = ectx.eth_fn_call('dissect_%(ER)s_%(STRING_TYPE)s', ret='offset',
+ par=(('%(TVB)s', '%(OFFSET)s', '%(PINFO)s', '%(TREE)s', '%(HF_INDEX)s'),
+ ('%(MIN_VAL)s', '%(MAX_VAL)s',),))
else:
body = '#error Can not decode %s' % (tname)
- out += ectx.eth_type_fn_body(tname, body)
- out += ectx.eth_type_fn_ftr(tname)
- return out
+ return body
class BMPStringType (RestrictedCharacterStringType):
def eth_tsname(self):
@@ -2893,16 +2917,13 @@ class GeneralizedTime (RestrictedCharacterStringType):
def eth_tsname(self):
return 'GeneralizedTime'
- def eth_type_fn(self, proto, tname, ectx):
+ def eth_type_default_body(self, ectx, tname):
if (ectx.Ber()):
- out = ectx.eth_type_fn_hdr(tname)
- body = ectx.eth_fn_call('dissect_ber_GeneralizedTime', ret='offset',
- par=(('implicit_tag', 'pinfo', 'tree', 'tvb', 'offset', 'hf_index'),))
- out += ectx.eth_type_fn_body(tname, body)
- out += ectx.eth_type_fn_ftr(tname)
- return out
+ body = ectx.eth_fn_call('dissect_%(ER)s_%(STRING_TYPE)s', ret='offset',
+ par=(('%(IMPLICIT_TAG)s', '%(PINFO)s', '%(TREE)s', '%(TVB)s', '%(OFFSET)s', '%(HF_INDEX)s'),))
+ return body
else:
- return RestrictedCharacterStringType.eth_type_fn(self, proto, tname, ectx)
+ return RestrictedCharacterStringType.eth_type_default_body(self, ectx, tname)
class UTCTime (RestrictedCharacterStringType):
def eth_tsname(self):
@@ -3124,38 +3145,42 @@ class BitStringType (Type):
bits.append((int(e.val), e.ident))
return bits
- def eth_type_fn(self, proto, tname, ectx):
- out = ''
+ def eth_type_default_pars(self, ectx, tname):
+ pars = Type.eth_type_default_pars(self, ectx, tname)
+ (pars['MIN_VAL'], pars['MAX_VAL'], pars['EXT']) = self.eth_get_size_constr()
+ if not pars.has_key('ETT_INDEX'):
+ pars['ETT_INDEX'] = '-1'
+ pars['TABLE'] = 'NULL'
+ if self.eth_named_bits():
+ pars['TABLE'] = '%(TNAME)s_bits'
+ return pars
+
+ def eth_type_default_table(self, ectx, tname):
+ #print "eth_type_default_table(tname='%s')" % (tname)
+ table = ''
bits = self.eth_named_bits()
- bitsp = 'NULL'
if (bits):
- out += ectx.eth_bits(tname, bits)
- bitsp = tname + '_bits'
- out += ectx.eth_type_fn_hdr(tname)
- (minv, maxv, ext) = self.eth_get_size_constr()
- tree = '-1'
- if (ectx.eth_type[tname]['tree']):
- tree = ectx.eth_type[tname]['tree']
- if (ectx.OBer()):
- body = ectx.eth_fn_call('dissect_ber_bitstring', ret='offset',
- par=(('implicit_tag', 'pinfo', 'tree', 'tvb', 'offset'),
- (bitsp, 'hf_index', tree),
- ('NULL',)))
+ table = ectx.eth_bits(tname, bits)
+ return table
+
+ def eth_type_default_body(self, ectx, tname):
+ if (ectx.Ber()):
+ body = ectx.eth_fn_call('dissect_%(ER)s_bitstring', ret='offset',
+ par=(('%(IMPLICIT_TAG)s', '%(PINFO)s', '%(TREE)s', '%(TVB)s', '%(OFFSET)s'),
+ ('%(TABLE)s', '%(HF_INDEX)s', '%(ETT_INDEX)s',),
+ ('%(VAL_PTR)s',),))
elif (ectx.NPer()):
- body = ectx.eth_fn_call('dissect_pern_bit_string', ret='offset',
- par=(('tvb', 'offset', 'pinfo', 'tree'),
- ('hf_index', 'item', 'private_data'),
- (minv, maxv, ext),
- ('NULL', 'NULL')))
+ body = ectx.eth_fn_call('dissect_%(ER)s_bit_string', ret='offset',
+ par=(('%(TVB)s', '%(OFFSET)s', '%(PINFO)s', '%(TREE)s', '%(HF_INDEX)s', 'item', 'private_data'),
+ ('%(ETT_INDEX)s', '%(TABLE)s',),
+ ('%(MIN_VAL)s', '%(MAX_VAL)s', '%(EXT)s',),))
elif (ectx.OPer()):
- body = ectx.eth_fn_call('dissect_per_bit_string', ret='offset',
- par=(('tvb', 'offset', 'pinfo', 'tree', 'hf_index'),
- (minv, maxv)))
+ body = ectx.eth_fn_call('dissect_%(ER)s_bit_string', ret='offset',
+ par=(('%(TVB)s', '%(OFFSET)s', '%(PINFO)s', '%(TREE)s', '%(HF_INDEX)s'),
+ ('%(MIN_VAL)s', '%(MAX_VAL)s',),))
else:
body = '#error Can not decode %s' % (tname)
- out += ectx.eth_type_fn_body(tname, body)
- out += ectx.eth_type_fn_ftr(tname)
- return out
+ return body
#==============================================================================