From ec497dc1a54c88784b380200508eba6a85f4cb97 Mon Sep 17 00:00:00 2001 From: John Southworth Date: Thu, 10 May 2012 18:18:17 -0700 Subject: Bugfix 8079: fix require sys/ioctl.ph confilcts perl only allows a require to be done once. If it is done in two included modules the module or function in the module used second doesn't have the data in the required file in its scope. To prevent this I created a third module that contains the functions that require 'sys/ioctl.ph' so that there is no longer a conflict. --- lib/Vyatta/Interface.pm | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) (limited to 'lib/Vyatta/Interface.pm') diff --git a/lib/Vyatta/Interface.pm b/lib/Vyatta/Interface.pm index 3fce824..e23f565 100755 --- a/lib/Vyatta/Interface.pm +++ b/lib/Vyatta/Interface.pm @@ -23,9 +23,9 @@ use strict; use warnings; use Vyatta::Config; use Vyatta::Misc; +use Vyatta::ioctl; use base 'Exporter'; use Socket; -require 'sys/ioctl.ph'; our @EXPORT = qw(IFF_UP IFF_BROADCAST IFF_DEBUG IFF_LOOPBACK IFF_POINTOPOINT IFF_RUNNING IFF_NOARP @@ -411,21 +411,8 @@ sub address { # Do SIOCGIFFLAGS ioctl in perl sub flags { - my $self = shift; - - my $SIOCGIFFLAGS = &SIOCGIFFLAGS; - die "SIOCGIFFLAGS not found" - unless defined($SIOCGIFFLAGS); - - socket (my $sock, AF_INET, SOCK_DGRAM, 0) - or die "open UDP socket failed: $!"; - - my $ifreq = pack('a16', $self->{name}); - ioctl($sock, $SIOCGIFFLAGS, $ifreq) - or return; #undef - - my (undef, $flags) = unpack('a16s', $ifreq); - return $flags; + my $self = shift; + return Vyatta::ioctl::get_interface_flags($self->{name}); } sub exists { -- cgit v1.2.3