newtComponent networkform;
newtComponent addressentry;
newtComponent netmaskentry;
+newtComponent gatewayentry;
newtComponent statictyperadio;
newtComponent dhcptyperadio;
newtComponent pppoetyperadio;
{
char *addressresult;
char *netmaskresult;
+ char *gatewayresult;
char *dhcphostnameresult;
char *dhcpforcemturesult;
struct newtExitStruct es;
newtComponent header;
newtComponent addresslabel;
newtComponent netmasklabel;
+ newtComponent gatewaylabel;
newtComponent dhcphostnamelabel;
newtComponent dhcpforcemtulabel;
newtComponent ok, cancel;
char temp[STRING_SIZE];
char addressfield[STRING_SIZE];
char netmaskfield[STRING_SIZE];
+ char gatewayfield[STRING_SIZE];
char typefield[STRING_SIZE];
char dhcphostnamefield[STRING_SIZE];
char dhcpforcemtufield[STRING_SIZE];
/* Build some key strings. */
sprintf(addressfield, "%s_ADDRESS", colour);
sprintf(netmaskfield, "%s_NETMASK", colour);
+ sprintf(gatewayfield, "DEFAULT_GATEWAY");
sprintf(typefield, "%s_TYPE", colour);
sprintf(dhcphostnamefield, "%s_DHCP_HOSTNAME", colour);
sprintf(dhcpforcemtufield, "%s_DHCP_FORCE_MTU", colour);
sprintf(message, _("Interface - %s"), colour);
- newtCenteredWindow(44, (typeflag ? 18 : 12), message);
+ newtCenteredWindow(44, (typeflag ? 19 : 12), message);
networkform = newtForm(NULL, NULL, 0);
newtEntrySetFlags(dhcphostnameentry, NEWT_FLAG_DISABLED, NEWT_FLAGS_SET);
newtEntrySetFlags(dhcpforcemtuentry, NEWT_FLAG_DISABLED, NEWT_FLAGS_SET);
}
+ /* Gateway */
+ gatewaylabel = newtTextbox(2, (typeflag ? 11 : 4) + 2, 18, 1, 0);
+ newtTextboxSetText(gatewaylabel, _("Gateway:"));
+ strcpy(temp, "");
+ findkey(kv, gatewayfield, temp);
+ gatewayentry = newtEntry(20, (typeflag ? 11 : 4) + 2, temp, 20, &gatewayresult, 0);
+ newtEntrySetFilter(gatewayentry, ip_input_filter, NULL);
+ if (typeflag == 1 && startstatictype == 0)
+ newtEntrySetFlags(gatewayentry, NEWT_FLAG_DISABLED, NEWT_FLAGS_SET);
+ newtFormAddComponent(networkform, gatewaylabel);
+ newtFormAddComponent(networkform, gatewayentry);
+
}
/* Address */
addresslabel = newtTextbox(2, (typeflag ? 11 : 4) + 0, 18, 1, 0);
newtFormAddComponent(networkform, netmasklabel);
newtFormAddComponent(networkform, netmaskentry);
+
/* Buttons. */
- ok = newtButton(8, (typeflag ? 14 : 7), _("OK"));
- cancel = newtButton(26, (typeflag ? 14 : 7), _("Cancel"));
+ ok = newtButton(8, (typeflag ? 15 : 7), _("OK"));
+ cancel = newtButton(26, (typeflag ? 15 : 7), _("Cancel"));
newtFormAddComponents(networkform, ok, cancel, NULL);
strcat(message, "\n");
error = 1;
}
+ if (typeflag && (inet_addr(gatewayresult) == INADDR_NONE))
+ {
+ strcat(message, _("Gateway"));
+ strcat(message, "\n");
+ error = 1;
+ }
+
}
if (strcmp(type, "DHCP") == 0)
{
{
replacekeyvalue(kv, addressfield, "0.0.0.0");
replacekeyvalue(kv, netmaskfield, "0.0.0.0");
+ replacekeyvalue(kv, gatewayfield, "0.0.0.0");
}
else
{
replacekeyvalue(kv, addressfield, addressresult);
replacekeyvalue(kv, netmaskfield, netmaskresult);
+ replacekeyvalue(kv, gatewayfield, gatewayresult);
}
- replacekeyvalue(kv, typefield, type);
+ replacekeyvalue(kv, typefield, type);
}
else
{
{
newtEntrySetFlags(addressentry, NEWT_FLAG_DISABLED, NEWT_FLAGS_SET);
newtEntrySetFlags(netmaskentry, NEWT_FLAG_DISABLED, NEWT_FLAGS_SET);
+ newtEntrySetFlags(gatewayentry, NEWT_FLAG_DISABLED, NEWT_FLAGS_SET);
}
else
{
newtEntrySetFlags(addressentry, NEWT_FLAG_DISABLED, NEWT_FLAGS_RESET);
newtEntrySetFlags(netmaskentry, NEWT_FLAG_DISABLED, NEWT_FLAGS_RESET);
+ newtEntrySetFlags(gatewayentry, NEWT_FLAG_DISABLED, NEWT_FLAGS_RESET);
}
if (strcmp(type, "DHCP") == 0)
{
int changedrivers(void);
int greenaddressmenu(void);
int addressesmenu(void);
-int gatewaymenu(void);
int handlenetworking(void)
{
addressesmenu();
break;
- case 4:
- gatewaymenu();
- break;
-
case 0:
if (oktoleave()) done = 1;
break;
return 0;
}
}
-
- strcpy(temp, ""); findkey(kv, "RED_TYPE", temp);
- if ((configtype == 0) || (strcmp(temp, "STATIC") == 0))
- {
- strcpy(temp, ""); findkey(kv, "DEFAULT_GATEWAY", temp);
- if (!(strlen(temp)))
- {
- errorbox(_("Missing Default Gateway."));
- freekeyvalues(kv);
- return 0;
- }
- }
return 1;
}
_("Network configuration type"),
_("Drivers and card assignments"),
_("Address settings"),
- _("Gateway settings"),
NULL
};
int rc;
return 0;
}
-
-/* default gateway.... */
-int gatewaymenu(void)
-{
- struct keyvalue *kv = initkeyvalues();
- char message[1000];
- char temp[STRING_SIZE] = "0";
- struct newtWinEntry entries[2];
- char* values[1]; /* pointers for the values. */
- int error;
- int configtype;
- int rc;
-
- if (!(readkeyvalues(kv, CONFIG_ROOT "/ethernet/settings")))
- {
- freekeyvalues(kv);
- errorbox(_("Unable to open settings file"));
- return 0;
- }
-
- entries[0].text = _("Default gateway:");
- strcpy(temp, ""); findkey(kv, "DEFAULT_GATEWAY", temp);
- values[0] = strdup(temp);
- entries[0].value = &values[0];
- entries[0].flags = 0;
-
- entries[1].text = NULL;
- entries[1].value = NULL;
- entries[1].flags = 0;
-
- do
- {
- error = 0;
-
- rc = newtWinEntries(_("Gateway settings"),
- _("Enter the gateway information. "
- "These settings are used only with Static IP on the RED interface."),
- 50, 5, 5, 18, entries, _("OK"), _("Cancel"), NULL);
- if (rc == 0 || rc == 1)
- {
- if (strlen(values[0]))
- {
- if (inet_addr(values[0]) == INADDR_NONE)
- {
- strcat(message, _("Default gateway"));
- strcat(message, "\n");
- error = 1;
- }
- }
-
- if (error)
- errorbox(message);
- else
- {
- replacekeyvalue(kv, "DEFAULT_GATEWAY", values[0]);
- netaddresschange = 1;
- free(values[0]);
- writekeyvalues(kv, CONFIG_ROOT "/ethernet/settings");
- }
- }
- }
- while (error);
-
- freekeyvalues(kv);
-
- return 1;
-}