-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add wireshark dissector for TCP and UDP transports.
- Loading branch information
Showing
3 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Wireshark dissector | ||
|
||
This folder contains a Wireshark dissector for the Fizyr RPC protocol. | ||
Copy the `fizyr-rpc.lua` file to your Wireshark plugin directory to install it. | ||
See [the Wireshark manual][wireshark-plugin-folder] for more information on the plugin folder. | ||
|
||
Afterwards, either restart Wireshark or select the "Reload LUA plugins" option from the "Analyze" menu. | ||
You should now be able to activate the dissector from "Decode As ..." dialog from the "Analyze" menu. | ||
|
||
[wireshark-plugin-folder]: https://www.wireshark.org/docs/wsug_html_chunked/ChPluginFolders.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
do | ||
local fizyr_rpc_tcp_proto = Proto("fizyr_rpc_tcp", "Fizyr RPC over TCP"); | ||
local fizyr_rpc_udp_proto = Proto("fizyr_rpc_udp", "Fizyr RPC over UDP"); | ||
|
||
local udp_length = Field.new("udp.length"); | ||
|
||
local field_length = ProtoField.uint32( | ||
"fizyr_rpc.message_length", | ||
"Message length", | ||
base.DEC, | ||
nil, | ||
nil, | ||
"The length of the message, excluding the message length itself." | ||
) | ||
|
||
local field_kind = ProtoField.uint32( | ||
"fizyr_rpc.message_type", | ||
"Message type", | ||
base.DEC, | ||
{ | ||
[0] = "Request", | ||
[1] = "Response", | ||
[2] = "RequestUpdate", | ||
[3] = "ResponseUpdate", | ||
[4] = "Stream", | ||
}, | ||
nil, | ||
"The type of the RPC message: Request, Response, RequestUpdate, ResponseUpdate or Stream." | ||
) | ||
|
||
local field_request_id = ProtoField.uint32( | ||
"fizyr_rpc.request_id", | ||
"Request ID", | ||
base.DEC, | ||
nil, | ||
nil, | ||
"The request ID of the message. Not used for stream messages." | ||
) | ||
|
||
local field_service_id = ProtoField.int32( | ||
"fizyr_rpc.service_id", | ||
"Service ID", | ||
base.DEC, | ||
nil, | ||
nil, | ||
"The service ID of the message." | ||
) | ||
|
||
local field_body = ProtoField.bytes( | ||
"fizyr_rpc.body", | ||
"Message body", | ||
base.SPACE, | ||
"The message body/payload." | ||
) | ||
|
||
fizyr_rpc_tcp_proto.fields = { | ||
field_length, | ||
field_kind, | ||
field_request_id, | ||
field_service_id, | ||
field_body, | ||
} | ||
|
||
function fizyr_rpc_tcp_proto.dissector(buffer, pinfo, tree) | ||
dissect_tcp_pdus(buffer, tree, 4, fizyr_rpc_tcp_get_length, fizyr_rpc_tcp_dissect_reassembled) | ||
end | ||
|
||
function fizyr_rpc_tcp_get_length(buffer, pinfo, offset) | ||
return 4 + buffer(0, 4):le_uint() | ||
end | ||
|
||
function fizyr_rpc_tcp_dissect_reassembled(buffer, pinfo, tree) | ||
local subtree = tree:add(fizyr_rpc_tcp_proto, buffer) | ||
subtree:add_le(field_length, buffer(0, 4)) | ||
subtree:add_le(field_kind, buffer(4, 4)) | ||
subtree:add_le(field_request_id, buffer(8, 4)) | ||
subtree:add_le(field_service_id, buffer(12, 4)) | ||
subtree:add_le(field_body, buffer(16)) | ||
end | ||
|
||
function fizyr_rpc_udp_proto.dissector(buffer, pinfo, tree) | ||
subtree:add_le(field_length, udp_length()) | ||
subtree:add_le(field_kind, buffer(0, 4)) | ||
subtree:add_le(field_request_id, buffer(4, 4)) | ||
subtree:add_le(field_service_id, buffer(8, 4)) | ||
subtree:add_le(field_body, buffer(12)) | ||
end | ||
|
||
local tcp_table = DissectorTable.get("tcp.port") | ||
tcp_table:add("1-65535", fizyr_rpc_tcp_proto) | ||
|
||
local udp_table = DissectorTable.get("udp.port") | ||
udp_table:add("1-65535", fizyr_rpc_udp_proto) | ||
end |