1 /* SmoothWall setup program.
3 * This program is distributed under the terms of the GNU General Public
4 * Licence. See the file COPYING for details.
6 * (c) Lawrence Manning, 2001
7 * The big one: networking.
9 * $Id: networking.c,v 1.5.2.6 2006/02/06 22:00:13 gespinasse Exp $
17 #define DEFAULT_GATEWAY 2
18 #define DNSGATEWAY_TOTAL 3
28 #define HAS_ORANGE (configtype == 1 || configtype == 3 || configtype == 5 || configtype == 7)
29 #define HAS_RED (configtype == 2 || configtype == 3 || configtype == 6 || configtype == 7)
30 #define HAS_BLUE (configtype == 4 || configtype == 5 || configtype == 6 || configtype == 7)
31 #define RED_IS_NOT_ETH (configtype == 0 || configtype == 1 || configtype == 4 || configtype == 5)
33 extern struct nic nics
[];
34 extern struct knic knics
[];
36 char *configtypenames
[] = {
37 "GREEN (RED is modem/ISDN)",
38 "GREEN + ORANGE (RED is modem/ISDN)",
40 "GREEN + ORANGE + RED",
41 "GREEN + BLUE (RED is modem/ISDN) ",
42 "GREEN + ORANGE + BLUE (RED is modem/ISDN)",
44 "GREEN + ORANGE + BLUE + RED",
48 int oktoleave(char *errormessage
);
50 int configtypemenu(void);
52 int changedrivers(void);
53 int greenaddressmenu(void);
54 int addressesmenu(void);
55 int dnsgatewaymenu(void);
57 int handlenetworking(void)
61 char errormessage
[STRING_SIZE
];
89 if (oktoleave(errormessage
))
92 errorbox(errormessage
);
102 /* Restart networking! */
103 if (netaddresschange
)
105 runcommandwithstatus("/etc/rc.d/init.d/network stop",
106 ctr
[TR_PUSHING_NETWORK_DOWN
]);
107 runcommandwithstatus("/etc/rc.d/init.d/network start",
108 ctr
[TR_PULLING_NETWORK_UP
]);
115 int oktoleave(char *errormessage
)
117 struct keyvalue
*kv
= initkeyvalues();
118 char temp
[STRING_SIZE
];
121 if (!(readkeyvalues(kv
, CONFIG_ROOT
"/ethernet/settings")))
124 errorbox(ctr
[TR_UNABLE_TO_OPEN_SETTINGS_FILE
]);
128 strcpy(temp
, "0"); findkey(kv
, "CONFIG_TYPE", temp
); configtype
= atol(temp
);
129 if (configtype
< 0 || configtype
> 7) configtype
= 0;
133 strcpy(temp
, ""); findkey(kv
, "BLUE_DEV", temp
);
136 strcpy(errormessage
, ctr
[TR_NO_BLUE_INTERFACE
]);
139 if (!(interfacecheck(kv
, "BLUE")))
141 strcpy(errormessage
, ctr
[TR_MISSING_BLUE_IP
]);
147 strcpy(temp
, ""); findkey(kv
, "ORANGE_DEV", temp
);
150 strcpy(errormessage
, ctr
[TR_NO_ORANGE_INTERFACE
]);
153 if (!(interfacecheck(kv
, "ORANGE")))
155 strcpy(errormessage
, ctr
[TR_MISSING_ORANGE_IP
]);
161 strcpy(temp
, ""); findkey(kv
, "RED_DEV", temp
);
164 strcpy(errormessage
, ctr
[TR_NO_RED_INTERFACE
]);
167 if (!(interfacecheck(kv
, "RED")))
169 strcpy(errormessage
, ctr
[TR_MISSING_RED_IP
]);
173 strcpy(errormessage
, "");
177 if (strlen(errormessage
))
184 /* Shows the main menu and a summary of the current settings. */
187 char *sections
[] = { ctr
[TR_NETWORK_CONFIGURATION_TYPE
],
188 ctr
[TR_DRIVERS_AND_CARD_ASSIGNMENTS
],
189 ctr
[TR_ADDRESS_SETTINGS
],
190 ctr
[TR_DNS_AND_GATEWAY_SETTINGS
], NULL
};
192 static int choice
= 0;
193 struct keyvalue
*kv
= initkeyvalues();
195 char temp
[STRING_SIZE
];
198 char networkrestart
[STRING_SIZE
] = "";
200 if (!(readkeyvalues(kv
, CONFIG_ROOT
"/ethernet/settings")))
203 errorbox(ctr
[TR_UNABLE_TO_OPEN_SETTINGS_FILE
]);
207 if (netaddresschange
)
208 strcpy(networkrestart
, ctr
[TR_RESTART_REQUIRED
]);
210 strcpy(temp
, ""); findkey(kv
, "CONFIG_TYPE", temp
); x
= atol(temp
);
211 if (x
< 0 || x
> 7) x
= 0;
212 /* Format heading bit. */
213 snprintf(message
, 1000, ctr
[TR_CURRENT_CONFIG
], configtypenames
[x
],
215 rc
= newtWinMenu(ctr
[TR_NETWORK_CONFIGURATION_MENU
], message
, 50, 5, 5, 6,
216 sections
, &choice
, ctr
[TR_OK
], ctr
[TR_DONE
], NULL
);
218 if (rc
== 0 || rc
== 1)
226 /* Here they choose general network config, number of nics etc. */
227 int configtypemenu(void)
229 struct keyvalue
*kv
= initkeyvalues();
230 char temp
[STRING_SIZE
] = "0";
235 if (!(readkeyvalues(kv
, CONFIG_ROOT
"/ethernet/settings")))
238 errorbox(ctr
[TR_UNABLE_TO_OPEN_SETTINGS_FILE
]);
242 findkey(kv
, "CONFIG_TYPE", temp
); choice
= atol(temp
);
243 sprintf(message
, ctr
[TR_NETWORK_CONFIGURATION_TYPE_LONG
], NAME
);
244 rc
= newtWinMenu(ctr
[TR_NETWORK_CONFIGURATION_TYPE
], message
, 50, 5, 5,
245 6, configtypenames
, &choice
, ctr
[TR_OK
], ctr
[TR_CANCEL
], NULL
);
247 if (rc
== 0 || rc
== 1)
249 runcommandwithstatus("/etc/rc.d/init.d/network stop red blue orange",
250 ctr
[TR_PUSHING_NON_LOCAL_NETWORK_DOWN
]);
252 sprintf(temp
, "%d", choice
);
253 replacekeyvalue(kv
, "CONFIG_TYPE", temp
);
254 replacekeyvalue(kv
, "ORANGE_DEV", "");
255 replacekeyvalue(kv
, "BLUE_DEV", "");
256 replacekeyvalue(kv
, "RED_DEV", "");
257 writekeyvalues(kv
, CONFIG_ROOT
"/ethernet/settings");
258 netaddresschange
= 1;
266 /* Driver menu. Choose drivers.. */
269 struct keyvalue
*kv
= initkeyvalues();
270 char message
[STRING_SIZE
];
271 char temp
[STRING_SIZE
];
272 // char description[STRING_SIZE], macaddr[STRING_SIZE];
273 // struct nic *pnics = nics;
275 // struct knic *pknics = knics;
278 int rc
, kcount
= 0, found
, neednics
; //i = 0, count = 0,
280 fprintf(flog
,"enter drivermenu\n"); // #### Debug ####
282 if (!(readkeyvalues(kv
, CONFIG_ROOT
"/ethernet/settings")))
285 errorbox(ctr
[TR_UNABLE_TO_OPEN_SETTINGS_FILE
]);
289 strcpy(temp
, "0"); findkey(kv
, "CONFIG_TYPE", temp
);
290 configtype
= atol(temp
);
292 // if (configtype == 0)
294 // freekeyvalues(kv);
295 // errorbox(ctr[TR_YOUR_CONFIGURATION_IS_SINGLE_GREEN_ALREADY_HAS_DRIVER]);
299 strcpy(message
, ctr
[TR_CONFIGURE_NETWORK_DRIVERS
]);
301 found
= scan_network_cards();
302 fprintf(flog
,"found %d Card\'s\n", found
); // #### Debug ####
303 kcount
= 0; // counter to find knowing nics.
304 neednics
= 0; // counter to use needing nics.
306 strcpy(temp
, ""); findkey(kv
, "GREEN_MACADDR", temp
);
308 strcpy(knics
[_GREEN_CARD_
].macaddr
, temp
);
309 strcpy(knics
[_GREEN_CARD_
].colour
, "GREEN");
310 findkey(kv
, "GREEN_DESCRIPTION", temp
);
311 strcpy(knics
[_GREEN_CARD_
].description
, temp
);
314 strcpy(knics
[_GREEN_CARD_
].description
, ctr
[TR_UNSET
]);
316 sprintf(temp
, "GREEN: %s\n", knics
[_GREEN_CARD_
].description
);
317 strcat(message
, temp
);
318 if (strlen(knics
[_GREEN_CARD_
].macaddr
) ) {
319 sprintf(temp
, "GREEN: (%s) %s green0\n", knics
[_GREEN_CARD_
].macaddr
, ctr
[TR_AS
]);
320 strcat(message
, temp
);
325 strcpy(temp
, ""); findkey(kv
, "RED_MACADDR", temp
);
327 strcpy(knics
[_RED_CARD_
].macaddr
, temp
);
328 strcpy(knics
[_RED_CARD_
].colour
, "RED");
329 findkey(kv
, "RED_DESCRIPTION", temp
);
330 strcpy(knics
[_RED_CARD_
].description
, temp
);
333 strcpy(knics
[_RED_CARD_
].description
, ctr
[TR_UNSET
]);
335 sprintf(temp
, "RED: %s\n", knics
[_RED_CARD_
].description
);
336 strcat(message
, temp
);
337 if (strlen(knics
[_RED_CARD_
].macaddr
) ) {
338 sprintf(temp
, "RED: (%s) %s red0\n", knics
[_RED_CARD_
].macaddr
, ctr
[TR_AS
]);
339 strcat(message
, temp
);
344 strcpy(temp
, ""); findkey(kv
, "ORANGE_MACADDR", temp
);
346 strcpy(knics
[_ORANGE_CARD_
].macaddr
, temp
);
347 strcpy(knics
[_ORANGE_CARD_
].colour
, "ORANGE");
348 findkey(kv
, "ORANGE_DESCRIPTION", temp
);
349 strcpy(knics
[_ORANGE_CARD_
].description
, temp
);
352 strcpy(knics
[_ORANGE_CARD_
].description
, ctr
[TR_UNSET
]);
354 sprintf(temp
, "ORANGE: %s\n", knics
[_ORANGE_CARD_
].description
);
355 strcat(message
, temp
);
356 if ( strlen(knics
[_ORANGE_CARD_
].macaddr
) ) {
357 sprintf(temp
, "ORANGE: (%s) %s orange0\n", knics
[_ORANGE_CARD_
].macaddr
, ctr
[TR_AS
]);
358 strcat(message
, temp
);
363 strcpy(temp
, ""); findkey(kv
, "BLUE_MACADDR", temp
);
365 strcpy(knics
[_BLUE_CARD_
].macaddr
, temp
);
366 strcpy(knics
[_BLUE_CARD_
].colour
, "BLUE");
367 findkey(kv
, "BLUE_DESCRIPTION", temp
);
368 strcpy(knics
[_BLUE_CARD_
].description
, temp
);
371 strcpy(knics
[_BLUE_CARD_
].description
, ctr
[TR_UNSET
]);
373 sprintf(temp
, "BLUE: %s\n", knics
[_BLUE_CARD_
].description
);
374 strcat(message
, temp
);
375 if (strlen(knics
[_BLUE_CARD_
].macaddr
)) {
376 sprintf(temp
, "BLUE: (%s) %s blue0\n", knics
[_BLUE_CARD_
].macaddr
, ctr
[TR_AS
]);
377 strcat(message
, temp
);
382 fprintf(flog
,"found %d knowing Card\'s\n", kcount
); // #### DEBUG ####
384 if (neednics
= kcount
) {
385 strcat(message
, ctr
[TR_DO_YOU_WISH_TO_CHANGE_THESE_SETTINGS
]);
386 rc
= newtWinChoice(ctr
[TR_DRIVERS_AND_CARD_ASSIGNMENTS
], ctr
[TR_OK
],
387 ctr
[TR_CANCEL
], message
);
388 if (rc
== 0 || rc
== 1)
390 /* Shit, got to do something.. */
394 strcat(message
, "\nEs wurden noch nicht alle Netzwerkkarten konfiguriert.\n");
395 newtWinMessage(ctr
[TR_DRIVERS_AND_CARD_ASSIGNMENTS
], ctr
[TR_OK
], message
);
396 /* Shit, got to do something.. */
404 int cardassigned(char *colour
)
406 char command
[STRING_SIZE
];
407 fprintf(flog
,"cardassigned - %s\n", colour
);
408 sprintf(command
, "grep -q %s < /etc/udev/rules.d/30-persistent-network.rules 2>/dev/null", colour
);
415 int changedrivers(void)
417 struct keyvalue
*kv
= initkeyvalues();
418 char temp
[STRING_SIZE
], message
[STRING_SIZE
];
420 int green
= 0, red
= 0, blue
= 0, orange
= 0;
421 char MenuInhalt
[10][180];
422 char *pMenuInhalt
[10];
423 int count
= 0, choise
= 0, rc
;
426 if (!(readkeyvalues(kv
, CONFIG_ROOT
"/ethernet/settings")))
429 errorbox(ctr
[TR_UNABLE_TO_OPEN_SETTINGS_FILE
]);
432 fprintf(flog
,"stop network on red, blue and orange\n"); // #### Debug ####
433 runcommandwithstatus("/etc/rc.d/init.d/network stop red blue orange",
434 ctr
[TR_PUSHING_NON_LOCAL_NETWORK_DOWN
]);
436 findkey(kv
, "CONFIG_TYPE", temp
); configtype
= atol(temp
);
439 else if (configtype
== 1)
440 { green
= 1; orange
= 1; }
441 else if (configtype
== 2)
442 { green
= 1; red
= 1; }
443 else if (configtype
== 3)
444 { green
= 1; red
= 1; orange
= 1; }
445 else if (configtype
== 4)
446 { green
= 1; blue
= 1; }
447 else if (configtype
== 5)
448 { green
= 1; blue
= 1; orange
= 1; }
449 else if (configtype
== 6)
450 { green
= 1; red
= 1; blue
= 1; }
451 else if (configtype
== 7)
452 { green
= 1; red
= 1; blue
= 1; orange
= 1; }
454 fprintf(flog
,"found: g=%d r=%d o=%d b=%d\n",green
, red
, orange
, blue
); // #### Debug ####
459 strcpy(message
, "(TR) Bitte wählen Sie das Interface aus das geaendert werden soll.\n\n");
462 strcpy(MenuInhalt
[count
], "GREEN");
463 pMenuInhalt
[count
] = MenuInhalt
[count
];
464 NicEntry
[_GREEN_CARD_
] = count
;
465 // fprintf(flog,"found: %s as entry %d\n", MenuInhalt[count], NicEntry[count]); // #### Debug ####
466 sprintf(temp
, "GREEN: %s\n", knics
[_GREEN_CARD_
].description
);
467 strcat(message
, temp
);
468 if ( strlen(knics
[_GREEN_CARD_
].macaddr
) ) {
469 sprintf(temp
, "GREEN: (%s) %s green0\n", knics
[_GREEN_CARD_
].macaddr
, ctr
[TR_AS
]);
470 strcat(message
, temp
);
476 strcpy(MenuInhalt
[count
], "RED");
477 pMenuInhalt
[count
] = MenuInhalt
[count
];
478 NicEntry
[_RED_CARD_
] = count
;
479 // fprintf(flog,"found: %s as entry %d\n", MenuInhalt[count], NicEntry[count]); // #### Debug ####
480 sprintf(temp
, "RED: %s\n", knics
[_RED_CARD_
].description
);
481 strcat(message
, temp
);
482 if ( strlen(knics
[_RED_CARD_
].macaddr
) ) {
483 sprintf(temp
, "RED: (%s) %s red0\n", knics
[_RED_CARD_
].macaddr
, ctr
[TR_AS
]);
484 strcat(message
, temp
);
490 strcpy(MenuInhalt
[count
], "ORANGE");
491 pMenuInhalt
[count
] = MenuInhalt
[count
];
492 NicEntry
[_ORANGE_CARD_
] = count
;
493 // fprintf(flog,"found: %s as entry %d\n", MenuInhalt[count], NicEntry[count]); // #### Debug ####
494 sprintf(temp
, "ORANGE: %s\n", knics
[_ORANGE_CARD_
].description
);
495 strcat(message
, temp
);
496 if ( strlen(knics
[_ORANGE_CARD_
].macaddr
) ) {
497 sprintf(temp
, "ORANGE: (%s) %s orange0\n", knics
[_ORANGE_CARD_
].macaddr
, ctr
[TR_AS
]);
498 strcat(message
, temp
);
504 strcpy(MenuInhalt
[count
], "BLUE");
505 pMenuInhalt
[count
] = MenuInhalt
[count
];
506 NicEntry
[_BLUE_CARD_
] = count
;
507 // fprintf(flog,"found: %s as entry %d\n", MenuInhalt[count], NicEntry[count]); // #### Debug ####
508 sprintf(temp
, "BLUE: %s\n", knics
[_BLUE_CARD_
].description
);
509 strcat(message
, temp
);
510 if ( strlen(knics
[_BLUE_CARD_
].macaddr
) ) {
511 sprintf(temp
, "BLUE: (%s) %s blue0\n", knics
[_BLUE_CARD_
].macaddr
, ctr
[TR_AS
]);
512 strcat(message
, temp
);
516 pMenuInhalt
[count
] = NULL
;
518 rc
= newtWinMenu("(TR) Netcard Farbe", message
, 70, 5, 5, 6, pMenuInhalt
, &choise
, ctr
[TR_SELECT
], "(TR) Entfernen" , ctr
[TR_DONE
], NULL
);
520 if ( rc
== 0 || rc
== 1) {
521 // write_configs_netudev(pnics[choise].description, pnics[choise].macaddr, colour);
522 // insert nic to colourcard
523 if ((green
) && ( choise
== NicEntry
[0])) nicmenu("green");
524 if ((red
) && ( choise
== NicEntry
[1])) nicmenu("red");
525 if ((orange
) && ( choise
== NicEntry
[2])) nicmenu("orange");
526 if ((blue
) && ( choise
== NicEntry
[3])) nicmenu("blue");
527 } else if (rc
== 2) {
528 if ((green
) && ( choise
== NicEntry
[0])) remove_nic_entry("green");
529 if ((red
) && ( choise
== NicEntry
[1])) remove_nic_entry("red");
530 if ((orange
) && ( choise
== NicEntry
[2])) remove_nic_entry("orange");
531 if ((blue
) && ( choise
== NicEntry
[3])) remove_nic_entry("blue");
534 // errorbox("Sie haben keine Netzwerkkarte ausgewaehlt.\n");
540 // writekeyvalues(kv, CONFIG_ROOT "/ethernet/settings");
546 // Let user change GREEN address.
547 int greenaddressmenu(void)
549 struct keyvalue
*kv
= initkeyvalues();
553 if (!(readkeyvalues(kv
, CONFIG_ROOT
"/ethernet/settings")))
556 errorbox(ctr
[TR_UNABLE_TO_OPEN_SETTINGS_FILE
]);
560 sprintf(message
, ctr
[TR_WARNING_LONG
], NAME
);
561 rc
= newtWinChoice(ctr
[TR_WARNING
], ctr
[TR_OK
], ctr
[TR_CANCEL
], message
);
563 if (rc
== 0 || rc
== 1)
565 if (changeaddress(kv
, "GREEN", 0, ""))
567 netaddresschange
= 1;
568 writekeyvalues(kv
, CONFIG_ROOT
"/ethernet/settings");
578 // They can change BLUE, ORANGE and GREEN too :)
579 int addressesmenu(void)
581 struct keyvalue
*kv
= initkeyvalues();
582 struct keyvalue
*mainkv
= initkeyvalues();
585 char *green
= "GREEN";
586 char *orange
= "ORANGE";
590 char greenaddress
[STRING_SIZE
];
591 char oldgreenaddress
[STRING_SIZE
];
592 char temp
[STRING_SIZE
];
593 char temp2
[STRING_SIZE
];
598 char hostname
[STRING_SIZE
];
600 if (!(readkeyvalues(kv
, CONFIG_ROOT
"/ethernet/settings")))
603 freekeyvalues(mainkv
);
604 errorbox(ctr
[TR_UNABLE_TO_OPEN_SETTINGS_FILE
]);
607 if (!(readkeyvalues(mainkv
, CONFIG_ROOT
"/main/settings")))
610 freekeyvalues(mainkv
);
611 errorbox(ctr
[TR_UNABLE_TO_OPEN_SETTINGS_FILE
]);
615 strcpy(temp
, "0"); findkey(kv
, "CONFIG_TYPE", temp
);
616 configtype
= atol(temp
);
627 sections
[c
] = orange
;
641 rc
= newtWinMenu(ctr
[TR_ADDRESS_SETTINGS
],
642 ctr
[TR_SELECT_THE_INTERFACE_YOU_WISH_TO_RECONFIGURE
], 50, 5,
643 5, 6, sections
, &choice
, ctr
[TR_OK
], ctr
[TR_DONE
], NULL
);
645 if (rc
== 0 || rc
== 1)
647 if (strcmp(sections
[choice
], "GREEN") == 0)
649 findkey(kv
, "GREEN_ADDRESS", oldgreenaddress
);
650 sprintf(message
, ctr
[TR_WARNING_LONG
], NAME
);
651 rc
= newtWinChoice(ctr
[TR_WARNING
], ctr
[TR_OK
], ctr
[TR_CANCEL
],
653 if (rc
== 0 || rc
== 1)
655 if (changeaddress(kv
, "GREEN", 0, ""))
657 netaddresschange
= 1;
658 writekeyvalues(kv
, CONFIG_ROOT
"/ethernet/settings");
660 findkey(kv
, "GREEN_ADDRESS", greenaddress
);
661 snprintf(temp
, STRING_SIZE
-1, "option routers %s", oldgreenaddress
);
662 snprintf(temp2
, STRING_SIZE
-1, "option routers %s", greenaddress
);
663 replace (CONFIG_ROOT
"/dhcp/dhcpd.conf", temp
, temp2
);
664 chown (CONFIG_ROOT
"/dhcp/dhcpd.conf", 99, 99);
668 if (strcmp(sections
[choice
], "BLUE") == 0)
670 if (changeaddress(kv
, "BLUE", 0, ""))
671 netaddresschange
= 1;
673 if (strcmp(sections
[choice
], "ORANGE") == 0)
675 if (changeaddress(kv
, "ORANGE", 0, ""))
676 netaddresschange
= 1;
678 if (strcmp(sections
[choice
], "RED") == 0)
680 strcpy(hostname
, "");
681 findkey(mainkv
, "HOSTNAME", hostname
);
682 if (changeaddress(kv
, "RED", 1, hostname
))
683 netaddresschange
= 1;
690 writekeyvalues(kv
, CONFIG_ROOT
"/ethernet/settings");
692 freekeyvalues(mainkv
);
697 /* DNS and default gateway.... */
698 int dnsgatewaymenu(void)
700 struct keyvalue
*kv
= initkeyvalues();
702 char temp
[STRING_SIZE
] = "0";
703 struct newtWinEntry entries
[DNSGATEWAY_TOTAL
+1];
704 char *values
[DNSGATEWAY_TOTAL
]; /* pointers for the values. */
709 if (!(readkeyvalues(kv
, CONFIG_ROOT
"/ethernet/settings")))
712 errorbox(ctr
[TR_UNABLE_TO_OPEN_SETTINGS_FILE
]);
716 strcpy(temp
, "0"); findkey(kv
, "CONFIG_TYPE", temp
);
717 configtype
= atol(temp
);
722 errorbox(ctr
[TR_DNS_GATEWAY_WITH_GREEN
]);
726 entries
[DNS1
].text
= ctr
[TR_PRIMARY_DNS
];
727 strcpy(temp
, ""); findkey(kv
, "DNS1", temp
);
728 values
[DNS1
] = strdup(temp
);
729 entries
[DNS1
].value
= &values
[DNS1
];
730 entries
[DNS1
].flags
= 0;
732 entries
[DNS2
].text
= ctr
[TR_SECONDARY_DNS
];
733 strcpy(temp
, ""); findkey(kv
, "DNS2", temp
);
734 values
[DNS2
] = strdup(temp
);
735 entries
[DNS2
].value
= &values
[DNS2
];
736 entries
[DNS2
].flags
= 0;
738 entries
[DEFAULT_GATEWAY
].text
= ctr
[TR_DEFAULT_GATEWAY
];
739 strcpy(temp
, ""); findkey(kv
, "DEFAULT_GATEWAY", temp
);
740 values
[DEFAULT_GATEWAY
] = strdup(temp
);
741 entries
[DEFAULT_GATEWAY
].value
= &values
[DEFAULT_GATEWAY
];
742 entries
[DEFAULT_GATEWAY
].flags
= 0;
744 entries
[DNSGATEWAY_TOTAL
].text
= NULL
;
745 entries
[DNSGATEWAY_TOTAL
].value
= NULL
;
746 entries
[DNSGATEWAY_TOTAL
].flags
= 0;
752 rc
= newtWinEntries(ctr
[TR_DNS_AND_GATEWAY_SETTINGS
],
753 ctr
[TR_DNS_AND_GATEWAY_SETTINGS_LONG
], 50, 5, 5, 18, entries
,
754 ctr
[TR_OK
], ctr
[TR_CANCEL
], NULL
);
755 if (rc
== 0 || rc
== 1)
757 strcpy(message
, ctr
[TR_INVALID_FIELDS
]);
758 if (strlen(values
[DNS1
]))
760 if (inet_addr(values
[DNS1
]) == INADDR_NONE
)
762 strcat(message
, ctr
[TR_PRIMARY_DNS_CR
]);
766 if (strlen(values
[DNS2
]))
768 if (inet_addr(values
[DNS2
]) == INADDR_NONE
)
770 strcat(message
, ctr
[TR_SECONDARY_DNS_CR
]);
774 if (strlen(values
[DEFAULT_GATEWAY
]))
776 if (inet_addr(values
[DEFAULT_GATEWAY
]) == INADDR_NONE
)
778 strcat(message
, ctr
[TR_DEFAULT_GATEWAY_CR
]);
782 if (!strlen(values
[DNS1
]) && strlen(values
[DNS2
]))
784 strcpy(message
, ctr
[TR_SECONDARY_WITHOUT_PRIMARY_DNS
]);
792 replacekeyvalue(kv
, "DNS1", values
[DNS1
]);
793 replacekeyvalue(kv
, "DNS2", values
[DNS2
]);
794 replacekeyvalue(kv
, "DEFAULT_GATEWAY", values
[DEFAULT_GATEWAY
]);
795 netaddresschange
= 1;
798 free(values
[DEFAULT_GATEWAY
]);
799 writekeyvalues(kv
, CONFIG_ROOT
"/ethernet/settings");