* ap_search.c from Access Point SNMP Utils for Linux
*
* Copyright (c) 2002 Roman Festchook <roma at polesye dot net>
- * Copyright (c) 2003 Jan Rafaj <aputils at cedric dot vabo dot cz>
+ * Copyright (c) 2003 Jan Rafaj <jr-aputils at cedric dot unob dot cz>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License Version 2 from
#endif
#define SEARCH_COMMUNITY _("Community name: ")
-#define SEARCH_HEADER _(" NUM IP ADDRESS MIB TYPE NAME")
+#define SEARCH_HEADER _(" NUM IP ADDRESS MIB TYPE FW TYPE (VERSION) AP NAME")
#define MAX_APS LAST_ROW-7
extern int atmel410_filter;
extern WINDOW *main_sub;
extern char *ap_types[];
unsigned char message[1024], *start;
- extern int atmel410_filter; /* to check is this function called from ap-gl utility */
+ /* unsigned char name_fw[256], *name_p, *fwver_p; */
+ extern int atmel410_filter; /* if called from ap-gl utility */
- char Wireless[3][12] = {
- {0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x01, 0x01, 0x00},
- {0x2B, 0x06, 0x01, 0x02, 0x01, 0x01, 0x01, 0x00},
- {0x2B, 0x06, 0x01, 0x04, 0x01, 0xE0, 0x3E, 0x01, 0x01, 0x01, 0x01, 0x00}
- };
-
/*
* operAccessPointName OIDs used to detect AP MIB type [in order
* of appearance in the 'for' loop below: ATMEL410, NWN, ATMEL12350]
*/
-/* char operAccessPointName[3][12] = {
+/*
+ char operAccessPointName[3][12] = {
{0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x02, 0x01, 0x0A, 0x00},
{0x2B, 0x06, 0x01, 0x02, 0x01, 0x01, 0x05, 0x00},
{0x2B, 0x06, 0x01, 0x04, 0x01, 0xE0, 0x3E, 0x01, 0x02, 0x01, 0x0A, 0x00}
};
*/
- int scd_ap_type, last_searched_type=ATMEL12350;
+ /*
+ * note: we'll rather use sysDescr OID for probing, becouse the devices
+ * wont rely on correct community for this query
+ */
+ char sysDescr[3][12] = {
+ {0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x01, 0x01, 0x00},
+ {0x2B, 0x06, 0x01, 0x02, 0x01, 0x01, 0x01, 0x00},
+ {0x2B, 0x06, 0x01, 0x04, 0x01, 0xE0, 0x3E, 0x01, 0x01, 0x01, 0x01, 0x00}
+ };
+
+ int scd_ap_type, last_searched_type = ATMEL12350;
int c, s2, errno, len, client_len = SIZE;
struct in_addr to_addr_reserv;
struct sopts {
print_help(_("Please wait while scanning, or press 'Q' to quit."));
if ((s2 = socket(PF_INET, SOCK_DGRAM, 0)) == -1) {
- print_helperr(ERR_CREATING_SOCKET);
+ print_helperr(ERR_SOCKET);
getch();
return;
}
if (bind(s2, (struct sockaddr *) from, SIZE) == -1) {
- print_helperr(ERR_BINDING_SOCKET);
+ print_helperr(ERR_SOCKET);
getch();
goto close_ret;
}
mvwaddstr(main_sub, LAST_ROW - 2, 1, message);
if(atmel410_filter) {
- last_searched_type=ATMEL410;
+ last_searched_type = ATMEL410;
}
for (scd_ap_type = ATMEL410; scd_ap_type <= last_searched_type; scd_ap_type++) {
wrefresh(main_sub);
/* varbinds[0].oid = operAccessPointName[scd_ap_type];*/
- varbinds[0].oid = Wireless[scd_ap_type];
+ varbinds[0].oid = sysDescr[scd_ap_type];
varbinds[0].len_oid = (scd_ap_type == NWN ?
/* 8 : sizeof(operAccessPointName[scd_ap_type]));*/
- 8 : sizeof(Wireless[scd_ap_type]));
+ 8 : sizeof(sysDescr[scd_ap_type]));
varbinds[0].len_val = 0;
varbinds[0].type = NULL_VALUE;
len = ber(message, varbinds, 1, GET);
for (len = 0; len < varbinds[0].len_val && start[len]; len++);
start[len + 1] = '\0';
- if (len > 25) {
- /* Truncate (limited screen size) and screen-width independent! */
- start[COLS-53-atmel410_filter] = '>';
- start[COLS-52-atmel410_filter] = '\0';
+
+ /*
+ * Returned sysDescr string is (hopefully!) always of format:
+ * string1 (Ver. string2) string3
+ * where:
+ * string1 = "802.11 X "
+ * where: "X" identifies firmware type (AP, APP, WB, WA, etc)
+ * unfortunately this is not deterministic across
+ * manufacturers (each one uses different naming scheme)
+ * string2 = firmware version
+ * string3 = device name, as defined with operAccessPointName
+ * OID
+ name_p = strchr(start, ')');
+ *name_p = '\0';
+ name_p += 2;
+ fwver_p = strstr(start, "(Ver. ");
+ fwver_p += strlen("(Ver. ");
+ sprintf(name_fw, "%s (%s)", name_p, fwver_p);
+
+ if (strlen(name_fw) > (size_t)(COLS - MCOLS - 37)) {
+ name_fw[COLS - MCOLS - 38] = '>';
+ name_fw[COLS - MCOLS - 37] = '\0';
+ }
+ */
+
+ if (strlen(start) > (size_t)(COLS - MCOLS - 37)) {
+ /* truncate (limit to scr. size) */
+ start[COLS - MCOLS - 38] = '>';
+ start[COLS - MCOLS - 37] = '\0';
}
+
sprintf(message, " %3i %-15s %-10s %s", i,
inet_ntoa(fapsa[i].ip), ap_types[fapsa[i].type], start);
i++;
struct ifconf ifc;
struct ifreq *ifr;
char *ifbuf_ptr = NULL, *ifrec_ptr;
+/*
char *old_community;
char buf[16];
strncpy(community, buf, strlen(buf) + 1);
print_help("");
clear_main(0);
-
+*/
print_top(NULL, _("Access Points Search"));
mvwaddstr(main_sub, 0, 0, SEARCH_HEADER);
wrefresh(main_sub);
if ((s1 = socket(PF_INET, SOCK_DGRAM, 0)) == -1) {
- print_helperr(ERR_CREATING_SOCKET);
+ print_helperr(ERR_SOCKET);
goto wait_quit;
}
print_top(NULL, NULL);
clear_main(0);
- free(old_community);
+/* free(old_community); */
connect_options(fapsa[ac - '0'].ip.s_addr,
fapsa[ac - '0'].type + 1);
free(fapsa);
if (fapsa)
free(fapsa);
-
+/*
free(community);
community = old_community;
-
+*/
print_help("");
print_top(NULL, NULL);
clear_main(0);
}
-