home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 2000-03-30 | 54.2 KB | 2,167 lines
/* * * Module: lan.ycp * * Author: Stepan Marek (marek@suse.cz) * * Purpose: * - autodetect network cards and install kernel module for eth0 device * - set static IP address or dynamic IP address via DHCP for eth0. * - set hostname and configure DNS access. * - initial values are read from previous done configuration. * - compatibility with YaST1 configurations is preserved * - configuration of other devices and network interfaces * ([eth1, eth2...], [isdn0, isdn1...] ...) is preserved * - create backup file with postfix .old * * Require: * - installed dhclient or dhcpd package for dynamic IP address setup * * Modify: * /etc/rc.config * /etc/modules.conf * * Create: * /etc/route.conf * * Run SuSEconfig to generate /etc/hosts, /etc/host.conf, /etc/resolv.conf * */ { boolean has_pcmcia = SCR(`Read(.probe.has_pcmcia)); boolean card_is_pcmcia = false; // 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", "")); }; // Menuentry for the YaST2 menu if (Args() == [ "get_menuentry" ]) return [ "lan", $[ `menuentry : UI(_("Network/Base")), `arguments : [ ], `widget : `RichText( // UI(_("Launch this module to configure network devices for local networks")) + UI(_("<p>You need to be logged in as <i>root</i> in order to do this.</p>"))), `codefragment : nil ] ]; UI(``{ // The main dialog. Copied from installation.ycp. OpenDialog(`opt(`defaultsize), `VBox(`Image(`suseheader, "SuSE"), `HBox(`HWeight(30, `RichText(`id(`help), "")), `HWeight(70, `VBox( `Left(`Heading(`id(`title), _("YaST2\nInitializing ..."))), `HVCenter(`ReplacePoint(`id(`contents), `Empty())), `HBox( // back pushbutton: the user input is ignored and the last dialog is called `PushButton(`id(`back), `opt(`disabled), _("&Back")), `HStretch(), // next pushbutton: the user input is checked and the next dialog is called `PushButton(`id(`next), `opt(`disabled), _("&Next")))))))); define SetContents(string title, term contents, string helptext, boolean has_back, boolean has_next) ``{ ChangeWidget(`id(`next), `Enabled, has_next); ChangeWidget(`id(`back), `Enabled, has_back); ChangeWidget(`id(`help), `Value, helptext); ChangeWidget(`id(`title), `Value, title); ReplaceWidget(`id(`contents), contents); // ControlWidget(TheWizardDialog(), `id(`next), `SetFocus()); }; define DisplayMessage(string message, integer code, string stack) ``{ // ok pushbutton: confirm the dialog term t = `VBox(); t = add(t, `Left(`Label(message))); if (code != 0) // optional warning dialog text t = add(t, `Left(`Label(sformat(_("Error code %1"), code)))); if (stack != "") t = add(t, `Left(`Label(stack))); OpenDialog(`opt(`decorated), add(t, `PushButton(_("&OK")))); UserInput(); CloseDialog(); }; }); SCR(``{ /* * AnyAgent for reading default gateway from /etc/route.conf * * return: the last 'default' ip address in ip4number format * example: $["default":168427521] * */ MountAgent ( `anyagent ( ``Description ( ``File ("/etc/route.conf"),// real file name "#\n", // Comment true, // read-only ``Tuple ( Optional (Whitespace ()), Choice ( ["default", Sequence( Whitespace (), `default (Ip4Number ()), Optional (String ("^\n")), Continue ("\n") )], [String("^\n"), Continue ("\n")] ) ) ) ), .etc.routeconf.read ); /* * AnyAgetnt for reading /etc/rc.config * * return: map of all variables * example: $["FQHOSTNAME":"linux.suse.de", "YP_DOMAINNAME":"suse.de", "umask":"022"] * */ MountAgent ( `anyagent( ``Description ( ``File ("/etc/rc.config"), // real file name "#\n", // Comment true, // read-only ``Tuple ( Optional (Whitespace ()), Name (String ("^\t =")), Optional (Whitespace ()), Separator ("="), Optional (Whitespace ()), Choice ( ["\"", Sequence ( Optional (Value (String ("^\"\n"))), Optional (String ("^\n")), Continue("\n"))], [Value (String ("^\n\t ")), Sequence ( Optional (String ("^\n")), Continue ("\n"))], [Continue ("\n"), Skip ()] ) ) ) ), .etc.rcconfig.read ); /* * AnyAgent for reading /etc/modules.conf * * read: /etc/modules.conf * return: list of all lines (including empty lines) as maps * example: * [ * $["comment":"# The first ethernet device"], * $[], * $["alias":["eth0", "ne"], "comment":"# NE2000 compatible network card"], * $["options":["ne", "irq=5", "io=0x240"]] * ] * */ MountAgent ( `anyagent( ``Description ( ``File ("/etc/modules.conf"), // ``Run ("/sbin/modprobe -c"), "", true, ``List ( Tuple ( Choice ( [ "alias", Sequence (Whitespace (), `alias ( List ( String ("^\n\t #"), Whitespace () ) ) ) ], [ "options", Sequence ( Whitespace (), `options ( List ( String ("^\n\t #"), Whitespace () ) ) ) ], [ "", Skip () ] ), `comment (Optional(String("^\n"))) ), "\n" ) ) ), .etc.modulesconf.read ); /* * AnyAgent for creating unique temporary file in /tmp directory * * run: mktemp * return: file name string of new created file or "" in case of some error * */ MountAgent (`anyagent( ``Description ( ``Run("/bin/mktemp -q /tmp/YaST2.XXXXXX; echo"), "", true, ``Or (String("^\n"), "") ) ), .run.mktemp ); /* * AnyAgent for reading ip address, broadcast and netmask (as the ip4numbers) * of running network interfaces from ifconfig output * * example: * $[ * "eth0":$["addr":168453207, "bcast":168493055, "mask":4294901760], * "lo": $["addr":2130706433, "mask":4278190080] * ] * */ MountAgent (`anyagent( ``Description ( ``Run("/sbin/ifconfig"), "\n", true, ``Tuple ( Choice ( [ Name (String ("^\t ")), String ("^\n") ], [ Whitespace (), Choice ( [ "inet", Value ( Tuple ( Optional (Whitespace ()), Choice ( [ "addr:", `addr (Ip4Number ()) ], [ "Bcast:", `bcast (Ip4Number ()) ], [ "Mask:", `mask (Ip4Number ()) ], [ String ("^\n\t "), Skip() ] ), Continue (Whitespace ()) ) ) ], [ String ("^\n"), Skip () ] ) ] ), Continue ("\n") ) ) ), .run.ifconfig ); /* * AnyAgent for reading nslookup output. * Output must must be written to /tmp/nslookup.out file before reading * After reading /tmp/nslookup.out should be removed * * return: name of dns server and name of host from dns * * example: * $["name":"Phoenix.suse.de", "server":"Wotan.suse.de"] * * usage example: * Shell("/usr/bin/nslookup -timeout=1 10.10.0.8 > /tmp/nslookup.out"); * map m = SCR(`Read(.tmp.nslookup)); * Shell("/bin/rm -f /tmp/nslookup.out"); * */ MountAgent (`anyagent( ``Description ( ``File("/tmp/nslookup.out"), "*\n", false, ``Tuple ( Choice ( [ "Server:", Sequence ( Whitespace (), `server (Hostname ()) ) ], [ "Name:", Sequence ( Whitespace (), `name (Hostname ()) ) ], [ String ("^\n"), Skip () ], [ "", Skip () ] ), Continue ("\n") ) ) ), .tmp.nslookup ); /* * AnyAgent for reading address from ping return * Usually used for geting ips of responded computer on the local network * from ping to broadcast address to check network connection of host. * * Output from ping must be saved to /tmp/ping.out before reading * * usage example: * Shell("/bin/ping -w 1 -n 10.10.255.255 > /tmp/ping.out & /bin/sleep 2; /bin/kill $!"); * list l = SCR(`Read(.tmp.ping)); * Shell("/bin/rm -f /tmp/ping.out"); * * return: list of ips (ip4number) of responded host (duplicities are preserved) * * example: * [168427521, 168427522, 168427523] */ MountAgent (`anyagent( ``Description ( ``File("/tmp/ping.out"), "", false, ``List ( Choice ( [Number (), Choice ( [" bytes from ", Ip4Number ()], ["", Skip ()] ) ], ["", Skip ()] ), Sequence (Optional (String ("^\n")), "\n") ) ) ), .tmp.ping ); }); /* * 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); 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); i = findfirstnotof(s, sep); } return l; }; /* * Join list into string with separator (complement to split) * */ define join(list l, string sep) ``{ if (size(l) == 0) return ""; string str = sformat("%1", select(l, 0)); integer i = 1; while (i < size(l)) { string s = sformat("%1", select(l, i)); if (s != "") str = str + sep + s; i = i + 1; } return str; }; /* * 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 > 255) return []; ip = add(ip, x); str = substring (str, i + 1); } else { return []; } j = j - 1; } if (size(str) > 0) return []; return ip; }; /* * Convert ip4number address into list of four interger values * * ip4toaddr(2130706432) -> [127, 0, 0, 0] * */ define ip4toaddr(integer|void ii) ``{ if (ii == nil) return []; list ip = []; integer i = 0x1000000; while (i >= 1) { ip = add(ip, ii / i); ii = ii % i; i = i / 0x100; } return ip; }; /* * Convert list of four integers into ip address string * * addrtostr([127, 0, 0, 0]) -> "127.0.0.0" * */ define addrtostr(any ip) ``{ if (ip == nil) return ""; if (ip == []) return ""; return sformat("%1.%2.%3.%4", select(ip, 0), select(ip, 1), select(ip, 2), select(ip, 3)); }; /* * 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; }; /* * Logical 'or' on boolean elements of lists * */ define or(list a, list b) ``{ list c = []; integer no = 0; integer i = size(a) - size(b); while (i < 0) { a = add(a, false); i = i + 1; } while (i > 0) { b = add(b, false); i = i - 1; } no = size(a); while (i < no) { c = add (c, select (a, i) || select(b, i)); i = i + 1; } return c; }; /* * Logical 'not' on eight boolean element of list * */ define not(list a) ``{ list b = []; integer no = size(a); integer i = 8 - size(a); while (i > 0) { a = add(a, false); i = i - 1; } i = 0; while (i < 8) { b = add (b, ! select (a, i)); i = i + 1; } return b; }; /* * Compute broadcast from ip and mask * */ define getbcast(list ip, list mask) ``{ if (ip == []) return []; if (mask == []) return [255, 255, 255, 255]; // the same as mask = [0, 0, 0, 0] integer i = 0; list bcast = []; while (i < 4) { bcast = add( bcast, bytetoint( or( inttobyte(select(ip, i)), not(inttobyte(select(mask, i))) ) ) ); i = i + 1; } return bcast; }; /* * Compute network address from ip and mask * */ define getnet (list ip, list mask) ``{ if (ip == []) return []; if (mask == []) return ip; // the same as mask = [0, 0, 0, 0] 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; }; /* * Check syntax of hostname entry * */ define chkhost(string str) ``{ if (str == "") return false; if (findfirstnotof(str, "_0123456789abcdefghijklmnopqrstuvwxyz-") != nil) return false; return true; }; /* * Check syntax of domain entry * */ define chkdomain(string str) ``{ if (str == "") return false; if (findfirstnotof(str, "._0123456789abcdefghijklmnopqrstuvwxyz-") != nil) return false; return true; }; /* * Parse options line from modules.conf to get module argument * * "options ne irq=5 io=0x240" -> ["irq=5", "io=0x240"] * */ define getargs(string s) ``{ list result = []; list l = split(s, "\n"); if (l != []) { l = split(select(l, 0), " \t"); if (l != []) { integer i = 0; if (select(l, 0) == "options") i = 2; while (i < size(l)) { result = add(result, select(l, i)); i = i + 1; } } } return result; }; /* * Try to load module if it is not already loaded * * If there are paramerets for loading modules in .probe, the parameters * are saved to the new temporary modules.conf used for modprobe. * There are two ways to get the parameters, from "conf" or "args". * * variables: * string mod_name - kernel module name string (eg. "ne") * string mod_conf - modules.conf line (eg. "options ne irq=5 io=0x240") * list mod_args - parsed mod_conf (eg. ["irq=5", "io=0x240"]) * * args: line from SCR(`Read(.probe.byclass.network) * */ define ModuleProbe (map card) ``{ map module = lookup (card, "module"); mod_name = lookup (module, "name"); mod_conf = lookup (module, "conf", ""); mod_args = []; boolean active = lookup (module, "active", true); boolean modprobe = lookup (module, "modprobe", true); string tmpfile = "/etc/modules.conf.tmp"; string param = mod_name; // fix bug in libhd for isapnp card if (mod_conf == "(null)\n") mod_conf = ""; if (mod_args != "(null)\n") mod_args = split(lookup (module, "args", ""), " \t"); // parse "conf" or "args" if (mod_conf == "") { if (mod_args != []) mod_conf = sformat("options %1\t\t%2\n", mod_name, join(mod_args, " ")); } else { mod_args = getargs(mod_conf); if (substring(mod_conf, 0, 7) != "options") mod_conf = sformat("options %1 %2", mod_name, mod_conf); } // save temporary modules.conf if (mod_conf != "") { any a = SCR(`Read(.run.mktemp)); if ((a != nil) && (a != "")) tmpfile = a; if (!WriteString(tmpfile, getmodulesconf() + "\n" + mod_conf)) { // warning dialog message UI(`DisplayMessage(_("Cannot create temporary file"), 0, tmpfile)); return false; } param = param + " -C " + tmpfile; } // kernel module loading if (active == false) { integer code = Shell("/sbin/modprobe -s " + param); if (code != 0) { // warning dialog message UI(`DisplayMessage(_("Device initialization failed"), code, // kernel module name in warning dialog sformat(UI(_("Module name %1")), mod_name))); return false; } Shell("/sbin/modprobe -r " + param); } Shell("/bin/rm -f " + tmpfile); return true; }; /* * The fist dialog - Network card autodetection * * Read network card from SCR(`Read(.probe.byclass.network)). * If there are more network cards the list with radio buttons * are displayed. * * variables: * integer card_id - line number from .probe * string card_name - card description name * */ define FindCard (any result) ``{ // label for waiting while yast2 is checking hardware string msg = UI(_("Looking for network cards on your system...")); // help text for autodetecting and network card selecting // part 1 of 2 string helptext = UI(_("<p>YaST2 autodetects <b>network cards</b> installed in your system.</p>")); // part 2 of 2 helptext = helptext + UI(_("<p> If you have more than one network card, select which one you want to configure. Click <b>next</b> button to continue with network configuration. </p>")); term con = `Label (msg); // main dialog label UI(`SetContents (_("Network configuration"), con, helptext, false, false)); list cards = []; any a = SCR(`Read(.probe.byclass.network)); if (a != nil) cards = a; // filter out unknowen devices cards = filter(`c, cards, ``(lookup(c, "module") != nil)); if (size(cards) == 0) { if (has_pcmcia) { // result of autodetection con = `Label (_("No built-in network card was detected. However a PCMCIA\ndevice was found which can be used with a PCMCIA network\ncard. Press 'Next' to continue configuration for PCMCIA\nnetwork. Pressing 'Back' will cancel network configuration.")); } else { // result of autodetection con = `Label (_("No network card was detected.")); // `Bottom (`PushButton (`id (`manual), `opt(`disabled), _("Manual"))) } UI(`SetContents (_("Network configuration"), con, helptext, true, true)); UI(`UserInput ()); if (has_pcmcia) { card_is_pcmcia = true; return `next; } else return `back; } if (size(cards) == 1) { // result of autodetection // only one network card was detected and will be configured con = `Label (sformat(UI(_("The network card\n\n%1\n\nwill be configured for network access.")), name_of_device(select(cards, 0)))); UI(`SetContents (_("Network configuration"), con, helptext, true, true)); result = UI(`UserInput ()); if (result == `next) { ModuleProbe(select(cards, id)); card_id = 0; card_name = name_of_device(select(cards, id)); } return result; } term t = `VBox(); integer i = 0; integer id = card_id; // compare module items from .probe with module parameters // from modules.conf to get which card is previousely used if (id >= size(cards)) id = -1; while (i < size(cards)) { if (id < 0) { map m = lookup(select(cards, i), "module", $[]); if (mod_name == (lookup(m, "name", ""))) { list l = []; if (lookup(m, "conf") == nil) if (lookup(m, "args") == nil) l = []; else l = split(lookup(m, "args", ""), " \t\n"); else l = getargs(lookup(m, "conf")); if (sort(mod_args) == sort(l)) id = i; } } t = add (t, `Left(`RadioButton(`id(i), `opt(`notify), name_of_device(select(cards, i)), id == i))); i = i + 1; } con = `VBox ( // result of autodetection // more network cards were detected and radio button group is displayed `Label (_("Please choose the network card you want to configure")), `HSquash (`RadioButtonGroup (`id(`rb), t)) ); UI(`SetContents (_("Network configuration"), con, helptext, true, id >= 0)); // one card must be selected do { result = UI(`UserInput ()); if (!is(result, integer)) break; if (UI(`QueryWidget(`id(`rb), `CurrentButton) != nil)) UI(`ChangeWidget(`id(`next), `Enabled, true)); } while (true); if (result == `next) { id = UI(`QueryWidget(`id(`rb), `CurrentButton)); ModuleProbe(select(cards, id)); card_id = id; card_name = name_of_device(select(cards, id)); } return result; }; /* * Address setup dialog * * read and modify global variables: * * boolean dhcp * list ip * list mask * list gateway * string ifconfig * string dhcommand * */ define AddressSetup(any result) ``{ // if (result == `back) return result; string msg = "OK"; // help text for ip address setup dialog // part 1 of 2 string helptext = UI(_("<p>This dialog provides IP address configuration.</p>")); // help text for ip address setup dialog // part 2 of 2 helptext = helptext + UI(_("<p>You can select dynamic address assignment if you have a <b>DHCP server</b> running on your local network. You also should select this if you do not have a static IP address assigned to you by your cable or DSL provider. Network addresses will then be obtained <b>automatically</b> from the server. Configuration will be <b>finished</b> by clicking the <b>next</b> button.</p> <p>Otherwise, you must assign the network addresses <b>manually</b>. Enter the IP address (e.g., 192.168.100.99) for your computer, the network mask (usually 255.255.255.0) and, optionally, the default gateway IP address. The name server setup dialog follows.</p> ")); helptext = helptext + UI(_("<p>Please contact your <b>network administrator</b> for more information about the network configuration.</p>")); boolean dhcptmp = dhcp; list iptmp = ip; list masktmp = mask; list gwtmp = gateway; list nettmp = []; list bcasttmp = []; string ipstr = ""; string maskstr = ""; string gwstr = ""; if (ip != []) ipstr = addrtostr(ip); if (mask != []) maskstr = addrtostr(mask); if (gateway != []) gwstr = addrtostr(gateway); if ((ipstr == "") && (maskstr == "")) maskstr = "255.255.255.0"; // label for radio button group (dynamic/static ip address setup method) term label = `Label (_("Choose the network address setup method")); // frame label term frame1 = `Frame (_("Dynamic address"), `Left (`RadioButton (`id(true), `opt(`notify), // radio button label _("Automatic address setup (via DHCP)"), dhcptmp == true)) ); // frame label term frame2 = `Frame (_("Static address"), `VBox ( // radio button label `Left (`RadioButton (`id(false), `opt(`notify), _("Static address setup"), dhcptmp == false)), `HSquash ( `VBox ( // text entry label for ip address `TextEntry (`id(`ip), _("IP Address"), ipstr), // text entry label for network mask `TextEntry (`id(`mask), _("Subnet mask"), maskstr), // text entry label `TextEntry (`id(`gw), _("Default gateway"), gwstr) ) ) ) ); term t = `RadioButtonGroup (`id(`rb), `HSquash ( `VBox ( frame1, frame2 ) ) ); // main dialog label UI(`SetContents (_("Network address setup"), t, helptext, true, true)); UI(`ChangeWidget(`id(`ip), `Enabled, !dhcptmp)); UI(`ChangeWidget(`id(`mask), `Enabled, !dhcptmp)); UI(`ChangeWidget(`id(`gw), `Enabled, !dhcptmp)); // loop for values checking do { result = UI(`UserInput ()); while (is(result, boolean)) { UI(`ChangeWidget(`id(`ip), `Enabled, !result)); UI(`ChangeWidget(`id(`mask), `Enabled, !result)); UI(`ChangeWidget(`id(`gw), `Enabled, !result)); result = UI(`UserInput ()); } dhcptmp = UI(`QueryWidget(`id(`rb), `CurrentButton)); ipstr = UI(`QueryWidget(`id(`ip), `Value)); maskstr = UI(`QueryWidget(`id(`mask), `Value)); gwstr = UI(`QueryWidget(`id(`gw), `Value)); iptmp = strtoaddr(ipstr); masktmp = strtoaddr(maskstr); gwtmp = strtoaddr(gwstr); msg = "OK"; if (result == `next) { if (dhcptmp) { if (dhcommand == "" ) { // warning dialog message msg = UI(_("You need to install the dhclient or dhcpcd package for dynamic IP address setup.")); dhcptmp = false; UI(`ChangeWidget(`id(`ip), `Enabled, !dhcptmp)); UI(`ChangeWidget(`id(`mask), `Enabled, !dhcptmp)); UI(`ChangeWidget(`id(`gw), `Enabled, !dhcptmp)); UI(`ChangeWidget(`id(`rb), `CurrentButton, dhcptmp)); UI(`PollInput()); } } else { if ((iptmp != []) && (masktmp != [])) { nettmp = getnet(iptmp, masktmp); bcasttmp = getbcast(iptmp, masktmp); if (gwtmp != []) if ((getnet(gwtmp, masktmp) != nettmp) || (gwtmp == nettmp) || (gwtmp == bcasttmp)) // warning dialog message // gateway address must be accessible from subnet msg = UI(_("Default gateway address is out of range")); if ((iptmp == nettmp) || (iptmp == bcasttmp)) // warning dialog message // ip address overlaps network or broadcast address msg = UI(_("IP Address is out of range")); } if ((gwstr != "") && (gwtmp == [])) // warning dialog message msg = UI(_("The default gateway is not correct")); if (masktmp == []) msg = UI(_("The subnet mask is not correct")); if (iptmp == []) msg = UI(_("The IP address is not correct")); } } if (msg == "OK") break; UI(`DisplayMessage(msg, 0, "")); } while (true); if (result == `next) { dhcp = dhcptmp; if (dhcp) { ifconfig = "dhcpclient"; } else { ifconfig = sformat("%1 broadcast %2 netmask %3", addrtostr(iptmp), addrtostr(bcasttmp), addrtostr(masktmp)); ip = iptmp; mask = masktmp; gateway = gwtmp; } } return result; }; /* * Check network address for conflict with other interfaces. * User can correct ip address and mask of your configuration * or disable conflicted devices. * * use global variable * map ifs - all configurated interfaces provided by rc.config * * set global variable * list cdev - interfaces in conflict. * they should be deactivate by NETCONFIG(_PCMCIA) value * */ define CheckInterfaces(any result) ``{ cdev = []; if (dhcp) return result; if (result != `next) return result; term con = `VBox(`Empty ()); boolean active = false; maplist(`k, `v, ifs, ``{ if ((lookup(v, "dev") != "eth0") && (lookup(v, "addr") != [])) if ((getnet(ip, mask) == getnet(lookup(v, "addr"), mask)) || (getnet(ip, lookup(v, "mask")) == lookup(v, "net"))) { cdev = add(cdev, k); if (lookup(v, "active")) active = true; con = add(con, `Left(`HBox (`CheckBox (`id(k), `opt(`disabled), "", lookup(v, "active")), `Label (sformat("%1 [%2/%3]", lookup(v, "dev"), addrtostr(lookup(v, "addr")), addrtostr(lookup(v, "mask"))))))); } }); if (!active) return `next; // help text // address conflict setup dialog // part 1 of 3 string helptext = UI(_("<p> One or more previously configured devices (such as a second network card or ISDN adapter) were found in your system. Some of them have been assigned a network address range (IP address/network mask) which <b>conflicts</b> with your new configuration. It is <b>not possible</b> to use more devices with <b>overlapping</b> network address. </p> ")); // help text // address conflict setup dialog // part 2 of 3 helptext = helptext + UI(_("<p> This dialog displays a list of all incorrectly configured devices. A checked line in the list means that device is <b>active</b>. <p> ")); // help text // address conflict setup dialog // part 3 of 3 helptext = helptext + UI(_("<p> You can select <b>next</b> and the incorrectly configured devices will be <b>deactivated</b> and <b>disabled</b>. You will not be able to use them but you can reconfigure them later. Configuration will be <b>continued</b>. </p> <p> Or you can select <b>back</b> to go back to the address setup dialog and <b>replace</b> any required IP address and network masks. </p> ")); con = `VBox ( // main dialog label // list of already configured network interfaces // ([eth1, eth2...], [isdn0, isdn1...] etc.) with // network address (ip/mask) which overlaps address // defined by user `Label (_("Conflicting network devices")), `HSquash (con) ); UI(`SetContents (_("Network configuration"), con, helptext, true, true)); result = UI(`UserInput ()); return result; }; /* * DNS setup dialog * * read and modify global variables: * * string host * string domain * list nameserver * list searchlist * */ define DNSSetup(any result) `` { if (dhcp) return result; string msg = "OK"; // help text for dns setup // part 1 of 4 string helptext = UI(_("<p>Insert the host name and domain name for your computer. Name server list and domain search list are optional.</p> ")); // help text for dns setup // part 2 of 4 helptext = helptext + UI(_("<p>A name server is a computer which translates host names into IP addresses. This value must be entered as an <b>IP address</b> (e.g., 10.10.0.1), not as a host name.</p> ")); // help text for dns setup // part 3 of 4 helptext = helptext + UI(_("<p>Search domain is the domain name where host name searching is started. The primary search domain is usually the same as the <b>domain name</b> of your computer (e.g., suse.de). There may be additional search domains (e.g., suse.com).</p> ")); // help text for dns setup // part 4 of 4 helptext = helptext + UI(_("<p>Select the <b>next</b> button to <b>save</b> your changes and <b>finish</b> the network configuration.")); // reading from global variables string hoststr = host; string domainstr = domain; // domain search default dialog strings string s1 = ""; string s2 = ""; string s3 = ""; // name server default dialog strings string nstr1 = ""; string nstr2 = ""; string nstr3 = ""; // name server ip address list ns1 = []; list ns2 = []; list ns3 = []; integer i = size(nameserver); if (i > 0) nstr1 = addrtostr(select(nameserver, 0)); if (i > 1) nstr2 = addrtostr(select(nameserver, 1)); if (i > 2) nstr3 = addrtostr(select(nameserver, 2)); i = size(searchlist); if (i > 0) s1 = select(searchlist, 0); if (i > 1) s2 = select(searchlist, 1); if (i > 2) s3 = select(searchlist, 2); term t = `HSquash ( `VBox ( `HBox ( // text entry label `TextEntry(`id(`host), _("Host name"), hoststr), // text entry label `TextEntry(`id(`domain), _("Domain name"), domainstr) ), `HBox( `Frame ( // common label for more text entries _("Name server list"), `VBox ( `TextEntry (`id(`ns1), "", nstr1), `TextEntry (`id(`ns2), "", nstr2), `TextEntry (`id(`ns3), "", nstr3) ) ), `Frame ( // common label for more text entries _("Domain search list"), `VBox ( `TextEntry (`id(`s1), "", s1), `TextEntry (`id(`s2), "", s2), `TextEntry (`id(`s3), "", s3) ) ) ) )); // main dialog label UI(`SetContents (_("Name server configuration"), t, helptext, true, true)); do { result = UI(`UserInput ()); hoststr = tolower(UI(`QueryWidget(`id(`host), `Value))); domainstr = tolower(UI(`QueryWidget(`id(`domain), `Value))); nstr1 = UI(`QueryWidget(`id(`ns1), `Value)); nstr2 = UI(`QueryWidget(`id(`ns2), `Value)); nstr3 = UI(`QueryWidget(`id(`ns3), `Value)); ns1 = strtoaddr(UI(nstr1)); ns2 = strtoaddr(UI(nstr2)); ns3 = strtoaddr(UI(nstr3)); s1 = tolower(UI(`QueryWidget(`id(`s1), `Value))); s2 = tolower(UI(`QueryWidget(`id(`s2), `Value))); s3 = tolower(UI(`QueryWidget(`id(`s3), `Value))); msg = "OK"; if (result == `next) { if (!((s3 == "") || chkdomain(s3))) msg = UI(_("The tertiary search domain is not correct")); if (!((s2 == "") || chkdomain(s2))) msg = UI(_("The secondary search domain is not correct")); if (!((s1 == "") || chkdomain(s1))) msg = UI(_("The primary search domain is not correct")); if ((nstr3 != "") && (ns3 == [])) msg = UI(_("The tertiary nameserver is not correct")); if ((nstr2 != "") && (ns2 == [])) msg = UI(_("The secondary nameserver is not correct")); if ((nstr1 != "") && (ns1 == [])) msg = UI(_("The primary nameserver is not correct")); if (!chkdomain(domainstr)) msg = UI(_("The domain name is not correct")); if (!chkhost(hoststr)) msg = UI(_("The host name is not correct")); } if (msg != "OK") UI(`DisplayMessage(msg, 0, "")); } while (msg != "OK"); if (result == `next) { host = hoststr; domain = domainstr; nameserver = []; if (ns1 != []) nameserver = add(nameserver, ns1); if (ns2 != []) nameserver = add(nameserver, ns2); if (ns3 != []) nameserver = add(nameserver, ns3); searchlist = []; if (s1 != []) searchlist = add(searchlist, s1); if (s2 != []) searchlist = add(searchlist, s2); if (s3 != []) searchlist = add(searchlist, s3); } return result; }; /* * Configuration testing * */ define TestConfig (string device) ``{ Shell(sformat("/sbin/ifconfig %1 down", device)); if (dhcp) { Shell(sformat("/sbin/ifconfig %1 0.0.0.0 up", device)); Shell(sformat("/sbin/route add -host 255.255.255.255 dev %1", device)); Shell(sformat("%1 %2", dhcommand, device)); } else { Shell(sformat("/sbin/ifconfig %1 %2", device, ifconfig)); if (gateway != []) Shell(sformat("/sbin/route add default gw %1", addrtostr(gateway))); } Shell(sformat("/sbin/ifconfig %1 down", device)); }; /* * Read configuration and fill up global variables * * global variables: dhcommand * * file: /etc/modules.conf * global variables: modulesconf * * file: /etc/rc.config * global variables: * list netconfig - NETCONFIG value from rc.config (integers) * list netconfig_pcmcia - NETCONFIG_PCMCIA value from rc.config (integers) * bolean dhcp - DHCLIENT value * list ip - IPADDR_ value (eg. [10,10,0,1]) * list mask - netmask used by IFCONFIG_ value (eg. [255,255,255,0]) * list nameserver - NAMESERVER value (eg. [[10,10,0,1],[10,10,10,1]] * list searchlist - SEARCHLIST value (eg. [["suse.de"],["suse.cz"]]) * map ifs - NETCONFIG(_PCMCIA) and all IFCONFIG_ values * eg. $[ * 0:$["active":false, "addr":[10, 10, 0, 1], "bcast":[10, 10, 10, 255], "dev":"eth1", "mask":[255, 255, 255, 0], "net":[10, 10, 0, 0]], * 1:$["active":true, "addr":[10, 10, 10, 1], "bcast":[10, 10, 10, 255], "dev":"isdn0", "mask":[255, 255, 255, 0], "net":[10, 10, 10, 0]], * 2:$["active":false, "addr":[], "bcast":[], "dev":"eth0", "mask":[], "net":[]] * ] * * file /etc/route.conf * global variables: * list gateway - (eg. [10,10,0,8]) * * */ define ReadConfig () ``{ mod_name = ""; mod_name_old = ""; mod_args = []; // reading from /etc/modules.conf any a = SCR(`Read(.etc.modulesconf.read)); if (a != nil) modulesconf = a; maplist(`r, modulesconf, ``{ list l = lookup(r, "alias", []); if (size(l) > 1) if (select(l, 0) == "eth0") mod_name = select(l, 1); }); mod_name_old = mod_name; maplist(`r, modulesconf, ``{ list l = lookup(r, "options", []); if (size(l) > 1) if (select(l, 0) == mod_name) { mod_args = []; integer i = 1; while (i < size(l)) { mod_args = add(mod_args, select(l, i)); i = i + 1; } } l = lookup(r, "alias", []); if (size(l) > 1) if ((select(l, 1) == mod_name) && (select(l, 0) != "eth0")) mod_name_old = ""; }); // packages checking if (Shell("rpm -q dhclient") == 0) dhcommand = "/sbin/dhclient"; if (Shell("rpm -q dhcpcd") == 0) dhcommand = "/sbin/dhcpcd"; // reading from /etc/rc.config map rcconfig = $[]; a = SCR(`Read(.etc.rcconfig.read)); if (a != nil) rcconfig = a; netconfig = split(lookup(rcconfig, "NETCONFIG", ""), " _"); netconfig = maplist(`s, netconfig, ``tointeger(s)); if (has_pcmcia) { netconfig_pcmcia = split(lookup(rcconfig, "NETCONFIG_PCMCIA", ""), " _"); netconfig_pcmcia = maplist(`s, netconfig_pcmcia, ``tointeger(s)); } ifs = $[]; netdev = -1; maplist(`k, `v, rcconfig, ``{ if (substring(k, 0, 6) == "NETDEV") { integer i = 0; if (v != "") { i = tointeger(substring(k, 7)); if (v == "eth0") netdev = i; map m = $["addr":[], "net":[], "mask":[], "bcast":[]]; list l = split(lookup(rcconfig, sformat("IFCONFIG_%1", i), ""), " \t"); integer sizel = size(l); if (sizel > 0) { list addr = strtoaddr(select(l, 0)); list mask = []; list bcast = []; integer i = 1; while (i < sizel) { if (select(l, i) == "netmask") { i = i + 1; if (i < sizel) mask = strtoaddr(select(l, i)); } else { if (select(l, i) == "broadcast") { i = i + 1; if (i < sizel) bcast = strtoaddr(select(l, i)); } } i = i + 1; } if ((addr != []) && (mask != [])) { if (bcast == []) bcast = getbcast(addr, mask); m = $["addr":addr, "net":getnet(addr, mask), "mask":mask, "bcast":bcast]; } } m = add(m, "dev", v); if (card_is_pcmcia) m = add(m, "active", contains(netconfig_pcmcia, i)); else m = add(m, "active", contains(netconfig, i)); ifs = add(ifs, i, m); } } }); if (netdev < 0) { netdev = 0; while (haskey(ifs, netdev)) netdev = netdev + 1; ifs = add(ifs, netdev, $["dev":"eth0", "active":false, "addr":[], "net":[], "mask":[], "bcast":[]]); } ip = lookup(lookup(ifs, netdev), "addr"); mask = lookup(lookup(ifs, netdev), "mask"); dhcp = (ip == []) && (dhcommand != ""); if (dhcp) ifconfig = "dhcpclient"; else ifconfig = sformat("%1 broadcast %2 netmask %3", addrtostr(ip), addrtostr(lookup(lookup(ifs, netdev), "bcast")), addrtostr(mask)); a = SCR(`Read(.etc.routeconf.read)); if (a != nil) gateway = ip4toaddr(lookup(a, "default")); list l = split(lookup(rcconfig, "FQHOSTNAME", ""), "."); if (size(l) > 0) { host = select(l, 0); integer i = 1; while (i < size(l)) { string s = select(l, i); if (s != "") { if (domain != "") domain = domain + "."; domain = domain + s; } i = i + 1; } } else { // default FQHOSTNAME host = "linux"; domain = "local"; } l = split(lookup(rcconfig, "NAMESERVER", ""), " \t"); nameserver = maplist(`s, l, ``strtoaddr(s)); searchlist = split(lookup(rcconfig, "SEARCHLIST", "")," \t"); }; /* * Get host name from DNS * */ define gethostbyaddr (list ip) ``{ if (ip == []) return ""; if (Shell("/usr/bin/nslookup -timeout=1 " + addrtostr(ip) + " > /tmp/nslookup.out") != 0) return ""; any a = SCR(`Read(.tmp.nslookup)); if (a == nil) return ""; return lookup(a, "name", ""); }; /* * Convert global list modulesconf to modules.conf format * */ define getmodulesconf() ``{ string s = ""; any a = nil; foreach (`c, modulesconf, ``{ if (is(c, map)) { if (c == $[]) s = s + "\n"; a = lookup(c, "comment"); if (a != nil) s = s + a + "\n"; a = lookup(c, "alias"); if (a != nil) s = s + sformat("alias %1\n", join(a, " ")); a = lookup(c, "options"); if (a != nil) s = s + sformat("options %1\n", join(a, " ")); } else { s = s + c + "\n"; } }); a = substring(s, size(s) - 2); if (substring(a, 0, 1) != "\n") s = s + "\n"; if (substring(a, 1, 1) != "\n") s = s + "\n"; return s; }; /* * Save configuration * * modify /etc/modules.conf, /etc/rc.config * * create /etc/route.conf * * run SuSEconfig to generate /etc/hosts, /etc/host.conf, /etc/resolv.conf * */ define SaveConfig () ``{ string fqhostname = host + "." + domain; string nameserverstr = join(maplist(`v, nameserver, ``addrtostr(v)), " "); string searchstr = join(searchlist, " "); string dhcpstr = ""; string ipstr = ""; string gwstr = ""; // Add interface to /etc/modules.conf UI(`SetContents ( _("Network configuration"), // label for waiting while yast2 is writing `Label (sformat(UI(_("Saving file %1...")), modules_conf)), "", false, false ) ); modulesconf = filter(`r, modulesconf, ``{ list l = lookup(r, "alias", []); if (l != []) if (select(l, 0) == "eth0") return false; l = lookup(r, "options", []); if (l != []) { string s = select(l, 0); if ((s == "eth0") || (s == mod_name) || (s == mod_name_old) || (s == "")) return false; } if (substring(lookup(r, "comment", ""), 0, 8) == "# YaST2:") return false; return true; }); Shell(sformat("/bin/mv -f %1.old %2.old.o", modules_conf, modules_conf)); Shell(sformat("/bin/mv -f %1 %2.old", modules_conf, modules_conf)); string s = getmodulesconf() + sformat("# YaST2: %1\nalias %2 %3\n%4", card_name, "eth0", mod_name, mod_conf); if (!WriteString(modules_conf, s)) // warning dialog message UI(`DisplayMessage(sformat(UI(_("Couldn't write values to %1")), modules_conf), 0, "")); Shell("/sbin/depmod -a -F /boot/System.map-`uname -r` `uname -r`"); // rc.config saving UI(`SetContents ( _("Network configuration"), `Label (sformat(UI(_("Saving file %1...")), rc_config)), "", false, false ) ); if (dhcp) { dhcpstr = "yes"; } else { dhcpstr = "no"; ipstr = addrtostr(ip); if (gateway != []) { gwstr = sformat("default %1\n", addrtostr(gateway)); } } map m = $[ "FQHOSTNAME": [fqhostname, "The fully qualfied hostname of this computer. (e.g. \"linux.suse.de\")"], "SEARCHLIST": [searchstr, "Domain searchlist that should be used in /etc/resolv.conf"], "NAMESERVER": [nameserverstr, "Space separated list of nameservers that should be used for /etc/resolv.conf"], "DHCLIENT": [dhcpstr, "Shall the dynamic host configuration (DHCP) client be started? (\"yes\" or \"no\")"], // "START_LOOPBACK": ["yes", "Start loopback networking? (\"yes\" or \"no\")"], "CREATE_HOSTCONF": ["yes", "Should SuSEconfig create and check the /etc/host.conf? (\"yes\" or \"no\")"], "CREATE_RESOLVCONF": ["yes", "Shall SuSEconfig maintain /etc/resolv.conf (needed for DNS)? (\"yes\" or \"no\")"], "CHECK_ETC_HOSTS": ["yes", "Should SuSEconfig do some checks and modifications in /etc/hosts? (\"yes\" or \"no\")"], "BEAUTIFY_ETC_HOSTS": ["yes", "Should SuSEconfig sort your /etc/hosts? (\"yes\" or \"no\")"] ]; // filter out conflicted and undefined interfaces // move interface to start of NETCONFIG(_PCMCIA) to be started as first device if (card_is_pcmcia) { netconfig_pcmcia = union([netdev], filter(`v, netconfig_pcmcia, ``((haskey(ifs, v)) && (!contains(cdev, v)) && (v != netdev)))); s = join(maplist(`v, netconfig_pcmcia, ``sformat("_%1", v)), " "); m = add(m, "NETCONFIG_PCMCIA", [s, "Number of network devices: \"_0\" for one, \"_0 _1 _2 _3\" for four card"]); } else { netconfig = union([netdev], filter(`v, netconfig, ``((haskey(ifs, v)) && (!contains(cdev, v)) && (v != netdev)))); s = join(maplist(`v, netconfig, ``sformat("_%1", v)), " "); m = add(m, "NETCONFIG", [s, "Number of network devices: \"_0\" for one, \"_0 _1 _2 _3\" for four card"]); } m = add(m, sformat("IPADDR_%1", netdev), [ipstr, "IP Address"]); m = add(m, sformat("NETDEV_%1", netdev), ["eth0", "Network device name (e.g. \"eth0\")"]); m = add(m, sformat("IFCONFIG_%1", netdev), [ifconfig, "ifconfig (eg. \"10.10.1.3 broadcast 10.10.1.31 netmask 255.255.255.224\", \"bootp\" or \"dhcpclient\""]); if (!SCR(`Write(.etc.rcconfig, m))) // warning dialog message UI(`DisplayMessage(sformat(UI(_("Couldn't write values to %1")), rc_config), 0, "")); // change ifs to hold consistence with rc.config maplist(`k, cdev, ``{ ifs = add(ifs, k, add(lookup(ifs, k), "active", false)); }); ifs = add(ifs, netdev, $[ "dev": "eth0", "addr":ip, "net":getnet(ip, mask), "mask":mask, "bcast":getbcast(ip, mask), "active":true]); // route.conf saving UI(`SetContents ( _("Network configuration"), // label for waiting while yast2 is writing `Label (sformat(UI(_("Saving file %1...")), route_conf)), "", false, false ) ); Shell(sformat("/bin/mv -f %1.old %2.old.o", route_conf, route_conf)); Shell(sformat("/bin/cp -f %1 %2.old", route_conf, route_conf)); Shell(sformat("/bin/mv -f %1.old %2.old.o", resolv_conf, resolv_conf)); Shell(sformat("/bin/mv -f %1 %2.old", resolv_conf, resolv_conf)); if (gwstr != "") { string s = "# # /etc/route.conf # # In this file you can configure your static routing... # # This file is read by /sbin/init.d/route. # # # Destination Dummy/Gateway Netmask Device # # Examples: # # Net devices # 193.141.17.192 0.0.0.0 255.255.255.192 eth0 # # Gateways # default Riemann # 0.0.0.0 193.141.17.193 # # # Host behind Gateway # 193.141.17.142 193.141.17.193 255.255.255.255 # # Net behind a Gateway # 193.141.17.145 193.141.17.193 255.255.255.0 # # Multicast route for e.g. eth0. IP multicasting, forwarding and perhaps # multicast routing in kernel should be enabled. More information will # be found in the NET-3-HOWTO. Most people do NOT need this feature. # # 224.0.0.0 0.0.0.0 240.0.0.0 eth0 # # ISDN (i4l) # 192.168.0.1 0.0.0.0 255.255.255.255 ippp0 # default 192.168.0.1 " + gwstr; if (!WriteString(route_conf, s)) UI(`DisplayMessage(sformat(UI(_("Couldn't write values to %1")), route_conf), 0, "")); } UI(`SetContents ( _("Network configuration"), // label for waiting while SuSEconfig is runing `Label (_("Running SuSEconfig...")), "", false, false ) ); if (Shell("/sbin/SuSEconfig -quick -nonewpackage") != 0) // warning dialog message UI(`DisplayMessage(_("Error while running SuSEconfig"), 0, "")); if (card_is_pcmcia) { if (Shell("/sbin/conf.d/SuSEconfig.pcmcia") != 0) { // warning dialog message UI(`DisplayMessage(_("Error while running SuSEconfig"), 0, "")); } } return `next; }; /* * Stop networking, save new configuration and restart networking * */ define Finish (any result) ``{ // if (result == `back) return result; integer code = 0; // label for waiting until network is not stopped string msg = UI(_("Stopping network...")); // help text for configuration finishing string helptext = UI(_("<p>\n Network configuration is finished and the changes are saved.\n The network is then restarted.\n </p> ")); UI(`SetContents (_("Network configuration"), `Label(msg), "", false, false)); list l = []; void|map m = $[]; any a = SCR(`Read(.probe.byclass.network_interface.ethernet)); if (a != nil) l = maplist(`c, a, ``lookup(c, "dev_name", "")); Shell("/sbin/init.d/route stop"); maplist(`c, l, ``{ if (substring(c, 0, 3) == "eth") Shell("/sbin/ifconfig " + c + " down"); }); maplist(`i, cdev, ``{ Shell("/sbin/ifconfig " + lookup(lookup(ifs, i, $[]), "dev", "") + " down"); }); // Shell("/sbin/init.d/network stop"); Shell("/sbin/init.d/dhclient stop"); maplist(`c, l, ``Shell("/sbin/modprobe -r " + c)); SaveConfig(); Shell("/bin/hostname " + host + "." + domain); if (dhcp) { Shell("/sbin/init.d/dhclient start"); sleep(2000); } else { Shell("/sbin/init.d/network start"); Shell("/sbin/init.d/route start"); } // test networking // get address and broadcast for eth0 from /sbin/ifconfig and ping broadcast msg = ""; m = SCR(`Read(.run.ifconfig)); if (m != nil) { m = lookup(m, "eth0"); if (m != nil) { // there are some problems with broadcast ping !!! // therefore it is temporary commented // Shell(sformat("/bin/ping -w 1 -n %1 > /tmp/ping.out & /bin/sleep 10; /bin/kill $!", // addrtostr(ip4toaddr(lookup(m, "bcast"))))); // list|void l = SCR(`Read(.tmp.ping)); // Shell("/bin/rm -f /tmp/ping.out"); // if (l == nil) l = []; // l = filter(`c, l, ``(c != lookup(m, "addr"))); // if (size(l) > 0) // configuration is done msg = UI(_("The network device is now configured and ready to use.")); } } if (msg == "") // configuration is finished, but network is not running msg = UI(_("Something is wrong! Network is not running.\nPlease check your hardware and try again.\n\nHint on PCMCIA: Perhaps your network card\nisn't plugged in.")); UI(`SetContents (_("Network configuration"), `Label(msg), helptext, true, true)); result = UI(`UserInput ()); return result; }; /* * Global variables definiton * */ boolean dhcp = false; list netconfig = []; // list of active interfaces, NETCONFIG value list netconfig_pcmcia = []; // list of active interfaces, NETCONFIG_PCMCIA value integer netdev = -1; // interface number, index for NETDEV, IPADDR, IFCONFIG map ifs = $[]; // map of other than eth devices with static ip addreses list cdev = []; // list of conflicted devices according to NETCONFIG and netdev list ip = []; list mask = []; list gateway = []; string host = ""; string domain = ""; list nameserver = []; list searchlist = []; string dhcommand = ""; string ifconfig = ""; string rc_config = "/etc/rc.config"; string modules_conf = "/etc/modules.conf"; string route_conf = "/etc/route.conf"; string hosts = "/etc/hosts"; string host_conf = "/etc/host.conf"; string resolv_conf = "/etc/resolv.conf"; integer card_id = -1; // card number from .probe string card_name = ""; // card description name string dev_name = "eth0"; // device name string mod_name = ""; // kernel module name string mod_conf = ""; // modules.conf entry list mod_args = []; // insmod arguments string mod_name_old = "";// default kernel module name list modulesconf = []; /* * Global variables initialization * */ ReadConfig(); /* * Main dialog cycle * */ list dialog = [ ``FindCard (result), ``AddressSetup (result), ``CheckInterfaces(result), ``DNSSetup (result), ``Finish (result) ]; integer id = 0; any result = `next; while ((id >= 0) && (id < size (dialog))) { result = eval(select(dialog, id)); if (result == `cancel) break; else if (result == `next) id = id + 1; else if (result == `back) id = id - 1; } return UI(`CloseDialog()); }