int handlenetworking(void)
{
	int done;
	int choice;
	char errormessage[STRING_SIZE];
	
	netaddresschange = 0;

	done = 0;
	while (!done)
	{
		choice = firstmenu();
			
		switch (choice)
		{
			case 1:
				configtypemenu();
				break;

			case 2:
				drivermenu();
				break;
							
			case 3:
				addressesmenu();
				break;
			
			case 4:
				dnsgatewaymenu();
				break;
				
			case 0:
				if (oktoleave(errormessage))
					done = 1;
				else
					errorbox(errormessage);
				break;
				
			default:
				break;
		}				
	}

	if (automode == 0)
	{
		/* Restart netowrking!  Reboot?  BAH! */	
		if (netaddresschange)
		{
			runcommandwithstatus("/etc/rc.d/rc.netaddress.down",
				ctr[TR_PUSHING_NETWORK_DOWN]);
			runcommandwithstatus("/etc/rc.d/rc.netaddress.up",
				ctr[TR_PULLING_NETWORK_UP]);
		}
	}
	
	return 1;
}
Exemplo n.º 2
0
int handleisdn(void)
{
	char command[STRING_SIZE];
	sprintf(command, "/etc/rc.d/init.d/mISDN config");
	if (runcommandwithstatus(command, ctr[TR_PROBING_ISDN]))
		errorbox(ctr[TR_ERROR_PROBING_ISDN]);
	// Need to write some lines that count the cards and say the names...
	return 1;
}
Exemplo n.º 3
0
int probeisdncard(void)
{
	int c;
	char message[STRING_SIZE];
	char commandstring[STRING_SIZE];
	char moduleparams[STRING_SIZE] = "";
	struct keyvalue *kv = initkeyvalues();
	int result = -1;
	
	if (!(readkeyvalues(kv, CONFIG_ROOT "isdn/settings")))
	{
		freekeyvalues(kv);
		errorbox(ctr[TR_UNABLE_TO_OPEN_SETTINGS_FILE]);
		return  -1;
	}
	findkey(kv, "MODULE_PARAMS", moduleparams);
		
	c = 1;
	while (cards[c].name)
	{
		sprintf(message, ctr[TR_CHECKING_FOR], cards[c].name);

		/* 
		 * For USB ISDN....
		 * just check /proc/bus/usb/devices for our supported device
		 */
		if (cards[c].type == 100) {
			if (probeusbisdncard("Vendor=0483 ProdID=481"))
				sprintf(commandstring, "/sbin/modprobe hisax_st5481 protocol=1 %s", moduleparams);
			else
				goto CONTINUE;
		} else {
			sprintf(commandstring, "/sbin/modprobe hisax type=%d protocol=1 %s", 
				cards[c].type, moduleparams);
		}
		
		if (runcommandwithstatus(commandstring, message) == 0)
		{
			mysystem("/etc/ppp/isdn-cleanup");
			sprintf(message, ctr[TR_DETECTED], cards[c].name);
			newtWinMessage(TITLE, ctr[TR_OK], message);
			result = cards[c].type;
			goto EXIT;
		}

CONTINUE:
		c++;
	}

	errorbox(ctr[TR_UNABLE_TO_FIND_AN_ISDN_CARD]);
	
EXIT:
	freekeyvalues(kv);
	
	return result;
}
Exemplo n.º 4
0
/* Returns 0 if main ISDN setup loop should exit. */
int isdnenabledpressed(void)
{
	struct keyvalue *kv = initkeyvalues();
	char protocol[STRING_SIZE] = "";
	char type[STRING_SIZE] = "";
	char msn[STRING_SIZE] = "";
	char moduleparams[STRING_SIZE] = "";
	char commandstring[STRING_SIZE];
	int result = 0;

	if (!(readkeyvalues(kv, CONFIG_ROOT "isdn/settings")))
	{
		freekeyvalues(kv);
		errorbox(ctr[TR_UNABLE_TO_OPEN_SETTINGS_FILE]);
		return 0;
	}

	findkey(kv, "PROTOCOL", protocol);
	findkey(kv, "TYPE", type);
	findkey(kv, "MSN", msn);
	findkey(kv, "MODULE_PARAMS", moduleparams);
				
	if (strlen(protocol) && strlen(type) && strlen(msn))
	{
		if (!strcmp(type, "100")) {
			sprintf(commandstring, "/sbin/modprobe hisax_st5481 protocol=%s %s", protocol, moduleparams);
		} else {
			sprintf(commandstring, "/sbin/modprobe hisax protocol=%s type=%s %s",
				protocol, type, moduleparams);
		}
		if (runcommandwithstatus(commandstring, ctr[TR_INITIALISING_ISDN]) != 0)
		{
			errorbox(ctr[TR_UNABLE_TO_INITIALISE_ISDN]);
			replacekeyvalue(kv, "ENABLED", "off");
			result = 1;
		}
		else
			replacekeyvalue(kv, "ENABLED", "on");
	}
	else
	{
		errorbox(ctr[TR_ISDN_NOT_SETUP]);
		replacekeyvalue(kv, "ENABLED", "off");
		result = 1;
	}
	writekeyvalues(kv, CONFIG_ROOT "isdn/settings");

	freekeyvalues(kv);
	
	return result;
}
Exemplo n.º 5
0
/* Manual entry for gurus. */
int manualdriver(char *driver, char *driveroptions)
{
	char *values[] = { NULL, NULL };	/* pointers for the values. */
	struct newtWinEntry entries[] =
		{ { "", &values[0], 0,}, { NULL, NULL, 0 } };
	int rc;
	char commandstring[STRING_SIZE];
	char *driverend;

	strcpy(driver, "");
	strcpy(driveroptions, "");
	
	rc = newtWinEntries(_("Select network driver"), _("Set additional module parameters"),
		50, 5, 5, 40, entries,  _("OK"), _("Cancel"), NULL);
	if (rc == 0 || rc == 1)
	{
		if (strlen(values[0]))
		{
			sprintf(commandstring, "/sbin/modprobe %s", values[0]);
			if (runcommandwithstatus(commandstring, _("Loading module..."), _("Loading module..."), NULL) == 0)
			{
				if ((driverend = strchr(values[0], ' ')))
				{
					*driverend = '\0';
					strcpy(driver, values[0]);
					strcpy(driveroptions, driverend + 1);
				}				
				else
				{
					strcpy(driver, values[0]);
					strcpy(driveroptions, "");
				}
			}
			else
				errorbox(_("Unable to load driver module."));
		}
		else
			errorbox(_("Module name cannot be blank."));
	}
	free(values[0]);

	return 1;
}
/* Here they choose general network config, number of nics etc. */
int configtypemenu(void)
{
	struct keyvalue *kv = initkeyvalues();
	char temp[STRING_SIZE] = "0";
	int choice;
	int rc;

	if (!(readkeyvalues(kv, CONFIG_ROOT "ethernet/settings")))
	{
		freekeyvalues(kv);
		errorbox(ctr[TR_UNABLE_TO_OPEN_SETTINGS_FILE]);
		return 0;
	}
	
	findkey(kv, "CONFIG_TYPE", temp); choice = atol(temp);
	rc = newtWinMenu(ctr[TR_NETWORK_CONFIGURATION_TYPE],
		ctr[TR_NETWORK_CONFIGURATION_TYPE_LONG], 50, 5, 5, 6,
		configtypenames, &choice, ctr[TR_OK], ctr[TR_CANCEL], NULL);

	if (rc == 0 || rc == 1)
	{
		runcommandwithstatus("/etc/rc.d/rc.netaddress.down",
			ctr[TR_PUSHING_NETWORK_DOWN]);
	
		sprintf(temp, "%d", choice);
		replacekeyvalue(kv, "CONFIG_TYPE", temp);
		replacekeyvalue(kv, "GREEN_DEV", "");
		replacekeyvalue(kv, "ORANGE_DEV", "");
		replacekeyvalue(kv, "PURPLE_DEV", "");
		replacekeyvalue(kv, "RED_DEV", "");
		writekeyvalues(kv, CONFIG_ROOT "ethernet/settings");
		netaddresschange = 1;
	}
	
	freekeyvalues(kv);
	
	return 0;
}
Exemplo n.º 7
0
int handlenetworking(void)
{
	int done;
	int choice;
	int found;
	
	netaddresschange = 0;

	found =	scan_network_cards();
	found = init_knics();

	done = 0;
	while (!done)
	{
		choice = firstmenu();
			
		switch (choice)
		{
			case 1:
				configtypemenu();
				break;

			case 2:
				drivermenu();
				break;
							
			case 3:
				addressesmenu();
				break;
			
			case 4:
				dnsgatewaymenu();
				break;
				
			case 0:
				if (oktoleave()) done = 1;
				break;
				
			default:
				break;
		}				
	}

	if (automode == 0)
	{
		/* Restart networking! */	
		if (netaddresschange)
		{
			runcommandwithstatus("/etc/rc.d/init.d/network stop",
				_("Networking"), _("Stopping network..."), NULL);

			rename_nics();

			runcommandwithstatus("/etc/rc.d/init.d/network start",
				_("Networking"), _("Restarting network..."), NULL);
			runcommandwithstatus("/etc/rc.d/init.d/unbound restart",
				_("Networking"), _("Restarting unbound..."), NULL);
		}
	} else {
		rename_nics();
	}
	return 1;
}
Exemplo n.º 8
0
int changedrivers(void)
{
	struct keyvalue *kv = initkeyvalues();
	char temp[STRING_SIZE], message[STRING_SIZE];
	int configtype;
	int green = 0, red = 0, blue = 0, orange = 0;
	char MenuInhalt[10][180];
	char *pMenuInhalt[10];
	int count = 0, choise = 0, rc;
	int NicEntry[10];

	if (!(readkeyvalues(kv, CONFIG_ROOT "/ethernet/settings")))
	{
		freekeyvalues(kv);
		errorbox(_("Unable to open settings file"));
		return 0;
	}
	if (automode == 0)
		runcommandwithstatus("/etc/rc.d/init.d/network stop red blue orange",
			_("Networking"), _("Restarting non-local network..."), NULL);

	findkey(kv, "CONFIG_TYPE", temp); configtype = atol(temp);
	if (configtype == 1)
		{ green = 1; red = 1; }
	else if (configtype == 2)
		{ green = 1; red = 1; orange = 1; }
	else if (configtype == 3)
		{ green = 1; red = 1; blue = 1; }
	else if (configtype == 4)
		{ green = 1; red=1; orange=1; blue = 1; }
	else if (configtype == "")
	  { green = 1; red = 1; }

	do
	{
		count = 0;
		strcpy(message, _("Please choose the interface you wish to change.\n\n"));

		if (green) {
			strcpy(MenuInhalt[count], "GREEN");
			pMenuInhalt[count] = MenuInhalt[count];
			NicEntry[_GREEN_CARD_] = count;
			sprintf(temp, "%-6s: %s\n", "GREEN", knics[_GREEN_CARD_].description);
			strcat(message, temp);
			if ( strlen(knics[_GREEN_CARD_].macaddr) ) {
				sprintf(temp, "%-6s: (%s)\n", "GREEN", knics[_GREEN_CARD_].macaddr);
				strcat(message, temp);
			}
			count++;
		}

		if (red) {
			strcpy(MenuInhalt[count], "RED");
			pMenuInhalt[count] = MenuInhalt[count];
			NicEntry[_RED_CARD_] = count;
			sprintf(temp, "%-6s: %s\n", "RED", knics[_RED_CARD_].description);
			strcat(message, temp);
			if ( strlen(knics[_RED_CARD_].macaddr) ) {
				sprintf(temp, "%-6s: (%s)\n", "RED", knics[_RED_CARD_].macaddr);
				strcat(message, temp);
			}
			count++;
		}

		if (orange) {
			strcpy(MenuInhalt[count], "ORANGE");
			pMenuInhalt[count] = MenuInhalt[count];
			NicEntry[_ORANGE_CARD_] = count;
			sprintf(temp, "%-6s: %s\n", "ORANGE", knics[_ORANGE_CARD_].description);
			strcat(message, temp);
			if ( strlen(knics[_ORANGE_CARD_].macaddr) ) {
				sprintf(temp, "%-6s: (%s)\n", "ORANGE", knics[_ORANGE_CARD_].macaddr);
				strcat(message, temp);
			}
			count++;
		}

		if (blue) {
			strcpy(MenuInhalt[count], "BLUE");
			pMenuInhalt[count] = MenuInhalt[count];
			NicEntry[_BLUE_CARD_] = count;
			sprintf(temp, "%-6s: %s\n", "BLUE", knics[_BLUE_CARD_].description);
			strcat(message, temp);
			if ( strlen(knics[_BLUE_CARD_].macaddr) ) {
				sprintf(temp, "%-6s: (%s)\n", "BLUE", knics[_BLUE_CARD_].macaddr);
				strcat(message, temp);
			}
			count++;
		}
		pMenuInhalt[count] = NULL;

		rc = newtWinMenu(_("Assigned Cards"), message, 70, 5, 5, 6, pMenuInhalt,
			&choise, _("Select"), _("Remove"), _("Done"), NULL);
			
		if ( rc == 0 || rc == 1) {
			if ((green) && ( choise == NicEntry[0])) nicmenu(_GREEN_CARD_);
			if ((red) && ( choise == NicEntry[1])) nicmenu(_RED_CARD_);
			if ((orange) && ( choise == NicEntry[2])) nicmenu(_ORANGE_CARD_);
			if ((blue) && ( choise == NicEntry[3])) nicmenu(_BLUE_CARD_);
			netaddresschange = 1;
		} else if (rc == 2) {
			if ((green) && ( choise == NicEntry[0])) ask_clear_card_entry(_GREEN_CARD_);
			if ((red) && ( choise == NicEntry[1])) ask_clear_card_entry(_RED_CARD_);
			if ((orange) && ( choise == NicEntry[2])) ask_clear_card_entry(_ORANGE_CARD_);
			if ((blue) && ( choise == NicEntry[3])) ask_clear_card_entry(_BLUE_CARD_);
			netaddresschange = 1;
		}
	}
	while ( rc <= 2);

	freekeyvalues(kv);
	return 1;
}
int changedrivers(void)
{
	struct keyvalue *kv = initkeyvalues();
	char message[1000];
	char temp[STRING_SIZE];
	int configtype;
	int rc;
	int c;
	int needcards, sofarallocated, nictocheck, countofcards, toallocate;
	char *green = "GREEN";
	char *orange = "ORANGE";
	char *purple = "PURPLE";
	char *red = "RED";
	char *sections[6];
	int choice;
	char nexteth[STRING_SIZE];
	int abort;
	char currentdriver[STRING_SIZE], currentdriveroptions[STRING_SIZE];
	char displaydriver[STRING_SIZE];
	char cardinfo[STRING_SIZE];
	char mac[STRING_SIZE];
	int driverc = 0;
	
	if (!(readkeyvalues(kv, CONFIG_ROOT "ethernet/settings")))
	{
		freekeyvalues(kv);
		errorbox(ctr[TR_UNABLE_TO_OPEN_SETTINGS_FILE]);
		return 0;
	}
	
	strcpy(temp, "0"); findkey(kv, "CONFIG_TYPE", temp);
	configtype = atol(temp);
	
	runcommandwithstatus("/etc/rc.d/rc.netaddress.down",
		ctr[TR_PUSHING_NETWORK_DOWN]);
	
	/* Blank them so the rc.netaddress.up dosnt get confused. */
	replacekeyvalue(kv, "GREEN_DEV", "");
	replacekeyvalue(kv, "ORANGE_DEV", "");
	replacekeyvalue(kv, "PURPLE_DEV", "");
	replacekeyvalue(kv, "RED_DEV", "");
	
	if (configtype == 0)
		needcards = 1;
	else if (configtype == 1 || configtype == 2 || configtype == 4)
		needcards = 2;
	else if (configtype == 3 || configtype == 5 || configtype == 6)
		needcards = 3;
	else
		needcards = 4;

	/* This is the green card. */		
	sofarallocated = 0;
	nictocheck = 0;
	countofcards = countcards();

	strcpy(displaydriver, "");
	strcpy(currentdriver, "");
		
	abort = 0;
	driverc = 0;
	/* Keep going till all cards are got, or they give up. */
	while (sofarallocated < needcards && !abort)
	{
		/* This is how many cards were added by the last module. */
		toallocate = countofcards - nictocheck;
		while (!abort && toallocate > 0 && nictocheck < countofcards && sofarallocated < needcards)
		{
			findnicdescription(displaydriver, temp);
			/* Get device name, eth%d is hard coded. */
			sprintf(nexteth, "eth%d", nictocheck);
			/* Get MAC address. */
			if (getnicmac(mac, STRING_SIZE, nexteth))
				/* If MAC found put at the end of NIC description. */
				snprintf(cardinfo, STRING_SIZE, "%s [%s]", temp, mac);
			else
				/* MAC lookup failed so just display NIC description. */
				snprintf(cardinfo, STRING_SIZE, "%s", temp);
			sprintf(message, ctr[TR_UNCLAIMED_DRIVER], cardinfo);
			c = 0; choice = 0;
			strcpy(temp, ""); findkey(kv, "GREEN_DEV", temp);
			if (CONFIG_TYPE_GREEN(configtype) &&!strlen(temp))
				sections[c++] = green;
			strcpy(temp, ""); findkey(kv, "ORANGE_DEV", temp);
			if (CONFIG_TYPE_ORANGE(configtype) && !strlen(temp))
				sections[c++] = orange;
			strcpy(temp, ""); findkey(kv, "PURPLE_DEV", temp);
			if (CONFIG_TYPE_PURPLE(configtype) && !strlen(temp))
				sections[c++] = purple;
			strcpy(temp, ""); findkey(kv, "RED_DEV", temp);			
			if (CONFIG_TYPE_RED(configtype) && !strlen(temp))
				sections[c++] = red;
			sections[c] = NULL;
			rc = newtWinMenu(ctr[TR_CARD_ASSIGNMENT],
				message, 50, 5,	5, 6, sections, &choice, ctr[TR_OK],
				ctr[TR_SKIP], ctr[TR_CANCEL], NULL);	
			if (rc == 0 || rc == 1)
			{
				/* Now we see which iface needs its settings changed. */
				if (strcmp(sections[choice], green) == 0)
				{
					replacekeyvalue(kv, "GREEN_DEV", nexteth);
					replacekeyvalue(kv, "GREEN_DRIVER", currentdriver);
					replacekeyvalue(kv, "GREEN_DRIVER_OPTIONS", currentdriveroptions);
					replacekeyvalue(kv, "GREEN_DISPLAYDRIVER", displaydriver);
					sofarallocated++;
					nictocheck++;
					toallocate--;
					strcpy(currentdriver, "");
					strcpy(currentdriveroptions, "");
				}
				if (strcmp(sections[choice], orange) == 0)
				{
					replacekeyvalue(kv, "ORANGE_DEV", nexteth);
					replacekeyvalue(kv, "ORANGE_DRIVER", currentdriver);
					replacekeyvalue(kv, "ORANGE_DRIVER_OPTIONS", currentdriveroptions);
					replacekeyvalue(kv, "ORANGE_DISPLAYDRIVER", displaydriver);
					sofarallocated++;
					nictocheck++;
					toallocate--;
					strcpy(currentdriver, "");
					strcpy(currentdriveroptions, "");
				}
				if (strcmp(sections[choice], purple) == 0)
				{
					replacekeyvalue(kv, "PURPLE_DEV", nexteth);
					replacekeyvalue(kv, "PURPLE_DRIVER", currentdriver);
					replacekeyvalue(kv, "PURPLE_DRIVER_OPTIONS", currentdriveroptions);
					replacekeyvalue(kv, "PURPLE_DISPLAYDRIVER", displaydriver);
					sofarallocated++;
					nictocheck++;
					toallocate--;
					strcpy(currentdriver, "");
					strcpy(currentdriveroptions, "");
				}
				if (strcmp(sections[choice], red) == 0)
				{
					replacekeyvalue(kv, "RED_DEV", nexteth);
					replacekeyvalue(kv, "RED_DRIVER", currentdriver);
					replacekeyvalue(kv, "RED_DRIVER_OPTIONS", currentdriveroptions);
					replacekeyvalue(kv, "RED_DISPLAYDRIVER", displaydriver);
					sofarallocated++;
					nictocheck++;
					toallocate--;
					strcpy(currentdriver, "");
					strcpy(currentdriveroptions, "");
				}
			}
			else if (rc == 2)
			{
				nictocheck++;
			}
			else if (rc == 3)
			{
				// Cancelled? Then abort
				abort = 1;
			}

			// Reached the end of the cards? Abort
			if (nictocheck >= countofcards) abort=1;

			// Run out of cards to allocate? Abort
			if (toallocate == 0) abort=1;

			// Got enough cards? Break and finish
			if (sofarallocated == needcards) break;
		}
	}
	
	if (sofarallocated >= needcards)
	{
		newtWinMessage(ctr[TR_CARD_ASSIGNMENT], ctr[TR_OK],
			ctr[TR_ALL_CARDS_SUCCESSFULLY_ALLOCATED]);
	}
	else
		errorbox(ctr[TR_NOT_ENOUGH_CARDS_WERE_ALLOCATED]);
		
	writekeyvalues(kv, CONFIG_ROOT "ethernet/settings");

	freekeyvalues(kv);

	netaddresschange = 1;
	
	return 1;
}
Exemplo n.º 10
0
int nicmenu(int colour)
{
	int rc, choise = 0, count = 0, kcount = 0, mcount = 0, i, j, nic_in_use;
	int found_NIC_as_Card[MAX_NICS];
	char message[STRING_SIZE];
	char temp[STRING_SIZE];

	char cMenuInhalt[STRING_SIZE];
	char MenuInhalt[MAX_NICS][STRING_SIZE];
	char *pMenuInhalt[MAX_NICS];
	
	while (strcmp(nics[count].macaddr, "")) count++;			// 2 find how many nics in system
	for (i=0; i<MAX_NICS; i++) if (strcmp(knics[i].macaddr, "")) kcount++;	// loop to find all knowing nics

	// If new nics are found...
	if (count > kcount) {
		for (i=0 ; i < count ; i++)
		{
			nic_in_use = 0;
			for (j=0 ; j <= kcount ; j++) {
				if (strcmp(nics[ i ].macaddr, knics[ j ].macaddr) == 0 ) {
					nic_in_use = 1;
					break;
				}
			}
			if (!(nic_in_use)) {
				if ( strlen(nics[i].description) < 55 ) 
					sprintf(MenuInhalt[mcount], "%.*s",  strlen(nics[i].description)-2, nics[i].description+1);
				else {
					sprintf(cMenuInhalt, "%.50s", nics[i].description + 1);
					sprintf(MenuInhalt[mcount], cMenuInhalt);
					strcat (MenuInhalt[mcount], "...");
				}

				while ( strlen(MenuInhalt[mcount]) < 53) strcat(MenuInhalt[mcount], " "); // Fill with space.

				strcat(MenuInhalt[mcount], " (");
				strcat(MenuInhalt[mcount], nics[i].macaddr);
				strcat(MenuInhalt[mcount], ")");
				pMenuInhalt[mcount] = MenuInhalt[mcount];
				found_NIC_as_Card[mcount]=i;
				mcount++;
			}
		}

		pMenuInhalt[mcount] = NULL;

		sprintf(message, _("Please choose a networkcard for the following interface - %s."), ucolourcard[colour]);
		rc=2;
		while ( rc == 2 ) {
			rc = newtWinMenu(_("Extended Network Menu"), message, 50, 5, 5, 6, pMenuInhalt, &choise,
				_("Select"), _("Identify"), _("Cancel"), NULL);
			if ( rc == 2 ) {
				sprintf(temp, "/sbin/ip link set %s up", nics[found_NIC_as_Card[choise]].nic);
				mysystem(NULL, temp);
				sprintf(temp, "/usr/sbin/ethtool -p %s 10", nics[found_NIC_as_Card[choise]].nic);
				if (runcommandwithstatus(temp, _("Device Identification"), _("The lights on the selected port should flash now for 10 seconds..."), NULL) != 0) {
					errorbox(_("Identification is not supported by this interface."));
				sprintf(temp, "/sbin/ip link set %s down", nics[found_NIC_as_Card[choise]].nic);
				mysystem(NULL, temp);
				}
			}
		}
		if ( rc == 0 || rc == 1) {
			write_configs_netudev(found_NIC_as_Card[choise], colour);
		}
		return 0;
	} else {
		// We have to add here that you can manually add a device
		errorbox(_("There are no unassigned interfaces on your system."));
		return 1;
	}
}
Exemplo n.º 11
0
void handleisdncard(void)
{
	char **selection;
	int c;
	int rc;
	int choice;
	int type;
	struct keyvalue *kv = initkeyvalues();
	char temp[STRING_SIZE] = "0";
	int card;
	char message[STRING_SIZE];
	char commandstring[STRING_SIZE];
	char moduleparams[STRING_SIZE] = "";
	int done = 0;
	
	if (!(readkeyvalues(kv, CONFIG_ROOT "isdn/settings")))
	{
		freekeyvalues(kv);
		errorbox(ctr[TR_UNABLE_TO_OPEN_SETTINGS_FILE]);
		return;
	}
	
	findkey(kv, "TYPE", temp);
	type = atol(temp);
	findkey(kv, "MODULE_PARAMS", moduleparams);
	
	/* Count cards. */
	c = 0;
	while (cards[c].name) c++;
	selection = malloc((c + 1) * sizeof(char *));
	
	/* Fill out section. */
	c = 0;
	selection[c] = ctr[TR_AUTODETECT];
	c++;
	while (cards[c].name)
	{
		selection[c] = cards[c].name;
		c++;
	}
	selection[c] = NULL;
	
	/* Determine inital value for choice. */
	c = 0; choice = 0;
	while (cards[c].name)
	{
		if (cards[c].type == type)
		{
			choice = c;
			break;
		}
		c++;
	}
	
	while (!done)
	{
		rc = newtWinMenu(ctr[TR_ISDN_CARD_SELECTION], ctr[TR_CHOOSE_THE_ISDN_CARD_INSTALLED],
			50, 5, 5, 10, selection, &choice, ctr[TR_OK], ctr[TR_CANCEL], NULL);
	
		if (rc == 2)
			done = 1;
		else
		{	
			if (choice == 0)
				card = probeisdncard();
			else
			{
				sprintf(message, ctr[TR_CHECKING_FOR], cards[choice].name);
				if (cards[choice].type == 100) {
					sprintf(commandstring, "/sbin/modprobe hisax_st5481 protocol=1 %s", moduleparams);
				} else {
					sprintf(commandstring, "/sbin/modprobe hisax type=%d protocol=1 %s",
						cards[choice].type, moduleparams);
				}
				if (runcommandwithstatus(commandstring, message) == 0)
					card = cards[choice].type;
				else
				{
					errorbox(ctr[TR_ISDN_CARD_NOT_DETECTED]);
					card = -1;
				}
				mysystem("/etc/ppp/isdn-cleanup");
			}

			if (card != -1)
			{
				sprintf(temp, "%d", card);
				replacekeyvalue(kv, "TYPE", temp);
				writekeyvalues(kv, CONFIG_ROOT "isdn/settings");
				done = 1;
			}
		}
	}

	free(selection);	
	freekeyvalues(kv);
}