360-ctrl_iface_reload.patch 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. --- a/hostapd/ctrl_iface.c
  2. +++ b/hostapd/ctrl_iface.c
  3. @@ -55,6 +55,7 @@
  4. #include "fst/fst_ctrl_iface.h"
  5. #include "config_file.h"
  6. #include "ctrl_iface.h"
  7. +#include "config_file.h"
  8. #define HOSTAPD_CLI_DUP_VALUE_MAX_LEN 256
  9. @@ -73,6 +74,7 @@ static void hostapd_ctrl_iface_send(stru
  10. enum wpa_msg_type type,
  11. const char *buf, size_t len);
  12. +static char *reload_opts = NULL;
  13. static int hostapd_ctrl_iface_attach(struct hostapd_data *hapd,
  14. struct sockaddr_storage *from,
  15. @@ -124,6 +126,61 @@ static int hostapd_ctrl_iface_new_sta(st
  16. return 0;
  17. }
  18. +static char *get_option(char *opt, char *str)
  19. +{
  20. + int len = strlen(str);
  21. +
  22. + if (!strncmp(opt, str, len))
  23. + return opt + len;
  24. + else
  25. + return NULL;
  26. +}
  27. +
  28. +static struct hostapd_config *hostapd_ctrl_iface_config_read(const char *fname)
  29. +{
  30. + struct hostapd_config *conf;
  31. + char *opt, *val;
  32. +
  33. + conf = hostapd_config_read(fname);
  34. + if (!conf)
  35. + return NULL;
  36. +
  37. + for (opt = strtok(reload_opts, " ");
  38. + opt;
  39. + opt = strtok(NULL, " ")) {
  40. +
  41. + if ((val = get_option(opt, "channel=")))
  42. + conf->channel = atoi(val);
  43. + else if ((val = get_option(opt, "ht_capab=")))
  44. + conf->ht_capab = atoi(val);
  45. + else if ((val = get_option(opt, "ht_capab_mask=")))
  46. + conf->ht_capab &= atoi(val);
  47. + else if ((val = get_option(opt, "sec_chan=")))
  48. + conf->secondary_channel = atoi(val);
  49. + else if ((val = get_option(opt, "hw_mode=")))
  50. + conf->hw_mode = atoi(val);
  51. + else if ((val = get_option(opt, "ieee80211n=")))
  52. + conf->ieee80211n = atoi(val);
  53. + else
  54. + break;
  55. + }
  56. +
  57. + return conf;
  58. +}
  59. +
  60. +static int hostapd_ctrl_iface_update(struct hostapd_data *hapd, char *txt)
  61. +{
  62. + struct hostapd_config * (*config_read_cb)(const char *config_fname);
  63. + struct hostapd_iface *iface = hapd->iface;
  64. +
  65. + config_read_cb = iface->interfaces->config_read_cb;
  66. + iface->interfaces->config_read_cb = hostapd_ctrl_iface_config_read;
  67. + reload_opts = txt;
  68. +
  69. + hostapd_reload_config(iface);
  70. +
  71. + iface->interfaces->config_read_cb = config_read_cb;
  72. +}
  73. #ifdef CONFIG_IEEE80211W
  74. #ifdef NEED_AP_MLME
  75. @@ -2620,6 +2677,8 @@ static int hostapd_ctrl_iface_receive_pr
  76. } else if (os_strncmp(buf, "VENDOR ", 7) == 0) {
  77. reply_len = hostapd_ctrl_iface_vendor(hapd, buf + 7, reply,
  78. reply_size);
  79. + } else if (os_strncmp(buf, "UPDATE ", 7) == 0) {
  80. + hostapd_ctrl_iface_update(hapd, buf + 7);
  81. } else if (os_strcmp(buf, "ERP_FLUSH") == 0) {
  82. ieee802_1x_erp_flush(hapd);
  83. #ifdef RADIUS_SERVER
  84. --- a/src/ap/ctrl_iface_ap.c
  85. +++ b/src/ap/ctrl_iface_ap.c
  86. @@ -624,7 +624,13 @@ int hostapd_parse_csa_settings(const cha
  87. int hostapd_ctrl_iface_stop_ap(struct hostapd_data *hapd)
  88. {
  89. - return hostapd_drv_stop_ap(hapd);
  90. + struct hostapd_iface *iface = hapd->iface;
  91. + int i;
  92. +
  93. + for (i = 0; i < iface->num_bss; i++)
  94. + hostapd_drv_stop_ap(iface->bss[i]);
  95. +
  96. + return 0;
  97. }