From 202a93e9f67c863d234af7e36594b9a5b9e35d9a Mon Sep 17 00:00:00 2001 From: carlosg Date: Sun, 14 May 2006 17:52:21 +0000 Subject: 2006-05-14 Carlos Garnacho Parro * IfacesConfig.pm, Network/Ifaces.pm: add set() functionality, minor changes to get() --- ChangeLog | 2 + IfacesConfig.pm | 26 +- Network/Ifaces.pm | 2174 +++++++++++++++++++++++++++++++++++++++++++++++------ 3 files changed, 1960 insertions(+), 242 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9dbbae8..5e0eb27 100644 --- a/ChangeLog +++ b/ChangeLog @@ -17,6 +17,8 @@ * Init/ServicesList.pm: make a difference between SMB and NFS * Utils/Replace.pm (set_join_hash): renamed to join_hash. (set_ppp_options_re) (set_ppp_options_connect): added + * IfacesConfig.pm, Network/Ifaces.pm: add set() functionality, minor + changes to get() 2006-03-17 Carlos Garnacho Parro diff --git a/IfacesConfig.pm b/IfacesConfig.pm index 91055dc..c1dcc58 100644 --- a/IfacesConfig.pm +++ b/IfacesConfig.pm @@ -44,14 +44,36 @@ sub new return $self; } -dbus_method ("get", [], []); +dbus_method ("get", [], + [[ "array", [ "struct", "string", "int32", "int32", "string", "string", "string", "string" ]], + [ "array", [ "struct", "string", "int32", "int32", "string", "string", "string", "string", "string", "int32", "string" ]], + [ "array", [ "struct", "string", "int32", "int32", "string", "string", "string", "string" ]], + [ "array", [ "struct", "string", "int32", "string", "string" ]], + [ "array", [ "struct", "string", "int32", "string", "string", "string", "int32", "int32", "string", "string", "int32", "int32", "int32", "int32" ]], + [ "array", [ "struct", "string", "int32", "string", "string", "string", "string", "int32", "int32", "int32", "int32" ]]]); +dbus_method ("set", + [[ "array", [ "struct", "string", "int32", "int32", "string", "string", "string", "string" ]], + [ "array", [ "struct", "string", "int32", "int32", "string", "string", "string", "string", "string", "int32", "string" ]], + [ "array", [ "struct", "string", "int32", "int32", "string", "string", "string", "string" ]], + [ "array", [ "struct", "string", "int32", "string", "string" ]], + [ "array", [ "struct", "string", "int32", "string", "string", "string", "int32", "int32", "string", "string", "int32", "int32", "int32", "int32" ]], + [ "array", [ "struct", "string", "int32", "string", "string", "string", "string", "int32", "int32", "int32", "int32" ]]], []); + dbus_signal ("changed", []); sub get { my ($self) = @_; - #&Network::Ifaces::get (); + return &Network::Ifaces::get (); +} + +sub set +{ + my ($self, @config) = @_; + + &Network::Ifaces::set ($config[0], $config[1], $config[2], + $config[3], $config[4], $config[5]); } 1; diff --git a/Network/Ifaces.pm b/Network/Ifaces.pm index 52816f0..b1c71a6 100644 --- a/Network/Ifaces.pm +++ b/Network/Ifaces.pm @@ -178,7 +178,7 @@ sub get_interface_type $types_cache{$dev} = "modem"; } } - elsif ($dev =~ /(eth|dc|ed|bfe|em|fxp|bge|de|xl|ixgb|txp|vx|lge|nge|pcn|re|rl|sf|sis|sk|ste|ti|tl|tx|vge|vr|wb|cs|ex|ep|fe|ie|lnc|sn|xe|le|an|awi|wi|ndis|wlaue|axe|cue|kue|rue|fwe|nve)[0-9]/) + elsif ($dev =~ /^(eth|dc|ed|bfe|em|fxp|bge|de|xl|ixgb|txp|vx|lge|nge|pcn|re|rl|sf|sis|sk|ste|ti|tl|tx|vge|vr|wb|cs|ex|ep|fe|ie|lnc|sn|xe|le|an|awi|wi|ndis|wlaue|axe|cue|kue|rue|fwe|nve)[0-9]/) { $types_cache{$dev} = "ethernet"; } @@ -273,22 +273,9 @@ sub get_interfaces_info { my (%ifaces, $type); - %ifaces = &get_linux_interfaces_info if ($Utils::Backend::tool{"system"} eq "Linux"); - %ifaces = &get_freebsd_interfaces_info if ($Utils::Backend::tool{"system"} eq "FreeBSD"); - - foreach $dev (keys %ifaces) - { - $type = &get_interface_type ($dev); - $ifaces{$dev}{"type"} = $type; - - #delete unknown ifaces - if (!$type) - { - delete $ifaces{$dev}; - } - } - - return %ifaces; + return &get_linux_interfaces_info if ($Utils::Backend::tool{"system"} eq "Linux"); + return &get_freebsd_interfaces_info if ($Utils::Backend::tool{"system"} eq "FreeBSD"); + return undef; } # boot method parsing/replacing @@ -537,6 +524,18 @@ sub get_pap_passwd return $passwd; } +sub set_pap_passwd +{ + my ($file, $login, $passwd) = @_; + my ($line); + + $login = '"' . $login . '"'; + $passwd = '"'. $passwd . '"'; + $line = "* $passwd"; + + return &Utils::Replace::split ($file, $login, "[ \t]+", $line); +} + sub get_wep_key_type { my ($func) = shift @_; @@ -560,6 +559,26 @@ sub get_wep_key return $val; } +sub set_wep_key_full +{ + my ($key, $key_type, $func); + + # seems kind of hackish, but we want to use distro + # specific saving functions, so we need to leave + # the args as variable as possible + $func = shift @_; + $key_type = pop @_; + $key = pop @_; + + if ($key_type eq "ascii") + { + $key = "s:" . $key; + } + + push @_, $key; + &$func (@_); +} + sub get_modem_volume { my ($file) = @_; @@ -611,6 +630,50 @@ sub get_debian_auto return (&get_debian_auto_by_stanza ($file, $iface) ne undef)? 1 : 0; } +sub set_debian_auto +{ + my ($file, $iface, $value) = @_; + my ($buff, $line_no, $found); + + $buff = &Utils::File::load_buffer ($file); + &Utils::File::join_buffer_lines ($buff); + $line_no = 0; + + while (($found = &Utils::Replace::interfaces_get_next_stanza ($buff, \$line_no, "auto")) >= 0) + { + if ($value) + { + if ($$buff[$line_no] =~ /[ \t]$iface([\# \t\n])/) + { + return &Utils::File::save_buffer ($buff, $file); + } + } + else + { + # I'm including the hash here, although the man page says it's not supported. + last if $$buff[$line_no] =~ s/[ \t]$iface([\# \t\n])/$1/; + } + + $line_no ++; + } + + if ($found < 0 && $value) + { + &Utils::Replace::interfaces_auto_stanza_create ($buff, $iface); + } + else + { + if ($value) + { + chomp $$buff[$line_no]; + $$buff[$line_no] .= " $iface\n"; + } + $$buff[$line_no] =~ s/auto[ \t]*$//; + } + + return &Utils::File::save_buffer ($buff, $file); +} + sub get_debian_remote_address { my ($file, $iface) = @_; @@ -632,19 +695,36 @@ sub get_debian_remote_address return undef; } +sub set_debian_remote_address +{ + my ($file, $iface, $value) = @_; + my ($ifconfig, $ret); + + &Utils::Report::enter (); + &Utils::Report::do_report ("network_set_remote", $iface); + + $ifconfig = &Utils::File::locate_tool ("ifconfig"); + + $ret = &Utils::Replace::set_interfaces_option_str ($file, $iface, "up", + "$ifconfig $iface pointopoint $value"); + &Utils::Report::leave (); + return $ret; +} + sub get_suse_dev_name { my ($iface) = @_; - my ($ifaces, $dev, $hwaddr, $d); + my ($ifaces, $dev, $hwaddr); my ($dev); $dev = &Utils::Parse::get_sh ("/var/run/sysconfig/if-$iface", "interface"); if ($dev eq undef) { - $fd = &Utils::File::run_backtick ("getcfg-interface $iface"); + $dev = &Utils::File::run_backtick ("getcfg-interface $iface"); } + # FIXME: is all this necessary? getcfg-interface should give us what we want if ($dev eq undef) { # Those are the last cases, we make rough guesses @@ -690,6 +770,15 @@ sub get_suse_auto return 0; } +sub set_suse_auto +{ + my ($file, $key, $enabled) = @_; + my ($ret); + + return &Utils::Replace::set_sh($file, $key, + ($enabled) ? "onboot" : "manual"); +} + sub get_suse_gateway { my ($file, $address, $netmask) = @_; @@ -700,6 +789,8 @@ sub get_suse_gateway } # Return IP address or netmask, depending on $what +# FIXME: This function could be used in other places than PLD, +# calculates netmask given format 1.1.1.1/128 sub get_pld_ipaddr { my ($file, $key, $what) = @_; @@ -737,6 +828,42 @@ sub get_pld_ipaddr return undef; } +sub set_pld_ipaddr +{ + my ($file, $key, $what, $value) = @_; + my %prefixes = + ( + "0" => 0, + "128" => 1, + "192" => 2, + "224" => 3, + "240" => 4, + "248" => 5, + "252" => 6, + "254" => 7, + "255" => 8 + ); + my ($ipaddr, $netmask); + + $ipaddr = &Utils::Parse::get_sh($file, $key); + return undef if $ipaddr eq ""; + + if($what eq "address") + { + $ipaddr =~ s/.*\//$value\//; + } + else + { + if($value =~ /([[:digit:]]*).([[:digit:]]*).([[:digit:]]*).([[:digit:]]*)/) + { + $netmask = $prefixes{$1} + $prefixes{$2} + $prefixes{$3} + $prefixes{$4}; + $ipaddr =~ s/\/[[:digit:]]*/\/$netmask/; + } + } + + return &Utils::Replace::set_sh($file, $key, $ipaddr); +} + sub get_gateway { my ($file, $key, $address, $netmask) = @_; @@ -788,6 +915,60 @@ sub get_slackware_auto } } +# adds or deletes eth_up $eth_iface_number +sub set_slackware_auto +{ + my ($file, $rclocal, $iface, $active) = @_; + my ($search) = 0; + my ($nline) = 0; + my ($buff, $sline); + + if ($iface =~ /^eth/) + { + $buff = &Utils::File::load_buffer ($file); + &Utils::File::join_buffer_lines ($buff); + + $iface =~ s/eth//; + + foreach $i (@$buff) + { + if ($i =~ /^[ \t]*('start'\)|\*\))/) + { + # if the line is 'start') or *), begin the search + $search = 1; + } + elsif (($i =~ /^[ \t]*gateway_up/) && ($search == 1)) + { + # save the line in which we're going to save the eth_up stuff + $sline = $nline; + } + elsif (($i =~ /^[ \t]*(;;|esac)/) && ($search == 1)) + { + # we've arrived to the end of the case, if we wanted to + # add the iface, now it's the moment + $$buff[$sline] = "\teth_up $iface\n" . $$buff[$sline] if ($active == 1); + $search = 0; + } + elsif (($i =~ /^[ \t]*eth_up (\S+)/) && ($search == 1)) + { + if ($1 == $iface) + { + delete $$buff[$nline] if ($active == 0); + $search = 0; + } + } + + $nline++; + } + + return &Utils::File::save_buffer ($buff, $file); + } + elsif ($iface =~ /^ppp/) + { + return &Utils::Replace::set_kw ($rclocal, "ppp-go", $active); + } +} + sub get_freebsd_auto { my ($file, $defaults_file, $iface) = @_; @@ -801,6 +982,31 @@ sub get_freebsd_auto return 0; } +sub set_freebsd_auto +{ + my ($file, $iface, $active) = @_; + my ($val); + + $val = &Utils::Parse::get_sh ($file, "network_interfaces"); + $val = &Utils::File::run_backtick ("ifconfig -l") if ($val =~ /auto/); + $val .= " "; + + if ($active && ($val !~ /$iface /)) + { + $val .= $iface; + } + elsif (!$active && ($val =~ /$iface /)) + { + $val =~ s/$iface //; + } + + # Trim the string + $val =~ s/^[ \t]*//; + $val =~ s/[ \t]*$//; + + &Utils::Replace::set_sh ($file, "network_interfaces", $val); +} + sub get_freebsd_ppp_persist { my ($startif, $iface) = @_; @@ -817,123 +1023,728 @@ sub get_freebsd_ppp_persist return undef; } -sub get_interface_parse_table +# we need this function because essid can be +# multiword, and thus it can't be in rc.conf +sub set_freebsd_essid { - my %dist_map = - ( - "redhat-5.2" => "redhat-6.2", - "redhat-6.0" => "redhat-6.2", - "redhat-6.1" => "redhat-6.2", - "redhat-6.2" => "redhat-6.2", - "redhat-7.0" => "redhat-6.2", - "redhat-7.1" => "redhat-6.2", - "redhat-7.2" => "redhat-7.2", - "redhat-8.0" => "redhat-8.0", - "redhat-9" => "redhat-8.0", - "openna-1.0" => "redhat-6.2", - "mandrake-7.1" => "redhat-6.2", - "mandrake-7.2" => "redhat-6.2", - "mandrake-9.0" => "mandrake-9.0", - "mandrake-9.1" => "mandrake-9.0", - "mandrake-9.2" => "mandrake-9.0", - "mandrake-10.0" => "mandrake-9.0", - "mandrake-10.1" => "mandrake-9.0", - "blackpanther-4.0" => "mandrake-9.0", - "conectiva-9" => "conectiva-9", - "conectiva-10" => "conectiva-9", - "debian-3.0" => "debian-3.0", - "debian-sarge" => "debian-3.0", - "suse-9.0" => "suse-9.0", - "suse-9.1" => "suse-9.0", - "turbolinux-7.0" => "redhat-6.2", - "pld-1.0" => "pld-1.0", - "pld-1.1" => "pld-1.0", - "pld-1.99" => "pld-1.0", - "fedora-1" => "redhat-7.2", - "fedora-2" => "redhat-7.2", - "fedora-3" => "redhat-7.2", - "specifix" => "redhat-7.2", - "vine-3.0" => "vine-3.0", - "vine-3.1" => "vine-3.0", - "slackware-9.1.0" => "slackware-9.1.0", - "slackware-10.0.0" => "slackware-9.1.0", - "slackware-10.1.0" => "slackware-9.1.0", - "gentoo" => "gentoo", - "freebsd-5" => "freebsd-5", - "freebsd-6" => "freebsd-5", - ); + my ($file, $startif, $iface, $essid) = @_; + + if ($essid =~ /[ \t]/) + { + # It's multiword + &Utils::File::save_buffer ("ifconfig $iface ssid \"$essid\"", $startif); + &Utils::Replace::set_sh_re ($file, "ifconfig_$iface", "ssid[ \t]+([^ \t]*)", ""); + } + else + { + &Utils::Replace::set_sh_re ($file, "ifconfig_$iface", "ssid[ \t]+([^ \t]*)", " ssid $essid"); + } +} + +sub interface_changed +{ + my ($iface, $old_iface) = @_; + my ($key); + + foreach $key (keys %$iface) + { + next if ($key eq "enabled"); + return 1 if ($$iface{$key} ne $$old_iface{$key}); + } + + return 0; +} + +sub activate_interface_by_dev +{ + my ($dev, $enabled) = @_; + + &Utils::Report::enter (); + + if ($enabled) + { + &Utils::Report::do_report ("network_iface_activate", $dev); + return -1 if &Utils::File::run ("ifup $dev"); + } + else + { + &Utils::Report::do_report ("network_iface_deactivate", $dev); + return -1 if &Utils::File::run ("ifdown $dev"); + } - my %dist_tables = - ( - "redhat-6.2" => - { - ifaces_get => \&get_existing_rh62_ifaces, - fn => - { - IFCFG => "/etc/sysconfig/network-scripts/ifcfg-#iface#", - CHAT => "/etc/sysconfig/network-scripts/chat-#iface#", - IFACE => "#iface#", - TYPE => "#type#", - PAP => "/etc/ppp/pap-secrets", - CHAP => "/etc/ppp/chap-secrets", - PUMP => "/etc/pump.conf", - WVDIAL => "/etc/wvdial.conf" - }, - table => - [ - [ "bootproto", \&get_rh_bootproto, IFCFG, BOOTPROTO ], - [ "auto", \&Utils::Parse::get_sh_bool, IFCFG, ONBOOT ], -# [ "user", \&Utils::Parse::get_sh_bool, IFCFG, USERCTL ], - [ "dev", \&Utils::Parse::get_sh, IFCFG, DEVICE ], - [ "address", \&Utils::Parse::get_sh, IFCFG, IPADDR ], - [ "netmask", \&Utils::Parse::get_sh, IFCFG, NETMASK ], - [ "broadcast", \&Utils::Parse::get_sh, IFCFG, BROADCAST ], - [ "network", \&Utils::Parse::get_sh, IFCFG, NETWORK ], - [ "gateway", \&Utils::Parse::get_sh, IFCFG, GATEWAY ], - [ "remote_address", \&Utils::Parse::get_sh, IFCFG, REMIP ], -# [ "update_dns", \&gst_network_pump_get_nodns, PUMP, "%dev%", "%bootproto%" ], -# [ "dns1", \&Utils::Parse::get_sh, IFCFG, DNS1 ], -# [ "dns2", \&Utils::Parse::get_sh, IFCFG, DNS2 ], -# [ "ppp_options", \&Utils::Parse::get_sh, IFCFG, PPPOPTIONS ], - [ "section", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, WVDIALSECT ]], - [ "update_dns", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, PEERDNS ]], - [ "mtu", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, MTU ]], - [ "mru", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, MRU ]], - [ "login", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, PAPNAME ]], - [ "password", \&check_type, [TYPE, "modem", \&get_pap_passwd, PAP, "%login%" ]], - [ "password", \&check_type, [TYPE, "modem", \&get_pap_passwd, CHAP, "%login%" ]], - [ "serial_port", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, MODEMPORT ]], - [ "serial_speed", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, LINESPEED ]], - [ "set_default_gw", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, DEFROUTE ]], - [ "persist", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, PERSIST ]], - [ "serial_escapechars", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, ESCAPECHARS ]], - [ "serial_hwctl", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, HARDFLOWCTL ]], - [ "phone_number", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_chatfile, CHAT, "^atd[^0-9]*([0-9, -]+)" ]], - [ "phone_number", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Phone" ]], - [ "update_dns", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Auto DNS" ]], - [ "login", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Username" ]], - [ "password", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Password" ]], - [ "serial_port", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Modem" ]], - [ "serial_speed", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Baud" ]], - [ "set_default_gw", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Check Def Route" ]], - [ "persist", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Auto Reconnect" ]], - [ "dial_command", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Dial Command" ]], - [ "external_line", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Dial Prefix" ]], -# [ "enabled", \&gst_network_interface_active, IFACE, -# \&gst_network_active_interfaces_get ], -# [ "enabled", \&Utils::Parse::get_trivial, 0 ] - ] - }, + &Utils::Report::leave (); - "redhat-7.2" => - { - ifaces_get => \&get_existing_rh72_ifaces, - fn => - { - IFCFG => ["/etc/sysconfig/networking/profiles/default/ifcfg-#iface#", - "/etc/sysconfig/networking/devices/ifcfg-#iface#", - "/etc/sysconfig/network-scripts/ifcfg-#iface#"], - CHAT => "/etc/sysconfig/network-scripts/chat-#iface#", + return 0; +} + +# This works for all systems that have ifup/ifdown scripts. +sub activate_interface +{ + my ($hash, $old_hash, $enabled, $force) = @_; + my ($dev); + + if ($force || &interface_changed ($hash, $old_hash)) + { + $dev = ($$hash{"file"}) ? $$hash{"file"} : $$hash{"dev"}; + &activate_interface_by_dev ($dev, $enabled); + } +} + +# FIXME: can this function be mixed with the above? +sub activate_suse_interface +{ + my ($hash, $old_hash, $enabled, $force) = @_; + my ($iface, $dev); + + if ($force || &interface_changed ($hash, $old_hash)) + { + $dev = ($$hash{"file"}) ? &get_suse_dev_name ($$hash{"file"}) : $$hash{"dev"}; + &activate_interface_by_dev ($dev, $enabled); + } +} + +sub activate_slackware_interface_by_dev +{ + my ($dev, $enabled) = @_; + my ($address, $netmask, $gateway); + my ($file) = "/etc/rc.d/rc.inet1.conf"; + my ($ret) = 0; + + &Utils::Report::enter (); + + if ($enabled) + { + &Utils::Report::do_report ("network_iface_activate", $dev); + + if ($dev =~ /^ppp/) + { + $ret = &Utils::File::run ("ppp-go"); + } + else + { + if (&Utils::Parse::get_rcinet1conf_bool ($file, $dev, USE_DHCP)) + { + # Use DHCP + $ret = &Utils::File::run ("dhclient $dev"); + } + else + { + $address = &Utils::Parse::get_rcinet1conf ($file, $dev, "IPADDR"); + $netmask = &Utils::Parse::get_rcinet1conf ($file, $dev, "NETMASK"); + $gateway = &get_gateway ($file, "GATEWAY", $address, $netmask); + + $ret = &Utils::File::run ("ifconfig $dev $address netmask $netmask up"); + + # Add the gateway if necessary + if ($gateway ne undef) + { + &Utils::File::run ("route add default gw $gateway"); + } + } + } + } + else + { + &Utils::Report::do_report ("network_iface_deactivate", $dev); + + $ret = &Utils::File::run ("ifconfig $dev down") if ($dev =~ /^eth/); + $ret = &Utils::File::run ("ppp-off") if ($dev =~ /^ppp/); + } + + &Utils::Report::leave (); + return -1 if ($ret != 0); + return 0; +} + +sub activate_slackware_interface +{ + my ($hash, $old_hash, $enabled, $force) = @_; + my $dev = $$hash{"file"}; + + if ($force || &interface_changed ($hash, $old_hash)) + { + &activate_slackware_interface_by_dev ($dev, $enabled); + } +} + +sub activate_gentoo_interface_by_dev +{ + my ($dev, $enabled) = @_; + my $file = "/etc/init.d/net.$dev"; + my $action = ($enabled == 1)? "start" : "stop"; + + return &Utils::File::run ("$file $action"); +} + +sub activate_gentoo_interface +{ + my ($hash, $old_hash, $enabled, $force) = @_; + my $dev = $$hash{"file"}; + + if ($force || &interface_changed ($hash, $old_hash)) + { + &activate_gentoo_interface_by_dev ($dev, $enabled); + } +} + +sub activate_freebsd_interface_by_dev +{ + my ($hash, $enabled) = @_; + my ($dev) = $$hash{"file"}; + my ($startif) = "/etc/start_if.$dev"; + my ($file) = "/etc/rc.conf"; + my ($command, $dhcp_flags, $defaultroute, $fd); + + if ($enabled) + { + # Run the /etc/start_if.$dev commands + $fd = &Utils::File::open_read_from_names ($startif); + + while (<$fd>) + { + `$_`; + } + + &Utils::File::close_file ($fd); + $command = &Utils::Parse::get_sh ($file, "ifconfig_$dev"); + + # Bring up the interface + if ($command =~ /DHCP/i) + { + $dhcp_flags = &Utils::Parse::get_sh ($file, "dhcp_flags"); + &Utils::File::run ("dhclient $dhcp_flags $dev"); + } + else + { + &Utils::File::run ("ifconfig $dev $command"); + } + + # Add the default route + $default_route = &Utils::Parse::get_sh ($file, "defaultrouter"); + &Utils::File::run ("route add default $default_route") if ($default_route !~ /^no$/i); + } + else + { + &Utils::File::run ("ifconfig $dev down"); + } +} + +sub activate_freebsd_interface +{ + my ($hash, $old_hash, $enabled, $force) =@_; + + if ($force || &interface_changed ($hash, $old_hash)) + { + &activate_freebsd_interface_by_dev ($hash, $enabled); + } +} + +sub remove_pap_entry +{ + my ($file, $login) = @_; + my ($i, $buff); + + &Utils::Report::enter (); + &Utils::Report::do_report ("network_remove_pap", $file, $login); + + $buff = &Utils::File::load_buffer ($file); + + foreach $i (@$buff) + { + $i = "" if ($i =~ /^[ \t]*$login[ \t]/); + } + + &Utils::File::clean_buffer ($buff); + &Utils::Report::leave (); + return &Utils::File::save_buffer ($buff, $file); +} + +sub delete_rh62_interface +{ + my ($old_hash) = @_; + my ($dev, $login); + + $dev = $$old_hash{"file"}; + $login = $old_hash{"login"}; + &activate_interface_by_dev ($dev, 0); + + if ($login) + { + &remove_pap_entry ("/etc/ppp/pap-secrets", $login); + &remove_pap_entry ("/etc/ppp/chap-secrets", $login); + } + + &Utils::File::remove ("/etc/sysconfig/network-scripts/ifcfg-$dev"); +} + +sub delete_rh72_interface +{ + my ($old_hash) = @_; + my ($filedev, $dev, $login); + + $filedev = $$old_hash{"file"}; + $dev = $$old_hash{"dev"}; + $login = $$old_hash{"login"}; + + &activate_interface_by_dev ($filedev, 0); + + if ($login) + { + &remove_pap_entry ("/etc/ppp/pap-secrets", $login); + &remove_pap_entry ("/etc/ppp/chap-secrets", $login); + } + + &Utils::File::remove ("/etc/sysconfig/networking/devices/ifcfg-$filedev"); + &Utils::File::remove ("/etc/sysconfig/networking/profiles/default/ifcfg-$filedev"); + &Utils::File::remove ("/etc/sysconfig/network-scripts/ifcfg-$dev"); + + &Utils::File::run ("redhat-config-network-cmd"); +} + +sub delete_debian_interface +{ + my ($old_hash) = @_; + my ($dev, $login); + + $dev = $$old_hash{"dev"}; + $login = $old_hash{"login"}; + + &activate_interface_by_dev ($dev, 0); + &Utils::Replace::interfaces_iface_stanza_delete ("/etc/network/interfaces", $dev); + + if ($login) + { + &remove_pap_entry ("/etc/ppp/pap-secrets", $login); + &remove_pap_entry ("/etc/ppp/chap-secrets", $login); + } +} + +sub delete_suse_interface +{ + my ($old_hash) = @_; + my ($file, $provider, $dev); + + $file = $$old_hash{"file"}; + $dev = &get_suse_dev_name ($file); + $provider = &Utils::Parse::get_sh ("/etc/sysconfig/network/ifcfg-$file", PROVIDER); + + activate_interface_by_dev ($dev, 0); + + &Utils::File::remove ("/etc/sysconfig/network/ifroute-$file"); + &Utils::File::remove ("/etc/sysconfig/network/ifcfg-$file"); + &Utils::File::remove ("/etc/sysconfig/network/providers/$provider"); +} + +sub delete_pld_interface +{ + my ($old_hash) = @_; + my ($dev, $login); + + my $dev = $$old_hash{"file"}; + my $login = $$old_hash{"login"}; + &activate_interface_by_dev ($dev, 0); + + if ($login) + { + &remove_pap_entry ("/etc/ppp/pap-secrets", $login); + &remove_pap_entry ("/etc/ppp/chap-secrets", $login); + } + + &Utils::File::remove ("/etc/sysconfig/interfaces/ifcfg-$dev"); +} + +sub delete_slackware_interface +{ + my ($old_hash) = @_; + my ($rcinetconf, $rcinet, $rclocal, $pppscript, $dev); + + $rcinetconf = "/etc/rc.d/rc.inet1.conf"; + $rcinet = "/etc/rc.d/rc.inet1"; + $rclocal = "/etc/rc.d/rc.local"; + $pppscript = "/etc/ppp/pppscript"; + $dev = $$old_hash {"dev"}; + + # remove ifup/ppp-go at startup if existing + &set_slackware_auto ($rcinet, $rclocal, $dev, 0); + + if ($dev =~ /^ppp/) + { + &Utils::File::remove ($pppscript); + } + else + { + # empty the values + &Utils::Replace::set_rcinet1conf ($rcinetconf, $dev, "IPADDR", ""); + &Utils::Replace::set_rcinet1conf ($rcinetconf, $dev, "NETMASK", ""); + &Utils::Replace::set_rcinet1conf ($rcinetconf, $dev, "USE_DHCP", ""); + &Utils::Replace::set_rcinet1conf ($rcinetconf, $dev, "DHCP_HOSTNAME", ""); + } +} + +sub delete_gentoo_interface +{ + my ($old_hash) = @_; + my ($dev, $gateway); + + $dev = $$old_hash {"dev"}; + $gateway = $$old_hash {"gateway"}; + + # bring down the interface and remove from init + # FIXME: port this function + &gst_service_gentoo_set_status ("/etc/init.d/net.$dev", 1, 0); + + if ($dev =~ /^ppp/) + { + &Utils::File::remove ("/etc/conf.d/net.$dev"); + } + else + { + &Utils::Replace::set_sh ("/etc/conf.d/net", "iface_$dev", ""); + } +} + +sub delete_freebsd_interface +{ + my ($old_hash) = @_; + my ($dev, $startif, $pppconf); + my ($buff, $line_no, $end_line_no, $i); + + $dev = $$old_hash{"dev"}; + $startif = "/etc/start_if.$dev"; + $pppconf = "/etc/ppp/ppp.conf"; + + &Utils::File::run ("ifconfig $dev down"); + + if ($dev =~ /^tun[0-9]+/) + { + # Delete the ppp.conf section + $section = &Utils::Parse::get_startif ($startif, "ppp[ \t]+\-[^ \t]+[ \t]+([^ \t]+)"); + $buff = &Utils::File::load_buffer ($pppconf); + + $line_no = &Utils::Parse::pppconf_find_stanza ($buff, $section); + $end_line_no = &Utils::Parse::pppconf_find_next_stanza ($buff, $line_no + 1); + $end_line_no = scalar @$buff + 1 if ($end_line_no == -1); + $end_line_no--; + + for ($i = $line_no; $i <= $end_line_no; $i++) + { + delete $$buff[$i]; + } + + &Utils::File::clean_buffer ($buff); + &Utils::File::save_buffer ($buff, $pppconf); + } + + &Utils::Replace::set_sh ("/etc/rc.conf", "ifconfig_$dev", ""); + &Utils::File::remove ($startif); +} + +# FIXME: should move to external file!!! +sub create_pppscript +{ + my ($pppscript) = @_; + my ($contents); + + if (!&Utils::File::exists ($pppscript)) + { + # create a template file from scratch + $contents = 'TIMEOUT 60' . "\n"; + $contents .= 'ABORT ERROR' . "\n"; + $contents .= 'ABORT BUSY' . "\n"; + $contents .= 'ABORT VOICE' . "\n"; + $contents .= 'ABORT "NO CARRIER"' . "\n"; + $contents .= 'ABORT "NO DIALTONE"' . "\n"; + $contents .= 'ABORT "NO DIAL TONE"' . "\n"; + $contents .= 'ABORT "NO ANSWER"' . "\n"; + $contents .= '"" "ATZ"' . "\n"; + $contents .= '"" "AT&FH0"' . "\n"; + $contents .= 'OK-AT-OK "ATDT000000000"' . "\n"; + $contents .= 'TIMEOUT 75' . "\n"; + $contents .= 'CONNECT' . "\n"; + + &Utils::File::save_buffer ($contents, $pppscript); + } +} + +#FIXME: should move to external file!!! +sub create_pppgo +{ + my ($pppgo) = "/usr/sbin/ppp-go"; + my ($contents, $pppd, $chat); + local *FILE; + + if (!&Utils::File::exists ($pppgo)) + { + $pppd = &Utils::File::locate_tool ("pppd"); + $chat = &Utils::File::locate_tool ("chat"); + + # create a simple ppp-go from scratch + # this script is based on the one that's created by pppsetup + $contents = "killall -INT pppd 2>/dev/null \n"; + $contents .= "rm -f /var/lock/LCK* /var/run/ppp*.pid \n"; + $contents .= "( $pppd connect \"$chat -v -f /etc/ppp/pppscript\") || exit 1 \n"; + $contents .= "exit 0 \n"; + + &Utils::File::save_buffer ($contents, $pppgo); + chmod 0777, "$gst_prefix/$pppgo"; + } +} + +# FIXME: should move to external file!!! +sub create_gentoo_files +{ + my ($dev) = @_; + my ($init) = "/etc/init.d/net.$dev"; + my ($conf) = "/etc/conf.d/net.$dev"; + my ($backup) = "/etc/conf.d/net.ppp0.gstbackup"; + + if ($dev =~ /ppp/) + { + &Utils::File::copy_file ("/etc/init.d/net.ppp0", $init) if (!&Utils::File::exists ($init)); + + # backup the ppp config file + &Utils::File::copy_file ("/etc/conf.d/net.ppp0", $backup) if (!&Utils::File::exists ($backup)); + &Utils::File::copy_file ($backup, $conf) if (!&Utils::File::exists ($conf)); + } + else + { + &Utils::File::copy_file ("/etc/init.d/net.eth0", $init) if (!&Utils::File::exists ($init)); + } + + chmod 0755, "$gst_prefix/$init"; +} + +# FIXME: should move to external file!!! +sub create_ppp_startif +{ + my ($startif, $iface, $dev, $persist) = @_; + my ($section); + + if ($dev =~ /^tun[0-9]+/) + { + $section = &Utils::Parse::get_startif ($startif, "ppp[ \t]+\-[^ \t]+[ \t]+([^ \t]+)"); + $section = $dev if ($section eq undef); + + return &Utils::File::save_buffer ("ppp -ddial $section", $startif) if ($persist eq 1); + return &Utils::File::save_buffer ("ppp -auto $section", $startif); + } +} + +sub create_isdn_options +{ + my ($file) = @_; + + if (!&Utils::File::exists ($file)) + { + &Utils::File::copy_file_from_stock ("general_isdn_ppp_options", $file); + } +} + +sub set_modem_volume_sh +{ + my ($file, $key, $volume) = @_; + my ($vol); + + if ($volume == 0) { $vol = "ATM0" } + elsif ($volume == 1) { $vol = "ATL1" } + elsif ($volume == 2) { $vol = "ATL2" } + else { $vol = "ATL3" } + + return &Utils::Replace::set_sh ($file, $key, $vol); +} + +sub set_modem_volume +{ + my ($file, $volume) = @_; + my $line; + + $line = &Utils::Parse::get_from_chatfile ($file, "AT([^DZ][a-z0-9&]+)"); + $line =~ s/(M0|L[1-3])//g; + + if ($volume == 0) { $line .= "M0"; } + elsif ($volume == 1) { $line .= "L1"; } + elsif ($volume == 2) { $line .= "L2"; } + else { $line .= "L3"; } + + return &Utils::Replace::set_chat ($file, "AT([^DZ][a-z0-9&]+)", $line); +} + +sub set_pppconf_route +{ + my ($pppconf, $startif, $iface, $key, $val) = @_; + my ($section); + + if ($iface =~ /^tun[0-9]+/) + { + $section = &Utils::Parse::get_startif ($startif, "ppp[ \t]+\-[^ \t]+[ \t]+([^ \t]+)"); + &Utils::Replace::set_pppconf_common ($pppconf, $section, $key, + ($val == 1)? "add default HISADDR" : undef); + } +} + +sub set_pppconf_dial_command +{ + my ($pppconf, $startif, $iface, $val) = @_; + my ($section, $dial); + + if ($iface =~ /^tun[0-9]+/) + { + $section = &Utils::Parse::get_startif ($startif, "ppp[ \t]+\-[^ \t]+[ \t]+([^ \t]+)"); + $dial = &Utils::Parse::get_pppconf ($pppconf, $section, "dial"); + $dial =~ s/ATD[TP]/$val/; + + &Utils::Replace::set_pppconf ($pppconf, $section, "dial", $dial); + } +} + +sub set_pppconf_volume +{ + my ($pppconf, $startif, $iface, $val) = @_; + my ($section, $dial, $vol, $pre, $post); + + if ($iface =~ /^tun[0-9]+/) + { + $section = &Utils::Parse::get_startif ($startif, "ppp[ \t]+\-[^ \t]+[ \t]+([^ \t]+)"); + $dial = &Utils::Parse::get_pppconf ($pppconf, $section, "dial"); + + if ($dial =~ /(.*AT[^ \t]*)([ML][0-3])(.* OK .*)/i) + { + $pre = $1; + $post = $3; + } + elsif ($dial =~ /(.*AT[^ \t]*)( OK .*)/i) + { + $pre = $1; + $post = $2; + } + + if ($val == 0) + { + $vol = "M0"; + } + else + { + $vol = "L$val"; + } + + $dial = $pre . $vol . $post; + &Utils::Replace::set_pppconf ($pppconf, $section, "dial", $dial); + } +} + +sub get_interface_parse_table +{ + my %dist_map = + ( + "redhat-5.2" => "redhat-6.2", + "redhat-6.0" => "redhat-6.2", + "redhat-6.1" => "redhat-6.2", + "redhat-6.2" => "redhat-6.2", + "redhat-7.0" => "redhat-6.2", + "redhat-7.1" => "redhat-6.2", + "redhat-7.2" => "redhat-7.2", + "redhat-8.0" => "redhat-8.0", + "redhat-9" => "redhat-8.0", + "openna-1.0" => "redhat-6.2", + "mandrake-7.1" => "redhat-6.2", + "mandrake-7.2" => "redhat-6.2", + "mandrake-9.0" => "mandrake-9.0", + "mandrake-9.1" => "mandrake-9.0", + "mandrake-9.2" => "mandrake-9.0", + "mandrake-10.0" => "mandrake-9.0", + "mandrake-10.1" => "mandrake-9.0", + "blackpanther-4.0" => "mandrake-9.0", + "conectiva-9" => "conectiva-9", + "conectiva-10" => "conectiva-9", + "debian-3.0" => "debian-3.0", + "debian-sarge" => "debian-3.0", + "suse-9.0" => "suse-9.0", + "suse-9.1" => "suse-9.0", + "turbolinux-7.0" => "redhat-6.2", + "pld-1.0" => "pld-1.0", + "pld-1.1" => "pld-1.0", + "pld-1.99" => "pld-1.0", + "fedora-1" => "redhat-7.2", + "fedora-2" => "redhat-7.2", + "fedora-3" => "redhat-7.2", + "specifix" => "redhat-7.2", + "vine-3.0" => "vine-3.0", + "vine-3.1" => "vine-3.0", + "slackware-9.1.0" => "slackware-9.1.0", + "slackware-10.0.0" => "slackware-9.1.0", + "slackware-10.1.0" => "slackware-9.1.0", + "gentoo" => "gentoo", + "freebsd-5" => "freebsd-5", + "freebsd-6" => "freebsd-5", + ); + + my %dist_tables = + ( + "redhat-6.2" => + { + ifaces_get => \&get_existing_rh62_ifaces, + fn => + { + IFCFG => "/etc/sysconfig/network-scripts/ifcfg-#iface#", + CHAT => "/etc/sysconfig/network-scripts/chat-#iface#", + IFACE => "#iface#", + TYPE => "#type#", + PAP => "/etc/ppp/pap-secrets", + CHAP => "/etc/ppp/chap-secrets", + PUMP => "/etc/pump.conf", + WVDIAL => "/etc/wvdial.conf" + }, + table => + [ + [ "bootproto", \&get_rh_bootproto, IFCFG, BOOTPROTO ], + [ "auto", \&Utils::Parse::get_sh_bool, IFCFG, ONBOOT ], + [ "dev", \&Utils::Parse::get_sh, IFCFG, DEVICE ], + [ "address", \&Utils::Parse::get_sh, IFCFG, IPADDR ], + [ "netmask", \&Utils::Parse::get_sh, IFCFG, NETMASK ], + [ "broadcast", \&Utils::Parse::get_sh, IFCFG, BROADCAST ], + [ "network", \&Utils::Parse::get_sh, IFCFG, NETWORK ], + [ "gateway", \&Utils::Parse::get_sh, IFCFG, GATEWAY ], + [ "remote_address", \&Utils::Parse::get_sh, IFCFG, REMIP ], + [ "section", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, WVDIALSECT ]], + [ "update_dns", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, PEERDNS ]], + [ "mtu", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, MTU ]], + [ "mru", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, MRU ]], + [ "login", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, PAPNAME ]], + [ "password", \&check_type, [TYPE, "modem", \&get_pap_passwd, PAP, "%login%" ]], + [ "password", \&check_type, [TYPE, "modem", \&get_pap_passwd, CHAP, "%login%" ]], + [ "serial_port", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, MODEMPORT ]], + [ "serial_speed", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, LINESPEED ]], + [ "set_default_gw", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, DEFROUTE ]], + [ "persist", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, PERSIST ]], + [ "serial_escapechars", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, ESCAPECHARS ]], + [ "serial_hwctl", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, HARDFLOWCTL ]], + [ "phone_number", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_chatfile, CHAT, "^atd[^0-9]*([0-9, -]+)" ]], + [ "phone_number", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Phone" ]], + [ "update_dns", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Auto DNS" ]], + [ "login", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Username" ]], + [ "password", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Password" ]], + [ "serial_port", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Modem" ]], + [ "serial_speed", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Baud" ]], + [ "set_default_gw", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Check Def Route" ]], + [ "persist", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Auto Reconnect" ]], + [ "dial_command", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Dial Command" ]], + [ "external_line", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Dial Prefix" ]], +# [ "update_dns", \&gst_network_pump_get_nodns, PUMP, "%dev%", "%bootproto%" ], +# [ "dns1", \&Utils::Parse::get_sh, IFCFG, DNS1 ], +# [ "dns2", \&Utils::Parse::get_sh, IFCFG, DNS2 ], +# [ "ppp_options", \&Utils::Parse::get_sh, IFCFG, PPPOPTIONS ], + ] + }, + + "redhat-7.2" => + { + ifaces_get => \&get_existing_rh72_ifaces, + fn => + { + IFCFG => ["/etc/sysconfig/networking/profiles/default/ifcfg-#iface#", + "/etc/sysconfig/networking/devices/ifcfg-#iface#", + "/etc/sysconfig/network-scripts/ifcfg-#iface#"], + CHAT => "/etc/sysconfig/network-scripts/chat-#iface#", IFACE => "#iface#", TYPE => "#type#", PAP => "/etc/ppp/pap-secrets", @@ -945,9 +1756,6 @@ sub get_interface_parse_table [ [ "bootproto", \&get_rh_bootproto, IFCFG, BOOTPROTO ], [ "auto", \&Utils::Parse::get_sh_bool, IFCFG, ONBOOT ], -# [ "user", \&Utils::Parse::get_sh_bool, IFCFG, USERCTL ], -# [ "name", \&Utils::Parse::get_sh, IFCFG, NAME ], -# [ "name", \&Utils::Parse::get_trivial, IFACE ], [ "dev", \&Utils::Parse::get_sh, IFCFG, DEVICE ], [ "address", \&Utils::Parse::get_sh, IFCFG, IPADDR ], [ "netmask", \&Utils::Parse::get_sh, IFCFG, NETMASK ], @@ -958,9 +1766,6 @@ sub get_interface_parse_table [ "key_type", \&get_wep_key_type, [ \&Utils::Parse::get_sh, IFCFG, KEY ]], [ "key", \&get_wep_key, [ \&Utils::Parse::get_sh, IFCFG, KEY ]], [ "remote_address", \&Utils::Parse::get_sh, IFCFG, REMIP ], -# [ "update_dns", \&gst_network_pump_get_nodns, PUMP, "%dev%", "%bootproto%" ], -# [ "dns1", \&Utils::Parse::get_sh, IFCFG, DNS1 ], -# [ "dns2", \&Utils::Parse::get_sh, IFCFG, DNS2 ], [ "section", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, WVDIALSECT ]], [ "update_dns", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, PEERDNS ]], [ "mtu", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, MTU ]], @@ -970,18 +1775,18 @@ sub get_interface_parse_table [ "password", \&check_type, [TYPE, "modem", \&get_pap_passwd, CHAP, "%login%" ]], [ "serial_port", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, MODEMPORT ]], [ "serial_speed", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, LINESPEED ]], -# [ "ppp_options", \&Utils::Parse::get_sh, IFCFG, PPPOPTIONS ], [ "set_default_gw", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, DEFROUTE ]], -# [ "debug", \&Utils::Parse::get_sh_bool, IFCFG, DEBUG ], [ "persist", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, PERSIST ]], [ "serial_escapechars", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, ESCAPECHARS ]], [ "serial_hwctl", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, HARDFLOWCTL ]], [ "phone_number", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_chatfile, CHAT, "^atd[^0-9]*([0-9, -]+)" ]], -# [ "enabled", \&gst_network_interface_active, "%dev%", -# \&gst_network_active_interfaces_get ], -# [ "enabled", \&gst_network_interface_active, IFACE, -# \&gst_network_active_interfaces_get ], -# [ "enabled", \&Utils::Parse::get_trivial, 0 ] +# [ "name", \&Utils::Parse::get_sh, IFCFG, NAME ], +# [ "name", \&Utils::Parse::get_trivial, IFACE ], +# [ "update_dns", \&gst_network_pump_get_nodns, PUMP, "%dev%", "%bootproto%" ], +# [ "dns1", \&Utils::Parse::get_sh, IFCFG, DNS1 ], +# [ "dns2", \&Utils::Parse::get_sh, IFCFG, DNS2 ], +# [ "ppp_options", \&Utils::Parse::get_sh, IFCFG, PPPOPTIONS ], +# [ "debug", \&Utils::Parse::get_sh_bool, IFCFG, DEBUG ], # wvdial settings [ "phone_number", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Phone" ]], [ "update_dns", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Auto DNS" ]], @@ -1016,9 +1821,6 @@ sub get_interface_parse_table [ [ "bootproto", \&get_rh_bootproto, IFCFG, BOOTPROTO ], [ "auto", \&Utils::Parse::get_sh_bool, IFCFG, ONBOOT ], -# [ "user", \&Utils::Parse::get_sh_bool, IFCFG, USERCTL ], -# [ "name", \&Utils::Parse::get_sh, IFCFG, NAME ], -# [ "name", \&Utils::Parse::get_trivial, IFACE ], [ "dev", \&Utils::Parse::get_sh, IFCFG, DEVICE ], [ "address", \&Utils::Parse::get_sh, IFCFG, IPADDR ], [ "netmask", \&Utils::Parse::get_sh, IFCFG, NETMASK ], @@ -1027,11 +1829,8 @@ sub get_interface_parse_table [ "gateway", \&Utils::Parse::get_sh, IFCFG, GATEWAY ], [ "essid", \&Utils::Parse::get_sh, IFCFG, WIRELESS_ESSID ], [ "key_type", \&get_wep_key_type, [ \&Utils::Parse::get_sh, IFCFG, WIRELESS_KEY ]], - [ "key", \&get_wep_key, [ \&Utils::Parse::get_sh, IFCFG, WIRELESS_KEY ]], - [ "remote_address", \&Utils::Parse::get_sh, IFCFG, REMIP ], -# [ "update_dns", \&gst_network_pump_get_nodns, PUMP, "%dev%", "%bootproto%" ], -# [ "dns1", \&Utils::Parse::get_sh, IFCFG, DNS1 ], -# [ "dns2", \&Utils::Parse::get_sh, IFCFG, DNS2 ], + [ "key", \&get_wep_key, [ \&Utils::Parse::get_sh, IFCFG, WIRELESS_KEY ]], + [ "remote_address", \&Utils::Parse::get_sh, IFCFG, REMIP ], [ "section", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, WVDIALSECT ]], [ "update_dns", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, PEERDNS ]], [ "mtu", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, MTU ]], @@ -1041,18 +1840,18 @@ sub get_interface_parse_table [ "password", \&check_type, [TYPE, "modem", \&get_pap_passwd, CHAP, "%login%" ]], [ "serial_port", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, MODEMPORT ]], [ "serial_speed", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, LINESPEED ]], -# [ "ppp_options", \&Utils::Parse::get_sh, IFCFG, PPPOPTIONS ], [ "set_default_gw", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, DEFROUTE ]], -# [ "debug", \&Utils::Parse::get_sh_bool, IFCFG, DEBUG ], [ "persist", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, PERSIST ]], [ "serial_escapechars", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, ESCAPECHARS ]], [ "serial_hwctl", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, HARDFLOWCTL ]], [ "phone_number", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_chatfile, CHAT, "^atd[^0-9]*([0-9, -]+)" ]], -# [ "enabled", \&gst_network_interface_active, "%dev%", -# \&gst_network_active_interfaces_get ], -# [ "enabled", \&gst_network_interface_active, IFACE, -# \&gst_network_active_interfaces_get ], -# [ "enabled", \&Utils::Parse::get_trivial, 0 ] +# [ "name", \&Utils::Parse::get_sh, IFCFG, NAME ], +# [ "name", \&Utils::Parse::get_trivial, IFACE ], +# [ "update_dns", \&gst_network_pump_get_nodns, PUMP, "%dev%", "%bootproto%" ], +# [ "dns1", \&Utils::Parse::get_sh, IFCFG, DNS1 ], +# [ "dns2", \&Utils::Parse::get_sh, IFCFG, DNS2 ], +# [ "ppp_options", \&Utils::Parse::get_sh, IFCFG, PPPOPTIONS ], +# [ "debug", \&Utils::Parse::get_sh_bool, IFCFG, DEBUG ], # wvdial settings [ "phone_number", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Phone" ]], [ "update_dns", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Auto DNS" ]], @@ -1085,8 +1884,6 @@ sub get_interface_parse_table [ [ "bootproto", \&get_rh_bootproto, IFCFG, BOOTPROTO ], [ "auto", \&Utils::Parse::get_sh_bool, IFCFG, ONBOOT ], -# [ "user", \&Utils::Parse::get_sh_bool, IFCFG, USERCTL ], -# [ "name", \&Utils::Parse::get_sh, IFCFG, NAME ], [ "dev", \&Utils::Parse::get_sh, IFCFG, DEVICE ], [ "address", \&Utils::Parse::get_sh, IFCFG, IPADDR ], [ "netmask", \&Utils::Parse::get_sh, IFCFG, NETMASK ], @@ -1097,9 +1894,6 @@ sub get_interface_parse_table [ "key_type", \&get_wep_key_type, [ \&Utils::Parse::get_sh, IFCFG, KEY ]], [ "key", \&get_wep_key, [ \&Utils::Parse::get_sh, IFCFG, KEY ]], [ "remote_address", \&Utils::Parse::get_sh, IFCFG, REMIP ], -# [ "update_dns", \&gst_network_pump_get_nodns, PUMP, "%dev%", "%bootproto%" ], -# [ "dns1", \&Utils::Parse::get_sh, IFCFG, DNS1 ], -# [ "dns2", \&Utils::Parse::get_sh, IFCFG, DNS2 ], [ "section", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, WVDIALSECT ]], [ "update_dns", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, PEERDNS ]], [ "mtu", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, MTU ]], @@ -1109,15 +1903,17 @@ sub get_interface_parse_table [ "password", \&check_type, [TYPE, "modem", \&get_pap_passwd, CHAP, "%login%" ]], [ "serial_port", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, MODEMPORT ]], [ "serial_speed", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, LINESPEED ]], -# [ "ppp_options", \&Utils::Parse::get_sh, IFCFG, PPPOPTIONS ], [ "set_default_gw", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, DEFROUTE ]], -# [ "debug", \&Utils::Parse::get_sh_bool, IFCFG, DEBUG ], [ "persist", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, PERSIST ]], [ "serial_escapechars", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, ESCAPECHARS ]], [ "serial_hwctl", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, HARDFLOWCTL ]], [ "phone_number", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_chatfile, CHAT, "^atd[^0-9]*([0-9, -]+)" ]], -# [ "enabled", \&gst_network_interface_active, IFACE, \&gst_network_active_interfaces_get ], -# [ "enabled", \&Utils::Parse::get_trivial, 0 ] +# [ "name", \&Utils::Parse::get_sh, IFCFG, NAME ], +# [ "update_dns", \&gst_network_pump_get_nodns, PUMP, "%dev%", "%bootproto%" ], +# [ "dns1", \&Utils::Parse::get_sh, IFCFG, DNS1 ], +# [ "dns2", \&Utils::Parse::get_sh, IFCFG, DNS2 ], +# [ "ppp_options", \&Utils::Parse::get_sh, IFCFG, PPPOPTIONS ], +# [ "debug", \&Utils::Parse::get_sh_bool, IFCFG, DEBUG ], # wvdial settings [ "phone_number", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Phone" ]], [ "update_dns", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Auto DNS" ]], @@ -1150,8 +1946,6 @@ sub get_interface_parse_table [ [ "bootproto", \&get_rh_bootproto, IFCFG, BOOTPROTO ], [ "auto", \&Utils::Parse::get_sh_bool, IFCFG, ONBOOT ], -# [ "user", \&Utils::Parse::get_sh_bool, IFCFG, USERCTL ], -# [ "name", \&Utils::Parse::get_sh, IFCFG, NAME ], [ "dev", \&Utils::Parse::get_sh, IFCFG, DEVICE ], [ "address", \&Utils::Parse::get_sh, IFCFG, IPADDR ], [ "netmask", \&Utils::Parse::get_sh, IFCFG, NETMASK ], @@ -1162,9 +1956,6 @@ sub get_interface_parse_table [ "key_type", \&get_wep_key_type, [ \&Utils::Parse::get_sh, IFCFG, WIRELESS_KEY ]], [ "key", \&get_wep_key, [ \&Utils::Parse::get_sh, IFCFG, WIRELESS_KEY ]], [ "remote_address", \&Utils::Parse::get_sh, IFCFG, REMIP ], -# [ "update_dns", \&gst_network_pump_get_nodns, PUMP, "%dev%", "%bootproto%" ], -# [ "dns1", \&Utils::Parse::get_sh, IFCFG, DNS1 ], -# [ "dns2", \&Utils::Parse::get_sh, IFCFG, DNS2 ], [ "section", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, WVDIALSECT ]], [ "update_dns", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, PEERDNS ]], [ "mtu", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, MTU ]], @@ -1174,16 +1965,17 @@ sub get_interface_parse_table [ "password", \&check_type, [TYPE, "modem", \&get_pap_passwd, CHAP, "%login%" ]], [ "serial_port", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, MODEMPORT ]], [ "serial_speed", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, LINESPEED ]], -# [ "ppp_options", \&Utils::Parse::get_sh, IFCFG, PPPOPTIONS ], [ "set_default_gw", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, DEFROUTE ]], -# [ "debug", \&Utils::Parse::get_sh_bool, IFCFG, DEBUG ], [ "persist", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, PERSIST ]], [ "serial_escapechars", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, ESCAPECHARS ]], [ "serial_hwctl", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, HARDFLOWCTL ]], [ "phone_number", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_chatfile, CHAT, "^atd[^0-9]*([0-9, -]+)" ]], -# [ "enabled", \&gst_network_interface_active, IFACE, -# \&gst_network_active_interfaces_get ], -# [ "enabled", \&Utils::Parse::get_trivial, 0 ] +# [ "name", \&Utils::Parse::get_sh, IFCFG, NAME ], +# [ "update_dns", \&gst_network_pump_get_nodns, PUMP, "%dev%", "%bootproto%" ], +# [ "dns1", \&Utils::Parse::get_sh, IFCFG, DNS1 ], +# [ "dns2", \&Utils::Parse::get_sh, IFCFG, DNS2 ], +# [ "ppp_options", \&Utils::Parse::get_sh, IFCFG, PPPOPTIONS ], +# [ "debug", \&Utils::Parse::get_sh_bool, IFCFG, DEBUG ], # wvdial settings [ "phone_number", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Phone" ]], [ "update_dns", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Auto DNS" ]], @@ -1216,8 +2008,6 @@ sub get_interface_parse_table [ [ "bootproto", \&get_rh_bootproto, IFCFG, BOOTPROTO ], [ "auto", \&Utils::Parse::get_sh_bool, IFCFG, ONBOOT ], -# [ "user", \&Utils::Parse::get_sh_bool, IFCFG, USERCTL ], -# [ "name", \&Utils::Parse::get_sh, IFCFG, NAME ], [ "dev", \&Utils::Parse::get_sh, IFCFG, DEVICE ], [ "address", \&Utils::Parse::get_sh, IFCFG, IPADDR ], [ "netmask", \&Utils::Parse::get_sh, IFCFG, NETMASK ], @@ -1228,9 +2018,6 @@ sub get_interface_parse_table [ "key_type", \&get_wep_key_type, [ \&Utils::Parse::get_sh, IFCFG, WIRELESS_KEY ]], [ "key", \&get_wep_key, [ \&Utils::Parse::get_sh, IFCFG, WIRELESS_KEY ]], [ "remote_address", \&Utils::Parse::get_sh, IFCFG, REMIP ], -# [ "update_dns", \&gst_network_pump_get_nodns, PUMP, "%dev%", "%bootproto%" ], -# [ "dns1", \&Utils::Parse::get_sh, IFCFG, DNS1 ], -# [ "dns2", \&Utils::Parse::get_sh, IFCFG, DNS2 ], [ "section", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, WVDIALSECT ]], [ "update_dns", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, PEERDNS ]], [ "mtu", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, MTU ]], @@ -1242,14 +2029,15 @@ sub get_interface_parse_table [ "serial_speed", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, LINESPEED ]], [ "ppp_options", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, PPPOPTIONS ]], [ "set_default_gw", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, DEFROUTE ]], -# [ "debug", \&Utils::Parse::get_sh_bool, IFCFG, DEBUG ], [ "persist", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, PERSIST ]], [ "serial_escapechars", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, ESCAPECHARS ]], [ "serial_hwctl", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, HARDFLOWCTL ]], [ "phone_number", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_chatfile, CHAT, "^atd[^0-9]*([0-9, -]+)" ]], -# [ "enabled", \&gst_network_interface_active, IFACE, -# \&gst_network_active_interfaces_get ], -# [ "enabled", \&Utils::Parse::get_trivial, 0 ] +# [ "name", \&Utils::Parse::get_sh, IFCFG, NAME ], +# [ "update_dns", \&gst_network_pump_get_nodns, PUMP, "%dev%", "%bootproto%" ], +# [ "dns1", \&Utils::Parse::get_sh, IFCFG, DNS1 ], +# [ "dns2", \&Utils::Parse::get_sh, IFCFG, DNS2 ], +# [ "debug", \&Utils::Parse::get_sh_bool, IFCFG, DEBUG ], # wvdial settings [ "phone_number", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Phone" ]], [ "update_dns", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Auto DNS" ]], @@ -1300,7 +2088,6 @@ sub get_interface_parse_table [ "login", \&check_type, [TYPE, "(modem|isdn)", \&Utils::Parse::get_ppp_options_re, PPP_OPTIONS, "^user \"?([^\"]*)\"?" ]], [ "password", \&check_type, [TYPE, "(modem|isdn)", \&get_pap_passwd, PAP, "%login%" ]], [ "password", \&check_type, [TYPE, "(modem|isdn)", \&get_pap_passwd, CHAP, "%login%" ]], -# [ "ppp_options", \&check_type, [TYPE, "modem", \&gst_network_get_ppp_options_unsup, PPP_OPTIONS ]], [ "set_default_gw", \&check_type, [TYPE, "(modem|isdn)", \&Utils::Parse::get_kw, PPP_OPTIONS, "defaultroute" ]], [ "debug", \&check_type, [TYPE, "(modem|isdn)", \&Utils::Parse::get_kw, PPP_OPTIONS, "debug" ]], [ "persist", \&check_type, [TYPE, "(modem|isdn)", \&Utils::Parse::get_kw, PPP_OPTIONS, "persist" ]], @@ -1312,9 +2099,7 @@ sub get_interface_parse_table [ "phone_number", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_chatfile, CHAT, "atd.*[ptwW]([0-9, -]+)" ]], [ "dial_command", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_chatfile, CHAT, "(atd[tp])[0-9, -w]+" ]], [ "volume", \&check_type, [TYPE, "modem", \&get_modem_volume, CHAT ]], -# [ "enabled", \&gst_network_interface_active, IFACE, -# \&gst_network_active_interfaces_get ], -# [ "enabled", \&Utils::Parse::get_trivial, 0 ] +# [ "ppp_options", \&check_type, [TYPE, "modem", \&gst_network_get_ppp_options_unsup, PPP_OPTIONS ]], ] }, @@ -1332,7 +2117,6 @@ sub get_interface_parse_table table => [ [ "dev", \&get_suse_dev_name, IFACE ], -# [ "enabled", \&gst_network_interface_active, "%dev%", \&gst_network_active_interfaces_get ], [ "auto", \&get_suse_auto, IFCFG, STARTMODE ], [ "bootproto", \&get_bootproto, IFCFG, BOOTPROTO ], [ "address", \&Utils::Parse::get_sh, IFCFG, IPADDR ], @@ -1348,7 +2132,6 @@ sub get_interface_parse_table [ "serial_speed", \&Utils::Parse::get_sh, IFCFG, SPEED ], [ "mtu", \&Utils::Parse::get_sh, IFCFG, MTU ], [ "mru", \&Utils::Parse::get_sh, IFCFG, MRU ], -# [ "ppp_options", \&Utils::Parse::get_sh, IFCFG, PPPD_OPTIONS ], [ "dial_command", \&Utils::Parse::get_sh, IFCFG, DIALCOMMAND ], [ "external_line", \&Utils::Parse::get_sh, IFCFG, DIALPREFIX ], [ "section", \&Utils::Parse::get_sh, IFCFG, PROVIDER ], @@ -1362,6 +2145,7 @@ sub get_interface_parse_table [ "persist", \&Utils::Parse::get_sh_bool, PROVIDERS, PERSIST ], [ "stupid", \&Utils::Parse::get_sh_bool, PROVIDERS, STUPIDMODE ], [ "set_default_gw", \&Utils::Parse::get_sh_bool, PROVIDERS, DEFAULTROUTE ], +# [ "ppp_options", \&Utils::Parse::get_sh, IFCFG, PPPD_OPTIONS ], ] }, @@ -1382,18 +2166,11 @@ sub get_interface_parse_table [ [ "bootproto", \&get_rh_bootproto, IFCFG, BOOTPROTO ], [ "auto", \&Utils::Parse::get_sh_bool, IFCFG, ONBOOT ], -# [ "user", \&Utils::Parse::get_sh_bool, IFCFG, USERCTL ], -# [ "name", \&Utils::Parse::get_sh, IFCFG, DEVICE ], [ "dev", \&Utils::Parse::get_sh, IFCFG, DEVICE ], [ "address", \&get_pld_ipaddr, IFCFG, IPADDR, "address" ], [ "netmask", \&get_pld_ipaddr, IFCFG, IPADDR, "netmask" ], -# [ "broadcast", \&Utils::Parse::get_sh, IFCFG, BROADCAST ], -# [ "network", \&Utils::Parse::get_sh, IFCFG, NETWORK ], [ "gateway", \&Utils::Parse::get_sh, IFCFG, GATEWAY ], [ "remote_address", \&Utils::Parse::get_sh, IFCFG, REMIP ], -# [ "update_dns", \&gst_network_pump_get_nodns, PUMP, "%dev%", "%bootproto%" ], -# [ "dns1", \&Utils::Parse::get_sh, IFCFG, DNS1 ], -# [ "dns2", \&Utils::Parse::get_sh, IFCFG, DNS2 ], [ "update_dns", \&Utils::Parse::get_sh_bool, IFCFG, PEERDNS ], [ "mtu", \&Utils::Parse::get_sh, IFCFG, MTU ], [ "mru", \&Utils::Parse::get_sh, IFCFG, MRU ], @@ -1402,16 +2179,20 @@ sub get_interface_parse_table [ "password", \&get_pap_passwd, CHAP, "%login%" ], [ "serial_port", \&Utils::Parse::get_sh, IFCFG, MODEMPORT ], [ "serial_speed", \&Utils::Parse::get_sh, IFCFG, LINESPEED ], -# [ "ppp_options", \&Utils::Parse::get_sh, IFCFG, PPPOPTIONS ], -# [ "section", \&Utils::Parse::get_sh, IFCFG, WVDIALSECT ], [ "set_default_gw", \&Utils::Parse::get_sh_bool, IFCFG, DEFROUTE ], -# [ "debug", \&Utils::Parse::get_sh_bool, IFCFG, DEBUG ], [ "persist", \&Utils::Parse::get_sh_bool, IFCFG, PERSIST ], [ "serial_escapechars", \&Utils::Parse::get_sh_bool, IFCFG, ESCAPECHARS ], [ "serial_hwctl", \&Utils::Parse::get_sh_bool, IFCFG, HARDFLOWCTL ], [ "phone_number", \&Utils::Parse::get_from_chatfile, CHAT, "^atd[^0-9]*([0-9, -]+)" ], -# [ "enabled", \&gst_network_interface_active, IFACE, \&gst_network_active_interfaces_get ], -# [ "enabled", \&Utils::Parse::get_trivial, 0 ] +# [ "name", \&Utils::Parse::get_sh, IFCFG, DEVICE ], +# [ "broadcast", \&Utils::Parse::get_sh, IFCFG, BROADCAST ], +# [ "network", \&Utils::Parse::get_sh, IFCFG, NETWORK ], +# [ "update_dns", \&gst_network_pump_get_nodns, PUMP, "%dev%", "%bootproto%" ], +# [ "dns1", \&Utils::Parse::get_sh, IFCFG, DNS1 ], +# [ "dns2", \&Utils::Parse::get_sh, IFCFG, DNS2 ], +# [ "ppp_options", \&Utils::Parse::get_sh, IFCFG, PPPOPTIONS ], +# [ "section", \&Utils::Parse::get_sh, IFCFG, WVDIALSECT ], +# [ "debug", \&Utils::Parse::get_sh_bool, IFCFG, DEBUG ], ] }, @@ -1432,7 +2213,6 @@ sub get_interface_parse_table }, table => [ -# [ "user", \&Utils::Parse::get_trivial, 0 ], # not supported. [ "dev", \&Utils::Parse::get_trivial, IFACE ], [ "address", \&Utils::Parse::get_rcinet1conf, [RC_INET_CONF, IFACE], IPADDR ], [ "netmask", \&Utils::Parse::get_rcinet1conf, [RC_INET_CONF, IFACE], NETMASK ], @@ -1442,7 +2222,6 @@ sub get_interface_parse_table [ "essid", \&Utils::Parse::get_wireless_opts, [ WIRELESS, IFACE], \&get_wireless_ifaces, ESSID ], [ "key_type", \&get_wep_key_type, [ \&Utils::Parse::get_wireless_opts, [ WIRELESS, IFACE], \&get_wireless_ifaces, KEY ]], [ "key", \&get_wep_key, [ \&Utils::Parse::get_wireless_opts, [ WIRELESS, IFACE], \&get_wireless_ifaces, KEY ]], -# [ "enabled", \&gst_network_interface_active, IFACE, \&gst_network_active_interfaces_get ], # Modem stuff [ "update_dns", \&check_type, [TYPE, "modem", \&Utils::Parse::get_kw, PPP_OPTIONS, "usepeerdns" ]], [ "noauth", \&check_type, [TYPE, "modem", \&Utils::Parse::get_kw, PPP_OPTIONS, "noauth" ]], @@ -1453,7 +2232,6 @@ sub get_interface_parse_table [ "login", \&check_type, [TYPE, "modem", \&Utils::Parse::get_ppp_options_re, PPP_OPTIONS, "^name \"?([^\"]*)\"?" ]], [ "password", \&check_type, [TYPE, "modem", \&get_pap_passwd, PAP, "%login%" ]], [ "password", \&check_type, [TYPE, "modem", \&get_pap_passwd, CHAP, "%login%" ]], -# [ "ppp_options", \&check_type, [TYPE, "modem", \&gst_network_get_ppp_options_unsup, PPP_OPTIONS ]], [ "set_default_gw", \&check_type, [TYPE, "modem", \&Utils::Parse::get_kw, PPP_OPTIONS, "defaultroute" ]], [ "debug", \&check_type, [TYPE, "modem", \&Utils::Parse::get_kw, PPP_OPTIONS, "debug" ]], [ "persist", \&check_type, [TYPE, "modem", \&Utils::Parse::get_kw, PPP_OPTIONS, "persist" ]], @@ -1463,6 +2241,7 @@ sub get_interface_parse_table [ "phone_number", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_chatfile, CHAT, "atd.*[ptw]([0-9, -]+)" ]], [ "dial_command", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_chatfile, CHAT, "(atd[tp])[0-9, -w]+" ]], [ "volume", \&check_type, [TYPE, "modem", \&get_modem_volume, CHAT ]], +# [ "ppp_options", \&check_type, [TYPE, "modem", \&gst_network_get_ppp_options_unsup, PPP_OPTIONS ]], ] }, @@ -1480,13 +2259,11 @@ sub get_interface_parse_table table => [ [ "auto", \&Init::Services::get_gentoo_service_status, INIT, "default" ], - [ "user", \&Utils::Parse::get_trivial, 0 ], # not supported. [ "dev", \&Utils::Parse::get_trivial, IFACE ], [ "address", \&Utils::Parse::get_sh_re, NET, "iface_%dev%", "^[ \t]*([0-9\.]+)" ], [ "netmask", \&Utils::Parse::get_sh_re, NET, "iface_%dev%", "netmask[ \t]+([0-9\.]*)" ], [ "remote_address", \&Utils::Parse::get_sh_re, NET, "iface_%dev%", "dest_address[ \t]+([0-9\.]*)" ], [ "gateway", \&Utils::Parse::get_sh_re, NET, "gateway", "%dev%/([0-9\.\:]*)" ], -# [ "enabled", \&gst_network_interface_active, IFACE, \&gst_network_active_interfaces_get ], [ "bootproto", \&get_bootproto, NET, "iface_%dev%" ], [ "essid", \&Utils::Parse::get_wireless_opts, [ WIRELESS, IFACE], \&get_wireless_ifaces, ESSID ], [ "key_type", \&get_wep_key_type, [ \&Utils::Parse::get_wireless_opts, [ WIRELESS, IFACE], \&get_wireless_ifaces, KEY ]], @@ -1525,7 +2302,6 @@ sub get_interface_parse_table table => [ [ "auto", \&get_freebsd_auto, [RC_CONF, RC_CONF_DEFAULT, IFACE ]], -# [ "user", \&Utils::Parse::get_trivial, 0 ], # not supported. [ "dev", \&Utils::Parse::get_trivial, IFACE ], # we need to double check these values both in the start_if and in the rc.conf files, in this order [ "address", \&Utils::Parse::get_startif, STARTIF, "inet[ \t]+([0-9\.]+)" ], @@ -1539,7 +2315,6 @@ sub get_interface_parse_table # this is for plip interfaces [ "gateway", \&get_gateway, RC_CONF, "defaultrouter", "%remote_address%", "255.255.255.255" ], [ "gateway", \&get_gateway, RC_CONF, "defaultrouter", "%address%", "%netmask%" ], -# [ "enabled", \&gst_network_interface_active, IFACE, \&gst_network_freebsd5_active_interfaces_get ], [ "bootproto", \&get_bootproto, RC_CONF, "ifconfig_%dev%" ], # Modem stuff [ "serial_port", \&Utils::Parse::get_pppconf, [ PPPCONF, STARTIF, IFACE ], "device" ], @@ -1562,11 +2337,712 @@ sub get_interface_parse_table my $dist = $dist_map{$Utils::Backend::tool{"platform"}}; return %{$dist_tables{$dist}} if $dist; - &Utils::Report::do_report ("platform_no_table", $$tool{"platform"}); + &Utils::Report::do_report ("platform_no_table", $Utils::Backend::tool{"platform"}); + return undef; +} + +sub get_interface_replace_table +{ + my %dist_map = + ( + "redhat-5.2" => "redhat-6.2", + "redhat-6.0" => "redhat-6.2", + "redhat-6.1" => "redhat-6.2", + "redhat-6.2" => "redhat-6.2", + "redhat-7.0" => "redhat-6.2", + "redhat-7.1" => "redhat-6.2", + "redhat-7.2" => "redhat-7.2", + "redhat-8.0" => "redhat-8.0", + "redhat-9" => "redhat-8.0", + "mandrake-7.1" => "redhat-6.2", + "mandrake-7.2" => "redhat-6.2", + "mandrake-9.0" => "mandrake-9.0", + "mandrake-9.1" => "mandrake-9.0", + "mandrake-9.2" => "mandrake-9.0", + "mandrake-10.0" => "mandrake-9.0", + "mandrake-10.1" => "mandrake-9.0", + "blackpanther-4.0" => "mandrake-9.0", + "conectiva-9" => "conectiva-9", + "conectiva-10" => "conectiva-9", + "debian-3.0" => "debian-3.0", + "debian-sarge" => "debian-3.0", + "suse-9.0" => "suse-9.0", + "suse-9.1" => "suse-9.0", + "turbolinux-7.0" => "redhat-6.2", + "pld-1.0" => "pld-1.0", + "pld-1.1" => "pld-1.0", + "pld-1.99" => "pld-1.0", + "fedora-1" => "redhat-7.2", + "fedora-2" => "redhat-7.2", + "fedora-3" => "redhat-7.2", + "specifix" => "redhat-7.2", + "vine-3.0" => "vine-3.0", + "vine-3.1" => "vine-3.0", + "slackware-9.1.0" => "slackware-9.1.0", + "slackware-10.0.0" => "slackware-9.1.0", + "slackware-10.1.0" => "slackware-9.1.0", + "gentoo" => "gentoo", + "freebsd-5" => "freebsd-5", + "freebsd-6" => "freebsd-5", + ); + + my %dist_tables = + ( + "redhat-6.2" => + { + iface_set => \&activate_interface, + iface_delete => \&delete_rh62_interface, + fn => + { + IFCFG => "/etc/sysconfig/network-scripts/ifcfg-#iface#", + CHAT => "/etc/sysconfig/network-scripts/chat-#iface#", + IFACE => "#iface#", + WVDIAL => "/etc/wvdial.conf", + PUMP => "/etc/pump.conf" + }, + table => + [ + [ "bootproto", \&set_rh_bootproto, IFCFG, BOOTPROTO ], + [ "auto", \&Utils::Replace::set_sh_bool, IFCFG, ONBOOT ], + [ "dev", \&Utils::Replace::set_sh, IFCFG, NAME ], + [ "dev", \&Utils::Replace::set_sh, IFCFG, DEVICE ], + [ "address", \&Utils::Replace::set_sh, IFCFG, IPADDR ], + [ "netmask", \&Utils::Replace::set_sh, IFCFG, NETMASK ], + [ "broadcast", \&Utils::Replace::set_sh, IFCFG, BROADCAST ], + [ "network", \&Utils::Replace::set_sh, IFCFG, NETWORK ], + [ "gateway", \&Utils::Replace::set_sh, IFCFG, GATEWAY ], + [ "update_dns", \&Utils::Replace::set_sh_bool, IFCFG, PEERDNS ], + [ "remote_address", \&Utils::Replace::set_sh, IFCFG, REMIP ], + [ "login", \&Utils::Replace::set_sh, IFCFG, PAPNAME ], + [ "serial_port", \&Utils::Replace::set_sh, IFCFG, MODEMPORT ], + [ "serial_speed", \&Utils::Replace::set_sh, IFCFG, LINESPEED ], + [ "ppp_options", \&Utils::Replace::set_sh, IFCFG, PPPOPTIONS ], + [ "section", \&Utils::Replace::set_sh, IFCFG, WVDIALSECT ], + [ "set_default_gw", \&Utils::Replace::set_sh_bool, IFCFG, DEFROUTE ], + [ "persist", \&Utils::Replace::set_sh_bool, IFCFG, PERSIST ], + [ "phone_number", \&Utils::Replace::set_chat, CHAT, "^atd[^0-9]*([0-9, -]+)" ], +# [ "update_dns", \&gst_network_pump_set_nodns, PUMP, "%dev%", "%bootproto%" ], +# [ "dns1", \&Utils::Replace::set_sh, IFCFG, DNS1 ], +# [ "dns2", \&Utils::Replace::set_sh, IFCFG, DNS2 ], +# [ "mtu", \&Utils::Replace::set_sh, IFCFG, MTU ], +# [ "mru", \&Utils::Replace::set_sh, IFCFG, MRU ], +# [ "debug", \&Utils::Replace::set_sh_bool, IFCFG, DEBUG ], +# [ "serial_escapechars", \&Utils::Replace::set_sh_bool, IFCFG, ESCAPECHARS ], +# [ "serial_hwctl", \&Utils::Replace::set_sh_bool, IFCFG, HARDFLOWCTL ], + # wvdial settings + [ "phone_number", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Phone" ]], + [ "update_dns", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Auto DNS" ]], + [ "login", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Username" ]], + [ "password", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Password" ]], + [ "serial_port", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Modem" ]], + [ "serial_speed", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Baud" ]], + [ "set_default_gw", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Check Def Route" ]], + [ "persist", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Auto Reconnect" ]], + [ "dial_command", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Dial Command" ]], + [ "external_line", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Dial Prefix" ]], + ] + }, + + "redhat-7.2" => + { + iface_set => \&activate_interface, + iface_delete => \&delete_rh72_interface, + fn => + { + IFCFG => ["/etc/sysconfig/network-scripts/ifcfg-#iface#", + "/etc/sysconfig/networking/profiles/default/ifcfg-#iface#", + "/etc/sysconfig/networking/devices/ifcfg-#iface#"], + CHAT => "/etc/sysconfig/network-scripts/chat-#iface#", + IFACE => "#iface#", + WVDIAL => "/etc/wvdial.conf", + PUMP => "/etc/pump.conf" + }, + table => + [ + [ "bootproto", \&set_rh_bootproto, IFCFG, BOOTPROTO ], + [ "auto", \&Utils::Replace::set_sh_bool, IFCFG, ONBOOT ], + [ "dev", \&Utils::Replace::set_sh, IFCFG, NAME ], + [ "dev", \&Utils::Replace::set_sh, IFCFG, DEVICE ], + [ "address", \&Utils::Replace::set_sh, IFCFG, IPADDR ], + [ "netmask", \&Utils::Replace::set_sh, IFCFG, NETMASK ], + [ "broadcast", \&Utils::Replace::set_sh, IFCFG, BROADCAST ], + [ "network", \&Utils::Replace::set_sh, IFCFG, NETWORK ], + [ "gateway", \&Utils::Replace::set_sh, IFCFG, GATEWAY ], + [ "essid", \&Utils::Replace::set_sh, IFCFG, ESSID ], + [ "key", \&Utils::Replace::set_sh, IFCFG, KEY ], + [ "key_type", \&set_wep_key_full, [ \&Utils::Replace::set_sh, IFCFG, KEY, "%key%" ]], + [ "update_dns", \&Utils::Replace::set_sh_bool, IFCFG, PEERDNS ], + [ "remote_address", \&Utils::Replace::set_sh, IFCFG, REMIP ], + [ "login", \&Utils::Replace::set_sh, IFCFG, PAPNAME ], + [ "serial_port", \&Utils::Replace::set_sh, IFCFG, MODEMPORT ], + [ "serial_speed", \&Utils::Replace::set_sh, IFCFG, LINESPEED ], + [ "section", \&Utils::Replace::set_sh, IFCFG, WVDIALSECT ], + [ "set_default_gw", \&Utils::Replace::set_sh_bool, IFCFG, DEFROUTE ], + [ "persist", \&Utils::Replace::set_sh_bool, IFCFG, PERSIST ], + [ "phone_number", \&Utils::Replace::set_chat, CHAT, "^atd[^0-9]*([0-9, -]+)" ], +# [ "update_dns", \&gst_network_pump_set_nodns, PUMP, "%dev%", "%bootproto%" ], +# [ "dns1", \&Utils::Replace::set_sh, IFCFG, DNS1 ], +# [ "dns2", \&Utils::Replace::set_sh, IFCFG, DNS2 ], +# [ "mtu", \&Utils::Replace::set_sh, IFCFG, MTU ], +# [ "mru", \&Utils::Replace::set_sh, IFCFG, MRU ], +# [ "ppp_options", \&Utils::Replace::set_sh, IFCFG, PPPOPTIONS ], +# [ "debug", \&Utils::Replace::set_sh_bool, IFCFG, DEBUG ], +# [ "serial_escapechars", \&Utils::Replace::set_sh_bool, IFCFG, ESCAPECHARS ], +# [ "serial_hwctl", \&Utils::Replace::set_sh_bool, IFCFG, HARDFLOWCTL ], + # wvdial settings + [ "phone_number", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Phone" ]], + [ "update_dns", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Auto DNS" ]], + [ "login", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Username" ]], + [ "password", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Password" ]], + [ "serial_port", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Modem" ]], + [ "serial_speed", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Baud" ]], + [ "set_default_gw", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Check Def Route" ]], + [ "persist", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Auto Reconnect" ]], + [ "dial_command", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Dial Command" ]], + [ "external_line", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Dial Prefix" ]], + ] + }, + + "redhat-8.0" => + { + iface_set => \&activate_interface, + iface_delete => \&delete_rh72_interface, + fn => + { + IFCFG => ["/etc/sysconfig/network-scripts/ifcfg-#iface#", + "/etc/sysconfig/networking/profiles/default/ifcfg-#iface#", + "/etc/sysconfig/networking/devices/ifcfg-#iface#"], + CHAT => "/etc/sysconfig/network-scripts/chat-#iface#", + IFACE => "#iface#", + WVDIAL => "/etc/wvdial.conf", + PUMP => "/etc/pump.conf" + }, + table => + [ + [ "bootproto", \&set_rh_bootproto, IFCFG, BOOTPROTO ], + [ "auto", \&Utils::Replace::set_sh_bool, IFCFG, ONBOOT ], + [ "dev" , \&Utils::Replace::set_sh, IFCFG, NAME ], + [ "dev", \&Utils::Replace::set_sh, IFCFG, DEVICE ], + [ "address", \&Utils::Replace::set_sh, IFCFG, IPADDR ], + [ "netmask", \&Utils::Replace::set_sh, IFCFG, NETMASK ], + [ "broadcast", \&Utils::Replace::set_sh, IFCFG, BROADCAST ], + [ "network", \&Utils::Replace::set_sh, IFCFG, NETWORK ], + [ "gateway", \&Utils::Replace::set_sh, IFCFG, GATEWAY ], + [ "essid", \&Utils::Replace::set_sh, IFCFG, WIRELESS_ESSID ], + [ "key", \&Utils::Replace::set_sh, IFCFG, WIRELESS_KEY ], + [ "key_type", \&set_wep_key_full, [ \&Utils::Replace::set_sh, IFCFG, WIRELESS_KEY, "%key%" ]], + [ "update_dns", \&Utils::Replace::set_sh_bool, IFCFG, PEERDNS ], + [ "remote_address", \&Utils::Replace::set_sh, IFCFG, REMIP ], + [ "login", \&Utils::Replace::set_sh, IFCFG, PAPNAME ], + [ "serial_port", \&Utils::Replace::set_sh, IFCFG, MODEMPORT ], + [ "section", \&Utils::Replace::set_sh, IFCFG, WVDIALSECT ], + [ "set_default_gw", \&Utils::Replace::set_sh_bool, IFCFG, DEFROUTE ], + [ "persist", \&Utils::Replace::set_sh_bool, IFCFG, PERSIST ], + [ "phone_number", \&Utils::Replace::set_chat, CHAT, "^atd[^0-9]*([0-9, -]+)" ], +# [ "update_dns", \&gst_network_pump_set_nodns, PUMP, "%dev%", "%bootproto%" ], +# [ "dns1", \&Utils::Replace::set_sh, IFCFG, DNS1 ], +# [ "dns2", \&Utils::Replace::set_sh, IFCFG, DNS2 ], +# [ "mtu", \&Utils::Replace::set_sh, IFCFG, MTU ], +# [ "mru", \&Utils::Replace::set_sh, IFCFG, MRU ], +# [ "serial_speed", \&Utils::Replace::set_sh, IFCFG, LINESPEED ], +# [ "ppp_options", \&Utils::Replace::set_sh, IFCFG, PPPOPTIONS ], +# [ "debug", \&Utils::Replace::set_sh_bool, IFCFG, DEBUG ], +# [ "serial_escapechars", \&Utils::Replace::set_sh_bool, IFCFG, ESCAPECHARS ], +# [ "serial_hwctl", \&Utils::Replace::set_sh_bool, IFCFG, HARDFLOWCTL ], + # wvdial settings + [ "phone_number", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Phone" ]], + [ "update_dns", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Auto DNS" ]], + [ "login", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Username" ]], + [ "password", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Password" ]], + [ "serial_port", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Modem" ]], + [ "serial_speed", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Baud" ]], + [ "set_default_gw", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Check Def Route" ]], + [ "persist", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Auto Reconnect" ]], + [ "dial_command", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Dial Command" ]], + [ "external_line", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Dial Prefix" ]], + ] + }, + + "vine-3.0" => + { + iface_set => \&activate_interface, + iface_delete => \&delete_rh62_interface, + fn => + { + IFCFG => "/etc/sysconfig/network-scripts/ifcfg-#iface#", + CHAT => "/etc/sysconfig/network-scripts/chat-#iface#", + IFACE => "#iface#", + WVDIAL => "/etc/wvdial.conf", + PUMP => "/etc/pump.conf" + }, + table => + [ + [ "bootproto", \&set_rh_bootproto, IFCFG, BOOTPROTO ], + [ "auto", \&Utils::Replace::set_sh_bool, IFCFG, ONBOOT ], + [ "dev", \&Utils::Replace::set_sh, IFCFG, NAME ], + [ "dev", \&Utils::Replace::set_sh, IFCFG, DEVICE ], + [ "address", \&Utils::Replace::set_sh, IFCFG, IPADDR ], + [ "netmask", \&Utils::Replace::set_sh, IFCFG, NETMASK ], + [ "broadcast", \&Utils::Replace::set_sh, IFCFG, BROADCAST ], + [ "network", \&Utils::Replace::set_sh, IFCFG, NETWORK ], + [ "gateway", \&Utils::Replace::set_sh, IFCFG, GATEWAY ], + [ "essid", \&Utils::Replace::set_sh, IFCFG, ESSID ], + [ "key", \&Utils::Replace::set_sh, IFCFG, KEY ], + [ "key_type", \&set_wep_key_full, [ \&Utils::Replace::set_sh, IFCFG, KEY, "%key%" ]], + [ "update_dns", \&Utils::Replace::set_sh_bool, IFCFG, PEERDNS ], + [ "remote_address", \&Utils::Replace::set_sh, IFCFG, REMIP ], + [ "login", \&Utils::Replace::set_sh, IFCFG, PAPNAME ], + [ "serial_port", \&Utils::Replace::set_sh, IFCFG, MODEMPORT ], + [ "serial_speed", \&Utils::Replace::set_sh, IFCFG, LINESPEED ], + [ "section", \&Utils::Replace::set_sh, IFCFG, WVDIALSECT ], + [ "set_default_gw", \&Utils::Replace::set_sh_bool, IFCFG, DEFROUTE ], + [ "persist", \&Utils::Replace::set_sh_bool, IFCFG, PERSIST ], + [ "phone_number", \&Utils::Replace::set_chat, CHAT, "^atd[^0-9]*([0-9, -]+)" ], +# [ "update_dns", \&gst_network_pump_set_nodns, PUMP, "%dev%", "%bootproto%" ], +# [ "dns1", \&Utils::Replace::set_sh, IFCFG, DNS1 ], +# [ "dns2", \&Utils::Replace::set_sh, IFCFG, DNS2 ], +# [ "mtu", \&Utils::Replace::set_sh, IFCFG, MTU ], +# [ "mru", \&Utils::Replace::set_sh, IFCFG, MRU ], +# [ "ppp_options", \&Utils::Replace::set_sh, IFCFG, PPPOPTIONS ], +# [ "debug", \&Utils::Replace::set_sh_bool, IFCFG, DEBUG ], +# [ "serial_escapechars", \&Utils::Replace::set_sh_bool, IFCFG, ESCAPECHARS ], +# [ "serial_hwctl", \&Utils::Replace::set_sh_bool, IFCFG, HARDFLOWCTL ], + + # wvdial settings + [ "phone_number", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Phone" ]], + [ "update_dns", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Auto DNS" ]], + [ "login", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Username" ]], + [ "password", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Password" ]], + [ "serial_port", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Modem" ]], + [ "serial_speed", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Baud" ]], + [ "set_default_gw", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Check Def Route" ]], + [ "persist", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Auto Reconnect" ]], + [ "dial_command", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Dial Command" ]], + [ "external_line", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Dial Prefix" ]], + ] + }, + + "mandrake-9.0" => + { + iface_set => \&activate_interface, + iface_delete => \&delete_rh62_interface, + fn => + { + IFCFG => "/etc/sysconfig/network-scripts/ifcfg-#iface#", + CHAT => "/etc/sysconfig/network-scripts/chat-#iface#", + IFACE => "#iface#", + WVDIAL => "/etc/wvdial.conf", + PUMP => "/etc/pump.conf" + }, + table => + [ + [ "bootproto", \&set_rh_bootproto, IFCFG, BOOTPROTO ], + [ "auto", \&Utils::Replace::set_sh_bool, IFCFG, ONBOOT ], + [ "dev", \&Utils::Replace::set_sh, IFCFG, NAME ], + [ "dev", \&Utils::Replace::set_sh, IFCFG, DEVICE ], + [ "address", \&Utils::Replace::set_sh, IFCFG, IPADDR ], + [ "netmask", \&Utils::Replace::set_sh, IFCFG, NETMASK ], + [ "broadcast", \&Utils::Replace::set_sh, IFCFG, BROADCAST ], + [ "network", \&Utils::Replace::set_sh, IFCFG, NETWORK ], + [ "gateway", \&Utils::Replace::set_sh, IFCFG, GATEWAY ], + [ "essid", \&Utils::Replace::set_sh, IFCFG, WIRELESS_ESSID ], + [ "key", \&Utils::Replace::set_sh, IFCFG, WIRELESS_KEY ], + [ "key_type", \&set_wep_key_full, [ \&Utils::Replace::set_sh, IFCFG, WIRELESS_KEY, "%key%" ]], + [ "update_dns", \&Utils::Replace::set_sh_bool, IFCFG, PEERDNS ], + [ "remote_address", \&Utils::Replace::set_sh, IFCFG, REMIP ], + [ "login", \&Utils::Replace::set_sh, IFCFG, PAPNAME ], + [ "serial_port", \&Utils::Replace::set_sh, IFCFG, MODEMPORT ], + [ "section", \&Utils::Replace::set_sh, IFCFG, WVDIALSECT ], + [ "set_default_gw", \&Utils::Replace::set_sh_bool, IFCFG, DEFROUTE ], + [ "persist", \&Utils::Replace::set_sh_bool, IFCFG, PERSIST ], + [ "phone_number", \&Utils::Replace::set_chat, CHAT, "^atd[^0-9]*([0-9, -]+)" ], +# [ "update_dns", \&gst_network_pump_set_nodns, PUMP, "%dev%", "%bootproto%" ], +# [ "dns1", \&Utils::Replace::set_sh, IFCFG, DNS1 ], +# [ "dns2", \&Utils::Replace::set_sh, IFCFG, DNS2 ], +# [ "mtu", \&Utils::Replace::set_sh, IFCFG, MTU ], +# [ "mru", \&Utils::Replace::set_sh, IFCFG, MRU ], +# [ "serial_speed", \&Utils::Replace::set_sh, IFCFG, LINESPEED ], +# [ "ppp_options", \&Utils::Replace::set_sh, IFCFG, PPPOPTIONS ], +# [ "debug", \&Utils::Replace::set_sh_bool, IFCFG, DEBUG ], +# [ "serial_escapechars", \&Utils::Replace::set_sh_bool, IFCFG, ESCAPECHARS ], +# [ "serial_hwctl", \&Utils::Replace::set_sh_bool, IFCFG, HARDFLOWCTL ], + # wvdial settings + [ "phone_number", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Phone" ]], + [ "update_dns", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Auto DNS" ]], + [ "login", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Username" ]], + [ "password", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Password" ]], + [ "serial_port", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Modem" ]], + [ "serial_speed", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Baud" ]], + [ "set_default_gw", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Check Def Route" ]], + [ "persist", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Auto Reconnect" ]], + [ "dial_command", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Dial Command" ]], + [ "external_line", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Dial Prefix" ]], + ] + }, + + "conectiva-9" => + { + iface_set => \&activate_interface, + iface_delete => \&delete_rh62_interface, + fn => + { + IFCFG => "/etc/sysconfig/network-scripts/ifcfg-#iface#", + CHAT => "/etc/sysconfig/network-scripts/chat-#iface#", + IFACE => "#iface#", + WVDIAL => "/etc/wvdial.conf", + PUMP => "/etc/pump.conf" + }, + table => + [ + [ "bootproto", \&set_rh_bootproto, IFCFG, BOOTPROTO ], + [ "auto", \&Utils::Replace::set_sh_bool, IFCFG, ONBOOT ], + [ "dev" , \&Utils::Replace::set_sh, IFCFG, NAME ], + [ "dev", \&Utils::Replace::set_sh, IFCFG, DEVICE ], + [ "address", \&Utils::Replace::set_sh, IFCFG, IPADDR ], + [ "netmask", \&Utils::Replace::set_sh, IFCFG, NETMASK ], + [ "broadcast", \&Utils::Replace::set_sh, IFCFG, BROADCAST ], + [ "network", \&Utils::Replace::set_sh, IFCFG, NETWORK ], + [ "gateway", \&Utils::Replace::set_sh, IFCFG, GATEWAY ], + [ "essid", \&Utils::Replace::set_sh, IFCFG, WIRELESS_ESSID ], + [ "key", \&Utils::Replace::set_sh, IFCFG, WIRELESS_KEY ], + [ "key_type", \&set_wep_key_full, [ \&Utils::Replace::set_sh, IFCFG, WIRELESS_KEY, "%key%" ]], + [ "update_dns", \&Utils::Replace::set_sh_bool, IFCFG, PEERDNS ], + [ "remote_address", \&Utils::Replace::set_sh, IFCFG, REMIP ], + [ "login", \&Utils::Replace::set_sh, IFCFG, PAPNAME ], + [ "serial_port", \&Utils::Replace::set_sh, IFCFG, MODEMPORT ], + [ "section", \&Utils::Replace::set_sh, IFCFG, WVDIALSECT ], + [ "set_default_gw", \&Utils::Replace::set_sh_bool, IFCFG, DEFROUTE ], + [ "persist", \&Utils::Replace::set_sh_bool, IFCFG, PERSIST ], + [ "phone_number", \&Utils::Replace::set_chat, CHAT, "^atd[^0-9]*([0-9, -]+)" ], +# [ "update_dns", \&gst_network_pump_set_nodns, PUMP, "%dev%", "%bootproto%" ], +# [ "dns1", \&Utils::Replace::set_sh, IFCFG, DNS1 ], +# [ "dns2", \&Utils::Replace::set_sh, IFCFG, DNS2 ], +# [ "mtu", \&Utils::Replace::set_sh, IFCFG, MTU ], +# [ "mru", \&Utils::Replace::set_sh, IFCFG, MRU ], +# [ "serial_speed", \&Utils::Replace::set_sh, IFCFG, LINESPEED ], +# [ "ppp_options", \&Utils::Replace::set_sh, IFCFG, PPPOPTIONS ], +# [ "debug", \&Utils::Replace::set_sh_bool, IFCFG, DEBUG ], +# [ "serial_escapechars", \&Utils::Replace::set_sh_bool, IFCFG, ESCAPECHARS ], +# [ "serial_hwctl", \&Utils::Replace::set_sh_bool, IFCFG, HARDFLOWCTL ], + # wvdial settings + [ "phone_number", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Phone" ]], + [ "update_dns", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Auto DNS" ]], + [ "login", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Username" ]], + [ "password", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Password" ]], + [ "serial_port", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Modem" ]], + [ "serial_speed", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Baud" ]], + [ "set_default_gw", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Check Def Route" ]], + [ "persist", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Auto Reconnect" ]], + [ "dial_command", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Dial Command" ]], + [ "external_line", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Dial Prefix" ]], + ] + }, + + "debian-3.0" => + { + iface_set => \&activate_interface, + iface_delete => \&delete_debian_interface, + fn => + { + INTERFACES => "/etc/network/interfaces", + IFACE => "#iface#", + CHAT => "/etc/chatscripts/%section%", + PPP_OPTIONS => "/etc/ppp/peers/%section%", + PAP => "/etc/ppp/pap-secrets", + CHAP => "/etc/ppp/chap-secrets", + }, + table => + [ + [ "_always_", \&set_debian_bootproto, [INTERFACES, IFACE]], + [ "bootproto", \&set_debian_bootproto, [INTERFACES, IFACE]], + [ "auto", \&set_debian_auto, [INTERFACES, IFACE]], + [ "address", \&Utils::Replace::set_interfaces_option_str, [INTERFACES, IFACE], "address" ], + [ "netmask", \&Utils::Replace::set_interfaces_option_str, [INTERFACES, IFACE], "netmask" ], + [ "gateway", \&Utils::Replace::set_interfaces_option_str, [INTERFACES, IFACE], "gateway" ], + [ "essid", \&Utils::Replace::set_interfaces_option_str, [INTERFACES, IFACE], "wireless-essid" ], + [ "key", \&Utils::Replace::set_interfaces_option_str, [INTERFACES, IFACE], "wireless-key" ], + [ "key_type", \&set_wep_key_full, [ \&Utils::Replace::set_interfaces_option_str, INTERFACES, IFACE, "wireless-key", "%key%" ]], + # ugly hack for deleting undesired options (due to syntax duality) + [ "essid", \&Utils::Replace::set_interfaces_option_str, [INTERFACES, IFACE], "wireless_essid", "" ], + [ "key", \&Utils::Replace::set_interfaces_option_str, [INTERFACES, IFACE], "wireless_key", "" ], + [ "key", \&Utils::Replace::set_interfaces_option_str, [INTERFACES, IFACE], "wireless_key1", "" ], + # End of hack + [ "section", \&Utils::Replace::set_interfaces_option_str, [INTERFACES, IFACE], "provider" ], + [ "remote_address", \&set_debian_remote_address, [INTERFACES, IFACE]], + # Modem stuff + [ "section", \&check_type, [IFACE, "modem", \&Utils::Replace::set_ppp_options_connect, PPP_OPTIONS ]], + [ "phone_number", \&check_type, [IFACE, "modem", \&create_pppscript, CHAT ]], + [ "phone_number", \&check_type, [IFACE, "isdn", \&create_isdn_options, PPP_OPTIONS ]], + [ "update_dns", \&check_type, [IFACE, "(modem|isdn)", \&Utils::Replace::set_kw, PPP_OPTIONS, "usepeerdns" ]], + [ "noauth", \&check_type, [IFACE, "(modem|isdn)", \&Utils::Replace::set_kw, PPP_OPTIONS, "noauth" ]], + [ "set_default_gw", \&check_type, [IFACE, "(modem|isdn)", \&Utils::Replace::set_kw, PPP_OPTIONS, "defaultroute" ]], + [ "persist", \&check_type, [IFACE, "(modem|isdn)", \&Utils::Replace::set_kw, PPP_OPTIONS, "persist" ]], + [ "serial_port", \&check_type, [IFACE, "modem", \&Utils::Replace::set_ppp_options_re, PPP_OPTIONS, "^(/dev/[^ \t]+)" ]], + [ "login", \&check_type, [IFACE, "(modem|isdn)", \&Utils::Replace::set_ppp_options_re, PPP_OPTIONS, "^user (.*)", "user \"%login%\"" ]], + [ "password", \&check_type, [IFACE, "(modem|isdn)", \&set_pap_passwd, PAP, "%login%" ]], + [ "password", \&check_type, [IFACE, "(modem|isdn)", \&set_pap_passwd, CHAP, "%login%" ]], + [ "dial_command", \&check_type, [IFACE, "modem", \&Utils::Replace::set_chat, CHAT, "(atd[tp])[0-9w, -]+" ]], + [ "phone_number", \&check_type, [IFACE, "modem", \&Utils::Replace::set_chat, CHAT, "atd[tp]([0-9w]+)" ]], + [ "external_line", \&check_type, [IFACE, "modem", \&Utils::Replace::set_chat, CHAT, "atd[tp]([0-9w, -]+)", "%external_line%W%phone_number%" ]], + [ "phone_number", \&check_type, [IFACE, "isdn", \&Utils::Replace::set_ppp_options_re, PPP_OPTIONS, "^number (.*)", "number %phone_number%" ]], + [ "external_line", \&check_type, [IFACE, "isdn", \&Utils::Replace::set_ppp_options_re, PPP_OPTIONS, "^number (.*)", "number %external_line%W%phone_number%" ]], + [ "volume", \&check_type, [IFACE, "modem", \&set_modem_volume, CHAT ]], +# [ "serial_escapechars", \&check_type, [IFACE, "modem", \&Utils::Replace::join_first_str, PPP_OPTIONS, "escape", "[ \t]+" ]], +# [ "debug", \&check_type, [IFACE, "(modem|isdn)", \&Utils::Replace::set_kw, PPP_OPTIONS, "debug" ]], +# [ "serial_hwctl", \&check_type, [IFACE, "modem", \&Utils::Replace::set_kw, PPP_OPTIONS, "crtscts" ]], +# [ "mtu", \&check_type, [IFACE, "(modem|isdn)", \&Utils::Replace::join_first_str, PPP_OPTIONS, "mtu", "[ \t]+" ]], +# [ "mru", \&check_type, [IFACE, "(modem|isdn)", \&Utils::Replace::join_first_str, PPP_OPTIONS, "mru", "[ \t]+" ]], +# [ "serial_speed", \&check_type, [IFACE, "modem", \&Utils::Replace::set_ppp_options_re, PPP_OPTIONS, "^([0-9]+)" ]], + ] + }, + + "suse-9.0" => + { + iface_set => \&activate_suse_interface, + iface_delete => \&delete_suse_interface, + fn => + { + IFCFG => "/etc/sysconfig/network/ifcfg-#iface#", + PROVIDERS => "/etc/sysconfig/network/providers/%section%", + ROUTE_CONF => "/etc/sysconfig/network/routes", + IFACE => "#iface#", + PPP_OPTIONS => "/etc/ppp/options" + }, + table => + [ + [ "auto", \&set_suse_auto, IFCFG, STARTMODE ], + [ "bootproto", \&set_suse_bootproto, IFCFG, BOOTPROTO ], + [ "address", \&Utils::Replace::set_sh, IFCFG, IPADDR ], + [ "netmask", \&Utils::Replace::set_sh, IFCFG, NETMASK ], + [ "remote_address", \&Utils::Replace::set_sh, IFCFG, REMOTE_IPADDR ], + [ "essid", \&Utils::Replace::set_sh, IFCFG, WIRELESS_ESSID ], + [ "key", \&Utils::Replace::set_sh, IFCFG, WIRELESS_KEY ], + [ "key_type", \&set_wep_key_full, [ \&Utils::Replace::set_sh, IFCFG, WIRELESS_KEY, "%key%" ]], + # Modem stuff goes here + [ "serial_port", \&Utils::Replace::set_sh, IFCFG, MODEM_DEVICE ], + [ "ppp_options", \&Utils::Replace::set_sh, IFCFG, PPPD_OPTIONS ], + [ "dial_command", \&Utils::Replace::set_sh, IFCFG, DIALCOMMAND], + [ "external_line", \&Utils::Replace::set_sh, IFCFG, DIALPREFIX], + [ "provider", \&Utils::Replace::set_sh, IFCFG, PROVIDER ], + [ "volume", \&check_type, [ IFACE, "modem", \&set_modem_volume_sh, IFCFG, INIT8 ]], + [ "login", \&Utils::Replace::set_sh, PROVIDERS, USERNAME ], + [ "password", \&Utils::Replace::set_sh, PROVIDERS, PASSWORD ], + [ "phone_number", \&Utils::Replace::set_sh, PROVIDERS, PHONE ], + [ "update_dns", \&Utils::Replace::set_sh_bool, PROVIDERS, MODIFYDNS ], + [ "persist", \&Utils::Replace::set_sh_bool, PROVIDERS, PERSIST ], + [ "set_default_gw", \&Utils::Replace::set_sh_bool, PROVIDERS, DEFAULTROUTE ], +# [ "serial_speed", \&Utils::Replace::set_sh, IFCFG, SPEED ], +# [ "mtu", \&Utils::Replace::set_sh, IFCFG, MTU ], +# [ "mru", \&Utils::Replace::set_sh, IFCFG, MRU ], +# [ "dns1", \&Utils::Replace::set_sh, PROVIDER, DNS1 ], +# [ "dns2", \&Utils::Replace::set_sh, PROVIDER, DNS2 ], +# [ "stupid", \&Utils::Replace::set_sh_bool, PROVIDER, STUPIDMODE ], + ] + }, + + "pld-1.0" => + { + iface_set => \&activate_interface, + iface_delete => \&delete_pld_interface, + fn => + { + IFCFG => "/etc/sysconfig/interfaces/ifcfg-#iface#", + CHAT => "/etc/sysconfig/interfaces/data/chat-#iface#", + IFACE => "#iface#", + WVDIAL => "/etc/wvdial.conf", + PUMP => "/etc/pump.conf" + }, + table => + [ + [ "bootproto", \&set_rh_bootproto, IFCFG, BOOTPROTO ], + [ "auto", \&Utils::Replace::set_sh_bool, IFCFG, ONBOOT ], + [ "dev", \&Utils::Replace::set_sh, IFCFG, DEVICE ], + [ "address", \&set_pld_ipaddr, IFCFG, IPADDR, "address" ], + [ "netmask", \&set_pld_ipaddr, IFCFG, IPADDR, "netmask" ], + [ "gateway", \&Utils::Replace::set_sh, IFCFG, GATEWAY ], + [ "update_dns", \&Utils::Replace::set_sh_bool, IFCFG, PEERDNS ], + [ "remote_address", \&Utils::Replace::set_sh, IFCFG, REMIP ], + [ "login", \&Utils::Replace::set_sh, IFCFG, PAPNAME ], + [ "serial_port", \&Utils::Replace::set_sh, IFCFG, MODEMPORT ], + [ "ppp_options", \&Utils::Replace::set_sh, IFCFG, PPPOPTIONS ], + [ "set_default_gw", \&Utils::Replace::set_sh_bool, IFCFG, DEFROUTE ], + [ "persist", \&Utils::Replace::set_sh_bool, IFCFG, PERSIST ], + [ "phone_number", \&Utils::Replace::set_chat, CHAT, "^atd[^0-9]*([0-9, -]+)" ] +# [ "name", \&Utils::Replace::set_sh, IFCFG, NAME ], +# [ "broadcast", \&Utils::Replace::set_sh, IFCFG, BROADCAST ], +# [ "network", \&Utils::Replace::set_sh, IFCFG, NETWORK ], +# [ "update_dns", \&gst_network_pump_set_nodns, PUMP, "%dev%", "%bootproto%" ], +# [ "dns1", \&Utils::Replace::set_sh, IFCFG, DNS1 ], +# [ "dns2", \&Utils::Replace::set_sh, IFCFG, DNS2 ], +# [ "mtu", \&Utils::Replace::set_sh, IFCFG, MTU ], +# [ "mru", \&Utils::Replace::set_sh, IFCFG, MRU ], +# [ "serial_speed", \&Utils::Replace::set_sh, IFCFG, LINESPEED ], +# [ "section", \&Utils::Replace::set_sh, IFCFG, WVDIALSECT ], +# [ "debug", \&Utils::Replace::set_sh_bool, IFCFG, DEBUG ], +# [ "serial_escapechars", \&Utils::Replace::set_sh_bool, IFCFG, ESCAPECHARS ], +# [ "serial_hwctl", \&Utils::Replace::set_sh_bool, IFCFG, HARDFLOWCTL ], + ] + }, + + "slackware-9.1.0" => + { + iface_set => \&activate_slackware_interface, + iface_delete => \&delete_slackware_interface, + fn => + { + RC_INET_CONF => "/etc/rc.d/rc.inet1.conf", + RC_INET => "/etc/rc.d/rc.inet1", + RC_LOCAL => "/etc/rc.d/rc.local", + IFACE => "#iface#", + WIRELESS => "/etc/pcmcia/wireless.opts", + PPP_OPTIONS => "/etc/ppp/options", + PAP => "/etc/ppp/pap-secrets", + CHAP => "/etc/ppp/chap-secrets", + CHAT => "/etc/ppp/pppscript", + }, + table => + [ + [ "address", \&Utils::Replace::set_rcinet1conf, [ RC_INET_CONF, IFACE ], IPADDR ], + [ "netmask", \&Utils::Replace::set_rcinet1conf, [ RC_INET_CONF, IFACE ], NETMASK ], + [ "bootproto", \&set_slackware_bootproto, [ RC_INET_CONF, IFACE ] ], + [ "auto", \&set_slackware_auto, [ RC_INET, RC_LOCAL, IFACE ] ], + [ "essid", \&Utils::Replace::set_wireless_opts, [ WIRELESS, IFACE ], \&get_wireless_ifaces, ESSID ], + [ "key", \&Utils::Replace::set_wireless_opts, [ WIRELESS, IFACE ], \&get_wireless_ifaces, KEY ], + [ "key_type", \&set_wep_key_full, [ \&Utils::Replace::set_wireless_opts, [ WIRELESS, IFACE ], \&get_wireless_ifaces, KEY, "%key%" ]], + # Modem stuff + [ "phone_number", \&check_type, [IFACE, "modem", \&create_pppscript, CHAT ]], + [ "phone_number", \&check_type, [IFACE, "modem", \&create_pppgo ]], + [ "update_dns", \&check_type, [IFACE, "modem", \&Utils::Replace::set_kw, PPP_OPTIONS, "usepeerdns" ]], + [ "noauth", \&check_type, [IFACE, "modem", \&Utils::Replace::set_kw, PPP_OPTIONS, "noauth" ]], + [ "set_default_gw", \&check_type, [IFACE, "modem", \&Utils::Replace::set_kw, PPP_OPTIONS, "defaultroute" ]], + [ "debug", \&check_type, [IFACE, "modem", \&Utils::Replace::set_kw, PPP_OPTIONS, "debug" ]], + [ "persist", \&check_type, [IFACE, "modem", \&Utils::Replace::set_kw, PPP_OPTIONS, "persist" ]], + [ "serial_hwctl", \&check_type, [IFACE, "modem", \&Utils::Replace::set_kw, PPP_OPTIONS, "crtscts" ]], + [ "mtu", \&check_type, [IFACE, "modem", \&Utils::Replace::join_first_str, PPP_OPTIONS, "mtu", "[ \t]+" ]], + [ "mru", \&check_type, [IFACE, "modem", \&Utils::Replace::join_first_str, PPP_OPTIONS, "mru", "[ \t]+" ]], + [ "serial_port", \&check_type, [IFACE, "modem", \&Utils::Replace::set_ppp_options_re, PPP_OPTIONS, "^(/dev/[^ \t]+)" ]], + [ "serial_speed", \&check_type, [IFACE, "modem", \&Utils::Replace::set_ppp_options_re, PPP_OPTIONS, "^([0-9]+)" ]], + [ "login", \&check_type, [IFACE, "modem", \&Utils::Replace::set_ppp_options_re, PPP_OPTIONS, "^name \"(.*)\"", "name \"%login%\"" ]], + [ "serial_escapechars", \&check_type, [IFACE, "modem", \&Utils::Replace::join_first_str, PPP_OPTIONS, "escape", "[ \t]+" ]], + [ "password", \&check_type, [IFACE, "modem", \&set_pap_passwd, PAP, "%login%" ]], + [ "password", \&check_type, [IFACE, "modem", \&set_pap_passwd, CHAP, "%login%" ]], + [ "dial_command", \&check_type, [IFACE, "modem", \&Utils::Replace::set_chat, CHAT, "(atd[tp])[0-9w, -]+" ]], + [ "phone_number", \&check_type, [IFACE, "modem", \&Utils::Replace::set_chat, CHAT, "atd[tp]([0-9w]+)" ]], + [ "external_line", \&check_type, [IFACE, "modem", \&Utils::Replace::set_chat, CHAT, "atd[tp]([0-9w, -]+)", "%external_line%W%phone_number%" ]], + [ "volume", \&check_type, [IFACE, "modem", \&set_modem_volume, CHAT ]], + #[ "ppp_options", \&check_type, [IFACE, "modem", \&gst_network_set_ppp_options_unsup, PPP_OPTIONS ]], + ] + }, + + "gentoo" => + { + iface_set => \&activate_gentoo_interface, + iface_delete => \&delete_gentoo_interface, + fn => + { + NET => "/etc/conf.d/net", + PPPNET => "/etc/conf.d/net.#iface#", + INIT => "net.#iface#", + IFACE => "#iface#", + WIRELESS => "/etc/pcmcia/wireless.opts", + }, + table => + [ + [ "dev", \&create_gentoo_files ], + [ "auto", \&set_gentoo_service_status, INIT, "default" ], + [ "bootproto", \&set_gentoo_bootproto, [ NET, IFACE ]], + [ "address", \&Utils::Replace::set_sh_re, NET, "iface_%dev%", "^[ \t]*([0-9\.]+)" ], + [ "netmask", \&Utils::Replace::set_sh_re, NET, "iface_%dev%", "[ \t]+netmask[ \t]+[0-9\.]*", " netmask %netmask%"], + [ "broadcast", \&Utils::Replace::set_sh_re, NET, "iface_%dev%", "[ \t]+broadcast[ \t]+[0-9\.]*", " broadcast %broadcast%" ], + [ "remote_address", \&Utils::Replace::set_sh_re, NET, "iface_%dev%", "[ \t]+dest_address[ \t]+[0-9\.]*", " dest_address %remote_address%" ], + [ "essid", \&Utils::Replace::set_wireless_opts, [ WIRELESS, IFACE ], \&get_wireless_ifaces, ESSID ], + [ "key", \&Utils::Replace::set_wireless_opts, [ WIRELESS, IFACE ], \&get_wireless_ifaces, KEY ], + [ "key_type", \&set_wep_key_full, [ \&Utils::Replace::set_wireless_opts, [ WIRELESS, IFACE ], \&get_wireless_ifaces, KEY, "%key%" ]], + # modem stuff + [ "dev", \&check_type, [ IFACE, "modem", \&Utils::Replace::set_sh, PPPNET, PEER ]], + [ "update_dns", \&check_type, [ IFACE, "modem", \&Utils::Replace::set_sh_bool, PPPNET, PEERDNS ]], + [ "mtu", \&Utils::Replace::set_sh, PPPNET, MTU ], + [ "mru", \&Utils::Replace::set_sh, PPPNET, MRU ], + [ "serial_port", \&Utils::Replace::set_sh, PPPNET, MODEMPORT ], + [ "serial_speed", \&Utils::Replace::set_sh, PPPNET, LINESPEED ], + [ "login", \&Utils::Replace::set_sh, PPPNET, USERNAME ], + [ "password", \&Utils::Replace::set_sh, PPPNET, PASSWORD ], + [ "ppp_options", \&Utils::Replace::set_sh, PPPNET, PPPOPTIONS ], + [ "set_default_gw", \&Utils::Replace::set_sh_bool, PPPNET, DEFROUTE ], + [ "debug", \&Utils::Replace::set_sh_bool, PPPNET, DEBUG ], + [ "persist", \&Utils::Replace::set_sh_bool, PPPNET, PERSIST ], + [ "serial_escapechars", \&Utils::Replace::set_sh_bool, PPPNET, ESCAPECHARS ], + [ "serial_hwctl", \&Utils::Replace::set_sh_bool, PPPNET, HARDFLOWCTL ], + [ "phone_number", \&Utils::Replace::set_sh, PPPNET, NUMBER ], + [ "external_line", \&Utils::Replace::set_sh, PPPNET, NUMBER, "%external_line%W%phone_number%" ], + [ "volume", \&set_modem_volume_sh, PPPNET, INITSTRING ], + ] + }, + + "freebsd-5" => + { + iface_set => \&activate_freebsd_interface, + iface_delete => \&delete_freebsd_interface, + fn => + { + RC_CONF => "/etc/rc.conf", + STARTIF => "/etc/start_if.#iface#", + PPPCONF => "/etc/ppp/ppp.conf", + IFACE => "#iface#", + }, + table => + [ + [ "auto", \&set_freebsd_auto, [ RC_CONF, IFACE ]], + [ "bootproto", \&set_freebsd_bootproto, [ RC_CONF, IFACE ]], + [ "address", \&Utils::Replace::set_sh_re, RC_CONF, "ifconfig_%dev%", "inet[ \t]+([0-9\.]+)", "inet %address%" ], + [ "netmask", \&Utils::Replace::set_sh_re, RC_CONF, "ifconfig_%dev%", "netmask[ \t]+([0-9\.]+)", " netmask %netmask%" ], + [ "remote_address", \&Utils::Replace::set_sh_re, RC_CONF, "ifconfig_%dev%", "dest_address[ \t]+([0-9\.]+)", " dest_address %remote_address%" ], + [ "essid", \&set_freebsd_essid, [ RC_CONF, STARTIF, IFACE ]], + # Modem stuff + # we need this for putting an empty ifconfig_tunX command in rc.conf + [ "phone_number", \&Utils::Replace::set_sh, RC_CONF, "ifconfig_%dev%", " " ], + [ "file", \&create_ppp_startif, [ STARTIF, IFACE ]], + [ "persist", \&create_ppp_startif, [ STARTIF, IFACE ], "%file%" ], + [ "serial_port", \&Utils::Replace::set_pppconf, [ PPPCONF, STARTIF, IFACE ], "device" ], + [ "serial_speed", \&Utils::Replace::set_pppconf, [ PPPCONF, STARTIF, IFACE ], "speed" ], + [ "mtu", \&Utils::Replace::set_pppconf, [ PPPCONF, STARTIF, IFACE ], "mtu" ], + [ "mru", \&Utils::Replace::set_pppconf, [ PPPCONF, STARTIF, IFACE ], "mru" ], + [ "login", \&Utils::Replace::set_pppconf, [ PPPCONF, STARTIF, IFACE ], "authname" ], + [ "password", \&Utils::Replace::set_pppconf, [ PPPCONF, STARTIF, IFACE ], "authkey" ], + [ "update_dns", \&Utils::Replace::set_pppconf_bool, [ PPPCONF, STARTIF, IFACE ], "dns" ], + [ "set_default_gw", \&set_pppconf_route, [ PPPCONF, STARTIF, IFACE ], "default HISADDR" ], + [ "phone_number", \&Utils::Replace::set_pppconf, [ PPPCONF, STARTIF, IFACE ], "phone" ], + [ "external_line", \&Utils::Replace::set_pppconf, [ PPPCONF, STARTIF, IFACE ], "phone", "%external_line%W%phone_number%" ], + [ "dial_command", \&set_pppconf_dial_command, [ PPPCONF, STARTIF, IFACE ]], + [ "volume", \&set_pppconf_volume, [ PPPCONF, STARTIF, IFACE ]], + ] + } + ); + + my $dist = $dist_map{$Utils::Backend::tool{"platform"}}; + return %{$dist_tables{$dist}} if $dist; + + &Utils::Report::do_report ("platform_no_table", $Utils::Backend::tool{"platform"}); return undef; } -sub get_interfaces +sub add_dialup_iface +{ + my ($ifaces) = @_; + my ($dev, $i); + + $dev = "ppp0" if ($Utils::Backend::tool{"system"} eq "Linux"); + $dev = "tun0" if ($Utils::Backend::tool{"system"} eq "FreeBSD"); + + foreach $i (@$ifaces) + { + return if ($i eq $dev); + } + + push @$ifaces, $dev if (&Utils::File::locate_tool ("pppd")); +} + +sub get_interfaces_config { my (%dist_attrib, %config_hash, %hash, %fn); my (@config_ifaces, @ifaces, $iface, $dev); @@ -1579,6 +3055,7 @@ sub get_interfaces %fn = %{$dist_attrib{"fn"}}; $proc = $dist_attrib{"ifaces_get"}; + # FIXME: is proc necessary? why not using hash keys? if ($proc) { @ifaces = &$proc (); @@ -1588,18 +3065,16 @@ sub get_interfaces @ifaces = keys %hash; } + &add_dialup_iface (\@ifaces); + # clear unneeded hash elements foreach $i (@ifaces) { - delete $hash{$i}{"addr"}; - delete $hash{$i}{"bcast"}; - delete $hash{$i}{"mask"}; - foreach $j (keys (%fn)) { ${$dist_attrib{"fn"}}{$j} = &Utils::Parse::expand ($fn{$j}, "iface", $i, - "type", $hash{$i}{"type"}); + "type", &get_interface_type ($i)); } $iface = &Utils::Parse::get_from_table ($dist_attrib{"fn"}, @@ -1608,39 +3083,258 @@ sub get_interfaces &ensure_iface_broadcast_and_network ($iface); $$iface{"file"} = $i if ($$iface{"file"} eq undef); - $dev = $$iface{"dev"}; - delete $$iface{"dev"}; - - if (exists $hash{$dev}) + if (exists $hash{$i}) { - $hash{$dev}{"configuration"} = $iface; + foreach $k (keys %$iface) + { + $hash{$i}{$k} = $$iface{$k}; + } } - elsif (($dev eq "ppp0") || ($dev eq "tun0")) + elsif (($i eq "ppp0") || ($dev eq "tun0")) { - $modem_settings = $iface; + $hash{$i}{"dev"} = $i; + $hash{$i}{"enabled"} = 0; + + foreach $k (keys %$iface) + { + $hash{$i}{$k} = $$iface{$k}; + } } } - # only show PPP and ISDN devices if pppd exists - # and they aren't configured yet - $dev = "ppp0" if ($Utils::Backend::tool{"system"} eq "Linux"); - $dev = "tun0" if ($Utils::Backend::tool{"system"} eq "FreeBSD"); + return \%hash; +} + +sub interface_configured +{ + my ($iface) = @_; + my ($type); + + # FIXME: checking for "configuration" key is much better + $type = &get_interface_type ($$iface{"dev"}); + + if ($type eq "ethernet" || $type eq "irlan") + { + return 1 if ($$iface{"bootproto"} eq "dhcp" || ($$iface{"address"} && $$iface{"netmask"})); + } + elsif ($type eq "wireless") + { + return 1 if (($$iface{"bootproto"} eq "dhcp" || ($$iface{"address"} && $$iface{"netmask"})) && $$iface{"essid"}); + } + elsif ($type eq "plip") + { + return 1 if ($$iface{"bootproto"} eq "dhcp" || ($$iface{"address"} && $$iface{"remote_address"})); + } + elsif ($type eq "modem" || $type eq "isdn") + { + return 1 if ($$iface{"phone_number"} && $$iface{"login"}); + } + + return 0; +} + +sub set_interface_config +{ + my ($dev, $values_hash, $old_hash) = @_; + my (%dist_attrib, %fn); + my ($proc, $i, $res); + + &Utils::Report::enter (); + &Utils::Report::do_report ("network_iface_set", $dev); + + %dist_attrib = &get_interface_replace_table (); + $proc = $dist_attrib{"iface_set"}; + %fn = %{$dist_attrib{"fn"}}; - if (!exists $hash{$dev} && &Utils::File::locate_tool ("pppd")) + foreach $i (keys (%fn)) { - $hash{$dev}{"dev"} = $dev; - $hash{$dev}{"enabled"} = 0; - $hash{$dev}{"type"} = &get_interface_type ($dev); - $hash{$dev}{"configuration"} = $modem_settings if ($modem_settings); + $ {$dist_attrib{"fn"}}{$i} = &Utils::Parse::expand ($fn{$i}, "iface", $dev); } - return \%hash; + $res = &Utils::Replace::set_from_table ($dist_attrib{"fn"}, $dist_attrib{"table"}, + $values_hash, $old_hash); + + # if success saving the settings for the interface, set up immediatly. + &$proc ($values_hash, $old_hash, $$values_hash{"enabled"}, 0) if !$res; + + &Utils::Report::leave (); + return $res; +} + +sub set_interfaces_config +{ + my ($values_hash) = @_; + my ($old_hash); + my (%dist_attrib); + my ($i); + my ($delete_proc, $set_proc); + my ($do_active); + + &Utils::Report::enter (); + &Utils::Report::do_report ("network_ifaces_set"); + + %dist_attrib = &get_interface_replace_table (); + $old_hash = &get_interfaces_config (); + + $delete_proc = $dist_attrib{"iface_delete"}; + $set_proc = $dist_attrib{"iface_set"}; + + foreach $i (keys %$values_hash) + { + $do_active = $$values_hash{$i}{"enabled"}; + + # delete it if it's no longer configured + if (&interface_configured ($$old_hash{$i}) && + !&interface_configured ($$values_hash{$i})) + { + &$set_proc ($$values_hash{$i}, $$old_hash{$i}, 0, 1); + &$delete_proc ($$old_hash{$i}); + } + elsif (&interface_configured ($$values_hash{$i}) && + &interface_changed ($$values_hash{$i}, $$old_hash{$i})) + { + $$values_hash{$i}{"file"} = $$old_hash{$i}{"file"}; + + &$set_proc ($$values_hash{$i}, $$old_hash{$i}, 0, 1); + &set_interface_config ($i, $$values_hash{$i}, $$old_hash{$i}); + &$set_proc ($$values_hash{$i}, $$old_hash{$i}, 1, 1) if ($do_active); + } + elsif ($$values_hash{$i}{"enabled"} != $$old_hash{$i}{"enabled"}) + { + # only state has changed + &$set_proc ($$values_hash{$i}, $$old_hash{$i}, $do_active, 1); + } + + } + + &Utils::Report::leave (); } sub get { - &get_interfaces (); - return undef; + my ($config, $iface, $type); + my ($ethernet, $wireless, $irlan); + my ($plip, $modem, $isdn); + + $config = &get_interfaces_config (); + + foreach $i (keys %$config) + { + $iface = $$config{$i}; + $type = &get_interface_type ($i); + + if ($type eq "ethernet") + { + push @$ethernet, [ $$iface{"dev"}, $$iface{"enabled"}, + ($$iface{"bootproto"} eq "dhcp") ? 1 : 0, + $$iface{"address"}, $$iface{"netmask"}, + $$iface{"network"}, $$iface{"broadcast"} ]; + } + elsif ($type eq "wireless") + { + push @$wireless, [ $$iface{"dev"}, $$iface{"enabled"}, + ($$iface{"bootproto"} eq "dhcp") ? 1 : 0, + $$iface{"address"}, $$iface{"netmask"}, + $$iface{"network"}, $$iface{"broadcast"}, + $$iface{"essid"}, + ($$iface{"key_type"} eq "ascii") ? 0 : 1, + $$iface{"key"} ]; + } + elsif ($type eq "irlan") + { + push @$irlan, [ $$iface{"dev"}, $$iface{"enabled"}, + ($$iface{"bootproto"} eq "dhcp") ? 1 : 0, + $$iface{"address"}, $$iface{"netmask"}, + $$iface{"network"}, $$iface{"broadcast"} ]; + } + elsif ($type eq "plip") + { + push @$plip, [ $$iface{"dev"}, $$iface{"enabled"}, + $$iface{"address"}, $$iface{"remote_address"} ]; + } + elsif ($type eq "modem") + { + push @$modem, [ $$iface{"dev"}, $$iface{"enabled"}, + $$iface{"phone_number"}, $$iface{"external_line"}, + $$iface{"serial_port"}, $$iface{"volume"}, + ($$iface{"dial_command"} eq "atdt") ? 0 : 1, + $$iface{"login"}, $$iface{"password"}, + $$iface{"set_default_gw"}, $$iface{"update_dns"}, + $$iface{"persist"}, $$iface{"noauth"} ]; + } + elsif ($type eq "isdn") + { + push @$isdn, [ $$iface{"dev"}, $$iface{"enabled"}, + $$iface{"phone_number"}, $$iface{"external_line"}, + $$iface{"login"}, $$iface{"password"}, + $$iface{"set_default_gw"}, $$iface{"update_dns"}, + $$iface{"persist"}, $$iface{"noauth"} ]; + } + } + + return ($ethernet, $wireless, $irlan, + $plip, $modem, $isdn); +} + +sub set +{ + my ($ethernet, $wireless, $irlan, $plip, $modem, $isdn) = @_; + my (%hash, $iface, $bootproto, $key_type); + + foreach $iface (@$ethernet) + { + $bootproto = ($$iface[2] == 1) ? "dhcp" : "none"; + $hash{$$iface[0]} = { "dev" => $$iface[0], "enabled" => $$iface[1], + "bootproto" => $bootproto, + "address" => $$iface[3], "netmask" => $$iface[4] }; + } + + foreach $iface (@$wireless) + { + $bootproto = ($$iface[2] == 1) ? "dhcp" : "none"; + $key_type = ($$iface[8] == 1) ? "hexadecimal" : "ascii"; + $hash{$$iface[0]} = { "dev" => $$iface[0], "enabled" => $$iface[1], + "bootproto" => $bootproto, + "address" => $$iface[3], "netmask" => $$iface[4], + "essid" => $$iface[7], "key_type" => $key_type, "key" => $$iface[9] }; + } + + foreach $iface (@$irlan) + { + $bootproto = ($$iface[2] == 1) ? "dhcp" : "none"; + $hash{$$iface[0]} = { "dev" => $$iface[0], "enabled" => $$iface[1], + "bootproto" => $bootproto, + "address" => $$iface[3], "netmask" => $$iface[4] }; + } + + foreach $iface (@$plip) + { + $hash{$$iface[0]} = { "dev" => $$iface[0], "enabled" => $$iface[1], + "address" => $$iface[2], "remote_address" => $$iface[3] }; + } + + foreach $iface (@$modem) + { + $dial_command = ($$iface[6] == 0) ? "ATDT" : "ATDP"; + $hash{$$iface[0]} = { "dev" => $$iface[0], "enabled" => $$iface[1], + "phone_number" => $$iface[2], "external_line" => $$iface[3], + "serial_port" => $$iface[4], "volume" => $$iface[5], + "dial_command" => $dial_command, + "login" => $$iface[7], "password" => $$iface[8], + "set_default_gw" => $$iface[9], "update_dns"=> $$iface[10], + "persist" => $$iface[11], "noauth" => $$iface[12] }; + } + + foreach $iface (@$isdn) + { + $hash{$$iface[0]} = { "dev" => $$iface[0], "enabled" => $$iface[1], + "phone_number" => $$iface[2], "external_line" => $$iface[3], + "login" => $$iface[4], "password" => $$iface[5], + "set_default_gw" => $$iface[6], "update_dns"=> $$iface[7], + "persist" => $$iface[8], "noauth" => $$iface[9] }; + } + + &set_interfaces_config (\%hash); } 1; -- cgit v1.2.3