Add Wireshark packet dissector plugin and associated tools

This commit is contained in:
Allen Hill
2024-08-23 11:02:40 -07:00
parent fadd2c4259
commit e857bbb09f
26 changed files with 1475 additions and 0 deletions
@@ -0,0 +1,25 @@
"""
Record of pcap data
"""
struct PcapRecord
header::RecordHeader
timestamp::UnixTime
underlying_data::Vector{UInt8}
record_offset::Int
end
@inline function record_field_(x::PcapRecord, ::Val{:data})
offset = getfield(x, :record_offset) + sizeof(RecordHeader)
len = Int(getfield(x, :header).incl_len)
UnsafeArray{UInt8, 1}(pointer(getfield(x, :underlying_data)) + offset, (len,))
end
@inline function record_field_(x::PcapRecord, ::Val{:raw})
offset = getfield(x, :record_offset)
len = sizeof(RecordHeader) + getfield(x, :header).incl_len
UnsafeArray{UInt8, 1}(pointer(getfield(x, :underlying_data)) + offset, (len,))
end
@inline record_field_(x::PcapRecord, ::Val{f}) where {f} = getfield(x, f)
@inline Base.getproperty(x::PcapRecord, f::Symbol) = record_field_(x, Val(f))