home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / share / system-tools-backends-2.0 / scripts / Network / Ifaces.pm < prev   
Encoding:
Perl POD Document  |  2006-08-14  |  140.0 KB  |  3,320 lines

  1. #-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2. # Network Interfaces Configuration handling
  3. #
  4. # Copyright (C) 2000-2001 Ximian, Inc.
  5. #
  6. # Authors: Hans Petter Jansson <hpj@ximian.com>
  7. #          Arturo Espinosa <arturo@ximian.com>
  8. #          Michael Vogt <mvo@debian.org> - Debian 2.[2|3] support.
  9. #          David Lee Ludwig <davidl@wpi.edu> - Debian 2.[2|3] support.
  10. #          Grzegorz Golawski <grzegol@pld-linux.org> - PLD support
  11. #
  12. # This program is free software; you can redistribute it and/or modify
  13. # it under the terms of the GNU Library General Public License as published
  14. # by the Free Software Foundation; either version 2 of the License, or
  15. # (at your option) any later version.
  16. #
  17. # This program is distributed in the hope that it will be useful,
  18. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. # GNU Library General Public License for more details.
  21. #
  22. # You should have received a copy of the GNU Library General Public License
  23. # along with this program; if not, write to the Free Software
  24. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
  25.  
  26. package Network::Ifaces;
  27.  
  28. use Utils::Util;
  29. use Init::Services;
  30.  
  31. # FIXME: this function isn't IPv6-aware
  32. # it checks if a IP address is in the same network than another
  33. sub is_ip_in_same_network
  34. {
  35.   my ($address1, $address2, $netmask) = @_;
  36.   my (@add1, @add2, @mask);
  37.   my ($i);
  38.  
  39.   return 0 if (!$address1 || !$address2 || !$netmask);
  40.  
  41.   @add1 = split (/\./, $address1);
  42.   @add2 = split (/\./, $address2);
  43.   @mask = split (/\./, $netmask);
  44.  
  45.   for ($i = 0; $i < 4; $i++)
  46.   {
  47.     $add1[$i] += 0;
  48.     $add2[$i] += 0;
  49.     $mask[$i] += 0;
  50.  
  51.     return 0 if (($add1[$i] & $mask[$i]) != ($add2[$i] & $mask[$i]));
  52.   }
  53.  
  54.   return 1;
  55. }
  56.  
  57. sub ensure_iface_broadcast_and_network
  58. {
  59.   my ($iface) = @_;
  60.     
  61.   if (exists $$iface{"netmask"} &&
  62.       exists $$iface{"address"})
  63.   {
  64.     if (! exists $$iface{"broadcast"})
  65.     {
  66.       $$iface{"broadcast"} = &Utils::Util::ip_calc_broadcast ($$iface{"address"}, $$iface{"netmask"});
  67.     }
  68.  
  69.     if (! exists $$iface{"network"})
  70.     {
  71.       $$iface{"network"} = &Utils::Util::ip_calc_network ($$iface{"address"}, $$iface{"netmask"});
  72.     }
  73.   }
  74. }
  75.  
  76. sub check_pppd_plugin
  77. {
  78.   my ($plugin) = @_;
  79.   my ($version, $output);
  80.  
  81.   $version = &Utils::File::run_backtick ("pppd --version", 1);
  82.   $version =~ s/.*version[ \t]+//;
  83.   chomp $version;
  84.  
  85.   return 0 if !version;
  86.   return &Utils::File::exists ("/usr/lib/pppd/$version/$plugin.so");
  87. }
  88.  
  89. sub check_capi
  90. {
  91.   my ($line, $i);
  92.  
  93.   if ($Utils::Backend::tool{"system"} ne "Linux")
  94.   {
  95.     return &check_pppd_plugin("capiplugin");
  96.   }
  97.  
  98.   $i=0;
  99.   $fd = &Utils::File::open_read_from_names ("proc/capi/controller");
  100.   return 0 if !$fd;
  101.  
  102.   while (($line = &Utils::Parse::chomp_line_hash_comment ($fd)) != -1)
  103.   {
  104.     $i++;
  105.   }
  106.  
  107.   return ($i > 0) ? &check_pppd_plugin("capiplugin") : 0;
  108. }
  109.  
  110. sub get_linux_wireless_ifaces
  111. {
  112.   my ($fd, $line);
  113.   my (@ifaces, $command);
  114.  
  115.   $command = &Utils::File::get_cmd_path ("iwconfig");
  116.   open $fd, "$command |";
  117.   return @ifaces if $fd eq undef;
  118.  
  119.   while (<$fd>)
  120.   {
  121.     if (/^([a-zA-Z0-9]+)[\t ].*$/)
  122.     {
  123.       push @ifaces, $1;
  124.     }
  125.   }
  126.  
  127.   &Utils::File::close_file ($fd);
  128.  
  129.   &Utils::Report::leave ();
  130.   return \@ifaces;
  131. }
  132.  
  133. sub get_freebsd_wireless_ifaces
  134. {
  135.   my ($fd, $line, $iface);
  136.   my (@ifaces, $command);
  137.  
  138.   $command = &Utils::File::get_cmd_path ("ifconfig");
  139.   open $fd, "$command |";
  140.   return @ifaces if $fd eq undef;
  141.  
  142.   while (<$fd>)
  143.   {
  144.     if (/^([a-zA-Z]+[0-9]+):/)
  145.     {
  146.       $iface = $1;
  147.     }
  148.  
  149.     if (/media:.*wireless.*/i)
  150.     {
  151.       push @ifaces, $iface;
  152.     }
  153.   }
  154.  
  155.   &Utils::File::close_file ($fd);
  156.   &Utils::Report::leave ();
  157.  
  158.   return \@ifaces;
  159. }
  160.  
  161. # Returns an array with the wireless devices found
  162. sub get_wireless_ifaces
  163. {
  164.   my ($plat) = $Utils::Backend::tool{"system"};
  165.     
  166.   return &get_linux_wireless_ifaces   if ($plat eq "Linux");
  167.   return &get_freebsd_wireless_ifaces if ($plat eq "FreeBSD");
  168. }
  169.  
  170. # returns interface type depending on it's interface name
  171. # types_cache is a global var for caching interface types
  172. sub get_interface_type
  173. {
  174.   my ($dev) = @_;
  175.   my (@wireless_ifaces, $wi, $type);
  176.  
  177.   return $types_cache{$dev} if (exists $types_cache{$dev});
  178.  
  179.   #check whether interface is wireless
  180.   $wireless_ifaces = &get_wireless_ifaces ();
  181.   foreach $wi (@$wireless_ifaces)
  182.   {
  183.     if ($dev eq $wi)
  184.     {
  185.       $types_cache{$dev} = "wireless";
  186.       return $types_cache{$dev};
  187.     }
  188.   }
  189.  
  190.   if ($dev =~ /^(ppp|tun)/)
  191.   {
  192.     # check whether the proper plugin exists
  193.     if (&check_capi ())
  194.     {
  195.       $types_cache{$dev} = "isdn";
  196.     }
  197.     else
  198.     {
  199.       $types_cache{$dev} = "modem";
  200.     }
  201.   }
  202.   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|wl|aue|axe|cue|kue|rue|fwe|nve|hme|ath|iwi|ipw|ral|ural|my)[0-9]/)
  203.   {
  204.     $types_cache{$dev} = "ethernet";
  205.   }
  206.   elsif ($dev =~ /irlan[0-9]/)
  207.   {
  208.     $types_cache{$dev} = "irlan";
  209.   }
  210.   elsif ($dev =~ /plip[0-9]/)
  211.   {
  212.     $types_cache{$dev} = "plip";
  213.   }
  214.   elsif ($dev =~ /lo[0-9]?/)
  215.   {
  216.     $types_cache{$dev} = "loopback";
  217.   }
  218.  
  219.   return $types_cache{$dev};
  220. }
  221.  
  222. sub get_freebsd_interfaces_info
  223. {
  224.   my ($dev, %ifaces, $fd);
  225.  
  226.   &Utils::Report::enter ();
  227.   &Utils::Report::do_report ("network_iface_active_get");
  228.  
  229.   $fd = &Utils::File::run_pipe_read ("ifconfig");
  230.   return {} if $fd eq undef;
  231.   
  232.   while (<$fd>)
  233.   {
  234.     chomp;
  235.     if (/^([^ \t:]+):.*(<.*>)/)
  236.     {
  237.       $dev = $1;
  238.       $ifaces{$dev}{"dev"}    = $dev;
  239.       $ifaces{$dev}{"enabled"} = 1 if ($2 =~ /[<,]UP[,>]/);
  240.     }
  241.     
  242.     s/^[ \t]+//;
  243.     if ($dev)
  244.     {
  245.       $ifaces{$dev}{"hwaddr"}  = $1 if /ether[ \t]+([^ \t]+)/i;
  246.       $ifaces{$dev}{"addr"}    = $1 if /inet[ \t]+([^ \t]+)/i;
  247.       $ifaces{$dev}{"mask"}    = $1 if /netmask[ \t]+([^ \t]+)/i;
  248.       $ifaces{$dev}{"bcast"}   = $1 if /broadcast[ \t]+([^ \t]+)/i;
  249.     }
  250.   }
  251.   
  252.   &Utils::File::close_file ($fd);
  253.   &Utils::Report::leave ();
  254.   return %ifaces;
  255. }
  256.  
  257. sub get_linux_interfaces_info
  258. {
  259.   my ($dev, %ifaces, $fd);
  260.  
  261.   &Utils::Report::enter ();
  262.   &Utils::Report::do_report ("network_iface_active_get");
  263.  
  264.   $fd = &Utils::File::run_pipe_read ("ifconfig -a");
  265.   return {} if $fd eq undef;
  266.   
  267.   while (<$fd>)
  268.   {
  269.     chomp;
  270.     if (/^([^ \t:]+)/)
  271.     {
  272.       $dev = $1;
  273.       $ifaces{$dev}{"enabled"} = 0;
  274.       $ifaces{$dev}{"dev"}    = $dev;
  275.     }
  276.     
  277.     s/^[ \t]+//;
  278.     if ($dev)
  279.     {
  280.       $ifaces{$dev}{"hwaddr"}  = $1 if /HWaddr[ \t]+([^ \t]+)/i;
  281.       $ifaces{$dev}{"addr"}    = $1 if /addr:([^ \t]+)/i;
  282.       $ifaces{$dev}{"mask"}    = $1 if /mask:([^ \t]+)/i;
  283.       $ifaces{$dev}{"bcast"}   = $1 if /bcast:([^ \t]+)/i;
  284.       $ifaces{$dev}{"enabled"} = 1  if /^UP[ \t]/i;
  285.     }
  286.   }
  287.   
  288.   &Utils::File::close_file ($fd);
  289.   &Utils::Report::leave ();
  290.   return %ifaces;
  291. }
  292.  
  293. sub get_interfaces_info
  294. {
  295.   my (%ifaces, $type);
  296.  
  297.   return &get_linux_interfaces_info if ($Utils::Backend::tool{"system"} eq "Linux");
  298.   return &get_freebsd_interfaces_info if ($Utils::Backend::tool{"system"} eq "FreeBSD");
  299.   return undef;
  300. }
  301.  
  302. # boot method parsing/replacing
  303. sub get_rh_bootproto
  304. {
  305.   my ($file, $key) = @_;
  306.   my %rh_to_proto_name =
  307.      (
  308.       "bootp" => "bootp",
  309.       "dhcp"  => "dhcp",
  310.     "pump"  => "pump",
  311.       "none"  => "none"
  312.       );
  313.   my $ret;
  314.  
  315.   $ret = &Utils::Parse::get_sh ($file, $key);
  316.   
  317.   if (!exists $rh_to_proto_name{$ret})
  318.   {
  319.     &Utils::Report::do_report ("network_bootproto_unsup", $file, $ret);
  320.     $ret = "none";
  321.   }
  322.   return $rh_to_proto_name{$ret};
  323. }
  324.  
  325. sub set_rh_bootproto
  326. {
  327.   my ($file, $key, $value) = @_;
  328.   my %proto_name_to_rh =
  329.      (
  330.       "bootp"    => "bootp",
  331.       "dhcp"     => "dhcp",
  332.     "pump"     => "pump",
  333.       "none"     => "none"
  334.       );
  335.  
  336.   return &Utils::Replace::set_sh ($file, $key, $proto_name_to_rh{$value});
  337. }
  338.  
  339. sub get_debian_bootproto
  340. {
  341.   my ($file, $iface) = @_;
  342.   my (@stanzas, $stanza, $method, $bootproto);
  343.   my %debian_to_proto_name =
  344.       (
  345.        "bootp"    => "bootp",
  346.        "dhcp"     => "dhcp",
  347.        "loopback" => "none",
  348.        "ppp"      => "none",
  349.        "static"   => "none"
  350.        );
  351.  
  352.   &Utils::Report::enter ();
  353.   @stanzas = &Utils::Parse::get_interfaces_stanzas ($file, "iface");
  354.  
  355.   foreach $stanza (@stanzas)
  356.   {
  357.     if (($$stanza[0] eq $iface) && ($$stanza[1] eq "inet"))
  358.     {
  359.       $method = $$stanza[2];
  360.       last;
  361.     }
  362.   }
  363.  
  364.   if (exists $debian_to_proto_name {$method})
  365.   {
  366.     $bootproto = $debian_to_proto_name {$method};
  367.   }
  368.   else
  369.   {
  370.     $bootproto = "none";
  371.     &Utils::Report::do_report ("network_bootproto_unsup", $method, $iface);
  372.   }
  373.  
  374.   &Utils::Report::leave ();
  375.   return $bootproto;
  376. }
  377.  
  378. sub set_debian_bootproto
  379. {
  380.   my ($file, $iface, $value) = @_;
  381.   my (@stanzas, $stanza, $method, $bootproto);
  382.   my %proto_name_to_debian =
  383.       (
  384.        "bootp"    => "bootp",
  385.        "dhcp"     => "dhcp",
  386.        "loopback" => "loopback",
  387.        "ppp"      => "ppp",
  388.        "none"     => "static"
  389.        );
  390.  
  391.   my %dev_to_method = 
  392.       (
  393.        "lo" => "loopback",
  394.        "ppp" => "ppp",
  395.        "ippp" => "ppp"
  396.        );
  397.  
  398.   foreach $i (keys %dev_to_method)
  399.   {
  400.     $value = $dev_to_method{$i} if $iface =~ /^$i/;
  401.   }
  402.  
  403.   return &Utils::Replace::set_interfaces_stanza_value ($file, $iface, 2, $proto_name_to_debian{$value});
  404. }
  405.  
  406. sub get_slackware_bootproto
  407. {
  408.   my ($file, $iface) = @_;
  409.  
  410.   if (&Utils::Parse::get_rcinet1conf_bool ($file, $iface, USE_DHCP))
  411.   {
  412.     return "dhcp"
  413.   }
  414.   else
  415.   {
  416.     return "none";
  417.   }
  418. }
  419.  
  420. sub set_slackware_bootproto
  421. {
  422.     my ($file, $iface, $value) = @_;
  423.  
  424.     if ($value eq "dhcp")
  425.     {
  426.       &Utils::Replace::set_rcinet1conf ($file, $iface, USE_DHCP, "yes");
  427.     }
  428.     else
  429.     {
  430.       &Utils::Replace::set_rcinet1conf ($file, $iface, USE_DHCP);
  431.     }
  432. }
  433.  
  434. sub get_bootproto
  435. {
  436.   my ($file, $key) = @_;
  437.   my ($str);
  438.  
  439.   $str = &Utils::Parse::get_sh ($file, $key);
  440.  
  441.   return "dhcp"  if ($key =~ /dhcp/i);
  442.   return "bootp" if ($key =~ /bootp/i);
  443.   return "none";
  444. }
  445.  
  446. sub set_suse_bootproto
  447. {
  448.   my ($file, $key, $value) = @_;
  449.   my %proto_name_to_suse90 =
  450.      (
  451.       "dhcp"     => "dhcp",
  452.       "bootp"    => "bootp",
  453.       "static"   => "none",
  454.      );
  455.  
  456.   return &Utils::Replace::set_sh ($file, $key, $proto_name_to_suse90{$value});
  457. }
  458.  
  459. sub get_gentoo_bootproto
  460. {
  461.   my ($file, $dev) = @_;
  462.  
  463.   return "dhcp" if (&Utils::Parse::get_confd_net ($file, "config_$dev") =~ /dhcp/i);
  464.   return "none";
  465. }
  466.  
  467. sub set_gentoo_bootproto
  468. {
  469.   my ($file, $dev, $value) = @_;
  470.  
  471.   return if ($dev =~ /^ppp/);
  472.  
  473.   return &Utils::Replace::set_confd_net ($file, "config_$dev", "dhcp") if ($value ne "none");
  474.  
  475.   # replace with a fake IP address, it will be replaced
  476.   # later with the correct one, I know it's a hack
  477.   return &Utils::Replace::set_confd_net ($file, "config_$dev", "0.0.0.0");
  478. }
  479.  
  480. sub set_freebsd_bootproto
  481. {
  482.   my ($file, $dev, $value) = @_;
  483.  
  484.   return &Utils::Replace::set_sh ($file, "ifconfig_$dev", "dhcp") if ($value ne "none");
  485.   return &Utils::Replace::set_sh ($file, "ifconfig_$dev", "");
  486. }
  487.  
  488. # Functions to get the system interfaces, these are distro dependent
  489. sub sysconfig_dir_get_existing_ifaces
  490. {
  491.   my ($dir) = @_;
  492.   my (@ret, $i, $name);
  493.   local *IFACE_DIR;
  494.   
  495.   if (opendir IFACE_DIR, "$gst_prefix/$dir")
  496.   {
  497.     foreach $i (readdir (IFACE_DIR))
  498.     {
  499.       push @ret, $1 if ($i =~ /^ifcfg-(.+)$/);
  500.     }
  501.  
  502.     closedir (IFACE_DIR);
  503.   }
  504.  
  505.   return \@ret;
  506. }
  507.  
  508. sub get_existing_rh62_ifaces
  509. {
  510.   return @{&sysconfig_dir_get_existing_ifaces ("/etc/sysconfig/network-scripts")};
  511. }
  512.  
  513. sub get_existing_rh72_ifaces
  514. {
  515.   my ($ret, $arr);
  516.   
  517.   # This syncs /etc/sysconfig/network-scripts and /etc/sysconfig/networking
  518.   &Utils::File::run ("redhat-config-network-cmd");
  519.   
  520.   $ret = &sysconfig_dir_get_existing_ifaces
  521.       ("/etc/sysconfig/networking/profiles/default");
  522.   $arr = &sysconfig_dir_get_existing_ifaces
  523.       ("/etc/sysconfig/networking/devices");
  524.  
  525.   &Utils::Util::arr_merge ($ret, $arr); 
  526.   return @$ret;
  527. }
  528.  
  529. sub get_existing_suse_ifaces
  530. {
  531.   return @{&sysconfig_dir_get_existing_ifaces ("/etc/sysconfig/network")};
  532. }
  533.  
  534. sub get_existing_pld_ifaces
  535. {
  536.   return @{&sysconfig_dir_get_existing_ifaces ("/etc/sysconfig/interfaces")};
  537. }
  538.  
  539. sub get_pap_passwd
  540. {
  541.   my ($file, $login) = @_;
  542.   my (@arr, $passwd);
  543.  
  544.   $login = '"?' . $login . '"?';
  545.   &Utils::Report::enter ();
  546.   &Utils::Report::do_report ("network_get_pap_passwd", $login, $file);
  547.   $arr = &Utils::Parse::split_first_array ($file, $login, "[ \t]+", "[ \t]+");
  548.  
  549.   $passwd = $$arr[1];
  550.   &Utils::Report::leave ();
  551.  
  552.   $passwd =~ s/^\"([^\"]*)\"$/$1/;
  553.  
  554.   return $passwd;
  555. }
  556.  
  557. sub set_pap_passwd
  558. {
  559.   my ($file, $login, $passwd) = @_;
  560.   my ($line);
  561.  
  562.   $login = '"' . $login . '"';
  563.   $passwd = '"'. $passwd . '"';
  564.   $line = "* $passwd";
  565.  
  566.   return &Utils::Replace::split ($file, $login, "[ \t]+", $line);
  567. }
  568.  
  569. sub get_wep_key_type
  570. {
  571.   my ($func) = shift @_;
  572.   my ($val);
  573.  
  574.   $val = &$func (@_);
  575.  
  576.   return "ascii" if ($val =~ /^s\:/);
  577.   return "hexadecimal";
  578. }
  579.  
  580. sub get_wep_key
  581. {
  582.   my ($func) = shift @_;
  583.   my ($val);
  584.  
  585.   $val = &$func (@_);
  586.   $val =~ s/^s\://;
  587.  
  588.   return $val;
  589. }
  590.  
  591. sub set_wep_key_full
  592. {
  593.   my ($key, $key_type, $func);
  594.  
  595.   # seems kind of hackish, but we want to use distro
  596.   # specific saving functions, so we need to leave
  597.   # the args as variable as possible
  598.   $func = shift @_;
  599.   $key_type = pop @_;
  600.   $key = pop @_;
  601.  
  602.   if ($key_type eq "ascii")
  603.   {
  604.     $key = "s:" . $key;
  605.   }
  606.  
  607.   push @_, $key;
  608.   &$func (@_);
  609. }
  610.  
  611. sub get_modem_volume
  612. {
  613.   my ($file) = @_;
  614.   my ($volume);
  615.  
  616.   $volume = &Utils::Parse::get_from_chatfile ($file, "AT.*(M0|L[1-3])");
  617.  
  618.   return 3 if ($volume eq undef);
  619.  
  620.   $volume =~ s/^[ml]//i;
  621.   return $volume;
  622. }
  623.  
  624. sub check_type
  625. {
  626.   my ($type) = shift @_;
  627.   my ($expected_type) =  shift @_;
  628.   my ($func) =  shift @_;
  629.  
  630.   if ($type =~ "^$expected_type")
  631.   {
  632.     &$func (@_);
  633.   }
  634. }
  635.  
  636. # Distro specific helper functions
  637. sub get_debian_auto_by_stanza
  638. {
  639.   my ($file, $iface) = @_;
  640.   my (@stanzas, $stanza, $i);
  641.  
  642.   @stanzas = &Utils::Parse::get_interfaces_stanzas ($file, "auto");
  643.  
  644.   foreach $stanza (@stanzas)
  645.   {
  646.     foreach $i (@$stanza)
  647.     {
  648.       return $stanza if $i eq $iface;
  649.     }
  650.   }
  651.  
  652.   return undef;
  653. }
  654.  
  655. sub get_debian_auto
  656. {
  657.   my ($file, $iface) = @_;
  658.  
  659.   return (&get_debian_auto_by_stanza ($file, $iface) ne undef)? 1 : 0;
  660. }
  661.  
  662. sub set_debian_auto
  663. {
  664.   my ($file, $iface, $value) = @_;
  665.   my ($buff, $line_no, $found);
  666.  
  667.   $buff = &Utils::File::load_buffer ($file);
  668.   &Utils::File::join_buffer_lines ($buff);
  669.   $line_no = 0;
  670.  
  671.   while (($found = &Utils::Replace::interfaces_get_next_stanza ($buff, \$line_no, "auto")) >= 0)
  672.   {
  673.     if ($value)
  674.     {
  675.       if ($$buff[$line_no] =~ /[ \t]$iface([\# \t\n])/)
  676.       {
  677.         return &Utils::File::save_buffer ($buff, $file);
  678.       }
  679.     }
  680.     else
  681.     {
  682.       # I'm including the hash here, although the man page says it's not supported.
  683.       last if $$buff[$line_no] =~ s/[ \t]$iface([\# \t\n])/$1/;
  684.     }
  685.         
  686.         $line_no ++;
  687.   }
  688.  
  689.   if ($found < 0 && $value)
  690.   {
  691.     &Utils::Replace::interfaces_auto_stanza_create ($buff, $iface);
  692.   }
  693.   else
  694.   {
  695.     if ($value)
  696.     {
  697.       chomp $$buff[$line_no];
  698.       $$buff[$line_no] .= " $iface\n";
  699.     }
  700.     $$buff[$line_no] =~ s/auto[ \t]*$//;
  701.   }
  702.   
  703.   return &Utils::File::save_buffer ($buff, $file);
  704. }
  705.  
  706. sub get_debian_remote_address
  707. {
  708.   my ($file, $iface) = @_;
  709.   my ($str, @tuples, $tuple, @res);
  710.  
  711.   &Utils::Report::enter ();
  712.   &Utils::Report::do_report ("network_get_remote", $iface);
  713.   
  714.   @tuples = &Utils::Parse::get_interfaces_option_tuple ($file, $iface, "up", 1);
  715.  
  716.   &Utils::Report::leave ();
  717.   
  718.   foreach $tuple (@tuples)
  719.   {
  720.     @res = $$tuple[1] =~ /[ \t]+pointopoint[ \t]+([^ \t]+)/;
  721.     return $res[0] if $res[0];
  722.   }
  723.  
  724.   return undef;
  725. }
  726.  
  727. sub set_debian_remote_address
  728. {
  729.   my ($file, $iface, $value) = @_;
  730.   my ($ifconfig, $ret);
  731.   
  732.   &Utils::Report::enter ();
  733.   &Utils::Report::do_report ("network_set_remote", $iface);
  734.   
  735.   $ifconfig = &Utils::File::locate_tool ("ifconfig");
  736.  
  737.   $ret = &Utils::Replace::set_interfaces_option_str ($file, $iface, "up",
  738.                                                      "$ifconfig $iface pointopoint $value");
  739.   &Utils::Report::leave ();
  740.   return $ret;
  741. }
  742.  
  743. sub get_suse_dev_name
  744. {
  745.   my ($iface) = @_;
  746.   my ($ifaces, $dev, $hwaddr);
  747.   my ($dev);
  748.  
  749.   $dev = &Utils::Parse::get_sh ("/var/run/sysconfig/if-$iface", "interface");
  750.  
  751.   if ($dev eq undef)
  752.   {
  753.     $dev = &Utils::File::run_backtick ("getcfg-interface $iface");
  754.   }
  755.  
  756.   # FIXME: is all this necessary? getcfg-interface should give us what we want
  757.   if ($dev eq undef)
  758.   {
  759.     # Those are the last cases, we make rough guesses
  760.     if ($iface =~ /-pcmcia-/)
  761.     {
  762.       # it's something like wlan-pcmcia-0
  763.       $dev =~ s/-pcmcia-//;
  764.     }
  765.     elsif ($iface =~ /-id-([a-fA-F0-9\:]*)/)
  766.     {
  767.       # it's something like eth-id-xx:xx:xx:xx:xx:xx, which is the NIC MAC
  768.       $hwaddr = $1;
  769.       $ifaces = &get_interfaces_info ();
  770.  
  771.       foreach $d (keys %$ifaces)
  772.       {
  773.         if ($hwaddr eq $$ifaces{$d}{"hwaddr"})
  774.         {
  775.           $dev = $d;
  776.           last;
  777.         }
  778.       }
  779.     }
  780.   }
  781.  
  782.   if ($dev eq undef)
  783.   {
  784.     # We give up, take $iface as $dev
  785.     $dev = $iface;
  786.   }
  787.  
  788.   return $dev;
  789. }
  790.  
  791. sub get_suse_auto
  792. {
  793.   my ($file, $key) = @_;
  794.   my ($ret);
  795.  
  796.   $ret = &Utils::Parse::get_sh ($file, $key);
  797.  
  798.   return 1 if ($ret =~ /^onboot$/i);
  799.   return 0;
  800. }
  801.  
  802. sub set_suse_auto
  803. {
  804.   my ($file, $key, $enabled) = @_;
  805.   my ($ret);
  806.  
  807.   return &Utils::Replace::set_sh($file, $key,
  808.                                  ($enabled) ? "onboot" : "manual");
  809. }
  810.  
  811. sub get_suse_gateway
  812. {
  813.   my ($file, $address, $netmask) = @_;
  814.   my ($gateway) = &Utils::Parse::split_first_array_pos ($file, "default", 0, "[ \t]+", "[ \t]+");
  815.  
  816.   return $gateway if &is_ip_in_same_network ($address, $gateway, $netmask);
  817.   return undef;
  818. }
  819.  
  820. # Return IP address or netmask, depending on $what
  821. # FIXME: This function could be used in other places than PLD,
  822. # calculates netmask given format 1.1.1.1/128
  823. sub get_pld_ipaddr
  824. {
  825.   my ($file, $key, $what) = @_;
  826.   my ($ipaddr, $netmask, $ret, $i);
  827.     my @netmask_prefixes = (0, 128, 192, 224, 240, 248, 252, 254, 255);
  828.   
  829.   $ipaddr = &Utils::Parse::get_sh($file, $key);
  830.   return undef if $ipaddr eq "";
  831.   
  832.   if($ipaddr =~ /([^\/]*)\/([[:digit:]]*)/)
  833.   {
  834.     $netmask = $2;
  835.     return undef if $netmask eq "";
  836.  
  837.     if($what eq "address")
  838.     {
  839.       return $1;
  840.     }
  841.  
  842.     for($i = 0; $i < int($netmask/8); $i++)
  843.     {
  844.       $ret .= "255.";
  845.     }
  846.  
  847.     $ret .= "$netmask_prefixes[$b%8]." if $netmask < 32;
  848.  
  849.     for($i = int($netmask/8) + 1; $i < 4; $i++)
  850.     {
  851.       $ret .= "0.";
  852.     }
  853.  
  854.     chop($ret);
  855.     return $ret;
  856.   }
  857.   return undef;
  858. }
  859.  
  860. sub set_pld_ipaddr
  861. {
  862.   my ($file, $key, $what, $value) = @_;
  863.   my %prefixes =
  864.   (
  865.     "0"   => 0,
  866.     "128" => 1,
  867.     "192" => 2,
  868.     "224" => 3,
  869.     "240" => 4,
  870.     "248" => 5,
  871.     "252" => 6,
  872.     "254" => 7,
  873.     "255" => 8
  874.   );
  875.   my ($ipaddr, $netmask);
  876.  
  877.   $ipaddr = &Utils::Parse::get_sh($file, $key);
  878.   return undef if $ipaddr eq "";
  879.  
  880.   if($what eq "address")
  881.   {
  882.     $ipaddr =~ s/.*\//$value\//;
  883.   }
  884.     else
  885.   {
  886.     if($value =~ /([[:digit:]]*).([[:digit:]]*).([[:digit:]]*).([[:digit:]]*)/)
  887.     {
  888.       $netmask = $prefixes{$1} + $prefixes{$2} + $prefixes{$3} + $prefixes{$4};
  889.       $ipaddr =~ s/\/[[:digit:]]*/\/$netmask/;
  890.     }
  891.   }
  892.  
  893.   return &Utils::Replace::set_sh($file, $key, $ipaddr);
  894. }
  895.  
  896. sub get_gateway
  897. {
  898.   my ($file, $key, $address, $netmask) = @_;
  899.   my ($gateway);
  900.  
  901.   return undef if ($address eq undef);
  902.  
  903.   $gateway = &Utils::Parse::get_sh ($file, $key);
  904.  
  905.   return $gateway if &is_ip_in_same_network ($address, $gateway, $netmask);
  906.   return undef;
  907. }
  908.  
  909. # looks for eth_up $eth_iface_number
  910. sub get_slackware_auto
  911. {
  912.   my ($file, $rclocal, $iface) = @_;
  913.   my ($search) = 0;
  914.   my ($buff);
  915.  
  916.   if ($iface =~ /^eth/)
  917.   {
  918.     $buff = &Utils::File::load_buffer ($file);
  919.     &Utils::File::join_buffer_lines ($buff);
  920.  
  921.     $iface =~ s/eth//;
  922.  
  923.     foreach $i (@$buff)
  924.     {
  925.       if ($i =~ /^[ \t]*'start'\)/)
  926.       {
  927.         $search = 1;
  928.       }
  929.       elsif (($i =~ /^[ \t]*;;/) && ($search == 1))
  930.       {
  931.         return 0;
  932.       }
  933.       elsif (($i =~ /^[ \t]*eth_up (\S+)/) && ($search == 1))
  934.       {
  935.         return 1 if ($1 == $iface);
  936.       }
  937.     }
  938.  
  939.     return 0;
  940.   }
  941.   elsif ($iface =~ /^ppp/)
  942.   {
  943.     return &Utils::Parse::get_kw ($rclocal, "ppp-go");
  944.   }
  945. }
  946.  
  947. # adds or deletes eth_up $eth_iface_number
  948. sub set_slackware_auto
  949. {
  950.   my ($file, $rclocal, $iface, $active) = @_;
  951.   my ($search) = 0;
  952.   my ($nline) = 0;
  953.   my ($buff, $sline);
  954.  
  955.   if ($iface =~ /^eth/)
  956.   {
  957.     $buff = &Utils::File::load_buffer ($file);
  958.     &Utils::File::join_buffer_lines ($buff);
  959.  
  960.     $iface =~ s/eth//;
  961.  
  962.     foreach $i (@$buff)
  963.     {
  964.       if ($i =~ /^[ \t]*('start'\)|\*\))/)
  965.       {
  966.         # if the line is 'start') or *), begin the search
  967.         $search = 1;
  968.       }
  969.       elsif (($i =~ /^[ \t]*gateway_up/) && ($search == 1))
  970.       {
  971.         # save the line in which we're going to save the eth_up stuff
  972.         $sline = $nline;
  973.       }
  974.       elsif (($i =~ /^[ \t]*(;;|esac)/) && ($search == 1))
  975.       {
  976.         # we've arrived to the end of the case, if we wanted to
  977.         # add the iface, now it's the moment
  978.         $$buff[$sline] = "\teth_up $iface\n" . $$buff[$sline] if ($active == 1);
  979.         $search = 0;
  980.       }
  981.       elsif (($i =~ /^[ \t]*eth_up (\S+)/) && ($search == 1))
  982.       {
  983.         if ($1 == $iface)
  984.         {
  985.           delete $$buff[$nline] if ($active == 0);
  986.           $search = 0;
  987.         }
  988.       }
  989.  
  990.       $nline++;
  991.     }
  992.  
  993.     return &Utils::File::save_buffer ($buff, $file);
  994.   }
  995.   elsif ($iface =~ /^ppp/)
  996.   {
  997.     return &Utils::Replace::set_kw ($rclocal, "ppp-go", $active);
  998.   }
  999. }
  1000.  
  1001. sub get_freebsd_auto
  1002. {
  1003.   my ($file, $defaults_file, $iface) = @_;
  1004.   my ($val);
  1005.  
  1006.   $val = &Utils::Parse::get_sh ($file, "network_interfaces");
  1007.   $val = &Utils::Parse::get_sh ($defaults_file, "network_interfaces") if ($val eq undef);
  1008.  
  1009.   return 1 if ($val eq "auto");
  1010.   return 1 if ($val =~ /$iface/);
  1011.   return 0;
  1012. }
  1013.  
  1014. sub set_freebsd_auto
  1015. {
  1016.   my ($file, $iface, $active) = @_;
  1017.   my ($val);
  1018.  
  1019.   $val = &Utils::Parse::get_sh ($file, "network_interfaces");
  1020.   $val = &Utils::File::run_backtick ("ifconfig -l") if ($val =~ /auto/);
  1021.   $val .= " ";
  1022.  
  1023.   if ($active && ($val !~ /$iface /))
  1024.   {
  1025.     $val .= $iface;
  1026.   }
  1027.   elsif (!$active && ($val =~ /$iface /))
  1028.   {
  1029.     $val =~ s/$iface //;
  1030.   }
  1031.  
  1032.   # Trim the string
  1033.   $val =~ s/^[ \t]*//;
  1034.   $val =~ s/[ \t]*$//;
  1035.  
  1036.   &Utils::Replace::set_sh ($file, "network_interfaces", $val);
  1037. }
  1038.  
  1039. sub get_freebsd_ppp_persist
  1040. {
  1041.   my ($startif, $iface) = @_;
  1042.   my ($val);
  1043.  
  1044.   if ($iface =~ /^tun[0-9]+/)
  1045.   {
  1046.     $val = &Utils::Parse::get_startif ($startif, "ppp[ \t]+\-(auto|ddial)[ \t]+");
  1047.  
  1048.     return 1 if ($val eq "ddial");
  1049.     return 0;
  1050.   }
  1051.  
  1052.   return undef;
  1053. }
  1054.  
  1055. # we need this function because essid can be
  1056. # multiword, and thus it can't be in rc.conf
  1057. sub set_freebsd_essid
  1058. {
  1059.   my ($file, $startif, $iface, $essid) = @_;
  1060.  
  1061.   if ($essid =~ /[ \t]/)
  1062.   {
  1063.     # It's multiword
  1064.     &Utils::File::save_buffer ("ifconfig $iface ssid \"$essid\"", $startif);
  1065.     &Utils::Replace::set_sh_re ($file, "ifconfig_$iface", "ssid[ \t]+([^ \t]*)", "");
  1066.   }
  1067.   else
  1068.   {
  1069.     &Utils::Replace::set_sh_re ($file, "ifconfig_$iface", "ssid[ \t]+([^ \t]*)", " ssid $essid");
  1070.   }
  1071. }
  1072.  
  1073. sub interface_changed
  1074. {
  1075.   my ($iface, $old_iface) = @_;
  1076.   my ($key);
  1077.  
  1078.   foreach $key (keys %$iface)
  1079.   {
  1080.     next if ($key eq "enabled");
  1081.     return 1 if ($$iface{$key} ne $$old_iface{$key});
  1082.   }
  1083.  
  1084.   return 0;
  1085. }
  1086.  
  1087. sub activate_interface_by_dev
  1088. {
  1089.   my ($dev, $enabled) = @_;
  1090.  
  1091.   &Utils::Report::enter ();
  1092.  
  1093.   if ($enabled)
  1094.   {
  1095.     &Utils::Report::do_report ("network_iface_activate", $dev);
  1096.     return -1 if &Utils::File::run ("ifup $dev");
  1097.   }
  1098.   else
  1099.   {
  1100.     &Utils::Report::do_report ("network_iface_deactivate", $dev);
  1101.     return -1 if &Utils::File::run ("ifdown $dev");
  1102.   }
  1103.   
  1104.   &Utils::Report::leave ();
  1105.  
  1106.   return 0;
  1107. }
  1108.  
  1109. # This works for all systems that have ifup/ifdown scripts.
  1110. sub activate_interface
  1111. {
  1112.   my ($hash, $old_hash, $enabled, $force) = @_;
  1113.   my ($dev);
  1114.  
  1115.   if ($force || &interface_changed ($hash, $old_hash))
  1116.   {
  1117.     $dev = ($$hash{"file"}) ? $$hash{"file"} : $$hash{"dev"};
  1118.     &activate_interface_by_dev ($dev, $enabled);
  1119.   }
  1120. }
  1121.  
  1122. # FIXME: can this function be mixed with the above?
  1123. sub activate_suse_interface
  1124. {
  1125.   my ($hash, $old_hash, $enabled, $force) = @_;
  1126.   my ($iface, $dev);
  1127.  
  1128.   if ($force || &interface_changed ($hash, $old_hash))
  1129.   {
  1130.     $dev = ($$hash{"file"}) ? &get_suse_dev_name ($$hash{"file"}) : $$hash{"dev"};
  1131.     &activate_interface_by_dev ($dev, $enabled);
  1132.   }
  1133. }
  1134.  
  1135. sub activate_slackware_interface_by_dev
  1136. {
  1137.   my ($dev, $enabled) = @_;
  1138.   my ($address, $netmask, $gateway);
  1139.   my ($file) = "/etc/rc.d/rc.inet1.conf";
  1140.   my ($ret) = 0;
  1141.  
  1142.   &Utils::Report::enter ();
  1143.  
  1144.   if ($enabled)
  1145.   {
  1146.     &Utils::Report::do_report ("network_iface_activate", $dev);
  1147.  
  1148.     if ($dev =~ /^ppp/)
  1149.     {
  1150.       $ret = &Utils::File::run ("ppp-go");
  1151.     }
  1152.     else
  1153.     {
  1154.       if (&Utils::Parse::get_rcinet1conf_bool ($file, $dev, USE_DHCP))
  1155.       {
  1156.         # Use DHCP
  1157.         $ret = &Utils::File::run ("dhclient $dev");
  1158.       }
  1159.       else
  1160.       {
  1161.         $address = &Utils::Parse::get_rcinet1conf ($file, $dev, "IPADDR");
  1162.         $netmask = &Utils::Parse::get_rcinet1conf ($file, $dev, "NETMASK");
  1163.         $gateway = &get_gateway ($file, "GATEWAY", $address, $netmask);
  1164.  
  1165.         $ret = &Utils::File::run ("ifconfig $dev $address netmask $netmask up");
  1166.  
  1167.         # Add the gateway if necessary
  1168.         if ($gateway ne undef)
  1169.         {
  1170.           &Utils::File::run ("route add default gw $gateway");
  1171.         }
  1172.       }
  1173.     }
  1174.   }
  1175.   else
  1176.   {
  1177.     &Utils::Report::do_report ("network_iface_deactivate", $dev);
  1178.  
  1179.     $ret = &Utils::File::run ("ifconfig $dev down") if ($dev =~ /^eth/);
  1180.     $ret = &Utils::File::run ("ppp-off") if ($dev =~ /^ppp/);
  1181.   }
  1182.  
  1183.   &Utils::Report::leave ();
  1184.   return -1 if ($ret != 0);
  1185.   return 0;
  1186. }
  1187.  
  1188. sub activate_slackware_interface
  1189. {
  1190.   my ($hash, $old_hash, $enabled, $force) = @_;
  1191.   my $dev = $$hash{"file"};
  1192.  
  1193.   if ($force || &interface_changed ($hash, $old_hash))
  1194.   {
  1195.     &activate_slackware_interface_by_dev ($dev, $enabled);
  1196.   }
  1197. }
  1198.  
  1199. sub activate_gentoo_interface_by_dev
  1200. {
  1201.   my ($dev, $enabled) = @_;
  1202.   my $file = "/etc/init.d/net.$dev";
  1203.   my $action = ($enabled == 1)? "start" : "stop";
  1204.  
  1205.   return &Utils::File::run ("$file $action");
  1206. }
  1207.  
  1208. sub activate_gentoo_interface
  1209. {
  1210.   my ($hash, $old_hash, $enabled, $force) = @_;
  1211.   my $dev = $$hash{"file"};
  1212.  
  1213.   if ($force || &interface_changed ($hash, $old_hash))
  1214.   {
  1215.     &activate_gentoo_interface_by_dev ($dev, $enabled);
  1216.   }
  1217. }
  1218.  
  1219. sub activate_freebsd_interface_by_dev
  1220. {
  1221.   my ($hash, $enabled) = @_;
  1222.   my ($dev)     = $$hash{"file"};
  1223.   my ($startif) = "/etc/start_if.$dev";
  1224.   my ($file)    = "/etc/rc.conf";
  1225.   my ($command, $dhcp_flags, $defaultroute, $fd);
  1226.  
  1227.   if ($enabled)
  1228.   {
  1229.     # Run the /etc/start_if.$dev commands
  1230.     $fd = &Utils::File::open_read_from_names ($startif);
  1231.  
  1232.     while (<$fd>)
  1233.     {
  1234.       `$_`;
  1235.     }
  1236.  
  1237.     &Utils::File::close_file ($fd);
  1238.     $command = &Utils::Parse::get_sh ($file, "ifconfig_$dev");
  1239.  
  1240.     # Bring up the interface
  1241.     if ($command =~ /DHCP/i)
  1242.     {
  1243.       $dhcp_flags = &Utils::Parse::get_sh ($file, "dhcp_flags");
  1244.       &Utils::File::run ("dhclient $dhcp_flags $dev");
  1245.     }
  1246.     else
  1247.     {
  1248.       &Utils::File::run ("ifconfig $dev $command");
  1249.     }
  1250.  
  1251.     # Add the default route
  1252.     $default_route = &Utils::Parse::get_sh ($file, "defaultrouter");
  1253.     &Utils::File::run ("route add default $default_route") if ($default_route !~ /^no$/i);
  1254.   }
  1255.   else
  1256.   {
  1257.     &Utils::File::run ("ifconfig $dev down");
  1258.   }
  1259. }
  1260.  
  1261. sub activate_freebsd_interface
  1262. {
  1263.   my ($hash, $old_hash, $enabled, $force) =@_;
  1264.  
  1265.   if ($force || &interface_changed ($hash, $old_hash))
  1266.   {
  1267.     &activate_freebsd_interface_by_dev ($hash, $enabled);
  1268.   }
  1269. }
  1270.  
  1271. sub remove_pap_entry
  1272. {
  1273.   my ($file, $login) = @_;
  1274.   my ($i, $buff);
  1275.  
  1276.   &Utils::Report::enter ();
  1277.   &Utils::Report::do_report ("network_remove_pap", $file, $login);
  1278.   
  1279.   $buff = &Utils::File::load_buffer ($file);
  1280.  
  1281.   foreach $i (@$buff)
  1282.   {
  1283.     $i = "" if ($i =~ /^[ \t]*$login[ \t]/);
  1284.   }
  1285.  
  1286.   &Utils::File::clean_buffer ($buff);
  1287.   &Utils::Report::leave ();
  1288.   return &Utils::File::save_buffer ($buff, $file);
  1289. }
  1290.  
  1291. sub delete_rh62_interface
  1292. {
  1293.   my ($old_hash) = @_;
  1294.   my ($dev, $login);
  1295.  
  1296.   $dev = $$old_hash{"file"};
  1297.   $login = $old_hash{"login"};
  1298.   &activate_interface_by_dev ($dev, 0);
  1299.  
  1300.   if ($login)
  1301.   {
  1302.     &remove_pap_entry ("/etc/ppp/pap-secrets", $login);
  1303.     &remove_pap_entry ("/etc/ppp/chap-secrets", $login);
  1304.   }
  1305.  
  1306.   &Utils::File::remove ("/etc/sysconfig/network-scripts/ifcfg-$dev");
  1307. }
  1308.  
  1309. sub delete_rh72_interface
  1310. {
  1311.   my ($old_hash) = @_;
  1312.   my ($filedev, $dev, $login);
  1313.  
  1314.   $filedev = $$old_hash{"file"};
  1315.   $dev     = $$old_hash{"dev"};
  1316.   $login   = $$old_hash{"login"};
  1317.   
  1318.   &activate_interface_by_dev ($filedev, 0);
  1319.  
  1320.   if ($login)
  1321.   {
  1322.     &remove_pap_entry ("/etc/ppp/pap-secrets", $login);
  1323.     &remove_pap_entry ("/etc/ppp/chap-secrets", $login);
  1324.   }
  1325.  
  1326.   &Utils::File::remove ("/etc/sysconfig/networking/devices/ifcfg-$filedev");
  1327.   &Utils::File::remove ("/etc/sysconfig/networking/profiles/default/ifcfg-$filedev");
  1328.   &Utils::File::remove ("/etc/sysconfig/network-scripts/ifcfg-$dev");
  1329.  
  1330.   &Utils::File::run ("redhat-config-network-cmd");
  1331. }
  1332.  
  1333. sub delete_debian_interface
  1334. {
  1335.   my ($old_hash) = @_;
  1336.   my ($dev, $login);
  1337.  
  1338.   $dev = $$old_hash{"dev"};
  1339.   $login = $old_hash{"login"};
  1340.  
  1341.   &activate_interface_by_dev ($dev, 0);
  1342.   &Utils::Replace::interfaces_iface_stanza_delete ("/etc/network/interfaces", $dev);
  1343.   
  1344.   if ($login)
  1345.   {
  1346.     &remove_pap_entry ("/etc/ppp/pap-secrets", $login);
  1347.     &remove_pap_entry ("/etc/ppp/chap-secrets", $login);
  1348.   }
  1349. }
  1350.  
  1351. sub delete_suse_interface
  1352. {
  1353.   my ($old_hash) = @_;
  1354.   my ($file, $provider, $dev);
  1355.  
  1356.   $file = $$old_hash{"file"};
  1357.   $dev = &get_suse_dev_name ($file);
  1358.   $provider = &Utils::Parse::get_sh ("/etc/sysconfig/network/ifcfg-$file", PROVIDER);
  1359.  
  1360.   activate_interface_by_dev ($dev, 0);
  1361.  
  1362.   &Utils::File::remove ("/etc/sysconfig/network/ifroute-$file");
  1363.   &Utils::File::remove ("/etc/sysconfig/network/ifcfg-$file");
  1364.   &Utils::File::remove ("/etc/sysconfig/network/providers/$provider");
  1365. }
  1366.  
  1367. sub delete_pld_interface
  1368. {
  1369.   my ($old_hash) = @_;
  1370.   my ($dev, $login);
  1371.  
  1372.   my $dev = $$old_hash{"file"};
  1373.   my $login = $$old_hash{"login"};
  1374.   &activate_interface_by_dev ($dev, 0);
  1375.                                                                                 
  1376.   if ($login)
  1377.   {
  1378.     &remove_pap_entry ("/etc/ppp/pap-secrets", $login);
  1379.     &remove_pap_entry ("/etc/ppp/chap-secrets", $login);
  1380.   }
  1381.                                                                                 
  1382.   &Utils::File::remove ("/etc/sysconfig/interfaces/ifcfg-$dev");
  1383. }
  1384.  
  1385. sub delete_slackware_interface
  1386. {
  1387.   my ($old_hash) = @_;
  1388.   my ($rcinetconf, $rcinet, $rclocal, $pppscript, $dev);
  1389.  
  1390.   $rcinetconf = "/etc/rc.d/rc.inet1.conf";
  1391.   $rcinet = "/etc/rc.d/rc.inet1";
  1392.   $rclocal = "/etc/rc.d/rc.local";
  1393.   $pppscript = "/etc/ppp/pppscript";
  1394.   $dev = $$old_hash {"dev"};
  1395.  
  1396.   # remove ifup/ppp-go at startup if existing
  1397.   &set_slackware_auto ($rcinet, $rclocal, $dev, 0);
  1398.  
  1399.   if ($dev =~ /^ppp/)
  1400.   {
  1401.     &Utils::File::remove ($pppscript);
  1402.   }
  1403.   else
  1404.   {
  1405.     # empty the values
  1406.     &Utils::Replace::set_rcinet1conf ($rcinetconf, $dev, "IPADDR", "");
  1407.     &Utils::Replace::set_rcinet1conf ($rcinetconf, $dev, "NETMASK", "");
  1408.     &Utils::Replace::set_rcinet1conf ($rcinetconf, $dev, "USE_DHCP", "");
  1409.     &Utils::Replace::set_rcinet1conf ($rcinetconf, $dev, "DHCP_HOSTNAME", "");
  1410.   }
  1411. }
  1412.  
  1413. sub delete_gentoo_interface
  1414. {
  1415.   my ($old_hash) = @_;
  1416.   my ($dev, $gateway);
  1417.  
  1418.   $dev = $$old_hash {"dev"};
  1419.   $gateway = $$old_hash {"gateway"};
  1420.  
  1421.   # bring down the interface and remove from init
  1422.   &Init::Services::set_gentoo_service_status ("/etc/init.d/net.$dev", "default", "stop");
  1423.  
  1424.   if ($dev =~ /^ppp/)
  1425.   {
  1426.     &Utils::File::remove ("/etc/conf.d/net.$dev");
  1427.   }
  1428.   else
  1429.   {
  1430.     &Utils::Replace::set_sh ("/etc/conf.d/net", "config_$dev", "");
  1431.   }
  1432. }
  1433.  
  1434. sub delete_freebsd_interface
  1435. {
  1436.   my ($old_hash) = @_;
  1437.   my ($dev, $startif, $pppconf);
  1438.   my ($buff, $line_no, $end_line_no, $i);
  1439.  
  1440.   $dev = $$old_hash{"dev"};
  1441.   $startif = "/etc/start_if.$dev";
  1442.   $pppconf = "/etc/ppp/ppp.conf";
  1443.  
  1444.   &Utils::File::run ("ifconfig $dev down");
  1445.  
  1446.   if ($dev =~ /^tun[0-9]+/)
  1447.   {
  1448.     # Delete the ppp.conf section
  1449.     $section = &Utils::Parse::get_startif ($startif, "ppp[ \t]+\-[^ \t]+[ \t]+([^ \t]+)");
  1450.     $buff = &Utils::File::load_buffer ($pppconf);
  1451.  
  1452.     $line_no     = &Utils::Parse::pppconf_find_stanza      ($buff, $section);
  1453.     $end_line_no = &Utils::Parse::pppconf_find_next_stanza ($buff, $line_no + 1);
  1454.     $end_line_no = scalar @$buff + 1 if ($end_line_no == -1);
  1455.     $end_line_no--;
  1456.  
  1457.     for ($i = $line_no; $i <= $end_line_no; $i++)
  1458.     {
  1459.       delete $$buff[$i];
  1460.     }
  1461.  
  1462.     &Utils::File::clean_buffer ($buff);
  1463.     &Utils::File::save_buffer ($buff, $pppconf);
  1464.   }
  1465.   
  1466.   &Utils::Replace::set_sh  ("/etc/rc.conf", "ifconfig_$dev", "");
  1467.   &Utils::File::remove ($startif);
  1468. }
  1469.  
  1470. # FIXME: should move to external file!!!
  1471. sub create_pppscript
  1472. {
  1473.   my ($pppscript) = @_;
  1474.   my ($contents);
  1475.  
  1476.   if (!&Utils::File::exists ($pppscript))
  1477.   {
  1478.     # create a template file from scratch
  1479.     $contents  = 'TIMEOUT 60' . "\n";
  1480.     $contents .= 'ABORT ERROR' . "\n";
  1481.     $contents .= 'ABORT BUSY' . "\n";
  1482.     $contents .= 'ABORT VOICE' . "\n";
  1483.     $contents .= 'ABORT "NO CARRIER"' . "\n";
  1484.     $contents .= 'ABORT "NO DIALTONE"' . "\n";
  1485.     $contents .= 'ABORT "NO DIAL TONE"' . "\n";
  1486.     $contents .= 'ABORT "NO ANSWER"' . "\n";
  1487.     $contents .= '"" "ATZ"' . "\n";
  1488.     $contents .= '"" "AT&FH0"' . "\n";
  1489.     $contents .= 'OK-AT-OK "ATDT000000000"' . "\n";
  1490.     $contents .= 'TIMEOUT 75' . "\n";
  1491.     $contents .= 'CONNECT' . "\n";
  1492.  
  1493.     &Utils::File::save_buffer ($contents, $pppscript);
  1494.   }
  1495. }
  1496.  
  1497. #FIXME: should move to external file!!!
  1498. sub create_pppgo
  1499. {
  1500.   my ($pppgo) = "/usr/sbin/ppp-go";
  1501.   my ($contents, $pppd, $chat);
  1502.   local *FILE;
  1503.  
  1504.   if (!&Utils::File::exists ($pppgo))
  1505.   {
  1506.     $pppd = &Utils::File::locate_tool ("pppd");
  1507.     $chat = &Utils::File::locate_tool ("chat");
  1508.     
  1509.     # create a simple ppp-go from scratch
  1510.     # this script is based on the one that's created by pppsetup
  1511.     $contents  = "killall -INT pppd 2>/dev/null \n";
  1512.     $contents .= "rm -f /var/lock/LCK* /var/run/ppp*.pid \n";
  1513.     $contents .= "( $pppd connect \"$chat -v -f /etc/ppp/pppscript\") || exit 1 \n";
  1514.     $contents .= "exit 0 \n";
  1515.  
  1516.     &Utils::File::save_buffer ($contents, $pppgo);
  1517.     chmod 0777, "$gst_prefix/$pppgo";
  1518.   }
  1519. }
  1520.  
  1521. # FIXME: should move to external file!!!
  1522. sub create_gentoo_files
  1523. {
  1524.   my ($dev) = @_;
  1525.   my ($init) = "/etc/init.d/net.$dev";
  1526.   my ($conf) = "/etc/conf.d/net.$dev";
  1527.   my ($backup) = "/etc/conf.d/net.ppp0.gstbackup";
  1528.  
  1529.   if ($dev =~ /ppp/)
  1530.   {
  1531.     &Utils::File::copy_file ("/etc/init.d/net.ppp0", $init) if (!&Utils::File::exists ($init));
  1532.  
  1533.     # backup the ppp config file
  1534.     &Utils::File::copy_file ("/etc/conf.d/net.ppp0", $backup) if (!&Utils::File::exists ($backup));
  1535.     &Utils::File::copy_file ($backup, $conf) if (!&Utils::File::exists ($conf));
  1536.   }
  1537.   else
  1538.   {
  1539.     &Utils::File::copy_file ("/etc/init.d/net.eth0", $init) if (!&Utils::File::exists ($init));
  1540.   }
  1541.  
  1542.   chmod 0755, "$gst_prefix/$init";
  1543. }
  1544.  
  1545. # FIXME: should move to external file!!!
  1546. sub create_ppp_startif
  1547. {
  1548.   my ($startif, $iface, $dev, $persist) = @_;
  1549.   my ($section);
  1550.  
  1551.   if ($dev =~ /^tun[0-9]+/)
  1552.   {
  1553.     $section = &Utils::Parse::get_startif ($startif, "ppp[ \t]+\-[^ \t]+[ \t]+([^ \t]+)");
  1554.     $section = $dev if ($section eq undef);
  1555.  
  1556.     return &Utils::File::save_buffer ("ppp -ddial $section", $startif) if ($persist eq 1);
  1557.     return &Utils::File::save_buffer ("ppp -auto  $section", $startif);
  1558.   }
  1559. }
  1560.  
  1561. sub create_isdn_options
  1562. {
  1563.   my ($file) = @_;
  1564.  
  1565.   if (!&Utils::File::exists ($file))
  1566.   {
  1567.     &Utils::File::copy_file_from_stock ("general_isdn_ppp_options", $file);
  1568.   }
  1569. }
  1570.  
  1571. sub set_modem_volume_sh
  1572. {
  1573.   my ($file, $key, $volume) = @_;
  1574.   my ($vol);
  1575.  
  1576.   if    ($volume == 0) { $vol = "ATM0" }
  1577.   elsif ($volume == 1) { $vol = "ATL1" }
  1578.   elsif ($volume == 2) { $vol = "ATL2" }
  1579.   else                 { $vol = "ATL3" }
  1580.  
  1581.   return &Utils::Replace::set_sh ($file, $key, $vol);
  1582. }
  1583.  
  1584. sub set_modem_volume
  1585. {
  1586.   my ($file, $volume) = @_;
  1587.   my $line;
  1588.  
  1589.   $line = &Utils::Parse::get_from_chatfile ($file, "AT([^DZ][a-z0-9&]+)");
  1590.   $line =~ s/(M0|L[1-3])//g;
  1591.  
  1592.   if    ($volume == 0) { $line .= "M0"; }
  1593.   elsif ($volume == 1) { $line .= "L1"; }
  1594.   elsif ($volume == 2) { $line .= "L2"; }
  1595.   else                 { $line .= "L3"; }
  1596.  
  1597.   return &Utils::Replace::set_chat ($file, "AT([^DZ][a-z0-9&]+)", $line);
  1598. }
  1599.  
  1600. sub set_pppconf_route
  1601. {
  1602.   my ($pppconf, $startif, $iface, $key, $val) = @_;
  1603.   my ($section);
  1604.  
  1605.   if ($iface =~ /^tun[0-9]+/)
  1606.   {
  1607.     $section = &Utils::Parse::get_startif ($startif, "ppp[ \t]+\-[^ \t]+[ \t]+([^ \t]+)");
  1608.     &Utils::Replace::set_pppconf_common ($pppconf, $section, $key,
  1609.                                  ($val == 1)? "add default HISADDR" : undef);
  1610.   }
  1611. }
  1612.  
  1613. sub set_pppconf_dial_command
  1614. {
  1615.   my ($pppconf, $startif, $iface, $val) = @_;
  1616.   my ($section, $dial);
  1617.  
  1618.   if ($iface =~ /^tun[0-9]+/)
  1619.   {
  1620.     $section = &Utils::Parse::get_startif ($startif, "ppp[ \t]+\-[^ \t]+[ \t]+([^ \t]+)");
  1621.     $dial = &Utils::Parse::get_pppconf ($pppconf, $section, "dial");
  1622.     $dial =~ s/ATD[TP]/$val/;
  1623.  
  1624.     &Utils::Replace::set_pppconf ($pppconf, $section, "dial", $dial);
  1625.   }
  1626. }
  1627.  
  1628. sub set_pppconf_volume
  1629. {
  1630.   my ($pppconf, $startif, $iface, $val) = @_;
  1631.   my ($section, $dial, $vol, $pre, $post);
  1632.  
  1633.   if ($iface =~ /^tun[0-9]+/)
  1634.   {
  1635.     $section = &Utils::Parse::get_startif ($startif, "ppp[ \t]+\-[^ \t]+[ \t]+([^ \t]+)");
  1636.     $dial = &Utils::Parse::get_pppconf ($pppconf, $section, "dial");
  1637.  
  1638.     if ($dial =~ /(.*AT[^ \t]*)([ML][0-3])(.* OK .*)/i)
  1639.     {
  1640.       $pre  = $1;
  1641.       $post = $3;
  1642.     }
  1643.     elsif ($dial =~ /(.*AT[^ \t]*)( OK .*)/i)
  1644.     {
  1645.       $pre  = $1;
  1646.       $post = $2;
  1647.     }
  1648.  
  1649.     if ($val == 0)
  1650.     {
  1651.       $vol = "M0";
  1652.     }
  1653.     else
  1654.     {
  1655.       $vol = "L$val";
  1656.     }
  1657.  
  1658.     $dial = $pre . $vol . $post;
  1659.     &Utils::Replace::set_pppconf ($pppconf, $section, "dial", $dial);
  1660.   }
  1661. }
  1662.  
  1663. sub get_interface_dist
  1664. {
  1665.   my %dist_map =
  1666.      (
  1667.     "redhat-6.2"      => "redhat-6.2",
  1668.     "redhat-7.0"      => "redhat-6.2",
  1669.     "redhat-7.1"      => "redhat-6.2",
  1670.     "redhat-7.2"      => "redhat-7.2",
  1671.     "redhat-8.0"      => "redhat-8.0",
  1672.     "mandrake-9.0"    => "mandrake-9.0",
  1673.     "yoper-2.2"       => "redhat-6.2",
  1674.     "conectiva-9"     => "conectiva-9",
  1675.     "debian-3.0"      => "debian-3.0",
  1676.     "suse-9.0"        => "suse-9.0",
  1677.     "pld-1.0"         => "pld-1.0",
  1678.     "vine-3.0"        => "vine-3.0",
  1679.     "ark"             => "vine-3.0",
  1680.     "slackware-9.1.0" => "slackware-9.1.0",
  1681.     "gentoo"          => "gentoo",
  1682.     "freebsd-5"       => "freebsd-5",
  1683.    );
  1684.  
  1685.   return $dist_map{$Utils::Backend::tool{"platform"}};
  1686. }
  1687.  
  1688. sub get_interface_parse_table
  1689. {
  1690.   my %dist_tables =
  1691.     (
  1692.      "redhat-6.2" =>
  1693.      {
  1694.        ifaces_get => \&get_existing_rh62_ifaces,
  1695.        fn =>
  1696.        {
  1697.          IFCFG   => "/etc/sysconfig/network-scripts/ifcfg-#iface#",
  1698.          CHAT    => "/etc/sysconfig/network-scripts/chat-#iface#",
  1699.          IFACE   => "#iface#",
  1700.          TYPE    => "#type#",
  1701.          PAP     => "/etc/ppp/pap-secrets",
  1702.          CHAP    => "/etc/ppp/chap-secrets",
  1703.          PUMP    => "/etc/pump.conf",
  1704.          WVDIAL  => "/etc/wvdial.conf"
  1705.        },
  1706.        table =>
  1707.        [
  1708.         [ "bootproto",          \&get_rh_bootproto,          IFCFG, BOOTPROTO ],
  1709.         [ "auto",               \&Utils::Parse::get_sh_bool, IFCFG, ONBOOT ],
  1710.         [ "dev",                \&Utils::Parse::get_sh,      IFCFG, DEVICE ],
  1711.         [ "address",            \&Utils::Parse::get_sh,      IFCFG, IPADDR ],
  1712.         [ "netmask",            \&Utils::Parse::get_sh,      IFCFG, NETMASK ],
  1713.         [ "broadcast",          \&Utils::Parse::get_sh,      IFCFG, BROADCAST ],
  1714.         [ "network",            \&Utils::Parse::get_sh,      IFCFG, NETWORK ],
  1715.         [ "gateway",            \&Utils::Parse::get_sh,      IFCFG, GATEWAY ],
  1716.         [ "remote_address",     \&Utils::Parse::get_sh,      IFCFG, REMIP ],
  1717.         [ "section",            \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh,       IFCFG, WVDIALSECT ]],
  1718.         [ "update_dns",         \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool,  IFCFG, PEERDNS ]],
  1719.         [ "mtu",                \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh,       IFCFG, MTU ]],
  1720.         [ "mru",                \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh,       IFCFG, MRU ]],
  1721.         [ "login",              \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh,       IFCFG, PAPNAME ]],
  1722.         [ "password",           \&check_type, [TYPE, "modem", \&get_pap_passwd, PAP,  "%login%" ]],
  1723.         [ "password",           \&check_type, [TYPE, "modem", \&get_pap_passwd, CHAP, "%login%" ]],
  1724.         [ "serial_port",        \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh,       IFCFG, MODEMPORT ]],
  1725.         [ "serial_speed",       \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh,       IFCFG, LINESPEED ]],
  1726.         [ "set_default_gw",     \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool,  IFCFG, DEFROUTE ]],
  1727.         [ "persist",            \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool,  IFCFG, PERSIST ]],
  1728.         [ "serial_escapechars", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool,  IFCFG, ESCAPECHARS ]],
  1729.         [ "serial_hwctl",       \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool,  IFCFG, HARDFLOWCTL ]],
  1730.         [ "phone_number",       \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_chatfile,    CHAT, "^atd[^0-9]*([0-9, -]+)" ]],
  1731.         [ "phone_number",       \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Phone" ]],
  1732.         [ "update_dns",         \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Auto DNS" ]],
  1733.         [ "login",              \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Username" ]],
  1734.         [ "password",           \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Password" ]],
  1735.         [ "serial_port",        \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Modem" ]],
  1736.         [ "serial_speed",       \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Baud" ]],
  1737.         [ "set_default_gw",     \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Check Def Route" ]],
  1738.         [ "persist",            \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Auto Reconnect" ]],
  1739.         [ "dial_command",       \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Dial Command" ]],
  1740.         [ "external_line",      \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Dial Prefix" ]],
  1741. #        [ "update_dns",         \&gst_network_pump_get_nodns, PUMP, "%dev%", "%bootproto%" ],
  1742. #        [ "dns1",               \&Utils::Parse::get_sh,      IFCFG, DNS1 ],
  1743. #        [ "dns2",               \&Utils::Parse::get_sh,      IFCFG, DNS2 ],
  1744. #        [ "ppp_options",        \&Utils::Parse::get_sh,      IFCFG, PPPOPTIONS ],
  1745.        ]
  1746.      },
  1747.  
  1748.      "redhat-7.2" =>
  1749.      {
  1750.        ifaces_get => \&get_existing_rh72_ifaces,
  1751.        fn =>
  1752.        {
  1753.          IFCFG => ["/etc/sysconfig/networking/profiles/default/ifcfg-#iface#",
  1754.                    "/etc/sysconfig/networking/devices/ifcfg-#iface#",
  1755.                    "/etc/sysconfig/network-scripts/ifcfg-#iface#"],
  1756.          CHAT  => "/etc/sysconfig/network-scripts/chat-#iface#",
  1757.          IFACE => "#iface#",
  1758.          TYPE  => "#type#",
  1759.          PAP   => "/etc/ppp/pap-secrets",
  1760.          CHAP  => "/etc/ppp/chap-secrets",
  1761.          PUMP  => "/etc/pump.conf",
  1762.          WVDIAL => "/etc/wvdial.conf"
  1763.        },
  1764.        table =>
  1765.        [
  1766.         [ "bootproto",          \&get_rh_bootproto,   IFCFG, BOOTPROTO ],
  1767.         [ "auto",               \&Utils::Parse::get_sh_bool, IFCFG, ONBOOT ],
  1768.         [ "dev",                \&Utils::Parse::get_sh, IFCFG, DEVICE ],
  1769.         [ "address",            \&Utils::Parse::get_sh, IFCFG, IPADDR ],
  1770.         [ "netmask",            \&Utils::Parse::get_sh, IFCFG, NETMASK ],
  1771.         [ "broadcast",          \&Utils::Parse::get_sh, IFCFG, BROADCAST ],
  1772.         [ "network",            \&Utils::Parse::get_sh, IFCFG, NETWORK ],
  1773.         [ "gateway",            \&Utils::Parse::get_sh, IFCFG, GATEWAY ],
  1774.         [ "essid",              \&Utils::Parse::get_sh, IFCFG, ESSID ],
  1775.         [ "key_type",           \&get_wep_key_type, [ \&Utils::Parse::get_sh, IFCFG, KEY ]],
  1776.         [ "key",                \&get_wep_key,      [ \&Utils::Parse::get_sh, IFCFG, KEY ]],
  1777.         [ "remote_address",     \&Utils::Parse::get_sh,      IFCFG, REMIP ],
  1778.         [ "section",            \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh,      IFCFG, WVDIALSECT ]],
  1779.         [ "update_dns",         \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, PEERDNS ]],
  1780.         [ "mtu",                \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh,      IFCFG, MTU ]],
  1781.         [ "mru",                \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh,      IFCFG, MRU ]],
  1782.         [ "login",              \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh,      IFCFG, PAPNAME ]],
  1783.         [ "password",           \&check_type, [TYPE, "modem", \&get_pap_passwd, PAP,  "%login%" ]],
  1784.         [ "password",           \&check_type, [TYPE, "modem", \&get_pap_passwd, CHAP, "%login%" ]],
  1785.         [ "serial_port",        \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh,      IFCFG, MODEMPORT ]],
  1786.         [ "serial_speed",       \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh,      IFCFG, LINESPEED ]],
  1787.         [ "set_default_gw",     \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, DEFROUTE ]],
  1788.         [ "persist",            \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, PERSIST ]],
  1789.         [ "serial_escapechars", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, ESCAPECHARS ]],
  1790.         [ "serial_hwctl",       \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, HARDFLOWCTL ]],
  1791.         [ "phone_number",       \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_chatfile,    CHAT, "^atd[^0-9]*([0-9, -]+)" ]],
  1792. #        [ "name",               \&Utils::Parse::get_sh,      IFCFG, NAME ],
  1793. #        [ "name",               \&Utils::Parse::get_trivial, IFACE ],
  1794. #        [ "update_dns",         \&gst_network_pump_get_nodns, PUMP, "%dev%", "%bootproto%" ],
  1795. #        [ "dns1",               \&Utils::Parse::get_sh,      IFCFG, DNS1 ],
  1796. #        [ "dns2",               \&Utils::Parse::get_sh,      IFCFG, DNS2 ],
  1797. #        [ "ppp_options",        \&Utils::Parse::get_sh,      IFCFG, PPPOPTIONS ],
  1798. #        [ "debug",              \&Utils::Parse::get_sh_bool, IFCFG, DEBUG ],
  1799.         # wvdial settings
  1800.         [ "phone_number",       \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Phone" ]],
  1801.         [ "update_dns",         \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Auto DNS" ]],
  1802.         [ "login",              \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Username" ]],
  1803.         [ "password",           \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Password" ]],
  1804.         [ "serial_port",        \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Modem" ]],
  1805.         [ "serial_speed",       \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Baud" ]],
  1806.         [ "set_default_gw",     \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Check Def Route" ]],
  1807.         [ "persist",            \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Auto Reconnect" ]],
  1808.         [ "dial_command",       \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Dial Command" ]],
  1809.         [ "external_line",      \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Dial Prefix" ]],
  1810.        ]
  1811.      },
  1812.  
  1813.      "redhat-8.0" =>
  1814.      {
  1815.        ifaces_get => \&get_existing_rh72_ifaces,
  1816.        fn =>
  1817.        {
  1818.          IFCFG   => ["/etc/sysconfig/networking/profiles/default/ifcfg-#iface#",
  1819.                      "/etc/sysconfig/networking/devices/ifcfg-#iface#",
  1820.                      "/etc/sysconfig/network-scripts/ifcfg-#iface#"],
  1821.          CHAT    => "/etc/sysconfig/network-scripts/chat-#iface#",
  1822.          TYPE    => "#type#",
  1823.          IFACE   => "#iface#",
  1824.          PAP     => "/etc/ppp/pap-secrets",
  1825.          CHAP    => "/etc/ppp/chap-secrets",
  1826.          PUMP    => "/etc/pump.conf",
  1827.          WVDIAL  => "/etc/wvdial.conf"
  1828.        },
  1829.        table =>
  1830.        [
  1831.         [ "bootproto",          \&get_rh_bootproto,     IFCFG, BOOTPROTO ],
  1832.         [ "auto",               \&Utils::Parse::get_sh_bool, IFCFG, ONBOOT ],
  1833.         [ "dev",                \&Utils::Parse::get_sh, IFCFG, DEVICE ],
  1834.         [ "address",            \&Utils::Parse::get_sh, IFCFG, IPADDR ],
  1835.         [ "netmask",            \&Utils::Parse::get_sh, IFCFG, NETMASK ],
  1836.         [ "broadcast",          \&Utils::Parse::get_sh, IFCFG, BROADCAST ],
  1837.         [ "network",            \&Utils::Parse::get_sh, IFCFG, NETWORK ],
  1838.         [ "gateway",            \&Utils::Parse::get_sh, IFCFG, GATEWAY ],
  1839.         [ "essid",              \&Utils::Parse::get_sh, IFCFG, WIRELESS_ESSID ],
  1840.         [ "key_type",           \&get_wep_key_type, [ \&Utils::Parse::get_sh, IFCFG, WIRELESS_KEY ]],
  1841.         [ "key",                \&get_wep_key,      [ \&Utils::Parse::get_sh, IFCFG, WIRELESS_KEY ]],
  1842.         [ "remote_address",     \&Utils::Parse::get_sh,      IFCFG, REMIP ],
  1843.         [ "section",            \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh,      IFCFG, WVDIALSECT ]],
  1844.         [ "update_dns",         \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, PEERDNS ]],
  1845.         [ "mtu",                \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh,      IFCFG, MTU ]],
  1846.         [ "mru",                \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh,      IFCFG, MRU ]],
  1847.         [ "login",              \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh,      IFCFG, PAPNAME ]],
  1848.         [ "password",           \&check_type, [TYPE, "modem", \&get_pap_passwd, PAP,  "%login%" ]],
  1849.         [ "password",           \&check_type, [TYPE, "modem", \&get_pap_passwd, CHAP, "%login%" ]],
  1850.         [ "serial_port",        \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh,      IFCFG, MODEMPORT ]],
  1851.         [ "serial_speed",       \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh,      IFCFG, LINESPEED ]],
  1852.         [ "set_default_gw",     \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, DEFROUTE ]],
  1853.         [ "persist",            \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, PERSIST ]],
  1854.         [ "serial_escapechars", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, ESCAPECHARS ]],
  1855.         [ "serial_hwctl",       \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, HARDFLOWCTL ]],
  1856.         [ "phone_number",       \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_chatfile,    CHAT, "^atd[^0-9]*([0-9, -]+)" ]],
  1857. #        [ "name",               \&Utils::Parse::get_sh,      IFCFG, NAME ],
  1858. #        [ "name",               \&Utils::Parse::get_trivial, IFACE ],
  1859. #        [ "update_dns",         \&gst_network_pump_get_nodns, PUMP, "%dev%", "%bootproto%" ],
  1860. #        [ "dns1",               \&Utils::Parse::get_sh,      IFCFG, DNS1 ],
  1861. #        [ "dns2",               \&Utils::Parse::get_sh,      IFCFG, DNS2 ],
  1862. #        [ "ppp_options",        \&Utils::Parse::get_sh,      IFCFG, PPPOPTIONS ],
  1863. #        [ "debug",              \&Utils::Parse::get_sh_bool, IFCFG, DEBUG ],
  1864.         # wvdial settings
  1865.         [ "phone_number",       \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Phone" ]],
  1866.         [ "update_dns",         \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Auto DNS" ]],
  1867.         [ "login",              \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Username" ]],
  1868.         [ "password",           \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Password" ]],
  1869.         [ "serial_port",        \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Modem" ]],
  1870.         [ "serial_speed",       \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Baud" ]],
  1871.         [ "set_default_gw",     \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Check Def Route" ]],
  1872.         [ "persist",            \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Auto Reconnect" ]],
  1873.         [ "dial_command",       \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Dial Command" ]],
  1874.         [ "external_line",      \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Dial Prefix" ]],
  1875.        ]
  1876.      },
  1877.  
  1878.      "vine-3.0" =>
  1879.      {
  1880.        ifaces_get => \&get_existing_rh62_ifaces,
  1881.        fn =>
  1882.        {
  1883.          IFCFG   => "/etc/sysconfig/network-scripts/ifcfg-#iface#",
  1884.          CHAT    => "/etc/sysconfig/network-scripts/chat-#iface#",
  1885.          TYPE    => "#type#",
  1886.          IFACE   => "#iface#",
  1887.          PAP     => "/etc/ppp/pap-secrets",
  1888.          CHAP    => "/etc/ppp/chap-secrets",
  1889.          PUMP    => "/etc/pump.conf",
  1890.          WVDIAL  => "/etc/wvdial.conf"
  1891.        },
  1892.        table =>
  1893.        [
  1894.         [ "bootproto",          \&get_rh_bootproto,     IFCFG, BOOTPROTO ],
  1895.         [ "auto",               \&Utils::Parse::get_sh_bool, IFCFG, ONBOOT ],
  1896.         [ "dev",                \&Utils::Parse::get_sh, IFCFG, DEVICE ],
  1897.         [ "address",            \&Utils::Parse::get_sh, IFCFG, IPADDR ],
  1898.         [ "netmask",            \&Utils::Parse::get_sh, IFCFG, NETMASK ],
  1899.         [ "broadcast",          \&Utils::Parse::get_sh, IFCFG, BROADCAST ],
  1900.         [ "network",            \&Utils::Parse::get_sh, IFCFG, NETWORK ],
  1901.         [ "gateway",            \&Utils::Parse::get_sh, IFCFG, GATEWAY ],
  1902.         [ "essid",              \&Utils::Parse::get_sh, IFCFG, ESSID ],
  1903.         [ "key_type",           \&get_wep_key_type, [ \&Utils::Parse::get_sh, IFCFG, KEY ]],
  1904.         [ "key",                \&get_wep_key,      [ \&Utils::Parse::get_sh, IFCFG, KEY ]],
  1905.         [ "remote_address",     \&Utils::Parse::get_sh, IFCFG, REMIP ],
  1906.         [ "section",            \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh,      IFCFG, WVDIALSECT ]],
  1907.         [ "update_dns",         \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, PEERDNS ]],
  1908.         [ "mtu",                \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh,      IFCFG, MTU ]],
  1909.         [ "mru",                \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh,      IFCFG, MRU ]],
  1910.         [ "login",              \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh,      IFCFG, PAPNAME ]],
  1911.         [ "password",           \&check_type, [TYPE, "modem", \&get_pap_passwd, PAP,  "%login%" ]],
  1912.         [ "password",           \&check_type, [TYPE, "modem", \&get_pap_passwd, CHAP, "%login%" ]],
  1913.         [ "serial_port",        \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh,      IFCFG, MODEMPORT ]],
  1914.         [ "serial_speed",       \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh,      IFCFG, LINESPEED ]],
  1915.         [ "set_default_gw",     \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, DEFROUTE ]],
  1916.         [ "persist",            \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, PERSIST ]],
  1917.         [ "serial_escapechars", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, ESCAPECHARS ]],
  1918.         [ "serial_hwctl",       \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, HARDFLOWCTL ]],
  1919.         [ "phone_number",       \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_chatfile,    CHAT, "^atd[^0-9]*([0-9, -]+)" ]],
  1920. #        [ "name",               \&Utils::Parse::get_sh,      IFCFG, NAME ],
  1921. #        [ "update_dns",         \&gst_network_pump_get_nodns, PUMP, "%dev%", "%bootproto%" ],
  1922. #        [ "dns1",               \&Utils::Parse::get_sh,      IFCFG, DNS1 ],
  1923. #        [ "dns2",               \&Utils::Parse::get_sh,      IFCFG, DNS2 ],
  1924. #        [ "ppp_options",        \&Utils::Parse::get_sh,      IFCFG, PPPOPTIONS ],
  1925. #        [ "debug",              \&Utils::Parse::get_sh_bool, IFCFG, DEBUG ],
  1926.         # wvdial settings
  1927.         [ "phone_number",       \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Phone" ]],
  1928.         [ "update_dns",         \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Auto DNS" ]],
  1929.         [ "login",              \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Username" ]],
  1930.         [ "password",           \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Password" ]],
  1931.         [ "serial_port",        \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Modem" ]],
  1932.         [ "serial_speed",       \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Baud" ]],
  1933.         [ "set_default_gw",     \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Check Def Route" ]],
  1934.         [ "persist",            \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Auto Reconnect" ]],
  1935.         [ "dial_command",       \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Dial Command" ]],
  1936.         [ "external_line",      \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Dial Prefix" ]],
  1937.        ]
  1938.      },
  1939.  
  1940.      "mandrake-9.0" =>
  1941.      {
  1942.        ifaces_get => \&get_existing_rh62_ifaces,
  1943.        fn =>
  1944.        {
  1945.          IFCFG   => "/etc/sysconfig/network-scripts/ifcfg-#iface#",
  1946.          CHAT    => "/etc/sysconfig/network-scripts/chat-#iface#",
  1947.          TYPE    => "#type#",
  1948.          IFACE   => "#iface#",
  1949.          PAP     => "/etc/ppp/pap-secrets",
  1950.          CHAP    => "/etc/ppp/chap-secrets",
  1951.          PUMP    => "/etc/pump.conf",
  1952.          WVDIAL  => "/etc/wvdial.conf"
  1953.        },
  1954.        table =>
  1955.        [
  1956.         [ "bootproto",          \&get_rh_bootproto,     IFCFG, BOOTPROTO ],
  1957.         [ "auto",               \&Utils::Parse::get_sh_bool, IFCFG, ONBOOT ],
  1958.         [ "dev",                \&Utils::Parse::get_sh, IFCFG, DEVICE ],
  1959.         [ "address",            \&Utils::Parse::get_sh, IFCFG, IPADDR ],
  1960.         [ "netmask",            \&Utils::Parse::get_sh, IFCFG, NETMASK ],
  1961.         [ "broadcast",          \&Utils::Parse::get_sh, IFCFG, BROADCAST ],
  1962.         [ "network",            \&Utils::Parse::get_sh, IFCFG, NETWORK ],
  1963.         [ "gateway",            \&Utils::Parse::get_sh, IFCFG, GATEWAY ],
  1964.         [ "essid",              \&Utils::Parse::get_sh, IFCFG, WIRELESS_ESSID ],
  1965.         [ "key_type",           \&get_wep_key_type, [ \&Utils::Parse::get_sh, IFCFG, WIRELESS_KEY ]],
  1966.         [ "key",                \&get_wep_key,      [ \&Utils::Parse::get_sh, IFCFG, WIRELESS_KEY ]],
  1967.         [ "remote_address",     \&Utils::Parse::get_sh, IFCFG, REMIP ],
  1968.         [ "section",            \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh,      IFCFG, WVDIALSECT ]],
  1969.         [ "update_dns",         \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, PEERDNS ]],
  1970.         [ "mtu",                \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh,      IFCFG, MTU ]],
  1971.         [ "mru",                \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh,      IFCFG, MRU ]],
  1972.         [ "login",              \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh,      IFCFG, PAPNAME ]],
  1973.         [ "password",           \&check_type, [TYPE, "modem", \&get_pap_passwd, PAP,  "%login%" ]],
  1974.         [ "password",           \&check_type, [TYPE, "modem", \&get_pap_passwd, CHAP, "%login%" ]],
  1975.         [ "serial_port",        \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh,      IFCFG, MODEMPORT ]],
  1976.         [ "serial_speed",       \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh,      IFCFG, LINESPEED ]],
  1977.         [ "set_default_gw",     \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, DEFROUTE ]],
  1978.         [ "persist",            \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, PERSIST ]],
  1979.         [ "serial_escapechars", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, ESCAPECHARS ]],
  1980.         [ "serial_hwctl",       \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, HARDFLOWCTL ]],
  1981.         [ "phone_number",       \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_chatfile,    CHAT, "^atd[^0-9]*([0-9, -]+)" ]],
  1982. #        [ "name",               \&Utils::Parse::get_sh,      IFCFG, NAME ],
  1983. #        [ "update_dns",         \&gst_network_pump_get_nodns, PUMP, "%dev%", "%bootproto%" ],
  1984. #        [ "dns1",               \&Utils::Parse::get_sh,      IFCFG, DNS1 ],
  1985. #        [ "dns2",               \&Utils::Parse::get_sh,      IFCFG, DNS2 ],
  1986. #        [ "ppp_options",        \&Utils::Parse::get_sh,      IFCFG, PPPOPTIONS ],
  1987. #        [ "debug",              \&Utils::Parse::get_sh_bool, IFCFG, DEBUG ],
  1988.         # wvdial settings
  1989.         [ "phone_number",       \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Phone" ]],
  1990.         [ "update_dns",         \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Auto DNS" ]],
  1991.         [ "login",              \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Username" ]],
  1992.         [ "password",           \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Password" ]],
  1993.         [ "serial_port",        \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Modem" ]],
  1994.         [ "serial_speed",       \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Baud" ]],
  1995.         [ "set_default_gw",     \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Check Def Route" ]],
  1996.         [ "persist",            \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Auto Reconnect" ]],
  1997.         [ "dial_command",       \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Dial Command" ]],
  1998.         [ "external_line",      \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Dial Prefix" ]],
  1999.        ]
  2000.      },
  2001.  
  2002.      "conectiva-9" =>
  2003.      {
  2004.        ifaces_get => \&get_existing_rh62_ifaces,
  2005.        fn =>
  2006.        {
  2007.          IFCFG   => "/etc/sysconfig/network-scripts/ifcfg-#iface#",
  2008.          CHAT    => "/etc/sysconfig/network-scripts/chat-#iface#",
  2009.          TYPE    => "#type#",
  2010.          IFACE   => "#iface#",
  2011.          PAP     => "/etc/ppp/pap-secrets",
  2012.          CHAP    => "/etc/ppp/chap-secrets",
  2013.          PUMP    => "/etc/pump.conf",
  2014.          WVDIAL  => "/etc/wvdial.conf"
  2015.        },
  2016.        table =>
  2017.        [
  2018.         [ "bootproto",          \&get_rh_bootproto,     IFCFG, BOOTPROTO ],
  2019.         [ "auto",               \&Utils::Parse::get_sh_bool, IFCFG, ONBOOT ],
  2020.         [ "dev",                \&Utils::Parse::get_sh, IFCFG, DEVICE ],
  2021.         [ "address",            \&Utils::Parse::get_sh, IFCFG, IPADDR ],
  2022.         [ "netmask",            \&Utils::Parse::get_sh, IFCFG, NETMASK ],
  2023.         [ "broadcast",          \&Utils::Parse::get_sh, IFCFG, BROADCAST ],
  2024.         [ "network",            \&Utils::Parse::get_sh, IFCFG, NETWORK ],
  2025.         [ "gateway",            \&Utils::Parse::get_sh, IFCFG, GATEWAY ],
  2026.         [ "essid",              \&Utils::Parse::get_sh, IFCFG, WIRELESS_ESSID ],
  2027.         [ "key_type",           \&get_wep_key_type, [ \&Utils::Parse::get_sh, IFCFG, WIRELESS_KEY ]],
  2028.         [ "key",                \&get_wep_key,      [ \&Utils::Parse::get_sh, IFCFG, WIRELESS_KEY ]],
  2029.         [ "remote_address",     \&Utils::Parse::get_sh, IFCFG, REMIP ],
  2030.         [ "section",            \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh,      IFCFG, WVDIALSECT ]],
  2031.         [ "update_dns",         \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, PEERDNS ]],
  2032.         [ "mtu",                \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh,      IFCFG, MTU ]],
  2033.         [ "mru",                \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh,      IFCFG, MRU ]],
  2034.         [ "login",              \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh,      IFCFG, PAPNAME ]],
  2035.         [ "password",           \&check_type, [TYPE, "modem", \&get_pap_passwd, PAP,  "%login%" ]],
  2036.         [ "password",           \&check_type, [TYPE, "modem", \&get_pap_passwd, CHAP, "%login%" ]],
  2037.         [ "serial_port",        \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh,      IFCFG, MODEMPORT ]],
  2038.         [ "serial_speed",       \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh,      IFCFG, LINESPEED ]],
  2039.         [ "ppp_options",        \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh,      IFCFG, PPPOPTIONS ]],
  2040.         [ "set_default_gw",     \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, DEFROUTE ]],
  2041.         [ "persist",            \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, PERSIST ]],
  2042.         [ "serial_escapechars", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, ESCAPECHARS ]],
  2043.         [ "serial_hwctl",       \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, HARDFLOWCTL ]],
  2044.         [ "phone_number",       \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_chatfile,    CHAT, "^atd[^0-9]*([0-9, -]+)" ]],
  2045. #        [ "name",               \&Utils::Parse::get_sh,      IFCFG, NAME ],
  2046. #        [ "update_dns",         \&gst_network_pump_get_nodns, PUMP, "%dev%", "%bootproto%" ],
  2047. #        [ "dns1",               \&Utils::Parse::get_sh,      IFCFG, DNS1 ],
  2048. #        [ "dns2",               \&Utils::Parse::get_sh,      IFCFG, DNS2 ],
  2049. #        [ "debug",              \&Utils::Parse::get_sh_bool, IFCFG, DEBUG ],
  2050.         # wvdial settings
  2051.         [ "phone_number",       \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Phone" ]],
  2052.         [ "update_dns",         \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Auto DNS" ]],
  2053.         [ "login",              \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Username" ]],
  2054.         [ "password",           \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Password" ]],
  2055.         [ "serial_port",        \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Modem" ]],
  2056.         [ "serial_speed",       \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Baud" ]],
  2057.         [ "set_default_gw",     \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Check Def Route" ]],
  2058.         [ "persist",            \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Auto Reconnect" ]],
  2059.         [ "dial_command",       \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Dial Command" ]],
  2060.         [ "external_line",      \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Dial Prefix" ]],
  2061.        ]
  2062.      },
  2063.  
  2064.      "debian-3.0" =>
  2065.      {
  2066.        fn =>
  2067.        {
  2068.          INTERFACES  => "/etc/network/interfaces",
  2069.          IFACE       => "#iface#",
  2070.          TYPE        => "#type#",
  2071.          CHAT        => "/etc/chatscripts/%section%",
  2072.          PPP_OPTIONS => "/etc/ppp/peers/%section%",
  2073.          PAP         => "/etc/ppp/pap-secrets",
  2074.          CHAP        => "/etc/ppp/chap-secrets",
  2075.        },
  2076.        table =>
  2077.        [
  2078.         [ "dev",                \&Utils::Parse::get_trivial, IFACE ],
  2079.         [ "bootproto",          \&get_debian_bootproto,      [INTERFACES, IFACE]],
  2080.         [ "auto",               \&get_debian_auto,           [INTERFACES, IFACE]],
  2081.         [ "address",            \&Utils::Parse::get_interfaces_option_str,    [INTERFACES, IFACE], "address" ],
  2082.         [ "netmask",            \&Utils::Parse::get_interfaces_option_str,    [INTERFACES, IFACE], "netmask" ],
  2083.         [ "broadcast",          \&Utils::Parse::get_interfaces_option_str,    [INTERFACES, IFACE], "broadcast" ],
  2084.         [ "network",            \&Utils::Parse::get_interfaces_option_str,    [INTERFACES, IFACE], "network" ],
  2085.         [ "gateway",            \&Utils::Parse::get_interfaces_option_str,    [INTERFACES, IFACE], "gateway" ],
  2086.         [ "essid",              \&Utils::Parse::get_interfaces_option_str,    [INTERFACES, IFACE], "wireless[_-]essid" ],
  2087.         [ "key_type",           \&get_wep_key_type, [ \&Utils::Parse::get_interfaces_option_str, INTERFACES, IFACE, "wireless[_-]key1?" ]],
  2088.         [ "key",                \&get_wep_key,      [ \&Utils::Parse::get_interfaces_option_str, INTERFACES, IFACE, "wireless[_-]key1?" ]],
  2089.         [ "remote_address",     \&get_debian_remote_address, [INTERFACES, IFACE]],
  2090.         [ "section",            \&Utils::Parse::get_interfaces_option_str,    [INTERFACES, IFACE], "provider" ],
  2091.         [ "update_dns",         \&check_type, [TYPE, "(modem|isdn)", \&Utils::Parse::get_kw, PPP_OPTIONS, "usepeerdns" ]],
  2092.         [ "noauth",             \&check_type, [TYPE, "(modem|isdn)", \&Utils::Parse::get_kw, PPP_OPTIONS, "noauth" ]],
  2093.         [ "mtu",                \&check_type, [TYPE, "(modem|isdn)", \&Utils::Parse::split_first_str, PPP_OPTIONS, "mtu", "[ \t]+" ]],
  2094.         [ "mru",                \&check_type, [TYPE, "(modem|isdn)", \&Utils::Parse::split_first_str, PPP_OPTIONS, "mru", "[ \t]+" ]],
  2095.         [ "serial_port",        \&check_type, [TYPE, "modem", \&Utils::Parse::get_ppp_options_re, PPP_OPTIONS, "^(/dev/[^ \t]+)" ]],
  2096.         [ "serial_speed",       \&check_type, [TYPE, "modem", \&Utils::Parse::get_ppp_options_re, PPP_OPTIONS, "^([0-9]+)" ]],
  2097.         [ "login",              \&check_type, [TYPE, "(modem|isdn)", \&Utils::Parse::get_ppp_options_re, PPP_OPTIONS, "^user \"?([^\"]*)\"?" ]],
  2098.         [ "password",           \&check_type, [TYPE, "(modem|isdn)", \&get_pap_passwd, PAP, "%login%" ]],
  2099.         [ "password",           \&check_type, [TYPE, "(modem|isdn)", \&get_pap_passwd, CHAP, "%login%" ]],
  2100.         [ "set_default_gw",     \&check_type, [TYPE, "(modem|isdn)", \&Utils::Parse::get_kw, PPP_OPTIONS, "defaultroute" ]],
  2101.         [ "debug",              \&check_type, [TYPE, "(modem|isdn)", \&Utils::Parse::get_kw, PPP_OPTIONS, "debug" ]],
  2102.         [ "persist",            \&check_type, [TYPE, "(modem|isdn)", \&Utils::Parse::get_kw, PPP_OPTIONS, "persist" ]],
  2103.         [ "serial_escapechars", \&check_type, [TYPE, "modem", \&Utils::Parse::split_first_str, PPP_OPTIONS, "escape", "[ \t]+" ]],
  2104.         [ "serial_hwctl",       \&check_type, [TYPE, "modem", \&Utils::Parse::get_kw, PPP_OPTIONS, "crtscts" ]],
  2105.         [ "external_line",      \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_chatfile, CHAT, "atd[^0-9]([0-9*#]*)[wW]" ]],
  2106.         [ "external_line",      \&check_type, [TYPE, "isdn",  \&Utils::Parse::get_ppp_options_re, PPP_OPTIONS, "^number[ \t]+(.+)[wW]" ]],
  2107.         [ "phone_number",       \&check_type, [TYPE, "isdn",  \&Utils::Parse::get_ppp_options_re, PPP_OPTIONS, "^number.*[wW \t](.*)" ]],
  2108.         [ "phone_number",       \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_chatfile, CHAT, "atd.*[ptwW]([0-9, -]+)" ]],
  2109.         [ "dial_command",       \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_chatfile, CHAT, "(atd[tp])[0-9, -w]+" ]],
  2110.         [ "volume",             \&check_type, [TYPE, "modem", \&get_modem_volume, CHAT ]],
  2111. #        [ "ppp_options",        \&check_type, [TYPE, "modem", \&gst_network_get_ppp_options_unsup, PPP_OPTIONS ]],
  2112.        ]
  2113.      },
  2114.  
  2115.      "suse-9.0" =>
  2116.      {
  2117.        ifaces_get => \&get_existing_suse_ifaces,
  2118.        fn =>
  2119.        {
  2120.          IFCFG      => "/etc/sysconfig/network/ifcfg-#iface#",
  2121.          ROUTES_CONF => "/etc/sysconfig/network/routes",
  2122.          PROVIDERS  => "/etc/sysconfig/network/providers/%section%",
  2123.          IFACE      => "#iface#",
  2124.          TYPE       => "#type#",
  2125.        },
  2126.        table =>
  2127.        [
  2128.         [ "dev",            \&get_suse_dev_name, IFACE ],
  2129.         [ "auto",           \&get_suse_auto,        IFCFG, STARTMODE ],
  2130.         [ "bootproto",      \&get_bootproto,        IFCFG, BOOTPROTO ],
  2131.         [ "address",        \&Utils::Parse::get_sh, IFCFG, IPADDR ],
  2132.         [ "netmask",        \&Utils::Parse::get_sh, IFCFG, NETMASK ],
  2133.         [ "remote_address", \&Utils::Parse::get_sh, IFCFG, REMOTE_IPADDR ],
  2134.         [ "essid",          \&Utils::Parse::get_sh, IFCFG, WIRELESS_ESSID ],
  2135.         [ "key_type",       \&get_wep_key_type,     [ \&Utils::Parse::get_sh, IFCFG, WIRELESS_KEY ]],
  2136.         [ "key",            \&get_wep_key,          [ \&Utils::Parse::get_sh, IFCFG, WIRELESS_KEY ]],
  2137.         [ "gateway",        \&get_suse_gateway,     ROUTES_CONF, "%address%", "%netmask%" ],
  2138.         [ "gateway",        \&get_suse_gateway,     ROUTES_CONF, "%remote_address%", "255.255.255.255" ],
  2139.         # Modem stuff goes here
  2140.         [ "serial_port",    \&Utils::Parse::get_sh, IFCFG, MODEM_DEVICE ],
  2141.         [ "serial_speed",   \&Utils::Parse::get_sh, IFCFG, SPEED ],
  2142.         [ "mtu",            \&Utils::Parse::get_sh, IFCFG, MTU ],
  2143.         [ "mru",            \&Utils::Parse::get_sh, IFCFG, MRU ],
  2144.         [ "dial_command",   \&Utils::Parse::get_sh, IFCFG, DIALCOMMAND ],
  2145.         [ "external_line",  \&Utils::Parse::get_sh, IFCFG, DIALPREFIX ],
  2146.         [ "section",        \&Utils::Parse::get_sh, IFCFG, PROVIDER ],
  2147.         [ "volume",         \&Utils::Parse::get_sh_re, IFCFG, INIT8, "AT.*[ml]([0-3])" ],
  2148.         [ "login",          \&Utils::Parse::get_sh, PROVIDERS, USERNAME ],
  2149.         [ "password",       \&Utils::Parse::get_sh, PROVIDERS, PASSWORD ],
  2150.         [ "phone_number",   \&Utils::Parse::get_sh, PROVIDERS, PHONE ],
  2151.         [ "dns1",           \&Utils::Parse::get_sh, PROVIDERS, DNS1 ],
  2152.         [ "dns2",           \&Utils::Parse::get_sh, PROVIDERS, DNS2 ],
  2153.         [ "update_dns",     \&Utils::Parse::get_sh_bool, PROVIDERS, MODIFYDNS ],
  2154.         [ "persist",        \&Utils::Parse::get_sh_bool, PROVIDERS, PERSIST ],
  2155.         [ "stupid",         \&Utils::Parse::get_sh_bool, PROVIDERS, STUPIDMODE ],
  2156.         [ "set_default_gw", \&Utils::Parse::get_sh_bool, PROVIDERS, DEFAULTROUTE ],
  2157. #        [ "ppp_options",    \&Utils::Parse::get_sh, IFCFG,   PPPD_OPTIONS ],
  2158.        ]
  2159.      },
  2160.  
  2161.      "pld-1.0" =>
  2162.      {
  2163.        ifaces_get => \&get_existing_pld_ifaces,
  2164.        fn =>
  2165.        {
  2166.          IFCFG => "/etc/sysconfig/interfaces/ifcfg-#iface#",
  2167.          CHAT  => "/etc/sysconfig/interfaces/data/chat-#iface#",
  2168.          TYPE  => "#type#",
  2169.          IFACE => "#iface#",
  2170.          PAP   => "/etc/ppp/pap-secrets",
  2171.          CHAP  => "/etc/ppp/chap-secrets",
  2172.          PUMP  => "/etc/pump.conf"
  2173.        },
  2174.        table =>
  2175.        [
  2176.         [ "bootproto",          \&get_rh_bootproto,          IFCFG, BOOTPROTO ],
  2177.         [ "auto",               \&Utils::Parse::get_sh_bool, IFCFG, ONBOOT ],
  2178.         [ "dev",                \&Utils::Parse::get_sh,      IFCFG, DEVICE ],
  2179.         [ "address",            \&get_pld_ipaddr,            IFCFG, IPADDR, "address" ],
  2180.         [ "netmask",            \&get_pld_ipaddr,            IFCFG, IPADDR, "netmask" ],
  2181.         [ "gateway",            \&Utils::Parse::get_sh,      IFCFG, GATEWAY ],
  2182.         [ "remote_address",     \&Utils::Parse::get_sh,      IFCFG, REMIP ],
  2183.         [ "update_dns",         \&Utils::Parse::get_sh_bool, IFCFG, PEERDNS ],
  2184.         [ "mtu",                \&Utils::Parse::get_sh,      IFCFG, MTU ],
  2185.         [ "mru",                \&Utils::Parse::get_sh,      IFCFG, MRU ],
  2186.         [ "login",              \&Utils::Parse::get_sh,      IFCFG, PAPNAME ],
  2187.         [ "password",           \&get_pap_passwd,            PAP,  "%login%" ],
  2188.         [ "password",           \&get_pap_passwd,            CHAP, "%login%" ],
  2189.         [ "serial_port",        \&Utils::Parse::get_sh,      IFCFG, MODEMPORT ],
  2190.         [ "serial_speed",       \&Utils::Parse::get_sh,      IFCFG, LINESPEED ],
  2191.         [ "set_default_gw",     \&Utils::Parse::get_sh_bool, IFCFG, DEFROUTE ],
  2192.         [ "persist",            \&Utils::Parse::get_sh_bool, IFCFG, PERSIST ],
  2193.         [ "serial_escapechars", \&Utils::Parse::get_sh_bool, IFCFG, ESCAPECHARS ],
  2194.         [ "serial_hwctl",       \&Utils::Parse::get_sh_bool, IFCFG, HARDFLOWCTL ],
  2195.         [ "phone_number",       \&Utils::Parse::get_from_chatfile,    CHAT, "^atd[^0-9]*([0-9, -]+)" ],
  2196. #        [ "name",               \&Utils::Parse::get_sh,      IFCFG, DEVICE ],
  2197. #        [ "broadcast",          \&Utils::Parse::get_sh,      IFCFG, BROADCAST ],
  2198. #        [ "network",            \&Utils::Parse::get_sh,      IFCFG, NETWORK ],
  2199. #        [ "update_dns",         \&gst_network_pump_get_nodns, PUMP, "%dev%", "%bootproto%" ],
  2200. #        [ "dns1",               \&Utils::Parse::get_sh,      IFCFG, DNS1 ],
  2201. #        [ "dns2",               \&Utils::Parse::get_sh,      IFCFG, DNS2 ],
  2202. #        [ "ppp_options",        \&Utils::Parse::get_sh,      IFCFG, PPPOPTIONS ],
  2203. #        [ "section",            \&Utils::Parse::get_sh,      IFCFG, WVDIALSECT ],
  2204. #        [ "debug",              \&Utils::Parse::get_sh_bool, IFCFG, DEBUG ],
  2205.        ]
  2206.      },
  2207.  
  2208.      "slackware-9.1.0" =>
  2209.      {
  2210.        fn =>
  2211.        {
  2212.          RC_INET_CONF => "/etc/rc.d/rc.inet1.conf",
  2213.          RC_INET      => "/etc/rc.d/rc.inet1",
  2214.          RC_LOCAL     => "/etc/rc.d/rc.local",
  2215.          TYPE         => "#type#",
  2216.          IFACE        => "#iface#",
  2217.          WIRELESS     => "/etc/pcmcia/wireless.opts",
  2218.          PPP_OPTIONS  => "/etc/ppp/options",
  2219.          PAP          => "/etc/ppp/pap-secrets",
  2220.          CHAP         => "/etc/ppp/chap-secrets",
  2221.          CHAT         => "/etc/ppp/pppscript",
  2222.        },
  2223.        table =>
  2224.        [
  2225.         [ "dev",                \&Utils::Parse::get_trivial,     IFACE ],
  2226.         [ "address",            \&Utils::Parse::get_rcinet1conf, [RC_INET_CONF, IFACE], IPADDR ],
  2227.         [ "netmask",            \&Utils::Parse::get_rcinet1conf, [RC_INET_CONF, IFACE], NETMASK ],
  2228.         [ "gateway",            \&get_gateway,                   RC_INET_CONF, GATEWAY, "%address%", "%netmask%" ],
  2229.         [ "auto",               \&get_slackware_auto,            [RC_INET, RC_LOCAL, IFACE]],
  2230.         [ "bootproto",          \&get_slackware_bootproto,       [RC_INET_CONF, IFACE]],
  2231.         [ "essid",              \&Utils::Parse::get_wireless_opts,            [ WIRELESS, IFACE], \&get_wireless_ifaces, ESSID ],
  2232.         [ "key_type",           \&get_wep_key_type, [ \&Utils::Parse::get_wireless_opts, [ WIRELESS, IFACE], \&get_wireless_ifaces, KEY ]],
  2233.         [ "key",                \&get_wep_key,      [ \&Utils::Parse::get_wireless_opts, [ WIRELESS, IFACE], \&get_wireless_ifaces, KEY ]],
  2234.         # Modem stuff
  2235.         [ "update_dns",         \&check_type, [TYPE, "modem", \&Utils::Parse::get_kw, PPP_OPTIONS, "usepeerdns" ]],
  2236.         [ "noauth",             \&check_type, [TYPE, "modem", \&Utils::Parse::get_kw, PPP_OPTIONS, "noauth" ]],
  2237.         [ "mtu",                \&check_type, [TYPE, "modem", \&Utils::Parse::split_first_str, PPP_OPTIONS, "mtu", "[ \t]+" ]],
  2238.         [ "mru",                \&check_type, [TYPE, "modem", \&Utils::Parse::split_first_str, PPP_OPTIONS, "mru", "[ \t]+" ]],
  2239.         [ "serial_port",        \&check_type, [TYPE, "modem", \&Utils::Parse::get_ppp_options_re, PPP_OPTIONS, "^(/dev/[^ \t]+)" ]],
  2240.         [ "serial_speed",       \&check_type, [TYPE, "modem", \&Utils::Parse::get_ppp_options_re, PPP_OPTIONS, "^([0-9]+)" ]],
  2241.         [ "login",              \&check_type, [TYPE, "modem", \&Utils::Parse::get_ppp_options_re, PPP_OPTIONS, "^name \"?([^\"]*)\"?" ]],
  2242.         [ "password",           \&check_type, [TYPE, "modem", \&get_pap_passwd, PAP, "%login%" ]],
  2243.         [ "password",           \&check_type, [TYPE, "modem", \&get_pap_passwd, CHAP, "%login%" ]],
  2244.         [ "set_default_gw",     \&check_type, [TYPE, "modem", \&Utils::Parse::get_kw, PPP_OPTIONS, "defaultroute" ]],
  2245.         [ "debug",              \&check_type, [TYPE, "modem", \&Utils::Parse::get_kw, PPP_OPTIONS, "debug" ]],
  2246.         [ "persist",            \&check_type, [TYPE, "modem", \&Utils::Parse::get_kw, PPP_OPTIONS, "persist" ]],
  2247.         [ "serial_escapechars", \&check_type, [TYPE, "modem", \&Utils::Parse::split_first_str, PPP_OPTIONS, "escape", "[ \t]+" ]],
  2248.         [ "serial_hwctl",       \&check_type, [TYPE, "modem", \&Utils::Parse::get_kw, PPP_OPTIONS, "crtscts" ]],
  2249.         [ "external_line",      \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_chatfile, CHAT, "atd[^0-9]*([0-9*#]*)[wW]" ]],
  2250.         [ "phone_number",       \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_chatfile, CHAT, "atd.*[ptw]([0-9, -]+)" ]],
  2251.         [ "dial_command",       \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_chatfile, CHAT, "(atd[tp])[0-9, -w]+" ]],
  2252.         [ "volume",             \&check_type, [TYPE, "modem", \&get_modem_volume, CHAT ]],
  2253. #        [ "ppp_options",        \&check_type, [TYPE, "modem", \&gst_network_get_ppp_options_unsup, PPP_OPTIONS ]],
  2254.        ]
  2255.      },
  2256.  
  2257.      "gentoo" =>
  2258.      {
  2259.        fn =>
  2260.        {
  2261.          NET          => "/etc/conf.d/net",
  2262.          PPPNET       => "/etc/conf.d/net.#iface#",
  2263.          INIT         => "net.#iface#",
  2264.          TYPE         => "#type#",
  2265.          IFACE        => "#iface#",
  2266.          WIRELESS     => "/etc/conf.d/wireless",
  2267.        },
  2268.        table =>
  2269.        [
  2270.         [ "auto",               \&Init::Services::get_gentoo_service_status, INIT, "default" ],
  2271.         [ "dev",                \&Utils::Parse::get_trivial, IFACE ],
  2272.         [ "address",            \&Utils::Parse::get_confd_net_re, NET, "config_%dev%", "^[ \t]*([0-9\.]+)" ],
  2273.         [ "netmask",            \&Utils::Parse::get_confd_net_re, NET, "config_%dev%", "netmask[ \t]+([0-9\.]*)" ],
  2274.         [ "remote_address",     \&Utils::Parse::get_confd_net_re, NET, "config_%dev%", "dest_address[ \t]+([0-9\.]*)" ],
  2275.         # [ "gateway",            \&gst_network_gentoo_parse_gateway,   [ NET, IFACE ]],
  2276.         [ "bootproto",          \&get_gentoo_bootproto,  [ NET, IFACE ]],
  2277.         [ "essid",              \&Utils::Parse::get_sh,  WIRELESS, "essid_%dev%" ],
  2278.         [ "key_type",           \&get_wep_key_type,      [ \&Utils::Parse::get_sh, WIRELESS, "key_%essid%" ]],
  2279.         [ "key",                \&get_wep_key,           [ \&Utils::Parse::get_sh, WIRELESS, "key_%essid%" ]],
  2280.         # modem stuff
  2281.         [ "update_dns",         \&Utils::Parse::get_sh_bool, PPPNET, PEERDNS ],
  2282.         [ "mtu",                \&Utils::Parse::get_sh,      PPPNET, MTU ],
  2283.         [ "mru",                \&Utils::Parse::get_sh,      PPPNET, MRU ],
  2284.         [ "serial_port",        \&Utils::Parse::get_sh,      PPPNET, MODEMPORT ],
  2285.         [ "serial_speed",       \&Utils::Parse::get_sh,      PPPNET, LINESPEED ],
  2286.         [ "login",              \&Utils::Parse::get_sh,      PPPNET, USERNAME ],
  2287.         [ "password",           \&Utils::Parse::get_sh,      PPPNET, PASSWORD ],
  2288.         [ "ppp_options",        \&Utils::Parse::get_sh,      PPPNET, PPPOPTIONS ],
  2289.         [ "set_default_gw",     \&Utils::Parse::get_sh_bool, PPPNET, DEFROUTE ],
  2290.         [ "debug",              \&Utils::Parse::get_sh_bool, PPPNET, DEBUG ],
  2291.         [ "persist",            \&Utils::Parse::get_sh_bool, PPPNET, PERSIST ],
  2292.         [ "serial_escapechars", \&Utils::Parse::get_sh_bool, PPPNET, ESCAPECHARS ],
  2293.         [ "serial_hwctl",       \&Utils::Parse::get_sh_bool, PPPNET, HARDFLOWCTL ],
  2294.         [ "external_line",      \&Utils::Parse::get_sh_re,   PPPNET, NUMBER, "^([0-9*#]*)wW" ],
  2295.         [ "phone_number",       \&Utils::Parse::get_sh_re,   PPPNET, NUMBER, "w?([0-9]*)\$" ],
  2296.         [ "volume",             \&Utils::Parse::get_sh_re,   PPPNET, INITSTRING, "^at.*[ml]([0-3])" ],
  2297.        ]
  2298.      },
  2299.  
  2300.      "freebsd-5" =>
  2301.      {
  2302.        fn =>
  2303.        {
  2304.          RC_CONF         => "/etc/rc.conf",
  2305.          RC_CONF_DEFAULT => "/etc/defaults/rc.conf",
  2306.          STARTIF         => "/etc/start_if.#iface#",
  2307.          PPPCONF         => "/etc/ppp/ppp.conf",
  2308.          TYPE            => "#type#",
  2309.          IFACE           => "#iface#",
  2310.        },
  2311.        table =>
  2312.        [
  2313.         [ "auto",           \&get_freebsd_auto,               [RC_CONF, RC_CONF_DEFAULT, IFACE ]],
  2314.         [ "dev",            \&Utils::Parse::get_trivial,      IFACE ],
  2315.         # we need to double check these values both in the start_if and in the rc.conf files, in this order
  2316.         [ "address",        \&Utils::Parse::get_startif,      STARTIF, "inet[ \t]+([0-9\.]+)" ],
  2317.         [ "address",        \&Utils::Parse::get_sh_re,        RC_CONF, "ifconfig_%dev%", "inet[ \t]+([0-9\.]+)" ],
  2318.         [ "netmask",        \&Utils::Parse::get_startif,      STARTIF, "netmask[ \t]+([0-9\.]+)" ],
  2319.         [ "netmask",        \&Utils::Parse::get_sh_re,        RC_CONF, "ifconfig_%dev%", "netmask[ \t]+([0-9\.]+)" ],
  2320.         [ "remote_address", \&Utils::Parse::get_startif,      STARTIF, "dest_address[ \t]+([0-9\.]+)" ],
  2321.         [ "remote_address", \&Utils::Parse::get_sh_re,        RC_CONF, "ifconfig_%dev%", "dest_address[ \t]+([0-9\.]+)" ],
  2322.         [ "essid",          \&Utils::Parse::get_startif,      STARTIF, "ssid[ \t]+(\".*\"|[^\"][^ ]+)" ],
  2323.         [ "essid",          \&Utils::Parse::get_sh_re,        RC_CONF, "ifconfig_%dev%", "ssid[ \t]+([^ ]*)" ],
  2324.         # this is for plip interfaces
  2325.         [ "gateway",        \&get_gateway,                    RC_CONF, "defaultrouter", "%remote_address%", "255.255.255.255" ],
  2326.         [ "gateway",        \&get_gateway,                    RC_CONF, "defaultrouter", "%address%", "%netmask%" ],
  2327.         [ "bootproto",      \&get_bootproto,                  RC_CONF, "ifconfig_%dev%" ],
  2328.         # Modem stuff
  2329.         [ "serial_port",    \&Utils::Parse::get_pppconf,      [ PPPCONF, STARTIF, IFACE ], "device"   ],
  2330.         [ "serial_speed",   \&Utils::Parse::get_pppconf,      [ PPPCONF, STARTIF, IFACE ], "speed"    ],
  2331.         [ "mtu",            \&Utils::Parse::get_pppconf,      [ PPPCONF, STARTIF, IFACE ], "mtu"      ],
  2332.         [ "mru",            \&Utils::Parse::get_pppconf,      [ PPPCONF, STARTIF, IFACE ], "mru"      ],
  2333.         [ "login",          \&Utils::Parse::get_pppconf,      [ PPPCONF, STARTIF, IFACE ], "authname" ],
  2334.         [ "password",       \&Utils::Parse::get_pppconf,      [ PPPCONF, STARTIF, IFACE ], "authkey"  ],
  2335.         [ "update_dns",     \&Utils::Parse::get_pppconf_bool, [ PPPCONF, STARTIF, IFACE ], "dns"      ],
  2336.         [ "set_default_gw", \&Utils::Parse::get_pppconf_bool, [ PPPCONF, STARTIF, IFACE ], "default HISADDR" ],
  2337.         [ "external_line",  \&Utils::Parse::get_pppconf_re,   [ PPPCONF, STARTIF, IFACE ], "phone", "[ \t]+([0-9]+)[wW]" ],
  2338.         [ "phone_number",   \&Utils::Parse::get_pppconf_re,   [ PPPCONF, STARTIF, IFACE ], "phone", "[wW]?([0-9]+)[ \t]*\$" ],
  2339.         [ "dial_command",   \&Utils::Parse::get_pppconf_re,   [ PPPCONF, STARTIF, IFACE ], "dial",  "(ATD[TP])" ],
  2340.         [ "volume",         \&Utils::Parse::get_pppconf_re,   [ PPPCONF, STARTIF, IFACE ], "dial",  "AT.*[ml]([0-3]) OK " ],
  2341.         [ "persist",        \&get_freebsd_ppp_persist,        [ STARTIF, IFACE ]],
  2342.        ]
  2343.      },
  2344.       );
  2345.   
  2346.   my $dist = &get_interface_dist ();
  2347.   return %{$dist_tables{$dist}} if $dist;
  2348.  
  2349.   &Utils::Report::do_report ("platform_no_table", $Utils::Backend::tool{"platform"});
  2350.   return undef;
  2351. }
  2352.  
  2353. sub get_interface_replace_table
  2354. {
  2355.   my %dist_tables =
  2356.   (
  2357.    "redhat-6.2" =>
  2358.    {
  2359.      iface_set    => \&activate_interface,
  2360.      iface_delete => \&delete_rh62_interface,
  2361.      fn =>
  2362.      {
  2363.        IFCFG  => "/etc/sysconfig/network-scripts/ifcfg-#iface#",
  2364.        CHAT   => "/etc/sysconfig/network-scripts/chat-#iface#",
  2365.        IFACE  => "#iface#",
  2366.        WVDIAL => "/etc/wvdial.conf",
  2367.        PUMP   => "/etc/pump.conf"
  2368.      },
  2369.      table =>
  2370.      [
  2371.       [ "bootproto",          \&set_rh_bootproto, IFCFG, BOOTPROTO ],
  2372.       [ "auto",               \&Utils::Replace::set_sh_bool, IFCFG, ONBOOT ],
  2373.       [ "dev",                \&Utils::Replace::set_sh,      IFCFG, NAME ],
  2374.       [ "dev",                \&Utils::Replace::set_sh,      IFCFG, DEVICE ],
  2375.       [ "address",            \&Utils::Replace::set_sh,      IFCFG, IPADDR ],
  2376.       [ "netmask",            \&Utils::Replace::set_sh,      IFCFG, NETMASK ],
  2377.       [ "broadcast",          \&Utils::Replace::set_sh,      IFCFG, BROADCAST ],
  2378.       [ "network",            \&Utils::Replace::set_sh,      IFCFG, NETWORK ],
  2379.       [ "gateway",            \&Utils::Replace::set_sh,      IFCFG, GATEWAY ],
  2380.       [ "update_dns",         \&Utils::Replace::set_sh_bool, IFCFG, PEERDNS ],
  2381.       [ "remote_address",     \&Utils::Replace::set_sh,      IFCFG, REMIP ],
  2382.       [ "login",              \&Utils::Replace::set_sh,      IFCFG, PAPNAME ],
  2383.       [ "serial_port",        \&Utils::Replace::set_sh,      IFCFG, MODEMPORT ],
  2384.       [ "serial_speed",       \&Utils::Replace::set_sh,      IFCFG, LINESPEED ],
  2385.       [ "ppp_options",        \&Utils::Replace::set_sh,      IFCFG, PPPOPTIONS ],
  2386.       [ "section",            \&Utils::Replace::set_sh,      IFCFG, WVDIALSECT ],
  2387.       [ "set_default_gw",     \&Utils::Replace::set_sh_bool, IFCFG, DEFROUTE ],
  2388.       [ "persist",            \&Utils::Replace::set_sh_bool, IFCFG, PERSIST ],
  2389.       [ "phone_number",       \&Utils::Replace::set_chat,    CHAT,  "^atd[^0-9]*([0-9, -]+)" ],
  2390. #      [ "update_dns",         \&gst_network_pump_set_nodns, PUMP, "%dev%", "%bootproto%" ],
  2391. #      [ "dns1",               \&Utils::Replace::set_sh,      IFCFG, DNS1 ],
  2392. #      [ "dns2",               \&Utils::Replace::set_sh,      IFCFG, DNS2 ],
  2393. #      [ "mtu",                \&Utils::Replace::set_sh,      IFCFG, MTU ],
  2394. #      [ "mru",                \&Utils::Replace::set_sh,      IFCFG, MRU ],
  2395. #      [ "debug",              \&Utils::Replace::set_sh_bool, IFCFG, DEBUG ],
  2396. #      [ "serial_escapechars", \&Utils::Replace::set_sh_bool, IFCFG, ESCAPECHARS ],
  2397. #      [ "serial_hwctl",       \&Utils::Replace::set_sh_bool, IFCFG, HARDFLOWCTL ],
  2398.       # wvdial settings
  2399.       [ "phone_number",       \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Phone" ]],
  2400.       [ "update_dns",         \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Auto DNS" ]],
  2401.       [ "login",              \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Username" ]],
  2402.       [ "password",           \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Password" ]],
  2403.       [ "serial_port",        \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Modem" ]],
  2404.       [ "serial_speed",       \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Baud" ]],
  2405.       [ "set_default_gw",     \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Check Def Route" ]],
  2406.       [ "persist",            \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Auto Reconnect" ]],
  2407.       [ "dial_command",       \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Dial Command" ]],
  2408.       [ "external_line",      \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Dial Prefix" ]],
  2409.      ]
  2410.    },
  2411.  
  2412.    "redhat-7.2" =>
  2413.    {
  2414.      iface_set    => \&activate_interface,
  2415.      iface_delete => \&delete_rh72_interface,
  2416.      fn =>
  2417.      {
  2418.        IFCFG => ["/etc/sysconfig/network-scripts/ifcfg-#iface#",
  2419.                  "/etc/sysconfig/networking/profiles/default/ifcfg-#iface#",
  2420.                  "/etc/sysconfig/networking/devices/ifcfg-#iface#"],
  2421.        CHAT   => "/etc/sysconfig/network-scripts/chat-#iface#",
  2422.        IFACE  => "#iface#",
  2423.        WVDIAL => "/etc/wvdial.conf",
  2424.        PUMP   => "/etc/pump.conf"
  2425.      },
  2426.      table =>
  2427.      [
  2428.       [ "bootproto",          \&set_rh_bootproto, IFCFG, BOOTPROTO ],
  2429.       [ "auto",               \&Utils::Replace::set_sh_bool, IFCFG, ONBOOT ],
  2430.       [ "dev",                \&Utils::Replace::set_sh,      IFCFG, NAME ],
  2431.       [ "dev",                \&Utils::Replace::set_sh,      IFCFG, DEVICE ],
  2432.       [ "address",            \&Utils::Replace::set_sh,      IFCFG, IPADDR ],
  2433.       [ "netmask",            \&Utils::Replace::set_sh,      IFCFG, NETMASK ],
  2434.       [ "broadcast",          \&Utils::Replace::set_sh,      IFCFG, BROADCAST ],
  2435.       [ "network",            \&Utils::Replace::set_sh,      IFCFG, NETWORK ],
  2436.       [ "gateway",            \&Utils::Replace::set_sh,      IFCFG, GATEWAY ],
  2437.       [ "essid",              \&Utils::Replace::set_sh,      IFCFG, ESSID ],
  2438.       [ "key",                \&Utils::Replace::set_sh,      IFCFG, KEY ],
  2439.       [ "key_type",           \&set_wep_key_full, [ \&Utils::Replace::set_sh, IFCFG, KEY, "%key%" ]],
  2440.       [ "update_dns",         \&Utils::Replace::set_sh_bool, IFCFG, PEERDNS ],
  2441.       [ "remote_address",     \&Utils::Replace::set_sh,      IFCFG, REMIP ],
  2442.       [ "login",              \&Utils::Replace::set_sh,      IFCFG, PAPNAME ],
  2443.       [ "serial_port",        \&Utils::Replace::set_sh,      IFCFG, MODEMPORT ],
  2444.       [ "serial_speed",       \&Utils::Replace::set_sh,      IFCFG, LINESPEED ],
  2445.       [ "section",            \&Utils::Replace::set_sh,      IFCFG, WVDIALSECT ],
  2446.       [ "set_default_gw",     \&Utils::Replace::set_sh_bool, IFCFG, DEFROUTE ],
  2447.       [ "persist",            \&Utils::Replace::set_sh_bool, IFCFG, PERSIST ],
  2448.       [ "phone_number",       \&Utils::Replace::set_chat,    CHAT,  "^atd[^0-9]*([0-9, -]+)" ],
  2449. #      [ "update_dns",         \&gst_network_pump_set_nodns, PUMP, "%dev%", "%bootproto%" ],
  2450. #      [ "dns1",               \&Utils::Replace::set_sh,      IFCFG, DNS1 ],
  2451. #      [ "dns2",               \&Utils::Replace::set_sh,      IFCFG, DNS2 ],
  2452. #      [ "mtu",                \&Utils::Replace::set_sh,      IFCFG, MTU ],
  2453. #      [ "mru",                \&Utils::Replace::set_sh,      IFCFG, MRU ],
  2454. #      [ "ppp_options",        \&Utils::Replace::set_sh,      IFCFG, PPPOPTIONS ],
  2455. #      [ "debug",              \&Utils::Replace::set_sh_bool, IFCFG, DEBUG ],
  2456. #      [ "serial_escapechars", \&Utils::Replace::set_sh_bool, IFCFG, ESCAPECHARS ],
  2457. #      [ "serial_hwctl",       \&Utils::Replace::set_sh_bool, IFCFG, HARDFLOWCTL ],
  2458.       # wvdial settings
  2459.       [ "phone_number",       \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Phone" ]],
  2460.       [ "update_dns",         \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Auto DNS" ]],
  2461.       [ "login",              \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Username" ]],
  2462.       [ "password",           \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Password" ]],
  2463.       [ "serial_port",        \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Modem" ]],
  2464.       [ "serial_speed",       \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Baud" ]],
  2465.       [ "set_default_gw",     \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Check Def Route" ]],
  2466.       [ "persist",            \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Auto Reconnect" ]],
  2467.       [ "dial_command",       \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Dial Command" ]],
  2468.       [ "external_line",      \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Dial Prefix" ]],
  2469.      ]
  2470.    },
  2471.    
  2472.    "redhat-8.0" =>
  2473.    {
  2474.      iface_set    => \&activate_interface,
  2475.      iface_delete => \&delete_rh72_interface,
  2476.      fn =>
  2477.      {
  2478.        IFCFG => ["/etc/sysconfig/network-scripts/ifcfg-#iface#",
  2479.                  "/etc/sysconfig/networking/profiles/default/ifcfg-#iface#",
  2480.                  "/etc/sysconfig/networking/devices/ifcfg-#iface#"],
  2481.        CHAT   => "/etc/sysconfig/network-scripts/chat-#iface#",
  2482.        IFACE  => "#iface#",
  2483.        WVDIAL => "/etc/wvdial.conf",
  2484.        PUMP   => "/etc/pump.conf"
  2485.      },
  2486.      table =>
  2487.      [
  2488.       [ "bootproto",          \&set_rh_bootproto, IFCFG, BOOTPROTO ],
  2489.       [ "auto",               \&Utils::Replace::set_sh_bool, IFCFG, ONBOOT ],
  2490.       [ "dev" ,               \&Utils::Replace::set_sh,      IFCFG, NAME ],
  2491.       [ "dev",                \&Utils::Replace::set_sh,      IFCFG, DEVICE ],
  2492.       [ "address",            \&Utils::Replace::set_sh,      IFCFG, IPADDR ],
  2493.       [ "netmask",            \&Utils::Replace::set_sh,      IFCFG, NETMASK ],
  2494.       [ "broadcast",          \&Utils::Replace::set_sh,      IFCFG, BROADCAST ],
  2495.       [ "network",            \&Utils::Replace::set_sh,      IFCFG, NETWORK ],
  2496.       [ "gateway",            \&Utils::Replace::set_sh,      IFCFG, GATEWAY ],
  2497.       [ "essid",              \&Utils::Replace::set_sh,      IFCFG, WIRELESS_ESSID ],
  2498.       [ "key",                \&Utils::Replace::set_sh,      IFCFG, WIRELESS_KEY   ],
  2499.       [ "key_type",           \&set_wep_key_full, [ \&Utils::Replace::set_sh, IFCFG, WIRELESS_KEY, "%key%" ]],
  2500.       [ "update_dns",         \&Utils::Replace::set_sh_bool, IFCFG, PEERDNS ],
  2501.       [ "remote_address",     \&Utils::Replace::set_sh,      IFCFG, REMIP ],
  2502.       [ "login",              \&Utils::Replace::set_sh,      IFCFG, PAPNAME ],
  2503.       [ "serial_port",        \&Utils::Replace::set_sh,      IFCFG, MODEMPORT ],
  2504.       [ "section",            \&Utils::Replace::set_sh,      IFCFG, WVDIALSECT ],
  2505.       [ "set_default_gw",     \&Utils::Replace::set_sh_bool, IFCFG, DEFROUTE ],
  2506.       [ "persist",            \&Utils::Replace::set_sh_bool, IFCFG, PERSIST ],
  2507.       [ "phone_number",       \&Utils::Replace::set_chat,    CHAT,  "^atd[^0-9]*([0-9, -]+)" ],
  2508. #      [ "update_dns",         \&gst_network_pump_set_nodns, PUMP, "%dev%", "%bootproto%" ],
  2509. #      [ "dns1",               \&Utils::Replace::set_sh,      IFCFG, DNS1 ],
  2510. #      [ "dns2",               \&Utils::Replace::set_sh,      IFCFG, DNS2 ],
  2511. #      [ "mtu",                \&Utils::Replace::set_sh,      IFCFG, MTU ],
  2512. #      [ "mru",                \&Utils::Replace::set_sh,      IFCFG, MRU ],
  2513. #      [ "serial_speed",       \&Utils::Replace::set_sh,      IFCFG, LINESPEED ],
  2514. #      [ "ppp_options",        \&Utils::Replace::set_sh,      IFCFG, PPPOPTIONS ],
  2515. #      [ "debug",              \&Utils::Replace::set_sh_bool, IFCFG, DEBUG ],
  2516. #      [ "serial_escapechars", \&Utils::Replace::set_sh_bool, IFCFG, ESCAPECHARS ],
  2517. #      [ "serial_hwctl",       \&Utils::Replace::set_sh_bool, IFCFG, HARDFLOWCTL ],
  2518.       # wvdial settings
  2519.       [ "phone_number",       \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Phone" ]],
  2520.       [ "update_dns",         \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Auto DNS" ]],
  2521.       [ "login",              \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Username" ]],
  2522.       [ "password",           \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Password" ]],
  2523.       [ "serial_port",        \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Modem" ]],
  2524.       [ "serial_speed",       \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Baud" ]],
  2525.       [ "set_default_gw",     \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Check Def Route" ]],
  2526.       [ "persist",            \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Auto Reconnect" ]],
  2527.       [ "dial_command",       \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Dial Command" ]],
  2528.       [ "external_line",      \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Dial Prefix" ]],
  2529.      ]
  2530.    },
  2531.    
  2532.    "vine-3.0" =>
  2533.    {
  2534.      iface_set    => \&activate_interface,
  2535.      iface_delete => \&delete_rh62_interface,
  2536.      fn =>
  2537.      {
  2538.        IFCFG  => "/etc/sysconfig/network-scripts/ifcfg-#iface#",
  2539.        CHAT   => "/etc/sysconfig/network-scripts/chat-#iface#",
  2540.        IFACE  => "#iface#",
  2541.        WVDIAL => "/etc/wvdial.conf",
  2542.        PUMP   => "/etc/pump.conf"
  2543.      },
  2544.      table =>
  2545.      [
  2546.       [ "bootproto",          \&set_rh_bootproto, IFCFG, BOOTPROTO ],
  2547.       [ "auto",               \&Utils::Replace::set_sh_bool, IFCFG, ONBOOT ],
  2548.       [ "dev",                \&Utils::Replace::set_sh,      IFCFG, NAME ],
  2549.       [ "dev",                \&Utils::Replace::set_sh,      IFCFG, DEVICE ],
  2550.       [ "address",            \&Utils::Replace::set_sh,      IFCFG, IPADDR ],
  2551.       [ "netmask",            \&Utils::Replace::set_sh,      IFCFG, NETMASK ],
  2552.       [ "broadcast",          \&Utils::Replace::set_sh,      IFCFG, BROADCAST ],
  2553.       [ "network",            \&Utils::Replace::set_sh,      IFCFG, NETWORK ],
  2554.       [ "gateway",            \&Utils::Replace::set_sh,      IFCFG, GATEWAY ],
  2555.       [ "essid",              \&Utils::Replace::set_sh,      IFCFG, ESSID ],
  2556.       [ "key",                \&Utils::Replace::set_sh,      IFCFG, KEY   ],
  2557.       [ "key_type",           \&set_wep_key_full, [ \&Utils::Replace::set_sh, IFCFG, KEY, "%key%" ]],
  2558.       [ "update_dns",         \&Utils::Replace::set_sh_bool, IFCFG, PEERDNS ],
  2559.       [ "remote_address",     \&Utils::Replace::set_sh,      IFCFG, REMIP ],
  2560.       [ "login",              \&Utils::Replace::set_sh,      IFCFG, PAPNAME ],
  2561.       [ "serial_port",        \&Utils::Replace::set_sh,      IFCFG, MODEMPORT ],
  2562.       [ "serial_speed",       \&Utils::Replace::set_sh,      IFCFG, LINESPEED ],
  2563.       [ "section",            \&Utils::Replace::set_sh,      IFCFG, WVDIALSECT ],
  2564.       [ "set_default_gw",     \&Utils::Replace::set_sh_bool, IFCFG, DEFROUTE ],
  2565.       [ "persist",            \&Utils::Replace::set_sh_bool, IFCFG, PERSIST ],
  2566.       [ "phone_number",       \&Utils::Replace::set_chat,    CHAT,  "^atd[^0-9]*([0-9, -]+)" ],
  2567. #      [ "update_dns",         \&gst_network_pump_set_nodns, PUMP, "%dev%", "%bootproto%" ],
  2568. #      [ "dns1",               \&Utils::Replace::set_sh,      IFCFG, DNS1 ],
  2569. #      [ "dns2",               \&Utils::Replace::set_sh,      IFCFG, DNS2 ],
  2570. #      [ "mtu",                \&Utils::Replace::set_sh,      IFCFG, MTU ],
  2571. #      [ "mru",                \&Utils::Replace::set_sh,      IFCFG, MRU ],
  2572. #      [ "ppp_options",        \&Utils::Replace::set_sh,      IFCFG, PPPOPTIONS ],
  2573. #      [ "debug",              \&Utils::Replace::set_sh_bool, IFCFG, DEBUG ],
  2574. #      [ "serial_escapechars", \&Utils::Replace::set_sh_bool, IFCFG, ESCAPECHARS ],
  2575. #      [ "serial_hwctl",       \&Utils::Replace::set_sh_bool, IFCFG, HARDFLOWCTL ],
  2576.  
  2577.       # wvdial settings
  2578.       [ "phone_number",       \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Phone" ]],
  2579.       [ "update_dns",         \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Auto DNS" ]],
  2580.       [ "login",              \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Username" ]],
  2581.       [ "password",           \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Password" ]],
  2582.       [ "serial_port",        \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Modem" ]],
  2583.       [ "serial_speed",       \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Baud" ]],
  2584.       [ "set_default_gw",     \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Check Def Route" ]],
  2585.       [ "persist",            \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Auto Reconnect" ]],
  2586.       [ "dial_command",       \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Dial Command" ]],
  2587.       [ "external_line",      \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Dial Prefix" ]],
  2588.      ]
  2589.    },
  2590.  
  2591.    "mandrake-9.0" =>
  2592.    {
  2593.      iface_set    => \&activate_interface,
  2594.      iface_delete => \&delete_rh62_interface,
  2595.      fn =>
  2596.      {
  2597.        IFCFG  => "/etc/sysconfig/network-scripts/ifcfg-#iface#",
  2598.        CHAT   => "/etc/sysconfig/network-scripts/chat-#iface#",
  2599.        IFACE  => "#iface#",
  2600.        WVDIAL => "/etc/wvdial.conf",
  2601.        PUMP   => "/etc/pump.conf"
  2602.      },
  2603.      table =>
  2604.      [
  2605.       [ "bootproto",          \&set_rh_bootproto, IFCFG, BOOTPROTO ],
  2606.       [ "auto",               \&Utils::Replace::set_sh_bool, IFCFG, ONBOOT ],
  2607.       [ "dev",                \&Utils::Replace::set_sh,      IFCFG, NAME ],
  2608.       [ "dev",                \&Utils::Replace::set_sh,      IFCFG, DEVICE ],
  2609.       [ "address",            \&Utils::Replace::set_sh,      IFCFG, IPADDR ],
  2610.       [ "netmask",            \&Utils::Replace::set_sh,      IFCFG, NETMASK ],
  2611.       [ "broadcast",          \&Utils::Replace::set_sh,      IFCFG, BROADCAST ],
  2612.       [ "network",            \&Utils::Replace::set_sh,      IFCFG, NETWORK ],
  2613.       [ "gateway",            \&Utils::Replace::set_sh,      IFCFG, GATEWAY ],
  2614.       [ "essid",              \&Utils::Replace::set_sh,      IFCFG, WIRELESS_ESSID ],
  2615.       [ "key",                \&Utils::Replace::set_sh,      IFCFG, WIRELESS_KEY   ],
  2616.       [ "key_type",           \&set_wep_key_full, [ \&Utils::Replace::set_sh, IFCFG, WIRELESS_KEY, "%key%" ]],
  2617.       [ "update_dns",         \&Utils::Replace::set_sh_bool, IFCFG, PEERDNS ],
  2618.       [ "remote_address",     \&Utils::Replace::set_sh,      IFCFG, REMIP ],
  2619.       [ "login",              \&Utils::Replace::set_sh,      IFCFG, PAPNAME ],
  2620.       [ "serial_port",        \&Utils::Replace::set_sh,      IFCFG, MODEMPORT ],
  2621.       [ "section",            \&Utils::Replace::set_sh,      IFCFG, WVDIALSECT ],
  2622.       [ "set_default_gw",     \&Utils::Replace::set_sh_bool, IFCFG, DEFROUTE ],
  2623.       [ "persist",            \&Utils::Replace::set_sh_bool, IFCFG, PERSIST ],
  2624.       [ "phone_number",       \&Utils::Replace::set_chat,    CHAT,  "^atd[^0-9]*([0-9, -]+)" ],
  2625. #      [ "update_dns",         \&gst_network_pump_set_nodns, PUMP, "%dev%", "%bootproto%" ],
  2626. #      [ "dns1",               \&Utils::Replace::set_sh,      IFCFG, DNS1 ],
  2627. #      [ "dns2",               \&Utils::Replace::set_sh,      IFCFG, DNS2 ],
  2628. #      [ "mtu",                \&Utils::Replace::set_sh,      IFCFG, MTU ],
  2629. #      [ "mru",                \&Utils::Replace::set_sh,      IFCFG, MRU ],
  2630. #      [ "serial_speed",       \&Utils::Replace::set_sh,      IFCFG, LINESPEED ],
  2631. #      [ "ppp_options",        \&Utils::Replace::set_sh,      IFCFG, PPPOPTIONS ],
  2632. #      [ "debug",              \&Utils::Replace::set_sh_bool, IFCFG, DEBUG ],
  2633. #      [ "serial_escapechars", \&Utils::Replace::set_sh_bool, IFCFG, ESCAPECHARS ],
  2634. #      [ "serial_hwctl",       \&Utils::Replace::set_sh_bool, IFCFG, HARDFLOWCTL ],
  2635.       # wvdial settings
  2636.       [ "phone_number",       \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Phone" ]],
  2637.       [ "update_dns",         \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Auto DNS" ]],
  2638.       [ "login",              \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Username" ]],
  2639.       [ "password",           \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Password" ]],
  2640.       [ "serial_port",        \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Modem" ]],
  2641.       [ "serial_speed",       \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Baud" ]],
  2642.       [ "set_default_gw",     \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Check Def Route" ]],
  2643.       [ "persist",            \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Auto Reconnect" ]],
  2644.       [ "dial_command",       \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Dial Command" ]],
  2645.       [ "external_line",      \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Dial Prefix" ]],
  2646.      ]
  2647.    },
  2648.  
  2649.    "conectiva-9" =>
  2650.    {
  2651.      iface_set    => \&activate_interface,
  2652.      iface_delete => \&delete_rh62_interface,
  2653.      fn =>
  2654.      {
  2655.        IFCFG  => "/etc/sysconfig/network-scripts/ifcfg-#iface#",
  2656.        CHAT   => "/etc/sysconfig/network-scripts/chat-#iface#",
  2657.        IFACE  => "#iface#",
  2658.        WVDIAL => "/etc/wvdial.conf",
  2659.        PUMP   => "/etc/pump.conf"
  2660.      },
  2661.      table =>
  2662.      [
  2663.       [ "bootproto",          \&set_rh_bootproto, IFCFG, BOOTPROTO ],
  2664.       [ "auto",               \&Utils::Replace::set_sh_bool, IFCFG, ONBOOT ],
  2665.       [ "dev" ,               \&Utils::Replace::set_sh,      IFCFG, NAME ],
  2666.       [ "dev",                \&Utils::Replace::set_sh,      IFCFG, DEVICE ],
  2667.       [ "address",            \&Utils::Replace::set_sh,      IFCFG, IPADDR ],
  2668.       [ "netmask",            \&Utils::Replace::set_sh,      IFCFG, NETMASK ],
  2669.       [ "broadcast",          \&Utils::Replace::set_sh,      IFCFG, BROADCAST ],
  2670.       [ "network",            \&Utils::Replace::set_sh,      IFCFG, NETWORK ],
  2671.       [ "gateway",            \&Utils::Replace::set_sh,      IFCFG, GATEWAY ],
  2672.       [ "essid",              \&Utils::Replace::set_sh,      IFCFG, WIRELESS_ESSID ],
  2673.       [ "key",                \&Utils::Replace::set_sh,      IFCFG, WIRELESS_KEY ],
  2674.       [ "key_type",           \&set_wep_key_full, [ \&Utils::Replace::set_sh, IFCFG, WIRELESS_KEY, "%key%" ]],
  2675.       [ "update_dns",         \&Utils::Replace::set_sh_bool, IFCFG, PEERDNS ],
  2676.       [ "remote_address",     \&Utils::Replace::set_sh,      IFCFG, REMIP ],
  2677.       [ "login",              \&Utils::Replace::set_sh,      IFCFG, PAPNAME ],
  2678.       [ "serial_port",        \&Utils::Replace::set_sh,      IFCFG, MODEMPORT ],
  2679.       [ "section",            \&Utils::Replace::set_sh,      IFCFG, WVDIALSECT ],
  2680.       [ "set_default_gw",     \&Utils::Replace::set_sh_bool, IFCFG, DEFROUTE ],
  2681.       [ "persist",            \&Utils::Replace::set_sh_bool, IFCFG, PERSIST ],
  2682.       [ "phone_number",       \&Utils::Replace::set_chat,    CHAT,  "^atd[^0-9]*([0-9, -]+)" ],
  2683. #      [ "update_dns",         \&gst_network_pump_set_nodns, PUMP, "%dev%", "%bootproto%" ],
  2684. #      [ "dns1",               \&Utils::Replace::set_sh,      IFCFG, DNS1 ],
  2685. #      [ "dns2",               \&Utils::Replace::set_sh,      IFCFG, DNS2 ],
  2686. #      [ "mtu",                \&Utils::Replace::set_sh,      IFCFG, MTU ],
  2687. #      [ "mru",                \&Utils::Replace::set_sh,      IFCFG, MRU ],
  2688. #      [ "serial_speed",       \&Utils::Replace::set_sh,      IFCFG, LINESPEED ],
  2689. #      [ "ppp_options",        \&Utils::Replace::set_sh,      IFCFG, PPPOPTIONS ],
  2690. #      [ "debug",              \&Utils::Replace::set_sh_bool, IFCFG, DEBUG ],
  2691. #      [ "serial_escapechars", \&Utils::Replace::set_sh_bool, IFCFG, ESCAPECHARS ],
  2692. #      [ "serial_hwctl",       \&Utils::Replace::set_sh_bool, IFCFG, HARDFLOWCTL ],
  2693.       # wvdial settings
  2694.       [ "phone_number",       \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Phone" ]],
  2695.       [ "update_dns",         \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Auto DNS" ]],
  2696.       [ "login",              \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Username" ]],
  2697.       [ "password",           \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Password" ]],
  2698.       [ "serial_port",        \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Modem" ]],
  2699.       [ "serial_speed",       \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Baud" ]],
  2700.       [ "set_default_gw",     \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Check Def Route" ]],
  2701.       [ "persist",            \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Auto Reconnect" ]],
  2702.       [ "dial_command",       \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Dial Command" ]],
  2703.       [ "external_line",      \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Dial Prefix" ]],
  2704.      ]
  2705.    },
  2706.  
  2707.    "debian-3.0" =>
  2708.    {
  2709.      iface_set    => \&activate_interface,
  2710.      iface_delete => \&delete_debian_interface,
  2711.      fn =>
  2712.      {
  2713.        INTERFACES  => "/etc/network/interfaces",
  2714.        IFACE       => "#iface#",
  2715.        CHAT        => "/etc/chatscripts/%section%",
  2716.        PPP_OPTIONS => "/etc/ppp/peers/%section%",
  2717.        PAP         => "/etc/ppp/pap-secrets",
  2718.        CHAP        => "/etc/ppp/chap-secrets",
  2719.      },
  2720.      table =>
  2721.      [
  2722.       [ "_always_",           \&set_debian_bootproto, [INTERFACES, IFACE]],
  2723.       [ "bootproto",          \&set_debian_bootproto, [INTERFACES, IFACE]],
  2724.       [ "auto",               \&set_debian_auto,      [INTERFACES, IFACE]],
  2725.       [ "address",            \&Utils::Replace::set_interfaces_option_str, [INTERFACES, IFACE], "address" ],
  2726.       [ "netmask",            \&Utils::Replace::set_interfaces_option_str, [INTERFACES, IFACE], "netmask" ],
  2727.       [ "gateway",            \&Utils::Replace::set_interfaces_option_str, [INTERFACES, IFACE], "gateway" ],
  2728.       [ "essid",              \&Utils::Replace::set_interfaces_option_str, [INTERFACES, IFACE], "wireless-essid" ],
  2729.       [ "key",                \&Utils::Replace::set_interfaces_option_str, [INTERFACES, IFACE], "wireless-key"   ],
  2730.       [ "key_type",           \&set_wep_key_full, [ \&Utils::Replace::set_interfaces_option_str, INTERFACES, IFACE, "wireless-key", "%key%" ]],
  2731.       # ugly hack for deleting undesired options (due to syntax duality)
  2732.       [ "essid",              \&Utils::Replace::set_interfaces_option_str, [INTERFACES, IFACE], "wireless_essid", "" ],
  2733.       [ "key",                \&Utils::Replace::set_interfaces_option_str, [INTERFACES, IFACE], "wireless_key", ""   ],
  2734.       [ "key",                \&Utils::Replace::set_interfaces_option_str, [INTERFACES, IFACE], "wireless_key1", ""   ],
  2735.       # End of hack
  2736.       [ "section",            \&Utils::Replace::set_interfaces_option_str, [INTERFACES, IFACE], "provider" ],
  2737.       [ "remote_address",     \&set_debian_remote_address, [INTERFACES, IFACE]],
  2738.       # Modem stuff
  2739.       [ "section",            \&check_type, [IFACE, "modem", \&Utils::Replace::set_ppp_options_connect, PPP_OPTIONS ]],
  2740.       [ "phone_number",       \&check_type, [IFACE, "modem", \&create_pppscript, CHAT ]],
  2741.       [ "phone_number",       \&check_type, [IFACE, "isdn", \&create_isdn_options, PPP_OPTIONS ]],
  2742.       [ "update_dns",         \&check_type, [IFACE, "(modem|isdn)", \&Utils::Replace::set_kw, PPP_OPTIONS, "usepeerdns" ]],
  2743.       [ "noauth",             \&check_type, [IFACE, "(modem|isdn)", \&Utils::Replace::set_kw, PPP_OPTIONS, "noauth" ]],
  2744.       [ "set_default_gw",     \&check_type, [IFACE, "(modem|isdn)", \&Utils::Replace::set_kw, PPP_OPTIONS, "defaultroute" ]],
  2745.       [ "persist",            \&check_type, [IFACE, "(modem|isdn)", \&Utils::Replace::set_kw, PPP_OPTIONS, "persist" ]],
  2746.       [ "serial_port",        \&check_type, [IFACE, "modem", \&Utils::Replace::set_ppp_options_re, PPP_OPTIONS, "^(/dev/[^ \t]+)" ]],
  2747.       [ "serial_speed",       \&check_type, [IFACE, "modem", \&Utils::Replace::set_ppp_options_re, PPP_OPTIONS, "^([0-9]+)" ]],
  2748.       [ "login",              \&check_type, [IFACE, "(modem|isdn)", \&Utils::Replace::set_ppp_options_re, PPP_OPTIONS, "^user (.*)", "user \"%login%\"" ]],
  2749.       [ "password",           \&check_type, [IFACE, "(modem|isdn)", \&set_pap_passwd, PAP, "%login%" ]],
  2750.       [ "password",           \&check_type, [IFACE, "(modem|isdn)", \&set_pap_passwd, CHAP, "%login%" ]],
  2751.       [ "dial_command",       \&check_type, [IFACE, "modem", \&Utils::Replace::set_chat, CHAT, "(atd[tp])[0-9w, -]+" ]],
  2752.       [ "phone_number",       \&check_type, [IFACE, "modem", \&Utils::Replace::set_chat, CHAT, "atd[tp]([0-9w]+)" ]],
  2753.       [ "external_line",      \&check_type, [IFACE, "modem", \&Utils::Replace::set_chat, CHAT, "atd[tp]([0-9w, -]+)", "%external_line%W%phone_number%" ]],
  2754.       [ "phone_number",       \&check_type, [IFACE, "isdn", \&Utils::Replace::set_ppp_options_re, PPP_OPTIONS, "^number (.*)", "number %phone_number%" ]],
  2755.       [ "external_line",      \&check_type, [IFACE, "isdn", \&Utils::Replace::set_ppp_options_re, PPP_OPTIONS, "^number (.*)", "number %external_line%W%phone_number%" ]],
  2756.       [ "volume",             \&check_type, [IFACE, "modem", \&set_modem_volume, CHAT ]],
  2757. #      [ "serial_escapechars", \&check_type, [IFACE, "modem", \&Utils::Replace::join_first_str, PPP_OPTIONS, "escape", "[ \t]+" ]],
  2758. #      [ "debug",              \&check_type, [IFACE, "(modem|isdn)", \&Utils::Replace::set_kw, PPP_OPTIONS, "debug" ]],
  2759. #      [ "serial_hwctl",       \&check_type, [IFACE, "modem", \&Utils::Replace::set_kw, PPP_OPTIONS, "crtscts" ]],
  2760. #      [ "mtu",                \&check_type, [IFACE, "(modem|isdn)", \&Utils::Replace::join_first_str, PPP_OPTIONS, "mtu", "[ \t]+" ]],
  2761. #      [ "mru",                \&check_type, [IFACE, "(modem|isdn)", \&Utils::Replace::join_first_str, PPP_OPTIONS, "mru", "[ \t]+" ]],
  2762.      ]
  2763.    },
  2764.  
  2765.    "suse-9.0" =>
  2766.    {
  2767.      iface_set    => \&activate_suse_interface,
  2768.      iface_delete => \&delete_suse_interface,
  2769.      fn =>
  2770.      {
  2771.        IFCFG       => "/etc/sysconfig/network/ifcfg-#iface#",
  2772.        PROVIDERS   => "/etc/sysconfig/network/providers/%section%",
  2773.        ROUTE_CONF  => "/etc/sysconfig/network/routes",
  2774.        IFACE       => "#iface#",
  2775.        PPP_OPTIONS => "/etc/ppp/options"
  2776.      },
  2777.      table =>
  2778.      [
  2779.       [ "auto",           \&set_suse_auto,          IFCFG, STARTMODE ],
  2780.       [ "bootproto",      \&set_suse_bootproto,     IFCFG, BOOTPROTO ],
  2781.       [ "address",        \&Utils::Replace::set_sh, IFCFG, IPADDR ], 
  2782.       [ "netmask",        \&Utils::Replace::set_sh, IFCFG, NETMASK ],
  2783.       [ "remote_address", \&Utils::Replace::set_sh, IFCFG, REMOTE_IPADDR ],
  2784.       [ "essid",          \&Utils::Replace::set_sh, IFCFG, WIRELESS_ESSID ],
  2785.       [ "key",            \&Utils::Replace::set_sh, IFCFG, WIRELESS_KEY ],
  2786.       [ "key_type",       \&set_wep_key_full, [ \&Utils::Replace::set_sh, IFCFG, WIRELESS_KEY, "%key%" ]],
  2787.       # Modem stuff goes here
  2788.       [ "serial_port",    \&Utils::Replace::set_sh, IFCFG, MODEM_DEVICE ],
  2789.       [ "ppp_options",    \&Utils::Replace::set_sh, IFCFG, PPPD_OPTIONS ],
  2790.       [ "dial_command",   \&Utils::Replace::set_sh, IFCFG, DIALCOMMAND],
  2791.       [ "external_line",  \&Utils::Replace::set_sh, IFCFG, DIALPREFIX],
  2792.       [ "provider",       \&Utils::Replace::set_sh, IFCFG, PROVIDER ],
  2793.       [ "volume",         \&check_type, [ IFACE, "modem", \&set_modem_volume_sh, IFCFG, INIT8 ]],
  2794.       [ "login",          \&Utils::Replace::set_sh, PROVIDERS, USERNAME ],
  2795.       [ "password",       \&Utils::Replace::set_sh, PROVIDERS, PASSWORD ],
  2796.       [ "phone_number",   \&Utils::Replace::set_sh, PROVIDERS, PHONE ],
  2797.       [ "update_dns",     \&Utils::Replace::set_sh_bool, PROVIDERS, MODIFYDNS ],
  2798.       [ "persist",        \&Utils::Replace::set_sh_bool, PROVIDERS, PERSIST ],
  2799.       [ "set_default_gw", \&Utils::Replace::set_sh_bool, PROVIDERS, DEFAULTROUTE ],
  2800. #      [ "serial_speed",       \&Utils::Replace::set_sh,                        IFCFG,    SPEED        ],
  2801. #      [ "mtu",                \&Utils::Replace::set_sh,                        IFCFG,    MTU          ],
  2802. #      [ "mru",                \&Utils::Replace::set_sh,                        IFCFG,    MRU          ],
  2803. #      [ "dns1",               \&Utils::Replace::set_sh,                        PROVIDER, DNS1         ],
  2804. #      [ "dns2",               \&Utils::Replace::set_sh,                        PROVIDER, DNS2         ],
  2805. #      [ "stupid",             \&Utils::Replace::set_sh_bool,                   PROVIDER, STUPIDMODE   ],
  2806.      ]
  2807.    },
  2808.  
  2809.    "pld-1.0" =>
  2810.    {
  2811.      iface_set    => \&activate_interface,
  2812.      iface_delete => \&delete_pld_interface,
  2813.      fn =>
  2814.      {
  2815.        IFCFG  => "/etc/sysconfig/interfaces/ifcfg-#iface#",
  2816.        CHAT   => "/etc/sysconfig/interfaces/data/chat-#iface#",
  2817.        IFACE  => "#iface#",
  2818.        WVDIAL => "/etc/wvdial.conf",
  2819.        PUMP   => "/etc/pump.conf"
  2820.      },
  2821.      table =>
  2822.      [
  2823.       [ "bootproto",          \&set_rh_bootproto, IFCFG, BOOTPROTO ],
  2824.       [ "auto",               \&Utils::Replace::set_sh_bool, IFCFG, ONBOOT ],
  2825.       [ "dev",                \&Utils::Replace::set_sh,      IFCFG, DEVICE ],
  2826.       [ "address",            \&set_pld_ipaddr, IFCFG, IPADDR, "address" ],
  2827.       [ "netmask",            \&set_pld_ipaddr, IFCFG, IPADDR, "netmask" ],
  2828.       [ "gateway",            \&Utils::Replace::set_sh,      IFCFG, GATEWAY ],
  2829.       [ "update_dns",         \&Utils::Replace::set_sh_bool, IFCFG, PEERDNS ],
  2830.       [ "remote_address",     \&Utils::Replace::set_sh,      IFCFG, REMIP ],
  2831.       [ "login",              \&Utils::Replace::set_sh,      IFCFG, PAPNAME ],
  2832.       [ "serial_port",        \&Utils::Replace::set_sh,      IFCFG, MODEMPORT ],
  2833.       [ "ppp_options",        \&Utils::Replace::set_sh,      IFCFG, PPPOPTIONS ],
  2834.       [ "set_default_gw",     \&Utils::Replace::set_sh_bool, IFCFG, DEFROUTE ],
  2835.       [ "persist",            \&Utils::Replace::set_sh_bool, IFCFG, PERSIST ],
  2836.       [ "phone_number",       \&Utils::Replace::set_chat,    CHAT,  "^atd[^0-9]*([0-9, -]+)" ]
  2837. #      [ "name",               \&Utils::Replace::set_sh,      IFCFG, NAME ],
  2838. #      [ "broadcast",          \&Utils::Replace::set_sh,      IFCFG, BROADCAST ],
  2839. #      [ "network",            \&Utils::Replace::set_sh,      IFCFG, NETWORK ],
  2840. #      [ "update_dns",         \&gst_network_pump_set_nodns, PUMP, "%dev%", "%bootproto%" ],
  2841. #      [ "dns1",               \&Utils::Replace::set_sh,      IFCFG, DNS1 ],
  2842. #      [ "dns2",               \&Utils::Replace::set_sh,      IFCFG, DNS2 ],
  2843. #      [ "mtu",                \&Utils::Replace::set_sh,      IFCFG, MTU ],
  2844. #      [ "mru",                \&Utils::Replace::set_sh,      IFCFG, MRU ],
  2845. #      [ "serial_speed",       \&Utils::Replace::set_sh,      IFCFG, LINESPEED ],
  2846. #      [ "section",            \&Utils::Replace::set_sh,      IFCFG, WVDIALSECT ],
  2847. #      [ "debug",              \&Utils::Replace::set_sh_bool, IFCFG, DEBUG ],
  2848. #      [ "serial_escapechars", \&Utils::Replace::set_sh_bool, IFCFG, ESCAPECHARS ],
  2849. #      [ "serial_hwctl",       \&Utils::Replace::set_sh_bool, IFCFG, HARDFLOWCTL ],
  2850.      ]
  2851.    },
  2852.  
  2853.    "slackware-9.1.0" =>
  2854.    {
  2855.      iface_set    => \&activate_slackware_interface,
  2856.      iface_delete => \&delete_slackware_interface,
  2857.      fn =>
  2858.      {
  2859.        RC_INET_CONF => "/etc/rc.d/rc.inet1.conf",
  2860.        RC_INET      => "/etc/rc.d/rc.inet1",
  2861.        RC_LOCAL     => "/etc/rc.d/rc.local",
  2862.        IFACE        => "#iface#",
  2863.        WIRELESS     => "/etc/pcmcia/wireless.opts",
  2864.        PPP_OPTIONS  => "/etc/ppp/options",
  2865.        PAP          => "/etc/ppp/pap-secrets",
  2866.        CHAP         => "/etc/ppp/chap-secrets",
  2867.        CHAT         => "/etc/ppp/pppscript",
  2868.      },
  2869.      table =>
  2870.      [
  2871.       [ "address",            \&Utils::Replace::set_rcinet1conf,   [ RC_INET_CONF, IFACE ], IPADDR ],
  2872.       [ "netmask",            \&Utils::Replace::set_rcinet1conf,   [ RC_INET_CONF, IFACE ], NETMASK ],
  2873.       [ "bootproto",          \&set_slackware_bootproto, [ RC_INET_CONF, IFACE ] ],
  2874.       [ "auto",               \&set_slackware_auto, [ RC_INET, RC_LOCAL, IFACE ] ],
  2875.       [ "essid",              \&Utils::Replace::set_wireless_opts, [ WIRELESS, IFACE ], \&get_wireless_ifaces, ESSID ],
  2876.       [ "key",                \&Utils::Replace::set_wireless_opts, [ WIRELESS, IFACE ], \&get_wireless_ifaces, KEY   ],
  2877.       [ "key_type",           \&set_wep_key_full, [ \&Utils::Replace::set_wireless_opts, [ WIRELESS, IFACE ], \&get_wireless_ifaces, KEY, "%key%" ]],
  2878.       # Modem stuff
  2879.       [ "phone_number",       \&check_type, [IFACE, "modem", \&create_pppscript, CHAT ]],
  2880.       [ "phone_number",       \&check_type, [IFACE, "modem", \&create_pppgo ]],
  2881.       [ "update_dns",         \&check_type, [IFACE, "modem", \&Utils::Replace::set_kw, PPP_OPTIONS, "usepeerdns" ]],
  2882.       [ "noauth",             \&check_type, [IFACE, "modem", \&Utils::Replace::set_kw, PPP_OPTIONS, "noauth" ]],
  2883.       [ "set_default_gw",     \&check_type, [IFACE, "modem", \&Utils::Replace::set_kw, PPP_OPTIONS, "defaultroute" ]],
  2884.       [ "debug",              \&check_type, [IFACE, "modem", \&Utils::Replace::set_kw, PPP_OPTIONS, "debug" ]],
  2885.       [ "persist",            \&check_type, [IFACE, "modem", \&Utils::Replace::set_kw, PPP_OPTIONS, "persist" ]],
  2886.       [ "serial_hwctl",       \&check_type, [IFACE, "modem", \&Utils::Replace::set_kw, PPP_OPTIONS, "crtscts" ]],
  2887.       [ "mtu",                \&check_type, [IFACE, "modem", \&Utils::Replace::join_first_str, PPP_OPTIONS, "mtu", "[ \t]+" ]],
  2888.       [ "mru",                \&check_type, [IFACE, "modem", \&Utils::Replace::join_first_str, PPP_OPTIONS, "mru", "[ \t]+" ]],
  2889.       [ "serial_port",        \&check_type, [IFACE, "modem", \&Utils::Replace::set_ppp_options_re, PPP_OPTIONS, "^(/dev/[^ \t]+)" ]],
  2890.       [ "serial_speed",       \&check_type, [IFACE, "modem", \&Utils::Replace::set_ppp_options_re, PPP_OPTIONS, "^([0-9]+)" ]],
  2891.       [ "login",              \&check_type, [IFACE, "modem", \&Utils::Replace::set_ppp_options_re, PPP_OPTIONS, "^name \"(.*)\"", "name \"%login%\"" ]],
  2892.       [ "serial_escapechars", \&check_type, [IFACE, "modem", \&Utils::Replace::join_first_str, PPP_OPTIONS, "escape", "[ \t]+" ]],
  2893.       [ "password",           \&check_type, [IFACE, "modem", \&set_pap_passwd, PAP, "%login%" ]],
  2894.       [ "password",           \&check_type, [IFACE, "modem", \&set_pap_passwd, CHAP, "%login%" ]],
  2895.       [ "dial_command",       \&check_type, [IFACE, "modem", \&Utils::Replace::set_chat, CHAT, "(atd[tp])[0-9w, -]+" ]],
  2896.       [ "phone_number",       \&check_type, [IFACE, "modem", \&Utils::Replace::set_chat, CHAT, "atd[tp]([0-9w]+)" ]],
  2897.       [ "external_line",      \&check_type, [IFACE, "modem", \&Utils::Replace::set_chat, CHAT, "atd[tp]([0-9w, -]+)", "%external_line%W%phone_number%" ]],
  2898.       [ "volume",             \&check_type, [IFACE, "modem", \&set_modem_volume, CHAT ]],
  2899.       #[ "ppp_options",        \&check_type, [IFACE, "modem", \&gst_network_set_ppp_options_unsup, PPP_OPTIONS ]],
  2900.      ]
  2901.    },
  2902.  
  2903.    "gentoo" =>
  2904.    {
  2905.      iface_set    => \&activate_gentoo_interface,
  2906.      iface_delete => \&delete_gentoo_interface,
  2907.      fn =>
  2908.      {
  2909.        NET          => "/etc/conf.d/net",
  2910.        PPPNET       => "/etc/conf.d/net.#iface#",
  2911.        INIT         => "net.#iface#",
  2912.        IFACE        => "#iface#",
  2913.        WIRELESS     => "/etc/conf.d/wireless",
  2914.      },
  2915.      table =>
  2916.      [
  2917.       [ "dev",                \&create_gentoo_files ],
  2918.       [ "auto",               \&set_gentoo_service_status, INIT, "default" ],
  2919.       [ "bootproto",          \&set_gentoo_bootproto, [ NET, IFACE ]],
  2920.       [ "address",            \&Utils::Replace::set_confd_net_re, NET, "config_%dev%", "^[ \t]*([0-9\.]+)" ],
  2921.       [ "netmask",            \&Utils::Replace::set_confd_net_re, NET, "config_%dev%", "[ \t]+netmask[ \t]+[0-9\.]*", " netmask %netmask%"],
  2922.       [ "broadcast",          \&Utils::Replace::set_confd_net_re, NET, "config_%dev%", "[ \t]+broadcast[ \t]+[0-9\.]*", " broadcast %broadcast%" ],
  2923.       [ "remote_address",     \&Utils::Replace::set_confd_net_re, NET, "config_%dev%", "[ \t]+dest_address[ \t]+[0-9\.]*", " dest_address %remote_address%" ],
  2924.       # [ "gateway",            \&Utils::Replace::set_confd_net_re, NET, "routes_%dev%", "[ \t]*default[ \t]+(via|gw)[ \t]+[0-9\.\:]*", "default via %gateway%" ],
  2925.       [ "essid",              \&Utils::Replace::set_sh,           WIRELESS, "essid_%dev%" ],
  2926.       [ "key",                \&Utils::Replace::set_sh,           WIRELESS, "key_%essid%" ],
  2927.       [ "key_type",           \&set_wep_key_type,                 [ \&Utils::Replace::set_sh, WIRELESS, "key_%essid%", "%key%" ]],
  2928.       # modem stuff
  2929.       [ "dev",                \&check_type, [ IFACE, "modem", \&Utils::Replace::set_sh, PPPNET, PEER ]],
  2930.       [ "update_dns",         \&check_type, [ IFACE, "modem", \&Utils::Replace::set_sh_bool, PPPNET, PEERDNS ]],
  2931.       [ "mtu",                \&Utils::Replace::set_sh,                       PPPNET, MTU ],
  2932.       [ "mru",                \&Utils::Replace::set_sh,                       PPPNET, MRU ],
  2933.       [ "serial_port",        \&Utils::Replace::set_sh,                       PPPNET, MODEMPORT ],
  2934.       [ "serial_speed",       \&Utils::Replace::set_sh,                       PPPNET, LINESPEED ],
  2935.       [ "login",              \&Utils::Replace::set_sh,                       PPPNET, USERNAME ],
  2936.       [ "password",           \&Utils::Replace::set_sh,                       PPPNET, PASSWORD ],
  2937.       [ "ppp_options",        \&Utils::Replace::set_sh,                       PPPNET, PPPOPTIONS ],
  2938.       [ "set_default_gw",     \&Utils::Replace::set_sh_bool,                  PPPNET, DEFROUTE ],
  2939.       [ "debug",              \&Utils::Replace::set_sh_bool,                  PPPNET, DEBUG ],
  2940.       [ "persist",            \&Utils::Replace::set_sh_bool,                  PPPNET, PERSIST ],
  2941.       [ "serial_escapechars", \&Utils::Replace::set_sh_bool,                  PPPNET, ESCAPECHARS ],
  2942.       [ "serial_hwctl",       \&Utils::Replace::set_sh_bool,                  PPPNET, HARDFLOWCTL ],
  2943.       [ "phone_number",       \&Utils::Replace::set_sh,                       PPPNET, NUMBER ],
  2944.       [ "external_line",      \&Utils::Replace::set_sh,                       PPPNET, NUMBER, "%external_line%W%phone_number%" ],
  2945.       [ "volume",             \&set_modem_volume_sh,  PPPNET, INITSTRING ],
  2946.      ]
  2947.     },
  2948.  
  2949.     "freebsd-5" =>
  2950.     {
  2951.       iface_set    => \&activate_freebsd_interface,
  2952.       iface_delete => \&delete_freebsd_interface,
  2953.       fn =>
  2954.       {
  2955.         RC_CONF => "/etc/rc.conf",
  2956.         STARTIF => "/etc/start_if.#iface#",
  2957.         PPPCONF => "/etc/ppp/ppp.conf",
  2958.         IFACE   => "#iface#",
  2959.       },
  2960.       table =>
  2961.       [
  2962.        [ "auto",           \&set_freebsd_auto,      [ RC_CONF, IFACE ]],
  2963.        [ "bootproto",      \&set_freebsd_bootproto, [ RC_CONF, IFACE ]],
  2964.        [ "address",        \&Utils::Replace::set_sh_re,    RC_CONF, "ifconfig_%dev%", "inet[ \t]+([0-9\.]+)", "inet %address%" ],
  2965.        [ "netmask",        \&Utils::Replace::set_sh_re,    RC_CONF, "ifconfig_%dev%", "netmask[ \t]+([0-9\.]+)", " netmask %netmask%" ],
  2966.        [ "remote_address", \&Utils::Replace::set_sh_re,    RC_CONF, "ifconfig_%dev%", "dest_address[ \t]+([0-9\.]+)", " dest_address %remote_address%" ],
  2967.        [ "essid",          \&set_freebsd_essid,     [ RC_CONF, STARTIF, IFACE ]],
  2968.        # Modem stuff
  2969.        # we need this for putting an empty ifconfig_tunX command in rc.conf
  2970.        [ "phone_number",   \&Utils::Replace::set_sh,                         RC_CONF, "ifconfig_%dev%", " " ],
  2971.        [ "file",           \&create_ppp_startif, [ STARTIF, IFACE ]],
  2972.        [ "persist",        \&create_ppp_startif, [ STARTIF, IFACE ], "%file%" ],
  2973.        [ "serial_port",    \&Utils::Replace::set_pppconf,            [ PPPCONF, STARTIF, IFACE ], "device" ],
  2974.        [ "serial_speed",   \&Utils::Replace::set_pppconf,            [ PPPCONF, STARTIF, IFACE ], "speed"    ],
  2975.        [ "mtu",            \&Utils::Replace::set_pppconf,            [ PPPCONF, STARTIF, IFACE ], "mtu"      ],
  2976.        [ "mru",            \&Utils::Replace::set_pppconf,            [ PPPCONF, STARTIF, IFACE ], "mru"      ],
  2977.        [ "login",          \&Utils::Replace::set_pppconf,            [ PPPCONF, STARTIF, IFACE ], "authname" ],
  2978.        [ "password",       \&Utils::Replace::set_pppconf,            [ PPPCONF, STARTIF, IFACE ], "authkey"  ],
  2979.        [ "update_dns",     \&Utils::Replace::set_pppconf_bool,       [ PPPCONF, STARTIF, IFACE ], "dns"      ],
  2980.        [ "set_default_gw", \&set_pppconf_route, [ PPPCONF, STARTIF, IFACE ], "default HISADDR" ],
  2981.        [ "phone_number",   \&Utils::Replace::set_pppconf,            [ PPPCONF, STARTIF, IFACE ], "phone"    ],
  2982.        [ "external_line",  \&Utils::Replace::set_pppconf,            [ PPPCONF, STARTIF, IFACE ], "phone", "%external_line%W%phone_number%" ],
  2983.        [ "dial_command",   \&set_pppconf_dial_command, [ PPPCONF, STARTIF, IFACE ]],
  2984.        [ "volume",         \&set_pppconf_volume,       [ PPPCONF, STARTIF, IFACE ]],
  2985.       ]
  2986.     }
  2987.   );
  2988.   
  2989.   my $dist = &get_interface_dist ();
  2990.   return %{$dist_tables{$dist}} if $dist;
  2991.  
  2992.   &Utils::Report::do_report ("platform_no_table", $Utils::Backend::tool{"platform"});
  2993.   return undef;
  2994. }
  2995.  
  2996. sub add_dialup_iface
  2997. {
  2998.   my ($ifaces) = @_;
  2999.   my ($dev, $i);
  3000.  
  3001.   $dev = "ppp0" if ($Utils::Backend::tool{"system"} eq "Linux");
  3002.   $dev = "tun0" if ($Utils::Backend::tool{"system"} eq "FreeBSD");
  3003.  
  3004.   foreach $i (@$ifaces)
  3005.   {
  3006.     return if ($i eq $dev);
  3007.   }
  3008.  
  3009.   push @$ifaces, $dev if (&Utils::File::locate_tool ("pppd"));
  3010. }
  3011.  
  3012. sub get_interfaces_config
  3013. {
  3014.   my (%dist_attrib, %config_hash, %hash, %fn);
  3015.   my (@config_ifaces, @ifaces, $iface, $dev);
  3016.   my ($dist, $value, $file, $proc);
  3017.   my ($i, $j);
  3018.   my ($modem_settings);
  3019.  
  3020.   %hash = &get_interfaces_info ();
  3021.   %dist_attrib = &get_interface_parse_table ();
  3022.   %fn = %{$dist_attrib{"fn"}};
  3023.   $proc = $dist_attrib{"ifaces_get"};
  3024.  
  3025.   # FIXME: is proc necessary? why not using hash keys?
  3026.   if ($proc)
  3027.   {
  3028.     @ifaces = &$proc ();
  3029.   }
  3030.   else
  3031.   {
  3032.     @ifaces = keys %hash;
  3033.   }
  3034.  
  3035.   &add_dialup_iface (\@ifaces);
  3036.  
  3037.   # clear unneeded hash elements
  3038.   foreach $i (@ifaces)
  3039.   {
  3040.     foreach $j (keys (%fn))
  3041.     {
  3042.       ${$dist_attrib{"fn"}}{$j} = &Utils::Parse::expand ($fn{$j},
  3043.                                                          "iface", $i,
  3044.                                                          "type",  &get_interface_type ($i));
  3045.     }
  3046.  
  3047.     $iface = &Utils::Parse::get_from_table ($dist_attrib{"fn"},
  3048.                                             $dist_attrib{"table"});
  3049.  
  3050.     &ensure_iface_broadcast_and_network ($iface);
  3051.     $$iface{"file"} = $i if ($$iface{"file"} eq undef);
  3052.  
  3053.     if (exists $hash{$i})
  3054.     {
  3055.       foreach $k (keys %$iface)
  3056.       {
  3057.         $hash{$i}{$k} = $$iface{$k};
  3058.       }
  3059.     }
  3060.     elsif (($i eq "ppp0") || ($dev eq "tun0"))
  3061.     {
  3062.       $hash{$i}{"dev"} = $i;
  3063.       $hash{$i}{"enabled"} = 0;
  3064.  
  3065.       foreach $k (keys %$iface)
  3066.       {
  3067.         $hash{$i}{$k} = $$iface{$k};
  3068.       }
  3069.     }
  3070.   }
  3071.  
  3072.   return \%hash;
  3073. }
  3074.  
  3075. sub interface_configured
  3076. {
  3077.   my ($iface) = @_;
  3078.   my ($type);
  3079.  
  3080.   # FIXME: checking for "configuration" key is much better
  3081.   $type = &get_interface_type ($$iface{"dev"});
  3082.  
  3083.   if ($type eq "ethernet" || $type eq "irlan")
  3084.   {
  3085.     return 1 if ($$iface{"bootproto"} eq "dhcp" || ($$iface{"address"} && $$iface{"netmask"}));
  3086.   }
  3087.   elsif ($type eq "wireless")
  3088.   {
  3089.     return 1 if (($$iface{"bootproto"} eq "dhcp" || ($$iface{"address"} && $$iface{"netmask"})) && $$iface{"essid"});
  3090.   }
  3091.   elsif ($type eq "plip")
  3092.   {
  3093.     return 1 if ($$iface{"address"} && $$iface{"remote_address"});
  3094.   }
  3095.   elsif ($type eq "modem" || $type eq "isdn")
  3096.   {
  3097.     return 1 if ($$iface{"phone_number"} && $$iface{"login"});
  3098.   }
  3099.  
  3100.   return 0;  
  3101. }
  3102.  
  3103. sub set_interface_config
  3104. {
  3105.   my ($dev, $values_hash, $old_hash) = @_;
  3106.   my (%dist_attrib, %fn);
  3107.   my ($proc, $i, $res);
  3108.  
  3109.   &Utils::Report::enter ();
  3110.   &Utils::Report::do_report ("network_iface_set", $dev);
  3111.  
  3112.   %dist_attrib = &get_interface_replace_table ();
  3113.   $proc = $dist_attrib{"iface_set"};
  3114.   %fn = %{$dist_attrib{"fn"}};
  3115.  
  3116.   foreach $i (keys (%fn))
  3117.   {
  3118.     $ {$dist_attrib{"fn"}}{$i} = &Utils::Parse::expand ($fn{$i}, "iface", $dev);
  3119.   }
  3120.  
  3121.   $res = &Utils::Replace::set_from_table ($dist_attrib{"fn"}, $dist_attrib{"table"},
  3122.                                   $values_hash, $old_hash);
  3123.   
  3124.   # if success saving the settings for the interface, set up immediatly.
  3125.   &$proc ($values_hash, $old_hash, $$values_hash{"enabled"}, 0) if !$res;
  3126.  
  3127.   &Utils::Report::leave ();
  3128.   return $res;
  3129. }
  3130.  
  3131. sub set_interfaces_config
  3132. {
  3133.   my ($values_hash) = @_;
  3134.   my ($old_hash);
  3135.   my (%dist_attrib);
  3136.   my ($i);
  3137.   my ($delete_proc, $set_proc);
  3138.   my ($do_active);
  3139.  
  3140.   &Utils::Report::enter ();
  3141.   &Utils::Report::do_report ("network_ifaces_set");
  3142.   
  3143.   %dist_attrib = &get_interface_replace_table ();
  3144.   $old_hash = &get_interfaces_config ();
  3145.  
  3146.   $delete_proc = $dist_attrib{"iface_delete"};
  3147.   $set_proc    = $dist_attrib{"iface_set"};
  3148.  
  3149.   foreach $i (keys %$values_hash)
  3150.   {
  3151.     $do_active = $$values_hash{$i}{"enabled"};
  3152.  
  3153.     # delete it if it's no longer configured
  3154.     if (&interface_configured ($$old_hash{$i}) &&
  3155.         !&interface_configured ($$values_hash{$i}))
  3156.     {
  3157.       &$set_proc ($$values_hash{$i}, $$old_hash{$i}, 0, 1);
  3158.       &$delete_proc ($$old_hash{$i});
  3159.     }
  3160.     elsif (&interface_configured ($$values_hash{$i}) &&
  3161.            &interface_changed ($$values_hash{$i}, $$old_hash{$i}))
  3162.     {
  3163.       $$values_hash{$i}{"file"} = $$old_hash{$i}{"file"};
  3164.  
  3165.       &$set_proc ($$values_hash{$i}, $$old_hash{$i}, 0, 1);
  3166.       &set_interface_config ($i, $$values_hash{$i}, $$old_hash{$i});
  3167.       &$set_proc ($$values_hash{$i}, $$old_hash{$i}, 1, 1) if ($do_active);
  3168.     }
  3169.     elsif ($$values_hash{$i}{"enabled"} != $$old_hash{$i}{"enabled"})
  3170.     {
  3171.       # only state has changed
  3172.       &$set_proc ($$values_hash{$i}, $$old_hash{$i}, $do_active, 1);
  3173.     }
  3174.     
  3175.   }
  3176.  
  3177.   &Utils::Report::leave ();
  3178. }
  3179.  
  3180. sub bootproto_to_code
  3181. {
  3182.   my ($iface) = @_;
  3183.  
  3184.   return 0 if (!&interface_configured ($iface));
  3185.   return ($$iface{"bootproto"} eq "dhcp") ? 2 : 1;
  3186. }
  3187.  
  3188. sub get
  3189. {
  3190.   my ($config, $iface, $type);
  3191.   my ($ethernet, $wireless, $irlan);
  3192.   my ($plip, $modem, $isdn);
  3193.  
  3194.   $config = &get_interfaces_config ();
  3195.  
  3196.   foreach $i (keys %$config)
  3197.   {
  3198.     $iface = $$config{$i};
  3199.     $type = &get_interface_type ($i);
  3200.  
  3201.     if ($type eq "ethernet")
  3202.     {
  3203.       push @$ethernet, [ $$iface{"dev"}, $$iface{"enabled"}, $$iface{"auto"},
  3204.                          &bootproto_to_code ($iface),
  3205.                          $$iface{"address"}, $$iface{"netmask"},
  3206.                          $$iface{"network"}, $$iface{"broadcast"} ];
  3207.     }
  3208.     elsif ($type eq "wireless")
  3209.     {
  3210.       push @$wireless, [ $$iface{"dev"}, $$iface{"enabled"}, $$iface{"auto"},
  3211.                          &bootproto_to_code ($iface),
  3212.                          $$iface{"address"}, $$iface{"netmask"},
  3213.                          $$iface{"network"}, $$iface{"broadcast"},
  3214.                          $$iface{"essid"},
  3215.                          ($$iface{"key_type"} eq "ascii") ? 0 : 1,
  3216.                          $$iface{"key"} ];
  3217.     }
  3218.     elsif ($type eq "irlan")
  3219.     {
  3220.       push @$irlan, [ $$iface{"dev"}, $$iface{"enabled"}, $$iface{"auto"},
  3221.                       &bootproto_to_code ($iface),
  3222.                       $$iface{"address"}, $$iface{"netmask"},
  3223.                       $$iface{"network"}, $$iface{"broadcast"} ];
  3224.     }
  3225.     elsif ($type eq "plip")
  3226.     {
  3227.       push @$plip, [ $$iface{"dev"}, $$iface{"enabled"}, $$iface{"auto"},
  3228.                      $$iface{"address"}, $$iface{"remote_address"} ];
  3229.     }
  3230.     elsif ($type eq "modem")
  3231.     {
  3232.       push @$modem, [ $$iface{"dev"}, $$iface{"enabled"}, $$iface{"auto"},
  3233.                       $$iface{"phone_number"}, $$iface{"external_line"},
  3234.                       $$iface{"serial_port"}, $$iface{"volume"},
  3235.                       ($$iface{"dial_command"} eq "atdt") ? 0 : 1,
  3236.                       $$iface{"login"}, $$iface{"password"},
  3237.                       $$iface{"set_default_gw"}, $$iface{"update_dns"},
  3238.                       $$iface{"persist"}, $$iface{"noauth"} ];
  3239.     }
  3240.     elsif ($type eq "isdn")
  3241.     {
  3242.       push @$isdn, [ $$iface{"dev"}, $$iface{"enabled"}, $$iface{"auto"},
  3243.                       $$iface{"phone_number"}, $$iface{"external_line"},
  3244.                       $$iface{"login"}, $$iface{"password"},
  3245.                       $$iface{"set_default_gw"}, $$iface{"update_dns"},
  3246.                       $$iface{"persist"}, $$iface{"noauth"} ];
  3247.     }
  3248.   }
  3249.  
  3250.   return ($ethernet, $wireless, $irlan,
  3251.           $plip, $modem, $isdn);
  3252. }
  3253.  
  3254. sub set
  3255. {
  3256.   my ($ethernet, $wireless, $irlan, $plip, $modem, $isdn) = @_;
  3257.   my (%hash, $iface, $bootproto, $key_type);
  3258.  
  3259.   foreach $iface (@$ethernet)
  3260.   {
  3261.     $bootproto = ($$iface[3] == 2) ? "dhcp" : "none";
  3262.  
  3263.     $hash{$$iface[0]} = { "dev" => $$iface[0], "enabled" => $$iface[1], "auto" => $$iface[2],
  3264.                           "bootproto" => $bootproto,
  3265.                           "address" => $$iface[4], "netmask" => $$iface[5] };
  3266.   }
  3267.  
  3268.   foreach $iface (@$wireless)
  3269.   {
  3270.     $bootproto = ($$iface[3] == 2) ? "dhcp" : "none";
  3271.     $key_type = ($$iface[9] == 1) ? "hexadecimal" : "ascii";
  3272.  
  3273.     $hash{$$iface[0]} = { "dev" => $$iface[0], "enabled" => $$iface[1], "auto" => $$iface[2],
  3274.                           "bootproto" => $bootproto,
  3275.                           "address" => $$iface[4], "netmask" => $$iface[5],
  3276.                           "essid" => $$iface[8], "key_type" => $key_type, "key" => $$iface[10] };
  3277.   }
  3278.  
  3279.   foreach $iface (@$irlan)
  3280.   {
  3281.     $bootproto = ($$iface[3] == 2) ? "dhcp" : "none";
  3282.     $hash{$$iface[0]} = { "dev" => $$iface[0], "enabled" => $$iface[1], "auto" => $$iface[2],
  3283.                           "bootproto" => $bootproto,
  3284.                           "address" => $$iface[4], "netmask" => $$iface[5] };
  3285.   }
  3286.  
  3287.   foreach $iface (@$plip)
  3288.   {
  3289.     $hash{$$iface[0]} = { "dev" => $$iface[0], "enabled" => $$iface[1], "auto" => $$iface[2],
  3290.                           "address" => $$iface[3], "remote_address" => $$iface[4] };
  3291.   }
  3292.  
  3293.   foreach $iface (@$modem)
  3294.   {
  3295.     $dial_command = ($$iface[7] == 0) ? "ATDT" : "ATDP";
  3296.     $hash{$$iface[0]} = { "dev" => $$iface[0], "enabled" => $$iface[1], "auto" => $$iface[2],
  3297.                           "phone_number" => $$iface[3], "external_line" => $$iface[4],
  3298.                           "serial_port" => $$iface[5], "volume" => $$iface[6],
  3299.                           "dial_command" => $dial_command,
  3300.                           "login" => $$iface[8], "password" => $$iface[9],
  3301.                           "set_default_gw" => $$iface[10], "update_dns"=> $$iface[11],
  3302.                           "persist" => $$iface[12], "noauth" => $$iface[13],
  3303.                           # FIXME: hardcoded serial speed ATM
  3304.                           "serial_speed" => "115200"};
  3305.   }
  3306.  
  3307.   foreach $iface (@$isdn)
  3308.   {
  3309.     $hash{$$iface[0]} = { "dev" => $$iface[0], "enabled" => $$iface[1], "auto" => $$iface[2],
  3310.                           "phone_number" => $$iface[3], "external_line" => $$iface[4],
  3311.                           "login" => $$iface[5], "password" => $$iface[6],
  3312.                           "set_default_gw" => $$iface[7], "update_dns"=> $$iface[8],
  3313.                           "persist" => $$iface[9], "noauth" => $$iface[10] };
  3314.   }
  3315.  
  3316.   &set_interfaces_config (\%hash);
  3317. }
  3318.  
  3319. 1;
  3320.