| 1 | /*
|
|---|
| 2 | This file is part of Wi-viz (http://wiviz.natetrue.com).
|
|---|
| 3 |
|
|---|
| 4 | Wi-viz is free software; you can redistribute it and/or modify
|
|---|
| 5 | it under the terms of the GNU General Public License v2 as published by
|
|---|
| 6 | the Free Software Foundation.
|
|---|
| 7 |
|
|---|
| 8 | Wi-viz is distributed in the hope that it will be useful,
|
|---|
| 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 11 | GNU General Public License for more details.
|
|---|
| 12 |
|
|---|
| 13 | You should have received a copy of the GNU General Public License
|
|---|
| 14 | along with Wi-viz; if not, write to the Free Software
|
|---|
| 15 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|---|
| 16 | */
|
|---|
| 17 | //Structure definitions for wireless packets
|
|---|
| 18 |
|
|---|
| 19 | #define MAX_HOSTS 257
|
|---|
| 20 |
|
|---|
| 21 | #ifdef DEFINE_TYPES
|
|---|
| 22 | typedef unsigned short u_short;
|
|---|
| 23 | typedef unsigned char u_char;
|
|---|
| 24 | typedef unsigned int u_int;
|
|---|
| 25 | #endif
|
|---|
| 26 |
|
|---|
| 27 | typedef enum {
|
|---|
| 28 | mgt_assocRequest = 0,
|
|---|
| 29 | mgt_assocResponse = 1,
|
|---|
| 30 | mgt_reassocRequest = 2,
|
|---|
| 31 | mgt_reassocResponse = 3,
|
|---|
| 32 | mgt_probeRequest = 4,
|
|---|
| 33 | mgt_probeResponse = 5,
|
|---|
| 34 | mgt_beacon = 8,
|
|---|
| 35 | mgt_disassoc = 10,
|
|---|
| 36 | mgt_auth = 11,
|
|---|
| 37 | mgt_deauth = 12
|
|---|
| 38 | } wifi_frametype;
|
|---|
| 39 |
|
|---|
| 40 | typedef struct ieee802_11_hdr {
|
|---|
| 41 | u_char frame_control;
|
|---|
| 42 | u_char flags;
|
|---|
| 43 | #define IEEE80211_TO_DS 0x01
|
|---|
| 44 | #define IEEE80211_FROM_DS 0x02
|
|---|
| 45 | #define IEEE80211_MORE_FRAG 0x04
|
|---|
| 46 | #define IEEE80211_RETRY 0x08
|
|---|
| 47 | #define IEEE80211_PWR_MGT 0x10
|
|---|
| 48 | #define IEEE80211_MORE_DATA 0x20
|
|---|
| 49 | #define IEEE80211_WEP_FLAG 0x40
|
|---|
| 50 | #define IEEE80211_ORDER_FLAG 0x80
|
|---|
| 51 | u_short duration;
|
|---|
| 52 | u_char addr1[6];
|
|---|
| 53 | u_char addr2[6];
|
|---|
| 54 | u_char addr3[6];
|
|---|
| 55 | u_short frag_and_seq;
|
|---|
| 56 | } ieee802_11_hdr;
|
|---|
| 57 |
|
|---|
| 58 | typedef struct {
|
|---|
| 59 | u_char timestamp[8];
|
|---|
| 60 | u_short bcn_interval;
|
|---|
| 61 | u_short caps;
|
|---|
| 62 | #define MGT_CAPS_AP 0x1
|
|---|
| 63 | #define MGT_CAPS_IBSS 0x2
|
|---|
| 64 | #define MGT_CAPS_WEP 0x10
|
|---|
| 65 | } ieee_802_11_mgt_frame;
|
|---|
| 66 |
|
|---|
| 67 | typedef struct {
|
|---|
| 68 | u_char tag;
|
|---|
| 69 | u_char length;
|
|---|
| 70 | } ieee_802_11_tag;
|
|---|
| 71 |
|
|---|
| 72 | typedef enum {
|
|---|
| 73 | tagSSID = 0,
|
|---|
| 74 | tagRates = 1,
|
|---|
| 75 | tagChannel = 3,
|
|---|
| 76 | tagVendorSpecific = 0xDD
|
|---|
| 77 | } i81tag;
|
|---|
| 78 |
|
|---|
| 79 | typedef struct prism_hdr {
|
|---|
| 80 | u_int msg_code;
|
|---|
| 81 | u_int msg_length;
|
|---|
| 82 | char cap_device[16];
|
|---|
| 83 | //char dids[0];
|
|---|
| 84 | } prism_hdr;
|
|---|
| 85 |
|
|---|
| 86 | typedef struct prism_did {
|
|---|
| 87 | u_short did;
|
|---|
| 88 | u_short status1;
|
|---|
| 89 | u_short status2;
|
|---|
| 90 | u_short length;
|
|---|
| 91 | //int value[0];
|
|---|
| 92 | } prism_did;
|
|---|
| 93 |
|
|---|
| 94 | typedef enum prism_did_num {
|
|---|
| 95 | pdn_host_time = 0x1041,
|
|---|
| 96 | pdn_mac_time = 0x2041,
|
|---|
| 97 | pdn_rssi = 0x4041,
|
|---|
| 98 | pdn_sq = 0x5041,
|
|---|
| 99 | pdn_datarate = 0x8041,
|
|---|
| 100 | pdn_framelen = 0xa041
|
|---|
| 101 | } prism_did_num;
|
|---|
| 102 |
|
|---|
| 103 |
|
|---|
| 104 |
|
|---|
| 105 | //Structure definitions for data collection
|
|---|
| 106 |
|
|---|
| 107 | typedef enum {
|
|---|
| 108 | typeUnknown,
|
|---|
| 109 | typeAP,
|
|---|
| 110 | typeSta,
|
|---|
| 111 | typeAdhocHub
|
|---|
| 112 | } host_type;
|
|---|
| 113 |
|
|---|
| 114 | typedef enum {
|
|---|
| 115 | ssUnknown,
|
|---|
| 116 | ssUnassociated,
|
|---|
| 117 | ssAssociated
|
|---|
| 118 | } sta_state;
|
|---|
| 119 |
|
|---|
| 120 | typedef enum {
|
|---|
| 121 | aetUnknown,
|
|---|
| 122 | aetUnencrypted,
|
|---|
| 123 | aetEncUnknown,
|
|---|
| 124 | aetEncWEP,
|
|---|
| 125 | aetEncWPA
|
|---|
| 126 | } ap_enc_type;
|
|---|
| 127 |
|
|---|
| 128 | typedef struct {
|
|---|
| 129 | u_char bssid[6];
|
|---|
| 130 | char * ssid[32];
|
|---|
| 131 | u_char ssidlen;
|
|---|
| 132 | u_char channel;
|
|---|
| 133 | u_short flags;
|
|---|
| 134 | ap_enc_type encryption;
|
|---|
| 135 | } ap_info;
|
|---|
| 136 |
|
|---|
| 137 | typedef struct {
|
|---|
| 138 | sta_state state;
|
|---|
| 139 | u_char connectedBSSID[6];
|
|---|
| 140 | } sta_info;
|
|---|
| 141 |
|
|---|
| 142 | typedef struct {
|
|---|
| 143 | u_char occupied;
|
|---|
| 144 | u_char mac[6];
|
|---|
| 145 | host_type type;
|
|---|
| 146 | time_t lastSeen;
|
|---|
| 147 | int RSSI;
|
|---|
| 148 | ap_info * apInfo;
|
|---|
| 149 | sta_info * staInfo;
|
|---|
| 150 | } wiviz_host;
|
|---|
| 151 |
|
|---|
| 152 | //Primary config struct
|
|---|
| 153 | typedef struct {
|
|---|
| 154 | wiviz_host hosts[MAX_HOSTS];
|
|---|
| 155 | int numHosts;
|
|---|
| 156 | int readFromWl;
|
|---|
| 157 | time_t lastKeepAlive;
|
|---|
| 158 | int channelHopping;
|
|---|
| 159 | int channelDwellTime;
|
|---|
| 160 | int channelHopSeq[14];
|
|---|
| 161 | int channelHopSeqLen;
|
|---|
| 162 | int curChannel;
|
|---|
| 163 | int channelHopperPID;
|
|---|
| 164 | } wiviz_cfg;
|
|---|
| 165 |
|
|---|
| 166 |
|
|---|
| 167 |
|
|---|
| 168 |
|
|---|
| 169 |
|
|---|