]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/install+setup/install/nic.c
Ich hab mal ein bisschen die Arbeit vom Cuebernommen :D
[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
25 int networkmenu(struct keyvalue *ethernetkv)
26 {
27 int rc;
28 char driver[STRING_SIZE] = "";
29 char driveroptions[STRING_SIZE] = "";
30 int result = 0;
31 char commandstring[STRING_SIZE];
32 char address[STRING_SIZE], netmask[STRING_SIZE];
33 int done;
34 char description[1000];
35 char message[1000];
36 char title[STRING_SIZE];
37 done = 0;
38
39 while (!done)
40 {
41 rc = newtWinTernary(ctr[TR_CONFIGURE_NETWORKING], ctr[TR_PROBE],
42 ctr[TR_SELECT], ctr[TR_CANCEL], ctr[TR_CONFIGURE_NETWORKING_LONG]);
43
44 if (rc == 0 || rc == 1)
45 {
46 probecards(driver, driveroptions);
47 if (!strlen(driver))
48 errorbox(ctr[TR_PROBE_FAILED]);
49 else
50 {
51 findnicdescription(driver, description);
52 sprintf (title, "%s v%s - %s", NAME, VERSION, SLOGAN);
53 sprintf(message, ctr[TR_FOUND_NIC], NAME, description);
54 newtWinMessage(title, ctr[TR_OK], message);
55 }
56 }
57 else if (rc == 2)
58 choosecards(driver, driveroptions);
59 else
60 done = 1;
61
62 if (strlen(driver))
63 done = 1;
64 }
65
66 if (!strlen(driver))
67 goto EXIT;
68
69 /* Default is a GREEN nic only. */
70 /* Smoothie is not untarred yet, so we have to delay actually writing the
71 * settings till later. */
72 replacekeyvalue(ethernetkv, "CONFIG_TYPE", "0");
73 replacekeyvalue(ethernetkv, "GREEN_DRIVER", driver);
74 replacekeyvalue(ethernetkv, "GREEN_DRIVER_OPTIONS", driveroptions);
75 replacekeyvalue(ethernetkv, "GREEN_DEV", "eth0");
76 replacekeyvalue(ethernetkv, "GREEN_DISPLAYDRIVER", driver);
77
78 if (!(changeaddress(ethernetkv, "GREEN", 0, "")))
79 goto EXIT;
80
81 strcpy(address, ""); findkey(ethernetkv, "GREEN_ADDRESS", address);
82 strcpy(netmask, ""); findkey(ethernetkv, "GREEN_NETMASK", netmask);
83
84 snprintf(commandstring, STRING_SIZE, "/bin/ifconfig eth0 %s netmask %s up",
85 address, netmask);
86 if (mysystem(commandstring))
87 {
88 errorbox(ctr[TR_INTERFACE_FAILED_TO_COME_UP]);
89 goto EXIT;
90 }
91
92 result = 1;
93
94 EXIT:
95
96 return result;
97 }