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