X-Git-Url: https://git.decadent.org.uk/gitweb/?p=ap-utils.git;a=blobdiff_plain;f=src%2Fap-rrd.c;h=3f4c06ea6c8b5138d0fef958ebe9c8e731013084;hp=33b5463b507fe350f654f4bf8e058c11b9135923;hb=30c08d141bacedf0dd15a8eb8e4797fc8c26adeb;hpb=16204dfc7715783c2ebdfb55fc44fb9344613a76 diff --git a/src/ap-rrd.c b/src/ap-rrd.c index 33b5463..3f4c06e 100644 --- a/src/ap-rrd.c +++ b/src/ap-rrd.c @@ -1,5 +1,5 @@ /* - * 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 * @@ -29,12 +29,10 @@ #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() @@ -55,7 +53,7 @@ void usage() printf(_("-a aptype - AP type - 410 (default) or 510 for ATMEL12350's, like the ME-102\n")); printf(_("-r - reset AP when getting LinkQuality stats\n")); printf(_("-h - print this help screen\n\n")); - printf(_("ap-rrd %s Copyright (c) 2002-2004 Roman Festchook\n\n"), + printf(_("ap-rrd %s Copyright (c) 2002-2006 Roman Festchook\n\n"), VERSION); } @@ -114,9 +112,7 @@ int main(int argc, char **argv) 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, ""); @@ -124,11 +120,6 @@ int main(int argc, char **argv) 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); @@ -202,16 +193,6 @@ int main(int argc, char **argv) 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': @@ -228,7 +209,7 @@ int main(int argc, char **argv) varbinds[1].type = NULL_VALUE; if (snmp(varbinds, 2, GET) <= 0) { - printf(ERR_STR); + printf(ERR_STR, inet_ntoa(ap_ip)); return 1; } @@ -240,7 +221,7 @@ int main(int argc, char **argv) len_val); memcpy(EthRxStat, varbinds[0].value, varbinds[0].len_val); } else { - printf(ERR_STR); + printf(ERR_STR, inet_ntoa(ap_ip)); return 1; } @@ -252,7 +233,7 @@ int main(int argc, char **argv) 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)); @@ -270,7 +251,7 @@ int main(int argc, char **argv) varbinds[0].type = NULL_VALUE; if (snmp(varbinds, 1, GET) <= 0) { - printf(ERR_STR); + printf(ERR_STR, inet_ntoa(ap_ip)); return 1; } @@ -281,7 +262,7 @@ int main(int argc, char **argv) (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, @@ -302,7 +283,7 @@ int main(int argc, char **argv) varbinds[0].type = NULL_VALUE; if (snmp(varbinds, 1, GET) <= 0) { - printf(ERR_STR); + printf(ERR_STR, inet_ntoa(ap_ip)); return 1; } @@ -318,18 +299,18 @@ int main(int argc, char **argv) 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); @@ -341,7 +322,7 @@ int main(int argc, char **argv) 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; @@ -366,7 +347,7 @@ int main(int argc, char **argv) break; } if (bssid_flag) - printf(ERR_STR); + printf(ERR_STR, inet_ntoa(ap_ip)); break; default: usage(); @@ -396,8 +377,6 @@ int main(int argc, char **argv) printf("-\n"); } */ - close(sockfd); - quit: if (community) @@ -410,4 +389,3 @@ int main(int argc, char **argv) free(name); return 0; } -