diff --git a/epan/dissectors/packet-http2.c b/epan/dissectors/packet-http2.c index 2713060c83..654b286a6e 100644 --- a/epan/dissectors/packet-http2.c +++ b/epan/dissectors/packet-http2.c @@ -1105,6 +1105,25 @@ get_http2_session(packet_info *pinfo) return h2session; } +guint32 +http2_get_stream_id(packet_info *pinfo) +{ + conversation_t *conversation; + http2_session_t *h2session; + + conversation = find_conversation_pinfo(pinfo, 0); + if (!conversation) { + return 0; + } + + h2session = (http2_session_t*)conversation_get_proto_data(conversation, proto_http2); + if (!h2session) { + return 0; + } + + return h2session->current_stream_id; +} + #ifdef HAVE_NGHTTP2 static guint32 select_http2_flow_index(packet_info *pinfo, http2_session_t *h2session) diff --git a/epan/dissectors/packet-http2.h b/epan/dissectors/packet-http2.h index 774c41be8b..8fb6c61b91 100644 --- a/epan/dissectors/packet-http2.h +++ b/epan/dissectors/packet-http2.h @@ -25,6 +25,13 @@ int dissect_http2_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* */ const gchar* http2_get_header_value(packet_info *pinfo, const gchar* name, gboolean the_other_direction); +/** + * Get the HTTP2 Stream ID for the current PDU (typically the DATA frame). + * Only valid when called from a HTTP/2 subdissector. + * Returns 0 if no HTTP/2 session was found. + */ +guint32 http2_get_stream_id(packet_info *pinfo); + #endif /*