2 * ap-config.c from Wireless Access Point Utilites for Unix
4 * Copyright (c) 2002 Roman Festchook <roma at polesye dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License Version 2 from
8 * June 1991 as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include <sys/types.h>
27 #include <sys/ioctl.h>
36 WINDOW *win_for_menu, *sub_for_menu, *win_for_help, *main_win, *main_sub;
39 int sockfd, atmel410_filter=0;
41 char *prog_title = "Wireless Access Point Configurator";
45 struct umitems umenu_atmel[] = {
46 {_("Bridging"), _("Set bridging and IP-related options"), bridging,
48 {_("Wireless"), _("Set wireless options"), atmel_wireless, 0},
49 {_("Privacy"), MENU_ENCRYPT, wep, 0},
50 {_("MAC auth"), MENU_MAC, atmel_auth_mac, 0},
51 {_("Community"), MENU_COMMUNITY, AuthorizedSettings, 0},
52 {_("Radio"), _("Set radio signal power and antenna options"),
54 {"..", MAIN_MENU, NULL, 0},
58 struct umitems umenu_nwn[] = {
59 {_("General"), _("Set general options"), nwn_wireless, 0},
60 {_("Advanced"), _("Set advanced options"), advanced, 0},
61 {_("Privacy"), MENU_ENCRYPT, nwn_wep, 0},
62 {_("MAC auth"), MENU_MAC, nwn_auth_mac, 0},
63 {_("Community"), MENU_COMMUNITY, AuthorizedSettings, 0},
64 {"..", MAIN_MENU, NULL, 0},
71 uni_menu(umenu_atmel, sizeof(umenu_atmel) / sizeof(umenu_atmel[0]));
74 uni_menu(umenu_nwn, sizeof(umenu_nwn) / sizeof(umenu_nwn[0]));
82 struct umitems command_umenu_atmel[] = {
83 {_("Upload"), _("Make current configuration active"), upload, 0},
84 {_("Defaults"), _("Restore factory default settings"), defaults,
87 _("Reset AP. All not uploaded configuration will be lost"),
89 {_("TestMode"), _("Put Access Point in test mode"), test, 0},
90 {"..", MAIN_MENU, NULL, 0},
93 struct umitems command_umenu_nwn[] = {
94 {_("Reset"), _("Reset AP."), reset, 0},
95 {"..", MAIN_MENU, NULL, 0},
102 uni_menu(command_umenu_atmel,
103 sizeof(command_umenu_atmel) / sizeof(command_umenu_atmel[0]));
106 uni_menu(command_umenu_nwn,
107 sizeof(command_umenu_nwn) / sizeof(command_umenu_nwn[0]));
115 struct umitems umenu_atmel[] = {
116 {_("SysInfo"), MENU_SYSINFO, atmel_sysinfo, 0},
117 {_("Ethernet"), _("Get ethernet port statistics"), EthStat, 0},
118 {_("Wireless"), MENU_WIRELESS, WirelessStat, 0},
119 {_("Stations"), MENU_STAS, stations,
121 {_("KnownAPs"), _("Get info about known Access Points"), APs, 0},
122 {"..", MAIN_MENU, NULL, 0},
125 struct umitems umenu_nwn[] = {
126 {_("SysInfo"), MENU_SYSINFO, nwn_sysinfo, 0},
127 {_("Wireless"), MENU_WIRELESS, nwn_wireless_stat, 0},
128 {_("Stations"), MENU_STAS, nwn_stations, 0},
129 {_("Latest"), _("Get info about latest events"), latest, 0},
130 {"..", MAIN_MENU, NULL, 0},
137 uni_menu(umenu_atmel, sizeof(umenu_atmel) / sizeof(umenu_atmel[0]));
140 uni_menu(umenu_nwn, sizeof(umenu_nwn) / sizeof(umenu_nwn[0]));
148 connect_options((unsigned long) NULL, (int) NULL);
153 struct umitems config_umenu[] = {
154 {_("Info"), MENU_INFO, stat_menu, 1},
155 {_("Config"), MENU_CONFIG, config_menu, 1},
156 {_("Commands"), _("Execute commands on Access Point"),
158 {_("Connect"), MENU_CONNECT, _auth, 0},
159 {_("Search"), MENU_SEARCH, ap_search, 0},
160 {_("About"), MENU_ABOUT, about, 0},
161 {_("Shell"), MENU_SHELL, exit_shell, 0},
162 {_("Exit"), MENU_EXIT, exit_program, 0},
165 uni_menu(config_umenu, sizeof(config_umenu) / sizeof(config_umenu[0]));
170 int main( /*int argc, char **argv */ )
173 WINDOW *win_for_title;
178 /* locale support init */
179 setlocale(LC_ALL, "");
180 bindtextdomain("ap-utils", LOCALEDIR);
181 textdomain("ap-utils");
187 init_pair(1, COLOR_BLACK, COLOR_CYAN);
188 init_pair(2, COLOR_BLACK, COLOR_WHITE);
189 init_pair(3, COLOR_BLACK, COLOR_GREEN);
190 init_pair(4, COLOR_WHITE, COLOR_RED);
196 scrollok(stdscr, TRUE);
198 keypad(stdscr, TRUE);
202 win_for_help = newwin(1, COLS, LINES - 1, 0);
203 wattrset(win_for_help, COLOR_PAIR(1));
207 win_for_title = newwin(1, COLS, 0, 0);
208 wattrset(win_for_title, COLOR_PAIR(1));
209 for (i = 0; i < COLS; i++)
210 waddch(win_for_title, ' ');
211 sprintf(message, _("Wireless Access Point Configurator ver. %s"),
213 mvwaddstr(win_for_title, 0, (COLS - strlen(message)) / 2, message);
214 wrefresh(win_for_title);
217 win_for_menu = newwin(LINES - 2, MCOLS, 1, 0);
218 sub_for_menu = derwin(win_for_menu, LINES - 5, MCOLS - 2, 2, 1);
219 set_menu_win(NULL, win_for_menu);
220 set_menu_sub(NULL, sub_for_menu);
221 attrset(COLOR_PAIR(1));
224 waddch(win_for_menu, ACS_BSSB);
225 for (i = 0; i < MCOLS - 2; i++)
226 waddch(win_for_menu, ACS_BSBS);
227 waddch(win_for_menu, ACS_BSSS);
228 for (i = 0; i < LINES - 4; i++) {
229 waddch(win_for_menu, ACS_SBSB);
230 mvwaddch(win_for_menu, i + 1, MCOLS - 1, ACS_SBSB);
232 waddch(win_for_menu, ACS_SSBB);
233 for (i = 0; i < MCOLS - 2; i++)
234 waddch(win_for_menu, ACS_BSBS);
235 waddch(win_for_menu, ACS_SSBS);
236 wrefresh(win_for_menu);
239 main_win = newwin(LINES - 2, COLS - MCOLS, 1, MCOLS);
241 for (i = 0; i < COLS - MCOLS - 1; i++)
242 waddch(main_win, ACS_BSBS);
243 waddch(main_win, ACS_BBSS);
244 for (i = 0; i < LINES - 4; i++)
245 mvwaddch(main_win, i + 1, COLS - MCOLS - 1, ACS_SBSB);
246 for (i = 0; i < COLS - MCOLS - 1; i++)
247 waddch(main_win, ACS_BSBS);
248 waddch(main_win, ACS_SBBS);
249 main_sub = derwin(main_win, LINES - 4, COLS - MCOLS - 1, 1, 0);
254 if (get_opts() == 0) {
255 connect_options((unsigned long) NULL, (int) NULL);