ahobson / ruby-pcap

Ruby interface to LBL Packet Capture library.
http://www.goto.info.waseda.ac.jp/~fukusima/ruby/pcap-e.html
GNU General Public License v2.0
76 stars 32 forks source link

Fixes to make this gem run with ruby 1.9.2@p180 on Mac OS X 10.6.7. #4

Closed tjarratt closed 13 years ago

tjarratt commented 13 years ago

First off, I really like this gem an awful lot, but it was really frustrating not being able to use it with ruby 1.9.2 on OS X 10.6, so I spent some time over the weekend digging into the c-extension and made it work as best as I could. There are three areas that I think should be addressed.

1) rubysig.h is deprecated. AFAIK, there isn't a better way of writing c extensions that doesn't involve FFI. There does not appear to be any changes to TRAP_BEG or TRAP_END in ruby 1.9, although that is where the problems stem from. Is there a better way of handling this in ruby 1.9 that I'm not aware of? Surely there are other gems that use TRAP_BEG and TRAP_END in ruby 1.9.

2) The main problem is that calling TRAP_END after reading available packets on the file descriptor blocks forever -- sampling the process at this point shows that it's blocking on something that may never return. The trace looks like this:

__semwait_signal(0x110B, 0x100B, 0x1) = -1 Err#60 (this message repeated many, many times)

3) Another, smaller issue is that the wrapper around the c extension would catch any interrupt signals - this is not desirable for most processes. Perhaps there should be an optional flag to do this?

tjarratt commented 13 years ago

Oh, hmm. I had only originally planned for the first two commits (up to abc829e) for the pull request.

The other two commits are just a little cleanup and adding some nice to have features - namely parsing the mac address from the raw packet data.