#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <netinet/ip_icmp.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <asm/types.h>
#include <stdio.h>
#include <stddef.h>
#include <errno.h>
#include <fcntl.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <syslog.h>
#include <assert.h>
#include <features.h>
#include <linux/if_packet.h>
#include <linux/if_ether.h>
#include "owntypes.h"
#include <linux/filter.h>
#include "mn.h"
#include "monitor.h"
#include "debug.h"
#include "util.h"
#include "mn_agentadv.h"
#include "mn_handler.h"
#include "list.h"
#include "dyn_wireless.h"
#include "dyn_iwspy_rec.h"
Include dependency graph for monitor.c:
Go to the source code of this file.
Defines | |
#define | DEBUG_FLAG 'm' |
#define | REC_DUMP_TYPE 4 |
#define | MAX_QUAL 92 |
Functions | |
int | MONITOR_unregister_module (void) |
void | MONITOR_register_module (void) |
void | monitor_poll_ap_addresses (struct mn_data *mn) |
Variables | |
monitor_global_data | mon_conf |
GLOBAL VARIABLES. | |
monitor_interface | mon_devs [MAX_INTERFACES] |
int | mon_rec_qual_initialized |
monitor_conf_vars | monitor_conf [] |
STRUCTURES. |
#define MAX_QUAL 92 |
#define REC_DUMP_TYPE 4 |
void monitor_poll_ap_addresses | ( | struct mn_data * | mn | ) |
Definition at line 1360 of file monitor.c.
References monitor_interface::ap_hwaddr, DEBUG(), interface_data::device, dyn_wireless_get_ap_address(), mn_data::iface, mn, mon_devs, interface_data::s, and sock.
01361 { 01362 int i, j; 01363 char new_addr[ETH_ALEN]; 01364 01365 DEBUG(DEBUG_FLAG, "monitor_poll_ap_addresses()\n"); 01366 for (i = 0; i < MAX_INTERFACES; i++) { 01367 if (!mon_devs[i].in_use || mon_devs[i].sock < 0) 01368 continue; 01369 01370 if (dyn_wireless_get_ap_address(mon_devs[i].sock, 01371 mon_devs[i].ifname, 01372 new_addr) < 0) { 01373 DEBUG(DEBUG_FLAG, "monitor_poll_ap_addresses: get AP " 01374 "hw addr failed\n"); 01375 continue; 01376 } 01377 01378 if (memcmp(new_addr, mon_devs[i].ap_hwaddr, ETH_ALEN) != 0) { 01379 DEBUG(DEBUG_FLAG, "Monitor: AP hw addr changed " 01380 "(iface=%s): %s => ", 01381 mon_devs[i].ifname, 01382 ether_hwtoa((unsigned char *) 01383 mon_devs[i].ap_hwaddr)); 01384 DEBUG(DEBUG_FLAG, "%s\n", 01385 ether_hwtoa((unsigned char *) new_addr)); 01386 /* send agentsol to this interface */ 01387 for (j = 0; j < MAX_INTERFACES; j++) { 01388 if (strcmp(mon_devs[i].ifname, 01389 mn->iface[j].device) != 0 || 01390 mn->iface[j].s < 0) 01391 continue; 01392 01393 send_agent_solicitation(mn->iface[j].s); 01394 } 01395 memcpy(mon_devs[i].ap_hwaddr, new_addr, ETH_ALEN); 01396 } 01397 } 01398 }
Here is the call graph for this function:
void MONITOR_register_module | ( | void | ) |
Definition at line 1331 of file monitor.c.
References monitor_global_data::average_length, monitor_global_data::current_adv, monitor_global_data::current_fa, DEFAULT_AVG_LEN, monitor_global_data::default_ch, DEFAULT_DEV_PRIO_PERCENT, DEFAULT_EARLY_EXPIRE_TIME, DEFAULT_MIN_BALANCE, DEFAULT_THRESHOLD, DEFAULT_WORST_MAX_TIME, DEFAULT_WORST_MIN_TIME, monitor_global_data::dev_priority_percentage, monitor_global_data::expiretime, handler_register(), INTERFACE_DOWN, INTERFACE_INIT, monitor_global_data::interfaces, monitor_global_data::iwspy_supported, monitor_global_data::min_balance, mon_conf, mon_devs, mon_rec_qual_initialized, monitor_global_data::old_fa_factor, OLD_FA_FACTOR, monitor_global_data::rec_qual, monitor_global_data::reg_send_timer, monitor_global_data::SQ_cache, monitor_global_data::threshold, monitor_global_data::worst_max_time, and monitor_global_data::worst_min_time.
Referenced by mn_init().
01332 { 01333 /* initialize state and variables */ 01334 memset(&mon_conf, 0, sizeof(struct monitor_global_data)); 01335 mon_conf.current_fa = -1; /* not connected yet */ 01336 mon_conf.current_adv = NULL; 01337 mon_conf.reg_send_timer = NULL; 01338 mon_conf.interfaces = 0; 01339 mon_conf.iwspy_supported = 0; 01340 mon_conf.threshold = DEFAULT_THRESHOLD; 01341 mon_conf.default_ch = -1; 01342 mon_conf.old_fa_factor = OLD_FA_FACTOR; 01343 mon_conf.expiretime = DEFAULT_EARLY_EXPIRE_TIME; 01344 mon_conf.min_balance = DEFAULT_MIN_BALANCE; 01345 mon_conf.worst_min_time = DEFAULT_WORST_MIN_TIME; 01346 mon_conf.worst_max_time = DEFAULT_WORST_MAX_TIME; 01347 mon_conf.dev_priority_percentage = DEFAULT_DEV_PRIO_PERCENT; 01348 mon_conf.average_length = DEFAULT_AVG_LEN; 01349 mon_conf.rec_qual = 0; 01350 mon_conf.SQ_cache = 0; 01351 mon_rec_qual_initialized = 0; 01352 memset(mon_devs, 0, sizeof(mon_devs)); 01353 01354 /* register event_INTERFACE handlers */ 01355 handler_register(INTERFACE_INIT, monitor_interface_up); 01356 handler_register(INTERFACE_DOWN, monitor_interface_down); 01357 }
Here is the call graph for this function:
int MONITOR_unregister_module | ( | void | ) |
Definition at line 1303 of file monitor.c.
References dyn_wireless_iwspy_set(), mon_conf, mon_devs, mon_rec_qual_initialized, rec_clean_up(), rec_dump(), REC_DUMP_TYPE, monitor_global_data::rec_qual, sock, monitor_interface::sock, and monitor_global_data::SQ_cache.
Referenced by clean_up().
01304 { 01305 int i; 01306 01307 for (i = 0; i < MAX_INTERFACES; i++) { 01308 if (!mon_devs[i].in_use) 01309 continue; 01310 if (mon_devs[i].iwspy_support && !mon_conf.SQ_cache) 01311 dyn_wireless_iwspy_set(mon_devs[i].sock, 01312 mon_devs[i].ifname, NULL, 0); 01313 01314 if (mon_devs[i].sock >= 0) { 01315 close(mon_devs[i].sock); 01316 mon_devs[i].sock = -1; 01317 } 01318 } 01319 01320 if (mon_rec_qual_initialized) { 01321 if (mon_conf.rec_qual) 01322 rec_dump(REC_DUMP_TYPE, -1); 01323 rec_clean_up(); 01324 mon_rec_qual_initialized = 0; 01325 } 01326 01327 return 0; 01328 }
Here is the call graph for this function:
struct monitor_global_data mon_conf |
GLOBAL VARIABLES.
Definition at line 144 of file monitor.c.
Referenced by drop_worst(), monitor_get_dev(), MONITOR_register_module(), and MONITOR_unregister_module().
struct monitor_interface mon_devs[MAX_INTERFACES] |
Definition at line 145 of file monitor.c.
Referenced by monitor_api_get_ch(), monitor_api_set_ch(), monitor_get_dev(), monitor_poll_ap_addresses(), MONITOR_register_module(), MONITOR_unregister_module(), and print_entries().
Definition at line 146 of file monitor.c.
Referenced by MONITOR_register_module(), and MONITOR_unregister_module().
struct monitor_conf_vars monitor_conf[] |
Initial value:
{ {"Threshold (0-100) ", 1, &mon_conf.threshold, 0, 100}, {"Min-balance (0-100) ", 1, &mon_conf.min_balance, 0, 100}, {"Expirepercent (1-300) ", 1, &mon_conf.expiretime, 1, 300}, {"Old-FA-factor (0-100) ", 1, &mon_conf.old_fa_factor, 0, 100}, {"Worst-min-time (0- ) ", 8, &mon_conf.worst_min_time, 0, -1}, {"Worst-max-time (0- ) ", 8, &mon_conf.worst_max_time, 0, -1}, {"Average-length (1-10) ", 1, &mon_conf.average_length, 1, 10}, {"Default-channel (1-14) ", 1, &mon_conf.default_ch, 1, 14}, {"Record-quality (0, 1) ", 1, &mon_conf.rec_qual, 0, 1}, {"SQ-cache (0, 1) ", 1, &mon_conf.SQ_cache, 0, 1}, {"", 0, NULL, 0, 0} }