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