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
26 #include "ap-curses.h"
28 #define COMMUNITY_TOP_HEADER _("Set community/password")
29 #define COMMUNITY_HEADER1 _("Key Access level")
30 #define COMMUNITY_HEADER2 _("Community/Password")
31 #define COMMUNITY_USER _("[U] User")
32 #define COMMUNITY_ADMIN _("[A] Administrator")
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()
41 char AuthorizedUserPass[3][12] = {
42 {0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x09, 0x01,
44 {0x2B, 0x06, 0x01, 0x04, 0x01, 0x87, 0x29, 0x02, 0x01, 0x02, 0x01,
46 {0x2B, 0x06, 0x01, 0x04, 0x01, 0xe0, 0x3e, 0x01, 0x01, 0x09, 0x01,
49 char AuthorizedAdminPass[3][12] = {
50 {0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x09, 0x02,
52 {0x2B, 0x06, 0x01, 0x04, 0x01, 0x87, 0x29, 0x02, 0x01, 0x02, 0x02,
54 {0x2B, 0x06, 0x01, 0x04, 0x01, 0xe0, 0x3e, 0x01, 0x01, 0x09, 0x02,
57 char AuthorizedManufactPass[] =
58 { 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x09, 0x03,
63 char user[16], admin[16], manufact[16];
66 if (ap_type == ATMEL12350) {
67 AuthorizedManufactPass[5] = 0xE0;
68 AuthorizedManufactPass[6] = 0x3E;
71 user[0] = admin[0] = manufact[0] = '\0';
72 print_title(COMMUNITY_TOP_HEADER);
74 mvwaddstr(main_sub, 0, 0, COMMUNITY_HEADER1);
75 mvwaddstr(main_sub, 0, 25, COMMUNITY_HEADER2);
76 mvwaddstr(main_sub, 1, 0, COMMUNITY_USER);
77 mvwaddstr(main_sub, 2, 0, COMMUNITY_ADMIN);
79 if (ap_type == ATMEL410 || ap_type == ATMEL12350) {
80 mvwaddstr(main_sub, 3, 0, _("[M] Manufacturer"));
85 print_help(COMMUNITY_HELP);
92 /* get_value(user, 1, 25, sizeof(user), ANY_STRING, 0, 0, NULL); */
93 get_pass(user, 1, 25, sizeof(user));
97 /* get_value(admin, 2, 25, sizeof(admin), ANY_STRING, 0, 0, NULL); */
98 get_pass(admin, 2, 25, sizeof(admin));
102 if (ap_type == ATMEL410 || ap_type == ATMEL12350)
104 get_value(manufact, 3, 25, sizeof(manufact), ANY_STRING,
107 get_pass(manufact, 3, 25, sizeof(manufact));
116 varbinds[i].oid = AuthorizedUserPass[ap_type];
117 varbinds[i].len_oid = sizeof(AuthorizedUserPass[ap_type]);
118 varbinds[i].value = user;
119 varbinds[i].len_val = strlen(user);
120 varbinds[i].type = STRING_VALUE;
124 varbinds[i].oid = AuthorizedAdminPass[ap_type];
125 varbinds[i].len_oid = sizeof(AuthorizedAdminPass[ap_type]);
126 varbinds[i].value = admin;
127 varbinds[i].len_val = strlen(admin);
128 varbinds[i].type = STRING_VALUE;
131 if ((ap_type == ATMEL410 || ap_type == ATMEL12350) && strlen(manufact)) {
132 varbinds[i].oid = AuthorizedManufactPass;
133 varbinds[i].len_oid = sizeof(AuthorizedManufactPass);
134 varbinds[i].value = manufact;
135 varbinds[i].len_val = strlen(manufact);
136 varbinds[i].type = STRING_VALUE;
139 print_help(WAIT_SET);
140 if (snmp(varbinds, i, SET) <= 0) {
141 print_helperr(ERR_SET);
149 print_help(DONE_SET);