Esempio n. 1
0
int rename_nics(void) {
	int i, j, k;
	int fnics = scan_network_cards();
	char nic2find[STRING_SIZE], temp[STRING_SIZE];

	for(i=0; i<4; i++)
		if (strcmp(knics[i].macaddr, ""))
			for(j=0; j<fnics; j++)
				if(strcmp(knics[i].macaddr, nics[j].macaddr) == 0) {
					sprintf(nic2find,"%s0",lcolourcard[i]);
					if(strcmp(nic2find, nics[j].nic)) {
						if(is_interface_up(nics[j].nic)) {
							nic_shutdown(nics[j].nic);
						}
						sprintf(temp,SYSDIR "/%s", nic2find);
						if(fmt_exists(temp)) {
							for(k=0; k<fnics; k++)
								if (strcmp(nics[k].nic, nic2find) == 0 ) {
									if(is_interface_up(nics[k].nic)) {
										nic_shutdown(nics[k].nic);
									}
									sprintf(temp,"dummy%i",k);
									if (rename_device(nics[k].nic, temp)) strcpy(nics[k].nic, temp);
								}
						}
						if (rename_device(nics[j].nic, nic2find)) strcpy(nics[j].nic, nic2find);
					}
				}
}
Esempio n. 2
0
/* Here they choose general network config, number of nics etc. */
int configtypemenu(void)
{
	struct keyvalue *kv = initkeyvalues();
	char temp[STRING_SIZE] = "1";
	char message[1000];
	int choise, found;
	int rc, configtype;

	if (!(readkeyvalues(kv, CONFIG_ROOT "/ethernet/settings")))
	{
		freekeyvalues(kv);
		errorbox(_("Unable to open settings file"));
		return 0;
	}

	found = scan_network_cards();
	
	findkey(kv, "CONFIG_TYPE", temp); choise = atol(temp);
	choise--;

		sprintf(message, _("Select the network configuration for %s. "
			"The following configuration types list those interfaces which have ethernet attached. "
			"If you change this setting, a network restart will be required, and you will have to "
			"reconfigure the network driver assignments."), NAME);
		rc = newtWinMenu(_("Network configuration type"), message, 50, 5, 5,
			6, configtypenames, &choise, _("OK"), _("Cancel"), NULL);
		if ( configtypecards[choise] > found ) {
			sprintf(message, _("Not enough netcards for your choice.\n\nNeeded: %d - Available: %d\n"),
				configtypecards[choise], found);
			errorbox(message);
		}

	if (rc == 0 || rc == 1)
	{
		choise++;
		sprintf(temp, "%d", choise);
		replacekeyvalue(kv, "CONFIG_TYPE", temp);
		configtype = atol(temp);
		if (!HAS_RED)
			clear_card_entry(_RED_CARD_);
		if (!HAS_ORANGE)
			clear_card_entry(_ORANGE_CARD_);
		if (!HAS_BLUE)
			clear_card_entry(_BLUE_CARD_);

		writekeyvalues(kv, CONFIG_ROOT "/ethernet/settings");
		netaddresschange = 1;
	}
	freekeyvalues(kv);
	
	return 0;
}
Esempio n. 3
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;
}