2 * auth.c from Access Point SNMP Utils for Linux
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
27 #define COMMUNITY_TOP_HEADER _("Set community/password")
28 #define COMMUNITY_HEADER1 _("Key Access level")
29 #define COMMUNITY_HEADER2 _("Community/Password")
30 #define COMMUNITY_USER _("[U] User ")
31 #define COMMUNITY_ADMIN _("[A] Administrator ")
32 #define COMMUNITY_MANUF _("[M] Manufacturer ")
33 #define COMMUNITY_HELP _("[key] - set community/password; W - write config to AP; Q - quit to menu")
35 extern WINDOW *main_sub;
38 void AuthorizedSettings()
40 char AuthorizedUserPass[3][12] = {
41 {0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x09, 0x01,
43 {0x2B, 0x06, 0x01, 0x04, 0x01, 0x87, 0x29, 0x02, 0x01, 0x02, 0x01,
45 {0x2B, 0x06, 0x01, 0x04, 0x01, 0xE0, 0x3E, 0x01, 0x01, 0x09, 0x01,
48 char AuthorizedAdminPass[3][12] = {
49 {0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x09, 0x02,
51 {0x2B, 0x06, 0x01, 0x04, 0x01, 0x87, 0x29, 0x02, 0x01, 0x02, 0x02,
53 {0x2B, 0x06, 0x01, 0x04, 0x01, 0xE0, 0x3E, 0x01, 0x01, 0x09, 0x02,
56 char AuthorizedManufactPass[] =
57 { 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x09, 0x03,
62 char user[16], admin[16], manufact[16];
65 if (ap_type == ATMEL12350) {
66 AuthorizedManufactPass[5] = 0xE0;
67 AuthorizedManufactPass[6] = 0x3E;
70 user[0] = admin[0] = manufact[0] = '\0';
71 print_top(NULL, COMMUNITY_TOP_HEADER);
73 mvwaddstr(main_sub, 0, 0, COMMUNITY_HEADER1);
74 mvwaddstr(main_sub, 0, 37, COMMUNITY_HEADER2);
75 mvwaddstr(main_sub, 1, 0, COMMUNITY_USER);
76 mvwaddstr(main_sub, 2, 0, COMMUNITY_ADMIN);
78 if (ap_type == ATMEL410 || ap_type == ATMEL12350) {
79 mvwaddstr(main_sub, 3, 0, COMMUNITY_MANUF);
84 print_help(COMMUNITY_HELP);
91 /* get_value(user, 1, 37, sizeof(user), ANY_STRING, 0, 0, NULL); */
92 get_pass(user, 1, 37, sizeof(user));
96 /* get_value(admin, 2, 37, sizeof(admin), ANY_STRING, 0, 0, NULL); */
97 get_pass(admin, 2, 37, sizeof(admin));
101 if (ap_type == ATMEL410 || ap_type == ATMEL12350)
103 get_value(manufact, 3, 37, sizeof(manufact), ANY_STRING,
106 get_pass(manufact, 3, 37, sizeof(manufact));
115 varbinds[i].oid = AuthorizedUserPass[ap_type];
116 varbinds[i].len_oid = sizeof(AuthorizedUserPass[ap_type]);
117 varbinds[i].value = user;
118 varbinds[i].len_val = strlen(user);
119 varbinds[i].type = STRING_VALUE;
123 varbinds[i].oid = AuthorizedAdminPass[ap_type];
124 varbinds[i].len_oid = sizeof(AuthorizedAdminPass[ap_type]);
125 varbinds[i].value = admin;
126 varbinds[i].len_val = strlen(admin);
127 varbinds[i].type = STRING_VALUE;
130 if ((ap_type == ATMEL410 || ap_type == ATMEL12350) && strlen(manufact)) {
131 varbinds[i].oid = AuthorizedManufactPass;
132 varbinds[i].len_oid = sizeof(AuthorizedManufactPass);
133 varbinds[i].value = manufact;
134 varbinds[i].len_val = strlen(manufact);
135 varbinds[i].type = STRING_VALUE;
138 print_help(WAIT_SET);
139 if (snmp(varbinds, i, SET) <= 0) {
140 print_helperr(ERR_SET);
143 wbkgd(main_sub, A_NORMAL);
150 print_help(DONE_SET);
155 print_top(NULL, NULL);