]>
Commit | Line | Data |
---|---|---|
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 | ||
18 | extern FILE *flog; | |
19 | extern char *mylog; | |
10bc6f06 | 20 | |
d6aaa55d | 21 | extern char **ctr; |
10bc6f06 | 22 | |
d6aaa55d MT |
23 | extern struct nic nics[]; |
24 | ||
25 | int 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 | { | |
75ae2191 | 51 | //findnicdescription(driver, description); |
b4e381a8 MT |
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 | } | |
75ae2191 | 56 | } |
d6aaa55d | 57 | else |
b4e381a8 MT |
58 | done = 1; |
59 | ||
60 | if (strlen(driver)) | |
61 | done = 1; | |
33634aa8 | 62 | } |
b4e381a8 MT |
63 | |
64 | if (!strlen(driver)) | |
33634aa8 | 65 | goto EXIT; |
d6aaa55d MT |
66 | |
67 | /* Default is a GREEN nic only. */ | |
68 | /* Smoothie is not untarred yet, so we have to delay actually writing the | |
69 | * settings till later. */ | |
70 | replacekeyvalue(ethernetkv, "CONFIG_TYPE", "0"); | |
d6aaa55d MT |
71 | replacekeyvalue(ethernetkv, "GREEN_DEV", "eth0"); |
72 | replacekeyvalue(ethernetkv, "GREEN_DISPLAYDRIVER", driver); | |
73 | ||
74 | if (!(changeaddress(ethernetkv, "GREEN", 0, ""))) | |
75 | goto EXIT; | |
76 | ||
77 | strcpy(address, ""); findkey(ethernetkv, "GREEN_ADDRESS", address); | |
78 | strcpy(netmask, ""); findkey(ethernetkv, "GREEN_NETMASK", netmask); | |
79 | ||
4809e64e | 80 | snprintf(commandstring, STRING_SIZE, "/sbin/ifconfig eth0 %s netmask %s up", |
d6aaa55d MT |
81 | address, netmask); |
82 | if (mysystem(commandstring)) | |
83 | { | |
84 | errorbox(ctr[TR_INTERFACE_FAILED_TO_COME_UP]); | |
85 | goto EXIT; | |
86 | } | |
87 | ||
88 | result = 1; | |
89 | ||
90 | EXIT: | |
91 | ||
92 | return result; | |
93 | } |