ANNOUNCEMENT: Live Wireshark University & Allegro Packets online APAC Wireshark Training Session
April 17th, 2024 | 14:30-16:00 SGT (UTC+8) | Online

Wireshark-users: [Wireshark-users] Obtain ip address in lua script

From: Awadhesh Kumar <awadhesh.usa@xxxxxxxxx>
Date: Mon, 12 Oct 2009 14:29:02 +0530
Hi,

I have written LUA scripts which dissect proprietary packets from network. I had written the lua scripts as

-- declare our protocol
InDirectnip_proto = Proto("INIPD","NIP","NIP Messages")

-- create a function to dissect it
function InDirectnip_proto.dissector(buffer,pinfo,tree)
    pinfo.cols.protocol = "INIPD"
end


-- load the udp.port table
udp_table = DissectorTable.get("udp.port")

-- register caicd direct mip protocol to handle udp port 50019
udp_table:add(50013,InDirectnip_proto)

I need help to get the following

a) How can I get the source ip address of packets in this script file


I tried to get the ip address as

print(Field.new("ip.addr"))

but i got the error "A Field extractor must be defined before Taps or Dissectors get called" in wireshark. Please help me how to define extarctor before dissectors gets called.

b) is there any way to register multiple udp port in single lua file?




Thanks in Advance
Awadhesh.