hostapd: reset center_seg0_idx for 2.4 GHz
authorFelix Fietkau <nbd@nbd.name>
Sat, 2 Sep 2023 17:19:56 +0000 (19:19 +0200)
committerFelix Fietkau <nbd@nbd.name>
Sat, 2 Sep 2023 17:39:24 +0000 (19:39 +0200)
Fixes 40 MHz channel bandwidth on 2.4 GHz AP+STA

Signed-off-by: Felix Fietkau <nbd@nbd.name>
package/network/services/hostapd/src/src/ap/ucode.c
package/network/services/hostapd/src/src/utils/ucode.c

index 33160561d4d1dff8bbd1859867edc230b2a274f7..f0b4ce4eb82b0bdae78de6306998af530fd9f74f 100644 (file)
@@ -333,10 +333,15 @@ uc_hostapd_iface_start(uc_vm_t *vm, size_t nargs)
                conf->channel = intval;
        if ((intval = ucv_int64_get(ucv_object_get(info, "sec_channel", NULL))) && !errno)
                conf->secondary_channel = intval;
-       if ((intval = ucv_int64_get(ucv_object_get(info, "center_seg0_idx", NULL))) && !errno)
+
+       intval = ucv_int64_get(ucv_object_get(info, "center_seg0_idx", NULL));
+       if (!errno)
                hostapd_set_oper_centr_freq_seg0_idx(conf, intval);
-       if ((intval = ucv_int64_get(ucv_object_get(info, "center_seg1_idx", NULL))) && !errno)
+
+       intval = ucv_int64_get(ucv_object_get(info, "center_seg1_idx", NULL));
+       if (!errno)
                hostapd_set_oper_centr_freq_seg1_idx(conf, intval);
+
        intval = ucv_int64_get(ucv_object_get(info, "oper_chwidth", NULL));
        if (!errno)
                hostapd_set_oper_chwidth(conf, intval);
index 44169f0bf0a6ff84e1324228862d287804970b16..896ef46e1f6f13e2b25b5c38c51c285fa9587efa 100644 (file)
@@ -129,7 +129,10 @@ uc_value_t *uc_wpa_freq_info(uc_vm_t *vm, size_t nargs)
        tmp_channel &= ~((8 << width) - 1);
        center_idx = tmp_channel + center_ofs + (4 << width) - 1;
 
-       ucv_object_add(ret, "center_seg0_idx", ucv_int64_new(center_idx));
+       if (freq_val < 3000)
+               ucv_object_add(ret, "center_seg0_idx", ucv_int64_new(0));
+       else
+               ucv_object_add(ret, "center_seg0_idx", ucv_int64_new(center_idx));
        center_idx = (center_idx - channel) * 5 + freq_val;
        ucv_object_add(ret, "center_freq1", ucv_int64_new(center_idx));