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
10 * $Id: nic.c,v 1.8.2.1 2004/04/14 22:05:40 gespinasse Exp $
16 #include <sys/socket.h>
17 #include <netinet/in.h>
18 #include <arpa/inet.h>
25 extern struct nic nics
[];
27 int networkmenu(struct keyvalue
*ethernetkv
)
30 char driver
[STRING_SIZE
] = "";
31 char driveroptions
[STRING_SIZE
] = "";
32 struct keyvalue
*kv
= initkeyvalues();
34 char commandstring
[STRING_SIZE
];
35 char address
[STRING_SIZE
], netmask
[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 probecards(driver
, driveroptions
);
51 errorbox(ctr
[TR_PROBE_FAILED
]);
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
);
61 choosecards(driver
, driveroptions
);
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
);
81 if (!(changeaddress(ethernetkv
, "GREEN", 0, "")))
84 strcpy(address
, ""); findkey(ethernetkv
, "GREEN_ADDRESS", address
);
85 strcpy(netmask
, ""); findkey(ethernetkv
, "GREEN_NETMASK", netmask
);
87 snprintf(commandstring
, STRING_SIZE
, "/bin/ifconfig eth0 %s netmask %s up",
89 if (mysystem(commandstring
))
91 errorbox(ctr
[TR_INTERFACE_FAILED_TO_COME_UP
]);