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
]);
140 runcommandwithstatus("/etc/rc.d/init.d/network start",
141 ctr
[TR_PULLING_NETWORK_UP
]);
148 int oktoleave(char *errormessage
)
150 struct keyvalue
*kv
= initkeyvalues();
151 char temp
[STRING_SIZE
];
154 if (!(readkeyvalues(kv
, CONFIG_ROOT
"/ethernet/settings")))
157 errorbox(ctr
[TR_UNABLE_TO_OPEN_SETTINGS_FILE
]);
161 strcpy(temp
, "0"); findkey(kv
, "CONFIG_TYPE", temp
); configtype
= atol(temp
);
162 if (configtype
< 1 || configtype
> 4) configtype
= 0;
166 strcpy(temp
, ""); findkey(kv
, "GREEN_DEV", temp
);
169 strcpy(errormessage
, ctr
[TR_NO_GREEN_INTERFACE
]);
172 if (!(interfacecheck(kv
, "GREEN")))
174 strcpy(errormessage
, "(TR) GRÜNE IP nicht konfiguriert.\n"); //ctr[TR_MISSING_GREEN_IP]);
180 strcpy(temp
, ""); findkey(kv
, "RED_DEV", temp
);
183 strcpy(errormessage
, ctr
[TR_NO_RED_INTERFACE
]);
186 if (!(interfacecheck(kv
, "RED")))
188 strcpy(errormessage
, ctr
[TR_MISSING_RED_IP
]);
194 strcpy(temp
, ""); findkey(kv
, "ORANGE_DEV", temp
);
197 strcpy(errormessage
, ctr
[TR_NO_ORANGE_INTERFACE
]);
200 if (!(interfacecheck(kv
, "ORANGE")))
202 strcpy(errormessage
, ctr
[TR_MISSING_ORANGE_IP
]);
208 strcpy(temp
, ""); findkey(kv
, "BLUE_DEV", temp
);
211 strcpy(errormessage
, ctr
[TR_NO_BLUE_INTERFACE
]);
214 if (!(interfacecheck(kv
, "BLUE")))
216 strcpy(errormessage
, ctr
[TR_MISSING_BLUE_IP
]);
222 strcpy(temp
, ""); findkey(kv
, "DNS1", temp
);
225 strcpy(errormessage
, "(TR) Kein DNS eingetragen\n");
228 strcpy(temp
, ""); findkey(kv
, "DEFAULT_GATEWAY", temp
);
231 strcpy(errormessage
, "(TR) Kein default Gateway eingetragen.\n");
235 strcpy(errormessage
, "");
239 if (strlen(errormessage
))
246 /* Shows the main menu and a summary of the current settings. */
249 char *sections
[] = { ctr
[TR_NETWORK_CONFIGURATION_TYPE
],
250 ctr
[TR_DRIVERS_AND_CARD_ASSIGNMENTS
],
251 ctr
[TR_ADDRESS_SETTINGS
],
252 ctr
[TR_DNS_AND_GATEWAY_SETTINGS
], NULL
};
254 static int choice
= 0;
255 struct keyvalue
*kv
= initkeyvalues();
257 char temp
[STRING_SIZE
];
260 char networkrestart
[STRING_SIZE
] = "";
262 if (!(readkeyvalues(kv
, CONFIG_ROOT
"/ethernet/settings")))
265 errorbox(ctr
[TR_UNABLE_TO_OPEN_SETTINGS_FILE
]);
269 if (netaddresschange
)
270 strcpy(networkrestart
, ctr
[TR_RESTART_REQUIRED
]);
272 strcpy(temp
, ""); findkey(kv
, "CONFIG_TYPE", temp
); x
= atol(temp
);
273 if (x
< 1 || x
> 4) x
= 0;
274 /* Format heading bit. */
275 snprintf(message
, 1000, ctr
[TR_CURRENT_CONFIG
], configtypenames
[x
],
277 rc
= newtWinMenu(ctr
[TR_NETWORK_CONFIGURATION_MENU
], message
, 50, 5, 5, 6,
278 sections
, &choice
, ctr
[TR_OK
], ctr
[TR_DONE
], NULL
);
280 if (rc
== 0 || rc
== 1)
288 /* Here they choose general network config, number of nics etc. */
289 int configtypemenu(void)
291 struct keyvalue
*kv
= initkeyvalues();
292 char temp
[STRING_SIZE
] = "0";
297 fprintf(flog
,"Enter ConfigMenu\n");
299 if (!(readkeyvalues(kv
, CONFIG_ROOT
"/ethernet/settings")))
302 errorbox(ctr
[TR_UNABLE_TO_OPEN_SETTINGS_FILE
]);
306 found
= scan_network_cards();
307 fprintf(flog
,"found %d Card\'s\n", found
); // #### Debug ####
309 findkey(kv
, "CONFIG_TYPE", temp
); choise
= atol(temp
);
313 sprintf(message
, ctr
[TR_NETWORK_CONFIGURATION_TYPE_LONG
], NAME
);
314 rc
= newtWinMenu(ctr
[TR_NETWORK_CONFIGURATION_TYPE
], message
, 50, 5, 5,
315 6, configtypenames
, &choise
, ctr
[TR_OK
], ctr
[TR_CANCEL
], NULL
);
316 if ( configtypecards
[choise
] > found
) {
317 sprintf(message
, "(TR) Nicht genuegend Netzwerkkarten fuer diese Auswahl gefunden.\n\nBenoetigt: %d\nGefunden: %d\n", configtypecards
[choise
], found
);
321 while ( configtypecards
[choise
] > found
);
323 if (rc
== 0 || rc
== 1)
325 // if (automode != 0) runcommandwithstatus("/etc/rc.d/init.d/network stop red blue orange", ctr[TR_PUSHING_NON_LOCAL_NETWORK_DOWN]);
327 sprintf(temp
, "%d", choise
);
328 replacekeyvalue(kv
, "CONFIG_TYPE", temp
);
329 clear_card_entry(_RED_CARD_
);
330 clear_card_entry(_ORANGE_CARD_
);
331 clear_card_entry(_BLUE_CARD_
);
333 writekeyvalues(kv
, CONFIG_ROOT
"/ethernet/settings");
334 netaddresschange
= 1;
343 /* Driver menu. Choose drivers.. */
346 struct keyvalue
*kv
= initkeyvalues();
347 char message
[STRING_SIZE
];
348 char temp
[STRING_SIZE
];
351 int i
, rc
, kcount
= 0, neednics
; //i = 0, count = 0,
353 fprintf(flog
,"Enter drivermenu\n"); // #### Debug ####
355 if (!(readkeyvalues(kv
, CONFIG_ROOT
"/ethernet/settings")))
358 errorbox(ctr
[TR_UNABLE_TO_OPEN_SETTINGS_FILE
]);
362 strcpy(temp
, "0"); findkey(kv
, "CONFIG_TYPE", temp
);
363 configtype
= atol(temp
);
365 strcpy(message
, ctr
[TR_CONFIGURE_NETWORK_DRIVERS
]);
367 kcount
= 0; // counter to find knowing nics.
368 neednics
= 0; // counter to use needing nics.
370 sprintf(temp
, "GREEN: %s\n", knics
[_GREEN_CARD_
].description
);
371 strcat(message
, temp
);
372 if (strlen(knics
[_GREEN_CARD_
].macaddr
) ) {
373 sprintf(temp
, "GREEN: (%s) %s green0\n", knics
[_GREEN_CARD_
].macaddr
, ctr
[TR_AS
]);
374 strcat(message
, temp
);
379 sprintf(temp
, "RED: %s\n", knics
[_RED_CARD_
].description
);
380 strcat(message
, temp
);
381 if (strlen(knics
[_RED_CARD_
].macaddr
) ) {
382 sprintf(temp
, "RED: (%s) %s red0\n", knics
[_RED_CARD_
].macaddr
, ctr
[TR_AS
]);
383 strcat(message
, temp
);
388 sprintf(temp
, "ORANGE: %s\n", knics
[_ORANGE_CARD_
].description
);
389 strcat(message
, temp
);
390 if ( strlen(knics
[_ORANGE_CARD_
].macaddr
) ) {
391 sprintf(temp
, "ORANGE: (%s) %s orange0\n", knics
[_ORANGE_CARD_
].macaddr
, ctr
[TR_AS
]);
392 strcat(message
, temp
);
397 sprintf(temp
, "BLUE: %s\n", knics
[_BLUE_CARD_
].description
);
398 strcat(message
, temp
);
399 if (strlen(knics
[_BLUE_CARD_
].macaddr
)) {
400 sprintf(temp
, "BLUE: (%s) %s blue0\n", knics
[_BLUE_CARD_
].macaddr
, ctr
[TR_AS
]);
401 strcat(message
, temp
);
406 for ( i
=0 ; i
<4;i
++) if (strcmp(knics
[i
].macaddr
, "")) kcount
++;
407 fprintf(flog
,"found %d knowing Card\'s\n", kcount
); // #### DEBUG ####
409 if (neednics
= kcount
)
411 strcat(message
, ctr
[TR_DO_YOU_WISH_TO_CHANGE_THESE_SETTINGS
]);
412 rc
= newtWinChoice(ctr
[TR_DRIVERS_AND_CARD_ASSIGNMENTS
], ctr
[TR_OK
],
413 ctr
[TR_CANCEL
], message
);
414 if (rc
== 0 || rc
== 1)
416 /* Shit, got to do something.. */
420 // strcat(message, "\nEs wurden noch nicht alle Netzwerkkarten konfiguriert.\n");
421 // newtWinMessage(ctr[TR_DRIVERS_AND_CARD_ASSIGNMENTS], ctr[TR_OK], message);
422 /* Shit, got to do something.. */
430 int set_menu_entry_for(int *nr
, int *card
)
435 int changedrivers(void)
437 struct keyvalue
*kv
= initkeyvalues();
438 char temp
[STRING_SIZE
], message
[STRING_SIZE
];
440 int green
= 0, red
= 0, blue
= 0, orange
= 0;
441 char MenuInhalt
[10][180];
442 char *pMenuInhalt
[10];
443 int count
= 0, choise
= 0, rc
;
446 if (!(readkeyvalues(kv
, CONFIG_ROOT
"/ethernet/settings")))
449 errorbox(ctr
[TR_UNABLE_TO_OPEN_SETTINGS_FILE
]);
452 fprintf(flog
,"stop network on red, blue and orange\n"); // #### Debug ####
453 runcommandwithstatus("/etc/rc.d/init.d/network stop red blue orange",
454 ctr
[TR_PUSHING_NON_LOCAL_NETWORK_DOWN
]);
456 findkey(kv
, "CONFIG_TYPE", temp
); configtype
= atol(temp
);
459 else if (configtype
== 1)
460 { green
= 1; red
= 1; }
461 else if (configtype
== 2)
462 { green
= 1; red
= 1; orange
= 1; }
463 else if (configtype
== 3)
464 { green
= 1; red
= 1; blue
= 1; }
465 else if (configtype
== 4)
466 { green
= 1; red
=1; orange
=1; blue
= 1; }
467 // else if (configtype == 5)
468 // { green = 1; blue = 1; orange = 1; }
469 // else if (configtype == 6)
470 // { green = 1; red = 1; blue = 1; }
471 // else if (configtype == 7)
472 // { green = 1; red = 1; blue = 1; orange = 1; }
474 fprintf(flog
,"found: g=%d r=%d o=%d b=%d\n",green
, red
, orange
, blue
); // #### Debug ####
479 strcpy(message
, "(TR) Bitte wählen Sie das Interface aus das geaendert werden soll.\n\n");
482 strcpy(MenuInhalt
[count
], "GREEN");
483 pMenuInhalt
[count
] = MenuInhalt
[count
];
484 NicEntry
[_GREEN_CARD_
] = count
;
485 sprintf(temp
, "GREEN: %s\n", knics
[_GREEN_CARD_
].description
);
486 strcat(message
, temp
);
487 if ( strlen(knics
[_GREEN_CARD_
].macaddr
) ) {
488 sprintf(temp
, "GREEN: (%s) %s green0\n", knics
[_GREEN_CARD_
].macaddr
, ctr
[TR_AS
]);
489 strcat(message
, temp
);
495 strcpy(MenuInhalt
[count
], "RED");
496 pMenuInhalt
[count
] = MenuInhalt
[count
];
497 NicEntry
[_RED_CARD_
] = count
;
498 // fprintf(flog,"found: %s as entry %d\n", MenuInhalt[count], NicEntry[count]); // #### Debug ####
499 sprintf(temp
, "RED: %s\n", knics
[_RED_CARD_
].description
);
500 strcat(message
, temp
);
501 if ( strlen(knics
[_RED_CARD_
].macaddr
) ) {
502 sprintf(temp
, "RED: (%s) %s red0\n", knics
[_RED_CARD_
].macaddr
, ctr
[TR_AS
]);
503 strcat(message
, temp
);
509 strcpy(MenuInhalt
[count
], "ORANGE");
510 pMenuInhalt
[count
] = MenuInhalt
[count
];
511 NicEntry
[_ORANGE_CARD_
] = count
;
512 // fprintf(flog,"found: %s as entry %d\n", MenuInhalt[count], NicEntry[count]); // #### Debug ####
513 sprintf(temp
, "ORANGE: %s\n", knics
[_ORANGE_CARD_
].description
);
514 strcat(message
, temp
);
515 if ( strlen(knics
[_ORANGE_CARD_
].macaddr
) ) {
516 sprintf(temp
, "ORANGE: (%s) %s orange0\n", knics
[_ORANGE_CARD_
].macaddr
, ctr
[TR_AS
]);
517 strcat(message
, temp
);
523 strcpy(MenuInhalt
[count
], "BLUE");
524 pMenuInhalt
[count
] = MenuInhalt
[count
];
525 NicEntry
[_BLUE_CARD_
] = count
;
526 // fprintf(flog,"found: %s as entry %d\n", MenuInhalt[count], NicEntry[count]); // #### Debug ####
527 sprintf(temp
, "BLUE: %s\n", knics
[_BLUE_CARD_
].description
);
528 strcat(message
, temp
);
529 if ( strlen(knics
[_BLUE_CARD_
].macaddr
) ) {
530 sprintf(temp
, "BLUE: (%s) %s blue0\n", knics
[_BLUE_CARD_
].macaddr
, ctr
[TR_AS
]);
531 strcat(message
, temp
);
535 pMenuInhalt
[count
] = NULL
;
537 rc
= newtWinMenu("(TR) Netcard Farbe", message
, 70, 5, 5, 6, pMenuInhalt
, &choise
, ctr
[TR_SELECT
], "(TR) Entfernen" , ctr
[TR_DONE
], NULL
);
539 if ( rc
== 0 || rc
== 1) {
540 // write_configs_netudev(pnics[choise].description, pnics[choise].macaddr, colour);
541 // insert nic to colourcard
542 if ((green
) && ( choise
== NicEntry
[0])) nicmenu(_GREEN_CARD_
);
543 if ((red
) && ( choise
== NicEntry
[1])) nicmenu(_RED_CARD_
);
544 if ((orange
) && ( choise
== NicEntry
[2])) nicmenu(_ORANGE_CARD_
);
545 if ((blue
) && ( choise
== NicEntry
[3])) nicmenu(_BLUE_CARD_
);
546 netaddresschange
= 1;
547 } else if (rc
== 2) {
548 if ((green
) && ( choise
== NicEntry
[0])) ask_clear_card_entry(_GREEN_CARD_
);
549 if ((red
) && ( choise
== NicEntry
[1])) ask_clear_card_entry(_RED_CARD_
);
550 if ((orange
) && ( choise
== NicEntry
[2])) ask_clear_card_entry(_ORANGE_CARD_
);
551 if ((blue
) && ( choise
== NicEntry
[3])) ask_clear_card_entry(_BLUE_CARD_
);
552 netaddresschange
= 1;
555 // errorbox("Sie haben keine Netzwerkkarte ausgewaehlt.\n");
561 // writekeyvalues(kv, CONFIG_ROOT "/ethernet/settings");
567 // Let user change GREEN address.
568 int greenaddressmenu(void)
570 struct keyvalue
*kv
= initkeyvalues();
574 if (!(readkeyvalues(kv
, CONFIG_ROOT
"/ethernet/settings")))
577 errorbox(ctr
[TR_UNABLE_TO_OPEN_SETTINGS_FILE
]);
581 sprintf(message
, ctr
[TR_WARNING_LONG
], NAME
);
582 rc
= newtWinChoice(ctr
[TR_WARNING
], ctr
[TR_OK
], ctr
[TR_CANCEL
], message
);
584 if (rc
== 0 || rc
== 1)
586 if (changeaddress(kv
, "GREEN", 0, ""))
588 netaddresschange
= 1;
589 writekeyvalues(kv
, CONFIG_ROOT
"/ethernet/settings");
599 // They can change BLUE, ORANGE and GREEN too :)
600 int addressesmenu(void)
602 struct keyvalue
*kv
= initkeyvalues();
603 struct keyvalue
*mainkv
= initkeyvalues();
606 char *green
= "GREEN";
607 char *orange
= "ORANGE";
611 char greenaddress
[STRING_SIZE
];
612 char oldgreenaddress
[STRING_SIZE
];
613 char temp
[STRING_SIZE
];
614 char temp2
[STRING_SIZE
];
619 char hostname
[STRING_SIZE
];
621 if (!(readkeyvalues(kv
, CONFIG_ROOT
"/ethernet/settings")))
624 freekeyvalues(mainkv
);
625 errorbox(ctr
[TR_UNABLE_TO_OPEN_SETTINGS_FILE
]);
628 if (!(readkeyvalues(mainkv
, CONFIG_ROOT
"/main/settings")))
631 freekeyvalues(mainkv
);
632 errorbox(ctr
[TR_UNABLE_TO_OPEN_SETTINGS_FILE
]);
636 strcpy(temp
, "0"); findkey(kv
, "CONFIG_TYPE", temp
);
637 configtype
= atol(temp
);
648 sections
[c
] = orange
;
662 rc
= newtWinMenu(ctr
[TR_ADDRESS_SETTINGS
],
663 ctr
[TR_SELECT_THE_INTERFACE_YOU_WISH_TO_RECONFIGURE
], 50, 5,
664 5, 6, sections
, &choice
, ctr
[TR_OK
], ctr
[TR_DONE
], NULL
);
666 if (rc
== 0 || rc
== 1)
668 if (strcmp(sections
[choice
], "GREEN") == 0)
670 findkey(kv
, "GREEN_ADDRESS", oldgreenaddress
);
671 sprintf(message
, ctr
[TR_WARNING_LONG
], NAME
);
672 rc
= newtWinChoice(ctr
[TR_WARNING
], ctr
[TR_OK
], ctr
[TR_CANCEL
],
674 if (rc
== 0 || rc
== 1)
676 if (changeaddress(kv
, "GREEN", 0, ""))
678 netaddresschange
= 1;
679 writekeyvalues(kv
, CONFIG_ROOT
"/ethernet/settings");
681 findkey(kv
, "GREEN_ADDRESS", greenaddress
);
682 snprintf(temp
, STRING_SIZE
-1, "option routers %s", oldgreenaddress
);
683 snprintf(temp2
, STRING_SIZE
-1, "option routers %s", greenaddress
);
684 replace (CONFIG_ROOT
"/dhcp/dhcpd.conf", temp
, temp2
);
685 chown (CONFIG_ROOT
"/dhcp/dhcpd.conf", 99, 99);
689 if (strcmp(sections
[choice
], "BLUE") == 0)
691 if (changeaddress(kv
, "BLUE", 0, ""))
692 netaddresschange
= 1;
694 if (strcmp(sections
[choice
], "ORANGE") == 0)
696 if (changeaddress(kv
, "ORANGE", 0, ""))
697 netaddresschange
= 1;
699 if (strcmp(sections
[choice
], "RED") == 0)
701 strcpy(hostname
, "");
702 findkey(mainkv
, "HOSTNAME", hostname
);
703 if (changeaddress(kv
, "RED", 1, hostname
))
704 netaddresschange
= 1;
711 writekeyvalues(kv
, CONFIG_ROOT
"/ethernet/settings");
713 freekeyvalues(mainkv
);
718 /* DNS and default gateway.... */
719 int dnsgatewaymenu(void)
721 struct keyvalue
*kv
= initkeyvalues();
723 char temp
[STRING_SIZE
] = "0";
724 struct newtWinEntry entries
[DNSGATEWAY_TOTAL
+1];
725 char *values
[DNSGATEWAY_TOTAL
]; /* pointers for the values. */
730 if (!(readkeyvalues(kv
, CONFIG_ROOT
"/ethernet/settings")))
733 errorbox(ctr
[TR_UNABLE_TO_OPEN_SETTINGS_FILE
]);
737 /* strcpy(temp, "0"); findkey(kv, "CONFIG_TYPE", temp);
738 configtype = atol(temp);
743 errorbox(ctr[TR_DNS_GATEWAY_WITH_GREEN]);
747 entries
[DNS1
].text
= ctr
[TR_PRIMARY_DNS
];
748 strcpy(temp
, ""); findkey(kv
, "DNS1", temp
);
749 values
[DNS1
] = strdup(temp
);
750 entries
[DNS1
].value
= &values
[DNS1
];
751 entries
[DNS1
].flags
= 0;
753 entries
[DNS2
].text
= ctr
[TR_SECONDARY_DNS
];
754 strcpy(temp
, ""); findkey(kv
, "DNS2", temp
);
755 values
[DNS2
] = strdup(temp
);
756 entries
[DNS2
].value
= &values
[DNS2
];
757 entries
[DNS2
].flags
= 0;
759 entries
[DEFAULT_GATEWAY
].text
= ctr
[TR_DEFAULT_GATEWAY
];
760 strcpy(temp
, ""); findkey(kv
, "DEFAULT_GATEWAY", temp
);
761 values
[DEFAULT_GATEWAY
] = strdup(temp
);
762 entries
[DEFAULT_GATEWAY
].value
= &values
[DEFAULT_GATEWAY
];
763 entries
[DEFAULT_GATEWAY
].flags
= 0;
765 entries
[DNSGATEWAY_TOTAL
].text
= NULL
;
766 entries
[DNSGATEWAY_TOTAL
].value
= NULL
;
767 entries
[DNSGATEWAY_TOTAL
].flags
= 0;
773 rc
= newtWinEntries(ctr
[TR_DNS_AND_GATEWAY_SETTINGS
],
774 ctr
[TR_DNS_AND_GATEWAY_SETTINGS_LONG
], 50, 5, 5, 18, entries
,
775 ctr
[TR_OK
], ctr
[TR_CANCEL
], NULL
);
776 if (rc
== 0 || rc
== 1)
778 strcpy(message
, ctr
[TR_INVALID_FIELDS
]);
779 if (strlen(values
[DNS1
]))
781 if (inet_addr(values
[DNS1
]) == INADDR_NONE
)
783 strcat(message
, ctr
[TR_PRIMARY_DNS_CR
]);
787 if (strlen(values
[DNS2
]))
789 if (inet_addr(values
[DNS2
]) == INADDR_NONE
)
791 strcat(message
, ctr
[TR_SECONDARY_DNS_CR
]);
795 if (strlen(values
[DEFAULT_GATEWAY
]))
797 if (inet_addr(values
[DEFAULT_GATEWAY
]) == INADDR_NONE
)
799 strcat(message
, ctr
[TR_DEFAULT_GATEWAY_CR
]);
803 if (!strlen(values
[DNS1
]) && strlen(values
[DNS2
]))
805 strcpy(message
, ctr
[TR_SECONDARY_WITHOUT_PRIMARY_DNS
]);
813 replacekeyvalue(kv
, "DNS1", values
[DNS1
]);
814 replacekeyvalue(kv
, "DNS2", values
[DNS2
]);
815 replacekeyvalue(kv
, "DEFAULT_GATEWAY", values
[DEFAULT_GATEWAY
]);
816 netaddresschange
= 1;
819 free(values
[DEFAULT_GATEWAY
]);
820 writekeyvalues(kv
, CONFIG_ROOT
"/ethernet/settings");