aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-catapult-dct2000.c
diff options
context:
space:
mode:
authorMartin Mathieson <martin.r.mathieson@googlemail.com>2018-01-26 23:14:45 +0000
committerAnders Broman <a.broman58@gmail.com>2018-01-27 23:12:08 +0000
commitbaca10e725d312d067c45b5394d32f32a4f11ac6 (patch)
tree524add84be466766a8bfb25d5197023a07608fa1 /epan/dissectors/packet-catapult-dct2000.c
parent9972110f319c1525412cbc7e06783d6dd19dbd56 (diff)
DCT2000: after profiling, speed up some parts
Change-Id: Ia335aaca3368608fe495c887d846fe3f057b74dd Reviewed-on: https://code.wireshark.org/review/25486 Petri-Dish: Martin Mathieson <martin.r.mathieson@googlemail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-catapult-dct2000.c')
-rw-r--r--epan/dissectors/packet-catapult-dct2000.c43
1 files changed, 31 insertions, 12 deletions
diff --git a/epan/dissectors/packet-catapult-dct2000.c b/epan/dissectors/packet-catapult-dct2000.c
index 914daea796..d27a515ded 100644
--- a/epan/dissectors/packet-catapult-dct2000.c
+++ b/epan/dissectors/packet-catapult-dct2000.c
@@ -1327,16 +1327,13 @@ static dissector_handle_t look_for_dissector(const char *protocol_name)
return find_dissector("http");
}
else
- if ((strcmp(protocol_name, "fp") == 0) ||
- (strncmp(protocol_name, "fp_r", 4) == 0) ||
+ if ((strncmp(protocol_name, "fp_r", 4) == 0) ||
(strcmp(protocol_name, "fpiur_r5") == 0)) {
return find_dissector("fp");
}
else
- if ((strcmp(protocol_name, "iuup_rtp_r5") == 0) ||
- (strcmp(protocol_name, "iuup_rtp_r6") == 0)) {
-
+ if (strncmp(protocol_name, "iuup_rtp_r", strlen("iuup_rtp_r")) == 0) {
return find_dissector("rtp");
}
else
@@ -1381,7 +1378,6 @@ static dissector_handle_t look_for_dissector(const char *protocol_name)
return find_dissector("x2ap");
}
-
else
if ((strcmp(protocol_name, "gtpv2_r8_lte") == 0) ||
(strcmp(protocol_name, "gtpv2_r9_lte") == 0)) {
@@ -2181,11 +2177,32 @@ dissect_catapult_dct2000(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, vo
/* Timestamp in file */
timestamp_string = tvb_get_const_stringz(tvb, offset, &timestamp_length);
if (dct2000_tree) {
- /* TODO: this is *very* slow, but float version adds trailing digits when
- displayed as a custom column... */
+ /* g_ascii_strtod(timestamp_string, NULL)) is much simpler, but *very* slow..
+ There will be seconds, a dot, and 4 decimal places.
+ N.B. timestamp_length also includes following NULL character */
+ if (timestamp_length < 7) {
+ /* Can't properly parse, but leave showing how far we got */
+ return offset;
+ }
+
+ /* Seconds. */
+ int seconds = 0;
+ int multiplier = 1;
+ for (int d=timestamp_length-7; d >= 0; d--) {
+ seconds += ((timestamp_string[d]-'0') * multiplier);
+ multiplier *= 10;
+ }
+
+ /* Subseconds (4 digits). */
+ int subseconds = 0;
+ subseconds += (timestamp_string[timestamp_length-2]-'0');
+ subseconds += (timestamp_string[timestamp_length-3]-'0')*10;
+ subseconds += (timestamp_string[timestamp_length-4]-'0')*100;
+ subseconds += (timestamp_string[timestamp_length-5]-'0')*1000;
+
proto_tree_add_double(dct2000_tree, hf_catapult_dct2000_timestamp, tvb,
offset, timestamp_length,
- g_ascii_strtod(timestamp_string, NULL));
+ seconds+(subseconds/10000.0));
}
offset += timestamp_length;
@@ -2845,9 +2862,11 @@ dissect_catapult_dct2000(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, vo
/* Last chance: is there a (private) registered protocol of the form
"dct2000.protocol" ? */
if (protocol_handle == 0) {
- /* TODO: only look inside preference? */
- char dotted_protocol_name[64+128];
- g_snprintf(dotted_protocol_name, 64+128, "dct2000.%s", protocol_name);
+ /* TODO: only look inside if a preference enabled? */
+ char dotted_protocol_name[128];
+ /* N.B. avoiding g_snprintf(), which was slow */
+ g_strlcpy(dotted_protocol_name, "dct2000.", 128);
+ g_strlcpy(dotted_protocol_name+8, protocol_name, 128-8);
protocol_handle = find_dissector(dotted_protocol_name);
}