diff options
author | Jonathan McCrohan <jmccrohan@gmail.com> | 2014-01-25 00:07:30 +0000 |
---|---|---|
committer | Jonathan McCrohan <jmccrohan@gmail.com> | 2014-01-25 00:07:30 +0000 |
commit | d7ca0c3e555ef0b5250873ddce48ccf2326b017a (patch) | |
tree | 52fc801f0893eb7752524b2602d420afbda4ed59 /iw_if.h | |
parent | 3645c236e9720deb696e7aebc33cd9a6d8cbbdc6 (diff) | |
download | wavemon-d7ca0c3e555ef0b5250873ddce48ccf2326b017a.tar.gz |
Imported Upstream version 0.7.6upstream/0.7.6
Diffstat (limited to 'iw_if.h')
-rw-r--r-- | iw_if.h | 66 |
1 files changed, 51 insertions, 15 deletions
@@ -19,6 +19,7 @@ */ #include "wavemon.h" #include <netdb.h> +#include <pthread.h> #include <arpa/inet.h> #include <netinet/in.h> #include <netinet/ether.h> @@ -66,11 +67,10 @@ struct if_info { netmask, bcast; uint16_t mtu; - short txqlen; - short flags; + uint16_t txqlen; + uint16_t flags; }; -extern bool if_is_up(int skfd, const char *ifname); -extern int if_set_up(int skfd, const char *ifname); +extern int if_set_up(const char *ifname); extern void if_getinf(const char *ifname, struct if_info *info); /** @@ -232,30 +232,32 @@ static inline void sampling_stop(void) { alarm(0); } * Organization of scan results */ /** - * struct scan_result - Ranked list of scan results + * struct scan_entry - Representation of a single scan result. * @ap_addr: MAC address * @essid: station SSID (may be empty) * @mode: operation mode (type of station) * @freq: frequency/channel information + * @chan: channel corresponding to @freq (where applicable) * @qual: signal quality information * @has_key: whether using encryption or not * @flags: properties gathered from Information Elements - * @next: next, lower-ranking entry + * @next: next entry in list */ -struct scan_result { +struct scan_entry { struct ether_addr ap_addr; char essid[IW_ESSID_MAX_SIZE + 2]; int mode; double freq; - struct iw_quality qual; + int chan; + struct iw_quality qual; + struct iw_levelstat dbm; int has_key:1; uint32_t flags; - struct scan_result *next; + struct scan_entry *next; }; -extern struct scan_result *get_scan_list(int skfd, const char *ifname, int we_version); -extern void free_scan_result(struct scan_result *head); +extern void sort_scan_list(struct scan_entry **headp); /** * struct cnt - count frequency of integer numbers @@ -266,8 +268,42 @@ struct cnt { int val; int count; }; -extern struct cnt *channel_stats(struct scan_result *head, - struct iw_range *iw_range, int *max_cnt); + +/** + * struct scan_result - Structure to aggregate all collected scan data. + * @head: begin of scan_entry list (may be NULL) + * @msg: error message, if any + * @max_essid_len: maximum ESSID-string length (for formatting) + * @channel_stats: array of channel statistics entries + * @num.total: number of entries in list starting at @head + * @num.open: number of open entries among @num.total + * @num.two_gig: number of 2.4GHz stations among @num.total + * @num.five_gig: number of 5 GHz stations among @num.total + * @num.ch_stats: length of @channel_stats array + * @range: range data associated with scan interface + * @mutex: protects against concurrent consumer/producer access + */ +struct scan_result { + struct scan_entry *head; + char msg[128]; + uint16_t max_essid_len; + struct cnt *channel_stats; + struct assorted_numbers { + uint16_t entries, + open, + two_gig, + five_gig; +/* Maximum number of 'top' statistics entries. */ +#define MAX_CH_STATS 3 + size_t ch_stats; + } num; + struct iw_range range; + pthread_mutex_t mutex; +}; + +extern void scan_result_init(struct scan_result *sr); +extern void scan_result_fini(struct scan_result *sr); +extern void *do_scan(void *sr_ptr); /* * General helper routines @@ -484,8 +520,8 @@ static inline int freq_to_channel(double freq, const struct iw_range *range) { int i; - if (freq < 1.0e3) - return -1; + if (freq < 1e3) /* Convention: freq is channel number if < 1e3 */ + return freq; for (i = 0; i < range->num_frequency; i++) if (freq_to_hz(&range->freq[i]) == freq) |