#Hostapd之main函数(2)

main函数->hostapd_interface_init

4. 注册timeout,clean up的间隔(不重要)

eloop_register_timeout(HOSTAPD_CLEANUP_INTERVAL, 0,
                   hostapd_periodic, &interfaces, NULL);

hostapd_periodic->hostapd_for_each_interface->hostapd_periodic_call ->hostapd_periodic_iface

void hostapd_periodic_iface(struct hostapd_iface *iface)
{
    size_t i;

    ap_list_timer(iface);

    for (i = 0; i < iface->num_bss; i++) {
        struct hostapd_data *hapd = iface->bss[i];

        if (!hapd->started)
            continue;

#ifndef CONFIG_NO_RADIUS
        hostapd_acl_expire(hapd);
#endif /* CONFIG_NO_RADIUS */
    }
}

5. 有限状态机的初始化(什么时候为真?)

if (fst_global_init()) {
        wpa_printf(MSG_ERROR,
               "Failed to initialize global FST context");
        goto out;
    }

#if defined(CONFIG_FST) && defined(CONFIG_CTRL_IFACE)
    if (!fst_global_add_ctrl(fst_ctrl_cli))
        wpa_printf(MSG_WARNING, "Failed to add CLI FST ctrl");
#endif /* CONFIG_FST && CONFIG_CTRL_IFACE */

6. interface 初始化过程
对each iface执行初始化

    for (i = 0; i < interfaces.count; i++) {
        interfaces.iface[i] = hostapd_interface_init(&interfaces,
                                 argv[optind + i],
                                 debug);
        if (!interfaces.iface[i]) {
            wpa_printf(MSG_ERROR, "Failed to initialize interface");
            goto out;
        }
    }

hostapd_interface_init执行初始化操作,

static struct hostapd_iface *
hostapd_interface_init(struct hapd_interfaces *interfaces,
               const char *config_fname, int debug)
{
    struct hostapd_iface *iface;//[1]
    int k;

    wpa_printf(MSG_ERROR, "Configuration file: %s", config_fname);
    iface = hostapd_init(interfaces, config_fname);//[2]
    if (!iface)
        return NULL;
    iface->interfaces = interfaces;

    for (k = 0; k < debug; k++) {
        if (iface->bss[0]->conf->logger_stdout_level > 0)
            iface->bss[0]->conf->logger_stdout_level--;
    }

    if (iface->conf->bss[0]->iface[0] == '\0' &&
        !hostapd_drv_none(iface->bss[0])) {
        wpa_printf(MSG_ERROR, "Interface name not specified in %s",
               config_fname);
        hostapd_interface_deinit_free(iface);//[3]
        return NULL;
    }

    return iface;
}

[1]
struct hostapd_iface (src/ap/hostapd.h)。在这个数据结构中,主要有以下字段:


/**
 * struct hostapd_iface - hostapd per-interface data structure
 */
struct hostapd_iface {
    struct hapd_interfaces *interfaces;
    void *owner;
    char *config_fname;
    struct hostapd_config *conf;
    char phy[16]; /* Name of the PHY (radio) */

    enum hostapd_iface_state {
        HAPD_IFACE_UNINITIALIZED,
        HAPD_IFACE_DISABLED,
        HAPD_IFACE_COUNTRY_UPDATE,
        HAPD_IFACE_ACS,
        HAPD_IFACE_HT_SCAN,
        HAPD_IFACE_DFS,
        HAPD_IFACE_ENABLED
    } state;

1) struct hostapd_config: 保存对网络接口的配置(从配置文件hostapd.conf中加载)


/**
 * struct hostapd_config - Per-radio interface configuration
 */
struct hostapd_config {
    struct hostapd_bss_config **bss, *last_bss;
    size_t num_bss;

    u16 beacon_int;
    int rts_threshold;
    int fragm_threshold;
    u8 send_probe_response;
    u8 channel;
    u8 acs;
    struct wpa_freq_range_list acs_ch_list;
    enum hostapd_hw_mode hw_mode; /* HOSTAPD_MODE_IEEE80211A, .. */
    enum {
        LONG_PREAMBLE = 0,
        SHORT_PREAMBLE = 1
    } preamble;

    int *supported_rates;
    int *basic_rates;

    const struct wpa_driver_ops *driver;
    char *driver_params;

    int ap_table_max_size;
    int ap_table_expiration_time;

    unsigned int track_sta_max_num;
    unsigned int track_sta_max_age;

    char country[3]; /* first two octets: country code as described in
              * ISO/IEC 3166-1. Third octet:
              * ' ' (ascii 32): all environments
              * 'O': Outdoor environemnt only
              * 'I': Indoor environment only
              */

    int ieee80211d;

    int ieee80211h; /* DFS */

    /*
     * Local power constraint is an octet encoded as an unsigned integer in
     * units of decibels. Invalid value -1 indicates that Power Constraint
     * element will not be added.
     */
    int local_pwr_constraint;

    /* Control Spectrum Management bit */
    int spectrum_mgmt_required;

    struct hostapd_tx_queue_params tx_queue[NUM_TX_QUEUES];

    /*
     * WMM AC parameters, in same order as 802.1D, i.e.
     * 0 = BE (best effort)
     * 1 = BK (background)
     * 2 = VI (video)
     * 3 = VO (voice)
     */
    struct hostapd_wmm_ac_params wmm_ac_params[4];

    int ht_op_mode_fixed;
    u16 ht_capab;
    int ieee80211n;
    int secondary_channel;
    int no_pri_sec_switch;
    int require_ht;
    int obss_interval;
    u32 vht_capab;
    int ieee80211ac;
    int require_vht;
    u8 vht_oper_chwidth;
    u8 vht_oper_centr_freq_seg0_idx;
    u8 vht_oper_centr_freq_seg1_idx;

#ifdef CONFIG_FST
    struct fst_iface_cfg fst_cfg;
#endif /* CONFIG_FST */

#ifdef CONFIG_P2P
    u8 p2p_go_ctwindow;
#endif /* CONFIG_P2P */

#ifdef CONFIG_TESTING_OPTIONS
    double ignore_probe_probability;
    double ignore_auth_probability;
    double ignore_assoc_probability;
    double ignore_reassoc_probability;
    double corrupt_gtk_rekey_mic_probability;
#endif /* CONFIG_TESTING_OPTIONS */

#ifdef CONFIG_ACS
    unsigned int acs_num_scans;
    struct acs_bias {
        int channel;
        double bias;
    } *acs_chan_bias;
    unsigned int num_acs_chan_bias;
#endif /* CONFIG_ACS */
};

sizt_t num_bss: 此接口下辖的BSS 个数
struct hostapd_data **bss:BSS 列表,描述各BSS 的配置

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值