* common.c from Access Point SNMP Utils for Linux
*
* Copyright (c) 2002 Roman Festchook <roma at polesye dot net>
+ * Copyright (c) 2005 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
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
+#include <sys/socket.h>
#include "ap-utils.h"
#define APIP _("Access Point IP-address: ")
#define WANT_SYS_APLABEL _("Do you want to use AP's name as its label? ")
#define APLABEL _("Access Point label: ")
#define SAVESETTINGS _("Save connect-settings: ")
+#define POLL_I _("[P] Polling mode interval (tenths of second): ")
+#define POLL_HELP _("P - change polling mode interval; Q - quit to menu")
char *ap_types[] = {
"ATMEL410",
extern WINDOW *main_sub;
extern char *community, *prog_title;
-short ap_type, ap_vendorext;
-extern int sockfd;
extern struct in_addr ap_ip;
+short ap_type, ap_vendorext;
+int poll_delay = 10;
+
void about()
{
int nrow = 14, ncol = 47, brow = (LINES - 5 - nrow) / 2, bcol =
{0x2B, 0x06, 0x01, 0x04, 0x01, 0xE0, 0x3E, 0x01, 0x02, 0x01, 0x0A, 0x00}
};
- struct sockaddr_in client;
extern int atmel410_filter; /* boolean; = 1 if we call from ap-gl utility */
unsigned char message[256];
unsigned char label[17];
char save_settings=1;
varbind varbinds[1];
- memset(&client, 0, sizeof client);
- client.sin_family = AF_INET;
- client.sin_port = INADDR_ANY;
- client.sin_addr.s_addr = INADDR_ANY;
-
- if (sockfd)
- close(sockfd);
-
- if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
- print_helperr(ERR_CREATING_SOCKET);
- getch();
- goto exit;
- }
-
- if (bind(sockfd, (struct sockaddr *) &client, SIZE) == -1) {
- print_helperr(ERR_BINDING_SOCKET);
+ if (reopen_sockfd() == -1) {
+ print_helperr(ERR_SOCKET);
getch();
goto exit;
}
community, label, ap_type, ap_vendorext);
write(fd, message, strlen(message));
close(fd);
+ wbkgd(main_sub, A_NORMAL);
+ wrefresh(main_sub);
print_help(DONE_WRITING_APCONF);
} else
print_helperr(ERR_WRITING_APCONF);
char AuthRadiusIP_ATMEL[] = {
0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x02, 0x06, 0x03, 0x00
};
- /* ATMEL12350: GEMTEK and EZYNET MIBs define length 160, others 128 */
+ /* ATMEL12350: GEMTEK and EZYNET MIBs define length 160, others 92 or 128 */
char sysDeviceInfo_ATMEL[] = {
0x2B, 0x06, 0x01, 0x04, 0x01, 0xE0, 0x3E, 0x01, 0x01, 0x01, 0x05, 0x00
};
void exit_program()
{
+ erase();
+ refresh();
endwin();
exit(0);
}
refresh();
}
+/*
+ * Sets different-than-default (1 sec.) polling interval for polling-active
+ * modes, from interval <0.1;86400> seconds.
+ * poll_delay is natively in tenths of second.
+ */
+void polling_interval()
+{
+ unsigned char message[256];
+ int c = 0;
+
+ noecho();
+ print_help(POLL_HELP);
+
+ while (1) {
+ sprintf(message, _("%s%u"), POLL_I, poll_delay);
+ mvwaddstr(main_sub, 0, 0, message);
+ sprintf(message, _("(%0.1f seconds)"), (float) poll_delay / 10);
+ mvwaddstr(main_sub, 1, strlen(POLL_I), message);
+ wrefresh(main_sub);
+ c = getch();
+ switch (c) {
+ case 'P':
+ case 'p':
+ get_value(message, 0, strlen(POLL_I), 7, INT_STRING, 1, 864000,
+ POLL_HELP);
+ poll_delay = atoi(message);
+ clear_main_new(0, 2);
+ break;
+ case 'Q':
+ case 'q':
+ goto quit;
+ }
+ }
+
+quit:
+ print_help("");
+ clear_main(0);
+ return;
+}
+
/*
* Expects regulatory domain code on input and returns index of a corresponding
* regdom_types[] member, that describes the given regulatory domain properties.
return i;
}
-