2014-10-05 19:56:27 +02:00
|
|
|
#ifndef __IWINFO_H_
|
|
|
|
#define __IWINFO_H_
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/wait.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <glob.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <dirent.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/mman.h>
|
|
|
|
#include <net/if.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
|
|
|
|
#define IWINFO_BUFSIZE 24 * 1024
|
|
|
|
#define IWINFO_ESSID_MAX_SIZE 32
|
|
|
|
|
|
|
|
#define IWINFO_80211_A (1 << 0)
|
|
|
|
#define IWINFO_80211_B (1 << 1)
|
|
|
|
#define IWINFO_80211_G (1 << 2)
|
|
|
|
#define IWINFO_80211_N (1 << 3)
|
|
|
|
#define IWINFO_80211_AC (1 << 4)
|
|
|
|
|
|
|
|
#define IWINFO_CIPHER_NONE (1 << 0)
|
|
|
|
#define IWINFO_CIPHER_WEP40 (1 << 1)
|
|
|
|
#define IWINFO_CIPHER_TKIP (1 << 2)
|
|
|
|
#define IWINFO_CIPHER_WRAP (1 << 3)
|
|
|
|
#define IWINFO_CIPHER_CCMP (1 << 4)
|
|
|
|
#define IWINFO_CIPHER_WEP104 (1 << 5)
|
|
|
|
#define IWINFO_CIPHER_AESOCB (1 << 6)
|
|
|
|
#define IWINFO_CIPHER_CKIP (1 << 7)
|
2016-01-25 15:00:22 +01:00
|
|
|
#define IWINFO_CIPHER_COUNT 8
|
2014-10-05 19:56:27 +02:00
|
|
|
|
|
|
|
#define IWINFO_KMGMT_NONE (1 << 0)
|
|
|
|
#define IWINFO_KMGMT_8021x (1 << 1)
|
|
|
|
#define IWINFO_KMGMT_PSK (1 << 2)
|
2016-01-25 15:00:22 +01:00
|
|
|
#define IWINFO_KMGMT_COUNT 3
|
2014-10-05 19:56:27 +02:00
|
|
|
|
|
|
|
#define IWINFO_AUTH_OPEN (1 << 0)
|
|
|
|
#define IWINFO_AUTH_SHARED (1 << 1)
|
2016-01-25 15:00:22 +01:00
|
|
|
#define IWINFO_AUTH_COUNT 2
|
2014-10-05 19:56:27 +02:00
|
|
|
|
2017-08-15 10:36:18 +02:00
|
|
|
#define IWINFO_FREQ_NO_10MHZ (1 << 0)
|
|
|
|
#define IWINFO_FREQ_NO_20MHZ (1 << 1)
|
|
|
|
#define IWINFO_FREQ_NO_HT40PLUS (1 << 2)
|
|
|
|
#define IWINFO_FREQ_NO_HT40MINUS (1 << 3)
|
|
|
|
#define IWINFO_FREQ_NO_80MHZ (1 << 4)
|
|
|
|
#define IWINFO_FREQ_NO_160MHZ (1 << 5)
|
|
|
|
|
2016-01-25 15:00:22 +01:00
|
|
|
extern const char *IWINFO_CIPHER_NAMES[IWINFO_CIPHER_COUNT];
|
|
|
|
extern const char *IWINFO_KMGMT_NAMES[IWINFO_KMGMT_COUNT];
|
|
|
|
extern const char *IWINFO_AUTH_NAMES[IWINFO_AUTH_COUNT];
|
2014-10-05 19:56:27 +02:00
|
|
|
|
|
|
|
|
|
|
|
enum iwinfo_opmode {
|
|
|
|
IWINFO_OPMODE_UNKNOWN = 0,
|
|
|
|
IWINFO_OPMODE_MASTER = 1,
|
|
|
|
IWINFO_OPMODE_ADHOC = 2,
|
|
|
|
IWINFO_OPMODE_CLIENT = 3,
|
|
|
|
IWINFO_OPMODE_MONITOR = 4,
|
|
|
|
IWINFO_OPMODE_AP_VLAN = 5,
|
|
|
|
IWINFO_OPMODE_WDS = 6,
|
|
|
|
IWINFO_OPMODE_MESHPOINT = 7,
|
|
|
|
IWINFO_OPMODE_P2P_CLIENT = 8,
|
|
|
|
IWINFO_OPMODE_P2P_GO = 9,
|
|
|
|
};
|
|
|
|
|
|
|
|
extern const char *IWINFO_OPMODE_NAMES[];
|
|
|
|
|
|
|
|
|
2015-05-08 13:14:36 +02:00
|
|
|
enum iwinfo_htmode {
|
|
|
|
IWINFO_HTMODE_HT20 = (1 << 0),
|
|
|
|
IWINFO_HTMODE_HT40 = (1 << 1),
|
|
|
|
IWINFO_HTMODE_VHT20 = (1 << 2),
|
|
|
|
IWINFO_HTMODE_VHT40 = (1 << 3),
|
|
|
|
IWINFO_HTMODE_VHT80 = (1 << 4),
|
|
|
|
IWINFO_HTMODE_VHT80_80 = (1 << 5),
|
|
|
|
IWINFO_HTMODE_VHT160 = (1 << 6),
|
|
|
|
|
|
|
|
IWINFO_HTMODE_COUNT = 7
|
|
|
|
};
|
|
|
|
|
|
|
|
extern const char *IWINFO_HTMODE_NAMES[IWINFO_HTMODE_COUNT];
|
|
|
|
|
|
|
|
|
2014-10-05 19:56:27 +02:00
|
|
|
struct iwinfo_rate_entry {
|
|
|
|
uint32_t rate;
|
|
|
|
int8_t mcs;
|
|
|
|
uint8_t is_40mhz:1;
|
|
|
|
uint8_t is_short_gi:1;
|
2016-01-25 15:01:49 +01:00
|
|
|
uint8_t is_ht:1;
|
|
|
|
uint8_t is_vht:1;
|
|
|
|
uint8_t mhz;
|
|
|
|
uint8_t nss;
|
2014-10-05 19:56:27 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct iwinfo_assoclist_entry {
|
|
|
|
uint8_t mac[6];
|
|
|
|
int8_t signal;
|
|
|
|
int8_t noise;
|
|
|
|
uint32_t inactive;
|
|
|
|
uint32_t rx_packets;
|
|
|
|
uint32_t tx_packets;
|
|
|
|
struct iwinfo_rate_entry rx_rate;
|
|
|
|
struct iwinfo_rate_entry tx_rate;
|
2015-08-08 14:22:26 +02:00
|
|
|
uint32_t rx_bytes;
|
|
|
|
uint32_t tx_bytes;
|
|
|
|
uint32_t tx_retries;
|
|
|
|
uint32_t tx_failed;
|
|
|
|
uint64_t t_offset;
|
|
|
|
uint8_t is_authorized:1;
|
|
|
|
uint8_t is_authenticated:1;
|
|
|
|
uint8_t is_preamble_short:1;
|
|
|
|
uint8_t is_wme:1;
|
|
|
|
uint8_t is_mfp:1;
|
|
|
|
uint8_t is_tdls:1;
|
2018-02-14 21:37:44 +01:00
|
|
|
uint32_t thr;
|
2014-10-05 19:56:27 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct iwinfo_txpwrlist_entry {
|
|
|
|
uint8_t dbm;
|
|
|
|
uint16_t mw;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct iwinfo_freqlist_entry {
|
|
|
|
uint8_t channel;
|
|
|
|
uint32_t mhz;
|
|
|
|
uint8_t restricted;
|
2017-08-15 10:36:18 +02:00
|
|
|
uint32_t flags;
|
2014-10-05 19:56:27 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct iwinfo_crypto_entry {
|
|
|
|
uint8_t enabled;
|
|
|
|
uint8_t wpa_version;
|
|
|
|
uint8_t group_ciphers;
|
|
|
|
uint8_t pair_ciphers;
|
|
|
|
uint8_t auth_suites;
|
|
|
|
uint8_t auth_algs;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct iwinfo_scanlist_entry {
|
|
|
|
uint8_t mac[6];
|
2015-05-19 18:54:58 +02:00
|
|
|
char ssid[IWINFO_ESSID_MAX_SIZE+1];
|
2014-10-05 19:56:27 +02:00
|
|
|
enum iwinfo_opmode mode;
|
|
|
|
uint8_t channel;
|
|
|
|
uint8_t signal;
|
|
|
|
uint8_t quality;
|
|
|
|
uint8_t quality_max;
|
|
|
|
struct iwinfo_crypto_entry crypto;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct iwinfo_country_entry {
|
|
|
|
uint16_t iso3166;
|
2015-05-19 18:54:58 +02:00
|
|
|
char ccode[4];
|
2014-10-05 19:56:27 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct iwinfo_iso3166_label {
|
|
|
|
uint16_t iso3166;
|
2015-05-19 18:54:58 +02:00
|
|
|
char name[28];
|
2014-10-05 19:56:27 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct iwinfo_hardware_id {
|
|
|
|
uint16_t vendor_id;
|
|
|
|
uint16_t device_id;
|
|
|
|
uint16_t subsystem_vendor_id;
|
|
|
|
uint16_t subsystem_device_id;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct iwinfo_hardware_entry {
|
|
|
|
char vendor_name[64];
|
|
|
|
char device_name[64];
|
|
|
|
uint16_t vendor_id;
|
|
|
|
uint16_t device_id;
|
|
|
|
uint16_t subsystem_vendor_id;
|
|
|
|
uint16_t subsystem_device_id;
|
|
|
|
int16_t txpower_offset;
|
|
|
|
int16_t frequency_offset;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern const struct iwinfo_iso3166_label IWINFO_ISO3166_NAMES[];
|
|
|
|
|
|
|
|
#define IWINFO_HARDWARE_FILE "/usr/share/libiwinfo/hardware.txt"
|
|
|
|
|
|
|
|
|
|
|
|
struct iwinfo_ops {
|
|
|
|
const char *name;
|
|
|
|
|
|
|
|
int (*probe)(const char *ifname);
|
|
|
|
int (*mode)(const char *, int *);
|
|
|
|
int (*channel)(const char *, int *);
|
|
|
|
int (*frequency)(const char *, int *);
|
|
|
|
int (*frequency_offset)(const char *, int *);
|
|
|
|
int (*txpower)(const char *, int *);
|
|
|
|
int (*txpower_offset)(const char *, int *);
|
|
|
|
int (*bitrate)(const char *, int *);
|
|
|
|
int (*signal)(const char *, int *);
|
|
|
|
int (*noise)(const char *, int *);
|
|
|
|
int (*quality)(const char *, int *);
|
|
|
|
int (*quality_max)(const char *, int *);
|
|
|
|
int (*mbssid_support)(const char *, int *);
|
|
|
|
int (*hwmodelist)(const char *, int *);
|
2015-05-08 13:14:36 +02:00
|
|
|
int (*htmodelist)(const char *, int *);
|
2014-10-05 19:56:27 +02:00
|
|
|
int (*ssid)(const char *, char *);
|
|
|
|
int (*bssid)(const char *, char *);
|
|
|
|
int (*country)(const char *, char *);
|
|
|
|
int (*hardware_id)(const char *, char *);
|
|
|
|
int (*hardware_name)(const char *, char *);
|
|
|
|
int (*encryption)(const char *, char *);
|
|
|
|
int (*phyname)(const char *, char *);
|
|
|
|
int (*assoclist)(const char *, char *, int *);
|
|
|
|
int (*txpwrlist)(const char *, char *, int *);
|
|
|
|
int (*scanlist)(const char *, char *, int *);
|
|
|
|
int (*freqlist)(const char *, char *, int *);
|
|
|
|
int (*countrylist)(const char *, char *, int *);
|
2014-10-27 16:59:03 +01:00
|
|
|
int (*lookup_phy)(const char *, char *);
|
2014-10-05 19:56:27 +02:00
|
|
|
void (*close)(void);
|
|
|
|
};
|
|
|
|
|
|
|
|
const char * iwinfo_type(const char *ifname);
|
|
|
|
const struct iwinfo_ops * iwinfo_backend(const char *ifname);
|
2014-10-27 16:57:19 +01:00
|
|
|
const struct iwinfo_ops * iwinfo_backend_by_name(const char *name);
|
2014-10-05 19:56:27 +02:00
|
|
|
void iwinfo_finish(void);
|
|
|
|
|
|
|
|
extern const struct iwinfo_ops wext_ops;
|
|
|
|
extern const struct iwinfo_ops madwifi_ops;
|
|
|
|
extern const struct iwinfo_ops nl80211_ops;
|
|
|
|
extern const struct iwinfo_ops wl_ops;
|
|
|
|
|
|
|
|
#include "iwinfo/utils.h"
|
|
|
|
|
|
|
|
#endif
|