Tuesday, April 19, 2011

MacOS MAC Address

I emailed Victor with this link that gets MAC addresses on MacOS. His reply:


That is one way of going about it, but it's probably very painful. You'd have to make libffi bindings for all those OSX-specific calls.

Google took me here: http://forum.soft32.com/mac/sample-code-MAC-IP-address-Mac-OS-ftopict45416.html

Then I saw the comment at the bottom, and it makes some good points. I googled for a ruby gem that wraps getifaddres, and found this. https://github.com/bbcoimbra/system-getifaddrs

See if you can use it to get the network card information. If it works, you'll probably have to figure out how to build Windows-specific gems, because I'm almost sure this won't install on Windows.

===

So I git cloned "system-getifaddrs".

The problems are fixed here.

Problem 1: I can't the test.rb from its README to work

I found a extconf.rb in system-getifaddrs/ext/rb_getifaddrs, and did:
$ ruby extconf.rb
checking for arpa/inet.h... yes
checking for sys/socket.h... yes
checking for sys/types.h... yes
checking for netdb.h... yes
checking for ifaddrs.h... yes
checking for stdio.h... yes
checking for stdlib.h... yes
checking for unistd.h... yes
creating Makefile
I don't think that's what I'm supposed to do
Problem 2: How do I up "system-getifaddrs" to use it?

Problem 3: If system-getifaddrs is a ruby gem, where is the ".gem" file?

No comments:

Post a Comment