]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Add return value to ACL functions
authorChaoli Zhou <quic_zchaoli@quicinc.com>
Thu, 24 Mar 2022 07:19:25 +0000 (15:19 +0800)
committerJouni Malinen <j@w1.fi>
Thu, 24 Mar 2022 18:53:28 +0000 (20:53 +0200)
While these do not return error code within the current hostapd
implementation, matching functions in wpa_supplicant AP functionality
will have an error case and using consistent return type will make the
control interface code more consistent.

In addition, export hostapd_set_acl() in preparation for the
wpa_supplicant control interface implementation extension.

Signed-off-by: Chaoli Zhou <quic_zchaoli@quicinc.com>
src/ap/ctrl_iface_ap.c
src/ap/ctrl_iface_ap.h
src/ap/hostapd.c
src/ap/hostapd.h

index 6af941058eb00bc5c0888eabcaea32f086a6e74b..1bc1b0b3bb60086a7b8a5cb747e3f1ab65427c08 100644 (file)
@@ -1357,13 +1357,13 @@ int hostapd_ctrl_iface_acl_add_mac(struct mac_acl_entry **acl, int *num,
 }
 
 
-void hostapd_disassoc_accept_mac(struct hostapd_data *hapd)
+int hostapd_disassoc_accept_mac(struct hostapd_data *hapd)
 {
        struct sta_info *sta;
        struct vlan_description vlan_id;
 
        if (hapd->conf->macaddr_acl != DENY_UNLESS_ACCEPTED)
-               return;
+               return 0;
 
        for (sta = hapd->sta_list; sta; sta = sta->next) {
                if (!hostapd_maclist_found(hapd->conf->accept_mac,
@@ -1374,10 +1374,12 @@ void hostapd_disassoc_accept_mac(struct hostapd_data *hapd)
                        ap_sta_disconnect(hapd, sta, sta->addr,
                                          WLAN_REASON_UNSPECIFIED);
        }
+
+       return 0;
 }
 
 
-void hostapd_disassoc_deny_mac(struct hostapd_data *hapd)
+int hostapd_disassoc_deny_mac(struct hostapd_data *hapd)
 {
        struct sta_info *sta;
        struct vlan_description vlan_id;
@@ -1391,4 +1393,6 @@ void hostapd_disassoc_deny_mac(struct hostapd_data *hapd)
                        ap_sta_disconnect(hapd, sta, sta->addr,
                                          WLAN_REASON_UNSPECIFIED);
        }
+
+       return 0;
 }
index ac2e26d0119a7afafdb86bed5316e4e698aa3a56..614f0426c1a563168bd1e44e49a20c650035a26c 100644 (file)
@@ -51,7 +51,7 @@ void hostapd_ctrl_iface_acl_clear_list(struct mac_acl_entry **acl,
                                       int *num);
 int hostapd_ctrl_iface_acl_show_mac(struct mac_acl_entry *acl, int num,
                                    char *buf, size_t buflen);
-void hostapd_disassoc_accept_mac(struct hostapd_data *hapd);
-void hostapd_disassoc_deny_mac(struct hostapd_data *hapd);
+int hostapd_disassoc_accept_mac(struct hostapd_data *hapd);
+int hostapd_disassoc_deny_mac(struct hostapd_data *hapd);
 
 #endif /* CTRL_IFACE_AP_H */
index 4b88641a2dde9241b709b85f7c4920687decae11..81488a2ef2809005055467ccb670a72e1abb51f5 100644 (file)
@@ -1458,14 +1458,14 @@ static int hostapd_set_acl_list(struct hostapd_data *hapd,
 }
 
 
-static void hostapd_set_acl(struct hostapd_data *hapd)
+int hostapd_set_acl(struct hostapd_data *hapd)
 {
        struct hostapd_config *conf = hapd->iconf;
-       int err;
+       int err = 0;
        u8 accept_acl;
 
        if (hapd->iface->drv_max_acl_mac_addrs == 0)
-               return;
+               return 0;
 
        if (conf->bss[0]->macaddr_acl == DENY_UNLESS_ACCEPTED) {
                accept_acl = 1;
@@ -1474,7 +1474,7 @@ static void hostapd_set_acl(struct hostapd_data *hapd)
                                           accept_acl);
                if (err) {
                        wpa_printf(MSG_DEBUG, "Failed to set accept acl");
-                       return;
+                       return -1;
                }
        } else if (conf->bss[0]->macaddr_acl == ACCEPT_UNLESS_DENIED) {
                accept_acl = 0;
@@ -1483,9 +1483,10 @@ static void hostapd_set_acl(struct hostapd_data *hapd)
                                           accept_acl);
                if (err) {
                        wpa_printf(MSG_DEBUG, "Failed to set deny acl");
-                       return;
+                       return -1;
                }
        }
+       return err;
 }
 
 
index b30aa2ff60fbf1f308b6c5c2c9ba9466d7db73de..6c8723baf1a8a6ddc9b15992d47e03cb4aedaeea 100644 (file)
@@ -709,4 +709,6 @@ void fst_hostapd_fill_iface_obj(struct hostapd_data *hapd,
                                struct fst_wpa_obj *iface_obj);
 #endif /* CONFIG_FST */
 
+int hostapd_set_acl(struct hostapd_data *hapd);
+
 #endif /* HOSTAPD_H */