Ask Your Question

Revision history [back]

lua script for 80211ah

Hi I am currently trying to write a Lua dissector as a plugin on wireshark, but a problem came out String[......]:3:Bad argument #2 to 'Proto' (Proto_new:there can not be two protocols with the same description)

here are my codes, please help me to fix this problem ,thanks a lot!!

do --Create a new dissector PROTO_80211ah = Proto("80211ah","IEEE80211ah")

--IEEE 802.11ah QoS Data
local f_80211ah_Type                = ProtoField.bytes("80211ah.Type","Type")
local f_80211ah_FrameControlField       = ProtoField.bytes("80211ah.FrameControlField","FrameControlField")
--local f_80211ah_Duration          = ProtoField.bytes("80211ah.Duration","Duration")
local f_80211ah_ReceiverAddress         = ProtoField.bytes("80211ah.ReceiverAddress","ReceiverAddress")
local f_80211ah_DestinationAddress      = ProtoField.bytes("80211ah.DestinationAddress","DestinationAddress")
local f_80211ah_TransmitterAddress      = ProtoField.bytes("80211ah.TransmitterAddress","TransmitterAddress")
local f_80211ah_SourceAddress           = ProtoField.bytes("80211ah.SourceAddress","SourceAddress")
local f_80211ah_BSSID               = ProtoField.bytes("80211ah.BSSID","BSSID" )
local f_80211ah_StaAddress          = ProtoField.bytes("80211ah.StaAddress","StaAddress")
--local f_80211ah_FragmentNumber        = ProtoField.bytes("80211ah.FragmentNumber","FragmentNumber")
--local f_80211ah_SequenceNumber        = ProtoField.bytes("80211ah.SequenceNumber","SequenceNumber")
local f_80211ah_QoSControl          = ProtoField.bytes("80211ah.QoSControl","QoSControl")

local f_80211ah_LogicLinkControl        = ProtoField.bytes("80211ah.LogicLinkControl","LogicLinkControl")

--Internet Protocol Version 4 
local f_80211ah_DifferentiatedServicesField     = ProtoField.bytes("80211ah.DifferentiatedServicesField","DifferentiatedServicesField")
local f_80211ah_TotalLength         = ProtoField.bytes("80211ah.TotalLength","TotalLength")
local f_80211ah_Identification          = ProtoField.bytes("80211ah.Identification","Identification")
local f_80211ah_Flags               = ProtoField.bytes("80211ah.Flags","Flags")
local f_80211ah_FragmentOffest          = ProtoField.bytes("80211ah.FragmentOffest","FragmentOffest")
local f_80211ah_TimeToLive          = ProtoField.bytes("80211ah.TimeToLive","TimeToLive")
local f_80211ah_Protocol            = ProtoField.bytes("80211ah.Protocol","Protocol")
local f_80211ah_HeaderChecksum          = ProtoField.bytes("80211ah.HeaderChecksum","HeaderChecksum")
local f_80211ah_Source              = ProtoField.bytes("80211ah.Source","Source")
local f_80211ah_Destination         = ProtoField.bytes("80211ah.Destination","Destination")

--802.11ah Protocol
local f_80211ah_SourcePort          = ProtoField.bytes("80211ah.SourcePort","SourcePort")
local f_80211ah_DestinationPort         = ProtoField.bytes("80211ah.DestinationPort","DestinationPort")
local f_80211ah_Length              = ProtoField.bytes("80211ah.Length","Length")


PROTO_80211ah.fields={f_80211ah_Type,f_80211ah_FrameControlField, f_80211ah_Duration, f_80211ah_ReceiverAddress, f_80211ah_DestinationAddress, f_80211ah_TransmitterAddress, f_80211ah_SourceAddress, f_80211ah_BSSID, f_80211ah_StaAddress, f_80211ah_FragmentNumber, f_80211ah_SequenceNumber, f_80211ah_QoSControl, f_80211ah_LogicLinkControl, f_80211ah_DifferentiatedServicesField, f_80211ah_TotalLength, f_80211ah_Identification, f_80211ah_Flags, f_80211ah_FragmentOffest, f_80211ah_TimeToLive, f_80211ah_Protocol, f_80211ah_HeaderChecksum, f_80211ah_Source, f_80211ah_Destination, f_80211ah_SourcePort, f_80211ah_DestinationPort, f_80211ah_Length}

local data_dis = Dissector.get("data")
--The Dissector function
function PROTO_80211ah.dissector (buffer,pinfo,tree)
    length = buffer:len()
    if length == 0 then return end


    --show protocol name in protocol column
    pinfo.cols.protocol = PROTO_80211ah.name

    local subtree = tree:add(PROTO_80211ah, buffer(), "80211ah Protocol Data")

    --dissect field one by one , and add to protocol tree

    subtree:add_le(Type,buffer(0,1))
    subtree:add_le(FrameControlField,buffer(0,2))
    subtree:add_le(Duration,buffer(3,4))
    subtree:add_le(ReceiverAddress,buffer(5,10))
    subtree:add_le(DestinationAddress,buffer(17,22))
    subtree:add_le(TransmitterAddress,buffer(11,16))
    subtree:add_le(SourceAddress,buffer(11,16))
    subtree:add_le(BSSID,buffer(5,10))
    subtree:add_le(StaAddress,buffer(11,16))    
    subtree:add_le(FragmentNumber,buffer(23,24))
    subtree:add_le(SequenceNumber,buffer(23,24))
    subtree:add_le(QoSControl,buffer(25,26))
    subtree:add_le(LogicalLinkControl,buffer(27,34))    
    subtree:add_le(version,buffer(34,35))
    subtree:add_le(HeaderLength,buffer(34,35))
    subtree:add_le(DifferentiatedServicesField,buffer(35,36))
    subtree:add_le(TotalLength,buffer(37,38))
    subtree:add_le(Identification,buffer(39,40))
    subtree:add_le(Flags,buffer(41,41))
    subtree:add_le(FragmentOffset,buffer(41,42))
    subtree:add_le(TimeToLive,buffer(43,43))
    subtree:add_le(Protocol,buffer(44,44))
    subtree:add_le(HeaderChecksum,buffer(45,46))
    subtree:add_le(Source,buffer(47,50))
    subtree:add_le(Destination,buffer(51,54))
    subtree:add_le(SourcePort,buffer(55,56))
    subtree:add_le(DestinationPort,buffer(57,58))
    subtree:add_le(Length,buffer(59,60))



end

local udp_port = DissectorTable.get("udp.port"):add(9999,PROTO_80211ah) end

lua script for 80211ah

Hi I am currently trying to write a Lua dissector as a plugin on wireshark, but a problem came out String[......]:3:Bad argument #2 to 'Proto' (Proto_new:there can not be two protocols with the same description)

here are my codes, please help me to fix this problem ,thanks a lot!!

do
 --Create a new dissector 
 PROTO_80211ah = Proto("80211ah","IEEE80211ah")

Proto("80211ah","IEEE80211ah")


--IEEE 802.11ah QoS Data
local f_80211ah_Type                = ProtoField.bytes("80211ah.Type","Type")
local f_80211ah_FrameControlField       = ProtoField.bytes("80211ah.FrameControlField","FrameControlField")
--local f_80211ah_Duration          = ProtoField.bytes("80211ah.Duration","Duration")
local f_80211ah_ReceiverAddress         = ProtoField.bytes("80211ah.ReceiverAddress","ReceiverAddress")
local f_80211ah_DestinationAddress      = ProtoField.bytes("80211ah.DestinationAddress","DestinationAddress")
local f_80211ah_TransmitterAddress      = ProtoField.bytes("80211ah.TransmitterAddress","TransmitterAddress")
local f_80211ah_SourceAddress           = ProtoField.bytes("80211ah.SourceAddress","SourceAddress")
local f_80211ah_BSSID               = ProtoField.bytes("80211ah.BSSID","BSSID" )
local f_80211ah_StaAddress          = ProtoField.bytes("80211ah.StaAddress","StaAddress")
--local f_80211ah_FragmentNumber        = ProtoField.bytes("80211ah.FragmentNumber","FragmentNumber")
--local f_80211ah_SequenceNumber        = ProtoField.bytes("80211ah.SequenceNumber","SequenceNumber")
local f_80211ah_QoSControl          = ProtoField.bytes("80211ah.QoSControl","QoSControl")

local f_80211ah_LogicLinkControl        = ProtoField.bytes("80211ah.LogicLinkControl","LogicLinkControl")

--Internet Protocol Version 4 
local f_80211ah_DifferentiatedServicesField     = ProtoField.bytes("80211ah.DifferentiatedServicesField","DifferentiatedServicesField")
local f_80211ah_TotalLength         = ProtoField.bytes("80211ah.TotalLength","TotalLength")
local f_80211ah_Identification          = ProtoField.bytes("80211ah.Identification","Identification")
local f_80211ah_Flags               = ProtoField.bytes("80211ah.Flags","Flags")
local f_80211ah_FragmentOffest          = ProtoField.bytes("80211ah.FragmentOffest","FragmentOffest")
local f_80211ah_TimeToLive          = ProtoField.bytes("80211ah.TimeToLive","TimeToLive")
local f_80211ah_Protocol            = ProtoField.bytes("80211ah.Protocol","Protocol")
local f_80211ah_HeaderChecksum          = ProtoField.bytes("80211ah.HeaderChecksum","HeaderChecksum")
local f_80211ah_Source              = ProtoField.bytes("80211ah.Source","Source")
local f_80211ah_Destination         = ProtoField.bytes("80211ah.Destination","Destination")

--802.11ah Protocol
local f_80211ah_SourcePort          = ProtoField.bytes("80211ah.SourcePort","SourcePort")
local f_80211ah_DestinationPort         = ProtoField.bytes("80211ah.DestinationPort","DestinationPort")
local f_80211ah_Length              = ProtoField.bytes("80211ah.Length","Length")


PROTO_80211ah.fields={f_80211ah_Type,f_80211ah_FrameControlField, f_80211ah_Duration, f_80211ah_ReceiverAddress, f_80211ah_DestinationAddress, f_80211ah_TransmitterAddress, f_80211ah_SourceAddress, f_80211ah_BSSID, f_80211ah_StaAddress, f_80211ah_FragmentNumber, f_80211ah_SequenceNumber, f_80211ah_QoSControl, f_80211ah_LogicLinkControl, f_80211ah_DifferentiatedServicesField, f_80211ah_TotalLength, f_80211ah_Identification, f_80211ah_Flags, f_80211ah_FragmentOffest, f_80211ah_TimeToLive, f_80211ah_Protocol, f_80211ah_HeaderChecksum, f_80211ah_Source, f_80211ah_Destination, f_80211ah_SourcePort, f_80211ah_DestinationPort, f_80211ah_Length}

local data_dis = Dissector.get("data")
--The Dissector function
function PROTO_80211ah.dissector (buffer,pinfo,tree)
    length = buffer:len()
    if length == 0 then return end


    --show protocol name in protocol column
    pinfo.cols.protocol = PROTO_80211ah.name

    local subtree = tree:add(PROTO_80211ah, buffer(), "80211ah Protocol Data")

    --dissect field one by one , and add to protocol tree

    subtree:add_le(Type,buffer(0,1))
    subtree:add_le(FrameControlField,buffer(0,2))
    subtree:add_le(Duration,buffer(3,4))
    subtree:add_le(ReceiverAddress,buffer(5,10))
    subtree:add_le(DestinationAddress,buffer(17,22))
    subtree:add_le(TransmitterAddress,buffer(11,16))
    subtree:add_le(SourceAddress,buffer(11,16))
    subtree:add_le(BSSID,buffer(5,10))
    subtree:add_le(StaAddress,buffer(11,16))    
    subtree:add_le(FragmentNumber,buffer(23,24))
    subtree:add_le(SequenceNumber,buffer(23,24))
    subtree:add_le(QoSControl,buffer(25,26))
    subtree:add_le(LogicalLinkControl,buffer(27,34))    
    subtree:add_le(version,buffer(34,35))
    subtree:add_le(HeaderLength,buffer(34,35))
    subtree:add_le(DifferentiatedServicesField,buffer(35,36))
    subtree:add_le(TotalLength,buffer(37,38))
    subtree:add_le(Identification,buffer(39,40))
    subtree:add_le(Flags,buffer(41,41))
    subtree:add_le(FragmentOffset,buffer(41,42))
    subtree:add_le(TimeToLive,buffer(43,43))
    subtree:add_le(Protocol,buffer(44,44))
    subtree:add_le(HeaderChecksum,buffer(45,46))
    subtree:add_le(Source,buffer(47,50))
    subtree:add_le(Destination,buffer(51,54))
    subtree:add_le(SourcePort,buffer(55,56))
    subtree:add_le(DestinationPort,buffer(57,58))
    subtree:add_le(Length,buffer(59,60))

 end 

local udp_port = DissectorTable.get("udp.port"):add(9999,PROTO_80211ah)
end

local udp_port = DissectorTable.get("udp.port"):add(9999,PROTO_80211ah) end

lua script for 80211ah

Hi I am currently trying to write a Lua dissector as a plugin on wireshark, but a problem came out String[......]:3:Bad argument #2 to 'Proto' (Proto_new:there can not be two protocols with the same description)

here are my codes, please help me to fix this problem ,thanks a lot!!

do
--Create a new dissector 
PROTO_80211ah = Proto("80211ah","IEEE80211ah")


--IEEE 802.11ah QoS Data
local f_80211ah_Type                = ProtoField.bytes("80211ah.Type","Type")
local f_80211ah_FrameControlField       = ProtoField.bytes("80211ah.FrameControlField","FrameControlField")
--local f_80211ah_Duration          = ProtoField.bytes("80211ah.Duration","Duration")
local f_80211ah_ReceiverAddress         = ProtoField.bytes("80211ah.ReceiverAddress","ReceiverAddress")
local f_80211ah_DestinationAddress      = ProtoField.bytes("80211ah.DestinationAddress","DestinationAddress")
local f_80211ah_TransmitterAddress      = ProtoField.bytes("80211ah.TransmitterAddress","TransmitterAddress")
local f_80211ah_SourceAddress           = ProtoField.bytes("80211ah.SourceAddress","SourceAddress")
local f_80211ah_BSSID               = ProtoField.bytes("80211ah.BSSID","BSSID" )
local f_80211ah_StaAddress          = ProtoField.bytes("80211ah.StaAddress","StaAddress")
--local f_80211ah_FragmentNumber        = ProtoField.bytes("80211ah.FragmentNumber","FragmentNumber")
--local f_80211ah_SequenceNumber        = ProtoField.bytes("80211ah.SequenceNumber","SequenceNumber")
local f_80211ah_QoSControl          = ProtoField.bytes("80211ah.QoSControl","QoSControl")

local f_80211ah_LogicLinkControl        = ProtoField.bytes("80211ah.LogicLinkControl","LogicLinkControl")

--Internet Protocol Version 4 
local f_80211ah_DifferentiatedServicesField     = ProtoField.bytes("80211ah.DifferentiatedServicesField","DifferentiatedServicesField")
local f_80211ah_TotalLength         = ProtoField.bytes("80211ah.TotalLength","TotalLength")
local f_80211ah_Identification          = ProtoField.bytes("80211ah.Identification","Identification")
local f_80211ah_Flags               = ProtoField.bytes("80211ah.Flags","Flags")
local f_80211ah_FragmentOffest          = ProtoField.bytes("80211ah.FragmentOffest","FragmentOffest")
local f_80211ah_TimeToLive          = ProtoField.bytes("80211ah.TimeToLive","TimeToLive")
local f_80211ah_Protocol            = ProtoField.bytes("80211ah.Protocol","Protocol")
local f_80211ah_HeaderChecksum          = ProtoField.bytes("80211ah.HeaderChecksum","HeaderChecksum")
local f_80211ah_Source              = ProtoField.bytes("80211ah.Source","Source")
local f_80211ah_Destination         = ProtoField.bytes("80211ah.Destination","Destination")

--802.11ah Protocol
local f_80211ah_SourcePort          = ProtoField.bytes("80211ah.SourcePort","SourcePort")
local f_80211ah_DestinationPort         = ProtoField.bytes("80211ah.DestinationPort","DestinationPort")
local f_80211ah_Length              = ProtoField.bytes("80211ah.Length","Length")


PROTO_80211ah.fields={f_80211ah_Type,f_80211ah_FrameControlField, f_80211ah_Duration, f_80211ah_ReceiverAddress, f_80211ah_DestinationAddress, f_80211ah_TransmitterAddress, f_80211ah_SourceAddress, f_80211ah_BSSID, f_80211ah_StaAddress, f_80211ah_FragmentNumber, f_80211ah_SequenceNumber, f_80211ah_QoSControl, f_80211ah_LogicLinkControl, f_80211ah_DifferentiatedServicesField, f_80211ah_TotalLength, f_80211ah_Identification, f_80211ah_Flags, f_80211ah_FragmentOffest, f_80211ah_TimeToLive, f_80211ah_Protocol, f_80211ah_HeaderChecksum, f_80211ah_Source, f_80211ah_Destination, f_80211ah_SourcePort, f_80211ah_DestinationPort, f_80211ah_Length}

local data_dis = Dissector.get("data")
--The Dissector function
function PROTO_80211ah.dissector (buffer,pinfo,tree)
    length = buffer:len()
    if length == 0 then return end


    --show protocol name in protocol column
    pinfo.cols.protocol = PROTO_80211ah.name

    local subtree = tree:add(PROTO_80211ah, buffer(), "80211ah Protocol Data")

    --dissect field one by one , and add to protocol tree

    subtree:add_le(Type,buffer(0,1))
    subtree:add_le(FrameControlField,buffer(0,2))
    subtree:add_le(Duration,buffer(3,4))
    subtree:add_le(ReceiverAddress,buffer(5,10))
    subtree:add_le(DestinationAddress,buffer(17,22))
    subtree:add_le(TransmitterAddress,buffer(11,16))
    subtree:add_le(SourceAddress,buffer(11,16))
    subtree:add_le(BSSID,buffer(5,10))
    subtree:add_le(StaAddress,buffer(11,16))    
    subtree:add_le(FragmentNumber,buffer(23,24))
    subtree:add_le(SequenceNumber,buffer(23,24))
    subtree:add_le(QoSControl,buffer(25,26))
    subtree:add_le(LogicalLinkControl,buffer(27,34))    
    subtree:add_le(version,buffer(34,35))
    subtree:add_le(HeaderLength,buffer(34,35))
    subtree:add_le(DifferentiatedServicesField,buffer(35,36))
    subtree:add_le(TotalLength,buffer(37,38))
    subtree:add_le(Identification,buffer(39,40))
    subtree:add_le(Flags,buffer(41,41))
    subtree:add_le(FragmentOffset,buffer(41,42))
    subtree:add_le(TimeToLive,buffer(43,43))
    subtree:add_le(Protocol,buffer(44,44))
    subtree:add_le(HeaderChecksum,buffer(45,46))
    subtree:add_le(Source,buffer(47,50))
    subtree:add_le(Destination,buffer(51,54))
    subtree:add_le(SourcePort,buffer(55,56))
    subtree:add_le(DestinationPort,buffer(57,58))
    subtree:add_le(Length,buffer(59,60))

end 

local udp_port = DissectorTable.get("udp.port"):add(9999,PROTO_80211ah)
end