Commit 493a5f52 authored by Saurabh Verma's avatar Saurabh Verma

wfadatad: [WIP] Add remote device data

parent 85ba2945
......@@ -79,7 +79,6 @@ static int delm_func_1(void *priv)
return 0;
}
//static int delm_func_2(void *priv, void *remote_net)
static int delm_func_2(void *priv)
{
struct delm_private *p = (struct delm_private *)priv;
......@@ -116,6 +115,42 @@ static int delm_func_2(void *priv)
return 0;
}
static int delm_func_3(void *priv, void *remote_dev)
{
sleep(4);
struct delm_private *p = (struct delm_private *)priv;
struct wifi_data_element *dm = p->dm;
struct wifi_network *net = &dm->network;
//struct wifi_network_device *dev = &net->device[0];
//struct wifi_network_device *remote_net = (struct wifi_network_device *)dev;
struct wifi_network_device *remote_net = (struct wifi_network_device *)remote_dev;
if(remote_net == NULL) {
fprintf(stdout, "Nothing to add on dataelement\n");
return 0;
}
int is_set = 0;
while(!is_set) {
pthread_mutex_lock(&p->lock);
if(!p->getter_running) {
is_set = 1;
}
net->num_devices += 1;
p->dm = (struct wifi_data_element *)realloc(p->dm, sizeof(struct wifi_data_element) + (net->num_devices)*(sizeof(struct wifi_network_device)));
if(!p->dm) {
fprintf(stderr, "unable to allocate memory\n"); }
// Add remote device data at index = net->num_devices
// As of now, for testing pass the existing wifi_network_device
dm = p->dm;
net = &dm->network;
delm_add_device(remote_net, &net->device[net->num_devices-1]);
is_set = 1;
pthread_mutex_unlock(&p->lock);
}
return 0;
}
void refresh_timer_cb(atimer_t *t)
{
struct delm_private *p = container_of(t, struct delm_private, t);
......@@ -190,4 +225,5 @@ struct plugin wfa_delm = {
[PLUGIN_FUNC_1] = delm_func_1,
[PLUGIN_FUNC_2] = delm_func_2,
},
.ops1 = delm_func_3,
};
......@@ -219,6 +219,16 @@ int delm_dump_unassoc_sta(struct wifi_unassoc_sta_element *usta,
return 0;
}
int delm_dump_backhaul_sta(struct wifi_backhaul_element *bksta,
struct blob_buf *bb)
{
char macaddr[17] = {0};
hwaddr_ntoa(bksta->macaddr, macaddr);
blobmsg_add_string(bb, "MACAddress", macaddr);
return 0;
}
int delm_dump_curr_opclass(struct wifi_opclass_current_element *curr,
struct blob_buf *bb)
{
......@@ -272,7 +282,7 @@ int delm_dump_radio(struct wifi_radio_element *radio, struct blob_buf *bb)
blobmsg_add_u32(bb, "Utilization", radio->total_utilization);
blobmsg_add_u32(bb, "Transmit", radio->tx_utilization);
blobmsg_add_u32(bb, "ReceiveSelf", radio->rx_utilization);
blobmsg_add_u8(bb, "RecieveOther", radio->other_utilization);
blobmsg_add_u32(bb, "RecieveOther", radio->other_utilization);
/* bss */
arr = blobmsg_open_array(bb, "BSSList");
......@@ -324,6 +334,11 @@ int delm_dump_radio(struct wifi_radio_element *radio, struct blob_buf *bb)
}
blobmsg_close_array(bb, arr);
/* backhaul sta */
t = blobmsg_open_table(bb, "BackhaulSta");
delm_dump_backhaul_sta(&radio->bksta, bb);
blobmsg_close_table(bb, t);
return 0;
}
......
......@@ -96,9 +96,36 @@ int delm_get_sta_all(const char *ifname, struct wifi_sta_element **stalist,
return 0;
}
int delm_add_sta_all(struct wifi_sta_element **remote_sta, uint32_t remote_num_stas,
struct wifi_sta_element **stalist, uint32_t *num_stas)
int delm_add_sta_all(struct wifi_sta_element *remote_sta, struct wifi_sta_element *sta)
{
fprintf(stderr, "|%s:%d|\n", __func__, __LINE__);
get_timestamp(NULL, sta->tsp);
memcpy(sta->macaddr, remote_sta->macaddr, 6);
/* ToDO: STA caps ??
struct wifi_caps_element caps;*/
sta->dl_rate = remote_sta->dl_rate;
sta->ul_rate = remote_sta->ul_rate;
sta->ul_utilization = remote_sta->ul_utilization;
sta->dl_utilization = remote_sta->dl_utilization;
sta->dl_est_thput = remote_sta->dl_est_thput;
sta->ul_est_thput = remote_sta->ul_est_thput;
sta->rssi = remote_sta->rssi;
sta->conn_time = remote_sta->conn_time;
sta->tx_bytes = remote_sta->tx_bytes;
sta->rx_bytes = remote_sta->rx_bytes;
sta->tx_pkts = remote_sta->tx_pkts;
sta->rx_pkts = remote_sta->rx_pkts;
sta->tx_errors = remote_sta->tx_errors;
sta->rx_errors = remote_sta->rx_errors;
sta->rtx_pkts = remote_sta->rtx_pkts;
/*
ipaddr_t ipaddr;
char hostname[128];*/
sta->num_bcn_reports = 0;
sta->bcn_reportlist = NULL;
#if 0
struct wifi_sta_element *out;
uint8_t stas[768] = {0};
......@@ -156,10 +183,6 @@ int delm_add_sta_all(struct wifi_sta_element **remote_sta, uint32_t remote_num_s
}
#endif
*num_stas = 0;
*stalist = NULL;
return 0;
}
......@@ -206,9 +229,9 @@ int delm_get_bss(const char *ifname, struct wifi_bss_element *b)
int delm_add_bss(struct wifi_bss_element *remote_bss, struct wifi_bss_element *b)
{
int ret;
//wl_dump_capabilities(&bb, &bss->caps, bss->cbitmap);
int i = 0;
if(remote_bss) {
if (remote_bss) {
memcpy(b->bssid, remote_bss->bssid, 6);
memcpy(b->ssid, remote_bss->ssid, 32);
//b->num_stations = ap.bss.load.sta_count;
......@@ -221,8 +244,22 @@ int delm_add_bss(struct wifi_bss_element *remote_bss, struct wifi_bss_element *b
b->rx_mcast_bytes = remote_bss->rx_mcast_bytes;
b->tx_bcast_bytes = remote_bss->tx_bcast_bytes;
b->rx_bcast_bytes = remote_bss->rx_bcast_bytes;
b->est_wmm_be = remote_bss->est_wmm_be;
b->est_wmm_bk = remote_bss->est_wmm_bk;
b->est_wmm_vi = remote_bss->est_wmm_vi;
b->est_wmm_vo = remote_bss->est_wmm_vo;
/* STA*/
b->num_stations = remote_bss->num_stations;
b->stalist = (struct wifi_sta_element *)calloc(b->num_stations, sizeof(struct wifi_sta_element));
if (b->stalist) {
for (i = 0; i < b->num_stations; i++) {
delm_add_sta_all(remote_bss->stalist + i, b->stalist + i);
}
}
ret = delm_add_sta_all(&remote_bss->stalist, remote_bss->num_stations, &b->stalist, &b->num_stations);
//ret = delm_add_sta_all(&remote_bss->stalist, remote_bss->num_stations, &b->stalist, &b->num_stations);
}
return ret;
}
......@@ -373,6 +410,7 @@ int delm_add_scanresults(struct wifi_scanres_element **remote_scanlist, uint32_t
//int ret;
int i, j, k;
return 0;
bsss = calloc(num, sizeof(struct wifi_bss));
if (!bsss)
return -1;
......@@ -501,11 +539,16 @@ int delm_get_bksta(const char *ifname, struct wifi_backhaul_element *bksta)
return 0;
}
int delm_add_unassoc_sta(struct wifi_unassoc_sta_element *remote_unassoc_sta, struct wifi_unassoc_sta_element *unassoc_sta)
{
memcpy(unassoc_sta->macaddr, remote_unassoc_sta->macaddr, 6);
unassoc_sta->rssi = remote_unassoc_sta->rssi;
return 0;
}
int delm_add_bksta(struct wifi_backhaul_element *remote_bksta, struct wifi_backhaul_element *bksta)
{
if(remote_bksta->macaddr) {
memcpy(bksta->macaddr, remote_bksta->macaddr, 6);
}
memcpy(bksta->macaddr, remote_bksta->macaddr, 6);
return 0;
}
......@@ -634,11 +677,15 @@ int delm_add_radio(struct wifi_radio_element *remote_radio,
if(!remote_radio || !r) {
return -1;
}
memcpy(r->macaddr, remote_radio->macaddr, 6);
r->enabled = remote_radio->enabled;
r->anpi = remote_radio->anpi;
r->tx_utilization = remote_radio->tx_utilization;
r->rx_utilization = remote_radio->rx_utilization;
r->other_utilization = remote_radio->other_utilization;
//TODO: utilization, num_bss
//memcpy(r->macaddr, radio.macaddr, 6); //TODO
/* current opclass */
r->num_curr_opclass = remote_radio->num_curr_opclass;
......@@ -672,7 +719,7 @@ 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_bss = remote_radio->num_bss;
r->bsslist = calloc(r->num_bss, sizeof(struct wifi_bss_element));
r->bsslist = (struct wifi_bss_element *)calloc(r->num_bss, sizeof(struct wifi_bss_element));
if (!r->bsslist)
return -1;
......@@ -681,14 +728,17 @@ int delm_add_radio(struct wifi_radio_element *remote_radio,
ret = delm_add_bss(remote_radio->bsslist + j, r->bsslist + j);
}
/* backhaul sta(s) */
#if 0 /* Only one 'bksta' is supported in the WiFi Data Elements Std. */
for (j = 0; j < num_bk_iface; j++) {
ret = delm_get_bksta(bk_iface[j], r->bkstalist + j);
/* unassociated STA */
r->num_unassoc_sta = remote_radio->num_unassoc_sta;
r->unassoc_stalist = (struct wifi_unassoc_sta_element *)calloc(r->num_unassoc_sta, sizeof(struct wifi_unassoc_sta_element));
if (r->unassoc_stalist) {
for (j = 0; j < r->num_unassoc_sta; j++) {
ret = delm_add_unassoc_sta(remote_radio->unassoc_stalist + j, r->unassoc_stalist + j);
}
}
#else
/* bakchaul STA */
ret = delm_add_bksta(&remote_radio->bksta, &r->bksta);
#endif
return 0;
}
......@@ -726,6 +776,9 @@ int delm_add_device(struct wifi_network_device *remote_dev, struct wifi_network_
if (!remote_dev || !dev)
return -1;
memcpy(dev->macaddr, remote_dev->macaddr, 6);
dev->collect_int = remote_dev->collect_int;
dev->num_radios = remote_dev->num_radios;
dev->radiolist = calloc(dev->num_radios,
......@@ -734,7 +787,6 @@ int delm_add_device(struct wifi_network_device *remote_dev, struct wifi_network_
return -1;
for (i = 0; i < dev->num_radios; i++) {
//ret = delm_get_radio(ifs, ifs[i].radio, dev->radiolist + i);
ret = delm_add_radio(remote_dev->radiolist + i, dev->radiolist + i);
}
......
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