package network::netconnect; # $Id$ use strict; use common; use log; use detect_devices; use list_modules; use modules; use mouse; use services; use network::network; use network::tools; use network::thirdparty; sub detect { my ($modules_conf, $auto_detect, $o_class) = @_; my %l = ( isdn => sub { require network::isdn; $auto_detect->{isdn} = network::isdn::detect_backend($modules_conf); }, lan => sub { # ethernet require network::ethernet; modules::load_category($modules_conf, list_modules::ethernet_categories()); $auto_detect->{lan} = { map { $_->[0] => $_->[1] } network::ethernet::get_eth_cards($modules_conf) }; }, adsl => sub { require network::adsl; $auto_detect->{adsl} = network::adsl::adsl_detect(); }, modem => sub { $auto_detect->{modem} = { map { $_->{description} || "$_->{MANUFACTURER}|$_->{DESCRIPTION} ($_->{device})" => $_ } detect_devices::getModem($modules_conf) }; }, ); $l{$_}->() foreach $o_class || keys %l; return; } sub detect_timezone() { my %tmz2country = ( 'Europe/Paris' => N("France"), 'Europe/Amsterdam' => N("Netherlands"), 'Europe/Rome' => N("Italy"), 'Europe/Brussels' => N("Belgium"), 'America/New_York' => N("United States"), 'Europe/London' => N("United Kingdom") ); my %tm_parse = MDK::Common::System::getVarsFromSh("$::prefix/etc/sysconfig/clock"); my @country; foreach (keys %tmz2country) { if ($_ eq $tm_parse{ZONE}) { unshift @country, $tmz2country{$_}; } else { push @country, $tmz2country{$_} } } \@country; } sub real_main { my ($net, $in, $modules_conf) = @_; #- network configuration should have been already read in $net at this point my $mouse = $::o->{mouse} || {}; my ($cnx_type, @all_cards, %eth_intf, %all_eth_intf, %unavailable_wireless_intf); my (%connections, @connection_list); my ($modem, $modem_name, $modem_dyn_dns, $modem_dyn_ip); my $cable_no_auth; my (@adsl_devices, %adsl_cards, %adsl_data, $adsl_data, $adsl_provider, $adsl_old_provider, $adsl_vpi, $adsl_vci); my ($ntf_name, $gateway_ex, $up); my ($isdn, $isdn_name, $isdn_type, %isdn_cards, @isdn_dial_methods); my $my_isdn = join('', N("Manual choice"), " (", N("Internal ISDN card"), ")"); my (@ndiswrapper_drivers, $ndiswrapper_driver, $ndiswrapper_device); my ($is_wireless, $wireless_enc_mode, $wireless_enc_key, $need_rt2x00_iwpriv, $wireless_roaming, $need_wpa_supplicant); my ($dvb_adapter, $dvb_ad, $dvb_net, $dvb_pid); my ($module, $auto_ip, $protocol, $onboot, $needhostname, $peerdns, $peeryp, $peerntpd, $ifplugd, $track_network_id, $ipv6_tunnel, $need_network_restart); my $success = 1; my $ethntf = {}; my $db_path = "/usr/share/apps/kppp/Provider"; my (%countries, @isp, $country, $provider, $old_provider); my %l10n_lan_protocols = ( static => N("Manual configuration"), dhcp => N("Automatic IP (BOOTP/DHCP)"), if_(0, dhcp_zeroconf => N("Automatic IP (BOOTP/DHCP/Zeroconf)"), ) ); my $_w = N("Protocol for the rest of the world"); my %isdn_protocols = ( 2 => N("European protocol (EDSS1)"), 3 => N("Protocol for the rest of the world\nNo D-Channel (leased lines)"), ); $net->{autodetect} = {}; my $lan_detect = sub { detect($modules_conf, $net->{autodetect}, 'lan'); @all_cards = network::ethernet::get_eth_cards($modules_conf); %all_eth_intf = network::ethernet::get_eth_cards_names(@all_cards); #- needed not to loose GATEWAYDEV %eth_intf = map { $_->[0] => join(': ', $_->[0], $_->[2]) } grep { to_bool($is_wireless) == detect_devices::is_wireless_interface($_->[0]) } @all_cards; my %available; $available{$_->[2]} = undef foreach grep { $_->[2] } @all_cards; %unavailable_wireless_intf = map { $_->{driver} => sprintf('%s (%s): %s', N("unknown"), $_->{driver}, $_->{description}); } grep { !exists($available{$_->{description}}) } modules::probe_category('network/wireless'); }; my $is_dvb_interface = sub { $_[0]{DEVICE} =~ /^dvb\d+_\d+/ }; my $find_lan_module = sub { if (my $dev = find { $_->{device} eq $ethntf->{DEVICE} } detect_devices::pcmcia_probe()) { # PCMCIA case $module = $dev->{driver}; } elsif ($dev = find { $_->[0] eq $ethntf->{DEVICE} } @all_cards) { $module = $dev->[1]; } elsif ($is_dvb_interface->($ethntf)) { $module = $dvb_adapter->{driver}; } else { $module = "" } }; my %adsl_descriptions = ( speedtouch => N("Alcatel speedtouch USB modem"), sagem => N("Sagem USB modem"), bewan => N("Bewan modem"), eci => N("ECI Hi-Focus modem"), # this one needs eci agreement ); my %adsl_types = ( dhcp => N("Dynamic Host Configuration Protocol (DHCP)"), static => N("Manual TCP/IP configuration"), pptp => N("Point to Point Tunneling Protocol (PPTP)"), pppoe => N("PPP over Ethernet (PPPoE)"), pppoa => N("PPP over ATM (PPPoA)"), capi => N("DSL over CAPI"), ); my %encapsulations = ( 1 => N("Bridged Ethernet LLC"), 2 => N("Bridged Ethernet VC"), 3 => N("Routed IP LLC"), 4 => N("Routed IP VC"), 5 => N("PPPoA LLC"), 6 => N("PPPoA VC"), ); my %ppp_auth_methods = ( 0 => N("Script-based"), 1 => N("PAP"), 2 => N("Terminal-based"), 3 => N("CHAP"), 4 => N("PAP/CHAP"), ); my $offer_to_connect = sub { if ($net->{type} eq 'adsl' && !member($net->{adsl}{method}, qw(static dhcp)) || member($net->{type}, qw(modem isdn isdn_external))) { return "ask_connect_now"; } elsif ($need_network_restart) { services::restart("network"); } else { network::tools::stop_net_interface($net, 0); if (exists $net->{adsl}{ethernet_device}) { network::tools::stop_interface($net->{adsl}{ethernet_device}, 0); network::tools::stop_interface($net->{adsl}{ethernet_device}, 0); } network::tools::start_net_interface($net, 0); } return "end"; }; my $after_lan_intf_selection = sub { $is_wireless ? 'wireless' : 'lan_protocol' }; my $after_start_on_boot_step = sub { #- can't be done in adsl_account step because of static/dhcp adsl methods #- we need to write sagem specific parameters and load corresponding modules/programs (sagem/speedtouch) $net->{type} eq 'adsl' and network::adsl::adsl_conf_backend($in, $modules_conf, $net); network::network::configure_network($net, $in, $modules_conf); return $offer_to_connect->(); }; my $goto_start_on_boot_ifneeded = sub { return $after_start_on_boot_step->() if $net->{type} eq "lan"; return "isdn_dial_on_boot" if $net->{type} eq 'isdn'; return "network_on_boot"; @text = ([ N("<b>Surf the Internet</b>"), center => 1 ], ' ', N("Discovery will give you access to <b>every Internet resource</b>:"), N(" * Browse the <b>Web</b> with Konqueror."), N(" * <b>Chat</b> online with your friends using Kopete."), N(" * <b>Transfer</b> files with KBear."), N(" * ..."));