Commit e8b110c2 authored by Saurabh Verma's avatar Saurabh Verma

wfadatad: [WIP] Add remote device scanresult data

parent 493a5f52
......@@ -396,140 +396,80 @@ int delm_get_scanresults(const char *ifname,
return 0;
}
int delm_add_scanresults(struct wifi_scanres_element **remote_scanlist, uint32_t *remote_num_scanresult,
struct wifi_scanres_element **scanlist, uint32_t *num_scanresult)
int delm_add_scanres_neighbors(struct wifi_scanres_neighbor_element *remote_scanres_neighbor,
struct wifi_scanres_neighbor_element *r_scanres_neighbor)
{
struct wifi_scanres_element *out;
struct wifi_scanres_opclass_element *o;
struct wifi_scanres_neighbor_element *nbr /*, *nbrs */;
struct wifi_opclass supp_opclass[32] = {0};
struct wifi_bss *bss, *bsss;
int num_opclass;
int num = 128;
int idx = 0;
//int ret;
int i, j, k;
memcpy(r_scanres_neighbor->bssid, remote_scanres_neighbor->bssid, 6);
strcpy(r_scanres_neighbor->ssid, remote_scanres_neighbor->ssid);
r_scanres_neighbor->rssi = remote_scanres_neighbor->rssi;
r_scanres_neighbor->bw = remote_scanres_neighbor->bw;
r_scanres_neighbor->utilization = remote_scanres_neighbor->utilization;
r_scanres_neighbor->num_stations = remote_scanres_neighbor->num_stations;
return 0;
bsss = calloc(num, sizeof(struct wifi_bss));
if (!bsss)
return -1;
*num_scanresult = 0;
for(i=0; i<*num_scanresult; i++) {
scanlist[i] = NULL;
}
#if 0
ret = wifi_get_scan_results(ifname, bsss, &num);
if (ret) {
free(bsss);
return -1;
}
ret = wifi_get_supp_opclass(ifname, &num_opclass, supp_opclass);
if (ret) {
free(bsss);
return -1;
}
/* prepare output */
nbrs = calloc(num, sizeof(struct wifi_scanres_neighbor_element));
if (!nbrs) {
free(bsss);
return -1;
}
#endif
}
#if 0
out = calloc(1, sizeof(struct wifi_scanres_element));
if (!out) {
free(bsss);
//free(nbrs);
return -1;
}
int delm_add_scanres_channel(struct wifi_scanres_channel_element *remote_scanres_channel,
struct wifi_scanres_channel_element *r_scanres_channel)
{
uint32_t j = 0;
get_timestamp(NULL, out->tsp);
out->num_opclass_scanned = num_opclass;
get_timestamp(NULL, r_scanres_channel->tsp);
r_scanres_channel->channel = remote_scanres_channel->channel;
r_scanres_channel->utilization = remote_scanres_channel->utilization;
r_scanres_channel->anpi = remote_scanres_channel->anpi;
r_scanres_channel->num_neighbors = remote_scanres_channel->num_neighbors;
r_scanres_channel->nbrlist = (struct wifi_scanres_neighbor_element *)calloc(r_scanres_channel->num_neighbors,
sizeof(struct wifi_scanres_neighbor_element));
out->opclass_scanlist = calloc(out->num_opclass_scanned,
sizeof(struct wifi_scanres_opclass_element));
if (!out->opclass_scanlist) {
out->num_opclass_scanned = 0;
free(bsss);
//free(nbrs);
if (!r_scanres_channel->nbrlist)
return -1;
}
/* scanresult neighbors */
for (j = 0; j < r_scanres_channel->num_neighbors; j++)
delm_add_scanres_neighbors(remote_scanres_channel->nbrlist + j, r_scanres_channel->nbrlist + j);
for (i = 0; i < out->num_opclass_scanned; i++) {
o = out->opclass_scanlist + i;
if (supp_opclass[i].bw != BW20) {
/* skip non-20Mhz opclass */
o->opclass = supp_opclass[i].g_opclass;
o->num_channels_scanned = 0;
o->channel_scanlist = NULL;
continue;
}
return 0;
}
o->opclass = supp_opclass[i].g_opclass;
o->num_channels_scanned = supp_opclass[i].opchannel.num;
o->channel_scanlist = calloc(o->num_channels_scanned,
sizeof(struct wifi_scanres_channel_element));
if (!o->channel_scanlist) {
free(bsss);
//free(nbrs);
o->num_channels_scanned = 0;
return -1;
}
int delm_add_scanres_opclass(struct wifi_scanres_opclass_element *remote_scanres_opclass,
struct wifi_scanres_opclass_element *r_scanres_opclass)
{
uint32_t j = 0;
for (k = 0; k < num; k++) {
bss = bsss + k;
r_scanres_opclass->opclass = remote_scanres_opclass->opclass;
r_scanres_opclass->num_channels_scanned = remote_scanres_opclass->num_channels_scanned;
r_scanres_opclass->channel_scanlist = (struct wifi_scanres_channel_element *)calloc(r_scanres_opclass->num_channels_scanned,
sizeof(struct wifi_scanres_channel_element));
for (j = 0; j < o->num_channels_scanned; j++) {
get_timestamp(NULL, o->channel_scanlist[j].tsp);
o->channel_scanlist[j].channel =
supp_opclass[i].opchannel.ch[j];
o->channel_scanlist[j].utilization = 50; //FIXME
o->channel_scanlist[j].anpi = 100; //FIXME
if (!r_scanres_opclass->channel_scanlist)
return -1;
if (bss->channel == supp_opclass[i].opchannel.ch[j]) {
/* add nbr for this channel */
struct wifi_scanres_neighbor_element *new;
/* scanresult channel */
for (j = 0; j < r_scanres_opclass->num_channels_scanned; j++) {
delm_add_scanres_channel(remote_scanres_opclass->channel_scanlist + j, r_scanres_opclass->channel_scanlist + j);
}
new = realloc(o->channel_scanlist[j].nbrlist,
(o->channel_scanlist[j].num_neighbors + 1) * sizeof(*new));
if (!new) {
o->channel_scanlist[j].num_neighbors--;
fprintf(stderr, "realloc scannbr failed!\n");
break;
}
return 0;
}
nbr = new + o->channel_scanlist[j].num_neighbors;
//nbr = &nbrs[idx++];
int delm_add_scanresults(struct wifi_scanres_element *remote_scanlist, struct wifi_scanres_element *r_scanlist)
{
uint32_t j = 0;
idx++;
memcpy(nbr->bssid, bss->bssid, 6);
memcpy(nbr->ssid, bss->ssid, 32);
nbr->rssi = bss->rssi;
nbr->bw = bss->curr_bw;
nbr->utilization = bss->load.utilization;
nbr->num_stations = bss->load.sta_count;
get_timestamp(NULL, r_scanlist->tsp);
r_scanlist->num_opclass_scanned = remote_scanlist->num_opclass_scanned;
r_scanlist->opclass_scanlist = (struct wifi_scanres_opclass_element *)calloc(r_scanlist->num_opclass_scanned,
sizeof(struct wifi_scanres_opclass_element));
o->channel_scanlist[j].num_neighbors++;
o->channel_scanlist[j].nbrlist = new;
if (!r_scanlist->opclass_scanlist)
return -1;
break;
}
}
}
/* scanresult opclass */
for (j = 0; j < r_scanlist->num_opclass_scanned; j++) {
delm_add_scanres_opclass(remote_scanlist->opclass_scanlist + j, r_scanlist->opclass_scanlist +j);
}
*scanlist = out;
*num_scanresult = remote_num_scanresult;
#endif
return 0;
}
......@@ -717,7 +657,15 @@ int delm_add_radio(struct wifi_radio_element *remote_radio,
}
/* scan results */ // TO DO
ret = delm_add_scanresults(&remote_radio->scanlist, &remote_radio->num_scanresult, &r->scanlist, &r->num_scanresult);
r->num_scanresult = remote_radio->num_scanresult;
r->scanlist = (struct wifi_scanres_element *)calloc(r->num_scanresult, sizeof(struct wifi_scanres_element));
if (!r->scanlist)
return -1;
for(j = 0; j < r->num_scanresult; j++)
ret = delm_add_scanresults(remote_radio->scanlist + j, r->scanlist + j);
/* BSS */
r->num_bss = remote_radio->num_bss;
r->bsslist = (struct wifi_bss_element *)calloc(r->num_bss, sizeof(struct wifi_bss_element));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment