diff options
author | Alexis La Goutte <alexis.lagoutte@gmail.com> | 2015-01-08 17:35:58 +0100 |
---|---|---|
committer | Alexis La Goutte <alexis.lagoutte@gmail.com> | 2015-02-04 07:09:49 +0000 |
commit | 0f353c9cc412c94c966a5195c1ff847a9081e959 (patch) | |
tree | d453a3475be340ac79a286ad55626c1f76c91f44 | |
parent | ef929aded5676a5091bfda4d205f1ef2a1018eaa (diff) |
HTTP2: Add tap for HTTP2 dissector
Change-Id: Ib13d9391b64dad19321a4399c95b95d7fb791284
Reviewed-on: https://code.wireshark.org/review/6421
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
-rw-r--r-- | docbook/release-notes.asciidoc | 4 | ||||
-rw-r--r-- | epan/dissectors/packet-http2.c | 43 | ||||
-rw-r--r-- | ui/gtk/main_menubar.c | 2 | ||||
-rw-r--r-- | ui/qt/main_window.h | 1 | ||||
-rw-r--r-- | ui/qt/main_window.ui | 9 | ||||
-rw-r--r-- | ui/qt/main_window_slots.cpp | 6 |
6 files changed, 65 insertions, 0 deletions
diff --git a/docbook/release-notes.asciidoc b/docbook/release-notes.asciidoc index 1453de9c96..cd3710cf36 100644 --- a/docbook/release-notes.asciidoc +++ b/docbook/release-notes.asciidoc @@ -49,6 +49,10 @@ field and shows a description in the status bar. is possible to collect stats per channel (messages count and payload size), and opcode distribution. +* HTTP2 stats: + + A new stats tree has been added to the statistics menu. Now it + is possible to collect stats (type distribution). + The following features are new (or have been significantly updated) since version 1.12.0: diff --git a/epan/dissectors/packet-http2.c b/epan/dissectors/packet-http2.c index 0c01edce2b..8b3a750ee2 100644 --- a/epan/dissectors/packet-http2.c +++ b/epan/dissectors/packet-http2.c @@ -46,6 +46,8 @@ #include <epan/nghttp2/nghttp2.h> #include "packet-tcp.h" +#include <epan/tap.h> +#include <epan/stats_tree.h> #include "wsutil/pint.h" @@ -137,6 +139,17 @@ typedef struct { void proto_register_http2(void); void proto_reg_handoff_http2(void); +struct HTTP2Tap { + guint8 type; +}; + +static int http2_tap = -1; + +static const guint8* st_str_http2 = "HTTP2"; +static const guint8* st_str_http2_type = "Type"; + +static int st_node_http2 = -1; +static int st_node_http2_type = -1; /* Heuristic dissection */ static gboolean global_http2_heur = FALSE; @@ -1235,6 +1248,7 @@ dissect_http2_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* dat guint8 type, flags; guint16 length; guint32 streamid; + struct HTTP2Tap *http2_stats; if(!p_get_proto_data(wmem_file_scope(), pinfo, proto_http2, 0)) { http2_header_data_t *header_data; @@ -1305,6 +1319,10 @@ dissect_http2_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* dat proto_item_append_text(ti, ": %s, Stream ID: %u, Length %u", val_to_str(type, http2_type_vals, "Unknown type (%d)"), streamid, length); offset += 4; + /* Collect stats */ + http2_stats = wmem_new0(wmem_packet_scope(), struct HTTP2Tap); + http2_stats->type = type; + switch(type){ case HTTP2_DATA: /* Data (0) */ dissect_http2_data(tvb, pinfo, http2_tree, offset, flags); @@ -1358,6 +1376,10 @@ dissect_http2_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* dat proto_tree_add_item(http2_tree, hf_http2_unknown, tvb, offset, -1, ENC_NA); break; } + + tap_queue_packet(http2_tap, pinfo, http2_stats); + + return tvb_captured_length(tvb); } @@ -1840,6 +1862,25 @@ proto_register_http2(void) &global_http2_heur); new_register_dissector("http2", dissect_http2, proto_http2); + + http2_tap = register_tap("http2"); +} + +static void http2_stats_tree_init(stats_tree* st) +{ + st_node_http2 = stats_tree_create_node(st, st_str_http2, 0, TRUE); + st_node_http2_type = stats_tree_create_pivot(st, st_str_http2_type, st_node_http2); + +} + +static int http2_stats_tree_packet(stats_tree* st, packet_info* pinfo _U_, epan_dissect_t* edt _U_, const void* p) +{ + struct HTTP2Tap *pi = (struct HTTP2Tap *)p; + tick_stat_node(st, st_str_http2, 0, FALSE); + stats_tree_tick_pivot(st, st_node_http2_type, + val_to_str(pi->type, http2_type_vals, "Unknown type (%d)")); + + return 1; } void @@ -1852,6 +1893,8 @@ proto_reg_handoff_http2(void) heur_dissector_add("ssl", dissect_http2_heur, proto_http2); heur_dissector_add("http", dissect_http2_heur, proto_http2); + + stats_tree_register("http2", "http2", "HTTP2", 0, http2_stats_tree_packet, http2_stats_tree_init, NULL); } /* diff --git a/ui/gtk/main_menubar.c b/ui/gtk/main_menubar.c index dbff56869a..73a77bee95 100644 --- a/ui/gtk/main_menubar.c +++ b/ui/gtk/main_menubar.c @@ -1054,6 +1054,7 @@ static const char *ui_desc_menubar = " <menuitem name='http_req' action='/Statistics/HTTP/http_req'/>\n" " <menuitem name='http_srv' action='/Statistics/HTTP/http_srv'/>\n" " </menu>\n" +" <menuitem name='HTTP2' action='/Statistics/http2'/>\n" " <menuitem name='ONC-RPC-Programs' action='/Statistics/ONC-RPC-Programs'/>\n" " <menu name= 'SametimeMenu' action='/Statistics/Sametime'>\n" " <menuitem name='sametime' action='/Statistics/Sametime/sametime'/>\n" @@ -1487,6 +1488,7 @@ static const GtkActionEntry main_menu_bar_entries[] = { { "/Statistics/HTTP/http", NULL, "Packet Counter", NULL, NULL, G_CALLBACK(gtk_stats_tree_cb) }, { "/Statistics/HTTP/http_req", NULL, "Requests", NULL, NULL, G_CALLBACK(gtk_stats_tree_cb) }, { "/Statistics/HTTP/http_srv", NULL, "Load Distribution", NULL, NULL, G_CALLBACK(gtk_stats_tree_cb) }, + { "/Statistics/http2", NULL, "HTTP2", NULL, NULL, G_CALLBACK(gtk_stats_tree_cb) }, { "/Statistics/ONC-RPC-Programs", NULL, "ONC-RPC Programs", NULL, NULL, G_CALLBACK(gtk_rpcprogs_cb) }, { "/Statistics/Sametime", NULL, "Sametime", NULL, NULL, NULL }, { "/Statistics/Sametime/sametime", NULL, "Messages", NULL, NULL, G_CALLBACK(gtk_stats_tree_cb) }, diff --git a/ui/qt/main_window.h b/ui/qt/main_window.h index f64979d4b4..97b341928e 100644 --- a/ui/qt/main_window.h +++ b/ui/qt/main_window.h @@ -425,6 +425,7 @@ private slots: void on_actionStatisticsDNS_triggered(); void actionStatisticsPlugin_triggered(); void on_actionStatisticsHpfeeds_triggered(); + void on_actionStatisticsHTTP2_triggered(); void openVoipCallsDialog(bool all_flows = false); void on_actionTelephonyVoipCalls_triggered(); diff --git a/ui/qt/main_window.ui b/ui/qt/main_window.ui index f61360bb60..4bb733876a 100644 --- a/ui/qt/main_window.ui +++ b/ui/qt/main_window.ui @@ -438,6 +438,7 @@ <addaction name="actionStatisticsHART_IP"/> <addaction name="actionStatisticsHpfeeds"/> <addaction name="menuHTTP"/> + <addaction name="actionStatisticsHTTP2"/> <addaction name="actionStatisticsSametime"/> <addaction name="menuTcpStreamGraphs"/> </widget> @@ -1597,6 +1598,14 @@ <string>hpfeeds statistics</string> </property> </action> + <action name="actionStatisticsHTTP2"> + <property name="text"> + <string>HTTP2</string> + </property> + <property name="toolTip"> + <string>HTTP2 statistics</string> + </property> + </action> <action name="actionStatisticsHTTPPacketCounter"> <property name="text"> <string>Packet Counter</string> diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp index 99988aaaa6..4a2030c3e0 100644 --- a/ui/qt/main_window_slots.cpp +++ b/ui/qt/main_window_slots.cpp @@ -2448,6 +2448,12 @@ void MainWindow::actionStatisticsPlugin_triggered() } } +void MainWindow::on_actionStatisticsHTTP2_triggered() +{ + openStatisticsTreeDialog("http2"); + +} + // Telephony Menu void MainWindow::openVoipCallsDialog(bool all_flows) |