prlayer.rb
# ------------------------------------------------------------------
# prlayer.rb	Print all protocol layers in a given packet
#	usage : prlayer <capture-file> <pktid> 
#
#
# ------------------------------------------------------------------
require 'win32ole'
 
USAGE = "prlayer <capture-filename> <pkt-id>"
 
if ARGV.length != 2
	puts USAGE
	exit 1
end
 
InputFile = ARGV[0]
PktId     = ARGV[1]
UnsniffDB = WIN32OLE.new("Unsniff.Database")
UnsniffDB.Open(InputFile)
 
 
Packet = UnsniffDB.PacketIndex.Item(PktId)
layers = Packet.Layers
print "Number of layers in packet #{PktId} is #{layers.Count}\n"
layers.each do |lyr| 
	print "\t#{lyr.Name}\t#{lyr.Size}\t#{lyr.ProtID}\n"
end
 
UnsniffDB.Close()