forked from osmocom/wireshark
Add col_append_lstr(), speedup column generation for TCP.
When dissecting with columns TCP dissector spends around 1/4 time in col_append_fstr(), add col_append_lstr() and do formatting by ourselves. Change-Id: If90bc26242761884b4991e8db0db62c8f9e32690 Reviewed-on: https://code.wireshark.org/review/2527 Reviewed-by: Evan Huus <eapache@gmail.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
parent
ab6a45aec6
commit
6e0be0173b
|
@ -312,6 +312,45 @@ col_custom_prime_edt(epan_dissect_t *edt, column_info *cinfo)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
col_append_lstr(column_info *cinfo, const gint el, const gchar *str, ...)
|
||||
{
|
||||
va_list ap;
|
||||
size_t pos, max_len;
|
||||
int i;
|
||||
|
||||
if (!CHECK_COL(cinfo, el))
|
||||
return;
|
||||
|
||||
if (el == COL_INFO)
|
||||
max_len = COL_MAX_INFO_LEN;
|
||||
else
|
||||
max_len = COL_MAX_LEN;
|
||||
|
||||
for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
|
||||
if (cinfo->fmt_matx[i][el]) {
|
||||
/*
|
||||
* First arrange that we can append, if necessary.
|
||||
*/
|
||||
COL_CHECK_APPEND(cinfo, i, max_len);
|
||||
|
||||
pos = strlen(cinfo->col_buf[i]);
|
||||
if (pos >= max_len)
|
||||
return;
|
||||
|
||||
va_start(ap, str);
|
||||
do {
|
||||
if G_UNLIKELY(str == NULL)
|
||||
str = "(null)";
|
||||
|
||||
pos += g_strlcpy(&cinfo->col_buf[i][pos], str, max_len - pos);
|
||||
|
||||
} while (pos < max_len && (str = va_arg(ap, const char *)) != COL_ADD_LSTR_TERMINATOR);
|
||||
va_end(ap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
col_do_append_fstr(column_info *cinfo, const int el, const char *separator, const char *format, va_list ap)
|
||||
{
|
||||
|
|
|
@ -269,6 +269,12 @@ gboolean col_based_on_frame_data(column_info *cinfo, const gint col);
|
|||
*/
|
||||
WS_DLL_PUBLIC void col_append_str(column_info *cinfo, const gint col, const gchar *str);
|
||||
|
||||
/* Append the given strings (terminated by COL_ADD_LSTR_TERMINATOR) to a column element,
|
||||
*
|
||||
* Same result as col_append_str() called for every string element.
|
||||
*/
|
||||
WS_DLL_PUBLIC void col_append_lstr(column_info *cinfo, const gint el, const gchar *str, ...);
|
||||
|
||||
/** Append the given text to a column element, the text will be formatted and copied.
|
||||
*
|
||||
* Same function as col_append_str() but using a printf-like format string.
|
||||
|
|
|
@ -2361,7 +2361,13 @@ tcp_dissect_pdus(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
|
|||
static void
|
||||
tcp_info_append_uint(packet_info *pinfo, const char *abbrev, guint32 val)
|
||||
{
|
||||
col_append_fstr(pinfo->cinfo, COL_INFO, " %s=%u", abbrev, val);
|
||||
char buf[16];
|
||||
|
||||
guint32_to_str_buf(val, buf, sizeof(buf));
|
||||
/* fstr(" %s=%u", abbrev, val) */
|
||||
col_append_lstr(pinfo->cinfo, COL_INFO,
|
||||
" ", abbrev, "=", buf,
|
||||
COL_ADD_LSTR_TERMINATOR);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -2935,7 +2941,9 @@ dissect_tcpopt_qs(const ip_tcp_opt *optp, tvbuff_t *tvb,
|
|||
"%s: Rate response, %s, TTL diff %u ", optp->name,
|
||||
val_to_str_ext_const(rate, &qs_rate_vals_ext, "Unknown"),
|
||||
tvb_get_guint8(tvb, offset + 3));
|
||||
col_append_fstr(pinfo->cinfo, COL_INFO, " QSresp=%s", val_to_str_ext_const(rate, &qs_rate_vals_ext, "Unknown"));
|
||||
col_append_lstr(pinfo->cinfo, COL_INFO,
|
||||
" QSresp=", val_to_str_ext_const(rate, &qs_rate_vals_ext, "Unknown"),
|
||||
COL_ADD_LSTR_TERMINATOR);
|
||||
field_tree = proto_item_add_subtree(tf, ett_tcp_opt_qs);
|
||||
proto_tree_add_item(field_tree, hf_tcp_option_kind, tvb,
|
||||
offset, 1, ENC_BIG_ENDIAN);
|
||||
|
@ -3025,8 +3033,10 @@ dissect_tcpopt_scps(const ip_tcp_opt *optp _U_, tvbuff_t *tvb,
|
|||
if (capvector & capvecs[i].mask) {
|
||||
proto_item_append_text(tf, "%s%s", anyflag ? ", " : " (",
|
||||
capvecs[i].str);
|
||||
col_append_fstr(pinfo->cinfo, COL_INFO, "%s%s",
|
||||
anyflag ? ", " : "", capvecs[i].str);
|
||||
col_append_lstr(pinfo->cinfo, COL_INFO,
|
||||
anyflag ? ", " : "",
|
||||
capvecs[i].str,
|
||||
COL_ADD_LSTR_TERMINATOR);
|
||||
anyflag = TRUE;
|
||||
}
|
||||
}
|
||||
|
@ -4356,7 +4366,10 @@ dissect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|||
|
||||
flags_str = tcp_flags_to_str(tcph);
|
||||
|
||||
col_append_fstr(pinfo->cinfo, COL_INFO, " [%s] Seq=%u", flags_str, tcph->th_seq);
|
||||
col_append_lstr(pinfo->cinfo, COL_INFO,
|
||||
" [", flags_str, "]",
|
||||
COL_ADD_LSTR_TERMINATOR);
|
||||
tcp_info_append_uint(pinfo, "Seq", tcph->th_seq);
|
||||
if (tcph->th_flags&TH_ACK)
|
||||
tcp_info_append_uint(pinfo, "Ack", tcph->th_ack);
|
||||
|
||||
|
|
Loading…
Reference in New Issue