]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
hostapd: Make hostapd_interface_init_bss() available externally
authorKyeyoon Park <kyeyoonp@qca.qualcomm.com>
Tue, 29 Oct 2013 14:29:49 +0000 (16:29 +0200)
committerJouni Malinen <j@w1.fi>
Thu, 31 Oct 2013 20:00:31 +0000 (22:00 +0200)
Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>

hostapd/main.c
src/ap/hostapd.c
src/ap/hostapd.h

index 29afec9dade4b3cee290d73379f293bdaf59bac1..d6f9258bc2c2ee96c8296bf8708bc7f6a4e35ba6 100644 (file)
@@ -273,103 +273,6 @@ hostapd_interface_init(struct hapd_interfaces *interfaces,
 }
 
 
-static struct hostapd_iface *
-hostapd_interface_init_bss(struct hapd_interfaces *interfaces, const char *phy,
-                          const char *config_fname, int debug)
-{
-       struct hostapd_iface *new_iface = NULL, *iface = NULL;
-       struct hostapd_data *hapd;
-       int k;
-       size_t i, bss_idx;
-
-       if (!phy || !*phy)
-               return NULL;
-
-       for (i = 0; i < interfaces->count; i++) {
-               if (os_strcmp(interfaces->iface[i]->phy, phy) == 0) {
-                       iface = interfaces->iface[i];
-                       break;
-               }
-       }
-
-       wpa_printf(MSG_ERROR, "Configuration file: %s (phy %s)%s",
-                  config_fname, phy, iface ? "" : " --> new PHY");
-       if (iface) {
-               struct hostapd_config *conf;
-               struct hostapd_bss_config **tmp_conf;
-               struct hostapd_data **tmp_bss;
-               struct hostapd_bss_config *bss;
-
-               /* Add new BSS to existing iface */
-               conf = hostapd_config_read(config_fname);
-               if (conf == NULL)
-                       return NULL;
-               if (conf->num_bss > 1) {
-                       wpa_printf(MSG_ERROR, "Multiple BSSes specified in BSS-config");
-                       hostapd_config_free(conf);
-                       return NULL;
-               }
-
-               tmp_conf = os_realloc_array(
-                       iface->conf->bss, iface->conf->num_bss + 1,
-                       sizeof(struct hostapd_bss_config *));
-               tmp_bss = os_realloc_array(iface->bss, iface->num_bss + 1,
-                                          sizeof(struct hostapd_data *));
-               if (tmp_bss)
-                       iface->bss = tmp_bss;
-               if (tmp_conf) {
-                       iface->conf->bss = tmp_conf;
-                       iface->conf->last_bss = tmp_conf[0];
-               }
-               if (tmp_bss == NULL || tmp_conf == NULL) {
-                       hostapd_config_free(conf);
-                       return NULL;
-               }
-               bss = iface->conf->bss[iface->conf->num_bss] = conf->bss[0];
-               iface->conf->num_bss++;
-
-               hapd = hostapd_alloc_bss_data(iface, iface->conf, bss);
-               if (hapd == NULL) {
-                       iface->conf->num_bss--;
-                       hostapd_config_free(conf);
-                       return NULL;
-               }
-               iface->conf->last_bss = bss;
-               iface->bss[iface->num_bss] = hapd;
-               hapd->msg_ctx = hapd;
-
-               bss_idx = iface->num_bss++;
-               conf->num_bss--;
-               conf->bss[0] = NULL;
-               hostapd_config_free(conf);
-       } else {
-               /* Add a new iface with the first BSS */
-               new_iface = iface = hostapd_init(interfaces, config_fname);
-               if (!iface)
-                       return NULL;
-               os_strlcpy(iface->phy, phy, sizeof(iface->phy));
-               iface->interfaces = interfaces;
-               bss_idx = 0;
-       }
-
-       for (k = 0; k < debug; k++) {
-               if (iface->bss[bss_idx]->conf->logger_stdout_level > 0)
-                       iface->bss[bss_idx]->conf->logger_stdout_level--;
-       }
-
-       if (iface->conf->bss[bss_idx]->iface[0] == '\0' &&
-           !hostapd_drv_none(iface->bss[bss_idx])) {
-               wpa_printf(MSG_ERROR, "Interface name not specified in %s",
-                          config_fname);
-               if (new_iface)
-                       hostapd_interface_deinit_free(new_iface);
-               return NULL;
-       }
-
-       return iface;
-}
-
-
 static int hostapd_interface_init2(struct hostapd_iface *iface)
 {
        if (iface->init_done)
index 89cdc528b1ce44d417a6ab0d73c2b0cdc0b8c0db..88e44f537f7a9e893ab8288928a8379502f2b716 100644 (file)
@@ -1212,6 +1212,103 @@ fail:
 }
 
 
+struct hostapd_iface *
+hostapd_interface_init_bss(struct hapd_interfaces *interfaces, const char *phy,
+                          const char *config_fname, int debug)
+{
+       struct hostapd_iface *new_iface = NULL, *iface = NULL;
+       struct hostapd_data *hapd;
+       int k;
+       size_t i, bss_idx;
+
+       if (!phy || !*phy)
+               return NULL;
+
+       for (i = 0; i < interfaces->count; i++) {
+               if (os_strcmp(interfaces->iface[i]->phy, phy) == 0) {
+                       iface = interfaces->iface[i];
+                       break;
+               }
+       }
+
+       wpa_printf(MSG_ERROR, "Configuration file: %s (phy %s)%s",
+                  config_fname, phy, iface ? "" : " --> new PHY");
+       if (iface) {
+               struct hostapd_config *conf;
+               struct hostapd_bss_config **tmp_conf;
+               struct hostapd_data **tmp_bss;
+               struct hostapd_bss_config *bss;
+
+               /* Add new BSS to existing iface */
+               conf = interfaces->config_read_cb(config_fname);
+               if (conf == NULL)
+                       return NULL;
+               if (conf->num_bss > 1) {
+                       wpa_printf(MSG_ERROR, "Multiple BSSes specified in BSS-config");
+                       hostapd_config_free(conf);
+                       return NULL;
+               }
+
+               tmp_conf = os_realloc_array(
+                       iface->conf->bss, iface->conf->num_bss + 1,
+                       sizeof(struct hostapd_bss_config *));
+               tmp_bss = os_realloc_array(iface->bss, iface->num_bss + 1,
+                                          sizeof(struct hostapd_data *));
+               if (tmp_bss)
+                       iface->bss = tmp_bss;
+               if (tmp_conf) {
+                       iface->conf->bss = tmp_conf;
+                       iface->conf->last_bss = tmp_conf[0];
+               }
+               if (tmp_bss == NULL || tmp_conf == NULL) {
+                       hostapd_config_free(conf);
+                       return NULL;
+               }
+               bss = iface->conf->bss[iface->conf->num_bss] = conf->bss[0];
+               iface->conf->num_bss++;
+
+               hapd = hostapd_alloc_bss_data(iface, iface->conf, bss);
+               if (hapd == NULL) {
+                       iface->conf->num_bss--;
+                       hostapd_config_free(conf);
+                       return NULL;
+               }
+               iface->conf->last_bss = bss;
+               iface->bss[iface->num_bss] = hapd;
+               hapd->msg_ctx = hapd;
+
+               bss_idx = iface->num_bss++;
+               conf->num_bss--;
+               conf->bss[0] = NULL;
+               hostapd_config_free(conf);
+       } else {
+               /* Add a new iface with the first BSS */
+               new_iface = iface = hostapd_init(interfaces, config_fname);
+               if (!iface)
+                       return NULL;
+               os_strlcpy(iface->phy, phy, sizeof(iface->phy));
+               iface->interfaces = interfaces;
+               bss_idx = 0;
+       }
+
+       for (k = 0; k < debug; k++) {
+               if (iface->bss[bss_idx]->conf->logger_stdout_level > 0)
+                       iface->bss[bss_idx]->conf->logger_stdout_level--;
+       }
+
+       if (iface->conf->bss[bss_idx]->iface[0] == '\0' &&
+           !hostapd_drv_none(iface->bss[bss_idx])) {
+               wpa_printf(MSG_ERROR, "Interface name not specified in %s",
+                          config_fname);
+               if (new_iface)
+                       hostapd_interface_deinit_free(new_iface);
+               return NULL;
+       }
+
+       return iface;
+}
+
+
 void hostapd_interface_deinit_free(struct hostapd_iface *iface)
 {
        const struct wpa_driver_ops *driver;
index 35317c23aa6dce1944fdbf125060213613e8e423..bae4d0b110473e90bbfeb9f3f3a88ea332161b0a 100644 (file)
@@ -351,6 +351,9 @@ void hostapd_interface_deinit(struct hostapd_iface *iface);
 void hostapd_interface_free(struct hostapd_iface *iface);
 struct hostapd_iface * hostapd_init(struct hapd_interfaces *interfaces,
                                    const char *config_file);
+struct hostapd_iface *
+hostapd_interface_init_bss(struct hapd_interfaces *interfaces, const char *phy,
+                          const char *config_fname, int debug);
 void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
                           int reassoc);
 void hostapd_interface_deinit_free(struct hostapd_iface *iface);