|
7 | 7 | -- |
8 | 8 | --]] |
9 | 9 |
|
10 | | --- This file must only be loaded once, but each version requires it. |
11 | | -if package.loaded['rls'] == nil then |
12 | | - -- Update the following when adding new versions |
13 | | - local latestVersion = 0x0302 |
14 | | - local oldestVersion = 0x0301 |
| 10 | +local pluginVersion = "1.1.1" |
| 11 | +-- Update the following when adding new versions |
| 12 | +local latestVersion = 0x0302 |
| 13 | +local oldestVersion = 0x0301 |
15 | 14 |
|
16 | | - local rlsProtocol = Proto("RLS", "UERANSIM Radio Link Simulation (RLS) Protocol") |
| 15 | +local rlsProtocol = Proto("RLS", "UERANSIM Radio Link Simulation (RLS) Protocol") |
| 16 | +set_plugin_info({ |
| 17 | + version = pluginVersion, |
| 18 | + author = "Louis Royer", |
| 19 | + repository = "https://github.com/louisroyer/RLS-wireshark-dissector", |
| 20 | + description = "Dissector for Radio Link Simulation Protocol" |
| 21 | +}) |
17 | 22 |
|
18 | | - -- Create a DissectorTable to register dissector for each version of RLS |
19 | | - DissectorTable.new("rls", "RLS version", ftypes.UINT32, base.HEX, rlsProtocol) |
| 23 | +-- Create a DissectorTable to register dissector for each version of RLS |
| 24 | +DissectorTable.new("rls", "RLS version", ftypes.UINT32, base.HEX, rlsProtocol) |
20 | 25 |
|
21 | | - -- Preferences |
22 | | - rlsProtocol.prefs.udp_port = Pref.uint("RLS UDP port", 4997, "UDP port for RLS") |
| 26 | +-- Preferences |
| 27 | +rlsProtocol.prefs.udp_port = Pref.uint("RLS UDP port", 4997, "UDP port for RLS") |
23 | 28 |
|
24 | | - -- Add version field |
25 | | - local fields = rlsProtocol.fields |
26 | | - fields.Version = ProtoField.string("rls.version", "Version") |
| 29 | +-- Add version field |
| 30 | +local fields = rlsProtocol.fields |
| 31 | +fields.Version = ProtoField.string("rls.version", "Version") |
27 | 32 |
|
28 | | - function rlsProtocol.dissector(buffer, pinfo, tree) |
29 | | - -- Generic check |
30 | | - if buffer:len() == 0 then return end |
31 | | - if buffer(0, 1):uint() ~= 0x03 then return end |
| 33 | +function rlsProtocol.dissector(buffer, pinfo, tree) |
| 34 | + -- Generic check |
| 35 | + if buffer:len() == 0 then return end |
| 36 | + if buffer(0, 1):uint() ~= 0x03 then return end |
32 | 37 |
|
33 | | - pinfo.cols.protocol = rlsProtocol.name |
| 38 | + pinfo.cols.protocol = rlsProtocol.name |
34 | 39 |
|
35 | | - local version = buffer(1,2):uint() |
36 | | - local subprotocol = DissectorTable.get("rls"):get_dissector(version) |
| 40 | + local version = buffer(1,2):uint() |
| 41 | + local subprotocol = DissectorTable.get("rls"):get_dissector(version) |
| 42 | + if subprotocol == nil then |
| 43 | + if version > latestVersion then |
| 44 | + -- fallback to latest version |
| 45 | + version = latestVersion |
| 46 | + elseif version < oldestVersion then |
| 47 | + -- fallback to oldest version |
| 48 | + version = oldestVersion |
| 49 | + end |
| 50 | + subprotocol = DissectorTable.get("rls"):get_dissector(version) |
37 | 51 | if subprotocol == nil then |
38 | | - if version > latestVersion then |
39 | | - -- fallback to latest version |
40 | | - version = latestVersion |
41 | | - elseif version < oldestVersion then |
42 | | - -- fallback to oldest version |
43 | | - version = oldestVersion |
44 | | - end |
45 | | - subprotocol = DissectorTable.get("rls"):get_dissector(version) |
46 | | - if subprotocol == nil then |
47 | | - local versionNumber = buffer(1, 1):uint() .. "." .. buffer(2, 1):uint() .. "." .. buffer(3, 1):uint() |
48 | | - local subtree = tree:add(rlsProtocol, buffer(), "UERANSIM Radio Link Simulation (RLS) protocol") |
49 | | - pinfo.cols.info = "Unsupported version - Cannot decode" |
50 | | - subtree:add(fields.Version, buffer(1, 3), versionNumber) |
51 | | - return 4 |
52 | | - end |
| 52 | + local versionNumber = buffer(1, 1):uint() .. "." .. buffer(2, 1):uint() .. "." .. buffer(3, 1):uint() |
| 53 | + local subtree = tree:add(rlsProtocol, buffer(), "UERANSIM Radio Link Simulation (RLS) protocol") |
| 54 | + pinfo.cols.info = "Unsupported version - Cannot decode" |
| 55 | + subtree:add(fields.Version, buffer(1, 3), versionNumber) |
| 56 | + return 4 |
53 | 57 | end |
54 | | - subprotocol:call(buffer():tvb(), pinfo, tree) |
55 | 58 | end |
| 59 | + subprotocol:call(buffer():tvb(), pinfo, tree) |
| 60 | +end |
56 | 61 |
|
| 62 | +function rlsProtocol.init() |
57 | 63 | -- Export protocol |
58 | 64 | local udp_port = DissectorTable.get("udp.port") |
59 | 65 | udp_port:add(rlsProtocol.prefs.udp_port, rlsProtocol) |
|
0 commit comments