#include "Localization.h"
Localization::Localization()
{
for(int i=0;i<ARRAY_SZ;i++)
t[i]=0;
x=0;
y=0;
nbp=0;
loc_p=false;
}
Localization::Localization(const Localization& o)
{
x = o.x;
y = o.y;
nbp = o.nbp;
loc_p = o.loc_p;
for(int i=0;i<ARRAY_SZ;i++)
t[i]=o.t[i];
}
Localization::~Localization()
{
}
void Localization::data_calc()
{
//TODO
x++;
y++;
}
void Localization::setPoint(double a, double b, double c)
{
if(nbp<5) //max number of points to locate an access point is set to 5
{
int i=nbp*3; //put the index at the array's first empty element
t[i]=a ; //coord x
t[i+1]=b ; //coord y
t[i+2]=c ; //power
nbp++; //increase the number of points
loc_p=true; //at least one point is entered
if(nbp>2) //if we have at least 3 measure points, we can make the calculation
data_calc();
}
}
//getters
double Localization::getCoordX()
{
return x;
}
double Localization::getCoordY()
{
return y;
}
bool Localization::verif( wireless_network *net )
{
int netnum = 1 ;
FILE *netfile;
if ((netfile = fopen("test.kis", "w+" )) == NULL) {
fprintf(stderr, "Could not open %s for writing" );
return false;
}
char type[15];
if (net->type == network_ap)
snprintf(type, 15, "infrastructure" );
else if (net->type == network_adhoc)
snprintf(type, 15, "ad-hoc" );
else if (net->type == network_probe)
snprintf(type, 15, "probe" );
else if (net->type == network_data)
snprintf(type, 15, "data" );
else if (net->type == network_turbocell)
snprintf(type, 15, "turbocell" );
else
snprintf(type, 15, "unknown" );
char carrier[15];
if (net->carrier_set & (1 << (int) carrier_80211b))
snprintf(carrier, 15, "802.11b" );
else if (net->carrier_set & (1 << (int) carrier_80211bplus))
snprintf(carrier, 15, "802.11b+" );
else if (net->carrier_set & (1 << (int) carrier_80211a))
snprintf(carrier, 15, "802.11a" );
else if (net->carrier_set & (1 << (int) carrier_80211g))
snprintf(carrier, 15, "802.11g" );
else if (net->carrier_set & (1 << (int) carrier_80211fhss))
snprintf(carrier, 15, "802.11 FHSS" );
else if (net->carrier_set & (1 << (int) carrier_80211dsss))
snprintf(carrier, 15, "802.11 DSSS" );
else
snprintf(carrier, 15, "unknown" );
string crypt;
if (net->crypt_set == 0)
crypt = "None";
if (net->crypt_set & crypt_wep)
crypt += "WEP ";
if (net->crypt_set & crypt_wpa)
crypt += "WPA ";
if (net->crypt_set & crypt_layer3)
crypt += "Layer3 ";
if (net->crypt_set & crypt_leap)
crypt += "LEAP ";
if (net->crypt_set & crypt_ttls)
crypt += "TTLS ";
if (net->crypt_set & crypt_tls)
crypt += "TLS ";
if (net->crypt_set & crypt_peap)
crypt += "PEAP ";
if (net->crypt_set & crypt_isakmp)
crypt += "ISAKMP ";
if (net->crypt_set & crypt_pptp)
crypt += "PPTP ";
if (crypt.length() == 0)
crypt = "Unknown";
fprintf(netfile, "Network %d: \"%s\" BSSID: \"%s\"\n"
" Type : %s\n"
" Carrier : %s\n"
" Info : \"%s\"\n"
" Channel : %02d\n"
" Encryption : \"%s\"\n"
" Maxrate : %2.1f\n",
netnum,
net->ssid.c_str(), net->bssid.Mac2String().c_str(), type, carrier,
net->beacon_info == "" ? "None" : net->beacon_info.c_str(),
net->channel, crypt.c_str(),
net->maxrate);
return true ;
} |