in reply to Cross Platform Network Interface Module

In Net::PCap::FindDevice, I spawn netstat -r to find the device IP and the default gateway. Surprisingly, the regular expression only seems to differ between Windows and "Unix", or nobodyy uses that module or complained about it. Maybe the code in that module is helpful.
  • Comment on Re: Cross Platform Network Interface Module

Replies are listed 'Best First'.
Re^2: Cross Platform Network Interface Module
by VinsWorldcom (Prior) on Apr 18, 2013 at 19:53 UTC

    Thanks.

    Full disclosure - I work on Windows (Win7 x64 / Stawberry 5.16.1) so already coded Win32::Interfaces to parse 'ipconfig', 'arp -a' and various 'wmic' and 'netsh' commands to get all I need. Of course, my "solution" is Windows-only and I would say not CPAN-ready due to the "parsing a system command" approach I used. Win32::IPHelper does a much better job in terms of accessing the correct Windows data structures with XS Win32::API - albeit, there are bugs and XS is a bit beyond my capabilities to fix / patch. Likewise, the *nix-centric modules I listed above use XS against the sockets API (not WinSock).

    That said, if I want to port my program (that uses Win32::Interfaces) to *nix, I'm stuffed. I could do some conditional requires based on OS, but none of the modules I've found provide all the accessors I'm looking for (IP(v6) address and gateways, MAC's, MTU, names, etc...).

      We like the idea of your Win32::Interfaces module. I see this module is not on CPAN yet. Is there a possibility that you can share this module with us?

        Because it's based on screen scraping output of 'wmic' and 'netsh' commands which may not be available on older versions of Windows, I'm reluctant to throw it out there.

        You can find the Win32\Interfaces.pm code itself (minus the Changes, README, etc. stuff for a full .tar.gz module) on GitHub as part of my PPC project:

        https://github.com/vinsworldcom/PPC