libpcap: Fix build when PACKAGECONFIG ipv6 is not enabled
[15.05/openwrt.git] / package / network / services / hostapd / patches / 360-ctrl_iface_reload.patch
1 --- a/hostapd/ctrl_iface.c
2 +++ b/hostapd/ctrl_iface.c
3 @@ -45,6 +45,7 @@
4  #include "wps/wps.h"
5  #include "config_file.h"
6  #include "ctrl_iface.h"
7 +#include "config_file.h"
8  
9  
10  struct wpa_ctrl_dst {
11 @@ -55,6 +56,7 @@ struct wpa_ctrl_dst {
12         int errors;
13  };
14  
15 +static char *reload_opts = NULL;
16  
17  static void hostapd_ctrl_iface_send(struct hostapd_data *hapd, int level,
18                                     const char *buf, size_t len);
19 @@ -164,6 +166,61 @@ static int hostapd_ctrl_iface_new_sta(st
20         return 0;
21  }
22  
23 +static char *get_option(char *opt, char *str)
24 +{
25 +       int len = strlen(str);
26 +
27 +       if (!strncmp(opt, str, len))
28 +               return opt + len;
29 +       else
30 +               return NULL;
31 +}
32 +
33 +static struct hostapd_config *hostapd_ctrl_iface_config_read(const char *fname)
34 +{
35 +       struct hostapd_config *conf;
36 +       char *opt, *val;
37 +
38 +       conf = hostapd_config_read(fname);
39 +       if (!conf)
40 +               return NULL;
41 +
42 +       for (opt = strtok(reload_opts, " ");
43 +            opt;
44 +                opt = strtok(NULL, " ")) {
45 +
46 +               if ((val = get_option(opt, "channel=")))
47 +                       conf->channel = atoi(val);
48 +               else if ((val = get_option(opt, "ht_capab=")))
49 +                       conf->ht_capab = atoi(val);
50 +               else if ((val = get_option(opt, "ht_capab_mask=")))
51 +                       conf->ht_capab &= atoi(val);
52 +               else if ((val = get_option(opt, "sec_chan=")))
53 +                       conf->secondary_channel = atoi(val);
54 +               else if ((val = get_option(opt, "hw_mode=")))
55 +                       conf->hw_mode = atoi(val);
56 +               else if ((val = get_option(opt, "ieee80211n=")))
57 +                       conf->ieee80211n = atoi(val);
58 +               else
59 +                       break;
60 +       }
61 +
62 +       return conf;
63 +}
64 +
65 +static int hostapd_ctrl_iface_update(struct hostapd_data *hapd, char *txt)
66 +{
67 +       struct hostapd_config * (*config_read_cb)(const char *config_fname);
68 +       struct hostapd_iface *iface = hapd->iface;
69 +
70 +       config_read_cb = iface->interfaces->config_read_cb;
71 +       iface->interfaces->config_read_cb = hostapd_ctrl_iface_config_read;
72 +       reload_opts = txt;
73 +
74 +       hostapd_reload_config(iface);
75 +
76 +       iface->interfaces->config_read_cb = config_read_cb;
77 +}
78  
79  #ifdef CONFIG_IEEE80211W
80  #ifdef NEED_AP_MLME
81 @@ -2086,6 +2143,8 @@ static void hostapd_ctrl_iface_receive(i
82         } else if (os_strncmp(buf, "VENDOR ", 7) == 0) {
83                 reply_len = hostapd_ctrl_iface_vendor(hapd, buf + 7, reply,
84                                                       reply_size);
85 +       } else if (os_strncmp(buf, "UPDATE ", 7) == 0) {
86 +               hostapd_ctrl_iface_update(hapd, buf + 7);
87         } else if (os_strcmp(buf, "ERP_FLUSH") == 0) {
88                 ieee802_1x_erp_flush(hapd);
89  #ifdef RADIUS_SERVER
90 --- a/src/ap/ctrl_iface_ap.c
91 +++ b/src/ap/ctrl_iface_ap.c
92 @@ -541,5 +541,11 @@ int hostapd_parse_csa_settings(const cha
93  
94  int hostapd_ctrl_iface_stop_ap(struct hostapd_data *hapd)
95  {
96 -       return hostapd_drv_stop_ap(hapd);
97 +       struct hostapd_iface *iface = hapd->iface;
98 +       int i;
99 +
100 +       for (i = 0; i < iface->num_bss; i++)
101 +               hostapd_drv_stop_ap(iface->bss[i]);
102 +
103 +       return 0;
104  }