diff options
author | Jakub Zawadzki <darkjames@darkjames.pl> | 2014-05-14 01:56:23 +0200 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2014-05-17 21:33:26 +0000 |
commit | ea95c837fe62cb89ae7a0507e3ca437b822d658c (patch) | |
tree | 4474e48708ed60c27eb35d4ee3904381086daed7 /epan/dissectors/packet-vlan.c | |
parent | 24082972a3650c0e743776b47549a17ab0ad20fe (diff) |
Introduce col_add_lstr(), use it instead of slower col_add_fstr.
We have callgrind benchmarks which shows that col_add_fstr() takes
5% of Ir count cause of formatting done in g_vsnprintf().
New col_add_lstr() can be used in few dissectors without much ugliness,
and it should be a little faster.
Change-Id: Ifddd951063dfd3a27c2a7da4dafce9b242c0472c
Reviewed-on: https://code.wireshark.org/review/1629
Reviewed-by: Evan Huus <eapache@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-vlan.c')
-rw-r--r-- | epan/dissectors/packet-vlan.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/epan/dissectors/packet-vlan.c b/epan/dissectors/packet-vlan.c index 239bb68c6c..4479ce67cb 100644 --- a/epan/dissectors/packet-vlan.c +++ b/epan/dissectors/packet-vlan.c @@ -34,6 +34,7 @@ #include "packet-vlan.h" #include <epan/etypes.h> #include <epan/prefs.h> +#include <epan/to_str.h> void proto_register_vlan(void); void proto_reg_handoff_vlan(void); @@ -118,6 +119,23 @@ capture_vlan(const guchar *pd, int offset, int len, packet_counts *ld ) { } static void +columns_set_vlan(column_info *cinfo, guint16 tci) +{ + static const char fast_str[][2] = { "0", "1", "2", "3", "4", "5", "6", "7" }; + + char id_str[16]; + + guint32_to_str_buf(tci & 0xFFF, id_str, sizeof(id_str)); + + col_add_lstr(cinfo, COL_INFO, + "PRI: ", fast_str[(tci >> 13) & 7], " " + "CFI: ", fast_str[(tci >> 12) & 1], " " + "ID: ", id_str, + COL_ADD_LSTR_TERMINATOR); + col_add_str(cinfo, COL_8021Q_VLAN_ID, id_str); +} + +static void dissect_vlan(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { proto_item *ti; @@ -131,9 +149,7 @@ dissect_vlan(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) tci = tvb_get_ntohs( tvb, 0 ); - col_add_fstr(pinfo->cinfo, COL_INFO, "PRI: %u CFI: %u ID: %u", - (tci >> 13), ((tci >> 12) & 1), (tci & 0xFFF)); - col_add_fstr(pinfo->cinfo, COL_8021Q_VLAN_ID, "%u", (tci & 0xFFF)); + columns_set_vlan(pinfo->cinfo, tci); vlan_tree = NULL; |