git: parse Git Protocol version from pkt-lines

In Git's packfile transfer protocol[1], the initial server response
contains the version of the Git Protocol in use; version 1 or version 2
[2].

Parse out this information following up on work started in MR !805 [3]
by Izabela Bakollari and advice provided by Ronnie Sahlberg, add it as a
field for ease of reading and filtering.

[1] https://www.kernel.org/pub/software/scm/git/docs/technical/pack-protocol.html
[2] https://www.kernel.org/pub/software/scm/git/docs/technical/protocol-v2.html
[3] https://gitlab.com/wireshark/wireshark/-/merge_requests/805

Related to #17093
This commit is contained in:
Joey Salazar 2021-01-07 18:47:06 -06:00 committed by Wireshark GitLab Utility
parent ca4e5c2962
commit d7ffd8f014
1 changed files with 23 additions and 0 deletions

View File

@ -28,6 +28,7 @@ static int proto_git = -1;
static gint ett_git = -1;
static gint hf_git_protocol_version = -1;
static gint hf_git_packet_len = -1;
static gint hf_git_packet_data = -1;
static gint hf_git_packet_terminator = -1;
@ -39,6 +40,12 @@ static gint hf_git_sideband_control_code = -1;
#define TCP_PORT_GIT 9418
static const value_string version_vals[] = {
{ '1', "Git protocol version 1" },
{ '2', "Git protocol version 2" },
{ 0, NULL }
};
#define SIDEBAND_PACKFILE_DATA 0x01
#define SIDEBAND_PROGRESS_INFO 0x02
#define SIDEBAND_ERROR_INFO 0x03
@ -106,6 +113,18 @@ dissect_git_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data
offset += 4;
plen -= 4;
/*
* Parse out the version of the Git Protocol
*
* The initial server response contains the version of the Git Protocol in use;
* 1 or 2. Parsing out this information helps identify the capabilities and
* information that can be used with the protocol.
*/
if (plen >= 9 && !tvb_strneql(tvb, offset, "version ", 8)) {
proto_tree_add_item(git_tree, hf_git_protocol_version, tvb, offset + 8,
1, ENC_NA);
}
/*
* Parse out the sideband control code.
*
@ -140,6 +159,10 @@ void
proto_register_git(void)
{
static hf_register_info hf[] = {
{ &hf_git_protocol_version,
{ "Git Protocol Version", "git.version", FT_UINT8, BASE_NONE, VALS(version_vals),
0, NULL, HFILL },
},
{ &hf_git_packet_len,
{ "Packet length", "git.length", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL },
},