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>
30 WINDOW *win_for_menu, *sub_for_menu, *win_for_help, *main_win, *main_sub;
32 char *community, *name;
33 int sockfd, atmel410_filter=1;
42 char *prog_title = "Wireless AP Configurator for GlobalSun";
46 struct umitems umenu_atmel[] = {
47 {_("Bridging"), _("Set bridging and IP-related options"), bridging,
49 {_("Wireless"), _("Set wireless options"), atmel_wireless, 0},
50 {_("Privacy"), MENU_ENCRYPT, wep, 0},
51 {_("MAC auth"), MENU_MAC, atmel_auth_mac, 0},
52 {_("Community"), MENU_COMMUNITY, AuthorizedSettings, 0},
53 {_("Radio"), _("Set radio signal power and antenna options"),
55 {"..", MAIN_MENU, NULL, 0},
59 uni_menu(umenu_atmel, sizeof(umenu_atmel) / sizeof(umenu_atmel[0]));
65 struct umitems command_umenu_atmel[] = {
66 {_("Upload"), _("Make current configuration active"), upload, 0},
67 {_("Defaults"), _("Restore factory default settings"), defaults,
70 _("Reset AP. All not uploaded configuration will be lost"),
72 {_("TestMode"), _("Put Access Point in test mode"), test, 0},
73 {"..", MAIN_MENU, NULL, 0},
76 uni_menu(command_umenu_atmel, sizeof(command_umenu_atmel) / sizeof(command_umenu_atmel[0]));
82 struct umitems umenu_atmel[] = {
83 {_("SysInfo"), MENU_SYSINFO, atmel_sysinfo, 0},
84 {_("Ethernet"), _("Get ethernet port statistics"), EthStat, 0},
85 {_("Wireless"), MENU_WIRELESS, WirelessStat, 0},
86 {_("Stations"), MENU_STAS, stations,
88 {_("KnownAPs"), _("Get info about known Access Points"), APs, 0},
89 {"..", MAIN_MENU, NULL, 0},
93 uni_menu(umenu_atmel, sizeof(umenu_atmel) / sizeof(umenu_atmel[0]));
99 connect_options((unsigned long) NULL, ATMEL410+1);
104 struct umitems config_umenu[] = {
105 {_("Info"), MENU_INFO, stat_menu, 1},
106 {_("Config"), MENU_CONFIG, config_menu, 1},
107 {_("Commands"), _("Execute commands on Access Point"),
109 {_("Connect"), MENU_CONNECT, _auth, 0},
110 {_("Search"), MENU_SEARCH, ap_search, 0},
111 {_("About"), MENU_ABOUT, about, 0},
112 {_("Shell"), MENU_SHELL, exit_shell, 0},
113 {_("Exit"), MENU_EXIT, exit_program, 0},
116 uni_menu(config_umenu, sizeof(config_umenu) / sizeof(config_umenu[0]));
121 int main( /*int argc, char **argv */ )
124 WINDOW *win_for_title;
129 /* locale support init */
130 setlocale(LC_ALL, "");
131 bindtextdomain("ap-utils", LOCALEDIR);
132 textdomain("ap-utils");
138 init_pair(1, COLOR_BLACK, COLOR_CYAN);
139 init_pair(2, COLOR_BLACK, COLOR_WHITE);
140 init_pair(3, COLOR_BLACK, COLOR_GREEN);
141 init_pair(4, COLOR_WHITE, COLOR_RED);
147 scrollok(stdscr, TRUE);
149 keypad(stdscr, TRUE);
153 win_for_help = newwin(1, COLS, LINES - 1, 0);
154 wattrset(win_for_help, COLOR_PAIR(1));
158 win_for_title = newwin(1, COLS, 0, 0);
159 wattrset(win_for_title, COLOR_PAIR(1));
160 for (i = 0; i < COLS; i++)
161 waddch(win_for_title, ' ');
162 sprintf(message, _("Wireless Access Point Configurator ver. %s"),
164 mvwaddstr(win_for_title, 0, (COLS - strlen(message)) / 2, message);
165 wrefresh(win_for_title);
168 win_for_menu = newwin(LINES - 2, MCOLS, 1, 0);
169 sub_for_menu = derwin(win_for_menu, LINES - 5, MCOLS - 2, 2, 1);
170 set_menu_win(NULL, win_for_menu);
171 set_menu_sub(NULL, sub_for_menu);
172 attrset(COLOR_PAIR(1));
175 waddch(win_for_menu, ACS_BSSB);
176 for (i = 0; i < MCOLS - 2; i++)
177 waddch(win_for_menu, ACS_BSBS);
178 waddch(win_for_menu, ACS_BSSS);
179 for (i = 0; i < LINES - 4; i++) {
180 waddch(win_for_menu, ACS_SBSB);
181 mvwaddch(win_for_menu, i + 1, MCOLS - 1, ACS_SBSB);
183 waddch(win_for_menu, ACS_SSBB);
184 for (i = 0; i < MCOLS - 2; i++)
185 waddch(win_for_menu, ACS_BSBS);
186 waddch(win_for_menu, ACS_SSBS);
187 wrefresh(win_for_menu);
190 main_win = newwin(LINES - 2, COLS - MCOLS, 1, MCOLS);
192 for (i = 0; i < COLS - MCOLS - 1; i++)
193 waddch(main_win, ACS_BSBS);
194 waddch(main_win, ACS_BBSS);
195 for (i = 0; i < LINES - 4; i++)
196 mvwaddch(main_win, i + 1, COLS - MCOLS - 1, ACS_SBSB);
197 for (i = 0; i < COLS - MCOLS - 1; i++)
198 waddch(main_win, ACS_BSBS);
199 waddch(main_win, ACS_SBBS);
200 main_sub = derwin(main_win, LINES - 4, COLS - MCOLS - 1, 1, 0);
205 if (get_opts() == 0) {
206 connect_options((unsigned long) NULL, ATMEL410+1);