summaryrefslogtreecommitdiff
path: root/tests/interface.pl
blob: 79f4df492256997637bec2f1770ce396ad19f7ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#! /usr/bin/perl

# Standalone test for Vyatta::Interface, not intended to be used
# directly


use strict;
use warnings;
use Vyatta::Interface;
use Vyatta::Misc qw(getInterfaces getInterfacesIPadresses);

my @interfaces = getInterfaces();
print "Interfaces: ", join(' ',@interfaces),"\n";

my @ips = getInterfacesIPadresses('all');
print "IP addresses = ",join(' ',@ips), "\n";

foreach my $arg (@interfaces) {
    print "$arg : ";
    my $intf = new Vyatta::Interface($arg);

    if (! $intf) {
	print "undefined\n";
	next;
    }
    
    my $vif = $intf->vif();
    print "vif=$vif " if $vif;
    printf "path = '%s'\ndevice=%s\n", $intf->path(), $intf->physicalDevice();

    my @addresses = $intf->address();
    if ($#addresses eq -1) {
	print "address is no set\n";
    } else {
	print "address ", join(' ',@addresses), "\n";
    }

    foreach my $attr (qw(exists configured disabled using_dhcp flags up running)) {
	my $val = $intf->$attr();
	print " $attr=$val" if ($val);
    }
    print "\n";
}

exit 0;