1 /* SmoothWall install program.
3 * This program is distributed under the terms of the GNU General Public
4 * Licence. See the file COPYING for details.
6 * (c) Lawrence Manning, 2001
7 * Contains stuff related to firing up the network card, including a crude
14 #include <sys/socket.h>
15 #include <netinet/in.h>
16 #include <arpa/inet.h>
23 extern struct nic nics
[];
25 int networkmenu(struct keyvalue
*ethernetkv
)
28 char driver
[STRING_SIZE
] = "";
29 char driveroptions
[STRING_SIZE
] = "";
30 struct keyvalue
*kv
= initkeyvalues();
32 char commandstring
[STRING_SIZE
];
33 char address
[STRING_SIZE
], netmask
[STRING_SIZE
];
36 char line
[STRING_SIZE
];
37 char description
[1000];
39 char title
[STRING_SIZE
];
44 rc
= newtWinTernary(ctr
[TR_CONFIGURE_NETWORKING
], ctr
[TR_PROBE
],
45 ctr
[TR_SELECT
], ctr
[TR_CANCEL
], ctr
[TR_CONFIGURE_NETWORKING_LONG
]);
47 if (rc
== 0 || rc
== 1)
49 sprintf(commandstring
, "/bin/probenic.sh 1");
50 sprintf(message
, ctr
[TR_PROBING_FOR_NICS
]);
51 runcommandwithstatus(commandstring
, message
);
53 if ((handle
= fopen("/nicdriver", "r")))
56 fgets(line
, STRING_SIZE
-1, handle
);
58 line
[strlen(line
) - 1] = 0;
59 driver
= strtok(line
, ".");
60 fprintf(flog
, "Detected NIC driver: %s\n",driver
);
61 if (strlen(driver
) > 1) {
62 strcpy(driveroptions
, "");
63 findnicdescription(driver
, description
);
64 sprintf (title
, "%s %s - %s", NAME
, VERSION
, SLOGAN
);
65 sprintf(message
, ctr
[TR_FOUND_NIC
], NAME
, description
);
66 newtWinMessage(title
, ctr
[TR_OK
], message
);
68 errorbox(ctr
[TR_PROBE_FAILED
]);
73 choosecards(driver
, driveroptions
);
78 /* Default is a GREEN nic only. */
79 /* Smoothie is not untarred yet, so we have to delay actually writing the
80 * settings till later. */
81 replacekeyvalue(ethernetkv
, "CONFIG_TYPE", "0");
82 replacekeyvalue(ethernetkv
, "GREEN_DRIVER", driver
);
83 replacekeyvalue(ethernetkv
, "GREEN_DRIVER_OPTIONS", driveroptions
);
84 replacekeyvalue(ethernetkv
, "GREEN_DEV", "eth0");
85 replacekeyvalue(ethernetkv
, "GREEN_DISPLAYDRIVER", driver
);
87 if (!(changeaddress(ethernetkv
, "GREEN", 0, "")))
90 strcpy(address
, ""); findkey(ethernetkv
, "GREEN_ADDRESS", address
);
91 strcpy(netmask
, ""); findkey(ethernetkv
, "GREEN_NETMASK", netmask
);
93 snprintf(commandstring
, STRING_SIZE
, "/bin/ifconfig eth0 %s netmask %s up",
95 if (mysystem(commandstring
))
97 errorbox(ctr
[TR_INTERFACE_FAILED_TO_COME_UP
]);