]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/install+setup/install/nic.c
Neue Netzwerkdialoge sind zum ersten Test verfuegbar.
[people/pmueller/ipfire-2.x.git] / src / install+setup / install / nic.c
1 /* SmoothWall install program.
2 *
3 * This program is distributed under the terms of the GNU General Public
4 * Licence. See the file COPYING for details.
5 *
6 * (c) Lawrence Manning, 2001
7 * Contains stuff related to firing up the network card, including a crude
8 * autodector.
9 *
10 */
11
12 #include "install.h"
13
14 #include <sys/socket.h>
15 #include <netinet/in.h>
16 #include <arpa/inet.h>
17
18 extern FILE *flog;
19 extern char *mylog;
20
21 extern char **ctr;
22
23 //extern struct nic nics[];
24 //extern struct knic knics[];
25
26 int networkmenu(struct keyvalue *ethernetkv)
27 {
28 int rc;
29 char driver[STRING_SIZE] = "";
30 char driveroptions[STRING_SIZE] = "";
31 int result = 0;
32 char commandstring[STRING_SIZE];
33 char address[STRING_SIZE], netmask[STRING_SIZE];
34 int done;
35 char description[1000];
36 char message[1000];
37 char title[STRING_SIZE];
38 done = 0;
39
40 while (!done)
41 {
42 rc = newtWinTernary(ctr[TR_CONFIGURE_NETWORKING], ctr[TR_PROBE],
43 ctr[TR_SELECT], ctr[TR_CANCEL], ctr[TR_CONFIGURE_NETWORKING_LONG]);
44
45 if (rc == 0 || rc == 1)
46 {
47 probecards(driver, driveroptions);
48 if (!strlen(driver))
49 errorbox(ctr[TR_PROBE_FAILED]);
50 else
51 {
52 //findnicdescription(driver, description);
53 sprintf (title, "%s v%s - %s", NAME, VERSION, SLOGAN);
54 sprintf(message, ctr[TR_FOUND_NIC], NAME, description);
55 newtWinMessage(title, ctr[TR_OK], message);
56 }
57 }
58 else
59 done = 1;
60
61 if (strlen(driver))
62 done = 1;
63 }
64
65 if (!strlen(driver))
66 goto EXIT;
67
68 /* Default is a GREEN nic only. */
69 /* Smoothie is not untarred yet, so we have to delay actually writing the
70 * settings till later. */
71 replacekeyvalue(ethernetkv, "CONFIG_TYPE", "0");
72 replacekeyvalue(ethernetkv, "GREEN_DEV", "eth0");
73 replacekeyvalue(ethernetkv, "GREEN_DISPLAYDRIVER", driver);
74
75 if (!(changeaddress(ethernetkv, "GREEN", 0, "")))
76 goto EXIT;
77
78 strcpy(address, ""); findkey(ethernetkv, "GREEN_ADDRESS", address);
79 strcpy(netmask, ""); findkey(ethernetkv, "GREEN_NETMASK", netmask);
80
81 snprintf(commandstring, STRING_SIZE, "/sbin/ifconfig eth0 %s netmask %s up",
82 address, netmask);
83 if (mysystem(commandstring))
84 {
85 errorbox(ctr[TR_INTERFACE_FAILED_TO_COME_UP]);
86 goto EXIT;
87 }
88
89 result = 1;
90
91 EXIT:
92
93 return result;
94 }