forked from osmocom/wireshark
megaco: use ws_strtoi function.
Change-Id: I8e4807e29524976898f2656f2c6f06d890748f36 Reviewed-on: https://code.wireshark.org/review/18148 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
parent
ebede2a7c5
commit
5d5f58fb78
|
@ -51,6 +51,7 @@
|
||||||
#include <epan/exported_pdu.h>
|
#include <epan/exported_pdu.h>
|
||||||
#include <epan/asn1.h>
|
#include <epan/asn1.h>
|
||||||
#include <epan/sctpppids.h>
|
#include <epan/sctpppids.h>
|
||||||
|
#include <wsutil/strtoi.h>
|
||||||
#include "packet-ber.h"
|
#include "packet-ber.h"
|
||||||
#include "packet-tpkt.h"
|
#include "packet-tpkt.h"
|
||||||
#include "packet-h245.h"
|
#include "packet-h245.h"
|
||||||
|
@ -163,6 +164,8 @@ static expert_field ei_megaco_error_descriptor_transaction_list = EI_INIT;
|
||||||
static expert_field ei_megaco_parse_error = EI_INIT;
|
static expert_field ei_megaco_parse_error = EI_INIT;
|
||||||
static expert_field ei_megaco_audit_descriptor = EI_INIT;
|
static expert_field ei_megaco_audit_descriptor = EI_INIT;
|
||||||
static expert_field ei_megaco_signal_descriptor = EI_INIT;
|
static expert_field ei_megaco_signal_descriptor = EI_INIT;
|
||||||
|
static expert_field ei_megaco_reason_invalid = EI_INIT;
|
||||||
|
static expert_field ei_megaco_error_code_invalid = EI_INIT;
|
||||||
|
|
||||||
static dissector_handle_t megaco_text_handle;
|
static dissector_handle_t megaco_text_handle;
|
||||||
|
|
||||||
|
@ -444,7 +447,7 @@ dissect_megaco_digitmapdescriptor(tvbuff_t *tvb, proto_tree *tree, gint tvb_RBRK
|
||||||
static void
|
static void
|
||||||
dissect_megaco_topologydescriptor(tvbuff_t *tvb, proto_tree *tree, gint tvb_RBRKT, gint tvb_previous_offset);
|
dissect_megaco_topologydescriptor(tvbuff_t *tvb, proto_tree *tree, gint tvb_RBRKT, gint tvb_previous_offset);
|
||||||
static void
|
static void
|
||||||
dissect_megaco_errordescriptor(tvbuff_t *tvb, proto_tree *tree, gint tvb_RBRKT, gint tvb_previous_offset);
|
dissect_megaco_errordescriptor(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree, gint tvb_RBRKT, gint tvb_previous_offset);
|
||||||
static void
|
static void
|
||||||
dissect_megaco_TerminationStatedescriptor(tvbuff_t *tvb, proto_tree *tree, gint tvb_next_offset, gint tvb_current_offset);
|
dissect_megaco_TerminationStatedescriptor(tvbuff_t *tvb, proto_tree *tree, gint tvb_next_offset, gint tvb_current_offset);
|
||||||
static void
|
static void
|
||||||
|
@ -819,7 +822,7 @@ dissect_megaco_text(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* d
|
||||||
"Error" );
|
"Error" );
|
||||||
|
|
||||||
tvb_command_start_offset = tvb_previous_offset;
|
tvb_command_start_offset = tvb_previous_offset;
|
||||||
dissect_megaco_errordescriptor(tvb, megaco_tree, tvb_len-1, tvb_command_start_offset);
|
dissect_megaco_errordescriptor(tvb, pinfo, megaco_tree, tvb_len-1, tvb_command_start_offset);
|
||||||
}
|
}
|
||||||
return tvb_captured_length(tvb);
|
return tvb_captured_length(tvb);
|
||||||
/* transactionResponseAck
|
/* transactionResponseAck
|
||||||
|
@ -897,7 +900,7 @@ dissect_megaco_text(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* d
|
||||||
tvb_offset = megaco_tvb_skip_wsp(tvb, tvb_LBRKT+1);
|
tvb_offset = megaco_tvb_skip_wsp(tvb, tvb_LBRKT+1);
|
||||||
tempchar = tvb_get_guint8(tvb,tvb_offset);
|
tempchar = tvb_get_guint8(tvb,tvb_offset);
|
||||||
if ((tempchar == 'E')||(tempchar == 'e')){
|
if ((tempchar == 'E')||(tempchar == 'e')){
|
||||||
dissect_megaco_errordescriptor(tvb, megaco_tree, tvb_transaction_end_offset-1, tvb_offset);
|
dissect_megaco_errordescriptor(tvb, pinfo, megaco_tree, tvb_transaction_end_offset-1, tvb_offset);
|
||||||
return tvb_captured_length(tvb);
|
return tvb_captured_length(tvb);
|
||||||
}
|
}
|
||||||
/* Offset should be at first printable char after { */
|
/* Offset should be at first printable char after { */
|
||||||
|
@ -2390,7 +2393,8 @@ static const value_string MEGACO_ServiceChangeReasons_vals[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dissect_megaco_servicechangedescriptor(tvbuff_t *tvb, proto_tree *megaco_tree, gint tvb_RBRKT, gint tvb_previous_offset)
|
dissect_megaco_servicechangedescriptor(tvbuff_t *tvb, packet_info* pinfo, proto_tree *megaco_tree, gint tvb_RBRKT,
|
||||||
|
gint tvb_previous_offset)
|
||||||
{
|
{
|
||||||
|
|
||||||
gint tokenlen, tvb_LBRKT, tvb_offset;
|
gint tokenlen, tvb_LBRKT, tvb_offset;
|
||||||
|
@ -2399,6 +2403,7 @@ dissect_megaco_servicechangedescriptor(tvbuff_t *tvb, proto_tree *megaco_tree,
|
||||||
gboolean more_params = TRUE;
|
gboolean more_params = TRUE;
|
||||||
proto_item* item;
|
proto_item* item;
|
||||||
gint reason;
|
gint reason;
|
||||||
|
gboolean reason_valid;
|
||||||
guint8 ServiceChangeReason_str[4];
|
guint8 ServiceChangeReason_str[4];
|
||||||
|
|
||||||
tvb_LBRKT = tvb_find_guint8(tvb, tvb_previous_offset, tvb_RBRKT, '{');
|
tvb_LBRKT = tvb_find_guint8(tvb, tvb_previous_offset, tvb_RBRKT, '{');
|
||||||
|
@ -2446,9 +2451,10 @@ dissect_megaco_servicechangedescriptor(tvbuff_t *tvb, proto_tree *megaco_tree,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
tvb_get_nstringz0(tvb,tvb_current_offset,4,ServiceChangeReason_str);
|
tvb_get_nstringz0(tvb,tvb_current_offset,4,ServiceChangeReason_str);
|
||||||
reason = atoi(ServiceChangeReason_str);
|
reason_valid = ws_strtoi32(ServiceChangeReason_str, NULL, &reason);
|
||||||
|
|
||||||
proto_item_append_text(item,"[ %s ]", val_to_str(reason, MEGACO_ServiceChangeReasons_vals,"Unknown (%u)"));
|
proto_item_append_text(item,"[ %s ]", val_to_str(reason, MEGACO_ServiceChangeReasons_vals,"Unknown (%u)"));
|
||||||
|
if (!reason_valid)
|
||||||
|
expert_add_info(pinfo, item, &ei_megaco_reason_invalid);
|
||||||
break;
|
break;
|
||||||
case MEGACO_DELAY_TOKEN:
|
case MEGACO_DELAY_TOKEN:
|
||||||
case MEGACO_SC_ADDR_TOKEN:
|
case MEGACO_SC_ADDR_TOKEN:
|
||||||
|
@ -2883,7 +2889,8 @@ static const value_string MEGACO_error_code_vals[] = {
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dissect_megaco_errordescriptor(tvbuff_t *tvb, proto_tree *megaco_tree_command_line, gint tvb_RBRKT, gint tvb_previous_offset)
|
dissect_megaco_errordescriptor(tvbuff_t *tvb, packet_info* pinfo, proto_tree *megaco_tree_command_line,
|
||||||
|
gint tvb_RBRKT, gint tvb_previous_offset)
|
||||||
{
|
{
|
||||||
|
|
||||||
gint tokenlen;
|
gint tokenlen;
|
||||||
|
@ -2892,6 +2899,7 @@ dissect_megaco_errordescriptor(tvbuff_t *tvb, proto_tree *megaco_tree_command_li
|
||||||
gint tvb_current_offset;
|
gint tvb_current_offset;
|
||||||
proto_item* item;
|
proto_item* item;
|
||||||
proto_tree* error_tree;
|
proto_tree* error_tree;
|
||||||
|
gboolean error_code_valid;
|
||||||
|
|
||||||
tvb_current_offset = tvb_find_guint8(tvb, tvb_previous_offset , tvb_RBRKT, '=');
|
tvb_current_offset = tvb_find_guint8(tvb, tvb_previous_offset , tvb_RBRKT, '=');
|
||||||
tvb_current_offset = megaco_tvb_skip_wsp(tvb, tvb_current_offset +1);
|
tvb_current_offset = megaco_tvb_skip_wsp(tvb, tvb_current_offset +1);
|
||||||
|
@ -2904,8 +2912,10 @@ dissect_megaco_errordescriptor(tvbuff_t *tvb, proto_tree *megaco_tree_command_li
|
||||||
|
|
||||||
/* Get the error code */
|
/* Get the error code */
|
||||||
tvb_get_nstringz0(tvb,tvb_current_offset,4,error);
|
tvb_get_nstringz0(tvb,tvb_current_offset,4,error);
|
||||||
error_code = atoi(error);
|
error_code_valid = ws_strtoi32(error, NULL, &error_code);
|
||||||
proto_tree_add_uint(error_tree, hf_megaco_error_code, tvb, tvb_current_offset, 3, error_code);
|
item = proto_tree_add_uint(error_tree, hf_megaco_error_code, tvb, tvb_current_offset, 3, error_code);
|
||||||
|
if (!error_code_valid)
|
||||||
|
expert_add_info(pinfo, item, &ei_megaco_error_code_invalid);
|
||||||
|
|
||||||
/* Get the error string (even though we have a value_string that should match) */
|
/* Get the error string (even though we have a value_string that should match) */
|
||||||
tvb_previous_offset = tvb_find_guint8(tvb, tvb_current_offset, tvb_RBRKT, '\"');
|
tvb_previous_offset = tvb_find_guint8(tvb, tvb_current_offset, tvb_RBRKT, '\"');
|
||||||
|
@ -3407,13 +3417,13 @@ dissect_megaco_descriptors(tvbuff_t *tvb, proto_tree *megaco_command_tree, packe
|
||||||
dissect_megaco_signaldescriptor(tvb, pinfo, descriptor_tree, tvb_RBRKT, tvb_previous_offset, top_tree);
|
dissect_megaco_signaldescriptor(tvb, pinfo, descriptor_tree, tvb_RBRKT, tvb_previous_offset, top_tree);
|
||||||
break;
|
break;
|
||||||
case MEGACO_SERVICES_TOKEN:
|
case MEGACO_SERVICES_TOKEN:
|
||||||
dissect_megaco_servicechangedescriptor(tvb, descriptor_tree, tvb_RBRKT, tvb_previous_offset);
|
dissect_megaco_servicechangedescriptor(tvb, pinfo, descriptor_tree, tvb_RBRKT, tvb_previous_offset);
|
||||||
break;
|
break;
|
||||||
case MEGACO_STATS_TOKEN:
|
case MEGACO_STATS_TOKEN:
|
||||||
dissect_megaco_statisticsdescriptor(tvb, descriptor_tree, tvb_RBRKT, tvb_previous_offset);
|
dissect_megaco_statisticsdescriptor(tvb, descriptor_tree, tvb_RBRKT, tvb_previous_offset);
|
||||||
break;
|
break;
|
||||||
case MEGACO_ERROR_TOKEN:
|
case MEGACO_ERROR_TOKEN:
|
||||||
dissect_megaco_errordescriptor(tvb, descriptor_tree, tvb_RBRKT, tvb_previous_offset);
|
dissect_megaco_errordescriptor(tvb, pinfo, descriptor_tree, tvb_RBRKT, tvb_previous_offset);
|
||||||
break;
|
break;
|
||||||
case MEGACO_EVENTS_TOKEN:
|
case MEGACO_EVENTS_TOKEN:
|
||||||
dissect_megaco_eventsdescriptor(tvb, pinfo, descriptor_tree, tvb_RBRKT, tvb_previous_offset, top_tree);
|
dissect_megaco_eventsdescriptor(tvb, pinfo, descriptor_tree, tvb_RBRKT, tvb_previous_offset, top_tree);
|
||||||
|
@ -3768,6 +3778,8 @@ proto_register_megaco(void)
|
||||||
{ &ei_megaco_signal_descriptor, { "megaco.signal_descriptor.empty", PI_PROTOCOL, PI_NOTE, "Empty Signal Descriptor", EXPFILL }},
|
{ &ei_megaco_signal_descriptor, { "megaco.signal_descriptor.empty", PI_PROTOCOL, PI_NOTE, "Empty Signal Descriptor", EXPFILL }},
|
||||||
{ &ei_megaco_no_command, { "megaco.no_command", PI_PROTOCOL, PI_WARN, "No Command detectable", EXPFILL }},
|
{ &ei_megaco_no_command, { "megaco.no_command", PI_PROTOCOL, PI_WARN, "No Command detectable", EXPFILL }},
|
||||||
{ &ei_megaco_no_descriptor, { "megaco.no_descriptor", PI_PROTOCOL, PI_WARN, "No Descriptor detectable", EXPFILL }},
|
{ &ei_megaco_no_descriptor, { "megaco.no_descriptor", PI_PROTOCOL, PI_WARN, "No Descriptor detectable", EXPFILL }},
|
||||||
|
{ &ei_megaco_reason_invalid, { "megaco.change_reason.invalid", PI_MALFORMED, PI_ERROR, "Invalid Service Change Reason", EXPFILL }},
|
||||||
|
{ &ei_megaco_error_code_invalid, { "megaco.error_code.invalid", PI_MALFORMED, PI_ERROR, "Invalid error code", EXPFILL }}
|
||||||
};
|
};
|
||||||
|
|
||||||
module_t *megaco_module;
|
module_t *megaco_module;
|
||||||
|
|
Loading…
Reference in New Issue