]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/install+setup/install/nic.c
Installer repariert
[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 * $Id: nic.c,v 1.8.2.1 2004/04/14 22:05:40 gespinasse Exp $
11 *
12 */
13
14 #include "install.h"
15
16 #include <sys/socket.h>
17 #include <netinet/in.h>
18 #include <arpa/inet.h>
19
20 extern FILE *flog;
21 extern char *mylog;
22
23 extern char **ctr;
24
25 extern struct nic nics[];
26
27 int networkmenu(struct keyvalue *ethernetkv)
28 {
29 int rc;
30 char driver[STRING_SIZE] = "";
31 char driveroptions[STRING_SIZE] = "";
32 struct keyvalue *kv = initkeyvalues();
33 int result = 0;
34 char commandstring[STRING_SIZE];
35 char address[STRING_SIZE], netmask[STRING_SIZE];
36 int done;
37 char description[1000];
38 char message[1000];
39 char title[STRING_SIZE];
40 done = 0;
41
42 while (!done)
43 {
44 rc = newtWinTernary(ctr[TR_CONFIGURE_NETWORKING], ctr[TR_PROBE],
45 ctr[TR_SELECT], ctr[TR_CANCEL], ctr[TR_CONFIGURE_NETWORKING_LONG]);
46
47 if (rc == 0 || rc == 1)
48 {
49 probecards(driver, driveroptions);
50 if (!strlen(driver))
51 errorbox(ctr[TR_PROBE_FAILED]);
52 else
53 {
54 findnicdescription(driver, description);
55 sprintf (title, "%s v%s - %s", NAME, VERSION, SLOGAN);
56 sprintf(message, ctr[TR_FOUND_NIC], NAME, description);
57 newtWinMessage(title, ctr[TR_OK], message);
58 }
59 }
60 else if (rc == 2)
61 choosecards(driver, driveroptions);
62 else
63 done = 1;
64
65 if (strlen(driver))
66 done = 1;
67 }
68
69 if (!strlen(driver))
70 goto EXIT;
71
72 /* Default is a GREEN nic only. */
73 /* Smoothie is not untarred yet, so we have to delay actually writing the
74 * settings till later. */
75 replacekeyvalue(ethernetkv, "CONFIG_TYPE", "0");
76 replacekeyvalue(ethernetkv, "GREEN_DRIVER", driver);
77 replacekeyvalue(ethernetkv, "GREEN_DRIVER_OPTIONS", driveroptions);
78 replacekeyvalue(ethernetkv, "GREEN_DEV", "eth0");
79 replacekeyvalue(ethernetkv, "GREEN_DISPLAYDRIVER", driver);
80
81 if (!(changeaddress(ethernetkv, "GREEN", 0, "")))
82 goto EXIT;
83
84 strcpy(address, ""); findkey(ethernetkv, "GREEN_ADDRESS", address);
85 strcpy(netmask, ""); findkey(ethernetkv, "GREEN_NETMASK", netmask);
86
87 snprintf(commandstring, STRING_SIZE, "/bin/ifconfig eth0 %s netmask %s up",
88 address, netmask);
89 if (mysystem(commandstring))
90 {
91 errorbox(ctr[TR_INTERFACE_FAILED_TO_COME_UP]);
92 goto EXIT;
93 }
94
95 result = 1;
96
97 EXIT:
98 freekeyvalues(kv);
99
100 return result;
101 }
102