Commit 8f9627ee authored by Anjan Chanda's avatar Anjan Chanda

pass output buffer to scanresults and nbrlist apis

parent 748b1626
Pipeline #472 passed with stage
in 22 seconds
......@@ -197,7 +197,7 @@ static char *etostr(uint32_t e, char *out, int elen, const char **arr)
return out;
}
static char * etostr2(uint32_t e, char *out, int elen, const char **arr, char *sep)
static char *etostr2(uint32_t e, char *out, int elen, const char **arr, char *sep)
{
char *c = "";
int i;
......@@ -1097,7 +1097,7 @@ static int wl_scanresults(struct ubus_context *ctx, struct ubus_object *obj,
return UBUS_STATUS_UNKNOWN_ERROR;
}
bsss = (struct wifi_bss *)data;
if (wifi_get_scan_results(device, &bsss, &num) != 0) {
if (wifi_get_scan_results(device, bsss, &num) != 0) {
free(data);
return UBUS_STATUS_UNKNOWN_ERROR;
}
......@@ -1445,22 +1445,22 @@ static int nbr_del(struct ubus_context *ctx, struct ubus_object *obj,
static int _nbr_list(struct blob_buf *bb, const char *ifname, bool wildcard)
{
char bssid_str[18] = {0};
struct nbr *nbr;
int nr = 16;
int nr = 32;
void *a, *t;
char bssid_str[18] = {0};
int ret;
int i;
char *data;
data = calloc(nr, sizeof(struct nbr));
if (!data) {
nbr = calloc(nr, sizeof(struct nbr));
if (!nbr) {
fprintf(stderr, "OOM get_neighbor_list()\n");
return UBUS_STATUS_UNKNOWN_ERROR;
}
nbr = (struct nbr *)data;
if (wifi_get_neighbor_list(ifname, &nbr, &nr) < 0)
return -1;
ret = wifi_get_neighbor_list(ifname, nbr, &nr);
if (ret)
goto out_exit;
if (!wildcard)
a = blobmsg_open_array(bb, "neighbors");
......@@ -1484,22 +1484,30 @@ static int _nbr_list(struct blob_buf *bb, const char *ifname, bool wildcard)
if (!wildcard)
blobmsg_close_array(bb, a);
if (nr && nbr)
free(nbr);
return 0;
out_exit:
free(nbr);
return ret;
}
static int _sta_nbr_list(struct blob_buf *bb, const char *ifname, unsigned char *sta)
static int _sta_nbr_list(struct blob_buf *bb, const char *ifname,
unsigned char *sta)
{
struct sta_nbr *snbr;
int nr;
int nr = 32;
void *a, *t;
char bssid_str[18] = {0};
int ret;
int i;
if (wifi_get_beacon_report(ifname, sta, &snbr, &nr) < 0)
return -1;
snbr = calloc(nr, sizeof(struct sta_nbr));
if (!snbr) {
fprintf(stderr, "OOM get_neighbor_list()\n");
return UBUS_STATUS_UNKNOWN_ERROR;
}
ret = wifi_get_beacon_report(ifname, sta, snbr, &nr);
if (ret)
goto out_exit;
a = blobmsg_open_array(bb, "neighbors");
for (i = 0; i < nr; i++) {
......@@ -1507,7 +1515,6 @@ static int _sta_nbr_list(struct blob_buf *bb, const char *ifname, unsigned char
e = snbr + i;
t = blobmsg_open_table(bb, "");
//fprintf(stderr, "[%d] Ch = %d Phy = %d\n", i, e->channel, e->phy);
sprintf(bssid_str, "%02X:%02X:%02X:%02X:%02X:%02X",
e->bssid[0], e->bssid[1], e->bssid[2],
e->bssid[3], e->bssid[4], e->bssid[5]);
......@@ -1518,10 +1525,9 @@ static int _sta_nbr_list(struct blob_buf *bb, const char *ifname, unsigned char
}
blobmsg_close_array(bb, a);
if (nr && snbr)
free(snbr);
return 0;
out_exit:
free(snbr);
return ret;
}
static int nbr_list(struct ubus_context *ctx, struct ubus_object *obj,
......
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