]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blame - src/install+setup/install/nic.c
Neue Hardwareerkennung im Installer...
[people/teissler/ipfire-2.x.git] / src / install+setup / install / nic.c
CommitLineData
d6aaa55d
MT
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 *
d6aaa55d
MT
10 */
11
12#include "install.h"
13
14#include <sys/socket.h>
15#include <netinet/in.h>
16#include <arpa/inet.h>
17
18extern FILE *flog;
19extern char *mylog;
10bc6f06 20
d6aaa55d 21extern char **ctr;
10bc6f06 22
d6aaa55d
MT
23extern struct nic nics[];
24
25int networkmenu(struct keyvalue *ethernetkv)
26{
b4e381a8 27 int rc;
d6aaa55d
MT
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];
b4e381a8 33 int done;
d6aaa55d
MT
34 char description[1000];
35 char message[1000];
36 char title[STRING_SIZE];
b4e381a8 37 done = 0;
d6aaa55d 38
b4e381a8 39 while (!done)
d6aaa55d 40 {
b4e381a8
MT
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);
d6aaa55d 59 else
b4e381a8
MT
60 done = 1;
61
62 if (strlen(driver))
63 done = 1;
33634aa8 64 }
b4e381a8
MT
65
66 if (!strlen(driver))
33634aa8 67 goto EXIT;
d6aaa55d
MT
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
4809e64e 84 snprintf(commandstring, STRING_SIZE, "/sbin/ifconfig eth0 %s netmask %s up",
d6aaa55d
MT
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
94EXIT:
95
96 return result;
97}