diff --git a/src/agent.c b/src/agent.c index cf58c182ff82106890f868b94f8179a038788f66..8d834718529c575e0b96a82d530bd2804ab633da 100644 --- a/src/agent.c +++ b/src/agent.c @@ -1653,40 +1653,56 @@ static void wifi_chan_change_event_handler(void *c, struct blob_attr *msg) chan_change = !strcmp(event, "ap-chan-change"); if (chan_change) { - struct blob_attr *data[2]; - static const struct blobmsg_policy data_attr[2] = { + struct blob_attr *data[3]; + static const struct blobmsg_policy data_attr[3] = { [0] = { .name = "target-channel", .type = BLOBMSG_TYPE_STRING }, [1] = { .name = "target-width", .type = BLOBMSG_TYPE_STRING }, + [2] = { .name = "reason", .type = BLOBMSG_TYPE_STRING }, }; char chan[18] = {0}; char bw[18] = {0}; + char reason[30] = {0}; uint32_t channel = 0; uint32_t bandwidth = 0; - blobmsg_parse(data_attr, 2, data, blobmsg_data(tb[2]), + int ret = 0; + + blobmsg_parse(data_attr, 3, data, blobmsg_data(tb[2]), blobmsg_data_len(tb[2])); - if (!data[0] || !data[1]) + if (!data[0] || !data[1] || !data[2]) return; strncpy(chan, blobmsg_data(data[0]), sizeof(chan) - 1); strncpy(bw, blobmsg_data(data[1]), sizeof(bw) - 1); + strncpy(reason, blobmsg_data(data[2]), sizeof(reason) - 1); + + ret = strcmp(reason, "move-success"); + + if (ret != 0) + return; channel = atoi(chan); bandwidth = atoi(bw); - trace("|%s:%d| Channel has changed to channel [%d] bandwidth [%d]\n", - __func__, __LINE__, channel, bandwidth); + trace("|%s:%d| Channel has changed to channel [%d] bandwidth [%d] reason [%s]\n", + __func__, __LINE__, channel, bandwidth, reason); trace("|%s:%d| Channel has changed ifname [%s]\n", __func__, __LINE__, ifname); - /*Here we need to send the operating channel report message*/ + + /*Here we need to send the operating channel report message* + *also set the current operating channel to the new channel*/ radio = wifi_ifname_to_radio_element(a, ifname); + radio->current_channel = channel; + uint32_t op_class = get_op_class_frm_channel(channel, bw); + if (op_class == 0) + return ; + radio->current_opclass = (uint8_t) op_class; cmdu = agent_gen_oper_channel_response(a, radio, channel, bandwidth, 0); if (!cmdu) - return -1; + return; agent_send_cmdu(a, cmdu); cmdu_free(cmdu); } - //TODONEV write the new operating channel in the radio current operating channel } static void wifi_sta_event_handler(void *c, struct blob_attr *msg) diff --git a/src/agent_map.c b/src/agent_map.c index 791f9a070b466a51b77304dd588d27dd09857db6..727d4cdf0782513f6ed483fdf7a3faf5dca4f26f 100644 --- a/src/agent_map.c +++ b/src/agent_map.c @@ -1868,7 +1868,7 @@ int agent_fill_radio_max_preference(void *agent, for (l = 0; l < radio->supp_opclass[k]. num_supported_channels; l++) radio->supp_opclass[k].supp_chanlist[l].pref = - 0xff; + 0x0f; } channel_resp[j].response = 0x00; } @@ -1975,6 +1975,48 @@ int agent_get_highest_preference(struct agent *a, uint8_t *radio_id, int op_clas trace("channel to which channel needs to switch %d\n",*channel ); } +static int agent_is_radio_backhaul(struct agent *a, uint8_t *radio_id, struct netif_fh *p) + +{ +// struct netif_fh *p = NULL; + const char *radio_name = NULL; + int found = 0; + int ret = 0; + + trace("%s: --->\n", __func__); + + list_for_each_entry(p, &a->fhlist, list) { + struct wifi_radio_element *radio = NULL; + + trace("radio name %s\n", p->name); + radio_name = wifi_ifname_to_radio(a, p->name); + if (!radio_name) + continue; + trace("radio name 2%s\n", radio_name); + radio = wifi_ifname_to_radio_element(a, p->name); + trace("radio name 3 mac is "MACFMT"\n", MAC2STR(radio->macaddr)); + ret = memcmp(radio_id, &radio->macaddr, 6); + trace ("after point 1 %d\n",ret); + if(ret == 0) { + trace("I am here %p \n", p->cfg); + trace("radio name 51 multi_ap flag is %d\n", p->cfg->multi_ap); + // if (p->cfg->multi_ap != 2) + // continue; + // else { + found = 1; + break; + // } + } + } + + if (found == 1) + ret = 0; + else + ret = -1; + + return ret; +} + int agent_channel_switch(struct agent *a, uint8_t *radio_id, int channel, int opclass) { trace("%s: --->\n", __func__); @@ -1983,10 +2025,11 @@ int agent_channel_switch(struct agent *a, uint8_t *radio_id, int channel, int op int freq = 0; int bandwidth = 0; struct netif_fh *p = NULL; - int found = 0; +// int found = 0; const char *radio_name = NULL; trace("channel switch channel %d radio is "MACFMT" \n", channel, MAC2STR(radio_id)); +#if 0 list_for_each_entry(p, &a->fhlist, list) { struct wifi_radio_element *radio = NULL; @@ -2003,7 +2046,7 @@ int agent_channel_switch(struct agent *a, uint8_t *radio_id, int channel, int op if(ret == 0) { trace("I am here %p \n", p->cfg); //trace("radio name 5 multi_ap flag is %d\n", p->cfg->band); - // trace("radio name 51 multi_ap flag is %d\n", p->cfg->multi_ap); + trace("radio name 51 multi_ap flag is %d\n", p->cfg->multi_ap); // if (p->cfg->multi_ap != 2) // continue; // else { @@ -2012,8 +2055,9 @@ int agent_channel_switch(struct agent *a, uint8_t *radio_id, int channel, int op // } } } - - if (found == 0) +#endif + ret = agent_is_radio_backhaul(a, radio_id, p); + if (ret != 0) return -1; freq = c2f(channel); @@ -2116,6 +2160,16 @@ int agent_process_channel_pref_tlv(void *agent, struct tlv_channel_pref *p, radio = a->radios + l; match = memcmp(radio->macaddr, radio_id, 6); if (match == 0) { + struct netif_fh *p = NULL; + ret = agent_is_radio_backhaul(a, radio_id, p); + if (ret != 0) { + err("radio is a backhaul radio\n"); + memcpy(channel_resp[*channel_resp_nr].radio_id, + radio->macaddr, 6); + channel_resp[*channel_resp_nr].response = 0x03; + *channel_resp_nr = *channel_resp_nr +1; + return 0; + } found = 1; memcpy(channel_resp[*channel_resp_nr].radio_id, radio->macaddr, 6); diff --git a/src/agent_tlv.h b/src/agent_tlv.h index 92be44d7e2c989db42c162714b91de2db38097ea..5f4b0d7918be3cf34ec7cc0e10b82f737822a1a2 100644 --- a/src/agent_tlv.h +++ b/src/agent_tlv.h @@ -27,6 +27,7 @@ struct tlv_vendor_metric_specific { int get_radio_index(struct agent *a, uint8_t *mac); int get_bss_index(struct wifi_radio_element *radio, uint8_t *bssid); int get_radio_and_bss_index(struct agent *a, uint8_t *bssid, int *radio_index); +int get_op_class_frm_channel(uint32_t channel, uint32_t bandwidth); uint8_t rssi_to_rcpi(int rssi); struct netif_fh *wifi_get_netif_by_bssid(struct agent *a, uint8_t *bssid); int agent_gen_ap_ht_caps(struct agent *a,