http://qs321.pair.com?node_id=572345


in reply to Net::Ping broken on Solaris?

Indeed, Net::Ping hardware binding seems to work on linux only; the setsockopt call uses SO_BINDTODEVICE which constant isn't defined on solaris. The subroutine that provides the constant is

# h2ph "asm/socket.h" # require "asm/socket.ph"; sub SO_BINDTODEVICE {25;}

Hmm... asm/socket.h ? This file doesn't exist on solaris (nor *BSD).

But in Net::Ping there's $p->bind($local_addr) - maybe that suffices to select the interface.

--shmem

_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                              /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

Replies are listed 'Best First'.
Re^2: Net::Ping broken on Solaris?
by bronto (Priest) on Sep 11, 2006 at 14:08 UTC

    Thanks shmem. Unfortunately, my colleague can bind any address he wants, even weird or non-existent ones, and the module flawlessly fails to notice. It still uses the... er, default interface.

    Any clues? Should I go and try to patch the module myself?

    Ciao!
    --bronto


    In theory, there is no difference between theory and practice. In practice, there is.

      No further clue atm; and - if it's broken, u-fix-it :-)

      But it might be the case that binding a socket to an interface just isn't possible on Solaris.

      Why is interface binding necessary?

      --shmem

      _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                    /\_¯/(q    /
      ----------------------------  \__(m.====·.(_("always off the crowd"))."·
      ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

        Sorry for not being back for a while... :-( Because the script is part of a monitoring system, and he needs to check that a device is reachble from that specific interface.

        Hmm... I guess that, unless he already solved the problem, I'll have to try a patch :-D. Thanks anyway!

        Ciao!
        --bronto


        In theory, there is no difference between theory and practice. In practice, there is.