-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wireshark kaitai runtime for lua5.2 with modified generated runtime, …
…dissector stub, not working
- Loading branch information
Showing
30 changed files
with
2,716 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,4 @@ repos: | |
rev: v1.24.2 | ||
hooks: | ||
- id: yamllint | ||
args: [-c=.yamllint] | ||
args: [-c=.yamllint, .] |
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,11 @@ | ||
# runtime-only no dissector yet | ||
|
||
This folder contains modified Lua kaitai-struct-compiler results, with modified runtime from github.com/kaitai-io/kaitai_struct_lua_runtime | ||
|
||
Install the runtime to wireshark using `mkdir -p ~/.local/lib/wireshark/plugins ; cp *.lua ~/.local/lib/wireshark/plugins` | ||
|
||
Baking the new .lua from .ksy will require you to modify the results, if there are any bitwise operations | ||
``` | ||
``` |
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,80 @@ | ||
-- | ||
-- Adapted from http://lua-users.org/wiki/ObjectOrientationTutorial | ||
-- | ||
-- The "class" function is called with one or more tables that specify the base | ||
-- classes. | ||
-- | ||
-- If the user provides an "_init" method, this will be used as the class | ||
-- constructor. | ||
-- | ||
-- Each class also provides Python-style properties, which are implemented as | ||
-- tables that provide a "get" and "set" method. | ||
-- | ||
|
||
local Class = {} | ||
|
||
function Class.class(...) | ||
-- "cls" is the new class | ||
local cls, bases = {}, {...} | ||
|
||
-- Copy base class contents into the new class | ||
for _, base in ipairs(bases) do | ||
for k, v in pairs(base) do | ||
cls[k] = v | ||
end | ||
end | ||
|
||
-- Class also provides Python-style properties. These are implemented as | ||
-- tables with a "get" and "set" method | ||
cls.property = {} | ||
|
||
function cls:__index(key) | ||
local property = cls.property[key] | ||
|
||
if property then | ||
return property.get(self) | ||
else | ||
return cls[key] | ||
end | ||
|
||
return member | ||
end | ||
|
||
function cls:__newindex(key, value) | ||
local property = cls.property[key] | ||
|
||
if property then | ||
return property.set(self, value) | ||
else | ||
return rawset(self, key, value) | ||
end | ||
end | ||
|
||
-- Start filling an "is_a" table that contains this class and all of its | ||
-- bases so you can do an "instance of" check using | ||
-- my_instance.is_a[MyClass] | ||
cls.is_a = { [cls] = true } | ||
for i, base in ipairs(bases) do | ||
for c in pairs(base.is_a) do | ||
cls.is_a[c] = true | ||
end | ||
cls.is_a[base] = true | ||
end | ||
|
||
-- The class's __call metamethod | ||
setmetatable(cls, { | ||
__call = function(c, ...) | ||
local instance = setmetatable({}, c) | ||
-- Run the "init" method if it's there | ||
local init = instance._init | ||
if init then init(instance, ...) end | ||
|
||
return instance | ||
end | ||
}) | ||
|
||
-- Return the new class table, that's ready to fill with methods | ||
return cls | ||
end | ||
|
||
return Class |
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,53 @@ | ||
-- This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild | ||
-- | ||
-- This file is compatible with Lua 5.3 | ||
|
||
local class = require("class") | ||
require("kaitaistruct") | ||
local enum = require("enum") | ||
|
||
require("radio_ip") | ||
DataDeliveryStates = class.class(KaitaiStruct) | ||
|
||
DataDeliveryStates.StateTypes = enum.Enum { | ||
location_protocol_state = 8, | ||
radio_registration_service_state = 17, | ||
telemetry_protocol_state = 18, | ||
data_transmit_protocol_state = 19, | ||
} | ||
|
||
DataDeliveryStates.Results = enum.Enum { | ||
ok = 0, | ||
fail = 1, | ||
limited_timeout = 4, | ||
no_ack = 5, | ||
error_ack = 6, | ||
repeater_wakeup_fail = 7, | ||
tx_interrupted = 8, | ||
tx_deny = 9, | ||
invalid_params = 10, | ||
} | ||
|
||
function DataDeliveryStates:_init(io, parent, root) | ||
KaitaiStruct._init(self, io) | ||
self._parent = parent | ||
self._root = root or self | ||
self:_read() | ||
end | ||
|
||
function DataDeliveryStates:_read() | ||
self.reserved = self._io:read_bytes(1) | ||
self.state_type = DataDeliveryStates.StateTypes(self._io:read_u1()) | ||
self.message_length = self._io:read_u2be() | ||
self.radio_ip = RadioIp(self._io) | ||
self.protocol_opcode = self._io:read_u2be() | ||
self.result = DataDeliveryStates.Results(self._io:read_u1()) | ||
end | ||
|
||
-- | ||
-- should be 0x00. | ||
-- | ||
-- length of the message from next field to the end of DDS message. | ||
-- | ||
-- state_type+protocol_opcode should correspond to sent message, that this status is about. | ||
|
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,182 @@ | ||
-- This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild | ||
-- | ||
-- This file is compatible with Lua 5.3 | ||
|
||
local class = require("class") | ||
require("kaitaistruct") | ||
local enum = require("enum") | ||
local str_decode = require("string_decode") | ||
|
||
require("radio_ip") | ||
DataTransmitProtocol = class.class(KaitaiStruct) | ||
|
||
DataTransmitProtocol.ServiceTypes = enum.Enum { | ||
data_transmit_protocol = 160, | ||
} | ||
|
||
DataTransmitProtocol.ServiceSpecificTypes = enum.Enum { | ||
dtp_request = 1, | ||
data_slice_trasmit = 2, | ||
last_data_slice = 3, | ||
dtp_answer = 17, | ||
data_slice_answer = 18, | ||
last_data_slice_answer = 19, | ||
} | ||
|
||
DataTransmitProtocol.Results = enum.Enum { | ||
success = 0, | ||
failure = 1, | ||
} | ||
|
||
function DataTransmitProtocol:_init(io, parent, root) | ||
KaitaiStruct._init(self, io) | ||
self._parent = parent | ||
self._root = root or self | ||
self:_read() | ||
end | ||
|
||
function DataTransmitProtocol:_read() | ||
self.service_type = DataTransmitProtocol.ServiceTypes(self._io:read_u1()) | ||
self.service_specific_type = DataTransmitProtocol.ServiceSpecificTypes(self._io:read_u1()) | ||
self.message_length = self._io:read_u2be() | ||
local _on = self.service_specific_type | ||
if _on == DataTransmitProtocol.ServiceSpecificTypes.dtp_request then | ||
self.data = DataTransmitProtocol.DtpRequest(self._io, self, self._root) | ||
elseif _on == DataTransmitProtocol.ServiceSpecificTypes.data_slice_transmit then | ||
self.data = DataTransmitProtocol.DataSliceTransmit(self._io, self, self._root) | ||
elseif _on == DataTransmitProtocol.ServiceSpecificTypes.data_slice_answer then | ||
self.data = DataTransmitProtocol.DataSliceAnswer(self._io, self, self._root) | ||
elseif _on == DataTransmitProtocol.ServiceSpecificTypes.last_data_slice_answer then | ||
self.data = DataTransmitProtocol.LastDataSliceAnswer(self._io, self, self._root) | ||
elseif _on == DataTransmitProtocol.ServiceSpecificTypes.dtp_answer then | ||
self.data = DataTransmitProtocol.DtpAnswer(self._io, self, self._root) | ||
elseif _on == DataTransmitProtocol.ServiceSpecificTypes.last_data_slice then | ||
self.data = DataTransmitProtocol.LastDataSlice(self._io, self, self._root) | ||
end | ||
end | ||
|
||
-- | ||
-- should be always 0xA0 Data Transmit Protocol. | ||
-- | ||
-- length of the message from next field to the end of DTP message. | ||
|
||
-- | ||
-- sent by transmit source, requires answer from the destination. | ||
DataTransmitProtocol.LastDataSlice = class.class(KaitaiStruct) | ||
|
||
function DataTransmitProtocol.LastDataSlice:_init(io, parent, root) | ||
KaitaiStruct._init(self, io) | ||
self._parent = parent | ||
self._root = root or self | ||
self:_read() | ||
end | ||
|
||
function DataTransmitProtocol.LastDataSlice:_read() | ||
self.destination_ip = RadioIp(self._io) | ||
self.source_ip = RadioIp(self._io) | ||
end | ||
|
||
-- | ||
-- transmit recipient ip. | ||
-- | ||
-- transmit sender ip. | ||
|
||
DataTransmitProtocol.DtpRequest = class.class(KaitaiStruct) | ||
|
||
function DataTransmitProtocol.DtpRequest:_init(io, parent, root) | ||
KaitaiStruct._init(self, io) | ||
self._parent = parent | ||
self._root = root or self | ||
self:_read() | ||
end | ||
|
||
function DataTransmitProtocol.DtpRequest:_read() | ||
self.destination_ip = RadioIp(self._io) | ||
self.source_ip = RadioIp(self._io) | ||
self.file_size = self._io:read_u2be() | ||
self.file_name = str_decode.decode(self._io:read_bytes((self._parent.message_length - 10)), "UTF16-LE") | ||
end | ||
|
||
-- | ||
-- size in bytes. | ||
-- | ||
-- maximum of 256 bytes including file extension, if longer, recipient should refuse the transmission. | ||
|
||
DataTransmitProtocol.DataSliceAnswer = class.class(KaitaiStruct) | ||
|
||
function DataTransmitProtocol.DataSliceAnswer:_init(io, parent, root) | ||
KaitaiStruct._init(self, io) | ||
self._parent = parent | ||
self._root = root or self | ||
self:_read() | ||
end | ||
|
||
function DataTransmitProtocol.DataSliceAnswer:_read() | ||
self.destination_ip = RadioIp(self._io) | ||
self.source_ip = RadioIp(self._io) | ||
self.block_number = self._io:read_u2be() | ||
self.result = DataTransmitProtocol.Results(self._io:read_u1()) | ||
end | ||
|
||
-- | ||
-- sequence number in transfer, same as data_slice_transmit.block_number the response is for. | ||
-- | ||
-- result of transmit from receiving end. | ||
|
||
DataTransmitProtocol.DataSliceTransmit = class.class(KaitaiStruct) | ||
|
||
function DataTransmitProtocol.DataSliceTransmit:_init(io, parent, root) | ||
KaitaiStruct._init(self, io) | ||
self._parent = parent | ||
self._root = root or self | ||
self:_read() | ||
end | ||
|
||
function DataTransmitProtocol.DataSliceTransmit:_read() | ||
self.destination_ip = RadioIp(self._io) | ||
self.source_ip = RadioIp(self._io) | ||
self.block_number = self._io:read_u2be() | ||
self.file_data = self._io:read_bytes((self._parent.message_length - 10)) | ||
end | ||
|
||
-- | ||
-- sequence number in transfer, starting with 1. | ||
-- | ||
-- 448 bytes slice of transmitted file, or shorter if current slice is the last one. | ||
|
||
DataTransmitProtocol.LastDataSliceAnswer = class.class(KaitaiStruct) | ||
|
||
function DataTransmitProtocol.LastDataSliceAnswer:_init(io, parent, root) | ||
KaitaiStruct._init(self, io) | ||
self._parent = parent | ||
self._root = root or self | ||
self:_read() | ||
end | ||
|
||
function DataTransmitProtocol.LastDataSliceAnswer:_read() | ||
self.destination_ip = RadioIp(self._io) | ||
self.source_ip = RadioIp(self._io) | ||
self.result = DataTransmitProtocol.Results(self._io:read_u1()) | ||
end | ||
|
||
-- | ||
-- transmit sender ip. | ||
-- | ||
-- transmit recipient ip. | ||
|
||
DataTransmitProtocol.DtpAnswer = class.class(KaitaiStruct) | ||
|
||
function DataTransmitProtocol.DtpAnswer:_init(io, parent, root) | ||
KaitaiStruct._init(self, io) | ||
self._parent = parent | ||
self._root = root or self | ||
self:_read() | ||
end | ||
|
||
function DataTransmitProtocol.DtpAnswer:_read() | ||
self.destination_ip = RadioIp(self._io) | ||
self.source_ip = RadioIp(self._io) | ||
self.result = DataTransmitProtocol.Results(self._io:read_u1()) | ||
end | ||
|
||
|
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,24 @@ | ||
-- This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild | ||
-- | ||
-- This file is compatible with Lua 5.3 | ||
|
||
local class = require("class") | ||
require("kaitaistruct") | ||
local str_decode = require("string_decode") | ||
|
||
-- | ||
-- time in format yyyyMMddhhmmss, timezone GMT | ||
Datetimestring = class.class(KaitaiStruct) | ||
|
||
function Datetimestring:_init(io, parent, root) | ||
KaitaiStruct._init(self, io) | ||
self._parent = parent | ||
self._root = root or self | ||
self:_read() | ||
end | ||
|
||
function Datetimestring:_read() | ||
self.datetime = str_decode.decode(self._io:read_bytes(14), "UTF-8") | ||
end | ||
|
||
|
Oops, something went wrong.