aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-catapult-dct2000.c
diff options
context:
space:
mode:
authorMartin Mathieson <martin.r.mathieson@googlemail.com>2018-02-22 12:02:10 +0000
committerMartin Mathieson <martin.r.mathieson@googlemail.com>2018-02-22 16:26:20 +0000
commit032cb4b79fdb207e18bf121140d7c7c66f9b5cf2 (patch)
tree551ee22aeb7850ae70b34a659b78b749f187a642 /epan/dissectors/packet-catapult-dct2000.c
parent01e8f509d7425dbc5fb4f467087a70b3e8f7f4ea (diff)
Catapult DCT2000: Update sscanf patterns, and avoid calling if possible
Change-Id: Iafb7d62ab4a0431a00eaa284d421ea38b568533f Reviewed-on: https://code.wireshark.org/review/25990 Petri-Dish: Martin Mathieson <martin.r.mathieson@googlemail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Martin Mathieson <martin.r.mathieson@googlemail.com>
Diffstat (limited to 'epan/dissectors/packet-catapult-dct2000.c')
-rw-r--r--epan/dissectors/packet-catapult-dct2000.c103
1 files changed, 52 insertions, 51 deletions
diff --git a/epan/dissectors/packet-catapult-dct2000.c b/epan/dissectors/packet-catapult-dct2000.c
index 61d537abcb..0327f0bfe2 100644
--- a/epan/dissectors/packet-catapult-dct2000.c
+++ b/epan/dissectors/packet-catapult-dct2000.c
@@ -2012,14 +2012,23 @@ static void check_for_oob_mac_lte_events(packet_info *pinfo, tvbuff_t *tvb, prot
struct mac_lte_info *p_mac_lte_info;
guint16 n;
- /* Look for strings matching expected formats */
- if (sscanf(string, ">> RACH Preamble Request[UE = %u] [RAPID = %u] [Attempt = %u]",
- &ueids[0], &rapid, &rach_attempt_number) == 3) {
+ /* Current strings of interest begin with ">> ", so if don't see, avoid sscanf() calls. */
+ if (strncmp(string, ">> ", 3) != 0) {
+ return;
+ }
+
+ /*********************************************/
+ /* Look for strings matching formats */
+
+ /* RACH Preamble request */
+ if (sscanf(string, ">> RACH Preamble Request [CarrierId=%u] [LTE UE = %u] [RAPID = %u] [Attempt = %u",
+ &temp, &ueids[0], &rapid, &rach_attempt_number) == 4) {
oob_event = ltemac_send_preamble;
}
- else
- if (sscanf(string, ">> Schedule Requests (%u) [UE=%u][RNTI=%u]",
- &number_of_ues, &ueids[0], &rntis[0]) == 3) {
+
+ /* Scheduling Requests */
+ else if (sscanf(string, ">> Schedule Requests (%u) [CarrierId=%u][UE=%u][RNTI=%u]",
+ &number_of_ues, &temp, &ueids[0], &rntis[0]) == 4) {
const char *current_position;
/* Newer, multi-UE format */
@@ -2051,60 +2060,52 @@ static void check_for_oob_mac_lte_events(packet_info *pinfo, tvbuff_t *tvb, prot
}
}
}
- else
- /* Support both old and new formats of SR failure */
- if ((sscanf(string, ">> INFO (inst %u) MAC: [UE = %u] SR failed (CRNTI=%u)",
- &temp, &ueids[0], &rntis[0]) == 3) ||
- (sscanf(string, ">> INFO MAC: SR failed for UE %u (CRNTI=%u",
- &ueids[0], &rntis[0]) == 2))
- {
+
+ /* SR failures */
+ else if (sscanf(string, ">> INFO (inst %u) MAC: [UE = %u] SR failed (CRNTI=%u)",
+ &temp, &ueids[0], &rntis[0]) == 3) {
oob_event = ltemac_sr_failure;
}
- else {
- /* No events found */
- return;
- }
- /* We have an event */
- /* Only need to set info once per session. */
- p_mac_lte_info = get_mac_lte_proto_data(pinfo);
- if (p_mac_lte_info == NULL) {
+ /* No events found */
+ else return;
- /* Allocate & zero struct */
- p_mac_lte_info = wmem_new0(wmem_file_scope(), mac_lte_info);
- /* This indicates to MAC dissector that it has an oob event */
- p_mac_lte_info->length = 0;
+ /********************************************/
+ /* We have an event. Allocate & zero struct */
+ p_mac_lte_info = wmem_new0(wmem_file_scope(), mac_lte_info);
- switch (oob_event) {
- case ltemac_send_preamble:
- p_mac_lte_info->ueid = ueids[0];
- p_mac_lte_info->rapid = rapid;
- p_mac_lte_info->rach_attempt_number = rach_attempt_number;
- p_mac_lte_info->direction = DIRECTION_UPLINK;
- break;
- case ltemac_send_sr:
- for (n=0; n < number_of_ues; n++) {
- p_mac_lte_info->oob_ueid[n] = ueids[n];
- p_mac_lte_info->oob_rnti[n] = rntis[n];
- }
- p_mac_lte_info->number_of_srs = number_of_ues;
- p_mac_lte_info->direction = DIRECTION_UPLINK;
- break;
- case ltemac_sr_failure:
- p_mac_lte_info->rnti = rntis[0];
- p_mac_lte_info->ueid = ueids[0];
- p_mac_lte_info->direction = DIRECTION_DOWNLINK;
- break;
- }
+ /* This indicates to MAC dissector that it has an oob event */
+ p_mac_lte_info->length = 0;
- p_mac_lte_info->radioType = FDD_RADIO; /* TODO: will be the same as rest of log... */
- p_mac_lte_info->oob_event = oob_event;
-
- /* Store info in packet */
- set_mac_lte_proto_data(pinfo, p_mac_lte_info);
+ switch (oob_event) {
+ case ltemac_send_preamble:
+ p_mac_lte_info->ueid = ueids[0];
+ p_mac_lte_info->rapid = rapid;
+ p_mac_lte_info->rach_attempt_number = rach_attempt_number;
+ p_mac_lte_info->direction = DIRECTION_UPLINK;
+ break;
+ case ltemac_send_sr:
+ for (n=0; n < number_of_ues; n++) {
+ p_mac_lte_info->oob_ueid[n] = ueids[n];
+ p_mac_lte_info->oob_rnti[n] = rntis[n];
+ }
+ p_mac_lte_info->number_of_srs = number_of_ues;
+ p_mac_lte_info->direction = DIRECTION_UPLINK;
+ break;
+ case ltemac_sr_failure:
+ p_mac_lte_info->rnti = rntis[0];
+ p_mac_lte_info->ueid = ueids[0];
+ p_mac_lte_info->direction = DIRECTION_DOWNLINK;
+ break;
}
+ p_mac_lte_info->radioType = FDD_RADIO; /* TODO: will be the same as rest of log... */
+ p_mac_lte_info->oob_event = oob_event;
+
+ /* Store info in packet */
+ set_mac_lte_proto_data(pinfo, p_mac_lte_info);
+
/* Call MAC dissector */
call_dissector_only(mac_lte_handle, tvb, pinfo, tree, NULL);
}