/*
- * ap-mrtg.c from Access Point SNMP Utils for Linux
+ * ap-rrd.c from Access Point SNMP Utils for Linux
*
* Copyright (c) 2002 Roman Festchook <roma at polesye dot net>
*
#endif
#include "ap-utils.h"
-#define ERR_STR_V "\n\n-\n\n"
-#define ERR_STR_N "999999999\n999999999\n-\n\n"
+#define ERR_STR _("Error getting data from AP %s\n")
short ap_type = ATMEL410;
char *community = NULL;
-int sockfd;
struct in_addr ap_ip;
void usage()
struct wirelessStatistics_s *WirelessStat = NULL;
varbind varbinds[2];
int i, reset_flag=0;
- char message[12], bssid_flag, stat_type = 0, *ERR_STR =
- ERR_STR_N, *bssid = NULL, *name = NULL, *rrd_file = NULL, cmd[1024];
- struct sockaddr_in client;
+ char message[12], bssid_flag, stat_type = 0, *bssid = NULL, *name = NULL, *rrd_file = NULL, cmd[1024];
#ifdef HAVE_GETTEXT
setlocale(LC_ALL, "");
textdomain("ap-utils");
#endif
- memset(&client, 0, sizeof client);
- client.sin_family = AF_INET;
- client.sin_port = INADDR_ANY;
- client.sin_addr.s_addr = INADDR_ANY;
-
if (argc < 4) {
usage();
exit(0);
goto quit;
}
-
- if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
- perror(_("Create socket error"));
- return 1;
- }
- if (bind(sockfd, (struct sockaddr *) &client, SIZE) == -1) {
- perror(_("Bind socket error"));
- return 1;
- }
-
switch (stat_type) {
case 'e':
varbinds[1].type = NULL_VALUE;
if (snmp(varbinds, 2, GET) <= 0) {
- printf(ERR_STR);
+ printf(ERR_STR, inet_ntoa(ap_ip));
return 1;
}
len_val);
memcpy(EthRxStat, varbinds[0].value, varbinds[0].len_val);
} else {
- printf(ERR_STR);
+ printf(ERR_STR, inet_ntoa(ap_ip));
return 1;
}
len_val);
memcpy(EthTxStat, varbinds[1].value, varbinds[1].len_val);
} else {
- printf(ERR_STR);
+ printf(ERR_STR, inet_ntoa(ap_ip));
return 1;
}
sprintf(cmd, "rrdtool update %s N:%u:%u", rrd_file, swap4(EthRxStat->TotalBytesRx), swap4(EthTxStat->TotalBytesTx));
varbinds[0].type = NULL_VALUE;
if (snmp(varbinds, 1, GET) <= 0) {
- printf(ERR_STR);
+ printf(ERR_STR, inet_ntoa(ap_ip));
return 1;
}
(struct wirelessStatistics_s *) malloc(varbinds[0].len_val);
memcpy(WirelessStat, varbinds[0].value, varbinds[0].len_val);
} else {
- printf(ERR_STR);
+ printf(ERR_STR, inet_ntoa(ap_ip));
return 1;
}
sprintf(cmd, "rrdtool update %s N:%u:%u", rrd_file,
varbinds[0].type = NULL_VALUE;
if (snmp(varbinds, 1, GET) <= 0) {
- printf(ERR_STR);
+ printf(ERR_STR, inet_ntoa(ap_ip));
return 1;
}
varbinds[0].type = NULL_VALUE;
if (snmp(varbinds, 1, GET) <= 0) {
- printf(ERR_STR);
+ printf(ERR_STR, inet_ntoa(ap_ip));
return 1;
}
if (*(varbinds[0].value) != 3) {
- printf(ERR_STR);
+ printf(ERR_STR, inet_ntoa(ap_ip));
return 1;
}
if (reset_flag) {
if (SysReset()) {
- printf(ERR_STR);
+ printf(ERR_STR, inet_ntoa(ap_ip));
return 1;
}
sleep(10);
varbinds[0].len_val = 0;
if (snmp(varbinds, 1, GET) <= 0) {
- printf(ERR_STR);
+ printf(ERR_STR, inet_ntoa(ap_ip));
return 1;
}
bssid_flag = 1;
break;
}
if (bssid_flag)
- printf(ERR_STR);
+ printf(ERR_STR, inet_ntoa(ap_ip));
break;
default:
usage();
printf("-\n");
}
*/
- close(sockfd);
-
quit:
if (community)
free(name);
return 0;
}
-