#include <string.h>
#include <sys/types.h>
#include "ap-utils.h"
-#include "ap-curses.h"
extern WINDOW *main_sub, *win_for_help, *main_win;
-extern char *ap_types[];
-extern short ap_type;
+extern char *ap_types[], *ap_vendorexts[][3];
+extern short ap_type, ap_vendorext;
+extern struct in_addr ap_ip;
extern int atmel410_filter;
#define MAX_LINES LINES-6
struct APList {
char *ip;
char *passwd;
- int type;
- char *name;
+ int type;
+ int vendorext;
+ char *label;
struct APList * next;
};
{
int i = 1;
struct APList *curr = first;
- char message[56];
+ char message[80];
clear_main(3);
i = 0;
while (end-- > begin) {
- sprintf(message, "%5u %15s %s %s", begin + i, curr->ip,
- ap_types[curr->type], curr->name);
- mvwaddstr(main_sub, 2 + i, 1, message);
+ sprintf(message, " %3u %-15s %-10s %-8s %-16s", begin + i,
+ curr->ip, ap_types[curr->type],
+ ap_vendorexts[curr->type][curr->vendorext], curr->label);
+ mvwaddstr(main_sub, 2 + i, 0, message);
i++;
curr = curr->next;
}
struct APList *parse_db_str(char *str)
{
struct APList *curr=NULL;
- char *ip=NULL, *passwd=NULL, *name=NULL, mess[1024];
+ char *ip=NULL, *passwd=NULL, *label=NULL, *aptype=NULL, mess[1024];
int i=0, pos=0, j=0;
while(str[i] != '\0') {
passwd[j] = '\0';
break;
case 2:
- name = (char *) malloc(j+1);
- memcpy(name, mess, j+1);
- name[j] = '\0';
+ label = (char *) malloc(j+1);
+ memcpy(label, mess, j+1);
+ label[j > 16 ? 16 : j] = '\0';
+ break;
+ case 3:
+ aptype = (char *) malloc(j+1);
+ memcpy(aptype, mess, j+1);
+ aptype[j] = '\0';
break;
}
i++;
}
mess[j]='\0';
- if (pos==3 && ip && passwd && ((atmel410_filter && atoi(mess) == ATMEL410)
+ if (pos==4 && ip && passwd && ((atmel410_filter && atoi(aptype) == ATMEL410)
|| !atmel410_filter)) {
curr = (struct APList *) malloc(sizeof(struct APList));
- curr->type = atoi(mess);
+ curr->type = atoi(aptype);
+ curr->vendorext = atoi(mess);
curr->next = NULL;
curr->ip = (char *) malloc(strlen(ip) + 1);
strcpy(curr->ip, ip);
curr->passwd = (char *) malloc(strlen(passwd) + 1);
strcpy(curr->passwd, passwd);
- curr->name = (char *) malloc(strlen(name) + 1);
- strcpy(curr->name, name);
+ curr->label = (char *) malloc(strlen(label) + 1);
+ strcpy(curr->label, label);
}
-
+
if (ip)
free(ip);
if (passwd)
free(passwd);
- if (name)
- free(name);
+ if (label)
+ free(label);
+
+ if (aptype)
+ free(aptype);
return curr;
}
char *home_dir, buf[1024], mess[64];
char message[50];
- int c, fd, rval=0, pos;
- signed int j, i, begin, end, record_num=0;
- struct APList *first=NULL, *curr=NULL, *pmac;
+ int c, fd, rval = 0, pos;
+ signed int j, i, begin, end, record_num = 0;
+ struct APList *first = NULL, *curr = NULL, *pmac;
struct sockaddr_in client;
mess[pos]='\0';
if (first == NULL) {
if ((first = parse_db_str(mess)) != NULL) {
- curr=first;
- record_num=1;
+ curr = first;
+ record_num = 1;
}
} else {
if ((curr->next = parse_db_str(mess)) != NULL) {
mess[pos]='\0';
if (first == NULL) {
if ((first = parse_db_str(mess)) != NULL) {
- curr=first;
- record_num=1;
+ curr = first;
+ record_num = 1;
}
} else {
if ((curr->next = parse_db_str(mess)) != NULL)
if (!record_num)
return 0;
- mvwaddstr(main_sub, 0, 3,
- _("NUM IP ADDRESS TYPE NAME (in ~/.ap-config)"));
- print_title(_("Choose an AP to connect to"));
+ mvwaddstr(main_sub, 0, 2,
+ _("NUM IP ADDRESS MIB TYPE MIB EXT. LABEL"));
+ print_top(NULL, _("Choose an AP to connect to"));
begin = 1;
end = (MAX_LINES < record_num) ? MAX_LINES : record_num;
_scroll_rows(first, begin, end);
noecho();
- print_help(_("1-9,C: connect; N: new; D: delete; W: save; Q: quit; arrows: scroll"));
while (1) {
+ print_help(_("1-9,C: connect; N: new; D: delete; W: save; Q: quit; arrows: scroll"));
switch (c = getch()) {
case 'q':
case 'Q':
community = (char *) malloc(i);
strncpy(community, curr->passwd, i);
ap_type = curr->type;
- rval=1;
+ ap_vendorext = curr->vendorext;
+ rval = 1;
if (sockfd)
close(sockfd);
if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
- rval=0;
+ rval = 0;
if (bind(sockfd, (struct sockaddr *) &client, SIZE) == -1)
- rval=0;
+ rval = 0;
print_bottom(inet_ntoa(ap_ip));
- get_mib_details();
goto quit;
case 'c':
community = (char *) malloc(i);
strncpy(community, curr->passwd, i);
ap_type = curr->type;
- rval=1;
+ ap_vendorext = curr->vendorext;
+ rval = 1;
if (sockfd)
close(sockfd);
if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
- rval=0;
+ rval = 0;
if (bind(sockfd, (struct sockaddr *) &client, SIZE) == -1)
- rval=0;
+ rval = 0;
print_bottom(inet_ntoa(ap_ip));
- get_mib_details();
goto quit;
case 'd':
if (i == 1) {
curr = first;
first = first->next;
+ free(curr->ip);
+ free(curr->passwd);
+ free(curr->label);
free(curr);
} else {
curr = first;
pmac = curr->next;
curr->next = pmac->next;
+ free(pmac->ip);
+ free(pmac->passwd);
+ free(pmac->label);
free(pmac);
}
record_num--;
if ((fd = creat(buf, 0600)) != -1) {
curr=first;
while (curr) {
- sprintf(buf, "%s:%s:%d\n", curr->ip, curr->passwd,
- curr->type);
+ sprintf(buf, "%s:%s:%s:%d:%d\n", curr->ip, curr->passwd,
+ curr->label,curr->type, curr->vendorext);
write(fd, buf, strlen(buf));
curr = curr->next;
}
close(fd);
+ print_help(
+ _("AP list file ~/.ap-config successfully written. "
+ "Press any key."));
+ } else {
+ print_helperr(
+ _("Unable to write AP list file ~/.ap-config. "
+ "Press any key."));
}
+ getch();
continue;
-
}
}
/*
first = curr->next;
free(curr->ip);
free(curr->passwd);
+ free(curr->label);
free(curr);
}
print_help("");
- print_title("");
+ print_top(NULL, NULL);
wclear(main_sub);
wrefresh(main_sub);
return rval;
void save_Stations(struct MacListStat *curr)
{
- int fd;
+ int fd, err_f = 0;
char *home_dir;
char message[1024];
if ((home_dir = getenv("HOME"))) {
- sprintf(message, "%s/ap-%s.stations", home_dir, ap_types[ap_type]);
+ sprintf(message, "%s/ap-%s-%s-%s.stations", home_dir, inet_ntoa(ap_ip),
+ ap_types[ap_type],ap_vendorexts[ap_type][ap_vendorext]);
if ((fd = creat(message, 0600)) != -1) {
while (curr) {
sprintf(message, "%02X%02X%02X%02X%02X%02X\n",
curr = curr->next;
}
close(fd);
+ } else {
+ err_f = 1;
}
+ } else {
+ err_f = 1;
}
+ if (err_f)
+ print_helperr(_("Unable to write stations file. Press any key."));
+ else
+ print_help(_("Stations file succesfully written. Press any key."));
+ getch();
+ print_help("");
}