Has anyone been able to successfull开发者_C百科y use a pcap library for Ruby 1.9.2 (via rvm) on Mac OS X 10.6?
I have tried pcaprub and it seems to not behave well on Mac OS X and the pcap gem isn't compatible with ruby 1.9.2.
There's definitely some problems building the native extension stuff for the pcap gem on ruby 1.9.2 (I'm on patch 180). Mostly you can get it working by changing RUBYSTR(foo)->ptr to RUBYSTR_PTR(foo) -- that's fairly easy to macro away when you see gcc complaining.
The real problem for me is that it's blocking after the initial call in pcap_loop. I initially was able to get it to do the right thing, but it doesn't want to use the correct timeout. If I can get it working right, I'll definitely be pushing changes upstream.
Edit: see my comments here to get it building on 10.6.
Edit2: I've forked ruby-pcap and got it working on ruby 1.9.2 @ patch 180 on Mac OS X 10.6.7; I will be submitting a pull request to the gem shortly. In the meantime, you can get it here
精彩评论