RTPProxy: Make column info more readable.

This commit is contained in:
AndersBroman 2022-11-15 09:29:19 +01:00
parent b9a4bf297e
commit b704562c0c
1 changed files with 32 additions and 18 deletions

View File

@ -288,12 +288,13 @@ static nstime_t rtpproxy_timeout_ns = NSTIME_INIT_ZERO;
void proto_reg_handoff_rtpproxy(void); void proto_reg_handoff_rtpproxy(void);
static gint static gint
rtpproxy_add_tag(proto_tree *rtpproxy_tree, tvbuff_t *tvb, guint begin, guint realsize) rtpproxy_add_tag(tvbuff_t *tvb, packet_info* pinfo, proto_tree* rtpproxy_tree, guint begin, guint realsize)
{ {
proto_item *ti = NULL; proto_item *ti = NULL;
proto_tree *another_tree = NULL; proto_tree *another_tree = NULL;
gint new_offset; gint new_offset;
guint end; guint end;
const guint8* tmpstr;
new_offset = tvb_find_guint8(tvb, begin, -1, ' '); new_offset = tvb_find_guint8(tvb, begin, -1, ' ');
if(new_offset < 0) if(new_offset < 0)
@ -306,20 +307,23 @@ rtpproxy_add_tag(proto_tree *rtpproxy_tree, tvbuff_t *tvb, guint begin, guint re
*/ */
new_offset = tvb_find_guint8(tvb, begin, end, ';'); new_offset = tvb_find_guint8(tvb, begin, end, ';');
if(new_offset == -1){ if(new_offset == -1){
ti = proto_tree_add_item(rtpproxy_tree, hf_rtpproxy_tag, tvb, begin, end - begin, ENC_ASCII | ENC_NA); ti = proto_tree_add_item_ret_string(rtpproxy_tree, hf_rtpproxy_tag, tvb, begin, end - begin, ENC_ASCII | ENC_NA, pinfo->pool, &tmpstr);
col_append_fstr(pinfo->cinfo, COL_INFO, ", Tag: %s", tmpstr);
another_tree = proto_item_add_subtree(ti, ett_rtpproxy_tag); another_tree = proto_item_add_subtree(ti, ett_rtpproxy_tag);
ti = proto_tree_add_item(another_tree, hf_rtpproxy_mediaid, tvb, new_offset+1, 0, ENC_ASCII | ENC_NA); ti = proto_tree_add_item(another_tree, hf_rtpproxy_mediaid, tvb, new_offset+1, 0, ENC_ASCII | ENC_NA);
proto_item_append_text(ti, "<skipped>"); proto_item_append_text(ti, "<skipped>");
proto_item_set_generated(ti); proto_item_set_generated(ti);
} }
else{ else{
ti = proto_tree_add_item(rtpproxy_tree, hf_rtpproxy_tag, tvb, begin, new_offset - begin, ENC_ASCII | ENC_NA); ti = proto_tree_add_item_ret_string(rtpproxy_tree, hf_rtpproxy_tag, tvb, begin, new_offset - begin, ENC_ASCII | ENC_NA, pinfo->pool, &tmpstr);
col_append_fstr(pinfo->cinfo, COL_INFO, ", Tag: %s", tmpstr);
if ((guint)new_offset == begin){ if ((guint)new_offset == begin){
proto_item_append_text(ti, "<skipped>"); /* A very first Offer/Update command */ proto_item_append_text(ti, "<skipped>"); /* A very first Offer/Update command */
proto_item_set_generated(ti); proto_item_set_generated(ti);
} }
another_tree = proto_item_add_subtree(ti, ett_rtpproxy_tag); another_tree = proto_item_add_subtree(ti, ett_rtpproxy_tag);
proto_tree_add_item(another_tree, hf_rtpproxy_mediaid, tvb, new_offset+1, end - (new_offset+1), ENC_ASCII | ENC_NA); proto_tree_add_item_ret_string(another_tree, hf_rtpproxy_mediaid, tvb, new_offset+1, end - (new_offset+1), ENC_ASCII | ENC_NA, pinfo->pool, &tmpstr);
col_append_fstr(pinfo->cinfo, COL_INFO, ", Media id: %s", tmpstr);
} }
return (end == realsize ? -1 : (gint)end); return (end == realsize ? -1 : (gint)end);
} }
@ -611,7 +615,7 @@ dissect_rtpproxy(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data
/* FIXME https://github.com/sippy/rtpproxy/wiki/RTPP-%28RTPproxy-protocol%29-technical-specification#information */ /* FIXME https://github.com/sippy/rtpproxy/wiki/RTPP-%28RTPproxy-protocol%29-technical-specification#information */
rtpproxy_add_tid(FALSE, tvb, pinfo, rtpproxy_tree, rtpproxy_conv, cookie); rtpproxy_add_tid(FALSE, tvb, pinfo, rtpproxy_tree, rtpproxy_conv, cookie);
if ('e' == tvb_get_guint8(tvb, offset+1)){ if ('e' == tvb_get_guint8(tvb, offset+1)){
col_add_fstr(pinfo->cinfo, COL_INFO, "Reply: %s", rawstr); col_add_fstr(pinfo->cinfo, COL_INFO, "Reply: %s", format_text_wsp(pinfo->pool, rawstr, realsize - offset));
ti = proto_tree_add_item(rtpproxy_tree, hf_rtpproxy_reply, tvb, offset, -1, ENC_NA); ti = proto_tree_add_item(rtpproxy_tree, hf_rtpproxy_reply, tvb, offset, -1, ENC_NA);
rtpproxy_tree = proto_item_add_subtree(ti, ett_rtpproxy_reply); rtpproxy_tree = proto_item_add_subtree(ti, ett_rtpproxy_reply);
@ -641,7 +645,7 @@ dissect_rtpproxy(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data
case 'c': case 'c':
case 'q': case 'q':
rtpproxy_info = rtpproxy_add_tid(TRUE, tvb, pinfo, rtpproxy_tree, rtpproxy_conv, cookie); rtpproxy_info = rtpproxy_add_tid(TRUE, tvb, pinfo, rtpproxy_tree, rtpproxy_conv, cookie);
col_add_fstr(pinfo->cinfo, COL_INFO, "Request: %s", rawstr); col_add_fstr(pinfo->cinfo, COL_INFO, "Request: %s", val_to_str(tvb_get_guint8(tvb, offset), commandtypenames, "Unknown command code"));
ti = proto_tree_add_item(rtpproxy_tree, hf_rtpproxy_request, tvb, offset, -1, ENC_NA); ti = proto_tree_add_item(rtpproxy_tree, hf_rtpproxy_request, tvb, offset, -1, ENC_NA);
rtpproxy_tree = proto_item_add_subtree(ti, ett_rtpproxy_request); rtpproxy_tree = proto_item_add_subtree(ti, ett_rtpproxy_request);
@ -676,7 +680,8 @@ dissect_rtpproxy(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data
if (new_offset != offset + 1){ if (new_offset != offset + 1){
rtpproxy_tree = proto_item_add_subtree(ti, ett_rtpproxy_command); rtpproxy_tree = proto_item_add_subtree(ti, ett_rtpproxy_command);
ti2 = proto_tree_add_item(rtpproxy_tree, hf_rtpproxy_command_parameters, tvb, offset+1, new_offset - (offset+1), ENC_ASCII | ENC_NA); ti2 = proto_tree_add_item_ret_string(rtpproxy_tree, hf_rtpproxy_command_parameters, tvb, offset+1, new_offset - (offset+1), ENC_ASCII | ENC_NA, pinfo->pool, &tmpstr);
col_append_fstr(pinfo->cinfo, COL_INFO, " %s", tmpstr);
rtpproxy_add_parameter(tvb, pinfo, proto_item_add_subtree(ti2, ett_rtpproxy_command_parameters), offset+1, new_offset - (offset+1)); rtpproxy_add_parameter(tvb, pinfo, proto_item_add_subtree(ti2, ett_rtpproxy_command_parameters), offset+1, new_offset - (offset+1));
rtpproxy_tree = proto_item_get_parent(ti); rtpproxy_tree = proto_item_get_parent(ti);
} }
@ -690,7 +695,8 @@ dissect_rtpproxy(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data
/* Extract Call-ID */ /* Extract Call-ID */
new_offset = tvb_find_guint8(tvb, offset, -1, ' '); new_offset = tvb_find_guint8(tvb, offset, -1, ' ');
proto_tree_add_item(rtpproxy_tree, hf_rtpproxy_callid, tvb, offset, new_offset - offset, ENC_ASCII | ENC_NA); proto_tree_add_item_ret_string(rtpproxy_tree, hf_rtpproxy_callid, tvb, offset, new_offset - offset, ENC_ASCII | ENC_NA, pinfo->pool, &tmpstr);
col_append_fstr(pinfo->cinfo, COL_INFO, ", Call-ID: %s", tmpstr);
if(rtpproxy_info && !rtpproxy_info->callid) if(rtpproxy_info && !rtpproxy_info->callid)
rtpproxy_info->callid = tvb_get_string_enc(wmem_file_scope(), tvb, offset, new_offset - offset, ENC_ASCII); rtpproxy_info->callid = tvb_get_string_enc(wmem_file_scope(), tvb, offset, new_offset - offset, ENC_ASCII);
/* Skip whitespace */ /* Skip whitespace */
@ -701,24 +707,32 @@ dissect_rtpproxy(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data
/* Extract IP */ /* Extract IP */
new_offset = tvb_find_guint8(tvb, offset, -1, ' '); new_offset = tvb_find_guint8(tvb, offset, -1, ' ');
if (tvb_find_guint8(tvb, offset, new_offset - offset, ':') == -1){ if (tvb_find_guint8(tvb, offset, new_offset - offset, ':') == -1){
if(str_to_ip((char*)tvb_get_string_enc(pinfo->pool, tvb, offset, new_offset - offset, ENC_ASCII), ipaddr)) tmpstr = tvb_get_string_enc(pinfo->pool, tvb, offset, new_offset - offset, ENC_ASCII);
if (str_to_ip(tmpstr, ipaddr)) {
col_append_fstr(pinfo->cinfo, COL_INFO, ", IP: %s", tmpstr);
proto_tree_add_ipv4(rtpproxy_tree, hf_rtpproxy_ipv4, tvb, offset, new_offset - offset, ipaddr[0]); proto_tree_add_ipv4(rtpproxy_tree, hf_rtpproxy_ipv4, tvb, offset, new_offset - offset, ipaddr[0]);
else }
else {
proto_tree_add_expert(rtpproxy_tree, pinfo, &ei_rtpproxy_bad_ipv4, tvb, offset, new_offset - offset); proto_tree_add_expert(rtpproxy_tree, pinfo, &ei_rtpproxy_bad_ipv4, tvb, offset, new_offset - offset);
} }
else{ } else{
if(str_to_ip6((char*)tvb_get_string_enc(pinfo->pool, tvb, offset, new_offset - offset, ENC_ASCII), ipaddr)) tmpstr = tvb_get_string_enc(pinfo->pool, tvb, offset, new_offset - offset, ENC_ASCII);
proto_tree_add_ipv6(rtpproxy_tree, hf_rtpproxy_ipv6, tvb, offset, new_offset - offset, (const ws_in6_addr *)ipaddr); if (str_to_ip6(tmpstr, ipaddr)) {
else col_append_fstr(pinfo->cinfo, COL_INFO, ", IP: [%s]", tmpstr);
proto_tree_add_ipv6(rtpproxy_tree, hf_rtpproxy_ipv6, tvb, offset, new_offset - offset, (const ws_in6_addr*)ipaddr);
} else {
proto_tree_add_expert(rtpproxy_tree, pinfo, &ei_rtpproxy_bad_ipv6, tvb, offset, new_offset - offset); proto_tree_add_expert(rtpproxy_tree, pinfo, &ei_rtpproxy_bad_ipv6, tvb, offset, new_offset - offset);
}
} }
/* Skip whitespace */ /* Skip whitespace */
offset = tvb_skip_wsp(tvb, new_offset+1, -1); offset = tvb_skip_wsp(tvb, new_offset+1, -1);
/* Extract Port */ /* Extract Port */
new_offset = tvb_find_guint8(tvb, offset, -1, ' '); new_offset = tvb_find_guint8(tvb, offset, -1, ' ');
tmpstr = tvb_get_string_enc(pinfo->pool, tvb, offset, new_offset - offset, ENC_ASCII);
col_append_fstr(pinfo->cinfo, COL_INFO, ":%s", tmpstr);
proto_tree_add_uint(rtpproxy_tree, hf_rtpproxy_port, tvb, offset, new_offset - offset, proto_tree_add_uint(rtpproxy_tree, hf_rtpproxy_port, tvb, offset, new_offset - offset,
(guint16) g_ascii_strtoull((gchar*)tvb_get_string_enc(pinfo->pool, tvb, offset, new_offset - offset, ENC_ASCII), NULL, 10)); (guint16) g_ascii_strtoull((gchar*)tmpstr, NULL, 10));
/* Skip whitespace */ /* Skip whitespace */
offset = tvb_skip_wsp(tvb, new_offset+1, -1); offset = tvb_skip_wsp(tvb, new_offset+1, -1);
} }
@ -748,14 +762,14 @@ dissect_rtpproxy(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data
} }
/* Extract first tag */ /* Extract first tag */
new_offset = rtpproxy_add_tag(rtpproxy_tree, tvb, offset, realsize); new_offset = rtpproxy_add_tag(tvb, pinfo, rtpproxy_tree, offset, realsize);
if(new_offset == -1) if(new_offset == -1)
break; /* No more parameters */ break; /* No more parameters */
/* Skip whitespace */ /* Skip whitespace */
offset = tvb_skip_wsp(tvb, new_offset+1, -1); offset = tvb_skip_wsp(tvb, new_offset+1, -1);
/* Extract second tag */ /* Extract second tag */
new_offset = rtpproxy_add_tag(rtpproxy_tree, tvb, offset, realsize); new_offset = rtpproxy_add_tag(tvb, pinfo, rtpproxy_tree, offset, realsize);
if(new_offset == -1) if(new_offset == -1)
break; /* No more parameters */ break; /* No more parameters */
/* Skip whitespace */ /* Skip whitespace */