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.