#define AUTODETECT _("Autodetect AP type? ")
#define APIP _("Access Point IP-address: ")
#define APPASS _("Password (community): ")
+#define APNAME _("Access Point name: ")
+#define WANT_APNAME _("Do you want to define name for this AP? ")
#define APTYPE _("AP type: ")
#define SAVESETTINGS _("Save connect-settings: ")
+char IS_ATMEL410_SBRIDGES;
+char IS_ATMEL12350_TELLUS;
+char IS_ATMEL12350_VERNET;
+
extern WINDOW *main_sub;
extern char *community, *prog_title;
extern short ap_type;
{
int i;
struct sockaddr_in client;
- unsigned char message[16];
+ unsigned char message[256];
+ unsigned char name[17];
int fd;
char *home_dir;
char save_settings=1;
- char sysDescr_NWN[] = { 0x2B, 0x06, 0x01, 0x02, 0x01, 0x01, 0x01, 0x00 };
- char sysDescr_ATMEL410[] = { 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A,
- 0x01, 0x01, 0x01, 0x01, 0x00 };
- char sysDescr_ATMEL12350[] = { 0x2B, 0x06, 0x01, 0x04, 0x01, 0xE0, 0x3E,
- 0x01, 0x01, 0x01, 0x01, 0x00 };
- varbind varbinds[1];
-
memset(&client, 0, sizeof client);
client.sin_family = AF_INET;
community = (char *) malloc(i);
strncpy(community, message, i);
+ print_help(_("Display name for the Access point "
+ "(NOT the name defined inside the AP!)"));
+ mvwaddstr(main_sub, 3, 1, WANT_APNAME);
+ wrefresh(main_sub);
+ i = yes_no(3, 1 + strlen(WANT_APNAME));
+ if (i == 2) { /* NO */
+ name[0] = '\0';
+ mvwaddstr(main_sub, 3, 1 + strlen(WANT_APNAME), "No");
+ } else { /* YES */
+ clear_main_new(3, 4);
+ mvwaddstr(main_sub, 3, 1, APNAME);
+ get_value(message, 3, 1 + strlen(APNAME), sizeof(name),
+ ANY_STRING, 0, 0, NULL);
+ strncpy(name, message, strlen(message) + 1);
+ }
+
print_help("");
if (type) {
ap_type = --type;
- mvwaddstr(main_sub, 3, 1, APTYPE);
+ mvwaddstr(main_sub, 4, 1, APTYPE);
} else {
- mvwaddstr(main_sub, 3, 1, AUTODETECT);
+ mvwaddstr(main_sub, 4, 1, AUTODETECT);
wrefresh(main_sub);
- i = yes_no(3, 1 + strlen(AUTODETECT));
- clear_main_new(3, 4);
- mvwaddstr(main_sub, 3, 1, APTYPE);
+ i = yes_no(4, 1 + strlen(AUTODETECT));
+ clear_main_new(4, 5);
+ mvwaddstr(main_sub, 4, 1, APTYPE);
if (i == 2) { /* NO */
wrefresh(main_sub);
- ap_type = menu_choose(3, 1 + strlen(APTYPE), ap_types, 3);
+ ap_type = menu_choose(4, 1 + strlen(APTYPE), ap_types, 3);
} else { /* YES */
print_help(_("Determining AP type. Please wait..."));
- varbinds[0].oid = sysDescr_NWN;
- varbinds[0].len_oid = sizeof(sysDescr_NWN);
- varbinds[0].value = NULL;
- varbinds[0].len_val = 0;
- varbinds[0].type = NULL_VALUE;
- if (snmp(varbinds, 1, GET) > 0) {
- ap_type = NWN;
- } else {
- varbinds[0].oid = sysDescr_ATMEL410;
- varbinds[0].len_oid = sizeof(sysDescr_ATMEL410);
- varbinds[0].value = NULL;
- varbinds[0].len_val = 0;
- varbinds[0].type = NULL_VALUE;
- if (snmp(varbinds, 1, GET) > 0) {
- ap_type = ATMEL410;
- } else {
- varbinds[0].oid = sysDescr_ATMEL12350;
- varbinds[0].len_oid = sizeof(sysDescr_ATMEL12350);
- varbinds[0].value = NULL;
- varbinds[0].len_val = 0;
- varbinds[0].type = NULL_VALUE;
- if (snmp(varbinds, 1, GET) > 0) {
- ap_type = ATMEL12350;
- } else {
- print_helperr(_("Unable to determine AP type "
- "(no response). Press any key."));
- getch();
- clear_main_new(1, 4);
- goto get_all_again;
- }
- }
+ if (get_mib_details() == -1) {
+ clear_main_new(1, 5);
+ goto get_all_again;
}
- }
+ }
wattrset(main_sub, A_BOLD);
}
waddstr(main_sub, ap_types[ap_type]);
wattrset(main_sub, A_NORMAL);
- mvwaddstr(main_sub, 4, 1, SAVESETTINGS);
+ mvwaddstr(main_sub, 5, 1, SAVESETTINGS);
wrefresh(main_sub);
- save_settings = on_off(4, 1 + strlen(SAVESETTINGS));
+ save_settings = on_off(5, 1 + strlen(SAVESETTINGS));
print_bottom(inet_ntoa(ap_ip));
if ((home_dir = getenv("HOME"))) {
sprintf(message, "%s/.ap-config", home_dir);
if ((fd = open(message, O_CREAT | O_WRONLY | O_APPEND, 0600)) != -1) {
- sprintf(message, "%s:%s:%d\n", inet_ntoa(ap_ip),
- community, ap_type);
+ sprintf(message, "%s:%s:%s:%d\n", inet_ntoa(ap_ip),
+ community, name, ap_type);
write(fd, message, strlen(message));
close(fd);
}
return;
}
+/*
+ * Determines AP MIB type (fills ap_type), and AP MIB vendor extensions
+ * (changes values of IS_ATMEL* globals). Returns with -1 on error or 0
+ * if everything is OK.
+ */
+int get_mib_details()
+{
+ char sysDescr_NWN[] = {
+ 0x2B, 0x06, 0x01, 0x02, 0x01, 0x01, 0x01, 0x00
+ };
+ char sysDescr_ATMEL[] = {
+ 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x01, 0x01, 0x00
+ };
+ char operEthernetAddress_ATMEL[] = {
+ 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x02, 0x03, 0x00
+ };
+ char Wireless_ATMEL[] = {
+ 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x02, 0x03, 0x01, 0x00
+ };
+ varbind varbinds[2];
+ char oui_sbridges[3] = { 0x00, 0x30, 0x1A };
+ char oui_tellus[3] = { 0x00, 0x04, 0xDB };
+
+ /* first, determine the private MIB types according to enterprises ID */
+ varbinds[0].oid = sysDescr_NWN;
+ varbinds[0].len_oid = sizeof(sysDescr_NWN);
+ varbinds[0].value = NULL;
+ varbinds[0].len_val = 0;
+ varbinds[0].type = NULL_VALUE;
+ if (snmp(varbinds, 1, GET) > 0) {
+ ap_type = NWN;
+ } else {
+ varbinds[0].oid = sysDescr_ATMEL;
+ varbinds[0].len_oid = sizeof(sysDescr_ATMEL);
+ varbinds[0].value = NULL;
+ varbinds[0].len_val = 0;
+ varbinds[0].type = NULL_VALUE;
+ if (snmp(varbinds, 1, GET) > 0) {
+ ap_type = ATMEL410;
+ } else {
+ sysDescr_ATMEL[5] = 0xE0;
+ sysDescr_ATMEL[6] = 0x3E;
+ varbinds[0].oid = sysDescr_ATMEL;
+ varbinds[0].len_oid = sizeof(sysDescr_ATMEL);
+ varbinds[0].value = NULL;
+ varbinds[0].len_val = 0;
+ varbinds[0].type = NULL_VALUE;
+ if (snmp(varbinds, 1, GET) > 0) {
+ ap_type = ATMEL12350;
+ } else {
+ print_helperr(_("Unable to determine AP type "
+ "(no response). Press any key."));
+ getch();
+ return -1;
+ }
+ }
+ }
+
+ /*
+ * It is best to do the following HERE and FOR ONCE ONLY: find out more
+ * about specific MIB modifications - we'll use them on different places
+ * later.
+ */
+ IS_ATMEL410_SBRIDGES = 0;
+ IS_ATMEL12350_TELLUS = 0;
+ IS_ATMEL12350_VERNET = 0;
+
+ varbinds[0].type = NULL_VALUE;
+ varbinds[0].oid = operEthernetAddress_ATMEL;
+ varbinds[0].len_oid = sizeof(operEthernetAddress_ATMEL);
+ varbinds[0].len_val = 0;
+ varbinds[1].type = NULL_VALUE;
+ varbinds[1].oid = Wireless_ATMEL;
+ varbinds[1].len_oid = sizeof(Wireless_ATMEL);
+ varbinds[1].len_val = 0;
+ if (ap_type == ATMEL12350) {
+ operEthernetAddress_ATMEL[5] = 0xE0;
+ operEthernetAddress_ATMEL[6] = 0x3E;
+ Wireless_ATMEL[5] = 0xE0;
+ Wireless_ATMEL[6] = 0x3E;
+ }
+ if (snmp(varbinds, 2, GET) <= 0) {
+ print_helperr(ERR_RET);
+ getch();
+ return -1;
+ }
+
+ /* detection of different vendor-modified ATMEL private MIBs */
+ if (ap_type == ATMEL410 && (memcmp(oui_sbridges, varbinds[0].value, 3) ==0))
+ IS_ATMEL410_SBRIDGES = 1;
+
+ if (ap_type == ATMEL12350 && (memcmp(oui_tellus, varbinds[0].value, 3) ==0))
+ IS_ATMEL12350_TELLUS = 1;
+
+ if (ap_type == ATMEL12350 && varbinds[1].len_val == 104)
+ IS_ATMEL12350_VERNET = 1;
+
+ return 0;
+}
+
void exit_program()
{
endwin();