summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorMohit Mehta <mohit.mehta@vyatta.com>2008-10-31 14:50:19 -0700
committerMohit Mehta <mohit.mehta@vyatta.com>2008-10-31 14:50:19 -0700
commit013a9f70c38310a486b080b870a1173057ead6f6 (patch)
tree28dc884a44e8713beba6147f54107ed75b447e6a /scripts
parent3d48065f09241a6878dc31a8d0223d673b5d553f (diff)
downloadvyatta-cfg-013a9f70c38310a486b080b870a1173057ead6f6.tar.gz
vyatta-cfg-013a9f70c38310a486b080b870a1173057ead6f6.zip
Fix Bug 3808 - OpenVPN accepts non-existent local-host option
Move code to retrieve IP addresses for a specified interface-type to VyattaMisc module
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/VyattaMisc.pm38
1 files changed, 38 insertions, 0 deletions
diff --git a/scripts/VyattaMisc.pm b/scripts/VyattaMisc.pm
index d74b55a..7072908 100755
--- a/scripts/VyattaMisc.pm
+++ b/scripts/VyattaMisc.pm
@@ -32,6 +32,44 @@ use strict;
use VyattaConfig;
+# getInterfacesIPadresses() returns IP addresses for the interface type passed to it
+# possible type of interfaces : 'broadcast', 'pointopoint', 'multicast', 'all'
+# the loopback IP address is never returned with any of the above parameters
+sub getInterfacesIPadresses {
+
+ my $interface_type = shift;
+ if (!($interface_type =~ m/broadcast|pointopoint|multicast|all/)) {
+ print STDERR "Invalid interface type specified to retrive IP addresses for\n";
+ return undef;
+ }
+ my @interfaces_on_system = `ifconfig -a | awk '\$2 ~ /Link/ {print \$1}'`;
+ chomp @interfaces_on_system;
+ my @intf_ips = ();
+ my $intf_ips_index = 0;
+ foreach my $intf_system (@interfaces_on_system) {
+ if (!($intf_system eq 'lo')) {
+ my $is_intf_interface_type = 0;
+ if (!($interface_type eq 'all')) {
+ $is_intf_interface_type =
+ `ip link show $intf_system 2>/dev/null | grep -i $interface_type | wc -l`;
+ } else {
+ $is_intf_interface_type = 1;
+ }
+ if ($is_intf_interface_type > 0) {
+ $intf_ips[$intf_ips_index] =
+ `ip addr show $intf_system 2>/dev/null | grep inet | grep -v inet6 | awk '{print \$2}'`;
+ if (!($intf_ips[$intf_ips_index] eq '')){
+ $intf_ips_index++;
+ }
+ }
+ }
+ }
+ chomp @intf_ips;
+ return (@intf_ips);
+
+}
+
+
sub getNetAddrIP {
my ($interface);
($interface) = @_;