home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 2000-03-30 | 73.5 KB | 1,876 lines
/* * * Dial-Up Internet Connection YaST2 module * * Author: Petr Hrbek <hrbek@suse.cz> * * Purpose: * This module executes wvdialconf program, which tries autodetection of modem * and it tries autodetection of ISDN device (libhd library). * If modem or ISDN device was found it offers Predefined ISPs and shows it's * specification (phone, username, password) with two extra profiles (Current * settings and Generic). You can modify specification by hand. * * Second screen is Modem/ISDN configuration. Next step writes your configuration * into config files. * * Accessed Config files: * /etc/wvdial.conf * /etc/rc.config.d/i4l_hardware.rc.config (only ISDN) * /etc/rc.config.d/i4l.rc.config (only ISDN) * /etc/rc.config (only ISDN) * /etc/ppp/pap-secrets (only ISDN) * /etc/ppp/chap-secrets (only ISDN) * /etc/ppp/options.ippp0 (only ISDN) * * Needed external programs: * wvdialconf */ { // Menuentry for the YaST2 menu if (Args() == [ "get_menuentry" ]) return [ "dialup", $[ `menuentry : UI(_("Network/Modem+ISDN")), `arguments : [ ], `widget : `RichText( UI(_("Choose this item to configure your modem or ISDN-card for the connection to your ISP.")) + UI(_("<P><P>You need to be logged in as <I>root</I>."))), `codefragment : nil ] ]; // get full name of device from .probe device map define name_of_device (map device) ``{ string sub_vendor = lookup (device, "sub_vendor", ""); string sub_device = lookup (device, "sub_device", ""); if ((sub_vendor != "") && (sub_device != "")) return (sub_vendor + " " + sub_device); else return (lookup (device, "vendor", "") + " " + lookup (device, "device", "")); }; // Any agent for reading rc.config file SCR(``{ MountAgent (`anyagent( ``Description ( ``File("/etc/rc.config"), // real file name "#\n", // Comment false, // read-only ``List( Tuple( Optional(String(" ")), `key (String("^ =")), Separator ("= "), Optional(`value (String("^\n"))) ), "\n" ) )), .etc.rc_config); }); SCR(``{ MountAgent (`anyagent( ``Description ( ``File("/etc/route.conf"), // real file name "#\n", // Comment true, // read-only ``List( Tuple( `key (String("^ ")), Separator (" "), Optional(`value (String("^\n"))) ), "\n" ) )), .etc.route_conf); }); void|map predefined_providers = ReadY2("providers.ycp"); // ISDN protocols structure map isdn_prot = $[ // Type of ISDN protocol (1TR6, Euro-ISDN Leased line) 1 : UI(_("1TR6")), 2 : UI(_("Euro-ISDN (EDSS1)")), 3 : UI(_("Leased line")) ]; list valid_bauds = [1200,2400,4800,9600,19200,38400,57600,115200,230400,460800]; list def_IPs = ["30.0.0.","20.0.0.","12.0.0.","10.0.0.","192.168.0."]; // Was ISDN/modem device detected? boolean isdn_det = false; boolean modem_det = false; // Entries of /etc/wvdial.conf string init1 = ""; string init2 = ""; string init3 = ""; string prefix = ""; void|boolean tone_dial = nil; boolean pbx = false; void|boolean verbose = nil; string tel_no = ""; string username = ""; string pass = ""; boolean stupid = true; boolean compuserve = false; map providers = $[]; if (predefined_providers != nil) providers = predefined_providers; map providers_names = $[]; list sbox_entry = []; string wvdial_write_section = "/usr/bin/wvdial-write-section"; boolean usb = false; string isdn4all = "no"; // only root may dial-out (ISDN4ALL="false" in rc.config) void|string selected_provider = nil; string sec = ""; list keys = []; map entries = $[]; string kname = ""; string kvalue = ""; void|list modem_probe = []; list ISDN_probe = []; // ISDN AnyAgent structures and vars list pap_secrets = []; list chap_secrets = []; list i4l_rc_config = []; list i4l_hardware = []; list rc_config = []; list ippp_options = []; string msn = ""; string dial_mode = ""; void|string dev_num = nil; void|string card_num = nil; string if_config = ""; boolean dynamic = true; boolean dynDNS = true; boolean boot = true; string IP_local = ""; string IP_rem = ""; string net_dev = ""; string location = ""; integer protocol = 0; string callback_mode = ""; string type = ""; string subtype = ""; string baud = ""; void|string io = ""; void|string io0 = ""; void|string io1 = ""; void|string io2 = ""; map card_values = $[ "I4L_TYPE_" : "", "I4L_SUBTYPE_" : "", "I4L_IRQ_" : "", "I4L_IO_" : "", "I4L_IO0_" : "", "I4L_IO1_" : "", "I4L_IO2_" : "", "I4L_MEMBASE_" : "" ]; void|string membase = ""; void|string irq = ""; map active = $[]; map active_pcmcia = $[]; map net_devs = $[]; map if_configs = $[]; void|string ISDN_desc = nil; boolean isdn_pcmcia = false; boolean route = true; // Trasformation Anyagent structures to simplier form void|list wvdial_cfg = []; map i4l_rc_config_entries = $[]; map i4l_hardware_entries = $[]; any tmp = []; any tmp2 = []; map pap_secrets_int = $[]; map chap_secrets_int = $[]; map ippp_options_int = $[]; // ######################### Taken from lan.ycp script ############################# /* * Split long string by characters in separator string into list of strings * * split("addr:127.0.0.1 Mask:255.0.0.0", ": .") -> * -> ["addr", "127", "0", "0", "1", "Mask", "255", "0", "0", "0"] * */ define split(string s, string sep) ``{ list chars = []; integer|void i = size(sep) - 1; while (i >= 0) { chars = add(chars, substring(sep, i, 1)); i = i - 1; } chars = add(chars, ""); list l = []; string ch = ""; i = findfirstnotof(s, sep); while (i != nil) { s = substring(s, i, size(s) - i); i = 0; ch = substring(s, 0, 1); while (!contains(chars, ch)) { i = i + 1; ch = substring(s, i, 1); } l = add (l, substring(s, 0, i)); s = substring(s, i, size(s) - i); i = findfirstnotof(s, sep); } return l; }; /* * Convert ip address string into list of four integer * Return [] in case of syntax error * * strtoaddr("127.0.0.0") -> [127, 0, 0, 0] * */ define strtoaddr(string str) ``{ integer i = 0; integer j = 4; integer x = 0; list ip = []; str = str + "."; while (j > 0) { i = findfirstnotof (str, "1234567890"); if ((substring (str, i, 1) == ".") && (i != 0)) { x = tointeger(str); if (x > 256) return []; ip = add(ip, x); str = substring (str, i + 1); } else { return []; } j = j - 1; } if (size(str) > 0) return []; return ip; }; /* * Convert integer into list of eight boolean * */ define inttobyte(integer i) ``{ if ((i < 0) || (i > 255)) return [0]; list y = []; do { y = add(y, i%2 == 1); i = i / 2; } while (i > 0); return y; }; /* * Convert list of boolean to integer * */ define bytetoint(list a) ``{ integer i = size(a) - 1; integer x = 0; while (i >= 0) { x = x * 2; if (select(a, i)) x = x + 1; i = i - 1; } return x; }; /* * Logical 'and' on boolean elements of lists * */ define and(list a, list b) ``{ list c = []; integer no = 0; integer i = 0; if (size(a) < size(b)) no = size(a); else no = size(b); while (i < no) { c = add (c, select (a, i) && select(b, i)); i = i + 1; } return c; }; /* * Compute network address from ip and mask * */ define getnet (list ip, list mask) ``{ integer i = 0; list net = []; while (i < 4) { net = add( net, bytetoint( and( inttobyte(select(ip, i)), inttobyte(select(mask, i)) ) ) ); i = i + 1; } return net; }; // ######################### Taken from lan.ycp script ############################# // Returns haxadecimal value of input number // Parameters: i - number to be converted // Return Value: hexadecimal representation of i define tohex(integer i) ``{ integer mod = 0; string out = ""; do { mod = i % 16; if (mod < 10) out = sformat("%1",mod) + out; else if (mod == 10) out = "A" + out; else if (mod == 11) out = "B" + out; else if (mod == 12) out = "C" + out; else if (mod == 13) out = "D" + out; else if (mod == 14) out = "E" + out; else if (mod == 15) out = "F" + out; i = i / 16; } while (i > 0); out = "0x" + out; return out; }; // Returns input string without leading and trailing quote // Parameters: s - string to unqoute // Return Value: unquoted input string define unquote(string s) ``{ if (substring(s,0,1) == "\"") { s = substring(s,1,(size(s)-1)); if (substring(s,size(s)-1,1) == "\"") s = substring(s,0,(size(s)-1)); } return s; }; // Reads modem configuration file (/etc/wvdial.conf) and convert it to simplier form // Parameters: location (string) - selected group of C-b-C providers // rebuild_providers - completely rebuild providers structure (speed) // Return Value: define read_cfg_modem(string location, boolean rebuild_providers) ``{ providers_names = $[]; if (rebuild_providers) { wvdial_cfg = SCR(`Read(.etc.wvdialconf)); providers = $[]; if (predefined_providers != nil) providers = predefined_providers; if (wvdial_cfg != nil) tmp = maplist(`entry, wvdial_cfg, ``{ entries = $[]; sec = lookup (entry, "section",""); keys = lookup (entry, "contents",""); tmp2 = maplist(`keys_entry, keys, ``{ kname = lookup (keys_entry, "keyname",""); kvalue = lookup (keys_entry,"keyvalue",""); entries = add(entries,kname,kvalue); }); providers = add(providers,sec,entries); }); } string description = ""; // Creates providers_names map for SelectionBox tmp = maplist(`ISP_name, `ISP_data, providers, ``{ if ((((location == "`ger")&&(lookup(ISP_data,"Country","") == "Germany")) ||((location == "`UK")&&(lookup(ISP_data,"Country","") == "UK")) ||((location == "`USA")&&(lookup(ISP_data,"Country","") == "USA")) ||(ISP_name == "Dialer Defaults"))&&(((isdn_det)&&(lookup(ISP_data,"ISDN supported","") == "1"))||(modem_det))) { if ((ISP_name == "Dialer Defaults")&&(modem_det)) description = "Edit"; else if ((lookup(ISP_data,"Connection name","") == "") && (lookup(ISP_data,"Provider","") == "")) description = ISP_name; else if (lookup(ISP_data,"Provider","") == "") description = ISP_name; else { description = lookup(ISP_data,"Provider", ""); description = description + " ("+lookup(ISP_data,"Product", "")+")"; } providers_names = add(providers_names,ISP_name,description); } }); }; // Gets free device number of network devices // Parameters: // Return Value: define get_dev_num() ``{ rc_config = SCR(`Read(.etc.rc_config)); dev_num = nil; integer i = 0; while(i <= 3) { active = $[]; active_pcmcia = $[]; tmp = maplist (`entry, rc_config, ``{ if (lookup(entry,"key","") == sformat("NETDEV_%1",i)) net_devs = add(net_devs,i,unquote(lookup(entry,"value",""))); if (lookup(entry,"key","") == sformat("IFCONFIG_%1",i)) if_configs = add(if_configs,i,unquote(lookup(entry,"value",""))); if (lookup(entry,"key","") == "IP_DYNIP") if (unquote(lookup(entry,"value","")) == "no") dynamic = false; else dynamic = true; if (lookup(entry,"key","") == "I4L_START") if (unquote(lookup(entry,"value")) == "yes") boot = true; else boot = false; if (lookup(entry,"key","") == "NETCONFIG") tmp2 = maplist(`entry2, split(unquote(lookup(entry,"value",""))," "), ``{ active = add(active,tointeger(filterchars(entry2,"0123")),"1"); }); if (lookup(entry,"key","") == "NETCONFIG_PCMCIA") tmp2 = maplist(`entry2, split(unquote(lookup(entry,"value",""))," "), ``{ active_pcmcia = add(active_pcmcia, tointeger(filterchars(entry2,"0123")),"1"); }); }); if ((dev_num == nil)&&((lookup(net_devs,i,"") == "")||(lookup(net_devs,i,"") == "isdn0")||(lookup(net_devs,i,"") == "ippp0"))) { dev_num = sformat("%1",i); net_dev = lookup(net_devs,i,""); } i=i+1; } if (dev_num != nil) { if_config = lookup(if_configs,tointeger(dev_num),""); if (if_config != "") { IP_local = select(split(if_config," "),0); IP_rem = select(split(if_config," "),3); } } }; // Reads ISDN configuration files and convert it to simplier form // Parameters: // Return Value: define read_cfg_ISDN() ``{ get_dev_num(); card_num = "1"; any key = nil; any value = nil; any ret = nil; pap_secrets = SCR(`Read(.etc.ppp.pap_secrets)); chap_secrets = SCR(`Read(.etc.ppp.chap_secrets)); ret = Shell("if test ! -f /etc/ppp/options.ippp0 ; then cp /etc/ppp/ioptions.YaST /etc/ppp/options.ippp0; fi;"); ippp_options = SCR(`Read(.etc.ppp.ioptions)); i4l_rc_config = SCR(`Read(.etc.i4l)); i4l_hardware = SCR(`Read(.etc.i4l_hw)); tmp = maplist (`entry, pap_secrets, ``{ pap_secrets_int = add(pap_secrets_int,lookup(entry,"client",""),$["server":lookup(entry,"server",""), "secret":lookup(entry,"secret","")]); }); tmp = maplist (`entry, chap_secrets, ``{ chap_secrets_int = add(chap_secrets_int,lookup(entry,"client",""),$["server":lookup(entry,"server",""), "secret":lookup(entry,"secret","")]); }); tmp = maplist(`entry, i4l_rc_config, ``{ key = lookup (entry, "key",""); value = lookup (entry, "value",""); i4l_rc_config_entries = add(i4l_rc_config_entries,key,unquote(value)); }); tmp = maplist(`entry, i4l_hardware, ``{ key = lookup (entry, "key",""); value = lookup (entry, "value",""); i4l_hardware_entries = add(i4l_hardware_entries,key,unquote(value)); }); tmp = maplist(`entry, ippp_options, ``{ key = lookup (entry, "key",""); value = lookup (entry, "value",""); if (value == nil) value = ""; ippp_options_int = add(ippp_options_int,key,unquote(value)); }); if (lookup(ippp_options_int,"ms-get-dns","") == nil) dynDNS = false; providers_names = add(providers_names,"Dialer Defaults",UI(_("Edit"))); providers = add(providers,"Dialer Defaults",$["Phone":filterchars(lookup(i4l_rc_config_entries,"I4L_REMOTE_OUT_"+dev_num,""),"1234567890 ,*#-"),"Username":lookup(ippp_options_int,"user",""),"Password":lookup((lookup(pap_secrets_int,lookup(ippp_options_int,"user",""),lookup(pap_secrets_int,"\""+lookup(ippp_options_int,"user")+"\""))),"secret")]); }; // Check function for valid Phone number and Area Code // Parameters: caller - function from which was is_valid called // field - TextEntry name for error message // s - checked string // op - needed operation ("v" - validation for phone strings, // "e" - string can't be empty, // "i" - string is valid IP) // "b" - baud rate validation) // Return Value: caller (if there are invalid chars) define is_valid(any caller, string field, string s, string op) ``{ string help = ""; void|term contents = nil; if ((s != filterchars(s,"1234567890,*#- "))&&(filterchars(op,"v") == "v")) { // Invalid characters in various fields of dialogs (almost telephone numbers) help = sformat(UI(_("<P>You entered invalid characters in field \"%1\".</P><P>Valid characters are <B>numbers</B>, <B>*</B>, <B>#</B>, <B>SPACE</B>, <B>-</B> and <B>,</B>.</P> ")),field); contents = `HSquash(`VBox( // Label for error screen if invalid characters were writen `Label(sformat(UI(_("Invalid characters in field \"%1\"!")),field)),`Empty())); // Title for screen if invalid characters were writen } if (filterchars(op,"b") == "b") { boolean err = true; string valid_rates = ""; tmp = maplist(`entry, valid_bauds, ``{ if (s == sformat("%1",entry)) err = false; valid_rates = valid_rates + entry + ", "; }); valid_rates = substring(valid_rates,0,size(valid_rates)-2); if (err) { // Invalid baudrate heltext help = sformat(UI(_("<P>Please choose a valid <B>baud rate</B>.</P><P>Possible values are %1.</P>")),valid_rates); contents = `HSquash(`VBox( // Label for error screen if invalid baudrate writen `Label(UI(_("Invalid baud rate"))),`Empty())); } // Title for screen if invalid characters were writen } if (filterchars(op,"i") == "i") { list parts = split(s,"."); boolean err = false; tmp = maplist(`entry, parts, ``{ if (entry != nil) if ((tointeger(entry) < 0)||(tointeger(entry) > 255)||(filterchars(entry,"1234567890") != entry)) err = true; }); if ((err)||((size(parts) != 4)&&(s != ""))) // Invalid IP address inserted help = sformat(UI(_("Please enter a valid IP address in the field \"%1\".")),field); contents = `HSquash(`VBox( // Label for error screen if invalid characters were writen `Label(sformat(UI(_("Invalid IP address format in field \"%1\"")),field)),`Empty())); // Title for screen if invalid characters were writen } if ((s == "")&&(filterchars(op,"e") == "e")) { // Empty value of field where is value needed) help = sformat(UI(_("<P>The field \"%1\" must not be empty.</P><P>Please enter a value.</P>")),field); contents = `HSquash(`VBox( // Label for error screen if invalid characters were writen `Label(sformat(UI(_("The field \"%1\" must not be empty")),field)),`Empty())); // Title for screen if invalid characters were writen } if (help != "") { any ret = UI(`ShowPage(_("Input error"),contents,help,true,true)); return caller; } }; // Modem and ISDN device detection function // Parameters: // Return Value: `check_devices define modem_detection() ``{ // Deletes Modem entry from /etc/wvdial.conf tel_no = ""; username = ""; pass = ""; location = ""; modem_det = false; isdn_det = false; read_cfg_modem("",true); if (save_cfg_modem(true) == `back) return back; UI(``{ // Help text for autodetection screen. It dissapears automaticaly when autodetection is done ChangeWidget(`id(`help), `Value, _("<P>An attempt to find external modems and internal modems will be made.<P>If you are using an <I>ISA-PnP or PCI-Modem</I>, please refer to the manual.</P><P><B>Please wait...</B></P> ")); ChangeWidget(`id(`title), `Value, _("Modem and ISDN autodetection")); ChangeWidget(`id(`back), `Enabled, false); ChangeWidget(`id(`next), `Enabled, false); ChangeWidget(`id(`next), `Label, _("&Next")); ReplaceWidget(`id(`contents), `HSquash(`VBox( // Autodetection is running `Label(_("Modem device detection in progress...")),`Empty())) ); }); // Runs wvdialconf which detect modem and writes device, bauds and init string into cfg file any ret = Shell("wvdialconf /etc/wvdial.conf"); UI(`ChangeWidget(`id(`next), `Enabled, true)); modem_probe = SCR(`Read(.probe.byclass.modem)); ISDN_probe = SCR(`Read(.probe.byclass.isdn)); return `check_devices; }; // Check if modem or ISDN was detected by modem_detection function // Parameters: // Return Value: `ISP_sel if modem was detected or `back if not define check_devices() ``{ providers = $[]; read_cfg_modem("",true); void|term contents = nil; string help = ""; any ret = nil; list tmp = []; map isdn_map = $[]; map isdn_para = $[]; any modem_desc = nil; string|void modem_dev = lookup(lookup(providers,"Dialer Defaults",""),"Modem",""); if (size(filterchars(modem_dev,"USBACM")) > 1) usb = true; if ((modem_dev != nil) && (modem_dev != "")) modem_det = true; if (size(ISDN_probe) > 0) isdn_det = true; if (isdn_det) { io = nil; irq = nil; membase = nil; type = ""; subtype = ""; tmp = maplist(`entry, ISDN_probe, ``{ isdn_map = lookup(entry, "isdn",""); ISDN_desc = lookup(isdn_map, "name",""); type = sformat("%1",lookup(isdn_map,"type")); subtype = sformat("%1",lookup(isdn_map,"subtype","")); isdn_para = lookup(isdn_map, "parameter",""); card_values = add(card_values, "I4L_TYPE_", type); card_values = add(card_values, "I4L_SUBTYPE_", subtype); if (size(isdn_para) > 0) { foreach(`k, `v, isdn_para, ``{ if (k == "IRQ") { irq = sformat("%1", select(v, 0)); card_values = add(card_values, "I4L_IRQ_", irq); } if (k == "IO") { io = sformat("%1", select(v, 0)); card_values = add(card_values, "I4L_IO_", tohex(tointeger(io))); } if (k == "IO0") { io0 = sformat("%1", select(v, 0)); card_values = add(card_values, "I4L_IO0_", tohex(tointeger(io0))); } if (k == "IO1") { io1 = sformat("%1", select(v, 0)); card_values = add(card_values, "I4L_IO1_", tohex(tointeger(io1))); } if (k == "IO2") { io2 = sformat("%1", select(v, 0)); card_values = add(card_values, "I4L_IO2_", tohex(tointeger(io2))); } if (k == "MEMBASE") { mem = sformat("%1", select(v, 0)); card_values = add(card_values, "I4L_MEMBASE_", tohex(tointeger(mem))); } }); } }); } // Get modem description from libhd structure if (modem_det) { if (modem_dev != "/dev/modem") Shell("/bin/ln -sf "+modem_dev+" /dev/modem"); tmp = maplist(`entry, modem_probe, ``{ if (lookup(lookup(entry,"attached_to",""),"dev_name") == modem_dev) modem_desc = name_of_device(entry); }); if (modem_desc == nil) modem_desc = lookup(lookup(providers,"Dialer Defaults"),"Modem Name",nil); if (modem_desc == nil) modem_desc = UI(_("Unknown")); // Generates screen with information about detected devices if (isdn_det) { // If there are more detected devices, user has to select which of them will be configured help = UI(_("<P>Both an <B>ISDN card</B> and a <B>modem</B> were detected.</P>")); help = help + UI(_("<P>Please select the one that will be used for the internet connection.</P> ")); // help = help + UI(_("<P>Note: there are other names for serial ports in Linux (/dev/ttyS0 = COM1, /dev/ttyS1 = COM2...)</P>")); contents = `HSquash(`VBox( `Left(`Label(_("Hardware probing found several devices for internet connection"))), `Left(`Label(_("Please choose which one to configure:"))), `RadioButtonGroup(`id(`dev), `VBox( // Description of detected ISDN device `Left(`RadioButton(`id(`ISDN), sformat(UI(_("&ISDN card %1")),ISDN_desc),true)), // Description of detected modem `Left(`RadioButton(`id(`modem), sformat(UI(_("&Modem %1 on %2")),modem_desc, modem_dev))) ) ) )); ret = UI(`ShowPage(_("Internet configuration"),contents,help,true,true)); if (ret == `next) { isdn_det = UI(`QueryWidget(`id(`ISDN), `Value)); modem_det = UI(`QueryWidget(`id(`modem), `Value)); return `ISP_sel; } else if (ret == `cancel) return `cancel; else return `back; } else { // There was only one device (modem) detected and in next dialogs it'll be configured help = UI(_("<P>A <B>modem</B> was detected.</P><P>Please continue with the configuration of your connection to your ISP.</P> ")); help = help + UI(_("<P>Note: Serial ports in Linux are named differently than in DOS, e.g., /dev/ttyS0 = COM1, /dev/ttyS1 = COM2...</P> ")); contents = `HSquash(`VBox( // Description of detected modem `Label(sformat(UI(_("A modem\n\n %1\n\n was detected on %2 and will be configured\nfor internet access")), modem_desc, modem_dev)),`Empty())); ret = UI(`ShowPage(_("Internet configuration"),contents,help,true,true)); if (ret == `next) return `ISP_sel; else if (ret == `cancel) return `cancel; else return `back; } } else { if (isdn_det) { // There was only one device (ISDN card) detected and in next dialogs it'll be configured help = UI(_("<P>An <B>ISDN card</B> was detected.</P><P>Please continue with the configuration of the connection to your ISP.</P> ")); contents = `HSquash(`VBox( // Description of detected ISDN card `Label(sformat(UI(_("An ISDN card\n\n %1\n\n was detected and will be configured for internet access")),ISDN_desc)),`Empty())); ret = UI(`ShowPage(_("Internet configuration"),contents,help,true,true)); if (ret == `next) return `ISP_sel; else if (ret == `cancel) return `cancel; else return `back; } else { // No configurable device found // html-format / help start help = UI(_("<p>Neither an ISDN card nor a modem was found.</p>")); // html-format / help 2 help = help + UI(_("\ <p> If you are using a <b>PCI-Modem</b> run <i>lspci -v</i> and determine the IRQ and PORT. Then execute <i>setserial /dev/modem port PORT irq IRQ</i> and try again.</p> <p> <b>ISA-PnP card</b>: run <i>pnpdump -c > /etc/isapnp.conf</i> and <i>isapnp /etc/isapnp.conf</i>.<br> Determine the IRQ and PORT. Then execute <i>setserial /dev/modem port PORT irq IRQ</i> and try again.</p> ")); // html-format / help 3 help = help + UI(_("\ <p> Further Information can be found in the manual.</p> <p> If you are able to connect to the internet on another machine, have a look at the support database 'http://sdb.suse.de/sdb/en/html' and the modem trouble shooting tool 'http://sdb.suse.de/sdb/en/html/hoe_wvcheck.html'.</p> ")); contents = `HSquash(`VBox( `Label(_("Sorry, neither a modem nor an ISDN device was found")), `HBox( //Try again autodetection of ISDN device `PushButton(`id(`try), _("&Try again")), //Manual ISDN card configuration (if no ISDN card found) `PushButton(`id(`ISDN_man), _("&Manual ISDN device configuration")) ))); ret = UI(`ShowPage(_("Internet access"),contents,help,true,false)); if (ret == `try) return `modem_detection; if (ret == `ISDN_man) return `ISDN_man; else if (ret == `cancel) return `cancel; else return `back; } } }; //Manual ISDN device configuration //Parameters: - //Return value: `dev_cfg (if NEXT was pressed) or `modem_detection (BACK) define ISDN_man() ``{ //Manual selection of ISDN card (if autodetection fails) string help = UI(_("You need to select the type of your <B>ISDN</B> card and enter the required parameters manually (possible values of the parameters are shown)")); list ISDN_devices = SCR(`Read(.probe.ihw_data)); list card_list = []; map IO_ISDN = $[]; map IRQ_ISDN = $[]; map MEM_ISDN = $[]; map TYPES_ISDN = $[]; map SUBTYPES_ISDN = $[]; map CLASS_ISDN = $[]; map DESC_ISDN = $[]; list IO_list = []; list IRQ_list = []; list MEM_list = []; integer i = 0; integer j = 0; integer cl = 0; boolean initsel = false; string old_type = ""; string old_subtype = ""; // Read current settings read_cfg_ISDN(); old_type = lookup(i4l_hardware_entries, "I4L_TYPE_1", "0"); old_subtype = lookup(i4l_hardware_entries, "I4L_SUBTYPE_1", "0"); // Get information for manual selection tmp = maplist(`entry, ISDN_devices, ``{ cl = lookup(entry,"class"); // only legal ISA PCMCIA and parallel port devices are allowed if ((cl == 3) || (cl == 4) || (cl == 6)) { DESC_ISDN = add(DESC_ISDN, i, lookup(entry,"name")); type = sformat("%1",(lookup(entry,"type"))); subtype = sformat("%1",(lookup(entry,"subtype"))); TYPES_ISDN = add(TYPES_ISDN, i, (lookup(entry,"type"))); SUBTYPES_ISDN = add(SUBTYPES_ISDN,i,(lookup(entry,"subtype",""))); CLASS_ISDN = add(CLASS_ISDN, i, cl); if ((old_type == type) && (old_subtype == subtype)) initsel = true; else initsel = false; card_list = add(card_list,`item(`id(i),(lookup(entry,"name")),initsel)); if (lookup(entry,"parameter") != nil) { if ((lookup(lookup(entry,"parameter"),"IO")) != nil) IO_ISDN = add(IO_ISDN,i,lookup(lookup(entry,"parameter",[]),"IO",[])); else IO_ISDN = add(IO_ISDN,i,[]); if ((lookup(lookup(entry,"parameter"),"IRQ")) != nil) IRQ_ISDN = add(IRQ_ISDN,i,lookup(lookup(entry,"parameter",[]),"IRQ",[])); else IRQ_ISDN = add(IRQ_ISDN,i,[]); if ((lookup(lookup(entry,"parameter"),"MEMBASE")) != nil) MEM_ISDN = add(MEM_ISDN,i,lookup(lookup(entry,"parameter",[]),"MEMBASE",[])); else MEM_ISDN = add(MEM_ISDN,i,[]); } else { IO_ISDN = add(IO_ISDN,i,[]); IRQ_ISDN = add(IRQ_ISDN,i,[]); MEM_ISDN = add(MEM_ISDN,i,[]); } if (initsel) { IO_list = []; IRQ_list = []; MEM_list = []; j = 0; tmp = maplist(`entry, lookup(IO_ISDN,i), ``{ if ((j > 0)||(size(lookup(IO_ISDN,i)) == 1)) IO_list = add(IO_list,`item(`id(entry),tohex(entry),(tohex(entry) == lookup(i4l_hardware_entries, "I4L_IO_1")))); j=j+1; }); j = 0; tmp = maplist(`entry, lookup(IRQ_ISDN,i), ``{ if ((j > 0)||(size(lookup(IRQ_ISDN,i)) == 1)) IRQ_list = add(IRQ_list,`item(`id(entry),sformat("%1",entry),(sformat("%1",entry)==lookup(i4l_hardware_entries, "I4L_IRQ_1")))); j=j+1; }); j = 0; tmp = maplist(`entry, lookup(MEM_ISDN,i), ``{ if ((j > 0)||(size(lookup(MEM_ISDN,i)) == 1)) MEM_list = add(MEM_list,`item(`id(entry),tohex(entry), (tohex(entry) == lookup(i4l_hardware_entries, "I4L_MEMBASE_1")))); j=j+1; }); } i=i+1; } }); term contents = `HSquash(`VBox( `SelectionBox(`id(`sel_card),`opt(`notify), _("Select your ISDN card: "), card_list), `HBox( `ReplacePoint(`id(`io_repl),`SelectionBox(`id(`io),_("IO address"),IO_list)), `ReplacePoint(`id(`irq_repl),`SelectionBox(`id(`irq),_("IRQ"),IRQ_list)), `ReplacePoint(`id(`mem_repl),`SelectionBox(`id(`mem),_("MemBase"),MEM_list)) ) )); any ret = UI(`ShowPage(_("Manual ISDN selection and configuration"),contents,help,true,true)); while (ret != `next && ret != `back && ret != `cancel) { //If there was change in SelectionBox parameters are updated if (ret == `sel_card) { i = UI(`QueryWidget(`id(`sel_card), `CurrentItem)); IO_list = []; IRQ_list = []; MEM_list = []; j = 0; tmp = maplist(`entry, lookup(IO_ISDN,i,""), ``{ if ((j > 0)||(size(lookup(IO_ISDN,i,"")) == 1)) IO_list = add(IO_list,`item(`id(entry),tohex(entry),(entry == select(lookup(IO_ISDN,i,""),0)))); j=j+1; }); j = 0; tmp = maplist(`entry, lookup(IRQ_ISDN,i,""), ``{ if ((j > 0)||(size(lookup(IRQ_ISDN,i,"")) == 1)) IRQ_list = add(IRQ_list,`item(`id(entry),sformat("%1",entry),(entry == select(lookup(IRQ_ISDN,i,""),0)))); j=j+1; }); j = 0; tmp = maplist(`entry, lookup(MEM_ISDN,i,""), ``{ if ((j > 0)||(size(lookup(MEM_ISDN,i,"")) == 1)) MEM_list = add(MEM_list,`item(`id(entry),tohex(entry),(entry == select(lookup(MEM_ISDN,i,""),0)))); j=j+1; }); UI(`ReplaceWidget(`id(`io_repl), `SelectionBox(`id(`io),_("IO address (PORT)"), IO_list))); UI(`ReplaceWidget(`id(`irq_repl), `SelectionBox(`id(`irq),_("IRQ"), IRQ_list))); UI(`ReplaceWidget(`id(`mem_repl), `SelectionBox(`id(`mem),_("MemBase"), MEM_list))); } ret = UI(`UserInput()); } // If you click on NEXT button, contents of widgets are stored into YaST2 variables if (ret == `next) if (UI(`QueryWidget(`id(`sel_card), `CurrentItem)) == nil) return `modem_detection; else { if (UI(`QueryWidget(`id(`io), `CurrentItem)) != nil) { io = sformat("%1",UI(`QueryWidget(`id(`io), `CurrentItem))); card_values = add(card_values, "I4L_IO_", tohex(tointeger(io))); } if (UI(`QueryWidget(`id(`irq), `CurrentItem)) != nil) { irq = sformat("%1",UI(`QueryWidget(`id(`irq), `CurrentItem))); card_values = add(card_values, "I4L_IRQ_", irq); } if (UI(`QueryWidget(`id(`mem), `CurrentItem)) != nil) { membase = sformat("%1",UI(`QueryWidget(`id(`mem), `CurrentItem))); card_values = add(card_values, "I4L_MEMBASE_", tohex(tointeger(membase))); } if (lookup(TYPES_ISDN,UI(`QueryWidget(`id(`sel_card), `CurrentItem))) != nil) { type = sformat("%1",lookup(TYPES_ISDN,UI(`QueryWidget(`id(`sel_card), `CurrentItem)))); card_values = add(card_values, "I4L_TYPE_", type); } if (lookup(SUBTYPES_ISDN,UI(`QueryWidget(`id(`sel_card), `CurrentItem))) != nil) { subtype = sformat("%1",lookup(SUBTYPES_ISDN,UI(`QueryWidget(`id(`sel_card), `CurrentItem)))); card_values = add(card_values, "I4L_SUBTYPE_", subtype); } // Filter PCMCIA devices for NETCONFIG_PCMCIA if (lookup(CLASS_ISDN,UI(`QueryWidget(`id(`sel_card), `CurrentItem))) != nil) { cl = lookup(CLASS_ISDN,UI(`QueryWidget(`id(`sel_card), `CurrentItem))); if (cl == 4) isdn_pcmcia = true; } ISDN_desc = lookup(DESC_ISDN,(UI(`QueryWidget(`id(`sel_card), `CurrentItem))),""); isdn_det = true; return `ISP_sel; } else if (ret == `back) return `modem_detection; else if (ret == `cancel) return `cancel; }; //ISP selection screen for modem and ISDN device //Parameters: - //Return value: `device_cfg (if NEXT was pressed) or `modem_detection (BACK) define ISP_sel() ``{ string help = ""; read_cfg_modem(location,true); if (isdn_det) read_cfg_ISDN(); sbox_entry = []; // Making content of SelectionBox with ISPs (stored as sbox_entry list) tmp = maplist(`key, `value, providers_names, ``{ if (key == selected_provider) sbox_entry = add(sbox_entry,`item(`id(key),value, true)); else sbox_entry = add(sbox_entry,`item(`id(key),value, false)); }); // "Generic" ISP added (if there wasn't any ISP selected, this entry is default if ((selected_provider == "") || (selected_provider == nil)) // "Empty" ISP sbox_entry = flatten([ [`item(`id(""),_("New"),true)], sbox_entry]); else sbox_entry = flatten([ [`item(`id(""),_("New"),false)], sbox_entry]); term contents = `HSquash(`VBox( //Location of Call-by-Call providers (UK, Germany and USA) filter `Frame(_("Provider location"),`RadioButtonGroup(`id(`loc), `HBox( `RadioButton(`id(`ger),`opt(`notify),_("Germany"), (location == "`ger")), `RadioButton(`id(`UK),`opt(`notify),_("UK"), (location == "`UK")), `RadioButton(`id(`USA),`opt(`notify),_("USA"), (location == "`USA")) ,`HStretch()))), `ReplacePoint(`id(`prov),`SelectionBox(`id(`cbc),`opt(`notify), _("Select a provider: "), sbox_entry)), `HBox( `HWeight(20,`TextEntry(`id(`tel_no),_("Phone number"),tel_no)), `HWeight(80,`HStretch())), `HBox( `HWeight(40,`TextEntry(`id(`username),_("User ID"),username)), `HWeight(40,`Password(`id(`pass),_("Password"),pass)) ) )); string current_provider = ""; //Predefined provider's selection (for these providers Tel. No, Username and Password values are set help = UI(_("<P>Please choose:<UL><LI> <I>new</I> and enter the <I>tel. no., login</I> and <I>password,</I></LI><LI>or select a predefined Call-by-Call provider from the list for your country,</LI><LI>or edit the current settings, please choose the item <I>edit</I>.</LI></UL></P>")); any ret = UI(`ShowPage(_("Internet access - Provider configuration"),contents,help,true,true)); repeat { //If there was change in SelectionBox phone, username and password are updated if (ret == `cbc) { current_provider = UI(`QueryWidget(`id(`cbc), `CurrentItem)); if (current_provider != "") { tel_no = lookup(lookup(providers, current_provider,""), "Phone", ""); username = lookup(lookup(providers, current_provider, ""), "Username", ""); pass = lookup(lookup(providers, current_provider, ""), "Password", ""); if (lookup(lookup(providers,current_provider,""),"Compuserve","") == "1") compuserve = true; else compuserve = false; if (lookup(lookup(providers,current_provider,""),"Stupid Mode","") != "1") stupid = false; else stupid = true; } else { tel_no = ""; username = ""; pass = ""; compuserve = false; stupid = true; } UI(`ChangeWidget(`id(`tel_no), `Value, tel_no)); UI(`ChangeWidget(`id(`username), `Value, username)); UI(`ChangeWidget(`id(`pass), `Value, pass)); ret = UI(`UserInput()); } else if ((ret == `ger)||(ret == `UK)||(ret == `USA)) { location = sformat("%1",ret); read_cfg_modem(location,false); if (isdn_det) read_cfg_ISDN(); sbox_entry = []; tmp = maplist(`key, `value, providers_names, ``{ if (key == selected_provider) sbox_entry = add(sbox_entry,`item(`id(key),value, true)); else sbox_entry = add(sbox_entry,`item(`id(key),value, false)); }); if ((selected_provider == "") || (selected_provider == nil)) sbox_entry = flatten([ [`item(`id(""),_("New"),true)], sbox_entry]); else sbox_entry = flatten([ [`item(`id(""),_("New"),false)], sbox_entry]); //Let user to select provider UI(`ReplaceWidget(`id(`prov),`SelectionBox(`id(`cbc),`opt(`notify),_("Select a provider"), sbox_entry))); UI(`ChangeWidget(`id(`tel_no), `Value, "")); UI(`ChangeWidget(`id(`username), `Value, "")); UI(`ChangeWidget(`id(`pass), `Value, "")); tel_no = ""; username = ""; pass = ""; ret = UI(`UserInput()); } } until (ret == `next || ret == `back || ret == `cancel); // If you click on NEXT button, contents of widgets are stored into YaST2 variables if (ret == `next) { selected_provider = UI(`QueryWidget(`id(`cbc), `CurrentItem)); username = UI(`QueryWidget(`id(`username), `Value)); pass = UI(`QueryWidget(`id(`pass), `Value)); tel_no = UI(`QueryWidget(`id(`tel_no), `Value)); if (is_valid(`ISP_sel,UI(_("Telephone number")),tel_no,"ve") != `ISP_sel) return `device_cfg; else return `ISP_sel; } else if (ret == `back) return `modem_detection; else if (ret == `cancel) return `cancel; }; //ISDN configuration screen //Parameters: - //Return value: `ISP_sel (BACK) or `ISDN_net_cfg (NEXT) define ISDN_cfg() ``{ string help = UI(_("<P>Please enter the parameters for your internet connection.</P>")); // If this screen wasn't already shown, defaults from cfg file are used if (msn == "") msn = lookup(i4l_rc_config_entries,"I4L_LOCALMSN_"+dev_num,"0"); if (protocol == 0) { if (lookup(i4l_hardware_entries,"I4L_PROTOCOL_"+card_num,"") == "1") protocol = 1; else if (lookup(i4l_hardware_entries,"I4L_PROTOCOL_"+card_num,"") == "3") protocol = 3; else protocol = 2; } if (callback_mode == "") if (lookup(i4l_rc_config_entries,"I4L_CALLBACK_"+dev_num,"") != nil) callback_mode = lookup(i4l_rc_config_entries,"I4L_CALLBACK_"+dev_num,""); if (dial_mode == "") if (lookup(i4l_rc_config_entries,"I4L_DIALMODE_"+dev_num,"") != nil) dial_mode = lookup(i4l_rc_config_entries,"I4L_DIALMODE_"+dev_num,""); term contents = `HSquash(`VBox( `TextEntry(`id(`msn), _("Local number (MSN)"),msn), `HStretch(), `HBox( //Type of ISDN protocol `Frame(_("ISDN protocol"),`RadioButtonGroup(`id(`protocol), `VBox( `Left(`RadioButton(`id(`prot_1),lookup(isdn_prot,1),(protocol == 1))), `Left(`RadioButton(`id(`prot_2),lookup(isdn_prot,2),((protocol == 0)||(protocol == 2)))), `Left(`RadioButton(`id(`prot_3),lookup(isdn_prot,3),(protocol == 3))) ))), //ISDN callback mode selection `Frame(_("ISDN Callback configuration"),`RadioButtonGroup(`id(`callback), `VBox( `Left(`RadioButton(`id(`in),_("Callback Server"),(callback_mode == "in"))), `Left(`RadioButton(`id(`out),_("Callback Client"),(callback_mode == "out"))), `Left(`RadioButton(`id(`off),_("Callback Off"),(callback_mode == "off")||(callback_mode == ""))) )))), `HBox( //Type of device (isdn0/ippp0) selection `Frame(_("Network device type"),`RadioButtonGroup(`id(`netdev), `VBox( `Left(`RadioButton(`id(`ippp0),_("ISDN SyncPPP"),((net_dev == "ippp0")||(net_dev == "")))), `Left(`RadioButton(`id(`isdn0),_("ISDN Raw IP"),(net_dev == "isdn0"))) ))), //Dial mode selection `Frame(_("Dial mode"),`RadioButtonGroup(`id(`dial), `VBox( //Automatic dial mode `Left(`RadioButton(`id(`auto),_("Automatic"),((dial_mode == "auto")||(dial_mode == "")))), //Manual dial mode `Left(`RadioButton(`id(`manual),_("Manual"),(dial_mode == "manual"))), //Dial mode off `Left(`RadioButton(`id(`off),_("Off"),(dial_mode == "off"))) )))), `CheckBox(`id(`only_root), _("ISDN access for 'root' only"), (isdn4all == "no")) )); any ret = UI(`ShowPage(_("Internet access - ISDN configuration"),contents,help,true,true)); // Data from form are stored msn = UI(`QueryWidget(`id(`msn), `Value)); if (UI(`QueryWidget(`id(`only_root), `Value))) { isdn4all = "no"; } else { isdn4all = "yes"; } if (UI(`QueryWidget(`id(`prot_1), `Value))) protocol = 1; else if (UI(`QueryWidget(`id(`prot_2), `Value))) protocol = 2; else if (UI(`QueryWidget(`id(`prot_3), `Value))) protocol = 3; if (UI(`QueryWidget(`id(`in), `Value))) callback_mode = "in"; else if (UI(`QueryWidget(`id(`out), `Value))) callback_mode = "out"; else if (UI(`QueryWidget(`id(`off), `Value))) callback_mode = "off"; if (UI(`QueryWidget(`id(`ippp0), `Value))) net_dev = "ippp0"; else if (UI(`QueryWidget(`id(`isdn0), `Value))) net_dev = "isdn0"; if (UI(`QueryWidget(`id(`auto), `Value))) dial_mode = "auto"; else if (UI(`QueryWidget(`id(`manual), `Value))) dial_mode = "manual"; else if (UI(`QueryWidget(`id(`off), `Value))) dial_mode = "off"; if (ret == `next) { if (is_valid(`device_cfg,UI(_("Local number (MSN)")),msn,"ve") != `device_cfg) return `ISDN_net_cfg; else return `device_cfg; } else if (ret == `back) return `ISP_sel; else if (ret == `cancel) return `cancel; }; //ISDN network configuration screen //Parameters: - //Return value: `ISP_sel (BACK) or `save_cfg (NEXT) define ISDN_net_cfg() ``{ //Configuration of local IP address and remote IP address for Peer-to-Peer internet connection // html-format string help = UI(_("<P>You need to enter a local IP address and a remote IP address for your ISP.</P> ")); help = help + UI(_("<P>If your provider supports dynamic DNS assignment, you can choose the appropriate checkbox. All major ISPs support this feature.</P>")); integer i = 0; //Select default address for IP_local if (IP_local == "") tmp = maplist(`IP_entry, def_IPs, ``{ while (i <= 3) { if ((i != tointeger(dev_num)) && (lookup(if_configs,i,"") != "") && ((lookup(active,i,"") == "1") || (lookup(active_pcmcia,i,"") == "1"))) { if_conf = split(lookup(if_configs,i,"")," "); IP = []; netmask = []; net = false; IP = strtoaddr(select(if_conf,0)); tmp = maplist (`entry, if_conf, ``{ if (net) { netmask = strtoaddr(entry); net = false; } if (entry == "netmask") net = true; }); if ((netmask != [])&&(IP != [])&&(IP_entry+"99" != "")) if (getnet(IP,netmask) == getnet(strtoaddr(IP_entry+"99"),netmask)) { IP_local = IP_entry+"99"; break; } } i = i+1; } if ((0 == size(active)) && (0 == size(active_pcmcia))) IP_local = IP_entry+"99"; }); i = 0; //Select default address for IP_rem if (IP_rem == "") tmp = maplist(`IP_entry, def_IPs, ``{ while (i <= 3) { if ((i != tointeger(dev_num)) && (lookup(if_configs,i,"") != "") && ((lookup(active,i,"") == "1") || (lookup(active_pcmcia,i,"") == "1"))) { if_conf = split(lookup(if_configs,i,"")," "); IP = []; netmask = []; net = false; IP = strtoaddr(select(if_conf,0)); tmp = maplist (`entry, if_conf, ``{ if (net) { netmask = strtoaddr(entry); net = false; } if (entry == "netmask") net = true; }); if ((netmask != [])&&(IP != [])&&(IP_entry+"1" != "")) if (getnet(IP,netmask) == getnet(strtoaddr(IP_entry+"1"),netmask)) { IP_rem = IP_entry+"1"; break; } } i = i+1; } if ((0 == size(active)) && (0 == size(active_pcmcia))) IP_rem = IP_entry+"1"; }); term contents = `HSquash(`VBox( `Left(`TextEntry(`id(`IP_local), _("Local IP address of your machine"),IP_local)), //IP address of Peer for Point-to-Point connection `Left(`TextEntry(`id(`IP_rem), _("Remote IP address"),IP_rem)), `Left(`CheckBox(`id(`dynamic), _("Dynamic IP address"),dynamic)), `Left(`CheckBox(`id(`dynDNS), _("Dynamic DNS assignment"),dynDNS)), `Left(`CheckBox(`id(`boot), _("Start ISDN during system boot"),boot)) )); any ret = UI(`ShowPage(_("Internet access - ISDN network configuration"),contents,help,true,true)); // Data from form are stored IP_local = UI(`QueryWidget(`id(`IP_local), `Value)); dynamic = UI(`QueryWidget(`id(`dynamic), `Value)); IP_rem = UI(`QueryWidget(`id(`IP_rem), `Value)); dynDNS = UI(`QueryWidget(`id(`dynDNS), `Value)); boot = UI(`QueryWidget(`id(`boot), `Value)); if (ret == `next) { i = 0; list if_conf = []; list IP = []; list netmask = []; boolean net = false; string conflict = ""; string conflict_adr = ""; while (i <= 3) { if ((i != tointeger(dev_num)) && (lookup(if_configs,i,"") != "") && ((lookup(active,i,"") == "1") || (lookup(active_pcmcia,i,"") == "1"))) { if_conf = split(lookup(if_configs,i,"")," "); IP = []; netmask = []; net = false; IP = strtoaddr(select(if_conf,0)); tmp = maplist (`entry, if_conf, ``{ if (net) { netmask = strtoaddr(entry); net = false; } if (entry == "netmask") net = true; }); if ((netmask != [])&&(IP != [])&&(IP_local != "")) if (getnet(IP,netmask) == getnet(strtoaddr(IP_local),netmask)) { conflict_adr = UL(_("Local")); conflict = lookup(net_devs,0,""); break; } if ((netmask != [])&&(IP != [])&&(IP_rem != "")) if (getnet(IP,netmask) == getnet(strtoaddr(IP_rem),netmask)) { conflict_adr = UI(_("Remote")); conflict = lookup(net_devs,0,""); break; } } i = i+1; } if (conflict != "") { //If input Local IP address conflicts which existing network user is needed to set it again help = sformat(UI(_("You can't use this <B>IP address (%1)</B>, because it is part of an existing, already configured network. Please choose another address ...")),conflict_adr); contents = `HSquash(`VBox( `Label(sformat(UI(_("ISDN network conflicts with %1 network device")),conflict)), `Label(sformat(_("Please set your %1 address again"))))); ret = UI(`ShowPage(_("Network device conflict"),contents,help,true,true)); return `ISDN_net_cfg; } else { if ((is_valid(`ISDN_net_cfg,UI(_("Local IP address of your machine")),IP_local,"ie") != `ISDN_net_cfg) &&(is_valid(`ISDN_net_cfg,UI(_("Remote IP address of the P-t-P partner")),IP_rem,"ie") != `ISDN_net_cfg)) return `save_cfg; else return `ISDN_net_cfg; } } else return `device_cfg; }; //modem configuration screen //Parameters: - //Return value: `ISP_sel (BACK) or `save_cfg (NEXT) define modem_cfg() ``{ // If this screen wasn't already shown, defaults from cfg file are used string help = ""; //Setting of Modem specific parameters help = UI(_("<P>If you are on a PBX, you probably have to enter a <B>dial prefix</B>. Often this is <I>9</I>.</P><P> Most of the telephone companies use <I>tone dial</I> as the <B>dial method</B>.</P> ")); help = help + UI(_("<P>You can adjust the INIT strings for your device. This could be neccessary if you are using a terminal adapter or some special modems.</P> ")); if (prefix == "") prefix = lookup(lookup(providers,"Dialer Defaults",""),"Area Code",""); if (baud == "") baud = lookup(lookup(providers,"Dialer Defaults",""),"Baud",""); if (init1 == "") init1 = lookup(lookup(providers,"Dialer Defaults",""),"Init1",""); if (init2 == "") init2 = lookup(lookup(providers,"Dialer Defaults",""),"Init2",""); if (init3 == "") init3 = lookup(lookup(providers,"Dialer Defaults",""),"Init3",""); if (verbose == nil) if (lookup(lookup(providers,"Dialer Defaults",""),"Init9","") == "ATM0") verbose = false; else verbose = true; if (lookup(lookup(providers,"Dialer Defaults",""),"Area Code","") == "") pbx = true; else pbx = false; if (tone_dial == nil) if(filterchars(lookup(lookup(providers,"Dialer Defaults",""),"Dial Command",""),"P") == "P") tone_dial = false; else tone_dial = true; term contents = `HSquash(`VBox( `HBox( //Area Code prefix `TextEntry(`id(`prefix), _("Dial prefix(if needed)"),prefix), //Modem BaudRate `TextEntry(`id(`baud), _("BaudRate"), baud)), `Frame(_("Modem initialization strings"),`VBox( `TextEntry(`id(`init1), _("Init 1"), init1), `TextEntry(`id(`init2), _("Init 2"), init2), `TextEntry(`id(`init3), _("Init 3"), init3) )), `HBox( //Modem baudrate `Frame(_("Dial mode"),`RadioButtonGroup(`id(`dial), `VBox(`Left(`RadioButton(`id(`tone),_("Tone dialing"),tone_dial)), `Left(`RadioButton(`id(`pulse),_("Pulse dialing"),!tone_dial)) )) ), //Set modem to be loud `CheckBox(`id(`verbose), _("Turn on modem speaker"),verbose) ) ) ); any ret = UI(`ShowPage(_("Internet access - Modem configuration"),contents,help,true,true)); // Data from form are stored baud = UI(`QueryWidget(`id(`baud), `Value)); init1 = UI(`QueryWidget(`id(`init1), `Value)); init2 = UI(`QueryWidget(`id(`init2), `Value)); init3 = UI(`QueryWidget(`id(`init3), `Value)); prefix = UI(`QueryWidget(`id(`prefix), `Value)); tone_dial = UI(`QueryWidget(`id(`tone), `Value)); verbose = UI(`QueryWidget(`id(`verbose), `Value)); if (prefix != "") pbx = true; else pbx = false; if (ret == `next) { if ((is_valid(`device_cfg,UI(_("Dial Prefix")),prefix,"v") != `device_cfg) &&(is_valid(`device_cfg,UI(_("Baud Rate")),baud,"b") != `device_cfg)) return `save_cfg; else return `device_cfg; } else if (ret == `back) return `ISP_sel; else if (ret == `cancel) return `cancel; }; //Save configuration into /etc/wvdial.conf //Parameters: res_modem (may MODEM entry be deleted? - before autodetection) //Retrun value: - define save_cfg_modem (boolean res_modem) ``{ list cont = []; list rev_cfg = []; string dial_str = "AT"; string help = ""; any ret = nil; //Finish of modem internet connection configuration help = UI(_("<P><B>Congratulations!!!</B></P><P>Internet connection configuration is finished.</P>")); tmp = maplist(`isp, `keys, providers, ``{ // Update defaults section of cfg file from user's inputs and convert // YaST2 cfg structure back into the AnyAgent structure if (isp == "Dialer Defaults") { if (res_modem) ret = Shell(wvdial_write_section+" 'Modem='"); else { ret = Shell(wvdial_write_section+" 'Baud="+baud+"'"); if (ret == 0) ret = Shell(wvdial_write_section+" 'Phone="+tel_no+"'"); if (ret == 0) ret = Shell(wvdial_write_section+" 'Username="+username+"'"); if (ret == 0) ret = Shell(wvdial_write_section+" 'Password="+pass+"'"); if (ret == 0) ret = Shell(wvdial_write_section+" 'Init1="+init1+"'"); if (ret == 0) ret = Shell(wvdial_write_section+" 'Init2="+init2+"'"); if (ret == 0) ret = Shell(wvdial_write_section+" 'Init3="+init3+"'"); if (ret == 0) ret = Shell(wvdial_write_section+" 'Area Code="+prefix+"'"); if (ret == 0) { if (compuserve) ret = Shell(wvdial_write_section+" 'Compuserve=1'"); else ret = Shell(wvdial_write_section+" 'Compuserve=0'"); } if (ret == 0) { if (stupid) ret = Shell(wvdial_write_section+" 'Stupid Mode=1'"); else ret = Shell(wvdial_write_section+" 'Stupid=0'"); } if (ret == 0) { if (verbose) ret = Shell(wvdial_write_section+" 'Init9='"); else ret = Shell(wvdial_write_section+" 'Init9=ATM0'"); } if (pbx) dial_str = dial_str + "X3"; if (tone_dial) dial_str = dial_str + "DT"; else dial_str = dial_str + "DP"; if (ret == 0) ret = Shell(wvdial_write_section+" 'Dial Command="+dial_str+"'"); if (ret == 0) ret = Shell(wvdial_write_section+" 'Auto DNS=1'"); } } }); if (ret != 0) { help = UI(_("<P>Configuration failed due to configuration writing error.</P><P>You must run configuration as <B>root</B> user!</P>")); term contents = `HSquash(`VBox( `Label(_("Configuration failed")), `Label(_("I wasn't able to write your configuration to /etc/wvdial.conf")))); ret = UI(`ShowPage(_("Internet access configuration"),contents,help,true,false)); if ((ret == `next)&&(!res_modem)) return `next; else if (ret == `cancel) return `cancel; else return `back; } else if (!res_modem) { term contents = `HSquash(`VBox( `Label(_("Configuration completed")), `Left(`Label(_("To dial into the internet, type wvdial in a terminal window or on the console."))), `Left(`Label(_("The first connection must be established as user root."))))); ret = UI(`ShowPage(_("Internet access configuration"),contents,help,true,false)); if (ret == `back) return `device_cfg; else if (ret == `cancel) return `cancel; else return `next; } }; //Save configuration for ISDN //Parameters: - //Return value: - define save_cfg_ISDN () ``{ string help = ""; any fillup = nil; any en_k = nil; any en_v = nil; void|term contents = nil; help = UI(_("<P><B>Congratulations!!!</B></P><P>ISDN Internet connection configuration is finished.</P>")); pap_secrets = []; chap_secrets = []; list ippp_options_new = []; list i4l_rc_config_new = []; list i4l_hardware_new = []; pap_secrets_int = add(pap_secrets_int,"\""+unquote(username)+"\"", $["server" : "*", "secret" : "\""+unquote(pass)+"\""]); chap_secrets_int = add(chap_secrets_int,"\""+unquote(username)+"\"", $["server" : "*", "secret" : "\""+unquote(pass)+"\""]); ippp_options_int = add(ippp_options_int,"user","\""+unquote(username)+"\""); ippp_options_int = add(ippp_options_int,"name","\""+unquote(username)+"\""); if (msn != nil) i4l_rc_config_entries = add (i4l_rc_config_entries,"I4L_LOCALMSN_"+dev_num,msn); if ((tel_no != nil)&&(tel_no != "")) i4l_rc_config_entries = add (i4l_rc_config_entries,"I4L_REMOTE_OUT_"+dev_num,tel_no); if (net_dev == "isdn0") i4l_rc_config_entries = add (i4l_rc_config_entries,"I4L_ENCAP_"+dev_num,"rawip"); else i4l_rc_config_entries = add (i4l_rc_config_entries,"I4L_ENCAP_"+dev_num,"syncppp"); if ((dial_mode != nil)&&(dial_mode != "")) i4l_rc_config_entries = add (i4l_rc_config_entries,"I4L_DIALMODE_"+dev_num,dial_mode); if ((callback_mode != nil)&&(callback_mode != "")) i4l_rc_config_entries = add (i4l_rc_config_entries,"I4L_CALLBACK_"+dev_num,callback_mode); if (callback_mode == "in") i4l_rc_config_entries = add (i4l_rc_config_entries,"I4L_CBDELAY_"+dev_num,"3"); else i4l_rc_config_entries = add (i4l_rc_config_entries,"I4L_CBDELAY_"+dev_num,"1"); // Hardware foreach(`k, `v, card_values, ``{ i4l_hardware_entries = add (i4l_hardware_entries,k+card_num,v); }); if ((protocol != nil)&&(protocol != "")) i4l_hardware_entries = add (i4l_hardware_entries,"I4L_PROTOCOL_"+card_num,sformat("%1",protocol)); net_devs = add(net_devs,tointeger(dev_num),net_dev); if ((IP_local != "")&&(IP_rem != "")) if_configs = add(if_configs,tointeger(dev_num),sformat("%1 dynamic pointopoint %2 netmask 255.255.255.255 up",IP_local,IP_rem)); else if_configs = add(if_configs,tointeger(dev_num),""); map rc_config_write = $[]; integer i = 0; while (i <= 3) { rc_config_write = add(rc_config_write,"NETDEV_"+sformat("%1",i),[lookup(net_devs,i), "Device attached to network card"]); rc_config_write = add(rc_config_write,"IFCONFIG_"+sformat("%1",i),[lookup(if_configs,i), "ifconfig entry for network card"]); i=i+1; } if (dynamic) rc_config_write = add(rc_config_write,"IP_DYNIP",["yes", "Do you want the \"dynamic IP patch\" to be enabled at bootup? (yes/no)"]); else rc_config_write = add(rc_config_write,"IP_DYNIP",["no", "Do you want the \"dynamic IP patch\" to be enabled at bootup? (yes/no)"]); if (boot) rc_config_write = add(rc_config_write,"I4L_START",["yes","Start ISDN during system boot"]); else rc_config_write = add(rc_config_write,"I4L_START",["no","Do not start ISDN during system boot"]); string out = ""; if (isdn_pcmcia) { active_pcmcia = add(active_pcmcia, tointeger(dev_num),"1"); tmp = maplist(`key, `value, active_pcmcia, ``{ out = out + sformat("_%1 ",key); }); rc_config_write = add(rc_config_write,"NETCONFIG_PCMCIA", [out,"contains all indices of active PCMCIA network devices"]); } else { active = add(active, tointeger(dev_num),"1"); tmp = maplist(`key, `value, active, ``{ out = out + sformat("_%1 ",key); }); rc_config_write = add(rc_config_write,"NETCONFIG",[out,"Number of network cards: \"_0\" for one, \"_0 _1 _2 _3\" for four cards"]); } rc_config_write = add(rc_config_write,"ISDN4ALL",[isdn4all,"Any user may dialout via ISDN ?"]); tmp = maplist(`entry, i4l_rc_config, ``{ en_k = lookup(entry, "key"); fillup = lookup(entry, "`FILLUP"); en_v = lookup(i4l_rc_config_entries, en_k); if (en_v == nil) { i4l_rc_config_new = add(i4l_rc_config_new, entry); } else { i4l_rc_config_new = add(i4l_rc_config_new, $["key":en_k,"value":"\""+en_v+"\"","`FILLUP":fillup]); } }); tmp = maplist(`entry, i4l_hardware, ``{ en_k = lookup(entry, "key"); fillup = lookup(entry, "`FILLUP"); en_v = lookup(i4l_hardware_entries, en_k); if (en_v == nil) { i4l_hardware_new = add(i4l_hardware_new, entry); } else { i4l_hardware_new = add(i4l_hardware_new, $["key":en_k,"value":"\""+en_v+"\"","`FILLUP":fillup]); } }); tmp = maplist(`key, `value, pap_secrets_int, ``{ pap_secrets = add(pap_secrets,$["client":key,"server":lookup(value,"server",""),"secret":lookup(value,"secret","")]); }); tmp = maplist(`key, `value, chap_secrets_int, ``{ chap_secrets = add(chap_secrets,$["client":key,"server":lookup(value,"server",""),"secret":lookup(value,"secret","")]); }); tmp = maplist(`entry, ippp_options, ``{ en_k = lookup(entry, "key",""); fillup = lookup(entry, "`FILLUP"); en_v = lookup(ippp_options_int, en_k,""); if (en_v == nil) { ippp_options_new = add(ippp_options_new, entry); } else { if (en_k != "ms-get-dns") { ippp_options_new = add(ippp_options_new, $["key":en_k,"value":en_v,"`FILLUP":fillup]); } } }); if (dynDNS) { ippp_options_new = add(ippp_options_new, $["key":"ms-get-dns", "value":"", "`FILLUP":"# Get dns info from peer\n"]); } any ret = SCR(`Write(.etc.ppp.pap_secrets, pap_secrets)); if (ret != false) ret = SCR(`Write(.etc.ppp.chap_secrets, chap_secrets)); if (ret != false) ret = SCR(`Write(.etc.ppp.ioptions, ippp_options_new)); if (ret != false) ret = SCR(`Write(.etc.i4l,i4l_rc_config_new)); if (ret != false) ret = SCR(`Write(.etc.i4l_hw,i4l_hardware_new)); if (ret != false) { ret = SCR(`Write(.etc.rcconfig,rc_config_write)); Shell("/sbin/SuSEconfig --quick --nonewpackage"); } //Set default route if needed list|any routes = SCR(`Read(.etc.route_conf)); route = true; if (routes != nil) tmp = maplist(`entry, routes, ``{ if (lookup(entry,"key") == "default") { i = 0; tmp2 = maplist (`entry2, split(lookup(entry,"value")," "), ``{ if ((entry2 == "ippp0")||(entry2 == "isdn0")) i = i + 1; }); if (i == 0) route = false; } }); if (route) { Shell("touch /etc/route.conf"); Shell("mv /etc/route.conf /etc/route.conf.old"); Shell("grep -v '^[ ]*default.*ippp0' /etc/route.conf.old > /etc/route.conf.tmp"); Shell("grep -v '^[ ]*default.*isdn0' /etc/route.conf.tmp > /etc/route.conf.tmp2"); Shell("grep -v '# yast2 default' /etc/route.conf.tmp2 > /etc/route.conf"); Shell("rm -f /etc/route.conf.tmp"); Shell("rm -f /etc/route.conf.tmp2"); Shell("echo '# yast2 default entry for "+net_dev+"' >> /etc/route.conf"); Shell("echo default "+IP_rem+" 0.0.0.0 "+net_dev+" >> /etc/route.conf"); } //Check if there is ippp0 running and restart it if it's needed if (ReadString("/var/run/ipppd.ippp0.pid") != nil) { Shell("/usr/sbin/rci4l stop"); Shell("/usr/sbin/rci4l_hardware stop"); Shell("/usr/sbin/rci4l_hardware start"); Shell("/usr/sbin/rci4l start"); } if (ret != false) contents = `HSquash(`VBox( `Label(_("Configuration completed")), `Left(`Label(_("All required information has been saved succesfully."))), `Left(`Label(_("You can start ISDN service manually by typing the commands"))), `Left(`Label(_("\"rci4l_hardware start\" and \"rci4l start\"."))))); else { contents = `HSquash(`VBox( //Saving configuration failed `Label(_("Configuration failed due to writing error")), `Label(_("You must run ISDN configuration as a <B>root</B> user!")))); help = UI(_("Saving failed")); } ret = UI(`ShowPage(_("Internet access configuration"),contents,help,true,false)); if (ret == `back) return `ISDN_net_cfg; else if (ret == `cancel) return `cancel; else return `next; }; UI(``{ //Creates YaST2 screen //Parameters: t (string) - title of screen // c (term) - contents of screen // enable_back (boolean) - is BACK button enabled? // regular_next (boolean) - is label of NEXT button "next"? //Return value: return value of UserInput() function define ShowPage( string t, term c, string help, boolean enable_back, boolean regular_next ) ``{ ChangeWidget(`id(`title), `Value, t); ChangeWidget(`id(`help), `Value, help); ChangeWidget(`id(`back), `Enabled, enable_back); string next_label = _("&Next"); if (!regular_next) next_label = _("&Finish"); ChangeWidget(`id(`next), `Label, next_label); ReplaceWidget(`id(`contents), c); return UserInput(); }; OpenDialog( `opt(`defaultsize), `VBox( `Image(`suseheader, "SuSE"), `HBox(`HWeight(30, `RichText(`id(`help), "")), `HWeight(70, `VBox( `Left(`Label(`id(`title), _("Internet Connection Configuration") )), `HVCenter(`ReplacePoint(`id(`contents), `Empty())), `HBox( `PushButton(`id(`back), `opt(`disabled), _("&Back")), `HStretch(), `PushButton(`id(`next), _("&Next")) )))))); }); symbol|void stage = nil; stage = `modem_detection; while (true) { if (stage == `ISP_sel) stage = ISP_sel(); else if ((stage == `save_cfg) && (!isdn_det)) stage = save_cfg_modem(false); else if ((stage == `save_cfg) && (isdn_det)) stage = save_cfg_ISDN(); else if ((stage == `ISDN_net_cfg) && (isdn_det)) stage = ISDN_net_cfg(); else if ((stage == `device_cfg) && (!isdn_det)) stage = modem_cfg(); else if ((stage == `device_cfg) && (isdn_det)) stage = ISDN_cfg(); else if (stage == `check_devices) stage = check_devices(); else if (stage == `modem_detection) stage = modem_detection(); else if (stage == `ISDN_man) stage = ISDN_man(); else break; } UI(``{ CloseDialog(); }); return stage; }