From: Florian Forster Date: Sat, 18 Jul 2009 12:59:16 +0000 (+0200) Subject: Net::Oping: Add the `device' method. X-Git-Tag: liboping-1.3.0~4 X-Git-Url: https://git.octo.it/?p=liboping.git;a=commitdiff_plain;h=b1d5bb28df40942b1e8196b8326df3a1ce80f0f0 Net::Oping: Add the `device' method. --- diff --git a/bindings/perl/Oping.xs b/bindings/perl/Oping.xs index 1327a95..6106e13 100644 --- a/bindings/perl/Oping.xs +++ b/bindings/perl/Oping.xs @@ -79,6 +79,19 @@ _ping_setopt_source (obj, addr) OUTPUT: RETVAL +int +_ping_setopt_device (obj, dev) + pingobj_t *obj + char *dev + CODE: +#if OPING_VERSION >= 1003000 + RETVAL = ping_setopt (obj, PING_OPT_DEVICE, dev); +#else + RETVAL = -95; +#endif + OUTPUT: + RETVAL + int _ping_host_add (obj, host); pingobj_t *obj diff --git a/bindings/perl/lib/Net/Oping.pm b/bindings/perl/lib/Net/Oping.pm index dc06ad3..9dff945 100644 --- a/bindings/perl/lib/Net/Oping.pm +++ b/bindings/perl/lib/Net/Oping.pm @@ -171,6 +171,35 @@ sub bind return (1); } +=item I<$status> = I<$obj>-EB (I<$device>); + +Sets the network device used for communication. This may not be supported on +all platforms. + +I + +=cut + +sub device +{ + my $obj = shift; + my $device = shift; + my $status; + + $status = _ping_setopt_device ($obj->{'c_obj'}, $device); + if ($status == -95) # Feature not supported. + { + $obj->{'err_msg'} = "Feature not supported by your version of liboping."; + } + elsif ($status != 0) + { + $obj->{'err_msg'} = "" . _ping_get_error ($obj->{'c_obj'}); + return; + } + + return (1); +} + =item I<$status> = I<$obj>-EB (I<$host>, [I<$host>, ...]); Adds one or more hosts to the Net::Oping-object I<$obj>. The number of