00001 /* $Id: monitor.h,v 1.41 2001/09/29 16:06:39 jm Exp $ 00002 * Header files for Monitor module 00003 * 00004 * Dynamic hierarchial IP tunnel 00005 * Copyright (C) 1998-2001, Dynamics group 00006 * 00007 * This program is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License version 2 as 00009 * published by the Free Software Foundation. See README and COPYING for 00010 * more details. 00011 */ 00012 00013 #ifndef MONITOR_H 00014 #define MONITOR_H 00015 00016 #include <values.h> 00017 #include <asm/types.h> 00018 #include <sys/types.h> 00019 #include <sys/socket.h> 00020 #include <sys/time.h> 00021 #include <linux/wireless.h> 00022 #include <netinet/in.h> 00023 #include "mn.h" 00024 #include "owntypes.h" 00025 00026 #if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1 00027 #include <net/ethernet.h> /* the L2 protocols */ 00028 #include <netinet/if_ether.h> 00029 #else 00030 #include <linux/if_ether.h> /* The L2 protocols */ 00031 #endif 00032 00033 00034 /* defaults */ 00035 #define DEFAULT_THRESHOLD 90 /* 0 < treshold < 100. Quality treshold for 00036 changing FA (in percent) */ 00037 /* if more than MAX_MONITOR FAs to monitor, then drop worst FA from the 00038 iwspy list. Don't drop before the entry has been there WORST_MIN_TIME 00039 seconds. If some entry is older than WORST_MAX_TIME, then drop that one. 00040 00041 NOTICE: If WORST_MAX_TIME is smaller than FA agent advertisement interval, 00042 then the first found entry is dropped (not good). 00043 00044 NOTICE: If WORST_MIN_TIME is smaller than the FA agent advertisement 00045 interval, then the worst entry may not have enough time to get the quality 00046 value */ 00047 #define DEFAULT_WORST_MIN_TIME 10 00048 #define DEFAULT_WORST_MAX_TIME 20 00049 #define DEFAULT_MIN_BALANCE 10 00050 #define DEFAULT_EARLY_EXPIRE_TIME 50 00051 #define DEFAULT_AVG_LEN 3 00052 #define MAX_MONITOR 20 /* with SQ_cache the max number of entries */ 00053 #define MAX_KERNEL IW_MAX_SPY /* NOTICE! If you're using wvlan 0.2.7 00054 or below, use IW_MAX_SPY-2 because 00055 there is bug */ 00056 #define OLD_FA_FACTOR 50 /* 0 < factor < 100. multiply with this and 00057 divide with 100 if the advertisement 00058 isn't fresh */ 00059 #define DEFAULT_WIRELESS_PRIO 1.0 /* priority for single wireless interface */ 00060 #define DEFAULT_DEV_PRIO_PERCENT 0 /* don't use device priority for 00061 wireless interfaces */ 00062 #define MAXPRIORITY MAXINT /* Maximum priority for FA */ 00063 00064 /* MON_CONF API call types */ 00065 #define GET_MONCONF 1 00066 #define GET_MONCONF_VAR 2 00067 #define SET_MONCONF_VAR 3 00068 00069 /* structures */ 00070 00071 struct monitor_address { 00072 struct agentadv_data *adv; 00073 int active; /* 1 = used, -1 = not used or old, 0 not initialized */ 00074 __u16 fa_adv_lifetime; 00075 struct iw_quality qual; 00076 __u8 q10[10]; 00077 unsigned short q10_index; 00078 unsigned short avg; 00079 struct timeval updated; 00080 struct timeval added; 00081 }; 00082 00083 struct monitor_global_data { 00084 int current_fa; 00085 char current_dev[IFNAMSIZ]; 00086 int interfaces; 00087 int iwspy_supported; 00088 int dev_priority_percentage; /* The weight of the device priority */ 00089 int priority_factor; 00090 int threshold; 00091 int default_ch; 00092 int old_fa_factor; 00093 int expiretime; 00094 int min_balance; 00095 int worst_min_time; 00096 int worst_max_time; 00097 int average_length; 00098 int rec_qual; 00099 int SQ_cache; 00100 struct agentadv_data **current_adv; 00101 struct timeval *reg_send_timer; 00102 }; 00103 00104 struct monitor_interface { 00105 short in_use; 00106 short priority; 00107 short channel_get_support; /* is ch get supported */ 00108 short channel_support; /* is ch set supported */ 00109 short iwspy_support; 00110 char ifname[IFNAMSIZ]; 00111 int sock; 00112 int spy_number; 00113 int channel; 00114 int test_slot; 00115 struct iw_range range; 00116 /* If the link quality parameter is updated lately mark it update */ 00117 short vector_update[MAX_MONITOR]; 00118 /* Save information about the link quality to the FA */ 00119 struct monitor_address mon[MAX_MONITOR]; 00120 char ap_hwaddr[ETH_ALEN]; /* last polled AP hw address */ 00121 }; 00122 00123 00124 /* State variables */ 00125 struct monitor_conf_vars { 00126 char *name; /* name for mn_tool (etc.) */ 00127 int min_chars; /* minimum number of chars that must be compared */ 00128 int *value; /* pointer to the variable */ 00129 int min; /* minimun value (-1 no minimum) */ 00130 int max; /* maximum (-1, no maximu) */ 00131 }; 00132 00133 /* module interface */ 00134 void MONITOR_register_module(void); 00135 int MONITOR_unregister_module(void); 00136 00137 struct mn_data; 00138 void monitor_poll_ap_addresses(struct mn_data *mn); 00139 00140 00141 /* monitor_api.c */ 00142 int monitor_api_get_ch(unsigned char *buffer, __u16 *length); 00143 int monitor_api_set_ch(char *ifname, int channel); 00144 int monitor_api_mon_conf(char *buffer, int len, int type); 00145 00146 /* monitor_util.c */ 00147 int next(int p); 00148 int prev(int p); 00149 int drop_worst(struct timeval *tstamp, struct monitor_interface *dev); 00150 int get_free_slot(struct timeval *tstamp, struct monitor_interface *dev); 00151 struct monitor_interface *monitor_get_dev(char *ifname); 00152 void print_entries(void); 00153 int find_current_fa_iter(struct node *nod, void *data); 00154 00155 #endif /* MONITOR_H */