diff --git a/src/al_entity.c b/src/al_entity.c index 1e127e6b89627dd0ed7f6bba1e652020ed441a7e..4625b4b98318da1b87764a9d52490f45ba86aebf 100644 --- a/src/al_entity.c +++ b/src/al_entity.c @@ -93,7 +93,7 @@ static void dump_cmdu_fragments(void) __attribute__((unused)); static bool gs_ap_search_needed = true; -static int8_t gs_trigger_wsc_renew = -1; +static uint8_t gs_trigger_wsc_renew = 0; struct cmdu_fragment { @@ -738,10 +738,7 @@ static bool registrar_init(bool enabled) uci_set_wireless_interface_option(UCI_IEEE1905, interfaces_names[i], "ssid", ssid); uci_set_wireless_interface_option(UCI_IEEE1905, interfaces_names[i], "key", key); uci_set_wireless_interface_option(UCI_IEEE1905, interfaces_names[i], "encryption", enc); - if (gs_trigger_wsc_renew == -1) - gs_trigger_wsc_renew = intf_ap_band; - else - gs_trigger_wsc_renew |= intf_ap_band; + MODIFY_BIT(intf_ap_band, gs_trigger_wsc_renew, 1); } else { ret = uci_get_wireless_interface_option(UCI_IEEE1905, interfaces_names[i], "ssid", ssid2, sizeof(ssid)); @@ -758,10 +755,7 @@ static bool registrar_init(bool enabled) strcmp(enc, enc2) == 0) { INFO("WSC renew is not required"); } else { - if (gs_trigger_wsc_renew == -1) - gs_trigger_wsc_renew = intf_ap_band; - else - gs_trigger_wsc_renew |= intf_ap_band; + MODIFY_BIT(intf_ap_band, gs_trigger_wsc_renew, 1); uci_set_wireless_interface_option(UCI_IEEE1905, interfaces_names[i], "ssid", ssid); uci_set_wireless_interface_option(UCI_IEEE1905, interfaces_names[i], "key", key); uci_set_wireless_interface_option(UCI_IEEE1905, interfaces_names[i], "encryption", enc); @@ -769,8 +763,8 @@ static bool registrar_init(bool enabled) } } - if (gs_trigger_wsc_renew != -1) { - INFO("## WSC renew is required"); + if (gs_trigger_wsc_renew != 0) { + INFO("## WSC renew is required (%d)##", gs_trigger_wsc_renew); } PLATFORM_FREE_LIST_OF_1905_INTERFACES(interfaces_names, interfaces_nr); @@ -1159,17 +1153,17 @@ INT8U start1905AL(bool registrar_enabled) _triggerAPSearchProcess(true); // Trigger Auto configuration renew - if (gs_trigger_wsc_renew != -1) { - if (gs_trigger_wsc_renew & IEEE80211_FREQUENCY_BAND_2_4_GHZ) + if (gs_trigger_wsc_renew) { + if (BIT(IEEE80211_FREQUENCY_BAND_2_4_GHZ, gs_trigger_wsc_renew)) send1905APAutoconfigurationRenewPacket(IEEE80211_FREQUENCY_BAND_2_4_GHZ); - if (gs_trigger_wsc_renew & IEEE80211_FREQUENCY_BAND_5_GHZ) + if (BIT(IEEE80211_FREQUENCY_BAND_5_GHZ, gs_trigger_wsc_renew)) send1905APAutoconfigurationRenewPacket(IEEE80211_FREQUENCY_BAND_5_GHZ); - if (gs_trigger_wsc_renew & IEEE80211_FREQUENCY_BAND_60_GHZ) + if (BIT(IEEE80211_FREQUENCY_BAND_60_GHZ, gs_trigger_wsc_renew)) send1905APAutoconfigurationRenewPacket(IEEE80211_FREQUENCY_BAND_60_GHZ); - gs_trigger_wsc_renew = -1; + gs_trigger_wsc_renew = 0; } break; } diff --git a/src/al_recv.c b/src/al_recv.c index a3fc6a9630f05b67954305bb1f63328885d7413a..9688f38a376f742adcd2b7fd7d043a7c1977d893 100644 --- a/src/al_recv.c +++ b/src/al_recv.c @@ -1350,8 +1350,26 @@ INT8U process1905Cmdu(struct cmdu_cstruct *c, INT8U *receiving_interface_addr, I continue; } - if (ap_freq_band == supported_freq_band) { - platform_clear_bssid(ifs_names[i]); + platform_clear_bssid(ifs_names[i]); + PLATFORM_FREE_1905_INTERFACE_INFO(x); + } + + for (i = 0; i < ifs_nr; i++) { + + // Obtain WSC-M1 and send the WSC TLV + struct interfaceInfo *x; + uint8_t ap_freq_band; + + x = PLATFORM_GET_1905_INTERFACE_INFO(ifs_names[i]); + if (x == NULL) { + WARNING("Could not retrieve info of interface %s", ifs_names[i]); + continue; + } + + if (false == get_freq_band_from_media_type(x->interface_type, &ap_freq_band)) { + // non wireless interface continue + PLATFORM_FREE_1905_INTERFACE_INFO(x); + continue; } if (wscBuildM1(ifs_names[i], &m1, &m1_size, &key)) {