ruby libpcap fails when passing command-line argument

K

kenny roytman

Hi,

Can someone please help me out here? I'm trying to use Ruby/Libpcap
extension to write a rudimentary packet sniffer.

I downloaded ruby/libpcap 0.6 from http://www.goto.info.waseda.ac.jp/~fukusima/ruby/pcap-e.html.

The following code breaks when calling it from the command-line with a
parameter, such as:

$>ruby dumptraffic.rb en1
/usr/local/lib/ruby/site_ruby/1.8/universal-darwin8.0/pcap.bundle:
warning: do not use Fixnums as Symbols
/usr/local/lib/ruby/site_ruby/1.8/universal-darwin8.0/pcap.bundle:
warning: do not use Fixnums as Symbols
/usr/local/lib/ruby/site_ruby/1.8/universal-darwin8.0/pcap.bundle:
warning: do not use Fixnums as Symbols
setfilter: parse error
$>

The code:

------- start of code

require 'pcaplet'

include Pcap

class Sniffer
def sniff(d)
pcaplet = Pcaplet.new("-i " + d)
c = pcaplet.capture
d = Dumper.open(c,"dump.txt")

c.each_packet(50) { |pkt|
if pkt.ip?
d.dump(pkt)
puts "hello from #{pkt.src.to_num_s}"
end
}

pcaplet.close
end
end

if __FILE__ == $0
d = ARGV[0]
sniffit = Sniffer.new
sniffit.sniff(d)
end


---- end of code

Any help would be greatly appreciated. Thanks.

- kenny r.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top