Commit 89c80e8a authored by Anjan Chanda's avatar Anjan Chanda

show supported opclass and channels in radio status

parent e990a017
Pipeline #817 passed with stages
in 1 minute and 44 seconds
......@@ -490,9 +490,12 @@ int wl_radio_status(struct ubus_context *ctx, struct ubus_object *obj,
unsigned long maxrate;
int noise;
struct wifi_radio radio;
struct wifi_opclass opclass;
struct wifi_opclass supp_opclass[32] = {0};
int num_opclass;
struct blob_buf bb;
void *c;
int i;
void *c, *d, *dd;
int i, j;
memset(&bb, 0, sizeof(bb));
......@@ -513,6 +516,11 @@ int wl_radio_status(struct ubus_context *ctx, struct ubus_object *obj,
memset(&radio, 0, sizeof(struct wifi_radio));
wifi_radio_info(wldev, &radio);
memset(&opclass, 0, sizeof(struct wifi_opclass));
wifi_get_curr_opclass(wldev, &opclass);
wifi_get_supp_opclass(wldev, &num_opclass, supp_opclass);
blob_buf_init(&bb, 0);
blobmsg_add_string(&bb, "radio", wldev);
blobmsg_add_u8(&bb, "isup", (ifs & IFF_UP) ? true : false);
......@@ -524,6 +532,7 @@ int wl_radio_status(struct ubus_context *ctx, struct ubus_object *obj,
etostr(radio.oper_std, std_buf, WIFI_NUM_STD, standard_str));
blobmsg_add_string(&bb, "standard", std_buf2);
blobmsg_add_u32(&bb, "opclass", opclass.opclass);
blobmsg_add_u32(&bb, "channel", channel);
blobmsg_add_u32(&bb, "bandwidth", bw_int[bw]);
blobmsg_add_string(&bb, "channel_ext", radio.extch == EXTCH_NONE ? "none" :
......@@ -546,9 +555,22 @@ int wl_radio_status(struct ubus_context *ctx, struct ubus_object *obj,
blobmsg_close_array(&bb, c);
c = blobmsg_open_array(&bb, "supp_channels");
#if 0
for (i = 0; i < 32 && radio.supp_channels[i] != 0; i++) {
blobmsg_add_u32(&bb, "", radio.supp_channels[i]);
}
#else
for (i = 0; i < num_opclass; i++) {
d = blobmsg_open_table(&bb, "");
blobmsg_add_u32(&bb, "opclass", supp_opclass[i].g_opclass);
blobmsg_add_u32(&bb, "bandwidth", bw_int[supp_opclass[i].bw]);
dd = blobmsg_open_array(&bb, "channels");
for (j = 0; j < supp_opclass[i].opchannel.num; j++)
blobmsg_add_u32(&bb, "", supp_opclass[i].opchannel.ch[j]);
blobmsg_close_array(&bb, dd);
blobmsg_close_table(&bb, d);
}
#endif
blobmsg_close_array(&bb, c);
if (radio.acs_capable) {
......@@ -1795,15 +1817,19 @@ static int wl_sta_status(struct ubus_context *ctx, struct ubus_object *obj,
{
const char *ifname;
ifstatus_t ifs = 0;
struct wifi_sta sta;
struct blob_buf bb;
memset(&bb, 0, sizeof(bb));
int ret;
ifname = ubus_sta_to_ifname(obj);
wifi_get_ifstatus(ifname, &ifs);
//wifi_sta_info(ifname, &sta);
memset(&sta, 0, sizeof(struct wifi_sta));
ret = wifi_sta_info(ifname, &sta);
if (ret)
return UBUS_STATUS_UNKNOWN_ERROR;
memset(&bb, 0, sizeof(bb));
blob_buf_init(&bb, 0);
blobmsg_add_string(&bb, "ifname", ifname);
blobmsg_add_string(&bb, "status", ifstatus_str(ifs));
......@@ -1819,15 +1845,15 @@ static int wl_sta_stats(struct ubus_context *ctx, struct ubus_object *obj,
struct blob_attr *msg)
{
const char *ifname;
//struct wifi_sta_stats s;
struct wifi_sta_stats s;
struct blob_buf bb;
//int ret;
int ret;
ifname = ubus_sta_to_ifname(obj);
//ret = wifi_sta_get_stats(ifname, &s);
//if (ret != 0)
// return UBUS_STATUS_UNKNOWN_ERROR;
ret = wifi_sta_get_stats(ifname, &s);
if (ret)
return UBUS_STATUS_UNKNOWN_ERROR;
memset(&bb, 0, sizeof(bb));
blob_buf_init(&bb, 0);
......@@ -1848,13 +1874,16 @@ static const struct blobmsg_policy ap_disconnect_policy[__AP_DISCONNECT_MAX] = {
[AP_DISCONNECT_REASON] = { .name = "reason", .type = BLOBMSG_TYPE_INT32}
};
static int ap_disconnect(struct ubus_context *ctx, struct ubus_object *obj,
struct ubus_request_data *req, const char *method,
struct blob_attr *msg)
static int wl_sta_disconnect_ap(struct ubus_context *ctx,
struct ubus_object *obj,
struct ubus_request_data *req,
const char *method,
struct blob_attr *msg)
{
struct blob_attr *tb[__AP_DISCONNECT_MAX];
const char *ifname;
unsigned int reason_code = 0;
const char *ifname;
int ret;
ifname = ubus_sta_to_ifname(obj);
blobmsg_parse(ap_disconnect_policy, __AP_DISCONNECT_MAX, tb,
......@@ -1863,10 +1892,9 @@ static int ap_disconnect(struct ubus_context *ctx, struct ubus_object *obj,
if (tb[AP_DISCONNECT_REASON])
reason_code = blobmsg_get_u32(tb[AP_DISCONNECT_REASON]);
/* TODO
if (wifi_disconnect_ap(ifname, reason_code) != 0) {
ret = wifi_sta_disconnect_ap(ifname, reason_code);
if (ret)
return UBUS_STATUS_UNKNOWN_ERROR;
} */
return UBUS_STATUS_OK;
}
......@@ -2290,10 +2318,11 @@ static int add_sta_methods(struct ubus_object *interface_obj,
UBUS_METHOD_ADD(sta_methods, n_methods,
UBUS_METHOD_NOARG("stats", wl_sta_stats));
//if (libwifi_supports(ifname, "wifi_disconnect_ap")) {
if (libwifi_supports(ifname, "wifi_disconnect_ap")) {
UBUS_METHOD_ADD(sta_methods, n_methods,
UBUS_METHOD("disconnect", ap_disconnect, ap_disconnect_policy));
//}
UBUS_METHOD("disconnect", wl_sta_disconnect_ap,
ap_disconnect_policy));
}
interface_obj->methods = sta_methods;
interface_obj->n_methods = n_methods;
......
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