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_RED (configtype == 1 || configtype == 2 || configtype == 3 || configtype == 4)
29 #define HAS_ORANGE (configtype == 2 || configtype == 4)
30 #define HAS_BLUE (configtype == 3 || configtype == 4)
31 #define RED_IS_NOT_ETH (configtype == 0)
33 //#define HAS_ORANGE (configtype == 1 || configtype == 3 || configtype == 5 || configtype == 7)
34 //#define HAS_RED (configtype == 2 || configtype == 3 || configtype == 6 || configtype == 7)
35 //#define HAS_BLUE (configtype == 4 || configtype == 5 || configtype == 6 || configtype == 7)
36 //#define RED_IS_NOT_ETH (configtype == 0 || configtype == 1 || configtype == 4 || configtype == 5)
38 extern struct nic nics
[];
39 extern struct knic knics
[];
41 /* char *configtypenames[] = {
42 "GREEN (RED is modem/ISDN)",
43 "GREEN + ORANGE (RED is modem/ISDN)",
45 "GREEN + ORANGE + RED",
46 "GREEN + BLUE (RED is modem/ISDN) ",
47 "GREEN + ORANGE + BLUE (RED is modem/ISDN)",
49 "GREEN + ORANGE + BLUE + RED",
52 char *configtypenames
[] = {
55 "GREEN + RED + ORANGE",
57 "GREEN + RED + ORANGE + BLUE",
59 int configtypecards
[] = {
62 3, // "GREEN + RED + ORANGE",
63 3, // "GREEN + RED + BLUE",
64 4 // "GREEN + RED + ORANGE + BLUE",
70 int oktoleave(char *errormessage
);
72 int configtypemenu(void);
74 int changedrivers(void);
75 int greenaddressmenu(void);
76 int addressesmenu(void);
77 int dnsgatewaymenu(void);
79 int handlenetworking(void)
84 char errormessage
[STRING_SIZE
];
88 fprintf(flog
,"Enter HandleNetworking\n"); // #### Debug ####
90 found
= scan_network_cards();
91 fprintf(flog
,"found %d cards\n",found
); // #### Debug ####
93 fprintf(flog
,"found %d kcards\n",found
); // #### Debug ####
119 if (oktoleave(errormessage
))
122 errorbox(errormessage
);
132 /* Restart networking! */
133 if (netaddresschange
)
135 runcommandwithstatus("/etc/rc.d/init.d/network stop",
136 ctr
[TR_PUSHING_NETWORK_DOWN
]);
137 runcommandwithstatus("/etc/rc.d/init.d/network start",
138 ctr
[TR_PULLING_NETWORK_UP
]);
145 int oktoleave(char *errormessage
)
147 struct keyvalue
*kv
= initkeyvalues();
148 char temp
[STRING_SIZE
];
151 if (!(readkeyvalues(kv
, CONFIG_ROOT
"/ethernet/settings")))
154 errorbox(ctr
[TR_UNABLE_TO_OPEN_SETTINGS_FILE
]);
158 strcpy(temp
, "0"); findkey(kv
, "CONFIG_TYPE", temp
); configtype
= atol(temp
);
159 if (configtype
< 1 || configtype
> 4) configtype
= 0;
163 strcpy(temp
, ""); findkey(kv
, "GREEN_DEV", temp
);
166 strcpy(errormessage
, ctr
[TR_NO_GREEN_INTERFACE
]);
169 if (!(interfacecheck(kv
, "GREEN")))
171 strcpy(errormessage
, "(TR) GRÜNE IP nicht konfiguriert.\n"); //ctr[TR_MISSING_GREEN_IP]);
177 strcpy(temp
, ""); findkey(kv
, "RED_DEV", temp
);
180 strcpy(errormessage
, ctr
[TR_NO_RED_INTERFACE
]);
183 if (!(interfacecheck(kv
, "RED")))
185 strcpy(errormessage
, ctr
[TR_MISSING_RED_IP
]);
191 strcpy(temp
, ""); findkey(kv
, "ORANGE_DEV", temp
);
194 strcpy(errormessage
, ctr
[TR_NO_ORANGE_INTERFACE
]);
197 if (!(interfacecheck(kv
, "ORANGE")))
199 strcpy(errormessage
, ctr
[TR_MISSING_ORANGE_IP
]);
205 strcpy(temp
, ""); findkey(kv
, "BLUE_DEV", temp
);
208 strcpy(errormessage
, ctr
[TR_NO_BLUE_INTERFACE
]);
211 if (!(interfacecheck(kv
, "BLUE")))
213 strcpy(errormessage
, ctr
[TR_MISSING_BLUE_IP
]);
219 strcpy(temp
, ""); findkey(kv
, "DNS1", temp
);
222 strcpy(errormessage
, "(TR) Kein DNS eingetragen\n");
225 strcpy(temp
, ""); findkey(kv
, "DEFAULT_GATEWAY", temp
);
228 strcpy(errormessage
, "(TR) Kein default Gateway eingetragen.\n");
232 strcpy(errormessage
, "");
236 if (strlen(errormessage
))
243 /* Shows the main menu and a summary of the current settings. */
246 char *sections
[] = { ctr
[TR_NETWORK_CONFIGURATION_TYPE
],
247 ctr
[TR_DRIVERS_AND_CARD_ASSIGNMENTS
],
248 ctr
[TR_ADDRESS_SETTINGS
],
249 ctr
[TR_DNS_AND_GATEWAY_SETTINGS
], NULL
};
251 static int choice
= 0;
252 struct keyvalue
*kv
= initkeyvalues();
254 char temp
[STRING_SIZE
];
257 char networkrestart
[STRING_SIZE
] = "";
259 if (!(readkeyvalues(kv
, CONFIG_ROOT
"/ethernet/settings")))
262 errorbox(ctr
[TR_UNABLE_TO_OPEN_SETTINGS_FILE
]);
266 if (netaddresschange
)
267 strcpy(networkrestart
, ctr
[TR_RESTART_REQUIRED
]);
269 strcpy(temp
, ""); findkey(kv
, "CONFIG_TYPE", temp
); x
= atol(temp
);
270 if (x
< 1 || x
> 4) x
= 0;
271 /* Format heading bit. */
272 snprintf(message
, 1000, ctr
[TR_CURRENT_CONFIG
], configtypenames
[x
],
274 rc
= newtWinMenu(ctr
[TR_NETWORK_CONFIGURATION_MENU
], message
, 50, 5, 5, 6,
275 sections
, &choice
, ctr
[TR_OK
], ctr
[TR_DONE
], NULL
);
277 if (rc
== 0 || rc
== 1)
285 /* Here they choose general network config, number of nics etc. */
286 int configtypemenu(void)
288 struct keyvalue
*kv
= initkeyvalues();
289 char temp
[STRING_SIZE
] = "0";
294 fprintf(flog
,"Enter ConfigMenu\n");
296 if (!(readkeyvalues(kv
, CONFIG_ROOT
"/ethernet/settings")))
299 errorbox(ctr
[TR_UNABLE_TO_OPEN_SETTINGS_FILE
]);
303 found
= scan_network_cards();
304 fprintf(flog
,"found %d Card\'s\n", found
); // #### Debug ####
306 findkey(kv
, "CONFIG_TYPE", temp
); choise
= atol(temp
);
310 sprintf(message
, ctr
[TR_NETWORK_CONFIGURATION_TYPE_LONG
], NAME
);
311 rc
= newtWinMenu(ctr
[TR_NETWORK_CONFIGURATION_TYPE
], message
, 50, 5, 5,
312 6, configtypenames
, &choise
, ctr
[TR_OK
], ctr
[TR_CANCEL
], NULL
);
313 if ( configtypecards
[choise
] > found
) {
314 sprintf(message
, "(TR) Nicht genuegend Netzwerkkarten fuer diese Auswahl gefunden.\n\nBenoetigt: %d\nGefunden: %d\n", configtypecards
[choise
], found
);
318 while ( configtypecards
[choise
] > found
);
320 if (rc
== 0 || rc
== 1)
322 // if (automode != 0) runcommandwithstatus("/etc/rc.d/init.d/network stop red blue orange", ctr[TR_PUSHING_NON_LOCAL_NETWORK_DOWN]);
324 sprintf(temp
, "%d", choise
);
325 replacekeyvalue(kv
, "CONFIG_TYPE", temp
);
326 clear_card_entry(_RED_CARD_
);
327 clear_card_entry(_ORANGE_CARD_
);
328 clear_card_entry(_BLUE_CARD_
);
330 writekeyvalues(kv
, CONFIG_ROOT
"/ethernet/settings");
331 netaddresschange
= 1;
340 /* Driver menu. Choose drivers.. */
343 struct keyvalue
*kv
= initkeyvalues();
344 char message
[STRING_SIZE
];
345 char temp
[STRING_SIZE
];
348 int i
, rc
, kcount
= 0, neednics
; //i = 0, count = 0,
350 fprintf(flog
,"Enter drivermenu\n"); // #### Debug ####
352 if (!(readkeyvalues(kv
, CONFIG_ROOT
"/ethernet/settings")))
355 errorbox(ctr
[TR_UNABLE_TO_OPEN_SETTINGS_FILE
]);
359 strcpy(temp
, "0"); findkey(kv
, "CONFIG_TYPE", temp
);
360 configtype
= atol(temp
);
362 strcpy(message
, ctr
[TR_CONFIGURE_NETWORK_DRIVERS
]);
364 kcount
= 0; // counter to find knowing nics.
365 neednics
= 0; // counter to use needing nics.
367 sprintf(temp
, "GREEN: %s\n", knics
[_GREEN_CARD_
].description
);
368 strcat(message
, temp
);
369 if (strlen(knics
[_GREEN_CARD_
].macaddr
) ) {
370 sprintf(temp
, "GREEN: (%s) %s green0\n", knics
[_GREEN_CARD_
].macaddr
, ctr
[TR_AS
]);
371 strcat(message
, temp
);
376 sprintf(temp
, "RED: %s\n", knics
[_RED_CARD_
].description
);
377 strcat(message
, temp
);
378 if (strlen(knics
[_RED_CARD_
].macaddr
) ) {
379 sprintf(temp
, "RED: (%s) %s red0\n", knics
[_RED_CARD_
].macaddr
, ctr
[TR_AS
]);
380 strcat(message
, temp
);
385 sprintf(temp
, "ORANGE: %s\n", knics
[_ORANGE_CARD_
].description
);
386 strcat(message
, temp
);
387 if ( strlen(knics
[_ORANGE_CARD_
].macaddr
) ) {
388 sprintf(temp
, "ORANGE: (%s) %s orange0\n", knics
[_ORANGE_CARD_
].macaddr
, ctr
[TR_AS
]);
389 strcat(message
, temp
);
394 sprintf(temp
, "BLUE: %s\n", knics
[_BLUE_CARD_
].description
);
395 strcat(message
, temp
);
396 if (strlen(knics
[_BLUE_CARD_
].macaddr
)) {
397 sprintf(temp
, "BLUE: (%s) %s blue0\n", knics
[_BLUE_CARD_
].macaddr
, ctr
[TR_AS
]);
398 strcat(message
, temp
);
403 for ( i
=0 ; i
<4;i
++) if (strcmp(knics
[i
].macaddr
, "")) kcount
++;
404 fprintf(flog
,"found %d knowing Card\'s\n", kcount
); // #### DEBUG ####
406 if (neednics
= kcount
)
408 strcat(message
, ctr
[TR_DO_YOU_WISH_TO_CHANGE_THESE_SETTINGS
]);
409 rc
= newtWinChoice(ctr
[TR_DRIVERS_AND_CARD_ASSIGNMENTS
], ctr
[TR_OK
],
410 ctr
[TR_CANCEL
], message
);
411 if (rc
== 0 || rc
== 1)
413 /* Shit, got to do something.. */
417 // strcat(message, "\nEs wurden noch nicht alle Netzwerkkarten konfiguriert.\n");
418 // newtWinMessage(ctr[TR_DRIVERS_AND_CARD_ASSIGNMENTS], ctr[TR_OK], message);
419 /* Shit, got to do something.. */
427 int set_menu_entry_for(int *nr
, int *card
)
432 int changedrivers(void)
434 struct keyvalue
*kv
= initkeyvalues();
435 char temp
[STRING_SIZE
], message
[STRING_SIZE
];
437 int green
= 0, red
= 0, blue
= 0, orange
= 0;
438 char MenuInhalt
[10][180];
439 char *pMenuInhalt
[10];
440 int count
= 0, choise
= 0, rc
;
443 if (!(readkeyvalues(kv
, CONFIG_ROOT
"/ethernet/settings")))
446 errorbox(ctr
[TR_UNABLE_TO_OPEN_SETTINGS_FILE
]);
449 fprintf(flog
,"stop network on red, blue and orange\n"); // #### Debug ####
450 runcommandwithstatus("/etc/rc.d/init.d/network stop red blue orange",
451 ctr
[TR_PUSHING_NON_LOCAL_NETWORK_DOWN
]);
453 findkey(kv
, "CONFIG_TYPE", temp
); configtype
= atol(temp
);
456 else if (configtype
== 1)
457 { green
= 1; red
= 1; }
458 else if (configtype
== 2)
459 { green
= 1; red
= 1; orange
= 1; }
460 else if (configtype
== 3)
461 { green
= 1; red
= 1; blue
= 1; }
462 else if (configtype
== 4)
463 { green
= 1; red
=1; orange
=1; blue
= 1; }
464 // else if (configtype == 5)
465 // { green = 1; blue = 1; orange = 1; }
466 // else if (configtype == 6)
467 // { green = 1; red = 1; blue = 1; }
468 // else if (configtype == 7)
469 // { green = 1; red = 1; blue = 1; orange = 1; }
471 fprintf(flog
,"found: g=%d r=%d o=%d b=%d\n",green
, red
, orange
, blue
); // #### Debug ####
476 strcpy(message
, "(TR) Bitte wählen Sie das Interface aus das geaendert werden soll.\n\n");
479 strcpy(MenuInhalt
[count
], "GREEN");
480 pMenuInhalt
[count
] = MenuInhalt
[count
];
481 NicEntry
[_GREEN_CARD_
] = count
;
482 sprintf(temp
, "GREEN: %s\n", knics
[_GREEN_CARD_
].description
);
483 strcat(message
, temp
);
484 if ( strlen(knics
[_GREEN_CARD_
].macaddr
) ) {
485 sprintf(temp
, "GREEN: (%s) %s green0\n", knics
[_GREEN_CARD_
].macaddr
, ctr
[TR_AS
]);
486 strcat(message
, temp
);
492 strcpy(MenuInhalt
[count
], "RED");
493 pMenuInhalt
[count
] = MenuInhalt
[count
];
494 NicEntry
[_RED_CARD_
] = count
;
495 // fprintf(flog,"found: %s as entry %d\n", MenuInhalt[count], NicEntry[count]); // #### Debug ####
496 sprintf(temp
, "RED: %s\n", knics
[_RED_CARD_
].description
);
497 strcat(message
, temp
);
498 if ( strlen(knics
[_RED_CARD_
].macaddr
) ) {
499 sprintf(temp
, "RED: (%s) %s red0\n", knics
[_RED_CARD_
].macaddr
, ctr
[TR_AS
]);
500 strcat(message
, temp
);
506 strcpy(MenuInhalt
[count
], "ORANGE");
507 pMenuInhalt
[count
] = MenuInhalt
[count
];
508 NicEntry
[_ORANGE_CARD_
] = count
;
509 // fprintf(flog,"found: %s as entry %d\n", MenuInhalt[count], NicEntry[count]); // #### Debug ####
510 sprintf(temp
, "ORANGE: %s\n", knics
[_ORANGE_CARD_
].description
);
511 strcat(message
, temp
);
512 if ( strlen(knics
[_ORANGE_CARD_
].macaddr
) ) {
513 sprintf(temp
, "ORANGE: (%s) %s orange0\n", knics
[_ORANGE_CARD_
].macaddr
, ctr
[TR_AS
]);
514 strcat(message
, temp
);
520 strcpy(MenuInhalt
[count
], "BLUE");
521 pMenuInhalt
[count
] = MenuInhalt
[count
];
522 NicEntry
[_BLUE_CARD_
] = count
;
523 // fprintf(flog,"found: %s as entry %d\n", MenuInhalt[count], NicEntry[count]); // #### Debug ####
524 sprintf(temp
, "BLUE: %s\n", knics
[_BLUE_CARD_
].description
);
525 strcat(message
, temp
);
526 if ( strlen(knics
[_BLUE_CARD_
].macaddr
) ) {
527 sprintf(temp
, "BLUE: (%s) %s blue0\n", knics
[_BLUE_CARD_
].macaddr
, ctr
[TR_AS
]);
528 strcat(message
, temp
);
532 pMenuInhalt
[count
] = NULL
;
534 rc
= newtWinMenu("(TR) Netcard Farbe", message
, 70, 5, 5, 6, pMenuInhalt
, &choise
, ctr
[TR_SELECT
], "(TR) Entfernen" , ctr
[TR_DONE
], NULL
);
536 if ( rc
== 0 || rc
== 1) {
537 // write_configs_netudev(pnics[choise].description, pnics[choise].macaddr, colour);
538 // insert nic to colourcard
539 if ((green
) && ( choise
== NicEntry
[0])) nicmenu(_GREEN_CARD_
);
540 if ((red
) && ( choise
== NicEntry
[1])) nicmenu(_RED_CARD_
);
541 if ((orange
) && ( choise
== NicEntry
[2])) nicmenu(_ORANGE_CARD_
);
542 if ((blue
) && ( choise
== NicEntry
[3])) nicmenu(_BLUE_CARD_
);
543 } else if (rc
== 2) {
544 if ((green
) && ( choise
== NicEntry
[0])) ask_clear_card_entry(_GREEN_CARD_
);
545 if ((red
) && ( choise
== NicEntry
[1])) ask_clear_card_entry(_RED_CARD_
);
546 if ((orange
) && ( choise
== NicEntry
[2])) ask_clear_card_entry(_ORANGE_CARD_
);
547 if ((blue
) && ( choise
== NicEntry
[3])) ask_clear_card_entry(_BLUE_CARD_
);
550 // errorbox("Sie haben keine Netzwerkkarte ausgewaehlt.\n");
556 // writekeyvalues(kv, CONFIG_ROOT "/ethernet/settings");
562 // Let user change GREEN address.
563 int greenaddressmenu(void)
565 struct keyvalue
*kv
= initkeyvalues();
569 if (!(readkeyvalues(kv
, CONFIG_ROOT
"/ethernet/settings")))
572 errorbox(ctr
[TR_UNABLE_TO_OPEN_SETTINGS_FILE
]);
576 sprintf(message
, ctr
[TR_WARNING_LONG
], NAME
);
577 rc
= newtWinChoice(ctr
[TR_WARNING
], ctr
[TR_OK
], ctr
[TR_CANCEL
], message
);
579 if (rc
== 0 || rc
== 1)
581 if (changeaddress(kv
, "GREEN", 0, ""))
583 netaddresschange
= 1;
584 writekeyvalues(kv
, CONFIG_ROOT
"/ethernet/settings");
594 // They can change BLUE, ORANGE and GREEN too :)
595 int addressesmenu(void)
597 struct keyvalue
*kv
= initkeyvalues();
598 struct keyvalue
*mainkv
= initkeyvalues();
601 char *green
= "GREEN";
602 char *orange
= "ORANGE";
606 char greenaddress
[STRING_SIZE
];
607 char oldgreenaddress
[STRING_SIZE
];
608 char temp
[STRING_SIZE
];
609 char temp2
[STRING_SIZE
];
614 char hostname
[STRING_SIZE
];
616 if (!(readkeyvalues(kv
, CONFIG_ROOT
"/ethernet/settings")))
619 freekeyvalues(mainkv
);
620 errorbox(ctr
[TR_UNABLE_TO_OPEN_SETTINGS_FILE
]);
623 if (!(readkeyvalues(mainkv
, CONFIG_ROOT
"/main/settings")))
626 freekeyvalues(mainkv
);
627 errorbox(ctr
[TR_UNABLE_TO_OPEN_SETTINGS_FILE
]);
631 strcpy(temp
, "0"); findkey(kv
, "CONFIG_TYPE", temp
);
632 configtype
= atol(temp
);
643 sections
[c
] = orange
;
657 rc
= newtWinMenu(ctr
[TR_ADDRESS_SETTINGS
],
658 ctr
[TR_SELECT_THE_INTERFACE_YOU_WISH_TO_RECONFIGURE
], 50, 5,
659 5, 6, sections
, &choice
, ctr
[TR_OK
], ctr
[TR_DONE
], NULL
);
661 if (rc
== 0 || rc
== 1)
663 if (strcmp(sections
[choice
], "GREEN") == 0)
665 findkey(kv
, "GREEN_ADDRESS", oldgreenaddress
);
666 sprintf(message
, ctr
[TR_WARNING_LONG
], NAME
);
667 rc
= newtWinChoice(ctr
[TR_WARNING
], ctr
[TR_OK
], ctr
[TR_CANCEL
],
669 if (rc
== 0 || rc
== 1)
671 if (changeaddress(kv
, "GREEN", 0, ""))
673 netaddresschange
= 1;
674 writekeyvalues(kv
, CONFIG_ROOT
"/ethernet/settings");
676 findkey(kv
, "GREEN_ADDRESS", greenaddress
);
677 snprintf(temp
, STRING_SIZE
-1, "option routers %s", oldgreenaddress
);
678 snprintf(temp2
, STRING_SIZE
-1, "option routers %s", greenaddress
);
679 replace (CONFIG_ROOT
"/dhcp/dhcpd.conf", temp
, temp2
);
680 chown (CONFIG_ROOT
"/dhcp/dhcpd.conf", 99, 99);
684 if (strcmp(sections
[choice
], "BLUE") == 0)
686 if (changeaddress(kv
, "BLUE", 0, ""))
687 netaddresschange
= 1;
689 if (strcmp(sections
[choice
], "ORANGE") == 0)
691 if (changeaddress(kv
, "ORANGE", 0, ""))
692 netaddresschange
= 1;
694 if (strcmp(sections
[choice
], "RED") == 0)
696 strcpy(hostname
, "");
697 findkey(mainkv
, "HOSTNAME", hostname
);
698 if (changeaddress(kv
, "RED", 1, hostname
))
699 netaddresschange
= 1;
706 writekeyvalues(kv
, CONFIG_ROOT
"/ethernet/settings");
708 freekeyvalues(mainkv
);
713 /* DNS and default gateway.... */
714 int dnsgatewaymenu(void)
716 struct keyvalue
*kv
= initkeyvalues();
718 char temp
[STRING_SIZE
] = "0";
719 struct newtWinEntry entries
[DNSGATEWAY_TOTAL
+1];
720 char *values
[DNSGATEWAY_TOTAL
]; /* pointers for the values. */
725 if (!(readkeyvalues(kv
, CONFIG_ROOT
"/ethernet/settings")))
728 errorbox(ctr
[TR_UNABLE_TO_OPEN_SETTINGS_FILE
]);
732 /* strcpy(temp, "0"); findkey(kv, "CONFIG_TYPE", temp);
733 configtype = atol(temp);
738 errorbox(ctr[TR_DNS_GATEWAY_WITH_GREEN]);
742 entries
[DNS1
].text
= ctr
[TR_PRIMARY_DNS
];
743 strcpy(temp
, ""); findkey(kv
, "DNS1", temp
);
744 values
[DNS1
] = strdup(temp
);
745 entries
[DNS1
].value
= &values
[DNS1
];
746 entries
[DNS1
].flags
= 0;
748 entries
[DNS2
].text
= ctr
[TR_SECONDARY_DNS
];
749 strcpy(temp
, ""); findkey(kv
, "DNS2", temp
);
750 values
[DNS2
] = strdup(temp
);
751 entries
[DNS2
].value
= &values
[DNS2
];
752 entries
[DNS2
].flags
= 0;
754 entries
[DEFAULT_GATEWAY
].text
= ctr
[TR_DEFAULT_GATEWAY
];
755 strcpy(temp
, ""); findkey(kv
, "DEFAULT_GATEWAY", temp
);
756 values
[DEFAULT_GATEWAY
] = strdup(temp
);
757 entries
[DEFAULT_GATEWAY
].value
= &values
[DEFAULT_GATEWAY
];
758 entries
[DEFAULT_GATEWAY
].flags
= 0;
760 entries
[DNSGATEWAY_TOTAL
].text
= NULL
;
761 entries
[DNSGATEWAY_TOTAL
].value
= NULL
;
762 entries
[DNSGATEWAY_TOTAL
].flags
= 0;
768 rc
= newtWinEntries(ctr
[TR_DNS_AND_GATEWAY_SETTINGS
],
769 ctr
[TR_DNS_AND_GATEWAY_SETTINGS_LONG
], 50, 5, 5, 18, entries
,
770 ctr
[TR_OK
], ctr
[TR_CANCEL
], NULL
);
771 if (rc
== 0 || rc
== 1)
773 strcpy(message
, ctr
[TR_INVALID_FIELDS
]);
774 if (strlen(values
[DNS1
]))
776 if (inet_addr(values
[DNS1
]) == INADDR_NONE
)
778 strcat(message
, ctr
[TR_PRIMARY_DNS_CR
]);
782 if (strlen(values
[DNS2
]))
784 if (inet_addr(values
[DNS2
]) == INADDR_NONE
)
786 strcat(message
, ctr
[TR_SECONDARY_DNS_CR
]);
790 if (strlen(values
[DEFAULT_GATEWAY
]))
792 if (inet_addr(values
[DEFAULT_GATEWAY
]) == INADDR_NONE
)
794 strcat(message
, ctr
[TR_DEFAULT_GATEWAY_CR
]);
798 if (!strlen(values
[DNS1
]) && strlen(values
[DNS2
]))
800 strcpy(message
, ctr
[TR_SECONDARY_WITHOUT_PRIMARY_DNS
]);
808 replacekeyvalue(kv
, "DNS1", values
[DNS1
]);
809 replacekeyvalue(kv
, "DNS2", values
[DNS2
]);
810 replacekeyvalue(kv
, "DEFAULT_GATEWAY", values
[DEFAULT_GATEWAY
]);
811 netaddresschange
= 1;
814 free(values
[DEFAULT_GATEWAY
]);
815 writekeyvalues(kv
, CONFIG_ROOT
"/ethernet/settings");