Ask Your Question
0

lua script for 80211ah

asked 2018-06-14 02:34:59 +0000

TingHsu gravatar image

updated 2018-06-21 17:50:43 +0000

grahamb gravatar image

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 ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-06-14 14:04:28 +0000

cmaynard gravatar image

String[......]:3:Bad argument #2 to 'Proto' (Proto_new:there can not be two protocols with the same description)

I guess the problem is related to this line:

PROTO_80211ah = Proto("80211ah","IEEE80211ah")

So do you have another Lua dissector whose protocol description as the same as "IEEE80211ah"?

edit flag offensive delete link more

Comments

Hi this dissector is the only one i have in Wireshark and there wasn't any protocol description as the same as "IEEE80211ah" so this problem bothered me for a long time

TingHsu gravatar imageTingHsu ( 2018-06-21 02:29:48 +0000 )edit

@grahamb Hello sir First thank you for helping me about the codes but the problem still occur Can you give me your email and I can send you some screenshots about the question?

TingHsu gravatar imageTingHsu ( 2018-06-28 14:06:35 +0000 )edit

I copy/pasted your lua dissector into a file and then started Wireshark; it successfully loaded without any problem.

Do you see another 80211ah plugin dissector listed if you navigate to Wireshark's Help -> About Wireshark -> Plugins dialog? Or what about: Analyze -> Enabled Protocols... -> Search: 80211ah?

cmaynard gravatar imagecmaynard ( 2018-06-28 17:12:32 +0000 )edit

@cmaynard Yes I've searched both way and there is only one plugin/protocol called 80211ah may I ask you what system do you use when you test my codes? I use ns-3 system

TingHsu gravatar imageTingHsu ( 2018-06-29 02:06:19 +0000 )edit

I'm running Wireshark 2.6.1 on Windows 10 (64-bit).

cmaynard gravatar imagecmaynard ( 2018-06-29 02:10:21 +0000 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2018-06-14 02:34:59 +0000

Seen: 67 times

Last updated: Jun 21