LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 03-06-2009, 01:33 PM   #1
trist007
Senior Member
 
Registered: May 2008
Distribution: Slackware
Posts: 1,052

Rep: Reputation: 70
I'm having trouble with pcap...


I've been trying to make this ruby script work

#!/usr/bin/env ruby

# this line imports the libpcap ruby bindings
require 'pcaplet'

# create a sniffer that grabs the first 1500 bytes of each packet
$network = Pcaplet.new('-s 1500')

# create a filter that uses our query string and the sniffer we just made
$filter = Pcap::Filter.new('tcp and dst port 80', $network.capture)

# add the new filter to the sniffer
$network.add_filter($filter)

# iterate over every packet that goes through the sniffer for p in the $network
# print packet data for each packet that matches the filter
puts p.tcp_data if $filter =~ p
$end

but I end up getting this when I try and run it

/usr/lib/ruby/site_ruby/1.8/i486-linux/pcap.so: warning: do not use Fixnums as Symbols
/usr/lib/ruby/site_ruby/1.8/i486-linux/pcap.so: warning: do not use Fixnums as Symbols
/usr/lib/ruby/site_ruby/1.8/i486-linux/pcap.so: warning: do not use Fixnums as Symbols
packet_filter.rb:17:in `=~': wrong type NilClass (expected Pcap::Packet) (TypeError)
from packet_filter.rb:17

So I downloaded ruby-1.8.6-i486-1.tgz and the ruby-1.8.6_p287-i486-1_slack12.0.tgz to make sure I was fully updated. I installpkg ruby-1.8.6-i486.tgz and then the ruby-1.8.6_p287-i486-1_slack12.0.tgz(patch).

Still I had the same problem so I googled for a bit and found a patch(not sure if it did what ruby-1.8.6_p287-i486-1_slack12.0.tgz did, but I figured it was worth a shot.

So I downloaded the source for pcap ruby-pcap-0.6.tar.gz along with this patch

[trist007@bt:~/downloads]$ cat patch-Pcap.c
--- patch-Pcap.c begins here ---
--- Pcap.c.orig 2008-05-01 15:26:25.000000000 -0500
+++ Pcap.c 2008-05-01 15:27:21.000000000 -0500
@@ -782,9 +782,9 @@
/* define class PcapStat */
cPcapStat = rb_funcall(rb_cStruct, rb_intern("new"), 4,
Qnil,
- INT2NUM(rb_intern("recv")),
- INT2NUM(rb_intern("drop")),
- INT2NUM(rb_intern("ifdrop")));
+ ID2SYM(rb_intern("recv")),
+ ID2SYM(rb_intern("drop")),
+ ID2SYM(rb_intern("ifdrop")));
rb_define_const(mPcap, "Stat", cPcapStat);

/* define exception classes */
--- patch-Pcap.c ends here ---


So then I do this
tar -xvvzf ruby-pcap-0.6.tar.gz
cd pcap
mv ~/patch patch-Pcap.c .
patch -u -o patch-Pcap Pcap.c patch-Pcap.c
# says patching file
ruby extconf.rb #which configures it
make
make install
# no errors get passed

Then I run the script again, and I get that same error from above. No change at all. Any thoughts?
 
Old 03-10-2009, 11:03 AM   #2
trist007
Senior Member
 
Registered: May 2008
Distribution: Slackware
Posts: 1,052

Original Poster
Rep: Reputation: 70
bump
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
PCAP library ani09 Linux - Networking 1 12-12-2007 08:12 AM
pcap error ilnli Programming 2 05-26-2007 06:47 PM
Programming w/ pcap Rawjoe Programming 2 12-07-2006 08:55 AM
Pcap Files OriDagan Linux - Networking 0 07-15-2005 04:20 AM
pcap library jagman Programming 1 04-27-2005 07:35 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 02:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration