红宝石 1.9.2 + Mac OS X 上的 pcap
有没有人能够在 Mac OS X 10.6 上成功使用 Ruby 1.9.2(通过 rvm)的 pcap 库?
我尝试过 pcaprub,它似乎在 Mac OS X 上表现不佳,而且 pcap gem 与 ruby 1.9.2 不兼容。
Has anyone been able to successfully 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 ruby 1.9.2 上为 pcap gem 构建本机扩展内容肯定存在一些问题(我正在使用补丁 180)。大多数情况下,您可以通过将 RUBYSTR(foo)->ptr 更改为 RUBYSTR_PTR(foo) 来使其工作——当您看到 gcc 抱怨时,这很容易宏化。
对我来说真正的问题是它在 pcap_loop 中的初始调用之后被阻塞。我最初能够让它做正确的事情,但它不想使用正确的超时。如果我能让它正常工作,我肯定会向上游推动更改。
编辑:请参阅我的评论此处让它建立在 10.6 上。
Edit2:我已经分叉了 ruby-pcap 并让它在 Mac OS X 10.6.7 上的 ruby 1.9.2 @ patch 180 上工作;我很快就会向 gem 提交拉取请求。同时,您可以在此处获取它
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