Commit 0666fe04 authored by Anjan Chanda's avatar Anjan Chanda

adjust to uppercase enums and defines

parent 2d454ebe
Pipeline #426 passed with stage
in 23 seconds
......@@ -44,6 +44,19 @@
#define ARRAY_SIZE(_a) sizeof(_a)/sizeof(_a[0])
#endif
/* if IF_OPER_* not defined */
#ifndef IF_OPER_UNKNOWN
enum {
IF_OPER_UNKNOWN,
IF_OPER_NOTPRESENT,
IF_OPER_DOWN,
IF_OPER_LOWERLAYERDOWN,
IF_OPER_TESTING,
IF_OPER_DORMANT,
IF_OPER_UP,
};
#endif /* IF_OPER_UNKNOWN */
const char *standard_str[] = {
"b",
"g",
......@@ -146,10 +159,10 @@ static char *wifi_security_str(uint32_t a, uint32_t c, uint32_t gc, char *out)
uint32_t cip;
int ver;
ver = a & (wpaver2 | wpaver1);
if (ver == (wpaver1 | wpaver2)) {
ver = a & (WPA_VERSION2 | WPA_VERSION1);
if (ver == (WPA_VERSION1 | WPA_VERSION2)) {
v = "-mixed";
} else if (ver == wpaver2) {
} else if (ver == WPA_VERSION2) {
v = "2";
} else {
v = "";
......@@ -505,8 +518,8 @@ static int wl_radio_status(struct ubus_context *ctx, struct ubus_object *obj,
band = 1; // 5GHz
wifi_get_bandwidth(wldev, &bw);
if (bw < bw20 || bw > bw160) { // FIXME: in libwifi
bw = bw8080 + 1; // Unknown
if (bw < BW20 || bw > BW160) { // FIXME: in libwifi
bw = BW8080 + 1; // Unknown
}
wifi_get_maxrate(wldev, &maxrate);
wifi_get_noise(wldev, &noise);
......@@ -520,13 +533,13 @@ static int wl_radio_status(struct ubus_context *ctx, struct ubus_object *obj,
blobmsg_add_u32(&bb, "band", (band == 1) ? 5 : 2);
sprintf(std_buf2 + strlen(std_buf2), "%s",
etostr(radio.oper_std, std_buf, MODE_MAX, standard_str));
etostr(radio.oper_std, std_buf, WIFI_NUM_STD, standard_str));
blobmsg_add_string(&bb, "standard", std_buf2);
blobmsg_add_u32(&bb, "channel", channel);
blobmsg_add_u32(&bb, "bandwidth", bw_int[bw]);
blobmsg_add_string(&bb, "channel_ext", radio.extch == ext_auto ? "none" :
radio.extch == ext_above ? "above" :
blobmsg_add_string(&bb, "channel_ext", radio.extch == EXTCH_NONE ? "none" :
radio.extch == EXTCH_ABOVE ? "above" :
"below");
blobmsg_add_u32(&bb, "tx_streams", radio.tx_streams);
blobmsg_add_u32(&bb, "rx_streams", radio.rx_streams);
......@@ -565,8 +578,8 @@ static int wl_radio_status(struct ubus_context *ctx, struct ubus_object *obj,
blobmsg_add_u32(&bb, "dtim_period", radio.dtim_period);
blobmsg_add_string(&bb, "preamble",
radio.pr == short_preamble ? "short" :
radio.pr == long_preamble ? "long" : "auto");
radio.pr == SHORT_PREAMBLE ? "short" :
radio.pr == LONG_PREAMBLE ? "long" : "auto");
blobmsg_add_u32(&bb, "short_retry_limit", radio.srl);
blobmsg_add_u32(&bb, "long_retry_limit", radio.lrl);
......@@ -663,7 +676,7 @@ static int wl_ap_status(struct ubus_context *ctx, struct ubus_object *obj,
char syspath[32];
const char *ifname;
ifstatus_t ifs = 0;
enum oper_state opstatus;
ifopstatus_t opstatus;
char bssid[6] = {0};
char bssid_str[24] = {0};
char ssid[64] = {0};
......@@ -687,14 +700,14 @@ static int wl_ap_status(struct ubus_context *ctx, struct ubus_object *obj,
wifi_get_ifstatus(ifname, &ifs);
wifi_get_ifoperstatus(ifname, &opstatus);
if (opstatus > oper_Error) {
opstatus = oper_Error;
if (opstatus > IF_OPER_UP) {
opstatus = IF_OPER_UNKNOWN;
}
wifi_get_channel(ifname, &channel, &bw);
wifi_get_bandwidth(ifname, &bw);
if (bw < bw20 || bw > bw160) { // FIXME: in libwifi
bw = bw8080 + 1; // Unknown
if (bw < BW20 || bw > BW160) { // FIXME: in libwifi
bw = BW8080 + 1; // Unknown
}
wifi_ap_info(ifname, &ap);
......@@ -728,7 +741,7 @@ static int wl_ap_status(struct ubus_context *ctx, struct ubus_object *obj,
blobmsg_add_u32(&bb, "bandwidth", bw_int[bw]);
//blobmsg_add_u64(&bb, "rate", rate);
sprintf(std_buf2 + strlen(std_buf2), "%s",
etostr(ap.bss.oper_std, std_buf, MODE_MAX, standard_str));
etostr(ap.bss.oper_std, std_buf, WIFI_NUM_STD, standard_str));
blobmsg_add_string(&bb, "standard", std_buf2);
blobmsg_add_u32(&bb, "num_stations", ap.bss.load.sta_count);
blobmsg_add_u32(&bb, "utilization", ap.bss.load.utilization);
......@@ -1219,7 +1232,7 @@ static int wl_radios(struct ubus_context *ctx, struct ubus_object *obj,
#if 0
sprintf(mode_buf2 + strlen(mode_buf2), "%s",
etostr2(phymode, mode_buf, MODE_MAX, mode_str, ","));
etostr2(phymode, mode_buf, WIFI_NUM_STD, mode_str, ","));
blobmsg_add_string(&bb, "opmode", mode_buf2);
#endif
......@@ -1358,12 +1371,12 @@ static void wl_scanresult_print(struct blob_buf *bb, void *buf, bool detail)
wifi_security_str(b->sec, b->enc, b->g_enc, sec_str);
blobmsg_add_string(bb, "encryption", sec_str);
blobmsg_add_string(bb, "band",
b->band == Band_5 ? "5GHz" :
b->band == Band_2 ? "2.4GHz" : "unknown");
b->band == BAND_5 ? "5GHz" :
b->band == BAND_2 ? "2.4GHz" : "unknown");
blobmsg_add_u32(bb, "rssi", b->rssi);
//blobmsg_add_u32(bb, "snr", b->snr);
sprintf(std_buf2 + strlen(std_buf2), "%s",
etostr(b->oper_std, std_buf, MODE_MAX, standard_str));
etostr(b->oper_std, std_buf, WIFI_NUM_STD, standard_str));
blobmsg_add_string(bb, "standard", std_buf2);
blobmsg_add_u32(bb, "load_stas", b->load.sta_count);
blobmsg_add_u32(bb, "load_utilization", b->load.utilization);
......@@ -2441,7 +2454,7 @@ static int wl_status(struct ubus_context *ctx, struct ubus_object *obj,
uint32_t channel;
int channels[32] = {0};
ifstatus_t ifstat = 0;
enum wifi_band band = Band_2;
enum wifi_band band = BAND_2;
unsigned long rate;
int noise;
enum wifi_bw bw;
......@@ -2458,11 +2471,11 @@ static int wl_status(struct ubus_context *ctx, struct ubus_object *obj,
wifi_get_ifstatus(radios[i], &ifstat);
wifi_get_channel(radios[i], &channel, &bw);
if (channel && channel >= 36 && channel < 200)
band = Band_5;
band = BAND_5;
wifi_get_bandwidth(radios[i], &bw);
if (bw < bw20 || bw > bw160) { // FIXME: in libwifi
bw = bw_Unknown;
if (bw < BW20 || bw > BW160) { // FIXME: in libwifi
bw = BW_UNKNOWN;
}
if (!wifi_get_country(radios[i], alpha2))
......@@ -2506,7 +2519,7 @@ static int wl_status(struct ubus_context *ctx, struct ubus_object *obj,
char bssid[6] = {0};
char bssidstr[18] = {0};
char ssid[64] = {0};
//enum oper_state opstatus;
//ifopstatus_t opstatus;
uint32_t auth;
uint32_t enc;
struct wifi_caps apcaps;
......@@ -2546,7 +2559,7 @@ static int wl_status(struct ubus_context *ctx, struct ubus_object *obj,
tt = blobmsg_open_array(&bb, "backhauls");
for (j = 0; j < num_ifs; j++) {
char *ifname = ifs[j].iface;
//enum oper_state opstatus;
//ifopstatus_t opstatus;
if (ifs[j].device[0] &&
!strncmp(ifs[j].device, radios[i], 16) &&
......
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