#include <stdio.h>
#include <malloc.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#include <signal.h>
#include <errno.h>
#include <asm/types.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <linux/wireless.h>
#include "owntypes.h"
#include <linux/filter.h>
#include <netinet/ip_icmp.h>
#include <netinet/ip.h>
#include <features.h>
#include <linux/if_packet.h>
#include <linux/if_ether.h>
#include "debug.h"
#include "agentadv.h"
#include "dyn_wireless.h"
#include "monitor.h"
#include "fixed_fd_zero.h"
#include "util.h"
#include "dyn_iwspy_rec.h"
Include dependency graph for iwspy-gather.c:
Go to the source code of this file.
Defines | |
#define | DEBUG_FLAG '5' |
#define | TIME_ERROR 10000 |
#define | DEFAULT_INTERVAL 1000000 |
#define | USAGE |
#define | MAX_ADV_RADDRS 10 |
#define | MAX_ADV_COADDRS 10 |
Functions | |
int | main (int argc, char **argv) |
Variables | |
int | opt_debug |
int | iwspy_sock |
int | bcast_sock |
int | adver_sock |
int | interval |
char | ifname [IFNAMSIZ] |
char | cache [ETH_ALEN *IW_MAX_SPY+1] |
#define DEBUG_FLAG '5' |
Definition at line 50 of file iwspy-gather.c.
#define DEFAULT_INTERVAL 1000000 |
#define MAX_ADV_COADDRS 10 |
Definition at line 159 of file iwspy-gather.c.
#define MAX_ADV_RADDRS 10 |
Definition at line 158 of file iwspy-gather.c.
#define TIME_ERROR 10000 |
Definition at line 51 of file iwspy-gather.c.
#define USAGE |
Value:
"iwspy_gather [-h] [-v] -d <device_name> [-i <msecs>] [-l <seconds>]\n"\ "Options:\n"\ "\t-h\t\t\thelp (--help)\n"\ "\t-v\t\t\tverbose (--verbose)\n"\ "\t-d <name>\t\tdevice (--device)\n"\ "\t-i <milliseconds>\tchecking interval in milliseconds (--interval)\n"\ "\t-l <seconds>\t\tmonitoring length in seconds (--length)\n"
Definition at line 53 of file iwspy-gather.c.
int main | ( | int | argc, | |
char ** | argv | |||
) |
Definition at line 263 of file iwspy-gather.c.
References cache, clean_up(), DEBUG(), DEBUG_FLAG, DEFAULT_INTERVAL, dyn_wireless_get_ifname(), ifname, interval, opt_debug, optarg, rec_init(), and USAGE.
00264 { 00265 unsigned long length = 0; 00266 int ret = -1, c, oindex; 00267 struct timeval end; 00268 00269 interval = -1; 00270 00271 if (fopen("/var/run/dynamics_mn_read", "r") != NULL || 00272 fopen("/var/run/dynamics_mn_admin", "r") != NULL) { 00273 fprintf(stderr, "Don't run Mobile Node and iwspy_gather " 00274 "together. Exiting..\n"); 00275 return 1; 00276 } 00277 00278 /* parse arguments */ 00279 while ((c = getopt_long(argc, argv, "i:d:hl:v", long_options, 00280 &oindex)) 00281 != EOF) { 00282 switch (c) { 00283 case 'i': /* interval */ 00284 DEBUG(DEBUG_FLAG, "option i (Interval) with value" 00285 " '%s'\n", optarg); 00286 interval = atoi(optarg); 00287 break; 00288 case 'd': /* device */ 00289 DEBUG(DEBUG_FLAG, "option d (Device) with value" 00290 " '%s'\n", optarg); 00291 ret = dyn_wireless_get_ifname(optarg, ifname); 00292 break; 00293 case 'l': /* stop after <arg> seconds */ 00294 DEBUG(DEBUG_FLAG, "option l (Length) with value" 00295 " '%s'\n", optarg); 00296 length = atol(optarg); 00297 if (length <= 0) { 00298 fprintf(stderr, "length must be >0!\n"); 00299 return 1; 00300 } 00301 gettimeofday(&end, NULL); 00302 length += end.tv_sec; 00303 break; 00304 case 'v': /* verbose */ 00305 opt_debug = 1; 00306 break; 00307 case 'h': /* Usage */ 00308 default: 00309 printf(USAGE); 00310 return 1; 00311 } 00312 } 00313 00314 /* interface given? */ 00315 if (ret < 0) { 00316 fprintf(stderr, "No device argument!\n"); 00317 printf(USAGE); 00318 return 1; 00319 } 00320 00321 /* decent range? */ 00322 if (interval >= 0 && interval < 10) { 00323 fprintf(stderr, "Interval must be at least 10 msecs\n"); 00324 return 2; 00325 } 00326 00327 /* open sockets */ 00328 if (init_sockets()) { 00329 fprintf(stderr, "Open socket(s) failed\n"); 00330 return 3; 00331 } 00332 00333 /* Setup signal handler */ 00334 signal(SIGTERM, clean_up); 00335 signal(SIGINT, clean_up); 00336 signal(SIGHUP, clean_up); 00337 00338 /* initialize quality recorder database */ 00339 if (rec_init() < 0) { 00340 fprintf(stderr, "Recorder initialization failed!\n"); 00341 return 4; 00342 } 00343 00344 /* clear cache */ 00345 memset(cache, 0, sizeof(cache)); 00346 00347 /* begin harvesting */ 00348 if (interval < 0) 00349 collect_stats(DEFAULT_INTERVAL, length); 00350 else 00351 collect_stats((unsigned long)(interval*1000), length); 00352 00353 clean_up(0); 00354 return 0; 00355 }
Here is the call graph for this function:
int adver_sock |
Definition at line 74 of file iwspy-gather.c.
int bcast_sock |
Definition at line 74 of file iwspy-gather.c.
char cache[ETH_ALEN *IW_MAX_SPY+1] |
char ifname[IFNAMSIZ] |
Definition at line 75 of file iwspy-gather.c.
int interval |
int iwspy_sock |
Definition at line 74 of file iwspy-gather.c.
int opt_debug |