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
)
32 char driver
[STRING_SIZE
] = "";
33 char driveroptions
[STRING_SIZE
] = "";
34 struct keyvalue
*kv
= initkeyvalues();
36 char commandstring
[STRING_SIZE
];
37 char address
[STRING_SIZE
], netmask
[STRING_SIZE
];
39 char description
[1000];
41 char title
[STRING_SIZE
];
43 /* Detect and count nics */
44 count
= mysystem("/bin/probenic.sh count");
45 fprintf(flog
, "Number of detected nics: %s\n", count
);
47 /* sprintf(commandstring, "/bin/probenic.sh");
48 sprintf(message, ctr[TR_PROBING_FOR_NICS]);
49 runcommandwithstatus(commandstring, message); */
51 /* handle = fopen("/nicdriver", "r");
52 fgets(nics, STRING_SIZE, handle);
55 /* fprintf(flog, "Detected NIC drivers: %s\n",driver); */
57 /* sprintf (title, "%s %s - %s", NAME, VERSION, SLOGAN);
58 sprintf(message, ctr[TR_FOUND_NIC], NAME, description);
59 newtWinMessage(title, ctr[TR_OK], message); */
61 newtComponent form
, checkbox
, rb
[count
], button
;
62 newtOpenWindow(10, 5, 60, 11, "Checkboxes and Radio buttons");
64 for (i
= 1; i
<= 2; i
++)
66 fprintf(flog
, "Scan: %d\n", i
);
67 snprintf(commandstring
, STRING_SIZE
, "/bin/probenic.sh %i", i
);
68 mysystem(commandstring
);
69 if ((handle
= fopen("/nicdriver", "r")) == NULL
) {
70 errorbox(ctr
[TR_ERROR
]);
73 fgets(driver
, STRING_SIZE
, handle
);
75 findnicdescription(driver
, description
);
77 rb
[i
] = newtRadiobutton(1, i
+2, description
, 1, NULL
);
79 rb
[i
] = newtRadiobutton(1, i
+2, description
, 0, rb
[i
-1]);
82 button
= newtButton(1, count
+3, "OK");
84 form
= newtForm(NULL
, NULL
, 0);
85 newtFormAddComponent(form
, checkbox
);
86 for (i
= 1; i
<= 2; i
++) {
87 fprintf(flog
, "Add: %d\n", i
);
88 newtFormAddComponent(form
, rb
[i
]);
90 newtFormAddComponent(form
, button
);
95 for (i
= 1; i
<= 2; i
++)
96 if (newtRadioGetCurrent(rb
[0]) == rb
[i
])
97 printf("radio button picked: %d\n", i
);
98 newtFormDestroy(form
);
101 /* snprintf(commandstring, STRING_SIZE, "/bin/probenic.sh 1");
102 mysystem(commandstring);
103 if ((handle = fopen("/nicdriver", "r")) == NULL) {
104 errorbox(ctr[TR_ERROR]);
107 fgets(driver, STRING_SIZE, handle);
108 fprintf(flog, "Green nic driver: %s\n", driver);
111 /* Default is a GREEN nic only. */
112 /* Smoothie is not untarred yet, so we have to delay actually writing the
113 * settings till later. */
114 replacekeyvalue(ethernetkv
, "CONFIG_TYPE", "0");
115 replacekeyvalue(ethernetkv
, "GREEN_DRIVER", driver
);
116 replacekeyvalue(ethernetkv
, "GREEN_DRIVER_OPTIONS", driveroptions
);
117 replacekeyvalue(ethernetkv
, "GREEN_DEV", "eth0");
118 replacekeyvalue(ethernetkv
, "GREEN_DISPLAYDRIVER", driver
);
120 if (!(changeaddress(ethernetkv
, "GREEN", 0, "")))
123 strcpy(address
, ""); findkey(ethernetkv
, "GREEN_ADDRESS", address
);
124 strcpy(netmask
, ""); findkey(ethernetkv
, "GREEN_NETMASK", netmask
);
126 snprintf(commandstring
, STRING_SIZE
, "/bin/ifconfig eth0 %s netmask %s up",
128 if (mysystem(commandstring
))
130 errorbox(ctr
[TR_INTERFACE_FAILED_TO_COME_UP
]);